| 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" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "content/browser/renderer_host/render_view_host_impl.h" | 13 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 14 #include "content/browser/web_contents/drag_utils_gtk.h" | 14 #include "content/browser/web_contents/drag_utils_gtk.h" |
| 15 #include "content/browser/web_contents/web_contents_impl.h" | 15 #include "content/browser/web_contents/web_contents_impl.h" |
| 16 #include "content/public/browser/web_drag_dest_delegate.h" | 16 #include "content/public/browser/web_drag_dest_delegate.h" |
| 17 #include "content/public/common/url_constants.h" | 17 #include "content/public/common/url_constants.h" |
| 18 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 20 #include "ui/base/clipboard/custom_data_helper.h" | 20 #include "ui/base/clipboard/custom_data_helper.h" |
| 21 #include "ui/base/dragdrop/gtk_dnd_util.h" | 21 #include "ui/base/dragdrop/gtk_dnd_util.h" |
| 22 #include "ui/base/gtk/gtk_screen_util.h" | 22 #include "ui/base/gtk/gtk_screen_util.h" |
| 23 | 23 |
| 24 using content::RenderViewHostImpl; | |
| 25 using WebKit::WebDragOperation; | 24 using WebKit::WebDragOperation; |
| 26 using WebKit::WebDragOperationNone; | 25 using WebKit::WebDragOperationNone; |
| 27 | 26 |
| 28 namespace content { | 27 namespace content { |
| 29 | 28 |
| 30 namespace { | 29 namespace { |
| 31 | 30 |
| 32 int GetModifierFlags(GtkWidget* widget) { | 31 int GetModifierFlags(GtkWidget* widget) { |
| 33 int modifier_state = 0; | 32 int modifier_state = 0; |
| 34 GdkModifierType state; | 33 GdkModifierType state; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 WebDragDestGtk::~WebDragDestGtk() { | 76 WebDragDestGtk::~WebDragDestGtk() { |
| 78 if (widget_) { | 77 if (widget_) { |
| 79 gtk_drag_dest_unset(widget_); | 78 gtk_drag_dest_unset(widget_); |
| 80 g_signal_handler_disconnect(widget_, destroy_handler_); | 79 g_signal_handler_disconnect(widget_, destroy_handler_); |
| 81 } | 80 } |
| 82 } | 81 } |
| 83 | 82 |
| 84 void WebDragDestGtk::UpdateDragStatus(WebDragOperation operation) { | 83 void WebDragDestGtk::UpdateDragStatus(WebDragOperation operation) { |
| 85 if (context_) { | 84 if (context_) { |
| 86 is_drop_target_ = operation != WebDragOperationNone; | 85 is_drop_target_ = operation != WebDragOperationNone; |
| 87 gdk_drag_status(context_, content::WebDragOpToGdkDragAction(operation), | 86 gdk_drag_status(context_, WebDragOpToGdkDragAction(operation), |
| 88 drag_over_time_); | 87 drag_over_time_); |
| 89 } | 88 } |
| 90 } | 89 } |
| 91 | 90 |
| 92 void WebDragDestGtk::DragLeave() { | 91 void WebDragDestGtk::DragLeave() { |
| 93 GetRenderViewHost()->DragTargetDragLeave(); | 92 GetRenderViewHost()->DragTargetDragLeave(); |
| 94 if (delegate()) | 93 if (delegate()) |
| 95 delegate()->OnDragLeave(); | 94 delegate()->OnDragLeave(); |
| 96 | 95 |
| 97 drop_data_.reset(); | 96 drop_data_.reset(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 133 } |
| 135 | 134 |
| 136 if (delegate()) { | 135 if (delegate()) { |
| 137 gtk_drag_get_data(widget_, context, delegate()->GetBookmarkTargetAtom(), | 136 gtk_drag_get_data(widget_, context, delegate()->GetBookmarkTargetAtom(), |
| 138 time); | 137 time); |
| 139 } | 138 } |
| 140 } else if (data_requests_ == 0) { | 139 } else if (data_requests_ == 0) { |
| 141 GetRenderViewHost()->DragTargetDragOver( | 140 GetRenderViewHost()->DragTargetDragOver( |
| 142 ui::ClientPoint(widget_), | 141 ui::ClientPoint(widget_), |
| 143 ui::ScreenPoint(widget_), | 142 ui::ScreenPoint(widget_), |
| 144 content::GdkDragActionToWebDragOp(context->actions), | 143 GdkDragActionToWebDragOp(context->actions), |
| 145 GetModifierFlags(widget_)); | 144 GetModifierFlags(widget_)); |
| 146 | 145 |
| 147 if (delegate()) | 146 if (delegate()) |
| 148 delegate()->OnDragOver(); | 147 delegate()->OnDragOver(); |
| 149 | 148 |
| 150 drag_over_time_ = time; | 149 drag_over_time_ = time; |
| 151 } | 150 } |
| 152 | 151 |
| 153 // Pretend we are a drag destination because we don't want to wait for | 152 // Pretend we are a drag destination because we don't want to wait for |
| 154 // the renderer to tell us if we really are or not. | 153 // the renderer to tell us if we really are or not. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 } | 244 } |
| 246 } | 245 } |
| 247 | 246 |
| 248 if (data_requests_ == 0) { | 247 if (data_requests_ == 0) { |
| 249 // Tell the renderer about the drag. | 248 // Tell the renderer about the drag. |
| 250 // |x| and |y| are seemingly arbitrary at this point. | 249 // |x| and |y| are seemingly arbitrary at this point. |
| 251 GetRenderViewHost()->DragTargetDragEnter( | 250 GetRenderViewHost()->DragTargetDragEnter( |
| 252 *drop_data_.get(), | 251 *drop_data_.get(), |
| 253 ui::ClientPoint(widget_), | 252 ui::ClientPoint(widget_), |
| 254 ui::ScreenPoint(widget_), | 253 ui::ScreenPoint(widget_), |
| 255 content::GdkDragActionToWebDragOp(context->actions), | 254 GdkDragActionToWebDragOp(context->actions), |
| 256 GetModifierFlags(widget_)); | 255 GetModifierFlags(widget_)); |
| 257 | 256 |
| 258 if (delegate()) | 257 if (delegate()) |
| 259 delegate()->OnDragEnter(); | 258 delegate()->OnDragEnter(); |
| 260 | 259 |
| 261 drag_over_time_ = time; | 260 drag_over_time_ = time; |
| 262 } | 261 } |
| 263 } | 262 } |
| 264 | 263 |
| 265 // The drag has left our widget; forward this information to the renderer. | 264 // The drag has left our widget; forward this information to the renderer. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 gtk_drag_finish(context, is_drop_target_, FALSE, time); | 301 gtk_drag_finish(context, is_drop_target_, FALSE, time); |
| 303 | 302 |
| 304 return TRUE; | 303 return TRUE; |
| 305 } | 304 } |
| 306 | 305 |
| 307 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const { | 306 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const { |
| 308 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); | 307 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); |
| 309 } | 308 } |
| 310 | 309 |
| 311 } // namespace content | 310 } // namespace content |
| OLD | NEW |