OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/tab_contents/web_contents_view_gtk.h" | 5 #include "chrome/browser/tab_contents/web_contents_view_gtk.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/gfx/point.h" | 11 #include "base/gfx/point.h" |
12 #include "base/gfx/rect.h" | 12 #include "base/gfx/rect.h" |
13 #include "chrome/browser/gtk/browser_window_gtk.h" | 13 #include "chrome/browser/gtk/browser_window_gtk.h" |
14 #include "chrome/browser/renderer_host/render_view_host.h" | 14 #include "chrome/browser/renderer_host/render_view_host.h" |
| 15 #include "chrome/browser/renderer_host/render_view_host_factory.h" |
15 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" | 16 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" |
16 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h" | 17 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h" |
17 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 18 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
18 #include "chrome/browser/tab_contents/web_contents.h" | 19 #include "chrome/browser/tab_contents/web_contents.h" |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 // Called when the content view gtk widget is tabbed to. We always return true | 23 // Called when the content view gtk widget is tabbed to. We always return true |
23 // and grab focus if we don't have it. The call to SetInitialFocus(bool) | 24 // and grab focus if we don't have it. The call to SetInitialFocus(bool) |
24 // forwards the tab to webkit. We leave focus via TakeFocus(). | 25 // forwards the tab to webkit. We leave focus via TakeFocus(). |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 79 } |
79 | 80 |
80 RenderWidgetHostView* WebContentsViewGtk::CreateViewForWidget( | 81 RenderWidgetHostView* WebContentsViewGtk::CreateViewForWidget( |
81 RenderWidgetHost* render_widget_host) { | 82 RenderWidgetHost* render_widget_host) { |
82 if (render_widget_host->view()) { | 83 if (render_widget_host->view()) { |
83 // During testing, the view will already be set up in most cases to the | 84 // During testing, the view will already be set up in most cases to the |
84 // test view, so we don't want to clobber it with a real one. To verify that | 85 // test view, so we don't want to clobber it with a real one. To verify that |
85 // this actually is happening (and somebody isn't accidentally creating the | 86 // this actually is happening (and somebody isn't accidentally creating the |
86 // view twice), we check for the RVH Factory, which will be set when we're | 87 // view twice), we check for the RVH Factory, which will be set when we're |
87 // making special ones (which go along with the special views). | 88 // making special ones (which go along with the special views). |
88 DCHECK(web_contents()->render_manager()->has_render_view_host_factory()); | 89 DCHECK(RenderViewHostFactory::has_factory()); |
89 return render_widget_host->view(); | 90 return render_widget_host->view(); |
90 } | 91 } |
91 | 92 |
92 RenderWidgetHostViewGtk* view = | 93 RenderWidgetHostViewGtk* view = |
93 new RenderWidgetHostViewGtk(render_widget_host); | 94 new RenderWidgetHostViewGtk(render_widget_host); |
94 view->InitAsChild(); | 95 view->InitAsChild(); |
95 content_view_ = view->native_view(); | 96 content_view_ = view->native_view(); |
96 g_signal_connect(content_view_, "focus", | 97 g_signal_connect(content_view_, "focus", |
97 G_CALLBACK(OnFocus), web_contents()); | 98 G_CALLBACK(OnFocus), web_contents()); |
98 g_signal_connect(view->native_view(), "leave-notify-event", | 99 g_signal_connect(view->native_view(), "leave-notify-event", |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 // TODO(port): remove me when the above NOTIMPLEMENTED is fixed. | 242 // TODO(port): remove me when the above NOTIMPLEMENTED is fixed. |
242 if (web_contents()->render_view_host()) | 243 if (web_contents()->render_view_host()) |
243 web_contents()->render_view_host()->DragSourceSystemDragEnded(); | 244 web_contents()->render_view_host()->DragSourceSystemDragEnded(); |
244 } | 245 } |
245 | 246 |
246 gboolean WebContentsViewGtk::OnMouseDown(GtkWidget* widget, | 247 gboolean WebContentsViewGtk::OnMouseDown(GtkWidget* widget, |
247 GdkEventButton* event, WebContentsViewGtk* view) { | 248 GdkEventButton* event, WebContentsViewGtk* view) { |
248 view->last_mouse_down_time_ = event->time; | 249 view->last_mouse_down_time_ = event->time; |
249 return FALSE; | 250 return FALSE; |
250 } | 251 } |
OLD | NEW |