diff options
author | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-31 15:22:05 +0000 |
---|---|---|
committer | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-31 15:22:05 +0000 |
commit | c1068031c4eaf4facc80fc088c3129aff796101e (patch) | |
tree | a4df035c657cd26a6231374734794f17b2b0d076 /content/renderer | |
parent | 2e46ec5b9b33261d171fef83a4fc2274fb80832f (diff) | |
download | chromium_src-c1068031c4eaf4facc80fc088c3129aff796101e.zip chromium_src-c1068031c4eaf4facc80fc088c3129aff796101e.tar.gz chromium_src-c1068031c4eaf4facc80fc088c3129aff796101e.tar.bz2 |
WebDropData split to content and webkit/common
R=jamesr@chromium.org, jam@chromium.org
BUG=239107
Review URL: https://chromiumcodereview.appspot.com/15664011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203408 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r-- | content/renderer/render_view_impl.cc | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 9d060ff..2a8fc58 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -200,8 +200,8 @@ #include "v8/include/v8.h" #include "webkit/appcache/web_application_cache_host_impl.h" #include "webkit/base/file_path_string_conversions.h" +#include "webkit/common/webdropdata.h" #include "webkit/dom_storage/dom_storage_types.h" -#include "webkit/glue/webdropdata.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/weburlresponse_extradata_impl.h" #include "webkit/plugins/npapi/plugin_list.h" @@ -631,6 +631,71 @@ bool TouchEnabled() { #endif } +WebDragData WebDropDataToDragData(const WebDropData& drop_data) { + std::vector<WebDragData::Item> item_list; + + // These fields are currently unused when dragging into WebKit. + DCHECK(drop_data.download_metadata.empty()); + DCHECK(drop_data.file_contents.empty()); + DCHECK(drop_data.file_description_filename.empty()); + + if (!drop_data.text.is_null()) { + WebDragData::Item item; + item.storageType = WebDragData::Item::StorageTypeString; + item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeText); + item.stringData = drop_data.text.string(); + item_list.push_back(item); + } + + // TODO(dcheng): Do we need to distinguish between null and empty URLs? Is it + // meaningful to write an empty URL to the clipboard? + if (!drop_data.url.is_empty()) { + WebDragData::Item item; + item.storageType = WebDragData::Item::StorageTypeString; + item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeURIList); + item.stringData = WebString::fromUTF8(drop_data.url.spec()); + item.title = drop_data.url_title; + item_list.push_back(item); + } + + if (!drop_data.html.is_null()) { + WebDragData::Item item; + item.storageType = WebDragData::Item::StorageTypeString; + item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeHTML); + item.stringData = drop_data.html.string(); + item.baseURL = drop_data.html_base_url; + item_list.push_back(item); + } + + for (std::vector<WebDropData::FileInfo>::const_iterator it = + drop_data.filenames.begin(); + it != drop_data.filenames.end(); + ++it) { + WebDragData::Item item; + item.storageType = WebDragData::Item::StorageTypeFilename; + item.filenameData = it->path; + item.displayNameData = it->display_name; + item_list.push_back(item); + } + + for (std::map<base::string16, base::string16>::const_iterator it = + drop_data.custom_data.begin(); + it != drop_data.custom_data.end(); + ++it) { + WebDragData::Item item; + item.storageType = WebDragData::Item::StorageTypeString; + item.stringType = it->first; + item.stringData = it->second; + item_list.push_back(item); + } + + WebDragData result; + result.initialize(); + result.setItems(item_list); + result.setFilesystemId(drop_data.filesystem_id); + return result; +} + } // namespace RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) @@ -5177,7 +5242,7 @@ void RenderViewImpl::OnDragTargetDragEnter(const WebDropData& drop_data, WebDragOperationsMask ops, int key_modifiers) { WebDragOperation operation = webview()->dragTargetDragEnter( - drop_data.ToDragData(), + WebDropDataToDragData(drop_data), client_point, screen_point, ops, |