OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_GTK_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_GTK_H_ |
6 #define CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_GTK_DELEGATE_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "content/public/browser/web_contents_view_gtk_delegate.h" | 11 #include "content/public/browser/web_contents_view_delegate.h" |
12 #include "ui/base/gtk/gtk_signal.h" | 12 #include "ui/base/gtk/gtk_signal.h" |
13 #include "ui/base/gtk/owned_widget_gtk.h" | 13 #include "ui/base/gtk/owned_widget_gtk.h" |
14 | 14 |
15 class ConstrainedWindowGtk; | 15 class ConstrainedWindowGtk; |
16 class RenderViewContextMenuGtk; | 16 class RenderViewContextMenuGtk; |
17 class TabContents; | |
18 class WebDragBookmarkHandlerGtk; | 17 class WebDragBookmarkHandlerGtk; |
19 | 18 |
| 19 namespace content { |
| 20 class WebContents; |
| 21 } |
| 22 |
20 // A chrome/ specific class that extends TabContentsViewGtk with features like | 23 // A chrome/ specific class that extends TabContentsViewGtk with features like |
21 // constrained windows, which live in chrome/. | 24 // constrained windows, which live in chrome/. |
22 class ChromeWebContentsViewGtkDelegate | 25 class ChromeWebContentsViewDelegateGtk |
23 : public content::WebContentsViewGtkDelegate { | 26 : public content::WebContentsViewDelegate { |
24 public: | 27 public: |
25 ChromeWebContentsViewGtkDelegate(); | 28 explicit ChromeWebContentsViewDelegateGtk(content::WebContents* web_contents); |
26 virtual ~ChromeWebContentsViewGtkDelegate(); | 29 virtual ~ChromeWebContentsViewDelegateGtk(); |
27 | 30 |
28 // Unlike Windows, ConstrainedWindows need to collaborate with the | 31 // Unlike Windows, ConstrainedWindows need to collaborate with the |
29 // TabContentsViewGtk to position the dialogs. | 32 // TabContentsViewGtk to position the dialogs. |
30 void AttachConstrainedWindow(ConstrainedWindowGtk* constrained_window); | 33 void AttachConstrainedWindow(ConstrainedWindowGtk* constrained_window); |
31 void RemoveConstrainedWindow(ConstrainedWindowGtk* constrained_window); | 34 void RemoveConstrainedWindow(ConstrainedWindowGtk* constrained_window); |
32 | 35 |
33 // Overridden from WebContentsViewGtkDelegate: | 36 // Overridden from WebContentsViewDelegate: |
34 virtual void WrapView(content::TabContentsViewGtk* view) OVERRIDE; | 37 virtual void ShowContextMenu( |
| 38 const content::ContextMenuParams& params) OVERRIDE; |
| 39 virtual content::WebDragDestDelegate* GetDragDestDelegate() OVERRIDE; |
| 40 virtual void Initialize(GtkWidget* expanded_container) OVERRIDE; |
35 virtual gfx::NativeView GetNativeView() const OVERRIDE; | 41 virtual gfx::NativeView GetNativeView() const OVERRIDE; |
36 virtual void OnCreateViewForWidget() OVERRIDE; | |
37 virtual void Focus() OVERRIDE; | 42 virtual void Focus() OVERRIDE; |
38 virtual gboolean OnNativeViewFocusEvent(GtkWidget* widget, | 43 virtual gboolean OnNativeViewFocusEvent(GtkWidget* widget, |
39 GtkDirectionType type, | 44 GtkDirectionType type, |
40 gboolean* return_value) OVERRIDE; | 45 gboolean* return_value) OVERRIDE; |
41 virtual void ShowContextMenu( | |
42 const content::ContextMenuParams& params) OVERRIDE; | |
43 | 46 |
44 private: | 47 private: |
45 // Sets the location of the constrained windows. | 48 // Sets the location of the constrained windows. |
46 CHROMEGTK_CALLBACK_1(ChromeWebContentsViewGtkDelegate, void, | 49 CHROMEGTK_CALLBACK_1(ChromeWebContentsViewDelegateGtk, void, |
47 OnSetFloatingPosition, | 50 OnSetFloatingPosition, |
48 GtkAllocation*); | 51 GtkAllocation*); |
49 | 52 |
50 // Contains |expanded_| as its GtkBin member. | 53 // Contains |expanded_| as its GtkBin member. |
51 ui::OwnedWidgetGtk floating_; | 54 ui::OwnedWidgetGtk floating_; |
52 | 55 |
53 // Our owner. Also owns our child widgets. | |
54 content::TabContentsViewGtk* view_; | |
55 | |
56 // The UI for the constrained dialog currently displayed. This is owned by | 56 // The UI for the constrained dialog currently displayed. This is owned by |
57 // TabContents, not the view. | 57 // TabContents, not the view. |
58 ConstrainedWindowGtk* constrained_window_; | 58 ConstrainedWindowGtk* constrained_window_; |
59 | 59 |
60 // The context menu is reset every time we show it, but we keep a pointer to | 60 // The context menu is reset every time we show it, but we keep a pointer to |
61 // between uses so that it won't go out of scope before we're done with it. | 61 // between uses so that it won't go out of scope before we're done with it. |
62 scoped_ptr<RenderViewContextMenuGtk> context_menu_; | 62 scoped_ptr<RenderViewContextMenuGtk> context_menu_; |
63 | 63 |
64 // The chrome specific delegate that receives events from WebDragDestGtk. | 64 // The chrome specific delegate that receives events from WebDragDestGtk. |
65 scoped_ptr<WebDragBookmarkHandlerGtk> bookmark_handler_gtk_; | 65 scoped_ptr<WebDragBookmarkHandlerGtk> bookmark_handler_gtk_; |
| 66 |
| 67 content::WebContents* web_contents_; |
66 }; | 68 }; |
67 | 69 |
68 #endif // CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_GTK_DELEGATE_H_ | 70 #endif // CHROME_BROWSER_TAB_CONTENTS_CHROME_WEB_CONTENTS_VIEW_DELEGATE_GTK_H_ |
OLD | NEW |