| 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_image_view.h" | 7 #include "ash/drag_drop/drag_image_view.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "ui/aura/client/drag_drop_delegate.h" | 10 #include "ui/aura/client/drag_drop_delegate.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 drag_image_->SetScreenPosition( | 124 drag_image_->SetScreenPosition( |
| 125 event.root_location().Subtract(drag_image_offset_)); | 125 event.root_location().Subtract(drag_image_offset_)); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 void DragDropController::Drop(aura::Window* target, | 129 void DragDropController::Drop(aura::Window* target, |
| 130 const aura::LocatedEvent& event) { | 130 const aura::LocatedEvent& event) { |
| 131 Shell::GetRootWindow()->SetCursor(ui::kCursorPointer); | 131 Shell::GetRootWindow()->SetCursor(ui::kCursorPointer); |
| 132 aura::client::DragDropDelegate* delegate = NULL; | 132 aura::client::DragDropDelegate* delegate = NULL; |
| 133 | 133 |
| 134 // |drag_window_| can be NULL if we have just started the drag and have not | 134 // We must guarantee that a target gets a OnDragEntered before Drop. WebKit |
| 135 // received any DragUpdates, or, if the |drag_window_| gets destroyed during | 135 // depends on not getting a Drop without DragEnter. This behavior is |
| 136 // a drag/drop. Otherwise, target should be equal to the |drag_window_|. | 136 // consistent with drag/drop on other platforms. |
| 137 DCHECK(target == drag_window_ || !drag_window_); | 137 if (target != drag_window_) |
| 138 DragUpdate(target, event); |
| 139 DCHECK(target == drag_window_); |
| 140 |
| 138 if ((delegate = aura::client::GetDragDropDelegate(target))) { | 141 if ((delegate = aura::client::GetDragDropDelegate(target))) { |
| 139 aura::DropTargetEvent e( | 142 aura::DropTargetEvent e( |
| 140 *drag_data_, event.location(), event.root_location(), drag_operation_); | 143 *drag_data_, event.location(), event.root_location(), drag_operation_); |
| 141 drag_operation_ = delegate->OnPerformDrop(e); | 144 drag_operation_ = delegate->OnPerformDrop(e); |
| 142 if (drag_operation_ == 0) | 145 if (drag_operation_ == 0) |
| 143 StartCanceledAnimation(); | 146 StartCanceledAnimation(); |
| 144 else | 147 else |
| 145 drag_image_.reset(); | 148 drag_image_.reset(); |
| 146 } else { | 149 } else { |
| 147 drag_image_.reset(); | 150 drag_image_.reset(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 void DragDropController::Cleanup() { | 267 void DragDropController::Cleanup() { |
| 265 if (drag_window_) | 268 if (drag_window_) |
| 266 drag_window_->RemoveObserver(this); | 269 drag_window_->RemoveObserver(this); |
| 267 drag_window_ = NULL; | 270 drag_window_ = NULL; |
| 268 drag_data_ = NULL; | 271 drag_data_ = NULL; |
| 269 drag_drop_in_progress_ = false; | 272 drag_drop_in_progress_ = false; |
| 270 } | 273 } |
| 271 | 274 |
| 272 } // namespace internal | 275 } // namespace internal |
| 273 } // namespace ash | 276 } // namespace ash |
| OLD | NEW |