| 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 "ash/drag_drop/drag_drop_controller.h" | 5 #include "ash/drag_drop/drag_drop_controller.h" |
| 6 | 6 |
| 7 #include "ash/drag_drop/drag_drop_tracker.h" | 7 #include "ash/drag_drop/drag_drop_tracker.h" |
| 8 #include "ash/drag_drop/drag_image_view.h" | 8 #include "ash/drag_drop/drag_image_view.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/coordinate_conversion.h" | 10 #include "ash/wm/coordinate_conversion.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 int DragDropController::StartDragAndDrop( | 99 int DragDropController::StartDragAndDrop( |
| 100 const ui::OSExchangeData& data, | 100 const ui::OSExchangeData& data, |
| 101 aura::RootWindow* root_window, | 101 aura::RootWindow* root_window, |
| 102 aura::Window* source_window, | 102 aura::Window* source_window, |
| 103 const gfx::Point& root_location, | 103 const gfx::Point& root_location, |
| 104 int operation, | 104 int operation, |
| 105 ui::DragDropTypes::DragEventSource source) { | 105 ui::DragDropTypes::DragEventSource source) { |
| 106 if (IsDragDropInProgress()) | 106 if (IsDragDropInProgress()) |
| 107 return 0; | 107 return 0; |
| 108 | 108 |
| 109 #if defined(OS_WIN) |
| 110 // TODO(win_ash): need to figure out how this will work in Metro, since |
| 111 // OSExchangeDataProviderAura isn't used in Windows builds. Two alternatives: |
| 112 // 1) Use OSExchangeDataProviderAura in Ash and OSExchangeDataProviderWin |
| 113 // elsewhere. This will complicate creating an ui::OSExchangeData to pass |
| 114 // in more context. |
| 115 // 2) Add methods to get the image and offset in the base interface of these |
| 116 // implementations to get to this data here. |
| 117 NOTIMPLEMENTED(); |
| 118 return 0; |
| 119 #else |
| 109 const ui::OSExchangeDataProviderAura& provider = | 120 const ui::OSExchangeDataProviderAura& provider = |
| 110 static_cast<const ui::OSExchangeDataProviderAura&>(data.provider()); | 121 static_cast<const ui::OSExchangeDataProviderAura&>(data.provider()); |
| 111 // We do not support touch drag/drop without a drag image. | 122 // We do not support touch drag/drop without a drag image. |
| 112 if (source == ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH && | 123 if (source == ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH && |
| 113 provider.drag_image().size().IsEmpty()) | 124 provider.drag_image().size().IsEmpty()) |
| 114 return 0; | 125 return 0; |
| 115 | 126 |
| 116 current_drag_event_source_ = source; | 127 current_drag_event_source_ = source; |
| 117 DragDropTracker* tracker = new DragDropTracker(root_window); | 128 DragDropTracker* tracker = new DragDropTracker(root_window); |
| 118 if (source == ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) { | 129 if (source == ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 #endif // !defined(OS_MACOSX) | 184 #endif // !defined(OS_MACOSX) |
| 174 | 185 |
| 175 if (!cancel_animation_.get() || !cancel_animation_->is_animating() || | 186 if (!cancel_animation_.get() || !cancel_animation_->is_animating() || |
| 176 !pending_long_tap_.get()) { | 187 !pending_long_tap_.get()) { |
| 177 // If drag cancel animation is running, this cleanup is done when the | 188 // If drag cancel animation is running, this cleanup is done when the |
| 178 // animation completes. | 189 // animation completes. |
| 179 if (drag_source_window_) | 190 if (drag_source_window_) |
| 180 drag_source_window_->RemoveObserver(this); | 191 drag_source_window_->RemoveObserver(this); |
| 181 drag_source_window_ = NULL; | 192 drag_source_window_ = NULL; |
| 182 } | 193 } |
| 194 #endif |
| 183 | 195 |
| 184 return drag_operation_; | 196 return drag_operation_; |
| 185 } | 197 } |
| 186 | 198 |
| 187 void DragDropController::DragUpdate(aura::Window* target, | 199 void DragDropController::DragUpdate(aura::Window* target, |
| 188 const ui::LocatedEvent& event) { | 200 const ui::LocatedEvent& event) { |
| 189 aura::client::DragDropDelegate* delegate = NULL; | 201 aura::client::DragDropDelegate* delegate = NULL; |
| 190 if (target != drag_window_) { | 202 if (target != drag_window_) { |
| 191 if (drag_window_) { | 203 if (drag_window_) { |
| 192 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) | 204 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 drag_window_->RemoveObserver(this); | 502 drag_window_->RemoveObserver(this); |
| 491 drag_window_ = NULL; | 503 drag_window_ = NULL; |
| 492 drag_data_ = NULL; | 504 drag_data_ = NULL; |
| 493 // Cleanup can be called again while deleting DragDropTracker, so use Pass | 505 // Cleanup can be called again while deleting DragDropTracker, so use Pass |
| 494 // instead of reset to avoid double free. | 506 // instead of reset to avoid double free. |
| 495 drag_drop_tracker_.Pass(); | 507 drag_drop_tracker_.Pass(); |
| 496 } | 508 } |
| 497 | 509 |
| 498 } // namespace internal | 510 } // namespace internal |
| 499 } // namespace ash | 511 } // namespace ash |
| OLD | NEW |