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

Unified Diff: chrome/browser/tab_contents/web_drop_target_win.cc

Issue 1572027: Return an approximately correct drop effect from WebDragTarget::OnDrop. (Closed)
Patch Set: . Created 10 years, 8 months 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: chrome/browser/tab_contents/web_drop_target_win.cc
diff --git a/chrome/browser/tab_contents/web_drop_target_win.cc b/chrome/browser/tab_contents/web_drop_target_win.cc
index 1ea79a815ef5b4ab7f427e958880795675f28046..66dee6a17d739a352eeed4c66a2412993882363c 100644
--- a/chrome/browser/tab_contents/web_drop_target_win.cc
+++ b/chrome/browser/tab_contents/web_drop_target_win.cc
@@ -20,11 +20,11 @@
#include "webkit/glue/webdropdata.h"
#include "webkit/glue/window_open_disposition.h"
-using WebKit::WebDragOperationsMask;
using WebKit::WebDragOperationNone;
using WebKit::WebDragOperationCopy;
using WebKit::WebDragOperationLink;
using WebKit::WebDragOperationMove;
+using WebKit::WebDragOperationGeneric;
namespace {
@@ -39,16 +39,6 @@ DWORD GetPreferredDropEffect(DWORD effect) {
return DROPEFFECT_NONE;
}
-DWORD GetPreferredDragCursor(WebDragOperationsMask op) {
- if (op & WebDragOperationCopy)
- return DROPEFFECT_COPY;
- if (op & WebDragOperationLink)
- return DROPEFFECT_LINK;
- if (op & WebDragOperationMove)
- return DROPEFFECT_MOVE;
- return DROPEFFECT_NONE;
-}
-
} // anonymous namespace
// InterstitialDropTarget is like a BaseDropTarget implementation that
@@ -145,7 +135,11 @@ DWORD WebDropTarget::OnDragEnter(IDataObject* data_object,
// We lie here and always return a DROPEFFECT because we don't want to
// wait for the IPC call to return.
- return GetPreferredDragCursor(drag_cursor_);
+ DCHECK(drag_cursor_ == WebDragOperationNone ||
+ drag_cursor_ == WebDragOperationCopy ||
+ drag_cursor_ == WebDragOperationLink ||
+ drag_cursor_ == (WebDragOperationMove | WebDragOperationGeneric));
+ return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_);
}
DWORD WebDropTarget::OnDragOver(IDataObject* data_object,
@@ -173,7 +167,11 @@ DWORD WebDropTarget::OnDragOver(IDataObject* data_object,
tab_contents_->GetBookmarkDragDelegate()->OnDragOver(bookmark_drag_data);
}
- return GetPreferredDragCursor(drag_cursor_);
+ DCHECK(drag_cursor_ == WebDragOperationNone ||
+ drag_cursor_ == WebDragOperationCopy ||
+ drag_cursor_ == WebDragOperationLink ||
+ drag_cursor_ == (WebDragOperationMove | WebDragOperationGeneric));
+ return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_);
}
void WebDropTarget::OnDragLeave(IDataObject* data_object) {
@@ -224,7 +222,8 @@ DWORD WebDropTarget::OnDrop(IDataObject* data_object,
current_rvh_ = NULL;
- // We lie and always claim that the drop operation didn't happen because we
- // don't want to wait for the renderer to respond.
- return DROPEFFECT_NONE;
+ // This isn't always correct, but at least it's a close approximation.
+ // For now, we always map a move to a copy to prevent potential data loss.
+ DWORD drop_effect = web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_);
+ return drop_effect != DROPEFFECT_MOVE ? drop_effect : DROPEFFECT_COPY;
}
« no previous file with comments | « chrome/browser/tab_contents/web_drag_utils_win.cc ('k') | chrome/browser/views/tab_contents/tab_contents_drag_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698