summaryrefslogtreecommitdiffstats
path: root/components/clipboard/clipboard_standalone_impl.h
diff options
context:
space:
mode:
authorsky <sky@chromium.org>2015-04-20 16:44:51 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-20 23:45:39 +0000
commit8327ac08ec2c80f26c73a83b75a66eae7b27e3cc (patch)
treea68b6bbfba04c1fa98f081533a7100847d834d0d /components/clipboard/clipboard_standalone_impl.h
parent638ab71c6b28552e6adb7fd195ce50195b24725a (diff)
downloadchromium_src-8327ac08ec2c80f26c73a83b75a66eae7b27e3cc.zip
chromium_src-8327ac08ec2c80f26c73a83b75a66eae7b27e3cc.tar.gz
chromium_src-8327ac08ec2c80f26c73a83b75a66eae7b27e3cc.tar.bz2
Moves mojo/services/* to components/* part 1
I'm splitting this up in chunks so I can actually use the cq. R=ben@chromium.org Review URL: https://codereview.chromium.org/1097183002 Cr-Commit-Position: refs/heads/master@{#325942}
Diffstat (limited to 'components/clipboard/clipboard_standalone_impl.h')
-rw-r--r--components/clipboard/clipboard_standalone_impl.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/components/clipboard/clipboard_standalone_impl.h b/components/clipboard/clipboard_standalone_impl.h
new file mode 100644
index 0000000..eecae95
--- /dev/null
+++ b/components/clipboard/clipboard_standalone_impl.h
@@ -0,0 +1,62 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_CLIPBOARD_CLIPBOARD_STANDALONE_IMPL_H_
+#define COMPONENTS_CLIPBOARD_CLIPBOARD_STANDALONE_IMPL_H_
+
+#include <base/memory/scoped_ptr.h>
+#include <string>
+
+#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
+#include "third_party/mojo_services/src/clipboard/public/interfaces/clipboard.mojom.h"
+
+namespace clipboard {
+
+// Stub clipboard implementation.
+//
+// Eventually, we'll actually want to interact with the system clipboard, but
+// that's hard today because the system clipboard is asynchronous (on X11), the
+// ui::Clipboard interface is synchronous (which is what we'd use), mojo is
+// asynchronous across processes, and the WebClipboard interface is synchronous
+// (which is at least tractable).
+class ClipboardStandaloneImpl : public mojo::Clipboard {
+ public:
+ // mojo::Clipboard exposes three possible clipboards.
+ static const int kNumClipboards = 3;
+
+ explicit ClipboardStandaloneImpl(
+ mojo::InterfaceRequest<mojo::Clipboard> request);
+ ~ClipboardStandaloneImpl() override;
+
+ // mojo::Clipboard implementation.
+ void GetSequenceNumber(
+ mojo::Clipboard::Type clipboard_type,
+ const mojo::Callback<void(uint64_t)>& callback) override;
+ void GetAvailableMimeTypes(
+ mojo::Clipboard::Type clipboard_types,
+ const mojo::Callback<void(mojo::Array<mojo::String>)>& callback) override;
+ void ReadMimeType(
+ mojo::Clipboard::Type clipboard_type,
+ const mojo::String& mime_type,
+ const mojo::Callback<void(mojo::Array<uint8_t>)>& callback) override;
+ void WriteClipboardData(
+ mojo::Clipboard::Type clipboard_type,
+ mojo::Map<mojo::String, mojo::Array<uint8_t>> data) override;
+
+ private:
+ uint64_t sequence_number_[kNumClipboards];
+
+ // Internal struct which stores the current state of the clipboard.
+ class ClipboardData;
+
+ // The current clipboard state. This is what is read from.
+ scoped_ptr<ClipboardData> clipboard_state_[kNumClipboards];
+ mojo::StrongBinding<mojo::Clipboard> binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(ClipboardStandaloneImpl);
+};
+
+} // namespace clipboard
+
+#endif // COMPONENTS_CLIPBOARD_CLIPBOARD_STANDALONE_IMPL_H_