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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/drag_drop/drag_drop_tracker.h" | 9 #include "ash/drag_drop/drag_drop_tracker.h" |
10 #include "ash/drag_drop/drag_image_view.h" | 10 #include "ash/drag_drop/drag_image_view.h" |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 event->StopPropagation(); | 365 event->StopPropagation(); |
366 return; | 366 return; |
367 } | 367 } |
368 | 368 |
369 aura::Window* translated_target = drag_drop_tracker_->GetTarget(*event); | 369 aura::Window* translated_target = drag_drop_tracker_->GetTarget(*event); |
370 if (!translated_target) { | 370 if (!translated_target) { |
371 DragCancel(); | 371 DragCancel(); |
372 event->StopPropagation(); | 372 event->StopPropagation(); |
373 return; | 373 return; |
374 } | 374 } |
375 scoped_ptr<ui::LocatedEvent> translated_event( | 375 std::unique_ptr<ui::LocatedEvent> translated_event( |
376 drag_drop_tracker_->ConvertEvent(translated_target, *event)); | 376 drag_drop_tracker_->ConvertEvent(translated_target, *event)); |
377 switch (translated_event->type()) { | 377 switch (translated_event->type()) { |
378 case ui::ET_MOUSE_DRAGGED: | 378 case ui::ET_MOUSE_DRAGGED: |
379 DragUpdate(translated_target, *translated_event.get()); | 379 DragUpdate(translated_target, *translated_event.get()); |
380 break; | 380 break; |
381 case ui::ET_MOUSE_RELEASED: | 381 case ui::ET_MOUSE_RELEASED: |
382 Drop(translated_target, *translated_event.get()); | 382 Drop(translated_target, *translated_event.get()); |
383 break; | 383 break; |
384 default: | 384 default: |
385 // We could also reach here because RootWindow may sometimes generate a | 385 // We could also reach here because RootWindow may sometimes generate a |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 touch_offset_event.set_location_f(touch_offset_location); | 433 touch_offset_event.set_location_f(touch_offset_location); |
434 touch_offset_event.set_root_location_f(touch_offset_root_location); | 434 touch_offset_event.set_root_location_f(touch_offset_root_location); |
435 | 435 |
436 aura::Window* translated_target = | 436 aura::Window* translated_target = |
437 drag_drop_tracker_->GetTarget(touch_offset_event); | 437 drag_drop_tracker_->GetTarget(touch_offset_event); |
438 if (!translated_target) { | 438 if (!translated_target) { |
439 DragCancel(); | 439 DragCancel(); |
440 event->SetHandled(); | 440 event->SetHandled(); |
441 return; | 441 return; |
442 } | 442 } |
443 scoped_ptr<ui::LocatedEvent> translated_event( | 443 std::unique_ptr<ui::LocatedEvent> translated_event( |
444 drag_drop_tracker_->ConvertEvent(translated_target, touch_offset_event)); | 444 drag_drop_tracker_->ConvertEvent(translated_target, touch_offset_event)); |
445 | 445 |
446 switch (event->type()) { | 446 switch (event->type()) { |
447 case ui::ET_GESTURE_SCROLL_UPDATE: | 447 case ui::ET_GESTURE_SCROLL_UPDATE: |
448 DragUpdate(translated_target, *translated_event.get()); | 448 DragUpdate(translated_target, *translated_event.get()); |
449 break; | 449 break; |
450 case ui::ET_GESTURE_SCROLL_END: | 450 case ui::ET_GESTURE_SCROLL_END: |
451 case ui::ET_SCROLL_FLING_START: | 451 case ui::ET_SCROLL_FLING_START: |
452 Drop(translated_target, *translated_event.get()); | 452 Drop(translated_target, *translated_event.get()); |
453 break; | 453 break; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 drag_source_window_ = NULL; | 560 drag_source_window_ = NULL; |
561 } | 561 } |
562 | 562 |
563 void DragDropController::Cleanup() { | 563 void DragDropController::Cleanup() { |
564 if (drag_window_) | 564 if (drag_window_) |
565 drag_window_->RemoveObserver(this); | 565 drag_window_->RemoveObserver(this); |
566 drag_window_ = NULL; | 566 drag_window_ = NULL; |
567 drag_data_ = NULL; | 567 drag_data_ = NULL; |
568 // Cleanup can be called again while deleting DragDropTracker, so delete | 568 // Cleanup can be called again while deleting DragDropTracker, so delete |
569 // the pointer with a local variable to avoid double free. | 569 // the pointer with a local variable to avoid double free. |
570 scoped_ptr<ash::DragDropTracker> holder = std::move(drag_drop_tracker_); | 570 std::unique_ptr<ash::DragDropTracker> holder = std::move(drag_drop_tracker_); |
571 } | 571 } |
572 | 572 |
573 } // namespace ash | 573 } // namespace ash |
OLD | NEW |