diff options
-rw-r--r-- | chrome/common/clipboard_messages.h | 4 | ||||
-rw-r--r-- | chrome/renderer/renderer_glue.cc | 15 | ||||
-rw-r--r-- | content/browser/renderer_host/clipboard_message_filter.cc | 10 | ||||
-rw-r--r-- | content/browser/renderer_host/clipboard_message_filter.h | 1 | ||||
-rw-r--r-- | ui/base/clipboard/clipboard.h | 4 | ||||
-rw-r--r-- | ui/base/clipboard/clipboard_linux.cc | 9 | ||||
-rw-r--r-- | ui/base/clipboard/clipboard_mac.mm | 8 | ||||
-rw-r--r-- | ui/base/clipboard/clipboard_win.cc | 8 | ||||
-rw-r--r-- | webkit/glue/webclipboard_impl.cc | 12 | ||||
-rw-r--r-- | webkit/glue/webclipboard_impl.h | 1 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.h | 2 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_clipboard_impl.cc | 4 |
12 files changed, 70 insertions, 8 deletions
diff --git a/chrome/common/clipboard_messages.h b/chrome/common/clipboard_messages.h index 9bbce5b..7679c3f 100644 --- a/chrome/common/clipboard_messages.h +++ b/chrome/common/clipboard_messages.h @@ -7,7 +7,6 @@ #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" @@ -42,6 +41,9 @@ IPC_SYNC_MESSAGE_CONTROL1_2(ClipboardHostMsg_ReadHTML, ui::Clipboard::Buffer /* buffer */, string16 /* markup */, GURL /* url */) +IPC_SYNC_MESSAGE_CONTROL1_1(ClipboardHostMsg_ReadImage, + ui::Clipboard::Buffer /* buffer */, + std::string /* PNG-encoded image */) #if defined(OS_MACOSX) IPC_MESSAGE_CONTROL1(ClipboardHostMsg_FindPboardWriteStringAsync, string16 /* text */) diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index f61a011..4b31730 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -167,19 +167,22 @@ bool ClipboardIsFormatAvailable(const ui::Clipboard::FormatType& format, } void ClipboardReadText(ui::Clipboard::Buffer buffer, string16* result) { - RenderThread::current()->Send(new ClipboardHostMsg_ReadText(buffer, - result)); + RenderThread::current()->Send(new ClipboardHostMsg_ReadText(buffer, result)); } void ClipboardReadAsciiText(ui::Clipboard::Buffer buffer, std::string* result) { - RenderThread::current()->Send(new ClipboardHostMsg_ReadAsciiText(buffer, - result)); + RenderThread::current()->Send( + new ClipboardHostMsg_ReadAsciiText(buffer, result)); } void ClipboardReadHTML(ui::Clipboard::Buffer buffer, string16* markup, GURL* url) { - RenderThread::current()->Send(new ClipboardHostMsg_ReadHTML(buffer, - markup, url)); + RenderThread::current()->Send( + new ClipboardHostMsg_ReadHTML(buffer, markup, url)); +} + +void ClipboardReadImage(ui::Clipboard::Buffer buffer, std::string* data) { + RenderThread::current()->Send(new ClipboardHostMsg_ReadImage(buffer, data)); } bool ClipboardReadAvailableTypes(ui::Clipboard::Buffer buffer, diff --git a/content/browser/renderer_host/clipboard_message_filter.cc b/content/browser/renderer_host/clipboard_message_filter.cc index 8cb3b9d..ca71e5d 100644 --- a/content/browser/renderer_host/clipboard_message_filter.cc +++ b/content/browser/renderer_host/clipboard_message_filter.cc @@ -38,7 +38,9 @@ ClipboardMessageFilter::ClipboardMessageFilter() { void ClipboardMessageFilter::OverrideThreadForMessage( const IPC::Message& message, BrowserThread::ID* thread) { #if defined(USE_X11) - if (IPC_MESSAGE_CLASS(message) == ClipboardMsgStart) + if (message.type() == ClipboardHostMsg_ReadImage::ID) + *thread = BrowserThread::BACKGROUND_X11; + else if (IPC_MESSAGE_CLASS(message) == ClipboardMsgStart) *thread = BrowserThread::UI; #endif } @@ -53,6 +55,7 @@ bool ClipboardMessageFilter::OnMessageReceived(const IPC::Message& message, IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadText, OnReadText) IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadAsciiText, OnReadAsciiText) IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadHTML, OnReadHTML) + IPC_MESSAGE_HANDLER(ClipboardHostMsg_ReadImage, OnReadImage) #if defined(OS_MACOSX) IPC_MESSAGE_HANDLER(ClipboardHostMsg_FindPboardWriteStringAsync, OnFindPboardWriteString) @@ -132,6 +135,11 @@ void ClipboardMessageFilter::OnReadHTML( *url = GURL(src_url_str); } +void ClipboardMessageFilter::OnReadImage( + ui::Clipboard::Buffer buffer, std::string* data) { + GetClipboard()->ReadImage(buffer, data); +} + void ClipboardMessageFilter::OnReadAvailableTypes( ui::Clipboard::Buffer buffer, bool* succeeded, std::vector<string16>* types, bool* contains_filenames) { diff --git a/content/browser/renderer_host/clipboard_message_filter.h b/content/browser/renderer_host/clipboard_message_filter.h index f755d91..682e241e 100644 --- a/content/browser/renderer_host/clipboard_message_filter.h +++ b/content/browser/renderer_host/clipboard_message_filter.h @@ -35,6 +35,7 @@ class ClipboardMessageFilter : public BrowserMessageFilter { 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); + void OnReadImage(ui::Clipboard::Buffer buffer, std::string* data); #if defined(OS_MACOSX) void OnFindPboardWriteString(const string16& text); #endif diff --git a/ui/base/clipboard/clipboard.h b/ui/base/clipboard/clipboard.h index 715e6ea..bb3bc29 100644 --- a/ui/base/clipboard/clipboard.h +++ b/ui/base/clipboard/clipboard.h @@ -148,6 +148,10 @@ class Clipboard { // Reads HTML from the clipboard, if available. void ReadHTML(Buffer buffer, string16* markup, std::string* src_url) const; + // Reads an image from the clipboard, if available. The returned data will be + // encoded in PNG format. + void ReadImage(Buffer buffer, std::string* data) const; + // Reads a bookmark from the clipboard, if available. void ReadBookmark(string16* title, std::string* url) const; diff --git a/ui/base/clipboard/clipboard_linux.cc b/ui/base/clipboard/clipboard_linux.cc index f9ec174..3bb1e88 100644 --- a/ui/base/clipboard/clipboard_linux.cc +++ b/ui/base/clipboard/clipboard_linux.cc @@ -360,6 +360,15 @@ void Clipboard::ReadHTML(Clipboard::Buffer buffer, string16* markup, gtk_selection_data_free(data); } +void Clipboard::ReadImage(Buffer buffer, std::string* data) const { + // TODO(dcheng): implement this. + NOTIMPLEMENTED(); + if (!data) { + NOTREACHED(); + return; + } +} + void Clipboard::ReadBookmark(string16* title, std::string* url) const { // TODO(estade): implement this. NOTIMPLEMENTED(); diff --git a/ui/base/clipboard/clipboard_mac.mm b/ui/base/clipboard/clipboard_mac.mm index 89ad97d..2761eba 100644 --- a/ui/base/clipboard/clipboard_mac.mm +++ b/ui/base/clipboard/clipboard_mac.mm @@ -222,6 +222,14 @@ void Clipboard::ReadHTML(Clipboard::Buffer buffer, string16* markup, src_url->clear(); } +void Clipboard::ReadImage(Buffer buffer, std::string* data) const { + DCHECK_EQ(buffer, BUFFER_STANDARD); + if (!data) { + NOTREACHED(); + return; + } +} + void Clipboard::ReadBookmark(string16* title, std::string* url) const { NSPasteboard* pb = GetPasteboard(); diff --git a/ui/base/clipboard/clipboard_win.cc b/ui/base/clipboard/clipboard_win.cc index 88a1ff5..603779b 100644 --- a/ui/base/clipboard/clipboard_win.cc +++ b/ui/base/clipboard/clipboard_win.cc @@ -404,6 +404,14 @@ void Clipboard::ReadHTML(Clipboard::Buffer buffer, string16* markup, markup->assign(UTF8ToWide(markup_utf8)); } +void Clipboard::ReadImage(Buffer buffer, std::string* data) const { + DCHECK_EQ(buffer, BUFFER_STANDARD); + if (!data) { + NOTREACHED(); + return; + } +} + void Clipboard::ReadBookmark(string16* title, std::string* url) const { if (title) title->clear(); diff --git a/webkit/glue/webclipboard_impl.cc b/webkit/glue/webclipboard_impl.cc index b917677..9eddb68 100644 --- a/webkit/glue/webclipboard_impl.cc +++ b/webkit/glue/webclipboard_impl.cc @@ -10,6 +10,7 @@ #include "googleurl/src/gurl.h" #include "net/base/escape.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebImage.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" @@ -24,6 +25,7 @@ #endif using WebKit::WebClipboard; +using WebKit::WebData; using WebKit::WebImage; using WebKit::WebString; using WebKit::WebURL; @@ -124,6 +126,16 @@ WebString WebClipboardImpl::readHTML(Buffer buffer, WebURL* source_url) { return html_stdstr; } +WebData WebClipboardImpl::readImage(Buffer buffer) { + ui::Clipboard::Buffer buffer_type; + if (!ConvertBufferType(buffer, &buffer_type)) + return WebData(); + + std::string png_data; + ClipboardReadImage(buffer_type, &png_data); + return WebData(png_data); +} + void WebClipboardImpl::writeHTML( const WebString& html_text, const WebURL& source_url, const WebString& plain_text, bool write_smart_paste) { diff --git a/webkit/glue/webclipboard_impl.h b/webkit/glue/webclipboard_impl.h index ba3e747..c50f38d 100644 --- a/webkit/glue/webclipboard_impl.h +++ b/webkit/glue/webclipboard_impl.h @@ -25,6 +25,7 @@ class WebClipboardImpl : public WebKit::WebClipboard { virtual bool isFormatAvailable(Format, Buffer); virtual WebKit::WebString readPlainText(Buffer); virtual WebKit::WebString readHTML(Buffer, WebKit::WebURL* source_url); + virtual WebKit::WebData readImage(Buffer); virtual void writeHTML( const WebKit::WebString& html_text, const WebKit::WebURL& source_url, diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h index c1f45e6..68c3394 100644 --- a/webkit/glue/webkit_glue.h +++ b/webkit/glue/webkit_glue.h @@ -198,6 +198,8 @@ void ClipboardReadAsciiText(ui::Clipboard::Buffer buffer, std::string* result); void ClipboardReadHTML(ui::Clipboard::Buffer buffer, string16* markup, GURL* url); +void ClipboardReadImage(ui::Clipboard::Buffer buffer, std::string* data); + // Reads the available types from the clipboard, if available. bool ClipboardReadAvailableTypes(ui::Clipboard::Buffer buffer, std::vector<string16>* types, diff --git a/webkit/tools/test_shell/simple_clipboard_impl.cc b/webkit/tools/test_shell/simple_clipboard_impl.cc index ef290c7..cf7c43b 100644 --- a/webkit/tools/test_shell/simple_clipboard_impl.cc +++ b/webkit/tools/test_shell/simple_clipboard_impl.cc @@ -52,6 +52,10 @@ void ClipboardReadHTML(ui::Clipboard::Buffer buffer, string16* markup, *url = GURL(url_str); } +void ClipboardReadImage(ui::Clipboard::Buffer buffer, std::string* data) { + ClipboardGetClipboard()->ReadImage(buffer, data); +} + // TODO(dcheng): Implement. bool ClipboardReadAvailableTypes(ui::Clipboard::Buffer buffer, std::vector<string16>* types, |