OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "webkit/tools/test_shell/drop_delegate.h" | |
6 | |
7 #include "third_party/WebKit/Source/Platform/chromium/public/WebDragData.h" | |
8 #include "third_party/WebKit/Source/Platform/chromium/public/WebPoint.h" | |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | |
10 #include "webkit/glue/webdropdata.h" | |
11 | |
12 using WebKit::WebDragOperation; | |
13 using WebKit::WebDragOperationCopy; | |
14 using WebKit::WebPoint; | |
15 using WebKit::WebView; | |
16 | |
17 TestDropDelegate::TestDropDelegate(HWND source_hwnd, WebKit::WebView* webview) | |
18 : ui::DropTargetWin(source_hwnd), | |
19 webview_(webview) { | |
20 } | |
21 | |
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); | |
31 WebDragOperation op = webview_->dragTargetDragEnter( | |
32 drop_data.ToDragData(), | |
33 WebPoint(client_pt.x, client_pt.y), | |
34 WebPoint(cursor_position.x, cursor_position.y), | |
35 WebDragOperationCopy, | |
36 0); | |
37 // TODO(snej): Pass the real drag operation instead | |
38 return op ? DROPEFFECT_COPY : DROPEFFECT_NONE; | |
39 // TODO(snej): Return the real drop effect constant matching 'op' | |
40 } | |
41 | |
42 DWORD TestDropDelegate::OnDragOver(IDataObject* data_object, | |
43 DWORD key_state, | |
44 POINT cursor_position, | |
45 DWORD effect) { | |
46 POINT client_pt = cursor_position; | |
47 ScreenToClient(GetHWND(), &client_pt); | |
48 WebDragOperation op = webview_->dragTargetDragOver( | |
49 WebPoint(client_pt.x, client_pt.y), | |
50 WebPoint(cursor_position.x, cursor_position.y), | |
51 WebDragOperationCopy, | |
52 0); | |
53 // TODO(snej): Pass the real drag operation instead | |
54 return op ? DROPEFFECT_COPY : DROPEFFECT_NONE; | |
55 // TODO(snej): Return the real drop effect constant matching 'op' | |
56 } | |
57 | |
58 void TestDropDelegate::OnDragLeave(IDataObject* data_object) { | |
59 webview_->dragTargetDragLeave(); | |
60 } | |
61 | |
62 DWORD TestDropDelegate::OnDrop(IDataObject* data_object, | |
63 DWORD key_state, | |
64 POINT cursor_position, | |
65 DWORD effect) { | |
66 POINT client_pt = cursor_position; | |
67 ScreenToClient(GetHWND(), &client_pt); | |
68 webview_->dragTargetDrop( | |
69 WebPoint(client_pt.x, client_pt.y), | |
70 WebPoint(cursor_position.x, cursor_position.y), | |
71 0); | |
72 | |
73 // webkit win port always returns DROPEFFECT_NONE | |
74 return DROPEFFECT_NONE; | |
75 } | |
OLD | NEW |