Chromium Code Reviews| Index: content/renderer/render_view_impl.cc |
| diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc |
| index 887808994d2868d6ccc657be2820289c97d3ccc9..68a3860fea31f81a0ba1d77d06f0864de82496f3 100644 |
| --- a/content/renderer/render_view_impl.cc |
| +++ b/content/renderer/render_view_impl.cc |
| @@ -426,6 +426,44 @@ class WebWidgetLockTarget : public MouseLockDispatcher::LockTarget { |
| blink::WebWidget* webwidget_; |
| }; |
| +WebDragData DropMetaDataToWebDragData( |
| + const std::vector<DropData::MetaData>& drop_meta_data) { |
| + std::vector<WebDragData::Item> item_list; |
| + for (const auto& meta_data_item : drop_meta_data) { |
| + if (meta_data_item.kind == DropData::Kind::STRING) { |
| + WebDragData::Item item; |
| + item.storageType = WebDragData::Item::StorageTypeString; |
| + item.stringType = meta_data_item.mime_type; |
| + item_list.push_back(item); |
| + continue; |
| + } |
| + |
| + // TODO(hush): crbug.com/584789. Blink needs to support creating a file with |
| + // just the mimetype. This is needed to drag files to WebView on Android |
| + // platform. |
|
dcheng
2016/05/11 01:19:15
We should probably skip adding an item if it has n
hush (inactive)
2016/05/20 00:01:59
Done.
|
| + if (meta_data_item.kind == DropData::Kind::FILENAME) { |
| + WebDragData::Item item; |
| + item.storageType = WebDragData::Item::StorageTypeFilename; |
| + item.filenameData = meta_data_item.filename.AsUTF16Unsafe(); |
| + item_list.push_back(item); |
| + continue; |
| + } |
| + |
| + if (meta_data_item.kind == DropData::Kind::FILESYSTEMFILE) { |
| + WebDragData::Item item; |
| + item.storageType = WebDragData::Item::StorageTypeFileSystemFile; |
| + item.fileSystemURL = meta_data_item.file_system_url; |
| + item_list.push_back(item); |
| + continue; |
| + } |
| + } |
| + |
| + WebDragData result; |
| + result.initialize(); |
| + result.setItems(item_list); |
| + return result; |
| +} |
| + |
| WebDragData DropDataToWebDragData(const DropData& drop_data) { |
| std::vector<WebDragData::Item> item_list; |
| @@ -2449,17 +2487,15 @@ void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { |
| main_render_frame_->MaybeEnableMojoBindings(); |
| } |
| -void RenderViewImpl::OnDragTargetDragEnter(const DropData& drop_data, |
| - const gfx::Point& client_point, |
| - const gfx::Point& screen_point, |
| - WebDragOperationsMask ops, |
| - int key_modifiers) { |
| +void RenderViewImpl::OnDragTargetDragEnter( |
| + const std::vector<DropData::MetaData>& drop_meta_data, |
| + const gfx::Point& client_point, |
| + const gfx::Point& screen_point, |
| + WebDragOperationsMask ops, |
| + int key_modifiers) { |
| WebDragOperation operation = webview()->dragTargetDragEnter( |
| - DropDataToWebDragData(drop_data), |
| - ConvertWindowPointToViewport(client_point), |
| - screen_point, |
| - ops, |
| - key_modifiers); |
| + DropMetaDataToWebDragData(drop_meta_data), client_point, screen_point, |
| + ops, key_modifiers); |
| Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); |
| } |
| @@ -2481,11 +2517,12 @@ void RenderViewImpl::OnDragTargetDragLeave() { |
| webview()->dragTargetDragLeave(); |
| } |
| -void RenderViewImpl::OnDragTargetDrop(const gfx::Point& client_point, |
| +void RenderViewImpl::OnDragTargetDrop(const DropData& drop_data, |
| + const gfx::Point& client_point, |
| const gfx::Point& screen_point, |
| int key_modifiers) { |
| - webview()->dragTargetDrop( |
| - ConvertWindowPointToViewport(client_point), screen_point, key_modifiers); |
| + webview()->dragTargetDrop(DropDataToWebDragData(drop_data), client_point, |
| + screen_point, key_modifiers); |
| } |
| void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, |