summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-26 01:27:55 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-26 01:27:55 +0000
commit58377e2edb08dabeeba8a01bfb4484eb61527b4a (patch)
tree25fe434821c4537d799a316c91a995394ec00efb /webkit
parent24c289f856db14a85e5840ad0132512ef59c5c5f (diff)
downloadchromium_src-58377e2edb08dabeeba8a01bfb4484eb61527b4a.zip
chromium_src-58377e2edb08dabeeba8a01bfb4484eb61527b4a.tar.gz
chromium_src-58377e2edb08dabeeba8a01bfb4484eb61527b4a.tar.bz2
Add an identity (id) to system drag & drop.
Used for gears file drag & drop in chrome, assign a drag id (identity) to each drag and drop session. Send the identity to the renderer WebViewImpl in drag enter notifications, provide a getter method. BUG=7995 Original patch by noel.gordon@gmail.com in: http://codereview.chromium.org/28108/show Review URL: http://codereview.chromium.org/28158 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10430 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/webdropdata.h10
-rw-r--r--webkit/glue/webview.h1
-rw-r--r--webkit/glue/webview_impl.cc26
-rw-r--r--webkit/glue/webview_impl.h9
4 files changed, 45 insertions, 1 deletions
diff --git a/webkit/glue/webdropdata.h b/webkit/glue/webdropdata.h
index 9afcd04..7c9fe19 100644
--- a/webkit/glue/webdropdata.h
+++ b/webkit/glue/webdropdata.h
@@ -16,7 +16,15 @@
struct IDataObject;
struct WebDropData {
- // User is dropping a link on the webview.
+ // Construct with a given drag identity. Note: identity is an int32 because
+ // it is passed over the renderer NPAPI interface to gears.
+ explicit WebDropData(int32 drag_identity) : identity(drag_identity) {}
+ int32 identity;
+
+ // For default constructions, use drag |identity| 0.
+ WebDropData() : identity(0) {}
+
+ // User is dragging a link into the webview.
GURL url;
std::wstring url_title; // The title associated with |url|.
diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h
index fbd4f33f..d8ef94d 100644
--- a/webkit/glue/webview.h
+++ b/webkit/glue/webview.h
@@ -185,6 +185,7 @@ class WebView : public WebWidget {
virtual void DragTargetDragLeave() = 0;
virtual void DragTargetDrop(
int client_x, int client_y, int screen_x, int screen_y) = 0;
+ virtual int32 GetDragIdentity() = 0;
// Notifies the webview that autofill suggestions are available for a node.
virtual void AutofillSuggestionsForNode(
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index 6b0444d..4db2ac0 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -334,6 +334,8 @@ WebViewImpl::WebViewImpl()
suppress_next_keypress_event_(false),
window_open_disposition_(IGNORE_ACTION),
ime_accept_events_(true),
+ drag_target_dispatch_(false),
+ drag_identity_(0),
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
@@ -1472,37 +1474,61 @@ bool WebViewImpl::DragTargetDragEnter(const WebDropData& drop_data,
DCHECK(!current_drop_data_.get());
current_drop_data_ = webkit_glue::WebDropDataToChromiumDataObject(drop_data);
+ drag_identity_ = drop_data.identity;
DragData drag_data(current_drop_data_.get(), IntPoint(client_x, client_y),
IntPoint(screen_x, screen_y), kDropTargetOperation);
+ drag_target_dispatch_ = true;
DragOperation effect = page_->dragController()->dragEntered(&drag_data);
+ drag_target_dispatch_ = false;
+
return effect != DragOperationNone;
}
bool WebViewImpl::DragTargetDragOver(
int client_x, int client_y, int screen_x, int screen_y) {
DCHECK(current_drop_data_.get());
+
DragData drag_data(current_drop_data_.get(), IntPoint(client_x, client_y),
IntPoint(screen_x, screen_y), kDropTargetOperation);
+ drag_target_dispatch_ = true;
DragOperation effect = page_->dragController()->dragUpdated(&drag_data);
+ drag_target_dispatch_ = false;
+
return effect != DragOperationNone;
}
void WebViewImpl::DragTargetDragLeave() {
DCHECK(current_drop_data_.get());
+
DragData drag_data(current_drop_data_.get(), IntPoint(), IntPoint(),
DragOperationNone);
+ drag_target_dispatch_ = true;
page_->dragController()->dragExited(&drag_data);
+ drag_target_dispatch_ = false;
+
current_drop_data_ = NULL;
+ drag_identity_ = 0;
}
void WebViewImpl::DragTargetDrop(
int client_x, int client_y, int screen_x, int screen_y) {
DCHECK(current_drop_data_.get());
+
DragData drag_data(current_drop_data_.get(), IntPoint(client_x, client_y),
IntPoint(screen_x, screen_y), kDropTargetOperation);
+ drag_target_dispatch_ = true;
page_->dragController()->performDrag(&drag_data);
+ drag_target_dispatch_ = false;
+
current_drop_data_ = NULL;
+ drag_identity_ = 0;
+}
+
+int32 WebViewImpl::GetDragIdentity() {
+ if (drag_target_dispatch_)
+ return drag_identity_;
+ return 0;
}
SearchableFormData* WebViewImpl::CreateSearchableFormDataForFocusedNode() {
diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h
index 9023d96..2c0a118 100644
--- a/webkit/glue/webview_impl.h
+++ b/webkit/glue/webview_impl.h
@@ -100,6 +100,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
virtual void DragTargetDragLeave();
virtual void DragTargetDrop(
int client_x, int client_y, int screen_x, int screen_y);
+ virtual int32 GetDragIdentity();
virtual void AutofillSuggestionsForNode(
int64 node_id,
const std::vector<std::wstring>& suggestions,
@@ -294,6 +295,14 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> {
// Represents whether or not this object should process incoming IME events.
bool ime_accept_events_;
+ // True while dispatching system drag and drop events to drag/drop targets
+ // within this WebView.
+ bool drag_target_dispatch_;
+
+ // Valid when drag_target_dispatch_ is true; the identity of the drag data
+ // copied from the WebDropData object sent from the browser process.
+ int32 drag_identity_;
+
// The autocomplete popup. Kept around and reused every-time new suggestions
// should be shown.
RefPtr<WebCore::PopupContainer> autocomplete_popup_;