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

Unified Diff: content/renderer/render_view_impl.cc

Issue 2485693003: Drag-and-drop: DragEnter, DragOver, DragLeave, DragDrop (Closed)
Patch Set: Rebased. More fixes. 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
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 670a2238d453022516a88fc7af5ee98af24c1fd5..8909d500e220c0be69d4a26fdc8a3a8fea4c6cac 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -60,7 +60,6 @@
#include "content/public/common/content_client.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
-#include "content/public/common/drop_data.h"
#include "content/public/common/favicon_url.h"
#include "content/public/common/page_importance_signals.h"
#include "content/public/common/page_state.h"
@@ -111,7 +110,6 @@
#include "third_party/WebKit/public/platform/FilePathConversion.h"
#include "third_party/WebKit/public/platform/URLConversion.h"
#include "third_party/WebKit/public/platform/WebConnectionType.h"
-#include "third_party/WebKit/public/platform/WebDragData.h"
#include "third_party/WebKit/public/platform/WebHTTPBody.h"
#include "third_party/WebKit/public/platform/WebImage.h"
#include "third_party/WebKit/public/platform/WebMessagePortChannel.h"
@@ -162,7 +160,6 @@
#include "third_party/WebKit/public/web/WebWindowFeatures.h"
#include "third_party/icu/source/common/unicode/uchar.h"
#include "third_party/icu/source/common/unicode/uscript.h"
-#include "ui/base/clipboard/clipboard.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/events/latency_info.h"
#include "ui/gfx/geometry/point.h"
@@ -207,9 +204,7 @@ using blink::WebConsoleMessage;
using blink::WebData;
using blink::WebDataSource;
using blink::WebDocument;
-using blink::WebDragData;
using blink::WebDragOperation;
-using blink::WebDragOperationsMask;
using blink::WebElement;
using blink::WebFileChooserCompletion;
using blink::WebFormControlElement;
@@ -379,128 +374,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);
@@ -1316,10 +1189,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)
@@ -2085,13 +1954,6 @@ bool RenderViewImpl::HasAddedInputHandler() const {
return has_added_input_handler_;
}
-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);
-}
-
void RenderViewImpl::didChangeIcon(WebLocalFrame* frame,
WebIconURL::Type icon_type) {
if (frame->parent())
@@ -2258,45 +2120,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) {
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698