Commit fdd23bac authored by Stuart Langley's avatar Stuart Langley Committed by Commit Bot

Onion Soup WebClipboard - move clipboard.mojom to WebKit/common/clipboard.

This continues the work to onion soup WebClipboard.

- The mojo definition for ClipboardHost is moved from content/common to
  WebKit/common/clipboard.
- The implementation of WebClipboard, content/renderer/webclipboard_impl.* is
  moved to WebKit/Source/platform/expored/WebClipboardImpl.*.
- Fixed the implementation of WebClipboardImpl to use the blink types (
  WTF::String etc) directly rather than WebString.
- Plagiarized parts of DropDataBuilder and URLToImageMarkup as we need to keep
  implementations in content for MockWebClipboardImpl.
- Removed the interface binding from renderer_blink_platform_impl to
  WebClipboardImpl and render_frame_impl (for MACOSX only).
- Instantiate WebClipboardImpl in Platform.cpp (temporary until we can remove
  Clipboard() from platform.)


We cannot remove Platform::Clipboard yet because it is used by
pepper_webplugin_impl, will need see if we can move pepper to use mojo instead.

Next steps;

- Remove MockWebClipboardImpl and mock out at the mojo level instead of
  Platform.
- Provide typemap for blink::mojo::ClipboardBuffer to ui::Clipboard for browser.
- Remove Clipboard() from Platform by fixing pepper.
- Delete public/platform/WebClipboard definition.

Note: Gerrit is not showing which files are renames + modifications, the list is

content/renderer/webclipboard_impl* : Source/platform/exported/WebClipboardImpl*
content/common/clipboard.mojom : WebKit/common/clipboard/clipboard.mojom

