blob: 81960c6ebf7c750542de5586fb3cdc6d54de3432 [file] [log] [blame]
Nick Diego Yamane92544dc2020-09-27 15:40:131// 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
13namespace gfx {
14class Vector2d;
15}
16
17namespace exo {
18
19class DataOffer;
20
21class 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_