summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-23 02:28:48 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-23 02:28:48 +0000
commitd73545f4f8b2a7c6673da4b58591db5be775a4bd (patch)
treeeb16f3ab75d67b8f32104939aca1905c744858dc
parenta6b4150dd637f4b6986a58da63cc0c7192af3cc6 (diff)
downloadchromium_src-d73545f4f8b2a7c6673da4b58591db5be775a4bd.zip
chromium_src-d73545f4f8b2a7c6673da4b58591db5be775a4bd.tar.gz
chromium_src-d73545f4f8b2a7c6673da4b58591db5be775a4bd.tar.bz2
Hook up HTML5 effectAllowed and dragEffect on Windows.
This is the chrome side plumbing, but some patches need to land on the WebKit side. BUG=14654 Review URL: http://codereview.chromium.org/1132003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42301 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/tab_contents/web_drop_target_win.cc42
-rw-r--r--chrome/browser/tab_contents/web_drop_target_win.h7
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_drag_win.cc17
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_win.cc2
4 files changed, 49 insertions, 19 deletions
diff --git a/chrome/browser/tab_contents/web_drop_target_win.cc b/chrome/browser/tab_contents/web_drop_target_win.cc
index f3110d3..00f0427 100644
--- a/chrome/browser/tab_contents/web_drop_target_win.cc
+++ b/chrome/browser/tab_contents/web_drop_target_win.cc
@@ -19,9 +19,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::WebDragOperationsMask;
namespace {
@@ -36,6 +38,27 @@ 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;
+}
+
+WebDragOperationsMask WinDragOpToWebDragOp(DWORD effect) {
+ WebDragOperationsMask op = WebDragOperationNone;
+ if (effect & DROPEFFECT_COPY)
+ op = static_cast<WebDragOperationsMask>(op | WebDragOperationCopy);
+ if (effect & DROPEFFECT_LINK)
+ op = static_cast<WebDragOperationsMask>(op | WebDragOperationLink);
+ if (effect & DROPEFFECT_MOVE)
+ op = static_cast<WebDragOperationsMask>(op | WebDragOperationMove);
+ return op;
+}
+
} // anonymous namespace
// InterstitialDropTarget is like a BaseDropTarget implementation that
@@ -85,7 +108,7 @@ WebDropTarget::WebDropTarget(HWND source_hwnd, TabContents* tab_contents)
: BaseDropTarget(source_hwnd),
tab_contents_(tab_contents),
current_rvh_(NULL),
- is_drop_target_(false),
+ drag_cursor_(WebDragOperationNone),
interstitial_drop_target_(new InterstitialDropTarget(tab_contents)) {
}
@@ -112,16 +135,14 @@ DWORD WebDropTarget::OnDragEnter(IDataObject* data_object,
if (drop_data.url.is_empty())
OSExchangeDataProviderWin::GetPlainTextURL(data_object, &drop_data.url);
- is_drop_target_ = true;
+ drag_cursor_ = WebDragOperationNone;
POINT client_pt = cursor_position;
ScreenToClient(GetHWND(), &client_pt);
tab_contents_->render_view_host()->DragTargetDragEnter(drop_data,
gfx::Point(client_pt.x, client_pt.y),
gfx::Point(cursor_position.x, cursor_position.y),
- static_cast<WebDragOperationsMask>(WebDragOperationCopy |
- WebDragOperationMove));
- // FIXME(snej): Send actual operation
+ WinDragOpToWebDragOp(effect));
// This is non-null if tab_contents_ is showing an ExtensionDOMUI with
// support for (at the moment experimental) drag and drop extensions.
@@ -153,9 +174,7 @@ DWORD WebDropTarget::OnDragOver(IDataObject* data_object,
tab_contents_->render_view_host()->DragTargetDragOver(
gfx::Point(client_pt.x, client_pt.y),
gfx::Point(cursor_position.x, cursor_position.y),
- static_cast<WebDragOperationsMask>(WebDragOperationCopy |
- WebDragOperationMove));
- // FIXME(snej): Send actual operation
+ WinDragOpToWebDragOp(effect));
if (tab_contents_->GetBookmarkDragDelegate()) {
OSExchangeData os_exchange_data(new OSExchangeDataProviderWin(data_object));
@@ -164,10 +183,7 @@ DWORD WebDropTarget::OnDragOver(IDataObject* data_object,
tab_contents_->GetBookmarkDragDelegate()->OnDragOver(bookmark_drag_data);
}
- if (!is_drop_target_)
- return DROPEFFECT_NONE;
-
- return GetPreferredDropEffect(effect);
+ return GetPreferredDragCursor(drag_cursor_);
}
void WebDropTarget::OnDragLeave(IDataObject* data_object) {
diff --git a/chrome/browser/tab_contents/web_drop_target_win.h b/chrome/browser/tab_contents/web_drop_target_win.h
index fd49033..5b6188b1 100644
--- a/chrome/browser/tab_contents/web_drop_target_win.h
+++ b/chrome/browser/tab_contents/web_drop_target_win.h
@@ -7,6 +7,7 @@
#include "base/base_drop_target.h"
#include "base/scoped_ptr.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h"
class InterstitialDropTarget;
class RenderViewHost;
@@ -27,8 +28,8 @@ class WebDropTarget : public BaseDropTarget {
WebDropTarget(HWND source_hwnd, TabContents* contents);
virtual ~WebDropTarget();
- void set_is_drop_target(bool is_drop_target) {
- is_drop_target_ = is_drop_target;
+ void set_drag_cursor(WebKit::WebDragOperation op) {
+ drag_cursor_ = op;
}
protected:
@@ -61,7 +62,7 @@ class WebDropTarget : public BaseDropTarget {
// Used to determine what cursor we should display when dragging over web
// content area. This can be updated async during a drag operation.
- bool is_drop_target_;
+ WebKit::WebDragOperation drag_cursor_;
// A special drop target handler for when we try to d&d while an interstitial
// page is showing.
diff --git a/chrome/browser/views/tab_contents/tab_contents_drag_win.cc b/chrome/browser/views/tab_contents/tab_contents_drag_win.cc
index 59ddfd3..03497c8 100644
--- a/chrome/browser/views/tab_contents/tab_contents_drag_win.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_drag_win.cc
@@ -26,6 +26,9 @@
#include "webkit/glue/webdropdata.h"
using WebKit::WebDragOperationsMask;
+using WebKit::WebDragOperationCopy;
+using WebKit::WebDragOperationLink;
+using WebKit::WebDragOperationMove;
namespace {
@@ -58,6 +61,17 @@ LRESULT CALLBACK MsgFilterProc(int code, WPARAM wparam, LPARAM lparam) {
return CallNextHookEx(msg_hook, code, wparam, lparam);
}
+DWORD WebDragOpToWinDragOp(WebDragOperationsMask op) {
+ DWORD win_op = DROPEFFECT_NONE;
+ if (op & WebDragOperationCopy)
+ win_op |= DROPEFFECT_COPY;
+ if (op & WebDragOperationLink)
+ win_op |= DROPEFFECT_LINK;
+ if (op & WebDragOperationMove)
+ win_op |= DROPEFFECT_MOVE;
+ return win_op;
+}
+
} // namespace
class DragDropThread : public base::Thread {
@@ -287,8 +301,7 @@ void TabContentsDragWin::DoDragging(const WebDropData& drop_data,
bool old_state = MessageLoop::current()->NestableTasksAllowed();
MessageLoop::current()->SetNestableTasksAllowed(true);
DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source_,
- DROPEFFECT_COPY | DROPEFFECT_LINK, &effects);
- // TODO(snej): Use 'ops' param instead of hardcoding dropeffects
+ WebDragOpToWinDragOp(ops), &effects);
MessageLoop::current()->SetNestableTasksAllowed(old_state);
}
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
index 243017e..5297b5d 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
@@ -285,7 +285,7 @@ void TabContentsViewWin::CancelDragAndCloseTab() {
}
void TabContentsViewWin::UpdateDragCursor(WebDragOperation operation) {
- drop_target_->set_is_drop_target(operation != WebDragOperationNone);
+ drop_target_->set_drag_cursor(operation);
}
void TabContentsViewWin::GotFocus() {