Nick Diego Yamane | 92544dc | 2020-09-27 15:40:13 | [diff] [blame] | 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 | |
| 5 | #ifndef COMPONENTS_EXO_EXTENDED_DRAG_OFFER_H_ |
| 6 | #define COMPONENTS_EXO_EXTENDED_DRAG_OFFER_H_ |
| 7 | |
| 8 | #include <cstdint> |
| 9 | #include <string> |
| 10 | |
| 11 | #include "components/exo/data_offer_observer.h" |
| 12 | |
| 13 | namespace gfx { |
| 14 | class Vector2d; |
| 15 | } |
| 16 | |
| 17 | namespace exo { |
| 18 | |
| 19 | class DataOffer; |
| 20 | |
| 21 | class ExtendedDragOffer : public DataOfferObserver { |
| 22 | public: |
| 23 | class Delegate { |
| 24 | public: |
| 25 | virtual void OnDataOfferDestroying() = 0; |
| 26 | |
| 27 | protected: |
| 28 | virtual ~Delegate() = default; |
| 29 | }; |
| 30 | |
| 31 | ExtendedDragOffer(DataOffer* offer, Delegate* delegate); |
| 32 | ExtendedDragOffer(const ExtendedDragOffer&) = delete; |
| 33 | ExtendedDragOffer& operator=(const ExtendedDragOffer&) = delete; |
| 34 | ~ExtendedDragOffer() override; |
| 35 | |
| 36 | void Swallow(uint32_t serial, const std::string& mime_type); |
| 37 | void Unswallow(uint32_t serial, |
| 38 | const std::string& mime_type, |
| 39 | const gfx::Vector2d& offset); |
| 40 | |
| 41 | private: |
| 42 | // DataOfferObserver: |
| 43 | void OnDataOfferDestroying(DataOffer* offer) override; |
| 44 | |
| 45 | DataOffer* offer_ = nullptr; |
| 46 | |
| 47 | // Created and destroyed at wayland/zcr_extended_drag.cc and its lifetime is |
| 48 | // tied to the zcr_extended_drag_source_v1 object it's attached to. |
| 49 | Delegate* const delegate_; |
| 50 | }; |
| 51 | |
| 52 | } // namespace exo |
| 53 | |
| 54 | #endif // COMPONENTS_EXO_EXTENDED_DRAG_OFFER_H_ |