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 "components/renderer_context_menu/context_menu_delegate.h"
12 #include "content/public/browser/web_contents_view_delegate.h"
14 class LinkDisambiguationPopup;
15 class RenderViewContextMenuBase;
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 ~ChromeWebContentsViewDelegateViews() override;
42 // Overridden from WebContentsViewDelegate:
43 content::WebDragDestDelegate* GetDragDestDelegate() override;
44 void StoreFocus() override;
45 void RestoreFocus() override;
46 bool Focus() override;
47 void TakeFocus(bool reverse) override;
48 void ShowContextMenu(content::RenderFrameHost* render_frame_host,
49 const content::ContextMenuParams& params) override;
50 void SizeChanged(const gfx::Size& size) override;
51 void ShowDisambiguationPopup(
52 const gfx::Rect& target_rect,
53 const SkBitmap& zoomed_bitmap,
54 const gfx::NativeView content,
55 const base::Callback<void(ui::GestureEvent*)>& gesture_cb,
56 const base::Callback<void(ui::MouseEvent*)>& mouse_cb) override;
57 void HideDisambiguationPopup() override;
59 // Overridden from ContextMenuDelegate.
60 scoped_ptr<RenderViewContextMenuBase> BuildMenu(
61 content::WebContents* web_contents,
62 const content::ContextMenuParams& params) override;
63 void ShowMenu(scoped_ptr<RenderViewContextMenuBase> menu) override;
66 aura::Window* GetActiveNativeView();
67 views::Widget* GetTopLevelWidget();
68 views::FocusManager* GetFocusManager();
69 void SetInitialFocus();
71 // The id used in the ViewStorage to store the last focused view.
72 int last_focused_view_storage_id_;
74 // The context menu is reset every time we show it, but we keep a pointer to
75 // between uses so that it won't go out of scope before we're done with it.
76 scoped_ptr<RenderViewContextMenuBase> context_menu_;
78 // The chrome specific delegate that receives events from WebDragDest.
79 scoped_ptr<content::WebDragDestDelegate> bookmark_handler_;
81 content::WebContents* web_contents_;
83 scoped_ptr<LinkDisambiguationPopup> link_disambiguation_popup_;
85 DISALLOW_COPY_AND_ASSIGN(ChromeWebContentsViewDelegateViews);
88 #endif // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_