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