Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: chrome/browser/tab_contents/tab_contents_view_gtk.h

Issue 8344061: content: Split off ChromeTabContentsViewGtk from TabContentsViewGtk. This new (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase again to fix comment I committed that was backwards. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_TAB_CONTENTS_VIEW_GTK_H_ 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_
6 #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_ 6 #define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_
7 #pragma once 7 #pragma once
8 8
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" 14 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
15 #include "chrome/browser/ui/gtk/focus_store_gtk.h" 15 #include "chrome/browser/ui/gtk/focus_store_gtk.h"
16 #include "content/browser/tab_contents/tab_contents_view.h" 16 #include "content/browser/tab_contents/tab_contents_view.h"
17 #include "ui/base/gtk/gtk_signal.h" 17 #include "ui/base/gtk/gtk_signal.h"
18 #include "ui/base/gtk/owned_widget_gtk.h" 18 #include "ui/base/gtk/owned_widget_gtk.h"
19 19
20 class ConstrainedWindowGtk;
21 class RenderViewContextMenuGtk;
22 class WebDragBookmarkHandlerGtk;
23
24 namespace content { 20 namespace content {
21 class WebDragDestDelegate;
25 class WebDragDestGtk; 22 class WebDragDestGtk;
26 class WebDragSourceGtk; 23 class WebDragSourceGtk;
27 } 24 }
28 25
26 class TabContentsViewWrapperGtk;
27
29 class TabContentsViewGtk : public TabContentsView { 28 class TabContentsViewGtk : public TabContentsView {
30 public: 29 public:
31 // The corresponding TabContents is passed in the constructor, and manages our 30 // The corresponding TabContents is passed in the constructor, and manages
32 // lifetime. This doesn't need to be the case, but is this way currently 31 // our lifetime. This doesn't need to be the case, but is this way currently
33 // because that's what was easiest when they were split. 32 // because that's what was easiest when they were split. We optionally take
34 explicit TabContentsViewGtk(TabContents* tab_contents); 33 // |wrapper| which creates an intermediary widget layer for features from the
34 // embedding layer that live with the TabContentsView.
35 explicit TabContentsViewGtk(TabContents* tab_contents,
36 TabContentsViewWrapperGtk* wrapper);
35 virtual ~TabContentsViewGtk(); 37 virtual ~TabContentsViewGtk();
36 38
37 // Unlike Windows, ConstrainedWindows need to collaborate with the
38 // TabContentsViewGtk to position the dialogs.
39 void AttachConstrainedWindow(ConstrainedWindowGtk* constrained_window);
40 void RemoveConstrainedWindow(ConstrainedWindowGtk* constrained_window);
41
42 // Override the stored focus widget. This call only makes sense when the 39 // Override the stored focus widget. This call only makes sense when the
43 // tab contents is not focused. 40 // tab contents is not focused.
44 void SetFocusedWidget(GtkWidget* widget); 41 void SetFocusedWidget(GtkWidget* widget);
45 42
43 TabContentsViewWrapperGtk* wrapper() const { return view_wrapper_.get(); }
44 TabContents* tab_contents() { return tab_contents_; }
45 GtkWidget* expanded_container() { return expanded_.get(); }
46
47 // Allows our embeder to intercept incoming drag messages.
48 void SetDragDestDelegate(content::WebDragDestDelegate* delegate);
49
46 // TabContentsView implementation -------------------------------------------- 50 // TabContentsView implementation --------------------------------------------
47 51
48 virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; 52 virtual void CreateView(const gfx::Size& initial_size) OVERRIDE;
49 virtual RenderWidgetHostView* CreateViewForWidget( 53 virtual RenderWidgetHostView* CreateViewForWidget(
50 RenderWidgetHost* render_widget_host) OVERRIDE; 54 RenderWidgetHost* render_widget_host) OVERRIDE;
51 55
52 virtual gfx::NativeView GetNativeView() const OVERRIDE; 56 virtual gfx::NativeView GetNativeView() const OVERRIDE;
53 virtual gfx::NativeView GetContentNativeView() const OVERRIDE; 57 virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
54 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; 58 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
55 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE; 59 virtual void GetContainerBounds(gfx::Rect* out) const OVERRIDE;
(...skipping 10 matching lines...) Expand all
66 virtual void CancelDragAndCloseTab() OVERRIDE; 70 virtual void CancelDragAndCloseTab() OVERRIDE;
67 virtual bool IsEventTracking() const OVERRIDE; 71 virtual bool IsEventTracking() const OVERRIDE;
68 virtual void CloseTabAfterEventTracking() OVERRIDE; 72 virtual void CloseTabAfterEventTracking() OVERRIDE;
69 virtual void GetViewBounds(gfx::Rect* out) const OVERRIDE; 73 virtual void GetViewBounds(gfx::Rect* out) const OVERRIDE;
70 virtual void InstallOverlayView(gfx::NativeView view) OVERRIDE; 74 virtual void InstallOverlayView(gfx::NativeView view) OVERRIDE;
71 virtual void RemoveOverlayView() OVERRIDE; 75 virtual void RemoveOverlayView() OVERRIDE;
72 76
73 // Backend implementation of RenderViewHostDelegate::View. 77 // Backend implementation of RenderViewHostDelegate::View.
74 virtual void CreateNewWindow( 78 virtual void CreateNewWindow(
75 int route_id, 79 int route_id,
76 const ViewHostMsg_CreateWindow_Params& params); 80 const ViewHostMsg_CreateWindow_Params& params) OVERRIDE;
77 virtual void CreateNewWidget(int route_id, WebKit::WebPopupType popup_type); 81 virtual void CreateNewWidget(int route_id,
78 virtual void CreateNewFullscreenWidget(int route_id); 82 WebKit::WebPopupType popup_type) OVERRIDE;
83 virtual void CreateNewFullscreenWidget(int route_id) OVERRIDE;
79 virtual void ShowCreatedWindow(int route_id, 84 virtual void ShowCreatedWindow(int route_id,
80 WindowOpenDisposition disposition, 85 WindowOpenDisposition disposition,
81 const gfx::Rect& initial_pos, 86 const gfx::Rect& initial_pos,
82 bool user_gesture); 87 bool user_gesture) OVERRIDE;
83 virtual void ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos); 88 virtual void ShowCreatedWidget(int route_id,
84 virtual void ShowCreatedFullscreenWidget(int route_id); 89 const gfx::Rect& initial_pos) OVERRIDE;
85 virtual void ShowContextMenu(const ContextMenuParams& params); 90 virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
91 virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE;
86 virtual void ShowPopupMenu(const gfx::Rect& bounds, 92 virtual void ShowPopupMenu(const gfx::Rect& bounds,
87 int item_height, 93 int item_height,
88 double item_font_size, 94 double item_font_size,
89 int selected_item, 95 int selected_item,
90 const std::vector<WebMenuItem>& items, 96 const std::vector<WebMenuItem>& items,
91 bool right_aligned); 97 bool right_aligned) OVERRIDE;
92 virtual void StartDragging(const WebDropData& drop_data, 98 virtual void StartDragging(const WebDropData& drop_data,
93 WebKit::WebDragOperationsMask allowed_ops, 99 WebKit::WebDragOperationsMask allowed_ops,
94 const SkBitmap& image, 100 const SkBitmap& image,
95 const gfx::Point& image_offset); 101 const gfx::Point& image_offset) OVERRIDE;
96 virtual void UpdateDragCursor(WebKit::WebDragOperation operation); 102 virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE;
97 virtual void GotFocus(); 103 virtual void GotFocus() OVERRIDE;
98 virtual void TakeFocus(bool reverse); 104 virtual void TakeFocus(bool reverse) OVERRIDE;
99 105
100 private: 106 private:
101 // Insert the given widget into the content area. Should only be used for 107 // Insert the given widget into the content area. Should only be used for
102 // web pages and the like (including interstitials and sad tab). Note that 108 // web pages and the like (including interstitials and sad tab). Note that
103 // this will be perfectly happy to insert overlapping render views, so care 109 // this will be perfectly happy to insert overlapping render views, so care
104 // should be taken that the correct one is hidden/shown. 110 // should be taken that the correct one is hidden/shown.
105 void InsertIntoContentArea(GtkWidget* widget); 111 void InsertIntoContentArea(GtkWidget* widget);
106 112
107 void CancelDragIfAny(); 113 // Handle focus traversal on the render widget native view. Can be overridden
108 114 // by subclasses.
109 // Handle focus traversal on the render widget native view.
110 CHROMEGTK_CALLBACK_1(TabContentsViewGtk, gboolean, OnFocus, GtkDirectionType); 115 CHROMEGTK_CALLBACK_1(TabContentsViewGtk, gboolean, OnFocus, GtkDirectionType);
111 116
112 // Used to adjust the size of its children when the size of |expanded_| is 117 // Used to adjust the size of its children when the size of |expanded_| is
113 // changed. 118 // changed.
114 CHROMEGTK_CALLBACK_2(TabContentsViewGtk, void, OnChildSizeRequest, 119 CHROMEGTK_CALLBACK_2(TabContentsViewGtk, void, OnChildSizeRequest,
115 GtkWidget*, GtkRequisition*); 120 GtkWidget*, GtkRequisition*);
116 121
117 // Used to propagate the size change of |expanded_| to our RWHV to resize the 122 // Used to propagate the size change of |expanded_| to our RWHV to resize the
118 // renderer content. 123 // renderer content.
119 CHROMEGTK_CALLBACK_1(TabContentsViewGtk, void, OnSizeAllocate, 124 CHROMEGTK_CALLBACK_1(TabContentsViewGtk, void, OnSizeAllocate,
120 GtkAllocation*); 125 GtkAllocation*);
121 126
122 CHROMEGTK_CALLBACK_1(TabContentsViewGtk, void, OnSetFloatingPosition,
123 GtkAllocation*);
124
125 // The TabContents whose contents we display. 127 // The TabContents whose contents we display.
126 TabContents* tab_contents_; 128 TabContents* tab_contents_;
127 129
128 // Common implementations of some RenderViewHostDelegate::View methods. 130 // Common implementations of some RenderViewHostDelegate::View methods.
129 RenderViewHostDelegateViewHelper delegate_view_helper_; 131 RenderViewHostDelegateViewHelper delegate_view_helper_;
130 132
131 // Contains |expanded_| as its GtkBin member.
132 ui::OwnedWidgetGtk floating_;
133
134 // This container holds the tab's web page views. It is a GtkExpandedContainer 133 // This container holds the tab's web page views. It is a GtkExpandedContainer
135 // so that we can control the size of the web pages. 134 // so that we can control the size of the web pages.
136 GtkWidget* expanded_; 135 ui::OwnedWidgetGtk expanded_;
137
138 // The context menu is reset every time we show it, but we keep a pointer to
139 // between uses so that it won't go out of scope before we're done with it.
140 scoped_ptr<RenderViewContextMenuGtk> context_menu_;
141 136
142 FocusStoreGtk focus_store_; 137 FocusStoreGtk focus_store_;
143 138
144 // The UI for the constrained dialog currently displayed. This is owned by
145 // TabContents, not the view.
146 ConstrainedWindowGtk* constrained_window_;
147
148 // The helper object that handles drag destination related interactions with 139 // The helper object that handles drag destination related interactions with
149 // GTK. 140 // GTK.
150 scoped_ptr<content::WebDragDestGtk> drag_dest_; 141 scoped_ptr<content::WebDragDestGtk> drag_dest_;
151 142
152 // The chrome specific delegate that receives events from WebDragDestGtk.
153 scoped_ptr<WebDragBookmarkHandlerGtk> bookmark_handler_gtk_;
154
155 // Object responsible for handling drags from the page for us. 143 // Object responsible for handling drags from the page for us.
156 scoped_ptr<content::WebDragSourceGtk> drag_source_; 144 scoped_ptr<content::WebDragSourceGtk> drag_source_;
157 145
146 // Our optional views wrapper. If non-NULL, we return this widget as our
147 // GetNativeView() and insert |expanded_| as its child in the GtkWidget
148 // hierarchy.
149 scoped_ptr<TabContentsViewWrapperGtk> view_wrapper_;
150
158 // The size we want the tab contents view to be. We keep this in a separate 151 // The size we want the tab contents view to be. We keep this in a separate
159 // variable because resizing in GTK+ is async. 152 // variable because resizing in GTK+ is async.
160 gfx::Size requested_size_; 153 gfx::Size requested_size_;
161 154
162 // The overlaid view. Owned by the caller of |InstallOverlayView|; this is a 155 // The overlaid view. Owned by the caller of |InstallOverlayView|; this is a
163 // weak reference. 156 // weak reference.
164 GtkWidget* overlaid_view_; 157 GtkWidget* overlaid_view_;
165 158
166 DISALLOW_COPY_AND_ASSIGN(TabContentsViewGtk); 159 DISALLOW_COPY_AND_ASSIGN(TabContentsViewGtk);
167 }; 160 };
168 161
169 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_ 162 #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698