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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 } else { | 429 } else { |
430 aura::client::DragDropDelegate* delegate = | 430 aura::client::DragDropDelegate* delegate = |
431 aura::client::GetDragDropDelegate(drag_window_); | 431 aura::client::GetDragDropDelegate(drag_window_); |
432 if (delegate) { | 432 if (delegate) { |
433 ui::DropTargetEvent e(*drag_data_, gfx::Point(), gfx::Point(), | 433 ui::DropTargetEvent e(*drag_data_, gfx::Point(), gfx::Point(), |
434 drag_operation_); | 434 drag_operation_); |
435 e.set_location_f(event.location_f()); | 435 e.set_location_f(event.location_f()); |
436 e.set_root_location_f(event.root_location_f()); | 436 e.set_root_location_f(event.root_location_f()); |
437 e.set_flags(event.flags()); | 437 e.set_flags(event.flags()); |
438 op = delegate->OnDragUpdated(e); | 438 op = delegate->OnDragUpdated(e); |
439 gfx::NativeCursor cursor = ui::kCursorNoDrop; | 439 gfx::NativeCursor cursor = ui::CursorType::kNoDrop; |
440 if (op & ui::DragDropTypes::DRAG_COPY) | 440 if (op & ui::DragDropTypes::DRAG_COPY) |
441 cursor = ui::kCursorCopy; | 441 cursor = ui::CursorType::kCopy; |
442 else if (op & ui::DragDropTypes::DRAG_LINK) | 442 else if (op & ui::DragDropTypes::DRAG_LINK) |
443 cursor = ui::kCursorAlias; | 443 cursor = ui::CursorType::kAlias; |
444 else if (op & ui::DragDropTypes::DRAG_MOVE) | 444 else if (op & ui::DragDropTypes::DRAG_MOVE) |
445 cursor = ui::kCursorGrabbing; | 445 cursor = ui::CursorType::kGrabbing; |
446 ash::Shell::Get()->cursor_manager()->SetCursor(cursor); | 446 ash::Shell::Get()->cursor_manager()->SetCursor(cursor); |
447 } | 447 } |
448 } | 448 } |
449 | 449 |
450 DCHECK(drag_image_.get()); | 450 DCHECK(drag_image_.get()); |
451 if (drag_image_->visible()) { | 451 if (drag_image_->visible()) { |
452 gfx::Point root_location_in_screen = event.root_location(); | 452 gfx::Point root_location_in_screen = event.root_location(); |
453 ::wm::ConvertPointToScreen(target->GetRootWindow(), | 453 ::wm::ConvertPointToScreen(target->GetRootWindow(), |
454 &root_location_in_screen); | 454 &root_location_in_screen); |
455 drag_image_->SetScreenPosition(root_location_in_screen - | 455 drag_image_->SetScreenPosition(root_location_in_screen - |
456 drag_image_offset_); | 456 drag_image_offset_); |
457 drag_image_->SetTouchDragOperation(op); | 457 drag_image_->SetTouchDragOperation(op); |
458 } | 458 } |
459 } | 459 } |
460 | 460 |
461 void DragDropController::Drop(aura::Window* target, | 461 void DragDropController::Drop(aura::Window* target, |
462 const ui::LocatedEvent& event) { | 462 const ui::LocatedEvent& event) { |
463 ash::Shell::Get()->cursor_manager()->SetCursor(ui::kCursorPointer); | 463 ash::Shell::Get()->cursor_manager()->SetCursor(ui::CursorType::kPointer); |
464 | 464 |
465 // We must guarantee that a target gets a OnDragEntered before Drop. WebKit | 465 // We must guarantee that a target gets a OnDragEntered before Drop. WebKit |
466 // depends on not getting a Drop without DragEnter. This behavior is | 466 // depends on not getting a Drop without DragEnter. This behavior is |
467 // consistent with drag/drop on other platforms. | 467 // consistent with drag/drop on other platforms. |
468 if (target != drag_window_) | 468 if (target != drag_window_) |
469 DragUpdate(target, event); | 469 DragUpdate(target, event); |
470 DCHECK(target == drag_window_); | 470 DCHECK(target == drag_window_); |
471 | 471 |
472 aura::client::DragDropDelegate* delegate = | 472 aura::client::DragDropDelegate* delegate = |
473 aura::client::GetDragDropDelegate(target); | 473 aura::client::GetDragDropDelegate(target); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 } else { | 508 } else { |
509 // See comment about this in OnGestureEvent(). | 509 // See comment about this in OnGestureEvent(). |
510 base::ThreadTaskRunnerHandle::Get()->PostTask( | 510 base::ThreadTaskRunnerHandle::Get()->PostTask( |
511 FROM_HERE, base::Bind(&DragDropController::ForwardPendingLongTap, | 511 FROM_HERE, base::Bind(&DragDropController::ForwardPendingLongTap, |
512 weak_factory_.GetWeakPtr())); | 512 weak_factory_.GetWeakPtr())); |
513 } | 513 } |
514 } | 514 } |
515 } | 515 } |
516 | 516 |
517 void DragDropController::DoDragCancel(int drag_cancel_animation_duration_ms) { | 517 void DragDropController::DoDragCancel(int drag_cancel_animation_duration_ms) { |
518 ash::Shell::Get()->cursor_manager()->SetCursor(ui::kCursorPointer); | 518 ash::Shell::Get()->cursor_manager()->SetCursor(ui::CursorType::kPointer); |
519 | 519 |
520 // |drag_window_| can be NULL if we have just started the drag and have not | 520 // |drag_window_| can be NULL if we have just started the drag and have not |
521 // received any DragUpdates, or, if the |drag_window_| gets destroyed during | 521 // received any DragUpdates, or, if the |drag_window_| gets destroyed during |
522 // a drag/drop. | 522 // a drag/drop. |
523 aura::client::DragDropDelegate* delegate = | 523 aura::client::DragDropDelegate* delegate = |
524 drag_window_ ? aura::client::GetDragDropDelegate(drag_window_) : NULL; | 524 drag_window_ ? aura::client::GetDragDropDelegate(drag_window_) : NULL; |
525 if (delegate) | 525 if (delegate) |
526 delegate->OnDragExited(); | 526 delegate->OnDragExited(); |
527 | 527 |
528 Cleanup(); | 528 Cleanup(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 if (drag_window_) | 575 if (drag_window_) |
576 drag_window_->RemoveObserver(this); | 576 drag_window_->RemoveObserver(this); |
577 drag_window_ = NULL; | 577 drag_window_ = NULL; |
578 drag_data_ = NULL; | 578 drag_data_ = NULL; |
579 // Cleanup can be called again while deleting DragDropTracker, so delete | 579 // Cleanup can be called again while deleting DragDropTracker, so delete |
580 // the pointer with a local variable to avoid double free. | 580 // the pointer with a local variable to avoid double free. |
581 std::unique_ptr<ash::DragDropTracker> holder = std::move(drag_drop_tracker_); | 581 std::unique_ptr<ash::DragDropTracker> holder = std::move(drag_drop_tracker_); |
582 } | 582 } |
583 | 583 |
584 } // namespace ash | 584 } // namespace ash |
OLD | NEW |