Update To 11.40.268.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 LinkDisambiguationPopup;
15 class RenderViewContextMenuBase;
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   ~ChromeWebContentsViewDelegateViews() override;
41
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;
58
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;
64
65  private:
66   aura::Window* GetActiveNativeView();
67   views::Widget* GetTopLevelWidget();
68   views::FocusManager* GetFocusManager();
69   void SetInitialFocus();
70
71   // The id used in the ViewStorage to store the last focused view.
72   int last_focused_view_storage_id_;
73
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_;
77
78   // The chrome specific delegate that receives events from WebDragDest.
79   scoped_ptr<content::WebDragDestDelegate> bookmark_handler_;
80
81   content::WebContents* web_contents_;
82
83   scoped_ptr<LinkDisambiguationPopup> link_disambiguation_popup_;
84
85   DISALLOW_COPY_AND_ASSIGN(ChromeWebContentsViewDelegateViews);
86 };
87
88 #endif  // CHROME_BROWSER_UI_VIEWS_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_VIEWS_H_