Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Unified Diff: content/renderer/render_view_impl.cc

Issue 2485693003: Drag-and-drop: DragEnter, DragOver, DragLeave, DragDrop (Closed)
Patch Set: No longer using GetSiteInstance() in RenderWidgetHostImpl. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index ebfac09d0234e261dfa0541562a73189c46c27e2..451ce763cded39c321c420d1e3c1a90b59a67647 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -379,128 +379,6 @@ static void ConvertToFaviconSizes(
namespace {
-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;
- // Have to pass a dummy URL here instead of an empty URL because the
- // DropData received by browser_plugins goes through a round trip:
- // DropData::MetaData --> WebDragData-->DropData. In the end, DropData
- // will contain an empty URL (which means no URL is dragged) if the URL in
- // WebDragData is empty.
- if (base::EqualsASCII(meta_data_item.mime_type,
- ui::Clipboard::kMimeTypeURIList)) {
- item.stringData = WebString::fromUTF8("about:dragdrop-placeholder");
- }
- 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.
- if ((meta_data_item.kind == DropData::Kind::FILENAME) &&
- !meta_data_item.filename.empty()) {
- 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;
-
- // 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);
- }
-
- 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<ui::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.AsUTF16Unsafe();
- item.displayNameData = it->display_name.AsUTF16Unsafe();
- item_list.push_back(item);
- }
-
- for (std::vector<DropData::FileSystemFileInfo>::const_iterator it =
- drop_data.file_system_files.begin();
- it != drop_data.file_system_files.end();
- ++it) {
- WebDragData::Item item;
- item.storageType = WebDragData::Item::StorageTypeFileSystemFile;
- item.fileSystemURL = it->url;
- item.fileSystemFileSize = it->size;
- 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;
-}
-
typedef void (*SetFontFamilyWrapper)(blink::WebSettings*,
const base::string16&,
UScriptCode);
@@ -1307,10 +1185,6 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
OnScrollFocusedEditableNodeIntoRect)
IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale)
IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
- IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
- IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver)
- IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave)
- IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop)
IPC_MESSAGE_HANDLER(DragMsg_SourceEnded, OnDragSourceEnded)
IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded,
OnDragSourceSystemDragEnded)
@@ -2090,9 +1964,7 @@ bool RenderViewImpl::HasAddedInputHandler() const {
gfx::Point RenderViewImpl::ConvertWindowPointToViewport(
const gfx::Point& point) {
- blink::WebFloatRect point_in_viewport(point.x(), point.y(), 0, 0);
- convertWindowToViewport(&point_in_viewport);
- return gfx::Point(point_in_viewport.x, point_in_viewport.y);
+ return RenderWidget::ConvertWindowPointToViewport(point);
dcheng 2016/11/09 20:23:17 Do we still need to forward this, or can the calle
paulmeyer 2016/11/09 23:19:11 Nope, fixed.
}
void RenderViewImpl::didChangeIcon(WebLocalFrame* frame,
@@ -2261,45 +2133,6 @@ void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) {
main_render_frame_->MaybeEnableMojoBindings();
}
-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(
- DropMetaDataToWebDragData(drop_meta_data), client_point, screen_point,
- ops, key_modifiers);
-
- Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation));
-}
-
-void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point,
- const gfx::Point& screen_point,
- WebDragOperationsMask ops,
- int key_modifiers) {
- WebDragOperation operation = webview()->dragTargetDragOver(
- ConvertWindowPointToViewport(client_point),
- screen_point,
- ops,
- key_modifiers);
-
- Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation));
-}
-
-void RenderViewImpl::OnDragTargetDragLeave() {
- webview()->dragTargetDragLeave();
-}
-
-void RenderViewImpl::OnDragTargetDrop(const DropData& drop_data,
- const gfx::Point& client_point,
- const gfx::Point& screen_point,
- int key_modifiers) {
- webview()->dragTargetDrop(DropDataToWebDragData(drop_data),
- ConvertWindowPointToViewport(client_point),
- screen_point, key_modifiers);
-}
-
void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point,
const gfx::Point& screen_point,
WebDragOperation op) {

Powered by Google App Engine
This is Rietveld 408576698