Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / tab_contents / chrome_web_contents_view_delegate_views.h
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_VIEWS_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_
7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "components/renderer_context_menu/context_menu_delegate.h"
12 #include "content/public/browser/web_contents_view_delegate.h"
13
14 class RenderViewContextMenu;
15 class RenderViewContextMenuViews;
16
17 namespace aura {
18 class Window;
19 }
20
21 namespace content {
22 class WebContents;
23 class WebDragDestDelegate;
24 class RenderFrameHost;
25 }
26
27 namespace views {
28 class FocusManager;
29 class Widget;
30 }
31
32 // A chrome specific class that extends WebContentsViewWin with features like
33 // focus management, which live in chrome.
34 class ChromeWebContentsViewDelegateViews
35     : public content::WebContentsViewDelegate,
36       public ContextMenuDelegate {
37  public:
38   explicit ChromeWebContentsViewDelegateViews(
39       content::WebContents* web_contents);
40   virtual ~ChromeWebContentsViewDelegateViews();
41
42   // Overridden from WebContentsViewDelegate:
43   virtual content::WebDragDestDelegate* GetDragDestDelegate() OVERRIDE;
44   virtual void StoreFocus() OVERRIDE;
45   virtual void RestoreFocus() OVERRIDE;
46   virtual bool Focus() OVERRIDE;
47   virtual void TakeFocus(bool reverse) OVERRIDE;
48   virtual void ShowContextMenu(
49       content::RenderFrameHost* render_frame_host,
50       const content::ContextMenuParams& params) OVERRIDE;
51   virtual void SizeChanged(const gfx::Size& size) OVERRIDE;
52
53   // Overridden from ContextMenuDelegate.
54   virtual scoped_ptr<RenderViewContextMenu> BuildMenu(
55       content::WebContents* web_contents,
56       const content::ContextMenuParams& params) OVERRIDE;
57   virtual void ShowMenu(scoped_ptr<RenderViewContextMenu> menu) OVERRIDE;
58
59  private:
60   aura::Window* GetActiveNativeView();
61   views::Widget* GetTopLevelWidget();
62   views::FocusManager* GetFocusManager();
63   void SetInitialFocus();
64
65   // The id used in the ViewStorage to store the last focused view.
66   int last_focused_view_storage_id_;
67
68   // The context menu is reset every time we show it, but we keep a pointer to
69   // between uses so that it won't go out of scope before we're done with it.
70   scoped_ptr<RenderViewContextMenuViews> context_menu_;
71
72   // The chrome specific delegate that receives events from WebDragDest.
73   scoped_ptr<content::WebDragDestDelegate> bookmark_handler_;
74
75   content::WebContents* web_contents_;
76
77   DISALLOW_COPY_AND_ASSIGN(ChromeWebContentsViewDelegateViews);
78 };
79
80 #endif  // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_