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

Unified Diff: webkit/glue/webview_impl.cc

Issue 67297: Provide an override for Webview drop effect.... Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 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
« webkit/glue/webview_impl.h ('K') | « webkit/glue/webview_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webview_impl.cc
===================================================================
--- webkit/glue/webview_impl.cc (revision 14025)
+++ webkit/glue/webview_impl.cc (working copy)
@@ -363,6 +363,8 @@
ime_accept_events_(true),
drag_target_dispatch_(false),
drag_identity_(0),
+ drop_effect_(DROP_EFFECT_DEFAULT),
+ drop_accept_(false),
autocomplete_popup_showing_(false) {
// WebKit/win/WebView.cpp does the same thing, except they call the
// KJS specific wrapper around this method. We need to have threading
@@ -1644,11 +1646,15 @@
webkit_glue::WebPointToIntPoint(client_point),
webkit_glue::WebPointToIntPoint(screen_point),
kDropTargetOperation);
+
+ drop_effect_ = DROP_EFFECT_DEFAULT;
drag_target_dispatch_ = true;
DragOperation effect = page_->dragController()->dragEntered(&drag_data);
drag_target_dispatch_ = false;
- return effect != DragOperationNone;
+ if (drop_effect_ != DROP_EFFECT_DEFAULT)
+ return drop_accept_ = (drop_effect_ != DROP_EFFECT_NONE);
+ return drop_accept_ = (effect != DragOperationNone);
}
bool WebViewImpl::DragTargetDragOver(
@@ -1661,11 +1667,15 @@
webkit_glue::WebPointToIntPoint(client_point),
webkit_glue::WebPointToIntPoint(screen_point),
kDropTargetOperation);
+
+ drop_effect_ = DROP_EFFECT_DEFAULT;
drag_target_dispatch_ = true;
DragOperation effect = page_->dragController()->dragUpdated(&drag_data);
drag_target_dispatch_ = false;
- return effect != DragOperationNone;
+ if (drop_effect_ != DROP_EFFECT_DEFAULT)
+ return drop_accept_ = (drop_effect_ != DROP_EFFECT_NONE);
+ return drop_accept_ = (effect != DragOperationNone);
}
void WebViewImpl::DragTargetDragLeave() {
@@ -1676,11 +1686,14 @@
IntPoint(),
IntPoint(),
kDropTargetOperation);
+
drag_target_dispatch_ = true;
page_->dragController()->dragExited(&drag_data);
drag_target_dispatch_ = false;
current_drag_data_ = NULL;
+ drop_effect_ = DROP_EFFECT_DEFAULT;
+ drop_accept_ = false;
drag_identity_ = 0;
}
@@ -1689,16 +1702,31 @@
const WebPoint& screen_point) {
DCHECK(current_drag_data_.get());
+ // If this webview transitions from the "drop accepting" state to the "not
+ // accepting" state, then our IPC message reply indicating that may be in-
+ // flight, or else delayed by javascript processing in this webview. If a
+ // drop happens before our IPC reply has reached the browser process, then
+ // the browser forwards the drop to this webview. So only allow a drop to
+ // proceed if our webview drop_accept_ state is true.
+
+ if (!drop_accept_) { // IPC RACE CONDITION: do not allow this drop.
+ DragTargetDragLeave();
+ return;
+ }
+
DragData drag_data(
current_drag_data_.get(),
webkit_glue::WebPointToIntPoint(client_point),
webkit_glue::WebPointToIntPoint(screen_point),
kDropTargetOperation);
+
drag_target_dispatch_ = true;
page_->dragController()->performDrag(&drag_data);
drag_target_dispatch_ = false;
current_drag_data_ = NULL;
+ drop_effect_ = DROP_EFFECT_DEFAULT;
+ drop_accept_ = false;
drag_identity_ = 0;
}
@@ -1708,6 +1736,15 @@
return 0;
}
+bool WebViewImpl::SetDropEffect(bool accept) {
+ if (drag_target_dispatch_) {
+ drop_effect_ = accept ? DROP_EFFECT_COPY : DROP_EFFECT_NONE;
+ return true;
+ } else {
+ return false;
+ }
+}
+
SearchableFormData* WebViewImpl::CreateSearchableFormDataForFocusedNode() {
if (!page_.get())
return NULL;
« webkit/glue/webview_impl.h ('K') | « webkit/glue/webview_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698