OLD | NEW |
| (Empty) |
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_GTK_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_GTK
_H_ | |
6 #define CHROME_BROWSER_UI_GTK_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_GTK
_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "content/public/browser/web_contents_view_delegate.h" | |
11 #include "ui/base/gtk/gtk_signal.h" | |
12 #include "ui/gfx/scoped_gobject.h" | |
13 | |
14 class RenderViewContextMenuGtk; | |
15 class WebDragBookmarkHandlerGtk; | |
16 | |
17 namespace content { | |
18 class WebContents; | |
19 } | |
20 | |
21 // A chrome/ specific class that extends WebContentsViewGtk with features like | |
22 // web contents modal dialogs, which live in chrome/. | |
23 class ChromeWebContentsViewDelegateGtk | |
24 : public content::WebContentsViewDelegate { | |
25 public: | |
26 explicit ChromeWebContentsViewDelegateGtk(content::WebContents* web_contents); | |
27 virtual ~ChromeWebContentsViewDelegateGtk(); | |
28 | |
29 static ChromeWebContentsViewDelegateGtk* GetFor( | |
30 content::WebContents* web_contents); | |
31 | |
32 GtkWidget* expanded_container() { return expanded_container_; } | |
33 ui::FocusStoreGtk* focus_store() { return focus_store_; } | |
34 | |
35 // Unlike Windows, web contents modal dialogs need to collaborate with the | |
36 // WebContentsViewGtk to position the dialogs. | |
37 void AttachWebContentsModalDialog(GtkWidget* web_contents_modal_dialog); | |
38 void RemoveWebContentsModalDialog(GtkWidget* web_contents_modal_dialog); | |
39 | |
40 // Overridden from WebContentsViewDelegate: | |
41 virtual void ShowContextMenu( | |
42 content::RenderFrameHost* render_frame_host, | |
43 const content::ContextMenuParams& params) OVERRIDE; | |
44 virtual content::WebDragDestDelegate* GetDragDestDelegate() OVERRIDE; | |
45 virtual void Initialize(GtkWidget* expanded_container, | |
46 ui::FocusStoreGtk* focus_store) OVERRIDE; | |
47 virtual gfx::NativeView GetNativeView() const OVERRIDE; | |
48 virtual void Focus() OVERRIDE; | |
49 virtual gboolean OnNativeViewFocusEvent(GtkWidget* widget, | |
50 GtkDirectionType type, | |
51 gboolean* return_value) OVERRIDE; | |
52 | |
53 private: | |
54 // Sets the location of the web contents modal dialogs. | |
55 CHROMEGTK_CALLBACK_1(ChromeWebContentsViewDelegateGtk, void, | |
56 OnSetFloatingPosition, | |
57 GtkAllocation*); | |
58 | |
59 // Contains |expanded_| as its GtkBin member. | |
60 ui::ScopedGObject<GtkWidget>::Type floating_; | |
61 | |
62 // The UI for the web contents modal dialog currently displayed. This is owned | |
63 // by WebContents, not the view. | |
64 GtkWidget* web_contents_modal_dialog_; | |
65 | |
66 // The context menu is reset every time we show it, but we keep a pointer to | |
67 // between uses so that it won't go out of scope before we're done with it. | |
68 scoped_ptr<RenderViewContextMenuGtk> context_menu_; | |
69 | |
70 // The chrome specific delegate that receives events from WebDragDestGtk. | |
71 scoped_ptr<WebDragBookmarkHandlerGtk> bookmark_handler_gtk_; | |
72 | |
73 content::WebContents* web_contents_; | |
74 | |
75 GtkWidget* expanded_container_; | |
76 ui::FocusStoreGtk* focus_store_; | |
77 }; | |
78 | |
79 #endif // CHROME_BROWSER_UI_GTK_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_
GTK_H_ | |
OLD | NEW |