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