// 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 #include #include "components/clipboard/public/interfaces/clipboard.mojom.h" #include "third_party/mojo/src/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 request); ~ClipboardStandaloneImpl() override; // mojo::Clipboard implementation. void GetSequenceNumber( mojo::Clipboard::Type clipboard_type, const mojo::Callback& callback) override; void GetAvailableMimeTypes( mojo::Clipboard::Type clipboard_types, const mojo::Callback)>& callback) override; void ReadMimeType( mojo::Clipboard::Type clipboard_type, const mojo::String& mime_type, const mojo::Callback)>& callback) override; void WriteClipboardData( mojo::Clipboard::Type clipboard_type, mojo::Map> 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 clipboard_state_[kNumClipboards]; mojo::StrongBinding binding_; DISALLOW_COPY_AND_ASSIGN(ClipboardStandaloneImpl); }; } // namespace clipboard #endif // COMPONENTS_CLIPBOARD_CLIPBOARD_STANDALONE_IMPL_H_