diff options
Diffstat (limited to 'webkit/glue')
-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 |
3 files changed, 60 insertions, 2 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. |