| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 gdk_drag_status(context_, content::WebDragOpToGdkDragAction(operation), | 66 gdk_drag_status(context_, content::WebDragOpToGdkDragAction(operation), |
| 67 drag_over_time_); | 67 drag_over_time_); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 void WebDragDestGtk::DragLeave() { | 71 void WebDragDestGtk::DragLeave() { |
| 72 GetRenderViewHost()->DragTargetDragLeave(); | 72 GetRenderViewHost()->DragTargetDragLeave(); |
| 73 | 73 |
| 74 if (delegate()) | 74 if (delegate()) |
| 75 delegate()->OnDragLeave(); | 75 delegate()->OnDragLeave(); |
| 76 |
| 77 drop_data_.reset(); |
| 76 } | 78 } |
| 77 | 79 |
| 78 gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender, | 80 gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender, |
| 79 GdkDragContext* context, | 81 GdkDragContext* context, |
| 80 gint x, gint y, | 82 gint x, gint y, |
| 81 guint time) { | 83 guint time) { |
| 82 if (context_ != context) { | 84 if (context_ != context) { |
| 83 context_ = context; | 85 context_ = context; |
| 84 drop_data_.reset(new WebDropData); | 86 drop_data_.reset(new WebDropData); |
| 85 is_drop_target_ = false; | 87 is_drop_target_ = false; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 drag_over_time_ = time; | 235 drag_over_time_ = time; |
| 234 } | 236 } |
| 235 } | 237 } |
| 236 | 238 |
| 237 // The drag has left our widget; forward this information to the renderer. | 239 // The drag has left our widget; forward this information to the renderer. |
| 238 void WebDragDestGtk::OnDragLeave(GtkWidget* sender, GdkDragContext* context, | 240 void WebDragDestGtk::OnDragLeave(GtkWidget* sender, GdkDragContext* context, |
| 239 guint time) { | 241 guint time) { |
| 240 // Set |context_| to NULL to make sure we will recognize the next DragMotion | 242 // Set |context_| to NULL to make sure we will recognize the next DragMotion |
| 241 // as an enter. | 243 // as an enter. |
| 242 context_ = NULL; | 244 context_ = NULL; |
| 243 drop_data_.reset(); | 245 |
| 244 // When GTK sends us a drag-drop signal, it is shortly (and synchronously) | 246 // When GTK sends us a drag-drop signal, it is shortly (and synchronously) |
| 245 // preceded by a drag-leave. The renderer doesn't like getting the signals | 247 // preceded by a drag-leave. The renderer doesn't like getting the signals |
| 246 // in this order so delay telling it about the drag-leave till we are sure | 248 // in this order so delay telling it about the drag-leave till we are sure |
| 247 // we are not getting a drop as well. | 249 // we are not getting a drop as well. |
| 248 MessageLoop::current()->PostTask(FROM_HERE, | 250 MessageLoop::current()->PostTask(FROM_HERE, |
| 249 base::Bind(&WebDragDestGtk::DragLeave, method_factory_.GetWeakPtr())); | 251 base::Bind(&WebDragDestGtk::DragLeave, method_factory_.GetWeakPtr())); |
| 250 } | 252 } |
| 251 | 253 |
| 252 // Called by GTK when the user releases the mouse, executing a drop. | 254 // Called by GTK when the user releases the mouse, executing a drop. |
| 253 gboolean WebDragDestGtk::OnDragDrop(GtkWidget* sender, GdkDragContext* context, | 255 gboolean WebDragDestGtk::OnDragDrop(GtkWidget* sender, GdkDragContext* context, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 267 gtk_drag_finish(context, is_drop_target_, FALSE, time); | 269 gtk_drag_finish(context, is_drop_target_, FALSE, time); |
| 268 | 270 |
| 269 return TRUE; | 271 return TRUE; |
| 270 } | 272 } |
| 271 | 273 |
| 272 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const { | 274 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const { |
| 273 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); | 275 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); |
| 274 } | 276 } |
| 275 | 277 |
| 276 } // namespace content | 278 } // namespace content |
| OLD | NEW |