[email protected] | b3123ce | 2011-04-08 08:23:17 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 4 | |
| 5 | #include "webkit/tools/test_shell/drop_delegate.h" |
| 6 | |
[email protected] | 3034b681 | 2011-12-03 00:00:14 | [diff] [blame] | 7 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.h" |
| 8 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" |
[email protected] | c1d9cdc | 2011-01-17 06:50:01 | [diff] [blame] | 9 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 10 | #include "webkit/glue/webdropdata.h" |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 11 | |
[email protected] | 1d9f413 | 2009-09-08 17:29:25 | [diff] [blame] | 12 | using WebKit::WebDragOperation; |
| 13 | using WebKit::WebDragOperationCopy; |
[email protected] | e80c73be | 2009-04-07 23:24:58 | [diff] [blame] | 14 | using WebKit::WebPoint; |
[email protected] | 50ae00ef | 2009-10-19 05:11:03 | [diff] [blame] | 15 | using WebKit::WebView; |
[email protected] | e80c73be | 2009-04-07 23:24:58 | [diff] [blame] | 16 | |
[email protected] | 79a4c1e | 2010-10-17 20:44:38 | [diff] [blame] | 17 | TestDropDelegate::TestDropDelegate(HWND source_hwnd, WebKit::WebView* webview) |
[email protected] | 02bae0f | 2011-01-19 20:22:00 | [diff] [blame] | 18 | : ui::DropTarget(source_hwnd), |
[email protected] | 79a4c1e | 2010-10-17 20:44:38 | [diff] [blame] | 19 | webview_(webview) { |
| 20 | } |
[email protected] | e80c73be | 2009-04-07 23:24:58 | [diff] [blame] | 21 | |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 22 | DWORD TestDropDelegate::OnDragEnter(IDataObject* data_object, |
| 23 | DWORD key_state, |
| 24 | POINT cursor_position, |
| 25 | DWORD effect) { |
| 26 | WebDropData drop_data; |
| 27 | WebDropData::PopulateWebDropData(data_object, &drop_data); |
| 28 | |
| 29 | POINT client_pt = cursor_position; |
| 30 | ScreenToClient(GetHWND(), &client_pt); |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 31 | WebDragOperation op = webview_->dragTargetDragEnter( |
[email protected] | b3123ce | 2011-04-08 08:23:17 | [diff] [blame] | 32 | drop_data.ToDragData(), |
[email protected] | e80c73be | 2009-04-07 23:24:58 | [diff] [blame] | 33 | WebPoint(client_pt.x, client_pt.y), |
[email protected] | 1d9f413 | 2009-09-08 17:29:25 | [diff] [blame] | 34 | WebPoint(cursor_position.x, cursor_position.y), |
| 35 | WebDragOperationCopy); |
| 36 | // TODO(snej): Pass the real drag operation instead |
| 37 | return op ? DROPEFFECT_COPY : DROPEFFECT_NONE; |
| 38 | // TODO(snej): Return the real drop effect constant matching 'op' |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | DWORD TestDropDelegate::OnDragOver(IDataObject* data_object, |
| 42 | DWORD key_state, |
| 43 | POINT cursor_position, |
| 44 | DWORD effect) { |
| 45 | POINT client_pt = cursor_position; |
| 46 | ScreenToClient(GetHWND(), &client_pt); |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 47 | WebDragOperation op = webview_->dragTargetDragOver( |
[email protected] | e80c73be | 2009-04-07 23:24:58 | [diff] [blame] | 48 | WebPoint(client_pt.x, client_pt.y), |
[email protected] | 1d9f413 | 2009-09-08 17:29:25 | [diff] [blame] | 49 | WebPoint(cursor_position.x, cursor_position.y), |
| 50 | WebDragOperationCopy); |
| 51 | // TODO(snej): Pass the real drag operation instead |
| 52 | return op ? DROPEFFECT_COPY : DROPEFFECT_NONE; |
| 53 | // TODO(snej): Return the real drop effect constant matching 'op' |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | void TestDropDelegate::OnDragLeave(IDataObject* data_object) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 57 | webview_->dragTargetDragLeave(); |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | DWORD TestDropDelegate::OnDrop(IDataObject* data_object, |
| 61 | DWORD key_state, |
| 62 | POINT cursor_position, |
| 63 | DWORD effect) { |
| 64 | POINT client_pt = cursor_position; |
| 65 | ScreenToClient(GetHWND(), &client_pt); |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 66 | webview_->dragTargetDrop( |
[email protected] | e80c73be | 2009-04-07 23:24:58 | [diff] [blame] | 67 | WebPoint(client_pt.x, client_pt.y), |
| 68 | WebPoint(cursor_position.x, cursor_position.y)); |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 69 | |
| 70 | // webkit win port always returns DROPEFFECT_NONE |
| 71 | return DROPEFFECT_NONE; |
| 72 | } |