OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file contains the implementation of TestWebViewDelegate, which serves | 5 // This file contains the implementation of TestWebViewDelegate, which serves |
6 // as the WebViewDelegate for the TestShellWebHost. The host is expected to | 6 // as the WebViewDelegate for the TestShellWebHost. The host is expected to |
7 // have initialized a MessageLoop before these methods are called. | 7 // have initialized a MessageLoop before these methods are called. |
8 | 8 |
9 #include "webkit/tools/test_shell/test_webview_delegate.h" | 9 #include "webkit/tools/test_shell/test_webview_delegate.h" |
10 | 10 |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
14 #include "base/trace_event.h" | 14 #include "base/trace_event.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "gfx/native_widget_types.h" | 16 #include "gfx/native_widget_types.h" |
17 #include "gfx/point.h" | 17 #include "gfx/point.h" |
18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
19 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h" | 19 #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h" |
20 #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" | 20 #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" |
21 #include "third_party/WebKit/WebKit/chromium/public/WebContextMenuData.h" | 21 #include "third_party/WebKit/WebKit/chromium/public/WebContextMenuData.h" |
22 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" | 22 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" |
23 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" | 23 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" |
24 #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" | 24 #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" |
25 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" | 25 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" |
| 26 #include "third_party/WebKit/WebKit/chromium/public/WebImage.h" |
26 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" | 27 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" |
27 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 28 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
28 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" | 29 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" |
29 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" | 30 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" |
30 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" | 31 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" |
31 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" | 32 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" |
32 #include "third_party/WebKit/WebKit/chromium/public/WebPopupMenu.h" | 33 #include "third_party/WebKit/WebKit/chromium/public/WebPopupMenu.h" |
33 #include "third_party/WebKit/WebKit/chromium/public/WebRange.h" | 34 #include "third_party/WebKit/WebKit/chromium/public/WebRange.h" |
34 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" | 35 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" |
35 #include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h" | 36 #include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h" |
(...skipping 30 matching lines...) Expand all Loading... |
66 using WebKit::WebConsoleMessage; | 67 using WebKit::WebConsoleMessage; |
67 using WebKit::WebContextMenuData; | 68 using WebKit::WebContextMenuData; |
68 using WebKit::WebCookieJar; | 69 using WebKit::WebCookieJar; |
69 using WebKit::WebData; | 70 using WebKit::WebData; |
70 using WebKit::WebDataSource; | 71 using WebKit::WebDataSource; |
71 using WebKit::WebDragData; | 72 using WebKit::WebDragData; |
72 using WebKit::WebDragOperationsMask; | 73 using WebKit::WebDragOperationsMask; |
73 using WebKit::WebEditingAction; | 74 using WebKit::WebEditingAction; |
74 using WebKit::WebFormElement; | 75 using WebKit::WebFormElement; |
75 using WebKit::WebFrame; | 76 using WebKit::WebFrame; |
| 77 using WebKit::WebImage; |
76 using WebKit::WebHistoryItem; | 78 using WebKit::WebHistoryItem; |
77 using WebKit::WebMediaPlayer; | 79 using WebKit::WebMediaPlayer; |
78 using WebKit::WebMediaPlayerClient; | 80 using WebKit::WebMediaPlayerClient; |
79 using WebKit::WebNavigationType; | 81 using WebKit::WebNavigationType; |
80 using WebKit::WebNavigationPolicy; | 82 using WebKit::WebNavigationPolicy; |
81 using WebKit::WebNode; | 83 using WebKit::WebNode; |
82 using WebKit::WebPlugin; | 84 using WebKit::WebPlugin; |
83 using WebKit::WebPluginParams; | 85 using WebKit::WebPluginParams; |
84 using WebKit::WebPoint; | 86 using WebKit::WebPoint; |
85 using WebKit::WebPopupMenu; | 87 using WebKit::WebPopupMenu; |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 542 |
541 void TestWebViewDelegate::setStatusText(const WebString& text) { | 543 void TestWebViewDelegate::setStatusText(const WebString& text) { |
542 if (WebKit::layoutTestMode() && | 544 if (WebKit::layoutTestMode() && |
543 shell_->layout_test_controller()->ShouldDumpStatusCallbacks()) { | 545 shell_->layout_test_controller()->ShouldDumpStatusCallbacks()) { |
544 // When running tests, write to stdout. | 546 // When running tests, write to stdout. |
545 printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", text.utf8().data()
); | 547 printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", text.utf8().data()
); |
546 } | 548 } |
547 } | 549 } |
548 | 550 |
549 void TestWebViewDelegate::startDragging( | 551 void TestWebViewDelegate::startDragging( |
550 const WebPoint& mouse_coords, const WebDragData& data, | 552 const WebPoint& from, const WebDragData& data, |
551 WebDragOperationsMask mask) { | 553 WebDragOperationsMask allowed_mask) { |
| 554 startDragging(data, allowed_mask, WebImage(), WebPoint()); |
| 555 } |
| 556 |
| 557 void TestWebViewDelegate::startDragging( |
| 558 const WebDragData& data, |
| 559 WebDragOperationsMask mask, |
| 560 const WebImage& image, |
| 561 const WebPoint& image_offset) { |
552 if (WebKit::layoutTestMode()) { | 562 if (WebKit::layoutTestMode()) { |
553 WebDragData mutable_drag_data = data; | 563 WebDragData mutable_drag_data = data; |
554 if (shell_->layout_test_controller()->ShouldAddFileToPasteboard()) { | 564 if (shell_->layout_test_controller()->ShouldAddFileToPasteboard()) { |
555 // Add a file called DRTFakeFile to the drag&drop clipboard. | 565 // Add a file called DRTFakeFile to the drag&drop clipboard. |
556 AddDRTFakeFileToDataObject(&mutable_drag_data); | 566 AddDRTFakeFileToDataObject(&mutable_drag_data); |
557 } | 567 } |
558 | 568 |
559 // When running a test, we need to fake a drag drop operation otherwise | 569 // When running a test, we need to fake a drag drop operation otherwise |
560 // Windows waits for real mouse events to know when the drag is over. | 570 // Windows waits for real mouse events to know when the drag is over. |
561 shell_->event_sending_controller()->DoDragDrop( | 571 shell_->event_sending_controller()->DoDragDrop( |
562 mouse_coords, mutable_drag_data, mask); | 572 image_offset, mutable_drag_data, mask); |
563 } else { | 573 } else { |
564 // TODO(tc): Drag and drop is disabled in the test shell because we need | 574 // TODO(tc): Drag and drop is disabled in the test shell because we need |
565 // to be able to convert from WebDragData to an IDataObject. | 575 // to be able to convert from WebDragData to an IDataObject. |
566 //if (!drag_delegate_) | 576 //if (!drag_delegate_) |
567 // drag_delegate_ = new TestDragDelegate(shell_->webViewWnd(), | 577 // drag_delegate_ = new TestDragDelegate(shell_->webViewWnd(), |
568 // shell_->webView()); | 578 // shell_->webView()); |
569 //const DWORD ok_effect = DROPEFFECT_COPY | DROPEFFECT_LINK | DROPEFFECT_MOV
E; | 579 //const DWORD ok_effect = DROPEFFECT_COPY | DROPEFFECT_LINK | DROPEFFECT_MOV
E; |
570 //DWORD effect; | 580 //DWORD effect; |
571 //HRESULT res = DoDragDrop(drop_data.data_object, drag_delegate_.get(), | 581 //HRESULT res = DoDragDrop(drop_data.data_object, drag_delegate_.get(), |
572 // ok_effect, &effect); | 582 // ok_effect, &effect); |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 } | 1209 } |
1200 | 1210 |
1201 void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { | 1211 void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { |
1202 fake_rect_ = rect; | 1212 fake_rect_ = rect; |
1203 using_fake_rect_ = true; | 1213 using_fake_rect_ = true; |
1204 } | 1214 } |
1205 | 1215 |
1206 WebRect TestWebViewDelegate::fake_window_rect() { | 1216 WebRect TestWebViewDelegate::fake_window_rect() { |
1207 return fake_rect_; | 1217 return fake_rect_; |
1208 } | 1218 } |
OLD | NEW |