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.
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_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/renderer_context_menu/context_menu_delegate.h"
12 #include "content/public/browser/web_contents_view_delegate.h"
14 class RenderViewContextMenu;
15 class RenderViewContextMenuViews;
23 class WebDragDestDelegate;
24 class RenderFrameHost;
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 {
38 explicit ChromeWebContentsViewDelegateViews(
39 content::WebContents* web_contents);
40 virtual ~ChromeWebContentsViewDelegateViews();
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;
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;
60 aura::Window* GetActiveNativeView();
61 views::Widget* GetTopLevelWidget();
62 views::FocusManager* GetFocusManager();
63 void SetInitialFocus();
65 // The id used in the ViewStorage to store the last focused view.
66 int last_focused_view_storage_id_;
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_;
72 // The chrome specific delegate that receives events from WebDragDest.
73 scoped_ptr<content::WebDragDestDelegate> bookmark_handler_;
75 content::WebContents* web_contents_;
77 DISALLOW_COPY_AND_ASSIGN(ChromeWebContentsViewDelegateViews);
80 #endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_