app_list_drag_and_drop_host.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_APP_LIST_VIEWS_APP_LIST_DRAG_AND_DROP_HOST_H_
  5. #define ASH_APP_LIST_VIEWS_APP_LIST_DRAG_AND_DROP_HOST_H_
  6. #include <memory>
  7. #include <string>
  8. #include "ash/app_list/views/app_drag_icon_proxy.h"
  9. namespace gfx {
  10. class Point;
  11. } // namespace gfx
  12. namespace ash {
  13. class AppDragIconProxy;
  14. // This class will get used by the AppListView to drag and drop Application
  15. // shortcuts onto another host (the shelf).
  16. class ApplicationDragAndDropHost {
  17. public:
  18. // Returns whether the host wants to handle the drag operation.
  19. virtual bool ShouldHandleDrag(const std::string& app_id,
  20. const gfx::Point& location_in_screen) const = 0;
  21. // A drag operation could get started. The recipient has to return true if
  22. // it wants to take it - e.g. `location_in_screen` is over a
  23. // target area. The passed `app_id` identifies the application which should
  24. // get dropped.
  25. virtual bool StartDrag(const std::string& app_id,
  26. const gfx::Point& location_in_screen,
  27. const gfx::Rect& drag_icon_bounds_in_screen) = 0;
  28. // This gets only called when the `StartDrag()` function returned true and it
  29. // dispatches the mouse coordinate change accordingly. When the function
  30. // returns false it requests that the operation be aborted since the event
  31. // location is out of bounds.
  32. virtual bool Drag(const gfx::Point& location_in_screen,
  33. const gfx::Rect& drag_icon_bounds_in_screen) = 0;
  34. // Once `StartDrag()` returned true, this function is guaranteed to be called
  35. // when the mouse / touch events stop. If `cancel` is set, the drag operation
  36. // was aborted, otherwise the change should be kept.
  37. // `icon_proxy` is a drag icon proxy that was created for drag, which will be
  38. // set if the host is expected to handle icon animations on drag end.
  39. virtual void EndDrag(bool cancel,
  40. std::unique_ptr<AppDragIconProxy> icon_proxy) = 0;
  41. };
  42. } // namespace ash
  43. #endif // ASH_APP_LIST_VIEWS_APP_LIST_DRAG_AND_DROP_HOST_H_