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

Side by Side Diff: content/browser/tab_contents/tab_contents_view_gtk.cc

Issue 9586009: Move TabContentsViewGtk's delegate to content\public\browser. Also name it a delegate instead of a … (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 months 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 | Annotate | Revision Log
OLDNEW
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 #include "content/browser/tab_contents/tab_contents_view_gtk.h" 5 #include "content/browser/tab_contents/tab_contents_view_gtk.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
11 #include <algorithm> 11 #include <algorithm>
12 12
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "content/browser/renderer_host/render_view_host.h" 16 #include "content/browser/renderer_host/render_view_host.h"
17 #include "content/browser/renderer_host/render_view_host_factory.h" 17 #include "content/browser/renderer_host/render_view_host_factory.h"
18 #include "content/browser/renderer_host/render_widget_host_view_gtk.h" 18 #include "content/browser/renderer_host/render_widget_host_view_gtk.h"
19 #include "content/browser/tab_contents/interstitial_page_impl.h" 19 #include "content/browser/tab_contents/interstitial_page_impl.h"
20 #include "content/browser/tab_contents/tab_contents.h" 20 #include "content/browser/tab_contents/tab_contents.h"
21 #include "content/browser/tab_contents/tab_contents_view_wrapper_gtk.h"
22 #include "content/browser/tab_contents/web_drag_dest_gtk.h" 21 #include "content/browser/tab_contents/web_drag_dest_gtk.h"
23 #include "content/browser/tab_contents/web_drag_source_gtk.h" 22 #include "content/browser/tab_contents/web_drag_source_gtk.h"
24 #include "content/public/browser/web_contents_delegate.h" 23 #include "content/public/browser/web_contents_delegate.h"
24 #include "content/public/browser/web_contents_view_gtk_delegate.h"
25 #include "ui/base/gtk/gtk_expanded_container.h" 25 #include "ui/base/gtk/gtk_expanded_container.h"
26 #include "ui/gfx/point.h" 26 #include "ui/gfx/point.h"
27 #include "ui/gfx/rect.h" 27 #include "ui/gfx/rect.h"
28 #include "ui/gfx/size.h" 28 #include "ui/gfx/size.h"
29 #include "webkit/glue/webdropdata.h" 29 #include "webkit/glue/webdropdata.h"
30 30
31 using WebKit::WebDragOperation; 31 using WebKit::WebDragOperation;
32 using WebKit::WebDragOperationsMask; 32 using WebKit::WebDragOperationsMask;
33 using content::WebContents; 33 using content::WebContents;
34 34
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 delegate->ContentsZoomChange(event->direction == GDK_SCROLL_UP); 72 delegate->ContentsZoomChange(event->direction == GDK_SCROLL_UP);
73 return TRUE; 73 return TRUE;
74 } 74 }
75 75
76 } // namespace 76 } // namespace
77 77
78 namespace content { 78 namespace content {
79 79
80 TabContentsViewGtk::TabContentsViewGtk( 80 TabContentsViewGtk::TabContentsViewGtk(
81 content::WebContents* web_contents, 81 content::WebContents* web_contents,
82 content::TabContentsViewWrapperGtk* view_wrapper) 82 content::WebContentsViewGtkDelegate* delegate)
83 : tab_contents_(static_cast<TabContents*>(web_contents)), 83 : tab_contents_(static_cast<TabContents*>(web_contents)),
84 expanded_(gtk_expanded_container_new()), 84 expanded_(gtk_expanded_container_new()),
85 view_wrapper_(view_wrapper), 85 delegate_(delegate),
86 overlaid_view_(NULL) { 86 overlaid_view_(NULL) {
87 gtk_widget_set_name(expanded_.get(), "chrome-tab-contents-view"); 87 gtk_widget_set_name(expanded_.get(), "chrome-tab-contents-view");
88 g_signal_connect(expanded_.get(), "size-allocate", 88 g_signal_connect(expanded_.get(), "size-allocate",
89 G_CALLBACK(OnSizeAllocateThunk), this); 89 G_CALLBACK(OnSizeAllocateThunk), this);
90 g_signal_connect(expanded_.get(), "child-size-request", 90 g_signal_connect(expanded_.get(), "child-size-request",
91 G_CALLBACK(OnChildSizeRequestThunk), this); 91 G_CALLBACK(OnChildSizeRequestThunk), this);
92 92
93 gtk_widget_show(expanded_.get()); 93 gtk_widget_show(expanded_.get());
94 drag_source_.reset(new content::WebDragSourceGtk(web_contents)); 94 drag_source_.reset(new content::WebDragSourceGtk(web_contents));
95 95
96 if (view_wrapper_.get()) 96 if (delegate_.get())
97 view_wrapper_->WrapView(this); 97 delegate_->WrapView(this);
98 } 98 }
99 99
100 TabContentsViewGtk::~TabContentsViewGtk() { 100 TabContentsViewGtk::~TabContentsViewGtk() {
101 expanded_.Destroy(); 101 expanded_.Destroy();
102 } 102 }
103 103
104 void TabContentsViewGtk::CreateView(const gfx::Size& initial_size) { 104 void TabContentsViewGtk::CreateView(const gfx::Size& initial_size) {
105 requested_size_ = initial_size; 105 requested_size_ = initial_size;
106 } 106 }
107 107
(...skipping 20 matching lines...) Expand all
128 G_CALLBACK(OnMouseMove), tab_contents_); 128 G_CALLBACK(OnMouseMove), tab_contents_);
129 g_signal_connect(content_view, "scroll-event", 129 g_signal_connect(content_view, "scroll-event",
130 G_CALLBACK(OnMouseScroll), tab_contents_); 130 G_CALLBACK(OnMouseScroll), tab_contents_);
131 gtk_widget_add_events(content_view, GDK_LEAVE_NOTIFY_MASK | 131 gtk_widget_add_events(content_view, GDK_LEAVE_NOTIFY_MASK |
132 GDK_POINTER_MOTION_MASK); 132 GDK_POINTER_MOTION_MASK);
133 InsertIntoContentArea(content_view); 133 InsertIntoContentArea(content_view);
134 134
135 // Renderer target DnD. 135 // Renderer target DnD.
136 drag_dest_.reset(new content::WebDragDestGtk(tab_contents_, content_view)); 136 drag_dest_.reset(new content::WebDragDestGtk(tab_contents_, content_view));
137 137
138 if (view_wrapper_.get()) 138 if (delegate_.get())
139 view_wrapper_->OnCreateViewForWidget(); 139 delegate_->OnCreateViewForWidget();
140 140
141 return view; 141 return view;
142 } 142 }
143 143
144 gfx::NativeView TabContentsViewGtk::GetNativeView() const { 144 gfx::NativeView TabContentsViewGtk::GetNativeView() const {
145 if (view_wrapper_.get()) 145 if (delegate_.get())
146 return view_wrapper_->GetNativeView(); 146 return delegate_->GetNativeView();
147 147
148 return expanded_.get(); 148 return expanded_.get();
149 } 149 }
150 150
151 gfx::NativeView TabContentsViewGtk::GetContentNativeView() const { 151 gfx::NativeView TabContentsViewGtk::GetContentNativeView() const {
152 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); 152 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView();
153 if (!rwhv) 153 if (!rwhv)
154 return NULL; 154 return NULL;
155 return rwhv->GetNativeView(); 155 return rwhv->GetNativeView();
156 } 156 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 if (rwhv) 202 if (rwhv)
203 rwhv->SetSize(size); 203 rwhv->SetSize(size);
204 } 204 }
205 205
206 void TabContentsViewGtk::RenderViewCreated(RenderViewHost* host) { 206 void TabContentsViewGtk::RenderViewCreated(RenderViewHost* host) {
207 } 207 }
208 208
209 void TabContentsViewGtk::Focus() { 209 void TabContentsViewGtk::Focus() {
210 if (tab_contents_->ShowingInterstitialPage()) { 210 if (tab_contents_->ShowingInterstitialPage()) {
211 tab_contents_->GetInterstitialPage()->Focus(); 211 tab_contents_->GetInterstitialPage()->Focus();
212 } else if (wrapper()) { 212 } else if (delegate_.get()) {
213 wrapper()->Focus(); 213 delegate_->Focus();
214 } 214 }
215 } 215 }
216 216
217 void TabContentsViewGtk::SetInitialFocus() { 217 void TabContentsViewGtk::SetInitialFocus() {
218 if (tab_contents_->FocusLocationBarByDefault()) 218 if (tab_contents_->FocusLocationBarByDefault())
219 tab_contents_->SetFocusToLocationBar(false); 219 tab_contents_->SetFocusToLocationBar(false);
220 else 220 else
221 Focus(); 221 Focus();
222 } 222 }
223 223
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 308 }
309 309
310 // Called when the content view gtk widget is tabbed to, or after the call to 310 // Called when the content view gtk widget is tabbed to, or after the call to
311 // gtk_widget_child_focus() in TakeFocus(). We return true 311 // gtk_widget_child_focus() in TakeFocus(). We return true
312 // and grab focus if we don't have it. The call to 312 // and grab focus if we don't have it. The call to
313 // FocusThroughTabTraversal(bool) forwards the "move focus forward" effect to 313 // FocusThroughTabTraversal(bool) forwards the "move focus forward" effect to
314 // webkit. 314 // webkit.
315 gboolean TabContentsViewGtk::OnFocus(GtkWidget* widget, 315 gboolean TabContentsViewGtk::OnFocus(GtkWidget* widget,
316 GtkDirectionType focus) { 316 GtkDirectionType focus) {
317 // Give our view wrapper first chance at this event. 317 // Give our view wrapper first chance at this event.
318 if (view_wrapper_.get()) { 318 if (delegate_.get()) {
319 gboolean return_value = FALSE; 319 gboolean return_value = FALSE;
320 if (view_wrapper_->OnNativeViewFocusEvent(widget, focus, &return_value)) 320 if (delegate_->OnNativeViewFocusEvent(widget, focus, &return_value))
321 return return_value; 321 return return_value;
322 } 322 }
323 323
324 // If we already have focus, let the next widget have a shot at it. We will 324 // If we already have focus, let the next widget have a shot at it. We will
325 // reach this situation after the call to gtk_widget_child_focus() in 325 // reach this situation after the call to gtk_widget_child_focus() in
326 // TakeFocus(). 326 // TakeFocus().
327 if (gtk_widget_is_focus(widget)) 327 if (gtk_widget_is_focus(widget))
328 return FALSE; 328 return FALSE;
329 329
330 gtk_widget_grab_focus(widget); 330 gtk_widget_grab_focus(widget);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 } 378 }
379 379
380 void TabContentsViewGtk::ShowContextMenu( 380 void TabContentsViewGtk::ShowContextMenu(
381 const content::ContextMenuParams& params) { 381 const content::ContextMenuParams& params) {
382 // Allow delegates to handle the context menu operation first. 382 // Allow delegates to handle the context menu operation first.
383 if (web_contents()->GetDelegate() && 383 if (web_contents()->GetDelegate() &&
384 web_contents()->GetDelegate()->HandleContextMenu(params)) { 384 web_contents()->GetDelegate()->HandleContextMenu(params)) {
385 return; 385 return;
386 } 386 }
387 387
388 if (wrapper()) 388 if (delegate_.get())
389 wrapper()->ShowContextMenu(params); 389 delegate_->ShowContextMenu(params);
390 else 390 else
391 DLOG(ERROR) << "Cannot show context menus without a delegate."; 391 DLOG(ERROR) << "Cannot show context menus without a delegate.";
392 } 392 }
393 393
394 void TabContentsViewGtk::ShowPopupMenu(const gfx::Rect& bounds, 394 void TabContentsViewGtk::ShowPopupMenu(const gfx::Rect& bounds,
395 int item_height, 395 int item_height,
396 double item_font_size, 396 double item_font_size,
397 int selected_item, 397 int selected_item,
398 const std::vector<WebMenuItem>& items, 398 const std::vector<WebMenuItem>& items,
399 bool right_aligned) { 399 bool right_aligned) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // We manually tell our RWHV to resize the renderer content. This avoids 443 // We manually tell our RWHV to resize the renderer content. This avoids
444 // spurious resizes from GTK+. 444 // spurious resizes from GTK+.
445 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); 445 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView();
446 if (rwhv) 446 if (rwhv)
447 rwhv->SetSize(size); 447 rwhv->SetSize(size);
448 if (tab_contents_->GetInterstitialPage()) 448 if (tab_contents_->GetInterstitialPage())
449 tab_contents_->GetInterstitialPage()->SetSize(size); 449 tab_contents_->GetInterstitialPage()->SetSize(size);
450 } 450 }
451 451
452 } // namespace content 452 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/tab_contents/tab_contents_view_gtk.h ('k') | content/browser/tab_contents/tab_contents_view_wrapper_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698