extended_drag_offer.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2020 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_EXTENDED_DRAG_OFFER_H_
  5. #define COMPONENTS_EXO_EXTENDED_DRAG_OFFER_H_
  6. #include <cstdint>
  7. #include <string>
  8. #include "components/exo/data_offer_observer.h"
  9. namespace gfx {
  10. class Vector2d;
  11. }
  12. namespace exo {
  13. class DataOffer;
  14. class ExtendedDragOffer : public DataOfferObserver {
  15. public:
  16. class Delegate {
  17. public:
  18. virtual void OnDataOfferDestroying() = 0;
  19. protected:
  20. virtual ~Delegate() = default;
  21. };
  22. ExtendedDragOffer(DataOffer* offer, Delegate* delegate);
  23. ExtendedDragOffer(const ExtendedDragOffer&) = delete;
  24. ExtendedDragOffer& operator=(const ExtendedDragOffer&) = delete;
  25. ~ExtendedDragOffer() override;
  26. void Swallow(uint32_t serial, const std::string& mime_type);
  27. void Unswallow(uint32_t serial,
  28. const std::string& mime_type,
  29. const gfx::Vector2d& offset);
  30. private:
  31. // DataOfferObserver:
  32. void OnDataOfferDestroying(DataOffer* offer) override;
  33. DataOffer* offer_ = nullptr;
  34. // Created and destroyed at wayland/zcr_extended_drag.cc and its lifetime is
  35. // tied to the zcr_extended_drag_source_v1 object it's attached to.
  36. Delegate* const delegate_;
  37. };
  38. } // namespace exo
  39. #endif // COMPONENTS_EXO_EXTENDED_DRAG_OFFER_H_