1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_MAC_H_
6#define CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_MAC_H_
7
8#if defined(__OBJC__)
9
10#include "base/basictypes.h"
11#include "base/memory/scoped_ptr.h"
12#include "components/renderer_context_menu/context_menu_delegate.h"
13#include "content/public/browser/web_contents_view_delegate.h"
14
15class RenderViewContextMenu;
16class RenderViewContextMenuMac;
17class WebDragBookmarkHandlerMac;
18
19namespace content {
20class RenderWidgetHostView;
21class WebContents;
22}
23
24// A chrome/ specific class that extends WebContentsViewMac with features that
25// live in chrome/.
26class ChromeWebContentsViewDelegateMac
27    : public content::WebContentsViewDelegate,
28      public ContextMenuDelegate {
29 public:
30  explicit ChromeWebContentsViewDelegateMac(content::WebContents* web_contents);
31  virtual ~ChromeWebContentsViewDelegateMac();
32
33  // Overridden from WebContentsViewDelegate:
34  virtual NSObject<RenderWidgetHostViewMacDelegate>*
35      CreateRenderWidgetHostViewDelegate(
36          content::RenderWidgetHost* render_widget_host) OVERRIDE;
37  virtual content::WebDragDestDelegate* GetDragDestDelegate() OVERRIDE;
38  virtual void ShowContextMenu(
39      content::RenderFrameHost* render_frame_host,
40      const content::ContextMenuParams& params) OVERRIDE;
41
42  // Overridden from ContextMenuDelegate.
43  virtual scoped_ptr<RenderViewContextMenu> BuildMenu(
44      content::WebContents* web_contents,
45      const content::ContextMenuParams& params) OVERRIDE;
46  virtual void ShowMenu(scoped_ptr<RenderViewContextMenu> menu) OVERRIDE;
47
48 private:
49  content::RenderWidgetHostView* GetActiveRenderWidgetHostView();
50
51  // The context menu. Callbacks are asynchronous so we need to keep it around.
52  scoped_ptr<RenderViewContextMenuMac> context_menu_;
53
54  // The chrome specific delegate that receives events from WebDragDestMac.
55  scoped_ptr<WebDragBookmarkHandlerMac> bookmark_handler_;
56
57  // The WebContents that owns the view.
58  content::WebContents* web_contents_;
59
60  DISALLOW_COPY_AND_ASSIGN(ChromeWebContentsViewDelegateMac);
61};
62
63#endif  // __OBJC__
64
65#endif  // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_MAC_H_
66