summaryrefslogtreecommitdiffstats
path: root/chrome/browser/web_drop_target.cc
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-30 23:51:39 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-30 23:51:39 +0000
commit1057da7cbd8fe6257c667f346001b7e59902ea12 (patch)
tree50da926edf5c54a187bcbdf7c24ad61f5782c961 /chrome/browser/web_drop_target.cc
parentb16cc2ef8a7fd77707c88ae5a12ff2146f9ae401 (diff)
downloadchromium_src-1057da7cbd8fe6257c667f346001b7e59902ea12.zip
chromium_src-1057da7cbd8fe6257c667f346001b7e59902ea12.tar.gz
chromium_src-1057da7cbd8fe6257c667f346001b7e59902ea12.tar.bz2
When acting as a drop target, the webview keeps a cache of
the drop data so we don't have to send it over the IPC for each drag move. However, if a page load happens during the drop, the webview changes and we lose the cached data. To handle this, we keep track of which RVH we're dragging over and if it changes, we re-send the drop data. Review URL: http://codereview.chromium.org/8744 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4249 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_drop_target.cc')
-rw-r--r--chrome/browser/web_drop_target.cc27
1 files changed, 23 insertions, 4 deletions
diff --git a/chrome/browser/web_drop_target.cc b/chrome/browser/web_drop_target.cc
index 0d451bd..fe5ee53 100644
--- a/chrome/browser/web_drop_target.cc
+++ b/chrome/browser/web_drop_target.cc
@@ -9,6 +9,7 @@
#include "base/clipboard_util.h"
#include "base/gfx/point.h"
+#include "chrome/browser/render_view_host.h"
#include "chrome/browser/web_contents.h"
#include "chrome/common/os_exchange_data.h"
#include "googleurl/src/gurl.h"
@@ -77,6 +78,7 @@ class InterstitialDropTarget {
WebDropTarget::WebDropTarget(HWND source_hwnd, WebContents* web_contents)
: BaseDropTarget(source_hwnd),
web_contents_(web_contents),
+ current_rvh_(NULL),
is_drop_target_(false),
interstitial_drop_target_(new InterstitialDropTarget(web_contents)) {
}
@@ -88,14 +90,16 @@ DWORD WebDropTarget::OnDragEnter(IDataObject* data_object,
DWORD key_state,
POINT cursor_position,
DWORD effect) {
+ current_rvh_ = web_contents_->render_view_host();
+
// Don't pass messages to the renderer if an interstitial page is showing
// because we don't want the interstitial page to navigate. Instead,
// pass the messages on to a separate interstitial DropTarget handler.
if (web_contents_->showing_interstitial_page())
return interstitial_drop_target_->OnDragEnter(data_object, effect);
- // TODO(tc): PopulateWebDropData is kind of slow, maybe we can do this in a
- // background thread.
+ // TODO(tc): PopulateWebDropData can be slow depending on what is in the
+ // IDataObject. Maybe we can do this in a background thread.
WebDropData drop_data;
WebDropData::PopulateWebDropData(data_object, &drop_data);
@@ -119,6 +123,10 @@ DWORD WebDropTarget::OnDragOver(IDataObject* data_object,
DWORD key_state,
POINT cursor_position,
DWORD effect) {
+ DCHECK(current_rvh_);
+ if (current_rvh_ != web_contents_->render_view_host())
+ OnDragEnter(data_object, key_state, cursor_position, effect);
+
if (web_contents_->showing_interstitial_page())
return interstitial_drop_target_->OnDragOver(data_object, effect);
@@ -135,6 +143,10 @@ DWORD WebDropTarget::OnDragOver(IDataObject* data_object,
}
void WebDropTarget::OnDragLeave(IDataObject* data_object) {
+ DCHECK(current_rvh_);
+ if (current_rvh_ != web_contents_->render_view_host())
+ return;
+
if (web_contents_->showing_interstitial_page()) {
interstitial_drop_target_->OnDragLeave(data_object);
} else {
@@ -142,11 +154,17 @@ void WebDropTarget::OnDragLeave(IDataObject* data_object) {
}
}
-
DWORD WebDropTarget::OnDrop(IDataObject* data_object,
DWORD key_state,
POINT cursor_position,
DWORD effect) {
+ DCHECK(current_rvh_);
+ if (current_rvh_ != web_contents_->render_view_host())
+ OnDragEnter(data_object, key_state, cursor_position, effect);
+
+ if (web_contents_->showing_interstitial_page())
+ interstitial_drop_target_->OnDragOver(data_object, effect);
+
if (web_contents_->showing_interstitial_page())
return interstitial_drop_target_->OnDrop(data_object, effect);
@@ -156,8 +174,9 @@ DWORD WebDropTarget::OnDrop(IDataObject* data_object,
gfx::Point(client_pt.x, client_pt.y),
gfx::Point(cursor_position.x, cursor_position.y));
+ 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;
}
-