diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-07 22:43:41 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-07 22:43:41 +0000 |
commit | 97c2c0304fcda75890b4490ca5e6d569db30ca6d (patch) | |
tree | 083da18448d0479ffd8ec09ba530475309bb1fac /webkit | |
parent | 156c84585048ca444173b55097392e43c199a56c (diff) | |
download | chromium_src-97c2c0304fcda75890b4490ca5e6d569db30ca6d.zip chromium_src-97c2c0304fcda75890b4490ca5e6d569db30ca6d.tar.gz chromium_src-97c2c0304fcda75890b4490ca5e6d569db30ca6d.tar.bz2 |
Implement new Chromium IPCs for copying/dragging.
A new ClipboardDispatcher interface has been added to handle the IPC calls. The new methods don't really belong on the existing Clipboard class, since that class deals with only copy and paste. On Windows and Mac, ClipboardDispatcher will share logic for copy/paste and drag/drop. GTK will have to use two separate code paths.
BUG=31037
TEST=none
Review URL: http://codereview.chromium.org/2842016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51790 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/webclipboard_impl.cc | 39 | ||||
-rw-r--r-- | webkit/glue/webclipboard_impl.h | 7 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.h | 16 | ||||
-rw-r--r-- | webkit/tools/test_shell/mock_webclipboard_impl.cc | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/mock_webclipboard_impl.h | 3 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_clipboard_impl.cc | 17 |
6 files changed, 77 insertions, 9 deletions
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 |