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/ui/views/tab_contents/native_tab_contents_view_gtk.h" | 5 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_gtk.h" |
6 | 6 |
7 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" | 7 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" |
8 #include "chrome/browser/tab_contents/web_drag_dest_gtk.h" | 8 #include "chrome/browser/tab_contents/web_drag_dest_gtk.h" |
9 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" | 9 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" |
10 #include "chrome/browser/ui/gtk/tab_contents_drag_source.h" | 10 #include "chrome/browser/ui/gtk/tab_contents_drag_source.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 } | 50 } |
51 if (event->direction == GDK_SCROLL_UP) { | 51 if (event->direction == GDK_SCROLL_UP) { |
52 delegate->OnNativeTabContentsViewWheelZoom(true); | 52 delegate->OnNativeTabContentsViewWheelZoom(true); |
53 return TRUE; | 53 return TRUE; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 return FALSE; | 57 return FALSE; |
58 } | 58 } |
59 | 59 |
60 gfx::NativeView GetHiddenTabHostWindow() { | |
61 static views::Widget* widget = NULL; | |
62 | |
63 if (!widget) { | |
64 widget = new views::Widget; | |
65 // We don't want this widget to be closed automatically, this causes | |
66 // problems in tests that close the last non-secondary window. | |
67 widget->set_is_secondary_widget(false); | |
68 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | |
69 widget->Init(params); | |
70 } | |
71 | |
72 return static_cast<views::NativeWidgetGtk*>(widget->native_widget())-> | |
73 window_contents(); | |
74 } | |
75 | |
76 } // namespace | 60 } // namespace |
77 | 61 |
78 //////////////////////////////////////////////////////////////////////////////// | 62 //////////////////////////////////////////////////////////////////////////////// |
79 // NativeTabContentsViewGtk, public: | 63 // NativeTabContentsViewGtk, public: |
80 | 64 |
81 NativeTabContentsViewGtk::NativeTabContentsViewGtk( | 65 NativeTabContentsViewGtk::NativeTabContentsViewGtk( |
82 internal::NativeTabContentsViewDelegate* delegate) | 66 internal::NativeTabContentsViewDelegate* delegate) |
83 : views::NativeWidgetGtk(delegate->AsNativeWidgetDelegate()), | 67 : views::NativeWidgetGtk(delegate->AsNativeWidgetDelegate()), |
84 delegate_(delegate), | 68 delegate_(delegate), |
85 ignore_next_char_event_(false), | 69 ignore_next_char_event_(false), |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 params.native_widget = this; | 107 params.native_widget = this; |
124 params.delete_on_destroy = false; | 108 params.delete_on_destroy = false; |
125 GetWidget()->Init(params); | 109 GetWidget()->Init(params); |
126 | 110 |
127 // We need to own the widget in order to attach/detach the native view to a | 111 // We need to own the widget in order to attach/detach the native view to a |
128 // container. | 112 // container. |
129 gtk_object_ref(GTK_OBJECT(GetWidget()->GetNativeView())); | 113 gtk_object_ref(GTK_OBJECT(GetWidget()->GetNativeView())); |
130 } | 114 } |
131 | 115 |
132 void NativeTabContentsViewGtk::Unparent() { | 116 void NativeTabContentsViewGtk::Unparent() { |
133 // Note that we do not DCHECK on focus_manager_ as it may be NULL when used | |
134 // with an external tab container. | |
135 NativeWidget::ReparentNativeView(GetNativeView(), GetHiddenTabHostWindow()); | |
136 } | 117 } |
137 | 118 |
138 RenderWidgetHostView* NativeTabContentsViewGtk::CreateRenderWidgetHostView( | 119 RenderWidgetHostView* NativeTabContentsViewGtk::CreateRenderWidgetHostView( |
139 RenderWidgetHost* render_widget_host) { | 120 RenderWidgetHost* render_widget_host) { |
140 RenderWidgetHostViewGtk* view = | 121 RenderWidgetHostViewGtk* view = |
141 new RenderWidgetHostViewGtk(render_widget_host); | 122 new RenderWidgetHostViewGtk(render_widget_host); |
142 view->InitAsChild(); | 123 view->InitAsChild(); |
143 g_signal_connect(view->native_view(), "focus", | 124 g_signal_connect(view->native_view(), "focus", |
144 G_CALLBACK(OnFocus), delegate_->GetTabContents()); | 125 G_CALLBACK(OnFocus), delegate_->GetTabContents()); |
145 g_signal_connect(view->native_view(), "scroll-event", | 126 g_signal_connect(view->native_view(), "scroll-event", |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 256 |
276 //////////////////////////////////////////////////////////////////////////////// | 257 //////////////////////////////////////////////////////////////////////////////// |
277 // NativeTabContentsView, public: | 258 // NativeTabContentsView, public: |
278 | 259 |
279 // static | 260 // static |
280 NativeTabContentsView* NativeTabContentsView::CreateNativeTabContentsView( | 261 NativeTabContentsView* NativeTabContentsView::CreateNativeTabContentsView( |
281 internal::NativeTabContentsViewDelegate* delegate) { | 262 internal::NativeTabContentsViewDelegate* delegate) { |
282 return new NativeTabContentsViewGtk(delegate); | 263 return new NativeTabContentsViewGtk(delegate); |
283 } | 264 } |
284 | 265 |
OLD | NEW |