summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/clipboard/clipboard.h7
-rw-r--r--chrome/browser/clipboard_dispatcher.h41
-rw-r--r--chrome/browser/clipboard_dispatcher_gtk.cc33
-rw-r--r--chrome/browser/clipboard_dispatcher_mac.mm33
-rw-r--r--chrome/browser/clipboard_dispatcher_win.cc33
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc37
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h11
-rw-r--r--chrome/browser/renderer_host/resource_message_filter_gtk.cc75
-rw-r--r--chrome/chrome_browser.gypi4
-rw-r--r--chrome/common/render_messages.h3
-rw-r--r--chrome/common/render_messages_internal.h16
-rw-r--r--chrome/renderer/renderer_glue.cc25
-rw-r--r--webkit/glue/webclipboard_impl.cc39
-rw-r--r--webkit/glue/webclipboard_impl.h7
-rw-r--r--webkit/glue/webkit_glue.h16
-rw-r--r--webkit/tools/test_shell/mock_webclipboard_impl.cc4
-rw-r--r--webkit/tools/test_shell/mock_webclipboard_impl.h3
-rw-r--r--webkit/tools/test_shell/simple_clipboard_impl.cc17
18 files changed, 384 insertions, 20 deletions
diff --git a/app/clipboard/clipboard.h b/app/clipboard/clipboard.h
index b149d8d..0c0e5b7 100644
--- a/app/clipboard/clipboard.h
+++ b/app/clipboard/clipboard.h
@@ -79,9 +79,8 @@ class Clipboard {
// functions accept a buffer parameter.
enum Buffer {
BUFFER_STANDARD,
-#if defined(USE_X11)
BUFFER_SELECTION,
-#endif
+ BUFFER_DRAG,
};
static bool IsValidBuffer(int32 buffer) {
@@ -92,6 +91,8 @@ class Clipboard {
case BUFFER_SELECTION:
return true;
#endif
+ case BUFFER_DRAG:
+ return true;
}
return false;
}
@@ -150,6 +151,8 @@ class Clipboard {
// Reads raw data from the clipboard with the given format type. Stores result
// as a byte vector.
+ // TODO(dcheng): Due to platform limitations on Windows, we should make sure
+ // format is never controlled by the user.
void ReadData(const std::string& format, std::string* result);
// Get format Identifiers for various types.
diff --git a/chrome/browser/clipboard_dispatcher.h b/chrome/browser/clipboard_dispatcher.h
new file mode 100644
index 0000000..e346799
--- /dev/null
+++ b/chrome/browser/clipboard_dispatcher.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2010 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 CHROME_BROWSER_CLIPBOARD_DISPATCHER_H_
+#define CHROME_BROWSER_CLIPBOARD_DISPATCHER_H_
+
+#include <vector>
+
+#include "app/clipboard/clipboard.h"
+#include "base/basictypes.h"
+#include "base/string16.h"
+
+// This class backs IPC requests from the renderer for clipboard data. In this
+// context, clipboard does not only refer to the usual concept of a clipboard
+// for copy/paste, which is why it's not in app/clipboard/clipboard.h. It can
+// refer to one of three different types of clipboards:
+// - The copy/paste clipboard, which contains data that has been copied/cut.
+// - The dragging clipboard, which contains data that is currently being
+// dragged.
+// - On X, the selection clipboard, which contains data for the current
+// selection.
+class ClipboardDispatcher {
+ public:
+ static bool ReadAvailableTypes(Clipboard::Buffer buffer,
+ std::vector<string16>* types,
+ bool* contains_filenames);
+ static bool ReadData(Clipboard::Buffer buffer, const string16& type,
+ string16* data, string16* metadata);
+ static bool ReadFilenames(Clipboard::Buffer buffer,
+ std::vector<string16>* filenames);
+
+ private:
+ // This class is not meant to be instantiated. All public members are static.
+ ClipboardDispatcher();
+
+ DISALLOW_COPY_AND_ASSIGN(ClipboardDispatcher);
+};
+
+#endif // CHROME_BROWSER_CLIPBOARD_DISPATCHER_H_
+
diff --git a/chrome/browser/clipboard_dispatcher_gtk.cc b/chrome/browser/clipboard_dispatcher_gtk.cc
new file mode 100644
index 0000000..7fe0c3b
--- /dev/null
+++ b/chrome/browser/clipboard_dispatcher_gtk.cc
@@ -0,0 +1,33 @@
+// Copyright (c) 2010 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 "chrome/browser/clipboard_dispatcher.h"
+#include "base/logging.h"
+
+bool ClipboardDispatcher::ReadAvailableTypes(Clipboard::Buffer buffer,
+ std::vector<string16>* types,
+ bool* contains_filenames) {
+ DCHECK(types);
+ DCHECK(contains_filenames);
+ types->clear();
+ *contains_filenames = false;
+ return false;
+}
+
+bool ClipboardDispatcher::ReadData(Clipboard::Buffer buffer,
+ const string16& type,
+ string16* data,
+ string16* metadata) {
+ DCHECK(data);
+ DCHECK(metadata);
+ return false;
+}
+
+bool ClipboardDispatcher::ReadFilenames(Clipboard::Buffer buffer,
+ std::vector<string16>* filenames) {
+ DCHECK(filenames);
+ filenames->clear();
+ return false;
+}
+
diff --git a/chrome/browser/clipboard_dispatcher_mac.mm b/chrome/browser/clipboard_dispatcher_mac.mm
new file mode 100644
index 0000000..7fe0c3b
--- /dev/null
+++ b/chrome/browser/clipboard_dispatcher_mac.mm
@@ -0,0 +1,33 @@
+// Copyright (c) 2010 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 "chrome/browser/clipboard_dispatcher.h"
+#include "base/logging.h"
+
+bool ClipboardDispatcher::ReadAvailableTypes(Clipboard::Buffer buffer,
+ std::vector<string16>* types,
+ bool* contains_filenames) {
+ DCHECK(types);
+ DCHECK(contains_filenames);
+ types->clear();
+ *contains_filenames = false;
+ return false;
+}
+
+bool ClipboardDispatcher::ReadData(Clipboard::Buffer buffer,
+ const string16& type,
+ string16* data,
+ string16* metadata) {
+ DCHECK(data);
+ DCHECK(metadata);
+ return false;
+}
+
+bool ClipboardDispatcher::ReadFilenames(Clipboard::Buffer buffer,
+ std::vector<string16>* filenames) {
+ DCHECK(filenames);
+ filenames->clear();
+ return false;
+}
+
diff --git a/chrome/browser/clipboard_dispatcher_win.cc b/chrome/browser/clipboard_dispatcher_win.cc
new file mode 100644
index 0000000..7fe0c3b
--- /dev/null
+++ b/chrome/browser/clipboard_dispatcher_win.cc
@@ -0,0 +1,33 @@
+// Copyright (c) 2010 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 "chrome/browser/clipboard_dispatcher.h"
+#include "base/logging.h"
+
+bool ClipboardDispatcher::ReadAvailableTypes(Clipboard::Buffer buffer,
+ std::vector<string16>* types,
+ bool* contains_filenames) {
+ DCHECK(types);
+ DCHECK(contains_filenames);
+ types->clear();
+ *contains_filenames = false;
+ return false;
+}
+
+bool ClipboardDispatcher::ReadData(Clipboard::Buffer buffer,
+ const string16& type,
+ string16* data,
+ string16* metadata) {
+ DCHECK(data);
+ DCHECK(metadata);
+ return false;
+}
+
+bool ClipboardDispatcher::ReadFilenames(Clipboard::Buffer buffer,
+ std::vector<string16>* filenames) {
+ DCHECK(filenames);
+ filenames->clear();
+ return false;
+}
+
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 80e3de8..d303394 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/child_process_security_policy.h"
#include "chrome/browser/chrome_plugin_browsing_context.h"
#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/clipboard_dispatcher.h"
#include "chrome/browser/download/download_file.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/geolocation/geolocation_permission_context.h"
@@ -521,6 +522,12 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) {
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_GetMimeTypeFromExtension,
@@ -994,6 +1001,36 @@ void ResourceMessageFilter::OnClipboardReadHTML(Clipboard::Buffer buffer,
Send(reply);
}
+void ResourceMessageFilter::OnClipboardReadAvailableTypes(
+ 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 ResourceMessageFilter::OnClipboardReadData(
+ 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 ResourceMessageFilter::OnClipboardReadFilenames(
+ 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 ResourceMessageFilter::OnCheckNotificationPermission(
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 7b73450..d0c299d 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -220,6 +220,11 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
#if defined(OS_MACOSX)
void OnClipboardFindPboardWriteString(const string16& text);
#endif
+ void OnClipboardReadAvailableTypes(Clipboard::Buffer buffer,
+ IPC::Message* reply);
+ void OnClipboardReadData(Clipboard::Buffer buffer, const string16& type,
+ IPC::Message* reply);
+ void OnClipboardReadFilenames(Clipboard::Buffer buffer, IPC::Message* reply);
void OnCheckNotificationPermission(const GURL& source_url,
int* permission_level);
@@ -352,6 +357,12 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
void DoOnClipboardReadAsciiText(Clipboard::Buffer buffer,
IPC::Message* reply_msg);
void DoOnClipboardReadHTML(Clipboard::Buffer buffer, IPC::Message* reply_msg);
+ void DoOnClipboardReadAvailableTypes(Clipboard::Buffer buffer,
+ IPC::Message* reply_msg);
+ void DoOnClipboardReadData(Clipboard::Buffer buffer, const string16& type,
+ IPC::Message* reply_msg);
+ void DoOnClipboardReadFilenames(Clipboard::Buffer buffer,
+ IPC::Message* reply_msg);
void DoOnAllocateTempFileForPrinting(IPC::Message* reply_msg);
#endif
diff --git a/chrome/browser/renderer_host/resource_message_filter_gtk.cc b/chrome/browser/renderer_host/resource_message_filter_gtk.cc
index 97e1c14..dcd3d19 100644
--- a/chrome/browser/renderer_host/resource_message_filter_gtk.cc
+++ b/chrome/browser/renderer_host/resource_message_filter_gtk.cc
@@ -82,7 +82,7 @@ void ResourceMessageFilter::DoOnGetWindowRect(gfx::NativeViewId view,
ViewHostMsg_GetWindowRect::WriteReplyParams(reply_msg, rect);
- ChromeThread::PostTask(
+ ChromeThread::PostTask(
ChromeThread::IO, FROM_HERE,
NewRunnableMethod(
this, &ResourceMessageFilter::SendDelayedReply, reply_msg));
@@ -125,7 +125,7 @@ void ResourceMessageFilter::DoOnGetRootWindowRect(gfx::NativeViewId view,
ViewHostMsg_GetRootWindowRect::WriteReplyParams(reply_msg, rect);
- ChromeThread::PostTask(
+ ChromeThread::PostTask(
ChromeThread::IO, FROM_HERE,
NewRunnableMethod(
this, &ResourceMessageFilter::SendDelayedReply, reply_msg));
@@ -139,7 +139,7 @@ void ResourceMessageFilter::DoOnClipboardIsFormatAvailable(
ViewHostMsg_ClipboardIsFormatAvailable::WriteReplyParams(reply_msg, result);
- ChromeThread::PostTask(
+ ChromeThread::PostTask(
ChromeThread::IO, FROM_HERE,
NewRunnableMethod(
this, &ResourceMessageFilter::SendDelayedReply, reply_msg));
@@ -153,7 +153,7 @@ void ResourceMessageFilter::DoOnClipboardReadText(Clipboard::Buffer buffer,
ViewHostMsg_ClipboardReadText::WriteReplyParams(reply_msg, result);
- ChromeThread::PostTask(
+ ChromeThread::PostTask(
ChromeThread::IO, FROM_HERE,
NewRunnableMethod(
this, &ResourceMessageFilter::SendDelayedReply, reply_msg));
@@ -167,7 +167,7 @@ void ResourceMessageFilter::DoOnClipboardReadAsciiText(
ViewHostMsg_ClipboardReadAsciiText::WriteReplyParams(reply_msg, result);
- ChromeThread::PostTask(
+ ChromeThread::PostTask(
ChromeThread::IO, FROM_HERE,
NewRunnableMethod(
this, &ResourceMessageFilter::SendDelayedReply, reply_msg));
@@ -183,7 +183,34 @@ void ResourceMessageFilter::DoOnClipboardReadHTML(Clipboard::Buffer buffer,
ViewHostMsg_ClipboardReadHTML::WriteReplyParams(reply_msg, markup, src_url);
- ChromeThread::PostTask(
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &ResourceMessageFilter::SendDelayedReply, reply_msg));
+}
+
+// Called on the UI thread.
+void ResourceMessageFilter::DoOnClipboardReadAvailableTypes(
+ Clipboard::Buffer buffer, IPC::Message* reply_msg) {
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &ResourceMessageFilter::SendDelayedReply, reply_msg));
+}
+
+// Called on the UI thread.
+void ResourceMessageFilter::DoOnClipboardReadData(Clipboard::Buffer buffer,
+ const string16& type,
+ IPC::Message* reply_msg) {
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ this, &ResourceMessageFilter::SendDelayedReply, reply_msg));
+}
+// Called on the UI thread.
+void ResourceMessageFilter::DoOnClipboardReadFilenames(
+ Clipboard::Buffer buffer, IPC::Message* reply_msg) {
+ ChromeThread::PostTask(
ChromeThread::IO, FROM_HERE,
NewRunnableMethod(
this, &ResourceMessageFilter::SendDelayedReply, reply_msg));
@@ -223,7 +250,7 @@ void ResourceMessageFilter::DoOnAllocateTempFileForPrinting(
ViewHostMsg_AllocateTempFileForPrinting::WriteReplyParams(
reply_msg, temp_file_fd, fd_in_browser);
- ChromeThread::PostTask(
+ ChromeThread::PostTask(
ChromeThread::IO, FROM_HERE,
NewRunnableMethod(
this, &ResourceMessageFilter::SendDelayedReply, reply_msg));
@@ -241,7 +268,7 @@ void ResourceMessageFilter::OnGetScreenInfo(gfx::NativeViewId view,
// Called on the IO thread.
void ResourceMessageFilter::OnGetWindowRect(gfx::NativeViewId view,
IPC::Message* reply_msg) {
- ChromeThread::PostTask(
+ ChromeThread::PostTask(
ChromeThread::BACKGROUND_X11, FROM_HERE,
NewRunnableMethod(
this, &ResourceMessageFilter::DoOnGetWindowRect, view, reply_msg));
@@ -250,7 +277,7 @@ void ResourceMessageFilter::OnGetWindowRect(gfx::NativeViewId view,
// Called on the IO thread.
void ResourceMessageFilter::OnGetRootWindowRect(gfx::NativeViewId view,
IPC::Message* reply_msg) {
- ChromeThread::PostTask(
+ ChromeThread::PostTask(
ChromeThread::BACKGROUND_X11, FROM_HERE,
NewRunnableMethod(
this, &ResourceMessageFilter::DoOnGetRootWindowRect, view,
@@ -299,6 +326,36 @@ void ResourceMessageFilter::OnClipboardReadHTML(Clipboard::Buffer buffer,
}
// Called on the IO thread.
+void ResourceMessageFilter::OnClipboardReadAvailableTypes(
+ Clipboard::Buffer buffer, IPC::Message* reply_msg) {
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &ResourceMessageFilter::DoOnClipboardReadAvailableTypes, buffer,
+ reply_msg));
+}
+
+// Called on the IO thread.
+void ResourceMessageFilter::OnClipboardReadData(
+ Clipboard::Buffer buffer, const string16& type, IPC::Message* reply_msg) {
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &ResourceMessageFilter::DoOnClipboardReadData, buffer, type,
+ reply_msg));
+}
+
+// Called on the IO thread.
+void ResourceMessageFilter::OnClipboardReadFilenames(
+ Clipboard::Buffer buffer, IPC::Message* reply_msg) {
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ this, &ResourceMessageFilter::DoOnClipboardReadFilenames, buffer,
+ reply_msg));
+}
+
+// Called on the IO thread.
void ResourceMessageFilter::OnAllocateTempFileForPrinting(
IPC::Message* reply_msg) {
ChromeThread::PostTask(
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 7ff5c45..d825f4e 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -576,6 +576,10 @@
'browser/chromeos/wm_overview_snapshot.h',
'browser/chromeos/wm_overview_title.cc',
'browser/chromeos/wm_overview_title.h',
+ 'browser/clipboard_dispatcher_gtk.cc',
+ 'browser/clipboard_dispatcher_mac.mm',
+ 'browser/clipboard_dispatcher_win.cc',
+ 'browser/clipboard_dispatcher.h',
'browser/cocoa/about_ipc_bridge.h',
'browser/cocoa/about_ipc_bridge.mm',
'browser/cocoa/about_ipc_controller.h',
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 050aae8..6ee03d1 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -2273,6 +2273,9 @@ struct ParamTraits<Clipboard::Buffer> {
type = L"BUFFER_SELECTION";
break;
#endif
+ case Clipboard::BUFFER_DRAG:
+ type = L"BUFFER_DRAG";
+ break;
default:
type = L"UNKNOWN";
break;
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 042b7c6..20d5900 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1429,6 +1429,22 @@ IPC_BEGIN_MESSAGES(ViewHost)
string16 /* markup */,
GURL /* url */)
+ IPC_SYNC_MESSAGE_CONTROL1_3(ViewHostMsg_ClipboardReadAvailableTypes,
+ Clipboard::Buffer /* buffer */,
+ bool /* result */,
+ std::vector<string16> /* types */,
+ bool /* contains filenames */)
+ IPC_SYNC_MESSAGE_CONTROL2_3(ViewHostMsg_ClipboardReadData,
+ Clipboard::Buffer /* buffer */,
+ string16 /* type */,
+ bool /* succeeded */,
+ string16 /* data */,
+ string16 /* metadata */)
+ IPC_SYNC_MESSAGE_CONTROL1_2(ViewHostMsg_ClipboardReadFilenames,
+ Clipboard::Buffer /* buffer */,
+ bool /* result */,
+ std::vector<string16> /* filenames */)
+
#if defined(OS_MACOSX)
IPC_MESSAGE_CONTROL1(ViewHostMsg_ClipboardFindPboardWriteStringAsync,
string16 /* text */)
diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc
index 72a7629..d740c6e 100644
--- a/chrome/renderer/renderer_glue.cc
+++ b/chrome/renderer/renderer_glue.cc
@@ -221,6 +221,31 @@ void ClipboardReadHTML(Clipboard::Buffer buffer, string16* markup, GURL* url) {
markup, url));
}
+bool ClipboardReadAvailableTypes(Clipboard::Buffer buffer,
+ std::vector<string16>* types,
+ bool* contains_filenames) {
+ bool result = false;
+ RenderThread::current()->Send(new ViewHostMsg_ClipboardReadAvailableTypes(
+ buffer, &result, types, contains_filenames));
+ return result;
+}
+
+bool ClipboardReadData(Clipboard::Buffer buffer, const string16& type,
+ string16* data, string16* metadata) {
+ bool result = false;
+ RenderThread::current()->Send(new ViewHostMsg_ClipboardReadData(
+ buffer, type, &result, data, metadata));
+ return result;
+}
+
+bool ClipboardReadFilenames(Clipboard::Buffer buffer,
+ std::vector<string16>* filenames) {
+ bool result;
+ RenderThread::current()->Send(new ViewHostMsg_ClipboardReadFilenames(
+ buffer, &result, filenames));
+ return result;
+}
+
void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) {
if (!RenderThread::current()->plugin_refresh_allowed())
refresh = false;
diff --git a/webkit/glue/webclipboard_impl.cc b/webkit/glue/webclipboard_impl.cc
index 2c955e6..11bc96d 100644
--- a/webkit/glue/webclipboard_impl.cc
+++ b/webkit/glue/webclipboard_impl.cc
@@ -15,6 +15,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebSize.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebVector.h"
#include "webkit/glue/scoped_clipboard_writer_glue.h"
#include "webkit/glue/webkit_glue.h"
@@ -26,6 +27,7 @@ using WebKit::WebClipboard;
using WebKit::WebImage;
using WebKit::WebString;
using WebKit::WebURL;
+using WebKit::WebVector;
namespace webkit_glue {
@@ -171,12 +173,49 @@ void WebClipboardImpl::writeData(const WebKit::WebDragData& data) {
// TODO(dcheng): Implement this stub.
}
+WebVector<WebString> WebClipboardImpl::readAvailableTypes(
+ Buffer buffer, bool* contains_filenames) {
+ Clipboard::Buffer buffer_type;
+ std::vector<string16> types;
+ if (ConvertBufferType(buffer, &buffer_type)) {
+ ClipboardReadAvailableTypes(buffer_type, &types, contains_filenames);
+ }
+ return types;
+}
+
+bool WebClipboardImpl::readData(Buffer buffer, const WebString& type,
+ WebString* data, WebString* metadata) {
+ Clipboard::Buffer buffer_type;
+ if (!ConvertBufferType(buffer, &buffer_type))
+ return false;
+
+ string16 data_out;
+ string16 metadata_out;
+ bool result = ClipboardReadData(buffer_type, type, &data_out, &metadata_out);
+ if (result) {
+ *data = data_out;
+ *metadata = metadata_out;
+ }
+ return result;
+}
+
+WebVector<WebString> WebClipboardImpl::readFilenames(Buffer buffer) {
+ Clipboard::Buffer buffer_type;
+ std::vector<string16> filenames;
+ if (ConvertBufferType(buffer, &buffer_type)) {
+ ClipboardReadFilenames(buffer_type, &filenames);
+ }
+ return filenames;
+}
+
bool WebClipboardImpl::ConvertBufferType(Buffer buffer,
Clipboard::Buffer* result) {
switch (buffer) {
case BufferStandard:
*result = Clipboard::BUFFER_STANDARD;
break;
+ case BufferDrag:
+ *result = Clipboard::BUFFER_DRAG;
case BufferSelection:
#if defined(USE_X11)
*result = Clipboard::BUFFER_SELECTION;
diff --git a/webkit/glue/webclipboard_impl.h b/webkit/glue/webclipboard_impl.h
index 7eda08f..92c4a5e 100644
--- a/webkit/glue/webclipboard_impl.h
+++ b/webkit/glue/webclipboard_impl.h
@@ -7,7 +7,6 @@
#include "app/clipboard/clipboard.h"
#include "third_party/WebKit/WebKit/chromium/public/WebClipboard.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebDragData.h"
#include <string>
@@ -41,6 +40,12 @@ class WebClipboardImpl : public WebKit::WebClipboard {
const WebKit::WebString& title);
virtual void writeData(const WebKit::WebDragData&);
+ virtual WebKit::WebVector<WebKit::WebString> readAvailableTypes(
+ Buffer, bool* contains_filenames);
+ virtual bool readData(Buffer, const WebKit::WebString& type,
+ WebKit::WebString* data, WebKit::WebString* metadata);
+ virtual WebKit::WebVector<WebKit::WebString> readFilenames(Buffer);
+
private:
bool ConvertBufferType(Buffer, Clipboard::Buffer*);
};
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index 110d15a..d24e1512 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -76,7 +76,8 @@ int NumberOfPages(WebKit::WebFrame* web_frame,
float page_height_in_pixels);
// Returns a dump of the scroll position of the webframe.
-std::wstring DumpFrameScrollPosition(WebKit::WebFrame* web_frame, bool recursive);
+std::wstring DumpFrameScrollPosition(WebKit::WebFrame* web_frame,
+ bool recursive);
// Returns a dump of the given history state suitable for implementing the
// dumpBackForwardList command of the layoutTestController.
@@ -194,6 +195,19 @@ void ClipboardReadAsciiText(Clipboard::Buffer buffer, std::string* result);
// Reads HTML from the clipboard, if available.
void ClipboardReadHTML(Clipboard::Buffer buffer, string16* markup, GURL* url);
+// Reads the available types from the clipboard, if available.
+bool ClipboardReadAvailableTypes(Clipboard::Buffer buffer,
+ std::vector<string16>* types,
+ bool* contains_filenames);
+
+// Reads one type of data from the clipboard, if available.
+bool ClipboardReadData(Clipboard::Buffer buffer, const string16& type,
+ string16* data, string16* metadata);
+
+// Reads filenames from the clipboard, if available.
+bool ClipboardReadFilenames(Clipboard::Buffer buffer,
+ std::vector<string16>* filenames);
+
// Gets the directory where the application data and libraries exist. This
// may be a versioned subdirectory, or it may be the same directory as the
// GetExeDirectory(), depending on the embedder's implementation.
diff --git a/webkit/tools/test_shell/mock_webclipboard_impl.cc b/webkit/tools/test_shell/mock_webclipboard_impl.cc
index 7a6fc24..0693b07 100644
--- a/webkit/tools/test_shell/mock_webclipboard_impl.cc
+++ b/webkit/tools/test_shell/mock_webclipboard_impl.cc
@@ -87,7 +87,3 @@ void MockWebClipboardImpl::writeImage(const WebKit::WebImage& image,
}
}
-void MockWebClipboardImpl::writeData(const WebKit::WebDragData& data) {
- // TODO(dcheng): Implement this stub.
-}
-
diff --git a/webkit/tools/test_shell/mock_webclipboard_impl.h b/webkit/tools/test_shell/mock_webclipboard_impl.h
index 8feac76..57d7e17 100644
--- a/webkit/tools/test_shell/mock_webclipboard_impl.h
+++ b/webkit/tools/test_shell/mock_webclipboard_impl.h
@@ -11,8 +11,6 @@
#define WEBKIT_TOOLS_TEST_SHELL_MOCK_WEBCLIPBOARD_IMPL_H_
#include "third_party/WebKit/WebKit/chromium/public/WebClipboard.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebDragData.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
class MockWebClipboardImpl : public WebKit::WebClipboard {
public:
@@ -32,7 +30,6 @@ class MockWebClipboardImpl : public WebKit::WebClipboard {
virtual void writeImage(
const WebKit::WebImage&, const WebKit::WebURL&,
const WebKit::WebString& title);
- virtual void writeData(const WebKit::WebDragData&);
private:
WebKit::WebString m_plainText;
diff --git a/webkit/tools/test_shell/simple_clipboard_impl.cc b/webkit/tools/test_shell/simple_clipboard_impl.cc
index 9a8fae0..95a33eb 100644
--- a/webkit/tools/test_shell/simple_clipboard_impl.cc
+++ b/webkit/tools/test_shell/simple_clipboard_impl.cc
@@ -51,4 +51,21 @@ void ClipboardReadHTML(Clipboard::Buffer buffer, string16* markup, GURL* url) {
*url = GURL(url_str);
}
+// TODO(dcheng): Implement.
+bool ClipboardReadAvailableTypes(Clipboard::Buffer buffer,
+ std::vector<string16>* types,
+ bool* contains_filenames) {
+ return false;
+}
+
+bool ClipboardReadData(Clipboard::Buffer buffer, const string16& type,
+ string16* data, string16* metadata) {
+ return false;
+}
+
+bool ClipboardReadFilenames(Clipboard::Buffer buffer,
+ std::vector<string16>* filenames) {
+ return false;
+}
+
} // namespace webkit_glue