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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 DragDropController::DragDropController() | 141 DragDropController::DragDropController() |
142 : drag_image_(NULL), | 142 : drag_image_(NULL), |
143 drag_data_(NULL), | 143 drag_data_(NULL), |
144 drag_operation_(0), | 144 drag_operation_(0), |
145 drag_window_(NULL), | 145 drag_window_(NULL), |
146 drag_source_window_(NULL), | 146 drag_source_window_(NULL), |
147 should_block_during_drag_drop_(true), | 147 should_block_during_drag_drop_(true), |
148 drag_drop_window_delegate_(new DragDropTrackerDelegate(this)), | 148 drag_drop_window_delegate_(new DragDropTrackerDelegate(this)), |
149 current_drag_event_source_(ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE), | 149 current_drag_event_source_(ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE), |
150 weak_factory_(this) { | 150 weak_factory_(this) { |
151 Shell::GetInstance()->AddPreTargetHandler(this); | 151 Shell::GetInstance()->PrependPreTargetHandler(this); |
152 } | 152 } |
153 | 153 |
154 DragDropController::~DragDropController() { | 154 DragDropController::~DragDropController() { |
155 Shell::GetInstance()->RemovePreTargetHandler(this); | 155 Shell::GetInstance()->RemovePreTargetHandler(this); |
156 Cleanup(); | 156 Cleanup(); |
157 if (cancel_animation_) | 157 if (cancel_animation_) |
158 cancel_animation_->End(); | 158 cancel_animation_->End(); |
159 if (drag_image_) | 159 if (drag_image_) |
160 drag_image_.reset(); | 160 drag_image_.reset(); |
161 } | 161 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 drag_image_vertical_offset, drag_image_scale, &drag_image_offset_); | 219 drag_image_vertical_offset, drag_image_scale, &drag_image_offset_); |
220 drag_image_->SetBoundsInScreen(drag_image_bounds); | 220 drag_image_->SetBoundsInScreen(drag_image_bounds); |
221 drag_image_->SetWidgetVisible(true); | 221 drag_image_->SetWidgetVisible(true); |
222 | 222 |
223 drag_window_ = NULL; | 223 drag_window_ = NULL; |
224 | 224 |
225 // Ends cancel animation if it's in progress. | 225 // Ends cancel animation if it's in progress. |
226 if (cancel_animation_) | 226 if (cancel_animation_) |
227 cancel_animation_->End(); | 227 cancel_animation_->End(); |
228 | 228 |
229 // Become the first event handler since we should get first shot at handling | |
230 // any events during the drag drop session. | |
231 Shell::GetInstance()->RemovePreTargetHandler(this); | |
232 Shell::GetInstance()->PrependPreTargetHandler(this); | |
233 | |
234 | |
235 #if !defined(OS_MACOSX) | 229 #if !defined(OS_MACOSX) |
236 if (should_block_during_drag_drop_) { | 230 if (should_block_during_drag_drop_) { |
237 base::RunLoop run_loop(aura::Env::GetInstance()->GetDispatcher()); | 231 base::RunLoop run_loop(aura::Env::GetInstance()->GetDispatcher()); |
238 quit_closure_ = run_loop.QuitClosure(); | 232 quit_closure_ = run_loop.QuitClosure(); |
239 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); | 233 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
240 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); | 234 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); |
241 run_loop.Run(); | 235 run_loop.Run(); |
242 } | 236 } |
243 #endif // !defined(OS_MACOSX) | 237 #endif // !defined(OS_MACOSX) |
244 | 238 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 drag_window_->RemoveObserver(this); | 559 drag_window_->RemoveObserver(this); |
566 drag_window_ = NULL; | 560 drag_window_ = NULL; |
567 drag_data_ = NULL; | 561 drag_data_ = NULL; |
568 // Cleanup can be called again while deleting DragDropTracker, so use Pass | 562 // Cleanup can be called again while deleting DragDropTracker, so use Pass |
569 // instead of reset to avoid double free. | 563 // instead of reset to avoid double free. |
570 drag_drop_tracker_.Pass(); | 564 drag_drop_tracker_.Pass(); |
571 } | 565 } |
572 | 566 |
573 } // namespace internal | 567 } // namespace internal |
574 } // namespace ash | 568 } // namespace ash |
OLD | NEW |