data_device_delegate.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2017 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 COMPONENTS_EXO_DATA_DEVICE_DELEGATE_H_
  5. #define COMPONENTS_EXO_DATA_DEVICE_DELEGATE_H_
  6. #include "components/exo/data_offer.h"
  7. namespace base {
  8. class TimeTicks;
  9. }
  10. namespace gfx {
  11. class PointF;
  12. }
  13. namespace exo {
  14. class DataDevice;
  15. class Surface;
  16. enum class DndAction;
  17. // Handles events on data devices in context-specific ways.
  18. class DataDeviceDelegate {
  19. public:
  20. // Called at the top of the data device's destructor, to give observers a
  21. // chance to remove themselves.
  22. virtual void OnDataDeviceDestroying(DataDevice* data_device) = 0;
  23. // Called when DataOffer object is delivered from a client. DataDeviceDelegate
  24. // has responsibility to release the returned DataOffer object.
  25. virtual DataOffer* OnDataOffer() = 0;
  26. // Called during a drag operation when pointer enters |surface|.
  27. virtual void OnEnter(Surface* surface,
  28. const gfx::PointF& location,
  29. const DataOffer& data_offer) = 0;
  30. // Called during a drag operation when pointer leaves |surface|.
  31. virtual void OnLeave() = 0;
  32. // Called during a drag operation when pointer moves on the |surface|.
  33. virtual void OnMotion(base::TimeTicks time_stamp,
  34. const gfx::PointF& location) = 0;
  35. // Called during a drag operation when user drops dragging data on the
  36. // |surface|.
  37. virtual void OnDrop() = 0;
  38. // Called when the data is pasted on the DataDevice.
  39. virtual void OnSelection(const DataOffer& data_offer) = 0;
  40. // This should return true if |surface| is a valid target for this data
  41. // device. E.g. the surface is owned by the same client as the data device.
  42. virtual bool CanAcceptDataEventsForSurface(Surface* surface) const = 0;
  43. protected:
  44. virtual ~DataDeviceDelegate() {}
  45. };
  46. } // namespace exo
  47. #endif // COMPONENTS_EXO_DATA_DEVICE_DELEGATE_H_