OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/tab_contents/tab_contents_view_gtk.h" | 5 #include "chrome/browser/views/tab_contents/tab_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" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 g_signal_connect(view->native_view(), "leave-notify-event", | 182 g_signal_connect(view->native_view(), "leave-notify-event", |
183 G_CALLBACK(OnLeaveNotify2), tab_contents()); | 183 G_CALLBACK(OnLeaveNotify2), tab_contents()); |
184 g_signal_connect(view->native_view(), "motion-notify-event", | 184 g_signal_connect(view->native_view(), "motion-notify-event", |
185 G_CALLBACK(CallMouseMove), this); | 185 G_CALLBACK(CallMouseMove), this); |
186 g_signal_connect(view->native_view(), "scroll-event", | 186 g_signal_connect(view->native_view(), "scroll-event", |
187 G_CALLBACK(OnMouseScroll), tab_contents()); | 187 G_CALLBACK(OnMouseScroll), tab_contents()); |
188 gtk_widget_add_events(view->native_view(), GDK_LEAVE_NOTIFY_MASK | | 188 gtk_widget_add_events(view->native_view(), GDK_LEAVE_NOTIFY_MASK | |
189 GDK_POINTER_MOTION_MASK); | 189 GDK_POINTER_MOTION_MASK); |
190 | 190 |
191 // Renderer target DnD. | 191 // Renderer target DnD. |
192 drag_dest_.reset(new WebDragDestGtk(tab_contents(), view->native_view())); | 192 if (tab_contents()->ShouldAcceptDragAndDrop()) |
| 193 drag_dest_.reset(new WebDragDestGtk(tab_contents(), view->native_view())); |
193 | 194 |
194 gtk_fixed_put(GTK_FIXED(GetNativeView()), view->native_view(), 0, 0); | 195 gtk_fixed_put(GTK_FIXED(GetNativeView()), view->native_view(), 0, 0); |
195 return view; | 196 return view; |
196 } | 197 } |
197 | 198 |
198 gfx::NativeView TabContentsViewGtk::GetNativeView() const { | 199 gfx::NativeView TabContentsViewGtk::GetNativeView() const { |
199 return WidgetGtk::GetNativeView(); | 200 return WidgetGtk::GetNativeView(); |
200 } | 201 } |
201 | 202 |
202 gfx::NativeView TabContentsViewGtk::GetContentNativeView() const { | 203 gfx::NativeView TabContentsViewGtk::GetContentNativeView() const { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 // no longer be focusable (e.g. if the location bar was focused and then | 314 // no longer be focusable (e.g. if the location bar was focused and then |
314 // we switched to fullscreen mode). In that case we default to the | 315 // we switched to fullscreen mode). In that case we default to the |
315 // default focus. | 316 // default focus. |
316 SetInitialFocus(); | 317 SetInitialFocus(); |
317 } | 318 } |
318 view_storage->RemoveView(last_focused_view_storage_id_); | 319 view_storage->RemoveView(last_focused_view_storage_id_); |
319 } | 320 } |
320 } | 321 } |
321 | 322 |
322 void TabContentsViewGtk::UpdateDragCursor(WebDragOperation operation) { | 323 void TabContentsViewGtk::UpdateDragCursor(WebDragOperation operation) { |
323 drag_dest_->UpdateDragStatus(operation); | 324 if (drag_dest_.get()) |
| 325 drag_dest_->UpdateDragStatus(operation); |
324 } | 326 } |
325 | 327 |
326 void TabContentsViewGtk::GotFocus() { | 328 void TabContentsViewGtk::GotFocus() { |
327 if (tab_contents()->delegate()) | 329 if (tab_contents()->delegate()) |
328 tab_contents()->delegate()->TabContentsFocused(tab_contents()); | 330 tab_contents()->delegate()->TabContentsFocused(tab_contents()); |
329 } | 331 } |
330 | 332 |
331 void TabContentsViewGtk::TakeFocus(bool reverse) { | 333 void TabContentsViewGtk::TakeFocus(bool reverse) { |
332 if (tab_contents()->delegate() && | 334 if (tab_contents()->delegate() && |
333 !tab_contents()->delegate()->TakeFocus(reverse)) { | 335 !tab_contents()->delegate()->TakeFocus(reverse)) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 // not NULL, else our delegate. | 452 // not NULL, else our delegate. |
451 gboolean TabContentsViewGtk::OnMouseMove(GtkWidget* widget, | 453 gboolean TabContentsViewGtk::OnMouseMove(GtkWidget* widget, |
452 GdkEventMotion* event) { | 454 GdkEventMotion* event) { |
453 if (sad_tab_ != NULL) | 455 if (sad_tab_ != NULL) |
454 WidgetGtk::OnMotionNotify(widget, event); | 456 WidgetGtk::OnMotionNotify(widget, event); |
455 else if (tab_contents()->delegate()) | 457 else if (tab_contents()->delegate()) |
456 tab_contents()->delegate()->ContentsMouseEvent( | 458 tab_contents()->delegate()->ContentsMouseEvent( |
457 tab_contents(), views::Screen::GetCursorScreenPoint(), true); | 459 tab_contents(), views::Screen::GetCursorScreenPoint(), true); |
458 return FALSE; | 460 return FALSE; |
459 } | 461 } |
OLD | NEW |