summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webdropdata.cc
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 23:24:58 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 23:24:58 +0000
commite80c73be12cc2211d5a72a5ff85eb97366b2458f (patch)
tree5c395779776b368ed6cafdbc5c6bc929776c18a4 /webkit/glue/webdropdata.cc
parent25a3f6b52228bc68ce63c4032ed6b17cecd7b3c5 (diff)
downloadchromium_src-e80c73be12cc2211d5a72a5ff85eb97366b2458f.zip
chromium_src-e80c73be12cc2211d5a72a5ff85eb97366b2458f.tar.gz
chromium_src-e80c73be12cc2211d5a72a5ff85eb97366b2458f.tar.bz2
Switch to using WebDragData in WebView and WebViewDelegate.
I also cleaned up some of the WebView and WebViewDelegate methods to pass WebPoint instead of pairs of ints or gfx::Point. With this change, I am keeping webkit/glue/webdropdata.{h,cc}, which is what Chrome uses to pass around the equivalent data. Now, it is possible to construct a WebDropData from a WebKit::WebDragData and to also get a WebKit::WebDragData from a WebDropData. Hence, the conversion between WebDropData and ChromiumDataObject (see clipboard_conversion.{h,cc}) is now removed in favor of conversion between WebDropData and WebKit::WebDragData. Conversion between WebKit::WebDragData and WebCore::ChromiumDataObject is very cheap (just reference counting). Finally, this change also brings in WebData, which is now used by the return value of WebKitClient::loadResource. As a companion to that change, I also changed webkit_glue::GetDataResource to return StringPiece instead of std::string. That also saves on an unnecessary buffer copy. R=dglazkov Review URL: http://codereview.chromium.org/63084 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13305 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webdropdata.cc')
-rw-r--r--webkit/glue/webdropdata.cc63
1 files changed, 42 insertions, 21 deletions
diff --git a/webkit/glue/webdropdata.cc b/webkit/glue/webdropdata.cc
index bf6ef50..b48c04c 100644
--- a/webkit/glue/webdropdata.cc
+++ b/webkit/glue/webdropdata.cc
@@ -4,27 +4,48 @@
#include "webkit/glue/webdropdata.h"
-#include "base/clipboard_util.h"
-#include "googleurl/src/gurl.h"
-#include <shellapi.h>
-#include <shlobj.h>
+#include "third_party/WebKit/WebKit/chromium/public/WebData.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebDragData.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"
-/* static */
-void WebDropData::PopulateWebDropData(IDataObject* data_object,
- WebDropData* drop_data) {
- std::wstring url_str;
- if (ClipboardUtil::GetUrl(data_object, &url_str, &drop_data->url_title)) {
- GURL test_url(url_str);
- if (test_url.is_valid())
- drop_data->url = test_url;
- }
- ClipboardUtil::GetFilenames(data_object, &drop_data->filenames);
- ClipboardUtil::GetPlainText(data_object, &drop_data->plain_text);
- std::string base_url;
- ClipboardUtil::GetHtml(data_object, &drop_data->text_html, &base_url);
- if (!base_url.empty()) {
- drop_data->html_base_url = GURL(base_url);
+using WebKit::WebData;
+using WebKit::WebDragData;
+using WebKit::WebString;
+using WebKit::WebVector;
+
+WebDropData::WebDropData(const WebDragData& drag_data)
+ : identity(0),
+ url(drag_data.url()),
+ url_title(drag_data.urlTitle()),
+ file_extension(drag_data.fileExtension()),
+ plain_text(drag_data.plainText()),
+ text_html(drag_data.htmlText()),
+ html_base_url(drag_data.htmlBaseURL()),
+ file_description_filename(drag_data.fileContentFileName()) {
+ if (drag_data.hasFileNames()) {
+ WebVector<WebString> fileNames;
+ drag_data.fileNames(fileNames);
+ for (size_t i = 0; i < fileNames.size(); ++i)
+ filenames.push_back(fileNames[i]);
}
- ClipboardUtil::GetFileContents(data_object,
- &drop_data->file_description_filename, &drop_data->file_contents);
+ WebData contents = drag_data.fileContent();
+ if (!contents.isEmpty())
+ file_contents.assign(contents.data(), contents.size());
+}
+
+WebDragData WebDropData::ToDragData() const {
+ WebDragData result;
+ result.initialize();
+ result.setURL(url);
+ result.setURLTitle(url_title);
+ result.setFileExtension(file_extension);
+ result.setFileNames(filenames);
+ result.setPlainText(plain_text);
+ result.setHTMLText(text_html);
+ result.setHTMLBaseURL(html_base_url);
+ result.setFileContentFileName(file_description_filename);
+ result.setFileContent(WebData(file_contents.data(), file_contents.size()));
+ return result;
}