OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_MUS_CLIPBOARD_CLIPBOARD_IMPL_H_ |
| 6 #define COMPONENTS_MUS_CLIPBOARD_CLIPBOARD_IMPL_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <string> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "components/mus/public/interfaces/clipboard.mojom.h" |
| 14 #include "mojo/public/cpp/bindings/binding_set.h" |
| 15 |
| 16 namespace mus { |
| 17 namespace clipboard { |
| 18 |
| 19 // Stub clipboard implementation. |
| 20 // |
| 21 // Eventually, we'll actually want to interact with the system clipboard, but |
| 22 // that's hard today because the system clipboard is asynchronous (on X11), the |
| 23 // ui::Clipboard interface is synchronous (which is what we'd use), mojo is |
| 24 // asynchronous across processes, and the WebClipboard interface is synchronous |
| 25 // (which is at least tractable). |
| 26 class ClipboardImpl : public mojom::Clipboard { |
| 27 public: |
| 28 // mojom::Clipboard exposes three possible clipboards. |
| 29 static const int kNumClipboards = 3; |
| 30 |
| 31 ClipboardImpl(); |
| 32 ~ClipboardImpl() override; |
| 33 |
| 34 void AddBinding(mojom::ClipboardRequest request); |
| 35 |
| 36 // mojom::Clipboard implementation. |
| 37 void GetSequenceNumber( |
| 38 mojom::Clipboard::Type clipboard_type, |
| 39 const GetSequenceNumberCallback& callback) override; |
| 40 void GetAvailableMimeTypes( |
| 41 mojom::Clipboard::Type clipboard_types, |
| 42 const GetAvailableMimeTypesCallback& callback) override; |
| 43 void ReadMimeType( |
| 44 uint64_t sequence, |
| 45 mojom::Clipboard::Type clipboard_type, |
| 46 const mojo::String& mime_type, |
| 47 const ReadMimeTypeCallback& callback) override; |
| 48 void WriteClipboardData( |
| 49 mojom::Clipboard::Type clipboard_type, |
| 50 mojo::Map<mojo::String, mojo::Array<uint8_t>> data, |
| 51 const WriteClipboardDataCallback& callback) override; |
| 52 |
| 53 private: |
| 54 // Internal struct which stores the current state of the clipboard. |
| 55 class ClipboardData; |
| 56 |
| 57 // The current clipboard state. This is what is read from. |
| 58 std::unique_ptr<ClipboardData> clipboard_state_[kNumClipboards]; |
| 59 mojo::BindingSet<mojom::Clipboard> bindings_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(ClipboardImpl); |
| 62 }; |
| 63 |
| 64 } // namespace clipboard |
| 65 } // namespace mus |
| 66 |
| 67 #endif // COMPONENTS_MUS_CLIPBOARD_CLIPBOARD_IMPL_H_ |
OLD | NEW |