| 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 #include "chrome/browser/tab_contents/chrome_tab_contents_view_wrapper_gtk.h" | 5 #include "chrome/browser/tab_contents/chrome_tab_contents_view_wrapper_gtk.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_shutdown.h" | 7 #include "chrome/browser/browser_shutdown.h" |
| 8 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h" | 8 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h" |
| 9 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.h" | 9 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.h" |
| 10 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" | 10 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" |
| 11 #include "content/browser/renderer_host/render_view_host.h" | 11 #include "content/browser/renderer_host/render_view_host.h" |
| 12 #include "content/browser/renderer_host/render_widget_host_view.h" | |
| 13 #include "content/browser/tab_contents/tab_contents_view_gtk.h" | 12 #include "content/browser/tab_contents/tab_contents_view_gtk.h" |
| 14 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
| 14 #include "content/public/browser/render_widget_host_view.h" |
| 15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 16 #include "ui/base/gtk/gtk_floating_container.h" | 16 #include "ui/base/gtk/gtk_floating_container.h" |
| 17 | 17 |
| 18 ChromeTabContentsViewWrapperGtk::ChromeTabContentsViewWrapperGtk() | 18 ChromeTabContentsViewWrapperGtk::ChromeTabContentsViewWrapperGtk() |
| 19 : floating_(gtk_floating_container_new()), | 19 : floating_(gtk_floating_container_new()), |
| 20 view_(NULL), | 20 view_(NULL), |
| 21 constrained_window_(NULL) { | 21 constrained_window_(NULL) { |
| 22 gtk_widget_set_name(floating_.get(), "chrome-tab-contents-wrapper-view"); | 22 gtk_widget_set_name(floating_.get(), "chrome-tab-contents-wrapper-view"); |
| 23 g_signal_connect(floating_.get(), "set-floating-position", | 23 g_signal_connect(floating_.get(), "set-floating-position", |
| 24 G_CALLBACK(OnSetFloatingPositionThunk), this); | 24 G_CALLBACK(OnSetFloatingPositionThunk), this); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // Let the default TabContentsViewGtk::OnFocus() behaviour run. | 95 // Let the default TabContentsViewGtk::OnFocus() behaviour run. |
| 96 return FALSE; | 96 return FALSE; |
| 97 } | 97 } |
| 98 | 98 |
| 99 void ChromeTabContentsViewWrapperGtk::ShowContextMenu( | 99 void ChromeTabContentsViewWrapperGtk::ShowContextMenu( |
| 100 const content::ContextMenuParams& params) { | 100 const content::ContextMenuParams& params) { |
| 101 // Find out the RenderWidgetHostView that corresponds to the render widget on | 101 // Find out the RenderWidgetHostView that corresponds to the render widget on |
| 102 // which this context menu is showed, so that we can retrieve the last mouse | 102 // which this context menu is showed, so that we can retrieve the last mouse |
| 103 // down event on the render widget and use it as the timestamp of the | 103 // down event on the render widget and use it as the timestamp of the |
| 104 // activation event to show the context menu. | 104 // activation event to show the context menu. |
| 105 RenderWidgetHostView* view = NULL; | 105 content::RenderWidgetHostView* view = NULL; |
| 106 if (params.custom_context.render_widget_id != | 106 if (params.custom_context.render_widget_id != |
| 107 content::CustomContextMenuContext::kCurrentRenderWidget) { | 107 content::CustomContextMenuContext::kCurrentRenderWidget) { |
| 108 IPC::Channel::Listener* listener = | 108 IPC::Channel::Listener* listener = |
| 109 view_->web_contents()->GetRenderProcessHost()->GetListenerByID( | 109 view_->web_contents()->GetRenderProcessHost()->GetListenerByID( |
| 110 params.custom_context.render_widget_id); | 110 params.custom_context.render_widget_id); |
| 111 if (!listener) { | 111 if (!listener) { |
| 112 NOTREACHED(); | 112 NOTREACHED(); |
| 113 return; | 113 return; |
| 114 } | 114 } |
| 115 view = static_cast<RenderWidgetHost*>(listener)->view(); | 115 view = static_cast<RenderWidgetHost*>(listener)->view(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 g_value_set_int(&value, child_x); | 147 g_value_set_int(&value, child_x); |
| 148 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 148 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
| 149 widget, "x", &value); | 149 widget, "x", &value); |
| 150 | 150 |
| 151 int child_y = std::max((allocation->height - requisition.height) / 2, 0); | 151 int child_y = std::max((allocation->height - requisition.height) / 2, 0); |
| 152 g_value_set_int(&value, child_y); | 152 g_value_set_int(&value, child_y); |
| 153 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 153 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
| 154 widget, "y", &value); | 154 widget, "y", &value); |
| 155 g_value_unset(&value); | 155 g_value_unset(&value); |
| 156 } | 156 } |
| OLD | NEW |