diff options
-rw-r--r-- | BUILD.gn | 1 | ||||
-rw-r--r-- | components/clipboard/BUILD.gn | 58 | ||||
-rw-r--r-- | components/clipboard/DEPS | 6 | ||||
-rw-r--r-- | components/clipboard/OWNERS | 1 | ||||
-rw-r--r-- | components/clipboard/clipboard_application_delegate.cc | 38 | ||||
-rw-r--r-- | components/clipboard/clipboard_application_delegate.h | 40 | ||||
-rw-r--r-- | components/clipboard/clipboard_apptest.cc | 162 | ||||
-rw-r--r-- | components/clipboard/clipboard_standalone_impl.cc | 95 | ||||
-rw-r--r-- | components/clipboard/clipboard_standalone_impl.h | 65 | ||||
-rw-r--r-- | components/clipboard/main.cc | 12 | ||||
-rw-r--r-- | components/clipboard/public/interfaces/BUILD.gn | 11 | ||||
-rw-r--r-- | components/clipboard/public/interfaces/clipboard.mojom | 43 | ||||
-rw-r--r-- | mojo/shell/standalone/BUILD.gn | 2 | ||||
-rw-r--r-- | mojo/tools/data/apptests | 4 |
14 files changed, 0 insertions, 538 deletions
@@ -598,7 +598,6 @@ group("mojo_apptests") { if (is_win || is_linux) { deps += [ - "//components/clipboard:apptests", "//components/filesystem:apptests", "//components/mus/ws:tests", "//components/resource_provider:apptests", diff --git a/components/clipboard/BUILD.gn b/components/clipboard/BUILD.gn deleted file mode 100644 index f720ea8..0000000 --- a/components/clipboard/BUILD.gn +++ /dev/null @@ -1,58 +0,0 @@ -# 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. - -import("//mojo/public/mojo_application.gni") - -source_set("lib") { - sources = [ - "clipboard_application_delegate.cc", - "clipboard_application_delegate.h", - "clipboard_standalone_impl.cc", - "clipboard_standalone_impl.h", - ] - - deps = [ - "//base", - "//components/clipboard/public/interfaces", - "//mojo/public/cpp/bindings", - "//mojo/public/cpp/bindings:callback", - "//mojo/services/tracing/public/cpp", - "//mojo/shell/public/cpp", - ] -} - -mojo_native_application("clipboard") { - sources = [ - "main.cc", - ] - - deps = [ - ":lib", - "//base", - "//mojo/public/cpp/bindings:callback", - "//mojo/shell/public/cpp", - ] -} - -mojo_native_application("apptests") { - output_name = "clipboard_apptests" - - testonly = true - - sources = [ - "clipboard_apptest.cc", - ] - - deps = [ - "//base", - "//components/clipboard/public/interfaces", - "//mojo/common", - "//mojo/shell/public/cpp", - "//mojo/shell/public/cpp:test_support", - ] - - data_deps = [ - ":clipboard", - ] -} diff --git a/components/clipboard/DEPS b/components/clipboard/DEPS deleted file mode 100644 index 78718eb..0000000 --- a/components/clipboard/DEPS +++ /dev/null @@ -1,6 +0,0 @@ -include_rules = [ - "+mojo/shell", - "+mojo/common", - "+mojo/public", - "+mojo/services/tracing/public/cpp", -] diff --git a/components/clipboard/OWNERS b/components/clipboard/OWNERS deleted file mode 100644 index 4733a4f..0000000 --- a/components/clipboard/OWNERS +++ /dev/null @@ -1 +0,0 @@ -erg@chromium.org diff --git a/components/clipboard/clipboard_application_delegate.cc b/components/clipboard/clipboard_application_delegate.cc deleted file mode 100644 index 077ec90..0000000 --- a/components/clipboard/clipboard_application_delegate.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2015 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. - -#include "components/clipboard/clipboard_application_delegate.h" - -#include <utility> - -#include "components/clipboard/clipboard_standalone_impl.h" -#include "mojo/shell/public/cpp/connection.h" - -namespace clipboard { - -ClipboardApplicationDelegate::ClipboardApplicationDelegate() {} - -ClipboardApplicationDelegate::~ClipboardApplicationDelegate() {} - -void ClipboardApplicationDelegate::Initialize(mojo::Shell* shell, - const std::string& url, - uint32_t id) { - tracing_.Initialize(shell, url); -} - -bool ClipboardApplicationDelegate::AcceptConnection( - mojo::Connection* connection) { - connection->AddInterface(this); - return true; -} - -void ClipboardApplicationDelegate::Create( - mojo::Connection* connection, - mojo::InterfaceRequest<mojo::Clipboard> request) { - // TODO(erg): Write native implementations of the clipboard. For now, we - // just build a clipboard which doesn't interact with the system. - new clipboard::ClipboardStandaloneImpl(std::move(request)); -} - -} // namespace clipboard diff --git a/components/clipboard/clipboard_application_delegate.h b/components/clipboard/clipboard_application_delegate.h deleted file mode 100644 index 1184f9b..0000000 --- a/components/clipboard/clipboard_application_delegate.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 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_CLIBPOARD_APPLICATION_DELEGATE_H_ -#define COMPONENTS_CLIPBOARD_CLIBPOARD_APPLICATION_DELEGATE_H_ - -#include "base/macros.h" -#include "components/clipboard/public/interfaces/clipboard.mojom.h" -#include "mojo/services/tracing/public/cpp/tracing_impl.h" -#include "mojo/shell/public/cpp/interface_factory.h" -#include "mojo/shell/public/cpp/shell_client.h" - -namespace clipboard { - -class ClipboardApplicationDelegate - : public mojo::ShellClient, - public mojo::InterfaceFactory<mojo::Clipboard> { - public: - ClipboardApplicationDelegate(); - ~ClipboardApplicationDelegate() override; - - // mojo::ShellClient implementation. - void Initialize(mojo::Shell* shell, const std::string& url, - uint32_t id) override; - bool AcceptConnection(mojo::Connection* connection) override; - - // mojo::InterfaceFactory<mojo::Clipboard> implementation. - void Create(mojo::Connection* connection, - mojo::InterfaceRequest<mojo::Clipboard> request) override; - - private: - mojo::TracingImpl tracing_; - - DISALLOW_COPY_AND_ASSIGN(ClipboardApplicationDelegate); -}; - -} // namespace clipboard - -#endif // COMPONENTS_CLIPBOARD_CLIBPOARD_APPLICATION_DELEGATE_H_ diff --git a/components/clipboard/clipboard_apptest.cc b/components/clipboard/clipboard_apptest.cc deleted file mode 100644 index 01b85cd..0000000 --- a/components/clipboard/clipboard_apptest.cc +++ /dev/null @@ -1,162 +0,0 @@ -// 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. - -#include <stdint.h> -#include <utility> - -#include "base/bind.h" -#include "base/macros.h" -#include "base/run_loop.h" -#include "components/clipboard/public/interfaces/clipboard.mojom.h" -#include "mojo/common/common_type_converters.h" -#include "mojo/shell/public/cpp/application_test_base.h" -#include "mojo/shell/public/cpp/shell.h" - -using mojo::Array; -using mojo::Clipboard; -using mojo::Map; -using mojo::String; - -namespace { - -void CopyUint64AndEndRunloop(uint64_t* output, - base::RunLoop* run_loop, - uint64_t input) { - *output = input; - run_loop->Quit(); -} - -void CopyStringAndEndRunloop(std::string* output, - bool* string_is_null, - base::RunLoop* run_loop, - const Array<uint8_t>& input) { - *string_is_null = input.is_null(); - *output = input.is_null() ? "" : input.To<std::string>(); - run_loop->Quit(); -} - -void CopyVectorStringAndEndRunloop(std::vector<std::string>* output, - base::RunLoop* run_loop, - const Array<String>& input) { - *output = input.To<std::vector<std::string> >(); - run_loop->Quit(); -} - -const char* kUninitialized = "Uninitialized data"; -const char* kPlainTextData = "Some plain data"; -const char* kHtmlData = "<html>data</html>"; - -} // namespace - -namespace clipboard { - -class ClipboardAppTest : public mojo::test::ApplicationTestBase { - public: - ClipboardAppTest() : ApplicationTestBase() {} - ~ClipboardAppTest() override {} - - void SetUp() override { - mojo::test::ApplicationTestBase::SetUp(); - shell()->ConnectToInterface("mojo:clipboard", &clipboard_); - } - - uint64_t GetSequenceNumber() { - base::RunLoop run_loop; - uint64_t sequence_num = 999999; - clipboard_->GetSequenceNumber( - Clipboard::Type::COPY_PASTE, - base::Bind(&CopyUint64AndEndRunloop, &sequence_num, &run_loop)); - run_loop.Run(); - return sequence_num; - } - - std::vector<std::string> GetAvailableFormatMimeTypes() { - base::RunLoop run_loop; - std::vector<std::string> types; - types.push_back(kUninitialized); - clipboard_->GetAvailableMimeTypes( - Clipboard::Type::COPY_PASTE, - base::Bind(&CopyVectorStringAndEndRunloop, &types, &run_loop)); - run_loop.Run(); - return types; - } - - bool GetDataOfType(const std::string& mime_type, std::string* data) { - base::RunLoop run_loop; - bool is_null = false; - clipboard_->ReadMimeType( - Clipboard::Type::COPY_PASTE, mime_type, - base::Bind(&CopyStringAndEndRunloop, data, &is_null, &run_loop)); - run_loop.Run(); - return !is_null; - } - - void SetStringText(const std::string& data) { - Map<String, Array<uint8_t>> mime_data; - mime_data[Clipboard::MIME_TYPE_TEXT] = Array<uint8_t>::From(data); - clipboard_->WriteClipboardData(Clipboard::Type::COPY_PASTE, - std::move(mime_data)); - } - - protected: - mojo::ClipboardPtr clipboard_; - - DISALLOW_COPY_AND_ASSIGN(ClipboardAppTest); -}; - -TEST_F(ClipboardAppTest, EmptyClipboardOK) { - EXPECT_EQ(0ul, GetSequenceNumber()); - EXPECT_TRUE(GetAvailableFormatMimeTypes().empty()); - std::string data; - EXPECT_FALSE(GetDataOfType(Clipboard::MIME_TYPE_TEXT, &data)); -} - -TEST_F(ClipboardAppTest, CanReadBackText) { - std::string data; - EXPECT_FALSE(GetDataOfType(Clipboard::MIME_TYPE_TEXT, &data)); - EXPECT_EQ(0ul, GetSequenceNumber()); - - SetStringText(kPlainTextData); - EXPECT_EQ(1ul, GetSequenceNumber()); - - EXPECT_TRUE(GetDataOfType(Clipboard::MIME_TYPE_TEXT, &data)); - EXPECT_EQ(kPlainTextData, data); -} - -TEST_F(ClipboardAppTest, CanSetMultipleDataTypesAtOnce) { - Map<String, Array<uint8_t>> mime_data; - mime_data[Clipboard::MIME_TYPE_TEXT] = - Array<uint8_t>::From(std::string(kPlainTextData)); - mime_data[Clipboard::MIME_TYPE_HTML] = - Array<uint8_t>::From(std::string(kHtmlData)); - - clipboard_->WriteClipboardData(Clipboard::Type::COPY_PASTE, - std::move(mime_data)); - - EXPECT_EQ(1ul, GetSequenceNumber()); - - std::string data; - EXPECT_TRUE(GetDataOfType(Clipboard::MIME_TYPE_TEXT, &data)); - EXPECT_EQ(kPlainTextData, data); - EXPECT_TRUE(GetDataOfType(Clipboard::MIME_TYPE_HTML, &data)); - EXPECT_EQ(kHtmlData, data); -} - -TEST_F(ClipboardAppTest, CanClearClipboardWithZeroArray) { - std::string data; - SetStringText(kPlainTextData); - EXPECT_EQ(1ul, GetSequenceNumber()); - - EXPECT_TRUE(GetDataOfType(Clipboard::MIME_TYPE_TEXT, &data)); - EXPECT_EQ(kPlainTextData, data); - - Map<String, Array<uint8_t>> mime_data; - clipboard_->WriteClipboardData(Clipboard::Type::COPY_PASTE, - std::move(mime_data)); - - EXPECT_EQ(2ul, GetSequenceNumber()); - EXPECT_FALSE(GetDataOfType(Clipboard::MIME_TYPE_TEXT, &data)); -} - -} // namespace clipboard diff --git a/components/clipboard/clipboard_standalone_impl.cc b/components/clipboard/clipboard_standalone_impl.cc deleted file mode 100644 index 7b7544e..0000000 --- a/components/clipboard/clipboard_standalone_impl.cc +++ /dev/null @@ -1,95 +0,0 @@ -// 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. - -#include "components/clipboard/clipboard_standalone_impl.h" - -#include <string.h> -#include <utility> - -#include "base/macros.h" -#include "mojo/public/cpp/bindings/array.h" -#include "mojo/public/cpp/bindings/callback.h" -#include "mojo/public/cpp/bindings/string.h" - -using mojo::Array; -using mojo::Map; -using mojo::String; - -namespace clipboard { - -// ClipboardData contains data copied to the Clipboard for a variety of formats. -// It mostly just provides APIs to cleanly access and manipulate this data. -class ClipboardStandaloneImpl::ClipboardData { - public: - ClipboardData() {} - ~ClipboardData() {} - - Array<String> GetMimeTypes() const { - Array<String> types(data_types_.size()); - int i = 0; - for (auto it = data_types_.begin(); it != data_types_.end(); ++it, ++i) - types[i] = it->first; - - return types; - } - - void SetData(Map<String, Array<uint8_t>> data) { - data_types_ = std::move(data); - } - - void GetData(const String& mime_type, Array<uint8_t>* data) const { - auto it = data_types_.find(mime_type); - if (it != data_types_.end()) - *data = it->second.Clone(); - } - - private: - Map<String, Array<uint8_t>> data_types_; - - DISALLOW_COPY_AND_ASSIGN(ClipboardData); -}; - -ClipboardStandaloneImpl::ClipboardStandaloneImpl( - mojo::InterfaceRequest<mojo::Clipboard> request) - : binding_(this, std::move(request)) { - for (int i = 0; i < kNumClipboards; ++i) { - sequence_number_[i] = 0; - clipboard_state_[i].reset(new ClipboardData); - } -} - -ClipboardStandaloneImpl::~ClipboardStandaloneImpl() { -} - -void ClipboardStandaloneImpl::GetSequenceNumber( - Clipboard::Type clipboard_type, - const mojo::Callback<void(uint64_t)>& callback) { - callback.Run(sequence_number_[static_cast<int>(clipboard_type)]); -} - -void ClipboardStandaloneImpl::GetAvailableMimeTypes( - Clipboard::Type clipboard_type, - const mojo::Callback<void(Array<String>)>& callback) { - callback.Run( - clipboard_state_[static_cast<int>(clipboard_type)]->GetMimeTypes()); -} - -void ClipboardStandaloneImpl::ReadMimeType( - Clipboard::Type clipboard_type, - const String& mime_type, - const mojo::Callback<void(Array<uint8_t>)>& callback) { - Array<uint8_t> mime_data; - clipboard_state_[static_cast<int>(clipboard_type)]->GetData(mime_type, - &mime_data); - callback.Run(std::move(mime_data)); -} - -void ClipboardStandaloneImpl::WriteClipboardData( - Clipboard::Type clipboard_type, - Map<String, Array<uint8_t>> data) { - sequence_number_[static_cast<int>(clipboard_type)]++; - clipboard_state_[static_cast<int>(clipboard_type)]->SetData(std::move(data)); -} - -} // namespace clipboard diff --git a/components/clipboard/clipboard_standalone_impl.h b/components/clipboard/clipboard_standalone_impl.h deleted file mode 100644 index 7f81e85..0000000 --- a/components/clipboard/clipboard_standalone_impl.h +++ /dev/null @@ -1,65 +0,0 @@ -// 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 "base/memory/scoped_ptr.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. - 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_ diff --git a/components/clipboard/main.cc b/components/clipboard/main.cc deleted file mode 100644 index 4e2a55f..0000000 --- a/components/clipboard/main.cc +++ /dev/null @@ -1,12 +0,0 @@ -// 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. - -#include "components/clipboard/clipboard_application_delegate.h" -#include "mojo/public/c/system/main.h" -#include "mojo/shell/public/cpp/application_runner.h" - -MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunner runner(new clipboard::ClipboardApplicationDelegate); - return runner.Run(shell_handle); -} diff --git a/components/clipboard/public/interfaces/BUILD.gn b/components/clipboard/public/interfaces/BUILD.gn deleted file mode 100644 index 443f5bf..0000000 --- a/components/clipboard/public/interfaces/BUILD.gn +++ /dev/null @@ -1,11 +0,0 @@ -# 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. - -import("//mojo/public/tools/bindings/mojom.gni") - -mojom("interfaces") { - sources = [ - "clipboard.mojom", - ] -} diff --git a/components/clipboard/public/interfaces/clipboard.mojom b/components/clipboard/public/interfaces/clipboard.mojom deleted file mode 100644 index ca4d6b1..0000000 --- a/components/clipboard/public/interfaces/clipboard.mojom +++ /dev/null @@ -1,43 +0,0 @@ -// 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. - -module mojo; - -interface Clipboard { - enum Type { - COPY_PASTE = 0, - SELECTION = 1, - DRAG = 2 - }; - - // Mime type constants - const string MIME_TYPE_TEXT = "text/plain"; - const string MIME_TYPE_HTML = "text/html"; - const string MIME_TYPE_URL = "text/url"; - - // Returns a sequence number which uniquely identifies clipboard state. - // Clients are able to assume that the clipboard contents are unchanged as - // long as this number has not changed. This number is monotonically - // increasing, is increased when the clipboard state changes, and is - // provided by Windows, Linux, and Mac. - GetSequenceNumber(Type clipboard_type) => (uint64 sequence); - - // Returns the available mime types. (Note: the chrome interface has a - // |contains_filenames| parameter here, but it appears to always be set - // to false.) - GetAvailableMimeTypes(Type clipboard_types) => (array<string> types); - - // Returns the data associated with a Mime type, returning NULL if that data - // doesn't exist. Note: because of the inherit raciness of clipboard access, - // this may return NULL even if you just verified that it exists with - // GetAvailableFormatMimeTypes(). We don't want to provide one API to return - // the entire clipboard state because the combined size of the clipboard can - // be megabytes, especially when image data is involved. - ReadMimeType(Type clipboard_type, string mime_type) => (array<uint8>? data); - - // Writes a set of mime types to the clipboard. This will increment the - // sequence number. In the case of an empty or null map, this will just - // clear the clipboard. - WriteClipboardData(Type clipboard_type, map<string, array<uint8>>? data); -}; diff --git a/mojo/shell/standalone/BUILD.gn b/mojo/shell/standalone/BUILD.gn index eccb693..e87bea5 100644 --- a/mojo/shell/standalone/BUILD.gn +++ b/mojo/shell/standalone/BUILD.gn @@ -262,8 +262,6 @@ if (is_android) { testonly = true deps = [ ":android_assets", - "//components/clipboard:apptests_assets", - "//components/clipboard:clipboard_assets", "//components/mus/ws:apptests_assets", "//components/resource_provider:apptests_assets", "//components/resource_provider:resource_provider_assets", diff --git a/mojo/tools/data/apptests b/mojo/tools/data/apptests index 90e8048..da0ad64 100644 --- a/mojo/tools/data/apptests +++ b/mojo/tools/data/apptests @@ -31,10 +31,6 @@ if config.target_os != config.OS_ANDROID: # WARNING: If you add a test make sure the gn target mojo_apptests depends upon # it. tests = [ - { - 'test': 'mojo:clipboard_apptests', - 'type': 'gtest_isolated', - }, # TODO(rockot): Flaky. Failing with "Unrecognized --gtest_list_tests output" # http://crbug.com/569367. # { |