| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 } | 114 } |
| 115 | 115 |
| 116 if (delegate()) { | 116 if (delegate()) { |
| 117 gtk_drag_get_data(widget_, context, delegate()->GetBookmarkTargetAtom(), | 117 gtk_drag_get_data(widget_, context, delegate()->GetBookmarkTargetAtom(), |
| 118 time); | 118 time); |
| 119 } | 119 } |
| 120 } else if (data_requests_ == 0) { | 120 } else if (data_requests_ == 0) { |
| 121 GetRenderViewHost()->DragTargetDragOver( | 121 GetRenderViewHost()->DragTargetDragOver( |
| 122 ui::ClientPoint(widget_), | 122 ui::ClientPoint(widget_), |
| 123 ui::ScreenPoint(widget_), | 123 ui::ScreenPoint(widget_), |
| 124 content::GdkDragActionToWebDragOp(context->actions)); | 124 content::GdkDragActionToWebDragOp(context->actions), |
| 125 0 /* shift/ctrl/alt flags */); |
| 125 | 126 |
| 126 if (delegate()) | 127 if (delegate()) |
| 127 delegate()->OnDragOver(); | 128 delegate()->OnDragOver(); |
| 128 | 129 |
| 129 drag_over_time_ = time; | 130 drag_over_time_ = time; |
| 130 } | 131 } |
| 131 | 132 |
| 132 // Pretend we are a drag destination because we don't want to wait for | 133 // Pretend we are a drag destination because we don't want to wait for |
| 133 // the renderer to tell us if we really are or not. | 134 // the renderer to tell us if we really are or not. |
| 134 return TRUE; | 135 return TRUE; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 223 } |
| 223 } | 224 } |
| 224 | 225 |
| 225 if (data_requests_ == 0) { | 226 if (data_requests_ == 0) { |
| 226 // Tell the renderer about the drag. | 227 // Tell the renderer about the drag. |
| 227 // |x| and |y| are seemingly arbitrary at this point. | 228 // |x| and |y| are seemingly arbitrary at this point. |
| 228 GetRenderViewHost()->DragTargetDragEnter( | 229 GetRenderViewHost()->DragTargetDragEnter( |
| 229 *drop_data_.get(), | 230 *drop_data_.get(), |
| 230 ui::ClientPoint(widget_), | 231 ui::ClientPoint(widget_), |
| 231 ui::ScreenPoint(widget_), | 232 ui::ScreenPoint(widget_), |
| 232 content::GdkDragActionToWebDragOp(context->actions)); | 233 content::GdkDragActionToWebDragOp(context->actions), |
| 234 0 /* shift/ctrl/alt flags */); |
| 233 | 235 |
| 234 if (delegate()) | 236 if (delegate()) |
| 235 delegate()->OnDragEnter(); | 237 delegate()->OnDragEnter(); |
| 236 | 238 |
| 237 drag_over_time_ = time; | 239 drag_over_time_ = time; |
| 238 } | 240 } |
| 239 } | 241 } |
| 240 | 242 |
| 241 // The drag has left our widget; forward this information to the renderer. | 243 // The drag has left our widget; forward this information to the renderer. |
| 242 void WebDragDestGtk::OnDragLeave(GtkWidget* sender, GdkDragContext* context, | 244 void WebDragDestGtk::OnDragLeave(GtkWidget* sender, GdkDragContext* context, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 253 base::Bind(&WebDragDestGtk::DragLeave, method_factory_.GetWeakPtr())); | 255 base::Bind(&WebDragDestGtk::DragLeave, method_factory_.GetWeakPtr())); |
| 254 } | 256 } |
| 255 | 257 |
| 256 // Called by GTK when the user releases the mouse, executing a drop. | 258 // Called by GTK when the user releases the mouse, executing a drop. |
| 257 gboolean WebDragDestGtk::OnDragDrop(GtkWidget* sender, GdkDragContext* context, | 259 gboolean WebDragDestGtk::OnDragDrop(GtkWidget* sender, GdkDragContext* context, |
| 258 gint x, gint y, guint time) { | 260 gint x, gint y, guint time) { |
| 259 // Cancel that drag leave! | 261 // Cancel that drag leave! |
| 260 method_factory_.InvalidateWeakPtrs(); | 262 method_factory_.InvalidateWeakPtrs(); |
| 261 | 263 |
| 262 GetRenderViewHost()-> | 264 GetRenderViewHost()-> |
| 263 DragTargetDrop(ui::ClientPoint(widget_), ui::ScreenPoint(widget_)); | 265 DragTargetDrop(ui::ClientPoint(widget_), ui::ScreenPoint(widget_), |
| 266 0 /* shift/ctrl/alt flags */); |
| 264 | 267 |
| 265 if (delegate()) | 268 if (delegate()) |
| 266 delegate()->OnDrop(); | 269 delegate()->OnDrop(); |
| 267 | 270 |
| 268 // The second parameter is just an educated guess as to whether or not the | 271 // The second parameter is just an educated guess as to whether or not the |
| 269 // drag succeeded, but at least we will get the drag-end animation right | 272 // drag succeeded, but at least we will get the drag-end animation right |
| 270 // sometimes. | 273 // sometimes. |
| 271 gtk_drag_finish(context, is_drop_target_, FALSE, time); | 274 gtk_drag_finish(context, is_drop_target_, FALSE, time); |
| 272 | 275 |
| 273 return TRUE; | 276 return TRUE; |
| 274 } | 277 } |
| 275 | 278 |
| 276 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const { | 279 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const { |
| 277 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); | 280 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); |
| 278 } | 281 } |
| 279 | 282 |
| 280 } // namespace content | 283 } // namespace content |
| OLD | NEW |