Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Unified Diff: components/clipboard/clipboard_standalone_impl.h

Issue 1978763003: Readd the clipboard service and get it compiling again. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add OWNERS to the interfaces directory. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/clipboard/clipboard_standalone_impl.h
diff --git a/components/clipboard/clipboard_standalone_impl.h b/components/clipboard/clipboard_standalone_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..3f0dbd836d029498abad807ac15baa1b7927bf41
--- /dev/null
+++ b/components/clipboard/clipboard_standalone_impl.h
@@ -0,0 +1,64 @@
+// 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 <stdint.h>
+
+#include <string>
+
+#include "base/macros.h"
+#include "components/clipboard/public/interfaces/clipboard.mojom.h"
+#include "mojo/public/cpp/bindings/strong_binding.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.
+ std::unique_ptr<ClipboardData> clipboard_state_[kNumClipboards];
+ mojo::StrongBinding<mojo::Clipboard> binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(ClipboardStandaloneImpl);
+};
+
+} // namespace clipboard
+
+#endif // COMPONENTS_CLIPBOARD_CLIPBOARD_STANDALONE_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698