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/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // Sometimes we get a drag-leave event before getting a drag-data-received | 277 // Sometimes we get a drag-leave event before getting a drag-data-received |
278 // event. In that case, we don't want to bother the renderer with a | 278 // event. In that case, we don't want to bother the renderer with a |
279 // DragLeave event. | 279 // DragLeave event. |
280 if (data_requests_ != 0) | 280 if (data_requests_ != 0) |
281 return; | 281 return; |
282 | 282 |
283 // When GTK sends us a drag-drop signal, it is shortly (and synchronously) | 283 // When GTK sends us a drag-drop signal, it is shortly (and synchronously) |
284 // preceded by a drag-leave. The renderer doesn't like getting the signals | 284 // preceded by a drag-leave. The renderer doesn't like getting the signals |
285 // in this order so delay telling it about the drag-leave till we are sure | 285 // in this order so delay telling it about the drag-leave till we are sure |
286 // we are not getting a drop as well. | 286 // we are not getting a drop as well. |
287 MessageLoop::current()->PostTask(FROM_HERE, | 287 base::MessageLoop::current()->PostTask( |
| 288 FROM_HERE, |
288 base::Bind(&WebDragDestGtk::DragLeave, method_factory_.GetWeakPtr())); | 289 base::Bind(&WebDragDestGtk::DragLeave, method_factory_.GetWeakPtr())); |
289 } | 290 } |
290 | 291 |
291 // Called by GTK when the user releases the mouse, executing a drop. | 292 // Called by GTK when the user releases the mouse, executing a drop. |
292 gboolean WebDragDestGtk::OnDragDrop(GtkWidget* sender, GdkDragContext* context, | 293 gboolean WebDragDestGtk::OnDragDrop(GtkWidget* sender, GdkDragContext* context, |
293 gint x, gint y, guint time) { | 294 gint x, gint y, guint time) { |
294 // Cancel that drag leave! | 295 // Cancel that drag leave! |
295 method_factory_.InvalidateWeakPtrs(); | 296 method_factory_.InvalidateWeakPtrs(); |
296 | 297 |
297 GetRenderViewHost()-> | 298 GetRenderViewHost()-> |
298 DragTargetDrop(ui::ClientPoint(widget_), ui::ScreenPoint(widget_), | 299 DragTargetDrop(ui::ClientPoint(widget_), ui::ScreenPoint(widget_), |
299 GetModifierFlags(widget_)); | 300 GetModifierFlags(widget_)); |
300 | 301 |
301 if (delegate()) | 302 if (delegate()) |
302 delegate()->OnDrop(); | 303 delegate()->OnDrop(); |
303 | 304 |
304 // The second parameter is just an educated guess as to whether or not the | 305 // The second parameter is just an educated guess as to whether or not the |
305 // drag succeeded, but at least we will get the drag-end animation right | 306 // drag succeeded, but at least we will get the drag-end animation right |
306 // sometimes. | 307 // sometimes. |
307 gtk_drag_finish(context, is_drop_target_, FALSE, time); | 308 gtk_drag_finish(context, is_drop_target_, FALSE, time); |
308 | 309 |
309 return TRUE; | 310 return TRUE; |
310 } | 311 } |
311 | 312 |
312 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const { | 313 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const { |
313 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); | 314 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); |
314 } | 315 } |
315 | 316 |
316 } // namespace content | 317 } // namespace content |
OLD | NEW |