Bug: 775830
Change-Id: Ife7121886fe133cc7577cd1ce8f1d90262d97102
Reviewed-on: https://chromium-review.googlesource.com/809824
Commit-Queue: Stuart Langley <slangley@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523640}
parent 4ee0fd38
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/clipboard.mojom.h"
#include "content/common/frame_messages.h" #include "content/common/frame_messages.h"
#include "content/public/browser/browser_message_filter.h" #include "content/public/browser/browser_message_filter.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
...@@ -22,6 +21,7 @@ ...@@ -22,6 +21,7 @@
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "content/shell/browser/shell.h" #include "content/shell/browser/shell.h"
#include "ipc/message_filter.h" #include "ipc/message_filter.h"
#include "third_party/WebKit/common/clipboard/clipboard.mojom.h"
#include "ui/base/clipboard/clipboard_monitor.h" #include "ui/base/clipboard/clipboard_monitor.h"
#include "ui/base/clipboard/clipboard_observer.h" #include "ui/base/clipboard/clipboard_observer.h"
......
...@@ -56,7 +56,7 @@ ClipboardHostImpl::ClipboardHostImpl( ...@@ -56,7 +56,7 @@ ClipboardHostImpl::ClipboardHostImpl(
void ClipboardHostImpl::Create( void ClipboardHostImpl::Create(
scoped_refptr<ChromeBlobStorageContext> blob_storage_context, scoped_refptr<ChromeBlobStorageContext> blob_storage_context,
mojom::ClipboardHostRequest request) { blink::mojom::ClipboardHostRequest request) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
mojo::MakeStrongBinding( mojo::MakeStrongBinding(
base::WrapUnique<ClipboardHostImpl>( base::WrapUnique<ClipboardHostImpl>(
......
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/shared_memory.h" #include "base/memory/shared_memory.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/common/clipboard.mojom.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/public/browser/browser_associated_interface.h" #include "content/public/browser/browser_associated_interface.h"
#include "content/public/browser/browser_message_filter.h" #include "content/public/browser/browser_message_filter.h"
#include "third_party/WebKit/common/clipboard/clipboard.mojom.h"
#include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/clipboard.h"
class GURL; class GURL;
...@@ -37,13 +37,13 @@ namespace content { ...@@ -37,13 +37,13 @@ namespace content {
class ChromeBlobStorageContext; class ChromeBlobStorageContext;
class ClipboardHostImplTest; class ClipboardHostImplTest;
class CONTENT_EXPORT ClipboardHostImpl : public mojom::ClipboardHost { class CONTENT_EXPORT ClipboardHostImpl : public blink::mojom::ClipboardHost {
public: public:
~ClipboardHostImpl() override; ~ClipboardHostImpl() override;
static void Create( static void Create(
scoped_refptr<ChromeBlobStorageContext> blob_storage_context, scoped_refptr<ChromeBlobStorageContext> blob_storage_context,
mojom::ClipboardHostRequest request); blink::mojom::ClipboardHostRequest request);
private: private:
friend class ClipboardHostImplTest; friend class ClipboardHostImplTest;
......
...@@ -543,7 +543,6 @@ mojom("mojo_bindings") { ...@@ -543,7 +543,6 @@ mojom("mojo_bindings") {
"child.mojom", "child.mojom",
"child_control.mojom", "child_control.mojom",
"child_memory_coordinator.mojom", "child_memory_coordinator.mojom",
"clipboard.mojom",
"color_chooser.mojom", "color_chooser.mojom",
"devtools.mojom", "devtools.mojom",
"field_trial_recorder.mojom", "field_trial_recorder.mojom",
......
// Copyright 2017 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 content.mojom;
import "mojo/common/string16.mojom";
import "third_party/WebKit/common/clipboard/clipboard.mojom";
import "ui/gfx/geometry/mojo/geometry.mojom";
import "url/mojo/url.mojom";
interface ClipboardHost {
[Sync]
GetSequenceNumber(blink.mojom.ClipboardBuffer buffer) => (uint64 result);
[Sync]
IsFormatAvailable(blink.mojom.ClipboardFormat format,
blink.mojom.ClipboardBuffer buffer) => (bool result);
[Sync]
ReadAvailableTypes(blink.mojom.ClipboardBuffer buffer) =>
(array<mojo.common.mojom.String16> types, bool result);
[Sync]
ReadText(blink.mojom.ClipboardBuffer buffer) =>
(mojo.common.mojom.String16 result);
[Sync]
ReadHtml(blink.mojom.ClipboardBuffer buffer) =>
(mojo.common.mojom.String16 markup,
url.mojom.Url url,
uint32 fragment_start,
uint32 fragment_end);
[Sync]
ReadRtf(blink.mojom.ClipboardBuffer buffer) => (string result);
[Sync]
ReadImage(blink.mojom.ClipboardBuffer buffer) => (string blob_uuid,
string mime_type,
int64 size);
[Sync]
ReadCustomData(blink.mojom.ClipboardBuffer buffer,
mojo.common.mojom.String16 type) =>
(mojo.common.mojom.String16 result);
// Writing to the clipboard via IPC is a two-phase operation. First, the
// sender sends the different types of data it'd like to write to the
// receiver. Then, it sends a commit message to commit the data to the system
// clipboard.
WriteText(blink.mojom.ClipboardBuffer buffer,
mojo.common.mojom.String16 text);
WriteHtml(blink.mojom.ClipboardBuffer buffer,
mojo.common.mojom.String16 markup,
url.mojom.Url url);
WriteSmartPasteMarker(blink.mojom.ClipboardBuffer buffer);
WriteCustomData(
blink.mojom.ClipboardBuffer buffer,
map<mojo.common.mojom.String16, mojo.common.mojom.String16> data);
// TODO(dcheng): The |url| parameter should really be a GURL, but <canvas>'s
// copy as image tries to set very long data: URLs on the clipboard. Using
// GURL causes the browser to kill the renderer for sending a bad IPC (GURLs
// bigger than 2 megabytes are considered to be bad). https://crbug.com/459822
WriteBookmark(blink.mojom.ClipboardBuffer buffer,
string url,
mojo.common.mojom.String16 title);
WriteImage(blink.mojom.ClipboardBuffer buffer,
gfx.mojom.Size size_in_pixels,
handle<shared_buffer> shared_buffer_handle);
CommitWrite(blink.mojom.ClipboardBuffer buffer);
// OS_MACOSX only
WriteStringToFindPboard(mojo.common.mojom.String16 text);
};
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
"blink::mojom::BackgroundSyncService", "blink::mojom::BackgroundSyncService",
"blink::mojom::BlobRegistry", "blink::mojom::BlobRegistry",
"blink::mojom::BroadcastChannelProvider", "blink::mojom::BroadcastChannelProvider",
"blink::mojom::ClipboardHost",
"blink::mojom::LockManager", "blink::mojom::LockManager",
"blink::mojom::Hyphenation", "blink::mojom::Hyphenation",
"blink::mojom::MimeRegistry", "blink::mojom::MimeRegistry",
...@@ -29,7 +30,6 @@ ...@@ -29,7 +30,6 @@
"blink::mojom::ReportingServiceProxy", "blink::mojom::ReportingServiceProxy",
"blink::mojom::WebDatabaseHost", "blink::mojom::WebDatabaseHost",
"content::mojom::AppCacheBackend", "content::mojom::AppCacheBackend",
"content::mojom::ClipboardHost",
"content::mojom::FieldTrialRecorder", "content::mojom::FieldTrialRecorder",
"content::mojom::FileUtilitiesHost", "content::mojom::FileUtilitiesHost",
"content::mojom::FrameSinkProvider", "content::mojom::FrameSinkProvider",
......
...@@ -509,8 +509,6 @@ target(link_target_type, "renderer") { ...@@ -509,8 +509,6 @@ target(link_target_type, "renderer") {
"web_ui_extension.h", "web_ui_extension.h",
"web_ui_extension_data.cc", "web_ui_extension_data.cc",
"web_ui_extension_data.h", "web_ui_extension_data.h",
"webclipboard_impl.cc",
"webclipboard_impl.h",
"webfileutilities_impl.cc", "webfileutilities_impl.cc",
"webfileutilities_impl.h", "webfileutilities_impl.h",
"webgraphicscontext3d_provider_impl.cc", "webgraphicscontext3d_provider_impl.cc",
......
...@@ -11,17 +11,6 @@ ...@@ -11,17 +11,6 @@
namespace content { namespace content {
std::string URLToMarkup(const blink::WebURL& url,
const blink::WebString& title) {
std::string markup("<a href=\"");
markup.append(url.GetString().Utf8());
markup.append("\">");
// TODO(darin): HTML escape this
markup.append(net::EscapeForHTML(title.Utf8()));
markup.append("</a>");
return markup;
}
std::string URLToImageMarkup(const blink::WebURL& url, std::string URLToImageMarkup(const blink::WebURL& url,
const blink::WebString& title) { const blink::WebString& title) {
std::string markup("<img src=\""); std::string markup("<img src=\"");
......
...@@ -16,9 +16,6 @@ class WebURL; ...@@ -16,9 +16,6 @@ class WebURL;
namespace content { namespace content {
CONTENT_EXPORT std::string URLToMarkup(const blink::WebURL& url,
const blink::WebString& title);
CONTENT_EXPORT std::string URLToImageMarkup(const blink::WebURL& url, CONTENT_EXPORT std::string URLToImageMarkup(const blink::WebURL& url,
const blink::WebString& title); const blink::WebString& title);
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#include "content/common/accessibility_messages.h" #include "content/common/accessibility_messages.h"
#include "content/common/associated_interface_provider_impl.h" #include "content/common/associated_interface_provider_impl.h"
#include "content/common/associated_interfaces.mojom.h" #include "content/common/associated_interfaces.mojom.h"
#include "content/common/clipboard.mojom.h"
#include "content/common/content_constants_internal.h" #include "content/common/content_constants_internal.h"
#include "content/common/content_security_policy/csp_context.h" #include "content/common/content_security_policy/csp_context.h"
#include "content/common/content_security_policy_header.h" #include "content/common/content_security_policy_header.h"
...@@ -2090,10 +2089,13 @@ void RenderFrameImpl::OnCopyToFindPboard() { ...@@ -2090,10 +2089,13 @@ void RenderFrameImpl::OnCopyToFindPboard() {
// Since the find pasteboard supports only plain text, this can be simpler // Since the find pasteboard supports only plain text, this can be simpler
// than the |OnCopy()| case. // than the |OnCopy()| case.
if (frame_->HasSelection()) { if (frame_->HasSelection()) {
if (!clipboard_host_) {
auto* platform = RenderThreadImpl::current_blink_platform_impl();
platform->GetConnector()->BindInterface(platform->GetBrowserServiceName(),
&clipboard_host_);
}
base::string16 selection = frame_->SelectionAsText().Utf16(); base::string16 selection = frame_->SelectionAsText().Utf16();
RenderThreadImpl::current_blink_platform_impl() clipboard_host_->WriteStringToFindPboard(selection);
->GetClipboardHost()
.WriteStringToFindPboard(selection);
} }
} }
#endif #endif
......
...@@ -90,6 +90,10 @@ ...@@ -90,6 +90,10 @@
#include "url/gurl.h" #include "url/gurl.h"
#include "url/origin.h" #include "url/origin.h"
#if defined(OS_MACOSX)
#include "third_party/WebKit/common/clipboard/clipboard.mojom.h"
#endif
#if BUILDFLAG(ENABLE_PLUGINS) #if BUILDFLAG(ENABLE_PLUGINS)
#include "content/renderer/pepper/plugin_power_saver_helper.h" #include "content/renderer/pepper/plugin_power_saver_helper.h"
#endif #endif
...@@ -1601,6 +1605,11 @@ class CONTENT_EXPORT RenderFrameImpl ...@@ -1601,6 +1605,11 @@ class CONTENT_EXPORT RenderFrameImpl
bool has_scrolled_focused_editable_node_into_rect_ = false; bool has_scrolled_focused_editable_node_into_rect_ = false;
gfx::Rect rect_for_scrolled_focused_editable_node_; gfx::Rect rect_for_scrolled_focused_editable_node_;
#if defined(OS_MACOSX)
// Return the mojo interface for making ClipboardHost calls.
blink::mojom::ClipboardHostPtr clipboard_host_;
#endif
base::WeakPtrFactory<RenderFrameImpl> weak_factory_; base::WeakPtrFactory<RenderFrameImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl); DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl);
......
...@@ -75,7 +75,6 @@ ...@@ -75,7 +75,6 @@
#include "content/renderer/render_thread_impl.h" #include "content/renderer/render_thread_impl.h"
#include "content/renderer/storage_util.h" #include "content/renderer/storage_util.h"
#include "content/renderer/web_database_observer_impl.h" #include "content/renderer/web_database_observer_impl.h"
#include "content/renderer/webclipboard_impl.h"
#include "content/renderer/webfileutilities_impl.h" #include "content/renderer/webfileutilities_impl.h"
#include "content/renderer/webgraphicscontext3d_provider_impl.h" #include "content/renderer/webgraphicscontext3d_provider_impl.h"
#include "content/renderer/webpublicsuffixlist_impl.h" #include "content/renderer/webpublicsuffixlist_impl.h"
...@@ -417,10 +416,8 @@ blink::WebClipboard* RendererBlinkPlatformImpl::Clipboard() { ...@@ -417,10 +416,8 @@ blink::WebClipboard* RendererBlinkPlatformImpl::Clipboard() {
GetContentClient()->renderer()->OverrideWebClipboard(); GetContentClient()->renderer()->OverrideWebClipboard();
if (clipboard) if (clipboard)
return clipboard; return clipboard;
if (!clipboard_) {
clipboard_ = std::make_unique<WebClipboardImpl>(GetClipboardHost()); return BlinkPlatformImpl::Clipboard();
}
return clipboard_.get();
} }
blink::WebFileUtilities* RendererBlinkPlatformImpl::GetFileUtilities() { blink::WebFileUtilities* RendererBlinkPlatformImpl::GetFileUtilities() {
...@@ -1440,11 +1437,4 @@ blink::mojom::WebDatabaseHost& RendererBlinkPlatformImpl::GetWebDatabaseHost() { ...@@ -1440,11 +1437,4 @@ blink::mojom::WebDatabaseHost& RendererBlinkPlatformImpl::GetWebDatabaseHost() {
return **web_database_host_; return **web_database_host_;
} }
mojom::ClipboardHost& RendererBlinkPlatformImpl::GetClipboardHost() {
if (!clipboard_host_) {
GetConnector()->BindInterface(mojom::kBrowserServiceName, &clipboard_host_);
}
return *clipboard_host_;
}
} // namespace content } // namespace content
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "cc/blink/web_compositor_support_impl.h" #include "cc/blink/web_compositor_support_impl.h"
#include "components/viz/client/client_shared_bitmap_manager.h" #include "components/viz/client/client_shared_bitmap_manager.h"
#include "content/child/blink_platform_impl.h" #include "content/child/blink_platform_impl.h"
#include "content/common/clipboard.mojom.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/common/file_utilities.mojom.h" #include "content/common/file_utilities.mojom.h"
#include "content/common/possibly_associated_interface_ptr.h" #include "content/common/possibly_associated_interface_ptr.h"
...@@ -65,7 +64,6 @@ class LocalStorageCachedAreas; ...@@ -65,7 +64,6 @@ class LocalStorageCachedAreas;
class NotificationDispatcher; class NotificationDispatcher;
class PlatformEventObserverBase; class PlatformEventObserverBase;
class ThreadSafeSender; class ThreadSafeSender;
class WebClipboardImpl;
class WebDatabaseObserverImpl; class WebDatabaseObserverImpl;
class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
...@@ -270,9 +268,6 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { ...@@ -270,9 +268,6 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
// destructed. // destructed.
void SetCompositorThread(blink::scheduler::WebThreadBase* compositor_thread); void SetCompositorThread(blink::scheduler::WebThreadBase* compositor_thread);
// Return the mojo interface for making ClipboardHost calls.
mojom::ClipboardHost& GetClipboardHost();
private: private:
PossiblyAssociatedInterfacePtr<mojom::URLLoaderFactory> PossiblyAssociatedInterfacePtr<mojom::URLLoaderFactory>
CreateNetworkURLLoaderFactory(); CreateNetworkURLLoaderFactory();
...@@ -299,8 +294,6 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { ...@@ -299,8 +294,6 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
std::unique_ptr<blink::WebThread> main_thread_; std::unique_ptr<blink::WebThread> main_thread_;
std::unique_ptr<service_manager::Connector> connector_; std::unique_ptr<service_manager::Connector> connector_;
std::unique_ptr<WebClipboardImpl> clipboard_;
class FileUtilities; class FileUtilities;
std::unique_ptr<FileUtilities> file_utilities_; std::unique_ptr<FileUtilities> file_utilities_;
...@@ -349,7 +342,6 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { ...@@ -349,7 +342,6 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
scoped_refptr<blink::mojom::ThreadSafeWebDatabaseHostPtr> web_database_host_; scoped_refptr<blink::mojom::ThreadSafeWebDatabaseHostPtr> web_database_host_;
mojom::FileUtilitiesHostPtrInfo file_utilities_host_info_; mojom::FileUtilitiesHostPtrInfo file_utilities_host_info_;
mojom::ClipboardHostPtr clipboard_host_;
scoped_refptr<NotificationDispatcher> notification_dispatcher_; scoped_refptr<NotificationDispatcher> notification_dispatcher_;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/renderer/webclipboard_impl.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
......
...@@ -145,16 +145,6 @@ void MockWebClipboardImpl::WritePlainText(const blink::WebString& plain_text) { ...@@ -145,16 +145,6 @@ void MockWebClipboardImpl::WritePlainText(const blink::WebString& plain_text) {
++m_sequenceNumber; ++m_sequenceNumber;
} }
void MockWebClipboardImpl::writeURL(const blink::WebURL& url,
const blink::WebString& title) {
clear();
m_htmlText = base::NullableString16(
base::UTF8ToUTF16(URLToMarkup(url, title)), false /* is_null */);
m_plainText = WebString::ToNullableString16(url.GetString());
++m_sequenceNumber;
}
void MockWebClipboardImpl::WriteImage(const blink::WebImage& image, void MockWebClipboardImpl::WriteImage(const blink::WebImage& image,
const blink::WebURL& url, const blink::WebURL& url,
const blink::WebString& title) { const blink::WebString& title) {
......
...@@ -49,8 +49,6 @@ class MockWebClipboardImpl : public blink::WebMockClipboard { ...@@ -49,8 +49,6 @@ class MockWebClipboardImpl : public blink::WebMockClipboard {
const blink::WebURL& url, const blink::WebURL& url,
const blink::WebString& plainText, const blink::WebString& plainText,
bool writeSmartPaste) override; bool writeSmartPaste) override;
virtual void writeURL(
const blink::WebURL& url, const blink::WebString& title);
void WriteImage(const blink::WebImage& image, void WriteImage(const blink::WebImage& image,
const blink::WebURL& url, const blink::WebURL& url,
const blink::WebString& title) override; const blink::WebString& title) override;
......
...@@ -554,6 +554,8 @@ jumbo_component("platform") { ...@@ -554,6 +554,8 @@ jumbo_component("platform") {
"exported/WebCORSPreflightResultCache.cpp", "exported/WebCORSPreflightResultCache.cpp",
"exported/WebCache.cpp", "exported/WebCache.cpp",
"exported/WebCanvasCaptureHandler.cpp", "exported/WebCanvasCaptureHandler.cpp",
"exported/WebClipboardImpl.cpp",
"exported/WebClipboardImpl.h",
"exported/WebCoalescedInputEvent.cpp", "exported/WebCoalescedInputEvent.cpp",
"exported/WebContentDecryptionModule.cpp", "exported/WebContentDecryptionModule.cpp",
"exported/WebContentDecryptionModuleAccess.cpp", "exported/WebContentDecryptionModuleAccess.cpp",
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
#include "public/platform/modules/serviceworker/WebServiceWorkerCacheStorage.h" #include "public/platform/modules/serviceworker/WebServiceWorkerCacheStorage.h"
#include "public/platform/modules/webmidi/WebMIDIAccessor.h" #include "public/platform/modules/webmidi/WebMIDIAccessor.h"
#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/connector.h"
#include "third_party/WebKit/Source/platform/exported/WebClipboardImpl.h"
#include "third_party/WebKit/common/origin_trials/trial_policy.h" #include "third_party/WebKit/common/origin_trials/trial_policy.h"
namespace blink { namespace blink {
...@@ -291,4 +292,10 @@ std::unique_ptr<WebTrialTokenValidator> Platform::CreateTrialTokenValidator() { ...@@ -291,4 +292,10 @@ std::unique_ptr<WebTrialTokenValidator> Platform::CreateTrialTokenValidator() {
return nullptr; return nullptr;
} }
// TODO(slangley): Remove this once we can get pepper to use mojo directly.
WebClipboard* Platform::Clipboard() {
DEFINE_STATIC_LOCAL(WebClipboardImpl, clipboard, ());
return &clipboard;
}
} // namespace blink } // namespace blink
...@@ -2,58 +2,55 @@ ...@@ -2,58 +2,55 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_RENDERER_WEBCLIPBOARD_IMPL_H_ #ifndef WebClipboardImpl_h
#define CONTENT_RENDERER_WEBCLIPBOARD_IMPL_H_ #define WebClipboardImpl_h
#include <stdint.h> #include <stdint.h>
#include <string> #include <string>
#include "base/compiler_specific.h" #include "third_party/WebKit/common/clipboard/clipboard.mojom-blink.h"
#include "content/common/clipboard.mojom.h"
#include "third_party/WebKit/public/platform/WebClipboard.h" #include "third_party/WebKit/public/platform/WebClipboard.h"
namespace content { namespace blink {
class WebClipboardImpl : public blink::WebClipboard { class WebClipboardImpl : public blink::WebClipboard {
public: public:
explicit WebClipboardImpl(mojom::ClipboardHost& clipboard); WebClipboardImpl();
virtual ~WebClipboardImpl(); virtual ~WebClipboardImpl();
// WebClipboard methods: // WebClipboard methods:
uint64_t SequenceNumber(blink::mojom::ClipboardBuffer buffer) override; uint64_t SequenceNumber(mojom::ClipboardBuffer) override;
bool IsFormatAvailable(blink::mojom::ClipboardFormat format, bool IsFormatAvailable(mojom::ClipboardFormat,
blink::mojom::ClipboardBuffer buffer) override; mojom::ClipboardBuffer) override;
blink::WebVector<blink::WebString> ReadAvailableTypes( blink::WebVector<blink::WebString> ReadAvailableTypes(
blink::mojom::ClipboardBuffer buffer, mojom::ClipboardBuffer,
bool* contains_filenames) override; bool* contains_filenames) override;
blink::WebString ReadPlainText(blink::mojom::ClipboardBuffer buffer) override; blink::WebString ReadPlainText(mojom::ClipboardBuffer) override;
blink::WebString ReadHTML(blink::mojom::ClipboardBuffer buffer, blink::WebString ReadHTML(mojom::ClipboardBuffer,
blink::WebURL* source_url, blink::WebURL* source_url,
unsigned* fragment_start, unsigned* fragment_start,
unsigned* fragment_end) override; unsigned* fragment_end) override;
blink::WebString ReadRTF(blink::mojom::ClipboardBuffer buffer) override; blink::WebString ReadRTF(mojom::ClipboardBuffer) override;
blink::WebBlobInfo ReadImage(blink::mojom::ClipboardBuffer buffer) override; blink::WebBlobInfo ReadImage(mojom::ClipboardBuffer) override;
blink::WebString ReadCustomData(blink::mojom::ClipboardBuffer buffer, blink::WebString ReadCustomData(mojom::ClipboardBuffer,
const blink::WebString& type) override; const blink::WebString& type) override;
void WritePlainText(const blink::WebString& plain_text) override; void WritePlainText(const blink::WebString& plain_text) override;
void WriteHTML(const blink::WebString& html_text, void WriteHTML(const blink::WebString& html_text,
const blink::WebURL& source_url, const blink::WebURL& source_url,
const blink::WebString& plain_text, const blink::WebString& plain_text,
bool write_smart_paste) override; bool write_smart_paste) override;
void WriteImage(const blink::WebImage& image, void WriteImage(const blink::WebImage&,
const blink::WebURL& source_url, const blink::WebURL& source_url,
const blink::WebString& title) override; const blink::WebString& title) override;
void WriteDataObject(const blink::WebDragData& data) override; void WriteDataObject(const blink::WebDragData&) override;
private: private:
bool IsValidBufferType(blink::mojom::ClipboardBuffer buffer); bool IsValidBufferType(mojom::ClipboardBuffer);
bool WriteImageToClipboard(blink::mojom::ClipboardBuffer buffer, bool WriteImageToClipboard(mojom::ClipboardBuffer, const SkBitmap&);
const SkBitmap& bitmap); mojom::blink::ClipboardHostPtr clipboard_;
mojom::ClipboardHost& clipboard_;
}; };
} // namespace content } // namespace blink
#endif // CONTENT_RENDERER_WEBCLIPBOARD_IMPL_H_ #endif // WebClipboardImpl_h
...@@ -128,6 +128,7 @@ mojom("mojo_platform_bindings") { ...@@ -128,6 +128,7 @@ mojom("mojo_platform_bindings") {
public_deps = [ public_deps = [
"//mojo/common:common_custom_types", "//mojo/common:common_custom_types",
"//ui/gfx/geometry/mojo",
"//url/mojo:url_mojom_gurl", "//url/mojo:url_mojom_gurl",
"//url/mojo:url_mojom_origin", "//url/mojo:url_mojom_origin",
] ]
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
module blink.mojom; module blink.mojom;
import "mojo/common/string16.mojom";
import "ui/gfx/geometry/mojo/geometry.mojom";
import "url/mojo/url.mojom";
enum ClipboardFormat { enum ClipboardFormat {
kPlaintext, kPlaintext,
kHtml, kHtml,
...@@ -19,3 +23,74 @@ enum ClipboardBuffer { ...@@ -19,3 +23,74 @@ enum ClipboardBuffer {
// define this value for USE_X11. // define this value for USE_X11.
kSelection, kSelection,
}; };
interface ClipboardHost {
[Sync]
GetSequenceNumber(blink.mojom.ClipboardBuffer buffer) => (uint64 result);
[Sync]
IsFormatAvailable(blink.mojom.ClipboardFormat format,
blink.mojom.ClipboardBuffer buffer) => (bool result);
[Sync]
ReadAvailableTypes(blink.mojom.ClipboardBuffer buffer) =>
(array<mojo.common.mojom.String16> types, bool result);
[Sync]
ReadText(blink.mojom.ClipboardBuffer buffer) =>
(mojo.common.mojom.String16 result);
[Sync]
ReadHtml(blink.mojom.ClipboardBuffer buffer) =>
(mojo.common.mojom.String16 markup,
url.mojom.Url url,
uint32 fragment_start,
uint32 fragment_end);
[Sync]
ReadRtf(blink.mojom.ClipboardBuffer buffer) => (string result);
[Sync]
ReadImage(blink.mojom.ClipboardBuffer buffer) => (string blob_uuid,
string mime_type,
int64 size);
[Sync]
ReadCustomData(blink.mojom.ClipboardBuffer buffer,
mojo.common.mojom.String16 type) =>
(mojo.common.mojom.String16 result);
// Writing to the clipboard via IPC is a two-phase operation. First, the
// sender sends the different types of data it'd like to write to the
// receiver. Then, it sends a commit message to commit the data to the system
// clipboard.
WriteText(blink.mojom.ClipboardBuffer buffer,
mojo.common.mojom.String16 text);
WriteHtml(blink.mojom.ClipboardBuffer buffer,
mojo.common.mojom.String16 markup,
url.mojom.Url url);
WriteSmartPasteMarker(blink.mojom.ClipboardBuffer buffer);
WriteCustomData(
blink.mojom.ClipboardBuffer buffer,
map<mojo.common.mojom.String16, mojo.common.mojom.String16> data);
// TODO(dcheng): The |url| parameter should really be a GURL, but <canvas>'s
// copy as image tries to set very long data: URLs on the clipboard. Using
// GURL causes the browser to kill the renderer for sending a bad IPC (GURLs
// bigger than 2 megabytes are considered to be bad). https://crbug.com/459822
WriteBookmark(blink.mojom.ClipboardBuffer buffer,
string url,
mojo.common.mojom.String16 title);
WriteImage(blink.mojom.ClipboardBuffer buffer,
gfx.mojom.Size size_in_pixels,
handle<shared_buffer> shared_buffer_handle);
CommitWrite(blink.mojom.ClipboardBuffer buffer);
// OS_MACOSX only
WriteStringToFindPboard(mojo.common.mojom.String16 text);
};
...@@ -165,7 +165,7 @@ class BLINK_PLATFORM_EXPORT Platform { ...@@ -165,7 +165,7 @@ class BLINK_PLATFORM_EXPORT Platform {
virtual WebCookieJar* CookieJar() { return nullptr; } virtual WebCookieJar* CookieJar() { return nullptr; }
// Must return non-null. // Must return non-null.
virtual WebClipboard* Clipboard() { return nullptr; } virtual WebClipboard* Clipboard();
// Must return non-null. // Must return non-null.
virtual WebFileUtilities* GetFileUtilities() { return nullptr; } virtual WebFileUtilities* GetFileUtilities() { return nullptr; }
......
...@@ -94,7 +94,7 @@ class WebClipboard { ...@@ -94,7 +94,7 @@ class WebClipboard {
virtual void WriteDataObject(const WebDragData&) {} virtual void WriteDataObject(const WebDragData&) {}
protected: protected:
~WebClipboard() {} ~WebClipboard() = default;
}; };
} // namespace blink } // namespace blink
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment