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_dest_gtk.h" | 5 #include "content/browser/web_contents/web_drag_dest_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 void WebDragDestGtk::UpdateDragStatus(WebDragOperation operation) { | 84 void WebDragDestGtk::UpdateDragStatus(WebDragOperation operation) { |
85 if (context_) { | 85 if (context_) { |
86 is_drop_target_ = operation != WebDragOperationNone; | 86 is_drop_target_ = operation != WebDragOperationNone; |
87 gdk_drag_status(context_, content::WebDragOpToGdkDragAction(operation), | 87 gdk_drag_status(context_, content::WebDragOpToGdkDragAction(operation), |
88 drag_over_time_); | 88 drag_over_time_); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 void WebDragDestGtk::DragLeave() { | 92 void WebDragDestGtk::DragLeave() { |
93 GetRenderViewHost()->DragTargetDragLeave(); | 93 GetRenderViewHost()->DragTargetDragLeave(); |
94 | |
95 if (delegate()) | 94 if (delegate()) |
96 delegate()->OnDragLeave(); | 95 delegate()->OnDragLeave(); |
97 | 96 |
98 drop_data_.reset(); | 97 drop_data_.reset(); |
99 } | 98 } |
100 | 99 |
101 gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender, | 100 gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender, |
102 GdkDragContext* context, | 101 GdkDragContext* context, |
103 gint x, gint y, | 102 gint x, gint y, |
104 guint time) { | 103 guint time) { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 } | 262 } |
264 } | 263 } |
265 | 264 |
266 // The drag has left our widget; forward this information to the renderer. | 265 // The drag has left our widget; forward this information to the renderer. |
267 void WebDragDestGtk::OnDragLeave(GtkWidget* sender, GdkDragContext* context, | 266 void WebDragDestGtk::OnDragLeave(GtkWidget* sender, GdkDragContext* context, |
268 guint time) { | 267 guint time) { |
269 // Set |context_| to NULL to make sure we will recognize the next DragMotion | 268 // Set |context_| to NULL to make sure we will recognize the next DragMotion |
270 // as an enter. | 269 // as an enter. |
271 context_ = NULL; | 270 context_ = NULL; |
272 | 271 |
| 272 // Sometimes we get a drag-leave event before getting a drag-data-received |
| 273 // event. In that case, we don't want to bother the renderer with a |
| 274 // DragLeave event. |
| 275 if (data_requests_ != 0) |
| 276 return; |
| 277 |
273 // When GTK sends us a drag-drop signal, it is shortly (and synchronously) | 278 // When GTK sends us a drag-drop signal, it is shortly (and synchronously) |
274 // preceded by a drag-leave. The renderer doesn't like getting the signals | 279 // preceded by a drag-leave. The renderer doesn't like getting the signals |
275 // in this order so delay telling it about the drag-leave till we are sure | 280 // in this order so delay telling it about the drag-leave till we are sure |
276 // we are not getting a drop as well. | 281 // we are not getting a drop as well. |
277 MessageLoop::current()->PostTask(FROM_HERE, | 282 MessageLoop::current()->PostTask(FROM_HERE, |
278 base::Bind(&WebDragDestGtk::DragLeave, method_factory_.GetWeakPtr())); | 283 base::Bind(&WebDragDestGtk::DragLeave, method_factory_.GetWeakPtr())); |
279 } | 284 } |
280 | 285 |
281 // Called by GTK when the user releases the mouse, executing a drop. | 286 // Called by GTK when the user releases the mouse, executing a drop. |
282 gboolean WebDragDestGtk::OnDragDrop(GtkWidget* sender, GdkDragContext* context, | 287 gboolean WebDragDestGtk::OnDragDrop(GtkWidget* sender, GdkDragContext* context, |
(...skipping 14 matching lines...) Expand all Loading... |
297 gtk_drag_finish(context, is_drop_target_, FALSE, time); | 302 gtk_drag_finish(context, is_drop_target_, FALSE, time); |
298 | 303 |
299 return TRUE; | 304 return TRUE; |
300 } | 305 } |
301 | 306 |
302 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const { | 307 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const { |
303 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); | 308 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); |
304 } | 309 } |
305 | 310 |
306 } // namespace content | 311 } // namespace content |
OLD | NEW |