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 "content/browser/web_contents/web_drag_source_gtk.h" | 5 #include "content/browser/web_contents/web_drag_source_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/nix/mime_util_xdg.h" | 10 #include "base/nix/mime_util_xdg.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 signals_.Connect(drag_icon_, "expose-event", | 55 signals_.Connect(drag_icon_, "expose-event", |
56 G_CALLBACK(OnDragIconExposeThunk), this); | 56 G_CALLBACK(OnDragIconExposeThunk), this); |
57 } | 57 } |
58 | 58 |
59 WebDragSourceGtk::~WebDragSourceGtk() { | 59 WebDragSourceGtk::~WebDragSourceGtk() { |
60 // Break the current drag, if any. | 60 // Break the current drag, if any. |
61 if (drop_data_) { | 61 if (drop_data_) { |
62 gtk_grab_add(drag_widget_); | 62 gtk_grab_add(drag_widget_); |
63 gtk_grab_remove(drag_widget_); | 63 gtk_grab_remove(drag_widget_); |
64 MessageLoopForUI::current()->RemoveObserver(this); | 64 base::MessageLoopForUI::current()->RemoveObserver(this); |
65 drop_data_.reset(); | 65 drop_data_.reset(); |
66 } | 66 } |
67 | 67 |
68 gtk_widget_destroy(drag_widget_); | 68 gtk_widget_destroy(drag_widget_); |
69 gtk_widget_destroy(drag_icon_); | 69 gtk_widget_destroy(drag_icon_); |
70 } | 70 } |
71 | 71 |
72 bool WebDragSourceGtk::StartDragging(const WebDropData& drop_data, | 72 bool WebDragSourceGtk::StartDragging(const WebDropData& drop_data, |
73 WebDragOperationsMask allowed_ops, | 73 WebDragOperationsMask allowed_ops, |
74 GdkEventButton* last_mouse_down, | 74 GdkEventButton* last_mouse_down, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 gtk_target_list_unref(list); | 141 gtk_target_list_unref(list); |
142 | 142 |
143 // Sometimes the drag fails to start; |context| will be NULL and we won't | 143 // Sometimes the drag fails to start; |context| will be NULL and we won't |
144 // get a drag-end signal. | 144 // get a drag-end signal. |
145 if (!drag_context_) { | 145 if (!drag_context_) { |
146 drag_failed_ = true; | 146 drag_failed_ = true; |
147 drop_data_.reset(); | 147 drop_data_.reset(); |
148 return false; | 148 return false; |
149 } | 149 } |
150 | 150 |
151 MessageLoopForUI::current()->AddObserver(this); | 151 base::MessageLoopForUI::current()->AddObserver(this); |
152 return true; | 152 return true; |
153 } | 153 } |
154 | 154 |
155 void WebDragSourceGtk::WillProcessEvent(GdkEvent* event) { | 155 void WebDragSourceGtk::WillProcessEvent(GdkEvent* event) { |
156 // No-op. | 156 // No-op. |
157 } | 157 } |
158 | 158 |
159 void WebDragSourceGtk::DidProcessEvent(GdkEvent* event) { | 159 void WebDragSourceGtk::DidProcessEvent(GdkEvent* event) { |
160 if (event->type != GDK_MOTION_NOTIFY) | 160 if (event->type != GDK_MOTION_NOTIFY) |
161 return; | 161 return; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 } | 353 } |
354 } | 354 } |
355 | 355 |
356 void WebDragSourceGtk::OnDragEnd(GtkWidget* sender, | 356 void WebDragSourceGtk::OnDragEnd(GtkWidget* sender, |
357 GdkDragContext* drag_context) { | 357 GdkDragContext* drag_context) { |
358 if (drag_pixbuf_) { | 358 if (drag_pixbuf_) { |
359 g_object_unref(drag_pixbuf_); | 359 g_object_unref(drag_pixbuf_); |
360 drag_pixbuf_ = NULL; | 360 drag_pixbuf_ = NULL; |
361 } | 361 } |
362 | 362 |
363 MessageLoopForUI::current()->RemoveObserver(this); | 363 base::MessageLoopForUI::current()->RemoveObserver(this); |
364 | 364 |
365 if (!download_url_.is_empty()) { | 365 if (!download_url_.is_empty()) { |
366 gdk_property_delete(drag_context->source_window, | 366 gdk_property_delete(drag_context->source_window, |
367 ui::GetAtomForTarget(ui::DIRECT_SAVE_FILE)); | 367 ui::GetAtomForTarget(ui::DIRECT_SAVE_FILE)); |
368 } | 368 } |
369 | 369 |
370 if (!drag_failed_) { | 370 if (!drag_failed_) { |
371 gfx::Point root = ui::ScreenPoint(GetContentNativeView()); | 371 gfx::Point root = ui::ScreenPoint(GetContentNativeView()); |
372 gfx::Point client = ui::ClientPoint(GetContentNativeView()); | 372 gfx::Point client = ui::ClientPoint(GetContentNativeView()); |
373 | 373 |
(...skipping 21 matching lines...) Expand all Loading... |
395 cairo_clip(cr); | 395 cairo_clip(cr); |
396 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); | 396 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
397 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); | 397 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); |
398 cairo_paint(cr); | 398 cairo_paint(cr); |
399 cairo_destroy(cr); | 399 cairo_destroy(cr); |
400 | 400 |
401 return TRUE; | 401 return TRUE; |
402 } | 402 } |
403 | 403 |
404 } // namespace content | 404 } // namespace content |
OLD | NEW |