OLD | NEW |
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 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h" | 5 #include "chrome/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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/ui/gtk/gtk_floating_container.h" | 22 #include "chrome/browser/ui/gtk/gtk_floating_container.h" |
23 #include "chrome/browser/ui/gtk/gtk_util.h" | 23 #include "chrome/browser/ui/gtk/gtk_util.h" |
24 #include "chrome/browser/ui/gtk/sad_tab_gtk.h" | 24 #include "chrome/browser/ui/gtk/sad_tab_gtk.h" |
25 #include "chrome/browser/ui/gtk/tab_contents_drag_source.h" | 25 #include "chrome/browser/ui/gtk/tab_contents_drag_source.h" |
26 #include "content/browser/renderer_host/render_process_host.h" | 26 #include "content/browser/renderer_host/render_process_host.h" |
27 #include "content/browser/renderer_host/render_view_host.h" | 27 #include "content/browser/renderer_host/render_view_host.h" |
28 #include "content/browser/renderer_host/render_view_host_factory.h" | 28 #include "content/browser/renderer_host/render_view_host_factory.h" |
29 #include "content/browser/tab_contents/interstitial_page.h" | 29 #include "content/browser/tab_contents/interstitial_page.h" |
30 #include "content/browser/tab_contents/tab_contents.h" | 30 #include "content/browser/tab_contents/tab_contents.h" |
31 #include "content/browser/tab_contents/tab_contents_delegate.h" | 31 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| 32 #include "content/common/content_notification_types.h" |
32 #include "content/common/notification_source.h" | 33 #include "content/common/notification_source.h" |
33 #include "content/common/notification_type.h" | |
34 #include "ui/gfx/point.h" | 34 #include "ui/gfx/point.h" |
35 #include "ui/gfx/rect.h" | 35 #include "ui/gfx/rect.h" |
36 #include "ui/gfx/size.h" | 36 #include "ui/gfx/size.h" |
37 #include "webkit/glue/webdropdata.h" | 37 #include "webkit/glue/webdropdata.h" |
38 | 38 |
39 using WebKit::WebDragOperation; | 39 using WebKit::WebDragOperation; |
40 using WebKit::WebDragOperationsMask; | 40 using WebKit::WebDragOperationsMask; |
41 | 41 |
42 namespace { | 42 namespace { |
43 | 43 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 g_signal_connect(expanded_, "size-allocate", | 92 g_signal_connect(expanded_, "size-allocate", |
93 G_CALLBACK(OnSizeAllocateThunk), this); | 93 G_CALLBACK(OnSizeAllocateThunk), this); |
94 g_signal_connect(expanded_, "child-size-request", | 94 g_signal_connect(expanded_, "child-size-request", |
95 G_CALLBACK(OnChildSizeRequestThunk), this); | 95 G_CALLBACK(OnChildSizeRequestThunk), this); |
96 g_signal_connect(floating_.get(), "set-floating-position", | 96 g_signal_connect(floating_.get(), "set-floating-position", |
97 G_CALLBACK(OnSetFloatingPositionThunk), this); | 97 G_CALLBACK(OnSetFloatingPositionThunk), this); |
98 | 98 |
99 gtk_container_add(GTK_CONTAINER(floating_.get()), expanded_); | 99 gtk_container_add(GTK_CONTAINER(floating_.get()), expanded_); |
100 gtk_widget_show(expanded_); | 100 gtk_widget_show(expanded_); |
101 gtk_widget_show(floating_.get()); | 101 gtk_widget_show(floating_.get()); |
102 registrar_.Add(this, NotificationType::TAB_CONTENTS_CONNECTED, | 102 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_CONNECTED, |
103 Source<TabContents>(tab_contents)); | 103 Source<TabContents>(tab_contents)); |
104 drag_source_.reset(new TabContentsDragSource(this)); | 104 drag_source_.reset(new TabContentsDragSource(this)); |
105 } | 105 } |
106 | 106 |
107 TabContentsViewGtk::~TabContentsViewGtk() { | 107 TabContentsViewGtk::~TabContentsViewGtk() { |
108 floating_.Destroy(); | 108 floating_.Destroy(); |
109 } | 109 } |
110 | 110 |
111 void TabContentsViewGtk::AttachConstrainedWindow( | 111 void TabContentsViewGtk::AttachConstrainedWindow( |
112 ConstrainedWindowGtk* constrained_window) { | 112 ConstrainedWindowGtk* constrained_window) { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 275 |
276 // This is called when we the renderer asks us to take focus back (i.e., it has | 276 // This is called when we the renderer asks us to take focus back (i.e., it has |
277 // iterated past the last focusable element on the page). | 277 // iterated past the last focusable element on the page). |
278 void TabContentsViewGtk::TakeFocus(bool reverse) { | 278 void TabContentsViewGtk::TakeFocus(bool reverse) { |
279 if (!tab_contents()->delegate()->TakeFocus(reverse)) { | 279 if (!tab_contents()->delegate()->TakeFocus(reverse)) { |
280 gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()), | 280 gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()), |
281 reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD); | 281 reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD); |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
285 void TabContentsViewGtk::Observe(NotificationType type, | 285 void TabContentsViewGtk::Observe(int type, |
286 const NotificationSource& source, | 286 const NotificationSource& source, |
287 const NotificationDetails& details) { | 287 const NotificationDetails& details) { |
288 switch (type.value) { | 288 switch (type) { |
289 case NotificationType::TAB_CONTENTS_CONNECTED: { | 289 case content::NOTIFICATION_TAB_CONTENTS_CONNECTED: { |
290 // No need to remove the SadTabGtk's widget from the container since | 290 // No need to remove the SadTabGtk's widget from the container since |
291 // the new RenderWidgetHostViewGtk instance already removed all the | 291 // the new RenderWidgetHostViewGtk instance already removed all the |
292 // vbox's children. | 292 // vbox's children. |
293 sad_tab_.reset(); | 293 sad_tab_.reset(); |
294 break; | 294 break; |
295 } | 295 } |
296 default: | 296 default: |
297 NOTREACHED() << "Got a notification we didn't register for."; | 297 NOTREACHED() << "Got a notification we didn't register for."; |
298 break; | 298 break; |
299 } | 299 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 g_value_set_int(&value, child_x); | 447 g_value_set_int(&value, child_x); |
448 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 448 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
449 widget, "x", &value); | 449 widget, "x", &value); |
450 | 450 |
451 int child_y = std::max((allocation->height - requisition.height) / 2, 0); | 451 int child_y = std::max((allocation->height - requisition.height) / 2, 0); |
452 g_value_set_int(&value, child_y); | 452 g_value_set_int(&value, child_y); |
453 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 453 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
454 widget, "y", &value); | 454 widget, "y", &value); |
455 g_value_unset(&value); | 455 g_value_unset(&value); |
456 } | 456 } |
OLD | NEW |