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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } | 278 } |
279 | 279 |
280 void DragDropController::DragCancel() { | 280 void DragDropController::DragCancel() { |
281 DoDragCancel(kCancelAnimationDuration); | 281 DoDragCancel(kCancelAnimationDuration); |
282 } | 282 } |
283 | 283 |
284 bool DragDropController::IsDragDropInProgress() { | 284 bool DragDropController::IsDragDropInProgress() { |
285 return !!drag_drop_tracker_.get(); | 285 return !!drag_drop_tracker_.get(); |
286 } | 286 } |
287 | 287 |
288 ui::EventResult DragDropController::OnKeyEvent(ui::KeyEvent* event) { | 288 void DragDropController::OnKeyEvent(ui::KeyEvent* event) { |
289 if (IsDragDropInProgress() && event->key_code() == ui::VKEY_ESCAPE) { | 289 if (IsDragDropInProgress() && event->key_code() == ui::VKEY_ESCAPE) { |
290 DragCancel(); | 290 DragCancel(); |
291 return ui::ER_CONSUMED; | 291 event->StopPropagation(); |
292 } | 292 } |
293 return ui::ER_UNHANDLED; | |
294 } | 293 } |
295 | 294 |
296 ui::EventResult DragDropController::OnMouseEvent(ui::MouseEvent* event) { | 295 ui::EventResult DragDropController::OnMouseEvent(ui::MouseEvent* event) { |
297 if (!IsDragDropInProgress()) | 296 if (!IsDragDropInProgress()) |
298 return ui::ER_UNHANDLED; | 297 return ui::ER_UNHANDLED; |
299 | 298 |
300 // If current drag session was not started by mouse, dont process this mouse | 299 // If current drag session was not started by mouse, dont process this mouse |
301 // event, but consume it so it does not interfere with current drag session. | 300 // event, but consume it so it does not interfere with current drag session. |
302 if (current_drag_event_source_ != ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE) | 301 if (current_drag_event_source_ != ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE) |
303 return ui::ER_CONSUMED; | 302 return ui::ER_CONSUMED; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 drag_window_->RemoveObserver(this); | 498 drag_window_->RemoveObserver(this); |
500 drag_window_ = NULL; | 499 drag_window_ = NULL; |
501 drag_data_ = NULL; | 500 drag_data_ = NULL; |
502 // Cleanup can be called again while deleting DragDropTracker, so use Pass | 501 // Cleanup can be called again while deleting DragDropTracker, so use Pass |
503 // instead of reset to avoid double free. | 502 // instead of reset to avoid double free. |
504 drag_drop_tracker_.Pass(); | 503 drag_drop_tracker_.Pass(); |
505 } | 504 } |
506 | 505 |
507 } // namespace internal | 506 } // namespace internal |
508 } // namespace ash | 507 } // namespace ash |
OLD | NEW |