OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "views/widget/drop_target_gtk.h" | 5 #include "views/widget/drop_target_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "app/drag_drop_types.h" | |
13 #include "app/gtk_dnd_util.h" | |
14 #include "base/file_path.h" | 12 #include "base/file_path.h" |
15 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
16 #include "gfx/point.h" | 14 #include "gfx/point.h" |
17 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
| 16 #include "ui/base/dragdrop/drag_drop_types.h" |
| 17 #include "ui/base/dragdrop/gtk_dnd_util.h" |
18 #include "ui/base/dragdrop/os_exchange_data_provider_gtk.h" | 18 #include "ui/base/dragdrop/os_exchange_data_provider_gtk.h" |
19 #include "views/widget/root_view.h" | 19 #include "views/widget/root_view.h" |
20 #include "views/widget/widget_gtk.h" | 20 #include "views/widget/widget_gtk.h" |
21 | 21 |
22 using ui::OSExchangeData; | 22 using ui::OSExchangeData; |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 std::string GdkAtomToString(GdkAtom atom) { | 26 std::string GdkAtomToString(GdkAtom atom) { |
27 gchar* c_name = gdk_atom_name(atom); | 27 gchar* c_name = gdk_atom_name(atom); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // Consumers of OSExchangeData will see this as an invalid URL. That is, | 136 // Consumers of OSExchangeData will see this as an invalid URL. That is, |
137 // when GetURL is invoked on the OSExchangeData this triggers false to | 137 // when GetURL is invoked on the OSExchangeData this triggers false to |
138 // be returned. | 138 // be returned. |
139 data_provider().SetURL(GURL(), std::wstring()); | 139 data_provider().SetURL(GURL(), std::wstring()); |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 if (!data_->HasAllFormats(requested_formats_, requested_custom_formats_)) | 143 if (!data_->HasAllFormats(requested_formats_, requested_custom_formats_)) |
144 return; // Waiting on more data. | 144 return; // Waiting on more data. |
145 | 145 |
146 int drag_operation = DragDropTypes::GdkDragActionToDragOperation( | 146 int drag_operation = ui::DragDropTypes::GdkDragActionToDragOperation( |
147 context->actions); | 147 context->actions); |
148 gfx::Point root_view_location(x, y); | 148 gfx::Point root_view_location(x, y); |
149 drag_operation = helper_.OnDragOver(*data_, root_view_location, | 149 drag_operation = helper_.OnDragOver(*data_, root_view_location, |
150 drag_operation); | 150 drag_operation); |
151 GdkDragAction gdk_action = static_cast<GdkDragAction>( | 151 GdkDragAction gdk_action = static_cast<GdkDragAction>( |
152 DragDropTypes::DragOperationToGdkDragAction(drag_operation)); | 152 ui::DragDropTypes::DragOperationToGdkDragAction(drag_operation)); |
153 if (!received_drop_) | 153 if (!received_drop_) |
154 gdk_drag_status(context, gdk_action, time); | 154 gdk_drag_status(context, gdk_action, time); |
155 | 155 |
156 waiting_for_data_ = false; | 156 waiting_for_data_ = false; |
157 | 157 |
158 if (pending_view_ && received_drop_) { | 158 if (pending_view_ && received_drop_) { |
159 FinishDrop(context, x, y, time); | 159 FinishDrop(context, x, y, time); |
160 // WARNING: we've been deleted. | 160 // WARNING: we've been deleted. |
161 return; | 161 return; |
162 } | 162 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // drop is valid, but we don't have all the data. Request the data | 217 // drop is valid, but we don't have all the data. Request the data |
218 // now. When we get back the data we'll update the target. | 218 // now. When we get back the data we'll update the target. |
219 RequestFormats(context, formats, custom_formats, time); | 219 RequestFormats(context, formats, custom_formats, time); |
220 | 220 |
221 waiting_for_data_ = true; | 221 waiting_for_data_ = true; |
222 | 222 |
223 return TRUE; | 223 return TRUE; |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 int drag_operation = DragDropTypes::GdkDragActionToDragOperation( | 227 int drag_operation = ui::DragDropTypes::GdkDragActionToDragOperation( |
228 context->actions); | 228 context->actions); |
229 drag_operation = helper_.OnDragOver(*data_, root_view_location, | 229 drag_operation = helper_.OnDragOver(*data_, root_view_location, |
230 drag_operation); | 230 drag_operation); |
231 if (!received_drop_) { | 231 if (!received_drop_) { |
232 GdkDragAction gdk_action = | 232 GdkDragAction gdk_action = |
233 static_cast<GdkDragAction>( | 233 static_cast<GdkDragAction>( |
234 DragDropTypes::DragOperationToGdkDragAction(drag_operation)); | 234 ui::DragDropTypes::DragOperationToGdkDragAction(drag_operation)); |
235 gdk_drag_status(context, gdk_action, time); | 235 gdk_drag_status(context, gdk_action, time); |
236 } | 236 } |
237 return TRUE; | 237 return TRUE; |
238 } | 238 } |
239 | 239 |
240 void DropTargetGtk::FinishDrop(GdkDragContext* context, | 240 void DropTargetGtk::FinishDrop(GdkDragContext* context, |
241 gint x, gint y, guint time) { | 241 gint x, gint y, guint time) { |
242 gfx::Point root_view_location(x, y); | 242 gfx::Point root_view_location(x, y); |
243 int drag_operation = DragDropTypes::GdkDragActionToDragOperation( | 243 int drag_operation = ui::DragDropTypes::GdkDragActionToDragOperation( |
244 context->actions); | 244 context->actions); |
245 drag_operation = helper_.OnDrop(*data_, root_view_location, | 245 drag_operation = helper_.OnDrop(*data_, root_view_location, |
246 drag_operation); | 246 drag_operation); |
247 GdkDragAction gdk_action = | 247 GdkDragAction gdk_action = |
248 static_cast<GdkDragAction>( | 248 static_cast<GdkDragAction>( |
249 DragDropTypes::DragOperationToGdkDragAction(drag_operation)); | 249 ui::DragDropTypes::DragOperationToGdkDragAction(drag_operation)); |
250 gtk_drag_finish(context, gdk_action != 0, (gdk_action & GDK_ACTION_MOVE), | 250 gtk_drag_finish(context, gdk_action != 0, (gdk_action & GDK_ACTION_MOVE), |
251 time); | 251 time); |
252 | 252 |
253 static_cast<WidgetGtk*>(helper_.root_view()->GetWidget())->ResetDropTarget(); | 253 static_cast<WidgetGtk*>(helper_.root_view()->GetWidget())->ResetDropTarget(); |
254 // WARNING: we've been deleted. | 254 // WARNING: we've been deleted. |
255 } | 255 } |
256 | 256 |
257 void DropTargetGtk::IntersectFormats(int f1, const std::set<GdkAtom>& cf1, | 257 void DropTargetGtk::IntersectFormats(int f1, const std::set<GdkAtom>& cf1, |
258 int* f2, std::set<GdkAtom>* cf2) { | 258 int* f2, std::set<GdkAtom>* cf2) { |
259 *f2 = (*f2 & f1); | 259 *f2 = (*f2 & f1); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 gtk_drag_get_data(widget, context, *i, time); | 329 gtk_drag_get_data(widget, context, *i, time); |
330 } | 330 } |
331 } | 331 } |
332 } | 332 } |
333 | 333 |
334 OSExchangeDataProviderGtk& DropTargetGtk::data_provider() const { | 334 OSExchangeDataProviderGtk& DropTargetGtk::data_provider() const { |
335 return static_cast<OSExchangeDataProviderGtk&>(data_->provider()); | 335 return static_cast<OSExchangeDataProviderGtk&>(data_->provider()); |
336 } | 336 } |
337 | 337 |
338 } // namespace views | 338 } // namespace views |
OLD | NEW |