summaryrefslogtreecommitdiffstats
path: root/webkit/tools
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-04 06:19:37 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-04 06:19:37 +0000
commitc6562f4b883b37a288205a206bdadf9a37978bf3 (patch)
tree1a576398bcb2cd32e972449068bc1b66324df84f /webkit/tools
parent5d2cded762eacf51f77021b3de61de430f50a9d8 (diff)
downloadchromium_src-c6562f4b883b37a288205a206bdadf9a37978bf3.zip
chromium_src-c6562f4b883b37a288205a206bdadf9a37978bf3.tar.gz
chromium_src-c6562f4b883b37a288205a206bdadf9a37978bf3.tar.bz2
Add glue for supporting custom MIME types in DataTransfer.
BUG=31037 TEST=none in this patch, will be landed in WebKit as layout tests. Review URL: http://codereview.chromium.org/8775025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112927 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools')
-rw-r--r--webkit/tools/test_shell/mock_webclipboard_impl.cc24
-rw-r--r--webkit/tools/test_shell/mock_webclipboard_impl.h6
-rw-r--r--webkit/tools/test_shell/simple_clipboard_impl.cc7
-rw-r--r--webkit/tools/test_shell/simple_clipboard_impl.h3
4 files changed, 38 insertions, 2 deletions
diff --git a/webkit/tools/test_shell/mock_webclipboard_impl.cc b/webkit/tools/test_shell/mock_webclipboard_impl.cc
index d5a00b6..934ebac 100644
--- a/webkit/tools/test_shell/mock_webclipboard_impl.cc
+++ b/webkit/tools/test_shell/mock_webclipboard_impl.cc
@@ -4,6 +4,8 @@
#include "webkit/tools/test_shell/mock_webclipboard_impl.h"
+#include <algorithm>
+
#include "base/logging.h"
#include "base/stl_util.h"
#include "base/string_util.h"
@@ -21,6 +23,7 @@
#include <CoreFoundation/CoreFoundation.h>
#endif
+using WebKit::WebDragData;
using WebKit::WebString;
using WebKit::WebURL;
using WebKit::WebVector;
@@ -75,6 +78,11 @@ WebVector<WebString> MockWebClipboardImpl::readAvailableTypes(
if (!m_image.isNull()) {
results.push_back(WebString("image/png"));
}
+ for (size_t i = 0; i < m_customData.size(); ++i) {
+ CHECK(std::find(results.begin(), results.end(), m_customData[i].type) ==
+ results.end());
+ results.push_back(m_customData[i].type);
+ }
return results;
}
@@ -124,12 +132,24 @@ WebKit::WebData MockWebClipboardImpl::readImage(
return data;
}
+WebKit::WebString MockWebClipboardImpl::readCustomData(
+ WebKit::WebClipboard::Buffer buffer,
+ const WebKit::WebString& type) {
+ for (size_t i = 0; i < m_customData.size(); ++i) {
+ if (m_customData[i].type == type) {
+ return m_customData[i].data;
+ }
+ }
+ return WebKit::WebString();
+}
+
void MockWebClipboardImpl::writeHTML(
const WebKit::WebString& htmlText, const WebKit::WebURL& url,
const WebKit::WebString& plainText, bool writeSmartPaste) {
m_htmlText = htmlText;
m_plainText = plainText;
m_image.reset();
+ m_customData = WebVector<WebDragData::CustomData>();
m_writeSmartPaste = writeSmartPaste;
}
@@ -137,6 +157,7 @@ void MockWebClipboardImpl::writePlainText(const WebKit::WebString& plain_text) {
m_htmlText = WebKit::WebString();
m_plainText = plain_text;
m_image.reset();
+ m_customData = WebVector<WebDragData::CustomData>();
m_writeSmartPaste = false;
}
@@ -146,6 +167,7 @@ void MockWebClipboardImpl::writeURL(
webkit_glue::WebClipboardImpl::URLToMarkup(url, title));
m_plainText = url.spec().utf16();
m_image.reset();
+ m_customData = WebVector<WebDragData::CustomData>();
m_writeSmartPaste = false;
}
@@ -156,6 +178,7 @@ void MockWebClipboardImpl::writeImage(const WebKit::WebImage& image,
webkit_glue::WebClipboardImpl::URLToImageMarkup(url, title));
m_plainText = m_htmlText;
m_image = image;
+ m_customData = WebVector<WebDragData::CustomData>();
m_writeSmartPaste = false;
}
}
@@ -164,5 +187,6 @@ void MockWebClipboardImpl::writeDataObject(const WebKit::WebDragData& data) {
m_htmlText = data.htmlText();
m_plainText = data.plainText();
m_image.reset();
+ m_customData = data.customData();
m_writeSmartPaste = false;
}
diff --git a/webkit/tools/test_shell/mock_webclipboard_impl.h b/webkit/tools/test_shell/mock_webclipboard_impl.h
index c80175b..8133089 100644
--- a/webkit/tools/test_shell/mock_webclipboard_impl.h
+++ b/webkit/tools/test_shell/mock_webclipboard_impl.h
@@ -11,6 +11,7 @@
#define WEBKIT_TOOLS_TEST_SHELL_MOCK_WEBCLIPBOARD_IMPL_H_
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebClipboard.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h"
class MockWebClipboardImpl : public WebKit::WebClipboard {
@@ -28,7 +29,9 @@ class MockWebClipboardImpl : public WebKit::WebClipboard {
WebKit::WebURL* url,
unsigned* fragmentStart,
unsigned* fragmentEnd);
- virtual WebKit::WebData readImage(WebKit::WebClipboard::Buffer);
+ virtual WebKit::WebData readImage(WebKit::WebClipboard::Buffer buffer);
+ virtual WebKit::WebString readCustomData(WebKit::WebClipboard::Buffer buffer,
+ const WebKit::WebString& type);
virtual void writePlainText(const WebKit::WebString& plain_text);
virtual void writeHTML(
@@ -45,6 +48,7 @@ class MockWebClipboardImpl : public WebKit::WebClipboard {
WebKit::WebString m_plainText;
WebKit::WebString m_htmlText;
WebKit::WebImage m_image;
+ WebKit::WebVector<WebKit::WebDragData::CustomData> m_customData;
bool m_writeSmartPaste;
};
diff --git a/webkit/tools/test_shell/simple_clipboard_impl.cc b/webkit/tools/test_shell/simple_clipboard_impl.cc
index 0b137f1c..c7bb959 100644
--- a/webkit/tools/test_shell/simple_clipboard_impl.cc
+++ b/webkit/tools/test_shell/simple_clipboard_impl.cc
@@ -94,8 +94,13 @@ void SimpleClipboardClient::ReadImage(ui::Clipboard::Buffer buffer,
}
}
+void SimpleClipboardClient::ReadCustomData(ui::Clipboard::Buffer buffer,
+ const string16& type,
+ string16* data) {
+ GetClipboard()->ReadCustomData(buffer, type, data);
+}
+
webkit_glue::ClipboardClient::WriteContext*
SimpleClipboardClient::CreateWriteContext() {
return NULL;
}
-
diff --git a/webkit/tools/test_shell/simple_clipboard_impl.h b/webkit/tools/test_shell/simple_clipboard_impl.h
index f572eb3..873adc6 100644
--- a/webkit/tools/test_shell/simple_clipboard_impl.h
+++ b/webkit/tools/test_shell/simple_clipboard_impl.h
@@ -29,6 +29,9 @@ class SimpleClipboardClient : public webkit_glue::ClipboardClient {
uint32* fragment_end) OVERRIDE;
virtual void ReadImage(ui::Clipboard::Buffer buffer,
std::string* data) OVERRIDE;
+ virtual void ReadCustomData(ui::Clipboard::Buffer buffer,
+ const string16& type,
+ string16* data) OVERRIDE;
virtual WriteContext* CreateWriteContext() OVERRIDE;
};