summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 18:49:17 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 18:49:17 +0000
commit7e358974036ac5668c6fd779d9f0faaa3137baab (patch)
tree446456170dc2782167fdce833efa7497e7223f74
parent4848b9f891c3d572f7dc88478e2a1ca84c28f92d (diff)
downloadchromium_src-7e358974036ac5668c6fd779d9f0faaa3137baab.zip
chromium_src-7e358974036ac5668c6fd779d9f0faaa3137baab.tar.gz
chromium_src-7e358974036ac5668c6fd779d9f0faaa3137baab.tar.bz2
Move the clipboard messages to their own message filter.
BUG=75525 TEST=none Review URL: http://codereview.chromium.org/6657013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77664 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc2
-rw-r--r--chrome/chrome_common.gypi1
-rw-r--r--chrome/common/clipboard_messages.h63
-rw-r--r--chrome/common/common_message_generator.h1
-rw-r--r--chrome/common/render_messages.h37
-rw-r--r--chrome/common/render_messages_internal.h47
-rw-r--r--chrome/renderer/render_view.cc3
-rw-r--r--chrome/renderer/renderer_glue.cc19
-rw-r--r--content/browser/renderer_host/clipboard_message_filter.cc162
-rw-r--r--content/browser/renderer_host/clipboard_message_filter.h59
-rw-r--r--content/browser/renderer_host/clipboard_message_filter_mac.mm (renamed from content/browser/renderer_host/render_message_filter_mac.mm)6
-rw-r--r--content/browser/renderer_host/render_message_filter.cc169
-rw-r--r--content/browser/renderer_host/render_message_filter.h44
-rw-r--r--content/browser/renderer_host/render_message_filter_gtk.cc131
-rw-r--r--content/content_browser.gypi4
-rw-r--r--ipc/ipc_message_utils.h1
16 files changed, 309 insertions, 440 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index c8dc43a..f9007d9 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -74,6 +74,7 @@
#include "content/browser/plugin_service.h"
#include "content/browser/renderer_host/audio_renderer_host.h"
#include "content/browser/renderer_host/blob_message_filter.h"
+#include "content/browser/renderer_host/clipboard_message_filter.h"
#include "content/browser/renderer_host/database_message_filter.h"
#include "content/browser/renderer_host/file_utilities_message_filter.h"
#include "content/browser/renderer_host/gpu_message_filter.h"
@@ -453,6 +454,7 @@ void BrowserRenderProcessHost::CreateMessageFilters() {
channel_->AddFilter(new AudioRendererHost());
channel_->AddFilter(
new AppCacheDispatcherHost(profile()->GetRequestContext(), id()));
+ channel_->AddFilter(new ClipboardMessageFilter());
channel_->AddFilter(new DOMStorageMessageFilter(id(), profile()));
channel_->AddFilter(new IndexedDBDispatcherHost(id(), profile()));
channel_->AddFilter(
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 865b4e5..2b566a4 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -41,6 +41,7 @@
'common/chrome_counters.h',
'common/chrome_version_info.cc',
'common/chrome_version_info.h',
+ 'common/clipboard_messages.h',
'common/common_message_generator.cc',
'common/common_message_generator.h',
'common/common_param_traits.cc',
diff --git a/chrome/common/clipboard_messages.h b/chrome/common/clipboard_messages.h
new file mode 100644
index 0000000..9bbce5b
--- /dev/null
+++ b/chrome/common/clipboard_messages.h
@@ -0,0 +1,63 @@
+// Copyright (c) 2011 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.
+
+// Multiply-included message file, so no include guard.
+
+#include <string>
+#include <vector>
+
+// #include "chrome/common/common_param_traits.h"
+#include "content/common/common_param_traits.h"
+#include "ipc/ipc_message_macros.h"
+#include "ipc/ipc_param_traits.h"
+#include "ui/base/clipboard/clipboard.h"
+
+#define IPC_MESSAGE_START ClipboardMsgStart
+
+IPC_ENUM_TRAITS(ui::Clipboard::Buffer)
+
+// Clipboard IPC messages sent from the renderer to the browser.
+
+// This message is used when the object list does not contain a bitmap.
+IPC_MESSAGE_CONTROL1(ClipboardHostMsg_WriteObjectsAsync,
+ ui::Clipboard::ObjectMap /* objects */)
+// This message is used when the object list contains a bitmap.
+// It is synchronized so that the renderer knows when it is safe to
+// free the shared memory used to transfer the bitmap.
+IPC_SYNC_MESSAGE_CONTROL2_0(ClipboardHostMsg_WriteObjectsSync,
+ ui::Clipboard::ObjectMap /* objects */,
+ base::SharedMemoryHandle /* bitmap handle */)
+IPC_SYNC_MESSAGE_CONTROL2_1(ClipboardHostMsg_IsFormatAvailable,
+ std::string /* format */,
+ ui::Clipboard::Buffer /* buffer */,
+ bool /* result */)
+IPC_SYNC_MESSAGE_CONTROL1_1(ClipboardHostMsg_ReadText,
+ ui::Clipboard::Buffer /* buffer */,
+ string16 /* result */)
+IPC_SYNC_MESSAGE_CONTROL1_1(ClipboardHostMsg_ReadAsciiText,
+ ui::Clipboard::Buffer /* buffer */,
+ std::string /* result */)
+IPC_SYNC_MESSAGE_CONTROL1_2(ClipboardHostMsg_ReadHTML,
+ ui::Clipboard::Buffer /* buffer */,
+ string16 /* markup */,
+ GURL /* url */)
+#if defined(OS_MACOSX)
+IPC_MESSAGE_CONTROL1(ClipboardHostMsg_FindPboardWriteStringAsync,
+ string16 /* text */)
+#endif
+IPC_SYNC_MESSAGE_CONTROL1_3(ClipboardHostMsg_ReadAvailableTypes,
+ ui::Clipboard::Buffer /* buffer */,
+ bool /* result */,
+ std::vector<string16> /* types */,
+ bool /* contains filenames */)
+IPC_SYNC_MESSAGE_CONTROL2_3(ClipboardHostMsg_ReadData,
+ ui::Clipboard::Buffer /* buffer */,
+ string16 /* type */,
+ bool /* succeeded */,
+ string16 /* data */,
+ string16 /* metadata */)
+IPC_SYNC_MESSAGE_CONTROL1_2(ClipboardHostMsg_ReadFilenames,
+ ui::Clipboard::Buffer /* buffer */,
+ bool /* result */,
+ std::vector<string16> /* filenames */)
diff --git a/chrome/common/common_message_generator.h b/chrome/common/common_message_generator.h
index c8abe08..4ce33ad 100644
--- a/chrome/common/common_message_generator.h
+++ b/chrome/common/common_message_generator.h
@@ -5,6 +5,7 @@
// Multiply-included file, hence no include guard.
#include "chrome/common/autofill_messages.h"
+#include "chrome/common/clipboard_messages.h"
#include "chrome/common/database_messages.h"
#include "chrome/common/file_utilities_messages.h"
#include "chrome/common/indexed_db_messages.h"
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 5a257f2..a9d548d 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -23,7 +23,6 @@
#include "content/common/common_param_traits.h"
#include "ipc/ipc_message_utils.h"
#include "ipc/ipc_platform_file.h" // ifdefed typedef.
-#include "ui/base/clipboard/clipboard.h" // enum
#include "webkit/appcache/appcache_interfaces.h" // enum appcache::Status
#if defined(OS_MACOSX)
@@ -355,42 +354,6 @@ struct ParamTraits<URLPattern> {
static void Log(const param_type& p, std::string* l);
};
-template <>
-struct ParamTraits<ui::Clipboard::Buffer> {
- typedef ui::Clipboard::Buffer param_type;
- static void Write(Message* m, const param_type& p) {
- m->WriteInt(p);
- }
- static bool Read(const Message* m, void** iter, param_type* p) {
- int buffer;
- if (!m->ReadInt(iter, &buffer) || !ui::Clipboard::IsValidBuffer(buffer))
- return false;
- *p = ui::Clipboard::FromInt(buffer);
- return true;
- }
- static void Log(const param_type& p, std::string* l) {
- std::string type;
- switch (p) {
- case ui::Clipboard::BUFFER_STANDARD:
- type = "BUFFER_STANDARD";
- break;
-#if defined(USE_X11)
- case ui::Clipboard::BUFFER_SELECTION:
- type = "BUFFER_SELECTION";
- break;
-#endif
- case ui::Clipboard::BUFFER_DRAG:
- type = "BUFFER_DRAG";
- break;
- default:
- type = "UNKNOWN";
- break;
- }
-
- LogParam(type, l);
- }
-};
-
// Traits for EditCommand structure.
template <>
struct ParamTraits<EditCommand> {
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index fc2b135..c45b865 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -12,6 +12,8 @@
#include "base/file_path.h"
#include "base/nullable_string16.h"
#include "base/platform_file.h"
+#include "base/process.h"
+#include "base/shared_memory.h"
#include "base/sync_socket.h"
#include "chrome/common/content_settings.h"
#include "chrome/common/extensions/extension.h"
@@ -1448,52 +1450,7 @@ IPC_SYNC_MESSAGE_ROUTED1_0(ViewHostMsg_DestroyPluginContainer,
gfx::PluginWindowHandle /* id */)
#endif
-// Clipboard IPC messages
-
-// This message is used when the object list does not contain a bitmap.
-IPC_MESSAGE_CONTROL1(ViewHostMsg_ClipboardWriteObjectsAsync,
- ui::Clipboard::ObjectMap /* objects */)
-// This message is used when the object list contains a bitmap.
-// It is synchronized so that the renderer knows when it is safe to
-// free the shared memory used to transfer the bitmap.
-IPC_SYNC_MESSAGE_CONTROL2_0(ViewHostMsg_ClipboardWriteObjectsSync,
- ui::Clipboard::ObjectMap /* objects */,
- base::SharedMemoryHandle /* bitmap handle */)
-IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_ClipboardIsFormatAvailable,
- std::string /* format */,
- ui::Clipboard::Buffer /* buffer */,
- bool /* result */)
-IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_ClipboardReadText,
- ui::Clipboard::Buffer /* buffer */,
- string16 /* result */)
-IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_ClipboardReadAsciiText,
- ui::Clipboard::Buffer /* buffer */,
- std::string /* result */)
-IPC_SYNC_MESSAGE_CONTROL1_2(ViewHostMsg_ClipboardReadHTML,
- ui::Clipboard::Buffer /* buffer */,
- string16 /* markup */,
- GURL /* url */)
-
-IPC_SYNC_MESSAGE_CONTROL1_3(ViewHostMsg_ClipboardReadAvailableTypes,
- ui::Clipboard::Buffer /* buffer */,
- bool /* result */,
- std::vector<string16> /* types */,
- bool /* contains filenames */)
-IPC_SYNC_MESSAGE_CONTROL2_3(ViewHostMsg_ClipboardReadData,
- ui::Clipboard::Buffer /* buffer */,
- string16 /* type */,
- bool /* succeeded */,
- string16 /* data */,
- string16 /* metadata */)
-IPC_SYNC_MESSAGE_CONTROL1_2(ViewHostMsg_ClipboardReadFilenames,
- ui::Clipboard::Buffer /* buffer */,
- bool /* result */,
- std::vector<string16> /* filenames */)
-
#if defined(OS_MACOSX)
-IPC_MESSAGE_CONTROL1(ViewHostMsg_ClipboardFindPboardWriteStringAsync,
- string16 /* text */)
-
// Request that the browser load a font into shared memory for us.
IPC_SYNC_MESSAGE_CONTROL1_2(ViewHostMsg_LoadFont,
FontDescriptor /* font to load */,
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 513d5f5..c0a2e4b 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -29,6 +29,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/clipboard_messages.h"
#include "chrome/common/database_messages.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -1547,7 +1548,7 @@ void RenderView::OnCopyToFindPboard() {
if (frame->hasSelection()) {
string16 selection = frame->selectionAsText();
RenderThread::current()->Send(
- new ViewHostMsg_ClipboardFindPboardWriteStringAsync(selection));
+ new ClipboardHostMsg_FindPboardWriteStringAsync(selection));
}
UserMetricsRecordAction("CopyToFindPboard");
diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc
index 2506066..6b325b8 100644
--- a/chrome/renderer/renderer_glue.cc
+++ b/chrome/renderer/renderer_glue.cc
@@ -18,6 +18,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
+#include "chrome/common/clipboard_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
#include "chrome/plugin/npobject_util.h"
@@ -115,14 +116,14 @@ ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() {
if (shared_buf_) {
RenderThread::current()->Send(
- new ViewHostMsg_ClipboardWriteObjectsSync(objects_,
+ new ClipboardHostMsg_WriteObjectsSync(objects_,
shared_buf_->handle()));
delete shared_buf_;
return;
}
RenderThread::current()->Send(
- new ViewHostMsg_ClipboardWriteObjectsAsync(objects_));
+ new ClipboardHostMsg_WriteObjectsAsync(objects_));
}
namespace webkit_glue {
@@ -161,23 +162,23 @@ bool ClipboardIsFormatAvailable(const ui::Clipboard::FormatType& format,
ui::Clipboard::Buffer buffer) {
bool result;
RenderThread::current()->Send(
- new ViewHostMsg_ClipboardIsFormatAvailable(format, buffer, &result));
+ new ClipboardHostMsg_IsFormatAvailable(format, buffer, &result));
return result;
}
void ClipboardReadText(ui::Clipboard::Buffer buffer, string16* result) {
- RenderThread::current()->Send(new ViewHostMsg_ClipboardReadText(buffer,
+ RenderThread::current()->Send(new ClipboardHostMsg_ReadText(buffer,
result));
}
void ClipboardReadAsciiText(ui::Clipboard::Buffer buffer, std::string* result) {
- RenderThread::current()->Send(new ViewHostMsg_ClipboardReadAsciiText(buffer,
+ RenderThread::current()->Send(new ClipboardHostMsg_ReadAsciiText(buffer,
result));
}
void ClipboardReadHTML(ui::Clipboard::Buffer buffer, string16* markup,
GURL* url) {
- RenderThread::current()->Send(new ViewHostMsg_ClipboardReadHTML(buffer,
+ RenderThread::current()->Send(new ClipboardHostMsg_ReadHTML(buffer,
markup, url));
}
@@ -185,7 +186,7 @@ bool ClipboardReadAvailableTypes(ui::Clipboard::Buffer buffer,
std::vector<string16>* types,
bool* contains_filenames) {
bool result = false;
- RenderThread::current()->Send(new ViewHostMsg_ClipboardReadAvailableTypes(
+ RenderThread::current()->Send(new ClipboardHostMsg_ReadAvailableTypes(
buffer, &result, types, contains_filenames));
return result;
}
@@ -193,7 +194,7 @@ bool ClipboardReadAvailableTypes(ui::Clipboard::Buffer buffer,
bool ClipboardReadData(ui::Clipboard::Buffer buffer, const string16& type,
string16* data, string16* metadata) {
bool result = false;
- RenderThread::current()->Send(new ViewHostMsg_ClipboardReadData(
+ RenderThread::current()->Send(new ClipboardHostMsg_ReadData(
buffer, type, &result, data, metadata));
return result;
}
@@ -201,7 +202,7 @@ bool ClipboardReadData(ui::Clipboard::Buffer buffer, const string16& type,
bool ClipboardReadFilenames(ui::Clipboard::Buffer buffer,
std::vector<string16>* filenames) {
bool result;
- RenderThread::current()->Send(new ViewHostMsg_ClipboardReadFilenames(
+ RenderThread::current()->Send(new ClipboardHostMsg_ReadFilenames(
buffer, &result, filenames));
return result;
}
diff --git a/content/browser/renderer_host/clipboard_message_filter.cc b/content/browser/renderer_host/clipboard_message_filter.cc
new file mode 100644
index 0000000..8cb3b9d
--- /dev/null
+++ b/content/browser/renderer_host/clipboard_message_filter.cc
@@ -0,0 +1,162 @@
+// Copyright (c) 2011 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 "content/browser/renderer_host/clipboard_message_filter.h"
+
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/clipboard_dispatcher.h"
+#include "chrome/common/clipboard_messages.h"
+#include "googleurl/src/gurl.h"
+#include "ipc/ipc_message_macros.h"
+
+namespace {
+
+// Completes a clipboard write initiated by the renderer. The write must be
+// performed on the UI thread because the clipboard service from the IO thread
+// cannot create windows so it cannot be the "owner" of the clipboard's
+// contents.
+class WriteClipboardTask : public Task {
+ public:
+ explicit WriteClipboardTask(ui::Clipboard::ObjectMap* objects)
+ : objects_(objects) {}
+ ~WriteClipboardTask() {}
+
+ void Run() {
+ g_browser_process->clipboard()->WriteObjects(*objects_.get());
+ }
+
+ private:
+ scoped_ptr<ui::Clipboard::ObjectMap> objects_;
+};
+
+} // namespace
+
+ClipboardMessageFilter::ClipboardMessageFilter() {
+}
+
+void ClipboardMessageFilter::OverrideThreadForMessage(
+ const IPC::Message& message, BrowserThread::ID* thread) {
+#if defined(USE_X11)
+ if (IPC_MESSAGE_CLASS(message) == ClipboardMsgStart)
+ *thread = BrowserThread::UI;
+#endif
+}
+
+bool ClipboardMessageFilter::OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP_EX(ClipboardMessageFilter, message, *message_was_ok)
+ IPC_MESSAGE_HANDLER(ClipboardHostMsg_WriteObjectsAsync, OnWriteObjectsAsync)
+ IPC_MESSAGE_HANDLER(ClipboardHostMsg_WriteObjectsSync, OnWriteObjectsSync)
+ IPC_MESSAGE_HANDLER(ClipboardHostMsg_IsFormatAvailable, OnIsFormatAvailable)
+ IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadText, OnReadText)
+ IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadAsciiText, OnReadAsciiText)
+ IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadHTML, OnReadHTML)
+#if defined(OS_MACOSX)
+ IPC_MESSAGE_HANDLER(ClipboardHostMsg_FindPboardWriteStringAsync,
+ OnFindPboardWriteString)
+#endif
+ IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadAvailableTypes,
+ OnReadAvailableTypes)
+ IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadData, OnReadData)
+ IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadFilenames, OnReadFilenames)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+ClipboardMessageFilter::~ClipboardMessageFilter() {
+}
+
+void ClipboardMessageFilter::OnWriteObjectsSync(
+ const ui::Clipboard::ObjectMap& objects,
+ base::SharedMemoryHandle bitmap_handle) {
+ DCHECK(base::SharedMemory::IsHandleValid(bitmap_handle))
+ << "Bad bitmap handle";
+ // We cannot write directly from the IO thread, and cannot service the IPC
+ // on the UI thread. We'll copy the relevant data and get a handle to any
+ // shared memory so it doesn't go away when we resume the renderer, and post
+ // a task to perform the write on the UI thread.
+ ui::Clipboard::ObjectMap* long_living_objects =
+ new ui::Clipboard::ObjectMap(objects);
+
+ // Splice the shared memory handle into the clipboard data.
+ ui::Clipboard::ReplaceSharedMemHandle(long_living_objects, bitmap_handle,
+ peer_handle());
+
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ new WriteClipboardTask(long_living_objects));
+}
+
+void ClipboardMessageFilter::OnWriteObjectsAsync(
+ const ui::Clipboard::ObjectMap& objects) {
+ // We cannot write directly from the IO thread, and cannot service the IPC
+ // on the UI thread. We'll copy the relevant data and post a task to preform
+ // the write on the UI thread.
+ ui::Clipboard::ObjectMap* long_living_objects =
+ new ui::Clipboard::ObjectMap(objects);
+
+ // This async message doesn't support shared-memory based bitmaps; they must
+ // be removed otherwise we might dereference a rubbish pointer.
+ long_living_objects->erase(ui::Clipboard::CBF_SMBITMAP);
+
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ new WriteClipboardTask(long_living_objects));
+}
+
+void ClipboardMessageFilter::OnIsFormatAvailable(
+ ui::Clipboard::FormatType format, ui::Clipboard::Buffer buffer,
+ bool* result) {
+ *result = GetClipboard()->IsFormatAvailable(format, buffer);
+}
+
+void ClipboardMessageFilter::OnReadText(
+ ui::Clipboard::Buffer buffer, string16* result) {
+ GetClipboard()->ReadText(buffer, result);
+}
+
+void ClipboardMessageFilter::OnReadAsciiText(
+ ui::Clipboard::Buffer buffer, std::string* result) {
+ GetClipboard()->ReadAsciiText(buffer, result);
+}
+
+void ClipboardMessageFilter::OnReadHTML(
+ ui::Clipboard::Buffer buffer, string16* markup, GURL* url) {
+ std::string src_url_str;
+ GetClipboard()->ReadHTML(buffer, markup, &src_url_str);
+ *url = GURL(src_url_str);
+}
+
+void ClipboardMessageFilter::OnReadAvailableTypes(
+ ui::Clipboard::Buffer buffer, bool* succeeded, std::vector<string16>* types,
+ bool* contains_filenames) {
+ *contains_filenames = false;
+ *succeeded = ClipboardDispatcher::ReadAvailableTypes(
+ buffer, types, contains_filenames);
+}
+
+void ClipboardMessageFilter::OnReadData(
+ ui::Clipboard::Buffer buffer, const string16& type, bool* succeeded,
+ string16* data, string16* metadata) {
+ *succeeded = ClipboardDispatcher::ReadData(buffer, type, data, metadata);
+}
+
+void ClipboardMessageFilter::OnReadFilenames(
+ ui::Clipboard::Buffer buffer, bool* succeeded,
+ std::vector<string16>* filenames) {
+ *succeeded = ClipboardDispatcher::ReadFilenames(buffer, filenames);
+}
+
+// static
+ui::Clipboard* ClipboardMessageFilter::GetClipboard() {
+ // We have a static instance of the clipboard service for use by all message
+ // filters. This instance lives for the life of the browser processes.
+ static ui::Clipboard* clipboard = new ui::Clipboard;
+
+ return clipboard;
+}
diff --git a/content/browser/renderer_host/clipboard_message_filter.h b/content/browser/renderer_host/clipboard_message_filter.h
new file mode 100644
index 0000000..f755d91
--- /dev/null
+++ b/content/browser/renderer_host/clipboard_message_filter.h
@@ -0,0 +1,59 @@
+// Copyright (c) 2011 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 CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_
+#define CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "content/browser/browser_message_filter.h"
+#include "ui/base/clipboard/clipboard.h"
+
+class GURL;
+
+class ClipboardMessageFilter : public BrowserMessageFilter {
+ public:
+ ClipboardMessageFilter();
+
+ virtual void OverrideThreadForMessage(const IPC::Message& message,
+ BrowserThread::ID* thread);
+ virtual bool OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok);
+ private:
+ ~ClipboardMessageFilter();
+
+ void OnWriteObjectsAsync(const ui::Clipboard::ObjectMap& objects);
+ void OnWriteObjectsSync(const ui::Clipboard::ObjectMap& objects,
+ base::SharedMemoryHandle bitmap_handle);
+
+ void OnIsFormatAvailable(ui::Clipboard::FormatType format,
+ ui::Clipboard::Buffer buffer,
+ bool* result);
+ void OnReadText(ui::Clipboard::Buffer buffer, string16* result);
+ void OnReadAsciiText(ui::Clipboard::Buffer buffer, std::string* result);
+ void OnReadHTML(ui::Clipboard::Buffer buffer, string16* markup, GURL* url);
+#if defined(OS_MACOSX)
+ void OnFindPboardWriteString(const string16& text);
+#endif
+ void OnReadAvailableTypes(ui::Clipboard::Buffer buffer,
+ bool* succeeded,
+ std::vector<string16>* types,
+ bool* contains_filenames);
+ void OnReadData(ui::Clipboard::Buffer buffer, const string16& type,
+ bool* succeeded, string16* data, string16* metadata);
+ void OnReadFilenames(ui::Clipboard::Buffer buffer, bool* succeeded,
+ std::vector<string16>* filenames);
+
+ // We have our own clipboard because we want to access the clipboard on the
+ // IO thread instead of forwarding (possibly synchronous) messages to the UI
+ // thread. This instance of the clipboard should be accessed only on the IO
+ // thread.
+ static ui::Clipboard* GetClipboard();
+
+ DISALLOW_COPY_AND_ASSIGN(ClipboardMessageFilter);
+};
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_CLIPBOARD_MESSAGE_FILTER_H_
diff --git a/content/browser/renderer_host/render_message_filter_mac.mm b/content/browser/renderer_host/clipboard_message_filter_mac.mm
index 4cbcef9..72cfc53 100644
--- a/content/browser/renderer_host/render_message_filter_mac.mm
+++ b/content/browser/renderer_host/clipboard_message_filter_mac.mm
@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/renderer_host/render_message_filter.h"
+#include "content/browser/renderer_host/clipboard_message_filter.h"
#import <Cocoa/Cocoa.h>
-#include "base/message_loop.h"
#include "base/sys_string_conversions.h"
#import "chrome/browser/ui/cocoa/find_pasteboard.h"
#include "content/browser/browser_thread.h"
@@ -30,8 +29,7 @@ class WriteFindPboardTask : public Task {
};
// Called on the IO thread.
-void RenderMessageFilter::OnClipboardFindPboardWriteString(
- const string16& text) {
+void ClipboardMessageFilter::OnFindPboardWriteString(const string16& text) {
if (text.length() <= kMaxFindPboardStringLength) {
NSString* nsText = base::SysUTF16ToNSString(text);
if (nsText) {
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index a181ab4..32d6214 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -16,7 +16,6 @@
#include "chrome/browser/automation/automation_resource_message_filter.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_plugin_browsing_context.h"
-#include "chrome/browser/clipboard_dispatcher.h"
#include "chrome/browser/download/download_types.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/metrics/histogram_synchronizer.h"
@@ -123,24 +122,6 @@ class ContextMenuMessageDispatcher : public Task {
DISALLOW_COPY_AND_ASSIGN(ContextMenuMessageDispatcher);
};
-// Completes a clipboard write initiated by the renderer. The write must be
-// performed on the UI thread because the clipboard service from the IO thread
-// cannot create windows so it cannot be the "owner" of the clipboard's
-// contents.
-class WriteClipboardTask : public Task {
- public:
- explicit WriteClipboardTask(ui::Clipboard::ObjectMap* objects)
- : objects_(objects) {}
- ~WriteClipboardTask() {}
-
- void Run() {
- g_browser_process->clipboard()->WriteObjects(*objects_.get());
- }
-
- private:
- scoped_ptr<ui::Clipboard::ObjectMap> objects_;
-};
-
// Common functionality for converting a sync renderer message to a callback
// function in the browser. Derive from this, create it on the heap when
// issuing your callback. When done, write your reply parameters into
@@ -383,28 +364,6 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_HANDLER(ViewHostMsg_RendererHistograms, OnRendererHistograms)
IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_UpdateRect,
render_widget_helper_->DidReceiveUpdateMsg(message))
- IPC_MESSAGE_HANDLER(ViewHostMsg_ClipboardWriteObjectsAsync,
- OnClipboardWriteObjectsAsync)
- IPC_MESSAGE_HANDLER(ViewHostMsg_ClipboardWriteObjectsSync,
- OnClipboardWriteObjectsSync)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ClipboardIsFormatAvailable,
- OnClipboardIsFormatAvailable)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ClipboardReadText,
- OnClipboardReadText)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ClipboardReadAsciiText,
- OnClipboardReadAsciiText)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ClipboardReadHTML,
- OnClipboardReadHTML)
-#if defined(OS_MACOSX)
- IPC_MESSAGE_HANDLER(ViewHostMsg_ClipboardFindPboardWriteStringAsync,
- OnClipboardFindPboardWriteString)
-#endif
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ClipboardReadAvailableTypes,
- OnClipboardReadAvailableTypes)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ClipboardReadData,
- OnClipboardReadData)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ClipboardReadFilenames,
- OnClipboardReadFilenames)
IPC_MESSAGE_HANDLER(ViewHostMsg_CheckNotificationPermission,
OnCheckNotificationPermission)
IPC_MESSAGE_HANDLER(ViewHostMsg_RevealFolderInOS, OnRevealFolderInOS)
@@ -798,125 +757,6 @@ void RenderMessageFilter::OnDownloadUrl(const IPC::Message& message,
context);
}
-void RenderMessageFilter::OnClipboardWriteObjectsSync(
- const ui::Clipboard::ObjectMap& objects,
- base::SharedMemoryHandle bitmap_handle) {
- DCHECK(base::SharedMemory::IsHandleValid(bitmap_handle))
- << "Bad bitmap handle";
- // We cannot write directly from the IO thread, and cannot service the IPC
- // on the UI thread. We'll copy the relevant data and get a handle to any
- // shared memory so it doesn't go away when we resume the renderer, and post
- // a task to perform the write on the UI thread.
- ui::Clipboard::ObjectMap* long_living_objects =
- new ui::Clipboard::ObjectMap(objects);
-
- // Splice the shared memory handle into the clipboard data.
- ui::Clipboard::ReplaceSharedMemHandle(long_living_objects, bitmap_handle,
- peer_handle());
-
- BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- new WriteClipboardTask(long_living_objects));
-}
-
-void RenderMessageFilter::OnClipboardWriteObjectsAsync(
- const ui::Clipboard::ObjectMap& objects) {
- // We cannot write directly from the IO thread, and cannot service the IPC
- // on the UI thread. We'll copy the relevant data and post a task to preform
- // the write on the UI thread.
- ui::Clipboard::ObjectMap* long_living_objects =
- new ui::Clipboard::ObjectMap(objects);
-
- // This async message doesn't support shared-memory based bitmaps; they must
- // be removed otherwise we might dereference a rubbish pointer.
- long_living_objects->erase(ui::Clipboard::CBF_SMBITMAP);
-
- BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- new WriteClipboardTask(long_living_objects));
-}
-
-#if !defined(USE_X11)
-// On non-X11 platforms, clipboard actions can be performed on the IO thread.
-// On X11, since the clipboard is linked with GTK, we either have to do this
-// with GTK on the UI thread, or with Xlib on the BACKGROUND_X11 thread. In an
-// ideal world, we would do the latter. However, for now we're going to
-// terminate these calls on the UI thread. This risks deadlock in the case of
-// plugins, but it's better than crashing which is what doing on the IO thread
-// gives us.
-//
-// See resource_message_filter_gtk.cc for the Linux implementation of these
-// functions.
-
-void RenderMessageFilter::OnClipboardIsFormatAvailable(
- ui::Clipboard::FormatType format, ui::Clipboard::Buffer buffer,
- IPC::Message* reply) {
- const bool result = GetClipboard()->IsFormatAvailable(format, buffer);
- ViewHostMsg_ClipboardIsFormatAvailable::WriteReplyParams(reply, result);
- Send(reply);
-}
-
-void RenderMessageFilter::OnClipboardReadText(ui::Clipboard::Buffer buffer,
- IPC::Message* reply) {
- string16 result;
- GetClipboard()->ReadText(buffer, &result);
- ViewHostMsg_ClipboardReadText::WriteReplyParams(reply, result);
- Send(reply);
-}
-
-void RenderMessageFilter::OnClipboardReadAsciiText(ui::Clipboard::Buffer buffer,
- IPC::Message* reply) {
- std::string result;
- GetClipboard()->ReadAsciiText(buffer, &result);
- ViewHostMsg_ClipboardReadAsciiText::WriteReplyParams(reply, result);
- Send(reply);
-}
-
-void RenderMessageFilter::OnClipboardReadHTML(ui::Clipboard::Buffer buffer,
- IPC::Message* reply) {
- std::string src_url_str;
- string16 markup;
- GetClipboard()->ReadHTML(buffer, &markup, &src_url_str);
- const GURL src_url = GURL(src_url_str);
-
- ViewHostMsg_ClipboardReadHTML::WriteReplyParams(reply, markup, src_url);
- Send(reply);
-}
-
-void RenderMessageFilter::OnClipboardReadAvailableTypes(
- ui::Clipboard::Buffer buffer, IPC::Message* reply) {
- std::vector<string16> types;
- bool contains_filenames = false;
- bool result = ClipboardDispatcher::ReadAvailableTypes(
- buffer, &types, &contains_filenames);
- ViewHostMsg_ClipboardReadAvailableTypes::WriteReplyParams(
- reply, result, types, contains_filenames);
- Send(reply);
-}
-
-void RenderMessageFilter::OnClipboardReadData(
- ui::Clipboard::Buffer buffer, const string16& type, IPC::Message* reply) {
- string16 data;
- string16 metadata;
- bool result = ClipboardDispatcher::ReadData(buffer, type, &data, &metadata);
- ViewHostMsg_ClipboardReadData::WriteReplyParams(
- reply, result, data, metadata);
- Send(reply);
-}
-
-void RenderMessageFilter::OnClipboardReadFilenames(
- ui::Clipboard::Buffer buffer, IPC::Message* reply) {
- std::vector<string16> filenames;
- bool result = ClipboardDispatcher::ReadFilenames(buffer, &filenames);
- ViewHostMsg_ClipboardReadFilenames::WriteReplyParams(
- reply, result, filenames);
- Send(reply);
-}
-
-#endif
-
void RenderMessageFilter::OnCheckNotificationPermission(
const GURL& source_url, int* result) {
*result = WebKit::WebNotificationPresenter::PermissionNotAllowed;
@@ -1049,15 +889,6 @@ void RenderMessageFilter::OnResolveProxyCompleted(
Send(reply_msg);
}
-// static
-ui::Clipboard* RenderMessageFilter::GetClipboard() {
- // We have a static instance of the clipboard service for use by all message
- // filters. This instance lives for the life of the browser processes.
- static ui::Clipboard* clipboard = new ui::Clipboard;
-
- return clipboard;
-}
-
ChromeURLRequestContext* RenderMessageFilter::GetRequestContextForURL(
const GURL& url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h
index e2aaa07..2cb4547 100644
--- a/content/browser/renderer_host/render_message_filter.h
+++ b/content/browser/renderer_host/render_message_filter.h
@@ -16,6 +16,7 @@
#include "app/surface/transport_dib.h"
#include "base/file_path.h"
#include "base/linked_ptr.h"
+#include "base/shared_memory.h"
#include "base/string16.h"
#include "base/task.h"
#include "build/build_config.h"
@@ -26,7 +27,6 @@
#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h"
-#include "ui/base/clipboard/clipboard.h"
#include "ui/gfx/native_widget_types.h"
class ChromeURLRequestContext;
@@ -175,27 +175,6 @@ class RenderMessageFilter : public BrowserMessageFilter,
void OnRendererTcmalloc(base::ProcessId pid, const std::string& output);
#endif
void OnReceiveContextMenuMsg(const IPC::Message& msg);
- // Clipboard messages
- void OnClipboardWriteObjectsAsync(const ui::Clipboard::ObjectMap& objects);
- void OnClipboardWriteObjectsSync(const ui::Clipboard::ObjectMap& objects,
- base::SharedMemoryHandle bitmap_handle);
-
- void OnClipboardIsFormatAvailable(ui::Clipboard::FormatType format,
- ui::Clipboard::Buffer buffer,
- IPC::Message* reply);
- void OnClipboardReadText(ui::Clipboard::Buffer buffer, IPC::Message* reply);
- void OnClipboardReadAsciiText(ui::Clipboard::Buffer buffer,
- IPC::Message* reply);
- void OnClipboardReadHTML(ui::Clipboard::Buffer buffer, IPC::Message* reply);
-#if defined(OS_MACOSX)
- void OnClipboardFindPboardWriteString(const string16& text);
-#endif
- void OnClipboardReadAvailableTypes(ui::Clipboard::Buffer buffer,
- IPC::Message* reply);
- void OnClipboardReadData(ui::Clipboard::Buffer buffer, const string16& type,
- IPC::Message* reply);
- void OnClipboardReadFilenames(ui::Clipboard::Buffer buffer,
- IPC::Message* reply);
void OnCheckNotificationPermission(const GURL& source_url,
int* permission_level);
@@ -300,32 +279,11 @@ class RenderMessageFilter : public BrowserMessageFilter,
void DoOnGetScreenInfo(gfx::NativeViewId view, IPC::Message* reply_msg);
void DoOnGetWindowRect(gfx::NativeViewId view, IPC::Message* reply_msg);
void DoOnGetRootWindowRect(gfx::NativeViewId view, IPC::Message* reply_msg);
- void DoOnClipboardIsFormatAvailable(ui::Clipboard::FormatType format,
- ui::Clipboard::Buffer buffer,
- IPC::Message* reply_msg);
- void DoOnClipboardReadText(ui::Clipboard::Buffer buffer,
- IPC::Message* reply_msg);
- void DoOnClipboardReadAsciiText(ui::Clipboard::Buffer buffer,
- IPC::Message* reply_msg);
- void DoOnClipboardReadHTML(ui::Clipboard::Buffer buffer,
- IPC::Message* reply_msg);
- void DoOnClipboardReadAvailableTypes(ui::Clipboard::Buffer buffer,
- IPC::Message* reply_msg);
- void DoOnClipboardReadData(ui::Clipboard::Buffer buffer, const string16& type,
- IPC::Message* reply_msg);
- void DoOnClipboardReadFilenames(ui::Clipboard::Buffer buffer,
- IPC::Message* reply_msg);
#endif
bool CheckBenchmarkingEnabled() const;
bool CheckPreparsedJsCachingEnabled() const;
- // We have our own clipboard because we want to access the clipboard on the
- // IO thread instead of forwarding (possibly synchronous) messages to the UI
- // thread. This instance of the clipboard should be accessed only on the IO
- // thread.
- static ui::Clipboard* GetClipboard();
-
// Cached resource request dispatcher host and plugin service, guaranteed to
// be non-null if Init succeeds. We do not own the objects, they are managed
// by the BrowserProcess, which has a wider scope than we do.
diff --git a/content/browser/renderer_host/render_message_filter_gtk.cc b/content/browser/renderer_host/render_message_filter_gtk.cc
index 4a46691..9deac18 100644
--- a/content/browser/renderer_host/render_message_filter_gtk.cc
+++ b/content/browser/renderer_host/render_message_filter_gtk.cc
@@ -89,66 +89,6 @@ void RenderMessageFilter::DoOnGetRootWindowRect(gfx::NativeViewId view,
Send(reply_msg);
}
-void RenderMessageFilter::DoOnClipboardIsFormatAvailable(
- ui::Clipboard::FormatType format, ui::Clipboard::Buffer buffer,
- IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- const bool result = GetClipboard()->IsFormatAvailable(format, buffer);
-
- ViewHostMsg_ClipboardIsFormatAvailable::WriteReplyParams(reply_msg, result);
- Send(reply_msg);
-}
-
-void RenderMessageFilter::DoOnClipboardReadText(ui::Clipboard::Buffer buffer,
- IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- string16 result;
- GetClipboard()->ReadText(buffer, &result);
-
- ViewHostMsg_ClipboardReadText::WriteReplyParams(reply_msg, result);
- Send(reply_msg);
-}
-
-void RenderMessageFilter::DoOnClipboardReadAsciiText(
- ui::Clipboard::Buffer buffer, IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- std::string result;
- GetClipboard()->ReadAsciiText(buffer, &result);
-
- ViewHostMsg_ClipboardReadAsciiText::WriteReplyParams(reply_msg, result);
- Send(reply_msg);
-}
-
-void RenderMessageFilter::DoOnClipboardReadHTML(ui::Clipboard::Buffer buffer,
- IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- std::string src_url_str;
- string16 markup;
- GetClipboard()->ReadHTML(buffer, &markup, &src_url_str);
- const GURL src_url = GURL(src_url_str);
-
- ViewHostMsg_ClipboardReadHTML::WriteReplyParams(reply_msg, markup, src_url);
- Send(reply_msg);
-}
-
-void RenderMessageFilter::DoOnClipboardReadAvailableTypes(
- ui::Clipboard::Buffer buffer, IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- Send(reply_msg);
-}
-
-void RenderMessageFilter::DoOnClipboardReadData(ui::Clipboard::Buffer buffer,
- const string16& type,
- IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- Send(reply_msg);
-}
-void RenderMessageFilter::DoOnClipboardReadFilenames(
- ui::Clipboard::Buffer buffer, IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- Send(reply_msg);
-}
-
void RenderMessageFilter::OnGetScreenInfo(gfx::NativeViewId view,
IPC::Message* reply_msg) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
@@ -176,74 +116,3 @@ void RenderMessageFilter::OnGetRootWindowRect(gfx::NativeViewId view,
this, &RenderMessageFilter::DoOnGetRootWindowRect, view, reply_msg));
}
-void RenderMessageFilter::OnClipboardIsFormatAvailable(
- ui::Clipboard::FormatType format, ui::Clipboard::Buffer buffer,
- IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(
- this, &RenderMessageFilter::DoOnClipboardIsFormatAvailable, format,
- buffer, reply_msg));
-}
-
-void RenderMessageFilter::OnClipboardReadText(ui::Clipboard::Buffer buffer,
- IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(
- this, &RenderMessageFilter::DoOnClipboardReadText, buffer,
- reply_msg));
-}
-
-void RenderMessageFilter::OnClipboardReadAsciiText(ui::Clipboard::Buffer buffer,
- IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(
- this, &RenderMessageFilter::DoOnClipboardReadAsciiText, buffer,
- reply_msg));
-}
-
-void RenderMessageFilter::OnClipboardReadHTML(ui::Clipboard::Buffer buffer,
- IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(
- this, &RenderMessageFilter::DoOnClipboardReadHTML, buffer,
- reply_msg));
-}
-
-void RenderMessageFilter::OnClipboardReadAvailableTypes(
- ui::Clipboard::Buffer buffer, IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(
- this, &RenderMessageFilter::DoOnClipboardReadAvailableTypes, buffer,
- reply_msg));
-}
-
-void RenderMessageFilter::OnClipboardReadData(ui::Clipboard::Buffer buffer,
- const string16& type,
- IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(
- this, &RenderMessageFilter::DoOnClipboardReadData, buffer, type,
- reply_msg));
-}
-
-void RenderMessageFilter::OnClipboardReadFilenames(
- ui::Clipboard::Buffer buffer, IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(
- this, &RenderMessageFilter::DoOnClipboardReadFilenames, buffer,
- reply_msg));
-}
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index f1bbae9..133bea4 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -195,6 +195,9 @@
'browser/renderer_host/blob_message_filter.h',
'browser/renderer_host/buffered_resource_handler.cc',
'browser/renderer_host/buffered_resource_handler.h',
+ 'browser/renderer_host/clipboard_message_filter.cc',
+ 'browser/renderer_host/clipboard_message_filter.h',
+ 'browser/renderer_host/clipboard_message_filter_mac.mm',
'browser/renderer_host/cross_site_resource_handler.cc',
'browser/renderer_host/cross_site_resource_handler.h',
'browser/renderer_host/database_message_filter.cc',
@@ -221,7 +224,6 @@
'browser/renderer_host/render_message_filter.cc',
'browser/renderer_host/render_message_filter.h',
'browser/renderer_host/render_message_filter_gtk.cc',
- 'browser/renderer_host/render_message_filter_mac.mm',
'browser/renderer_host/render_message_filter_win.cc',
'browser/renderer_host/render_process_host.cc',
'browser/renderer_host/render_process_host.h',
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h
index eadfb03..7272302 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -74,6 +74,7 @@ enum IPCMessageStart {
ResourceMsgStart,
FileSystemMsgStart,
ChildProcessMsgStart,
+ ClipboardMsgStart,
};
class DictionaryValue;