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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "third_party/WebKit/WebKit/chromium/public/WebDeviceOrientationClientMo
ck.h" | 26 #include "third_party/WebKit/WebKit/chromium/public/WebDeviceOrientationClientMo
ck.h" |
27 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" | 27 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" |
28 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" | 28 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" |
29 #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" | 29 #include "third_party/WebKit/WebKit/chromium/public/WebDataSource.h" |
30 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" | 30 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" |
31 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" | 31 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" |
32 #include "third_party/WebKit/WebKit/chromium/public/WebImage.h" | 32 #include "third_party/WebKit/WebKit/chromium/public/WebImage.h" |
33 #include "third_party/WebKit/WebKit/chromium/public/WebFileError.h" | 33 #include "third_party/WebKit/WebKit/chromium/public/WebFileError.h" |
34 #include "third_party/WebKit/WebKit/chromium/public/WebFileSystemCallbacks.h" | 34 #include "third_party/WebKit/WebKit/chromium/public/WebFileSystemCallbacks.h" |
35 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 35 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
| 36 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationClientMock.h" |
36 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" | 37 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" |
37 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" | 38 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" |
38 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" | 39 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" |
39 #include "third_party/WebKit/WebKit/chromium/public/WebNotificationPresenter.h" | 40 #include "third_party/WebKit/WebKit/chromium/public/WebNotificationPresenter.h" |
40 #include "third_party/WebKit/WebKit/chromium/public/WebPluginParams.h" | 41 #include "third_party/WebKit/WebKit/chromium/public/WebPluginParams.h" |
41 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" | 42 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" |
42 #include "third_party/WebKit/WebKit/chromium/public/WebPopupMenu.h" | 43 #include "third_party/WebKit/WebKit/chromium/public/WebPopupMenu.h" |
43 #include "third_party/WebKit/WebKit/chromium/public/WebRange.h" | 44 #include "third_party/WebKit/WebKit/chromium/public/WebRange.h" |
44 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" | 45 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" |
45 #include "third_party/WebKit/WebKit/chromium/public/WebSpeechInputController.h" | 46 #include "third_party/WebKit/WebKit/chromium/public/WebSpeechInputController.h" |
(...skipping 16 matching lines...) Expand all Loading... |
62 #include "webkit/glue/webpreferences.h" | 63 #include "webkit/glue/webpreferences.h" |
63 #include "webkit/glue/window_open_disposition.h" | 64 #include "webkit/glue/window_open_disposition.h" |
64 #include "webkit/plugins/npapi/webplugin_impl.h" | 65 #include "webkit/plugins/npapi/webplugin_impl.h" |
65 #include "webkit/plugins/npapi/plugin_list.h" | 66 #include "webkit/plugins/npapi/plugin_list.h" |
66 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 67 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
67 #include "webkit/tools/test_shell/accessibility_controller.h" | 68 #include "webkit/tools/test_shell/accessibility_controller.h" |
68 #include "webkit/tools/test_shell/mock_spellcheck.h" | 69 #include "webkit/tools/test_shell/mock_spellcheck.h" |
69 #include "webkit/tools/test_shell/notification_presenter.h" | 70 #include "webkit/tools/test_shell/notification_presenter.h" |
70 #include "webkit/tools/test_shell/simple_appcache_system.h" | 71 #include "webkit/tools/test_shell/simple_appcache_system.h" |
71 #include "webkit/tools/test_shell/simple_file_system.h" | 72 #include "webkit/tools/test_shell/simple_file_system.h" |
72 #include "webkit/tools/test_shell/test_geolocation_service.h" | |
73 #include "webkit/tools/test_shell/test_navigation_controller.h" | 73 #include "webkit/tools/test_shell/test_navigation_controller.h" |
74 #include "webkit/tools/test_shell/test_shell.h" | 74 #include "webkit/tools/test_shell/test_shell.h" |
75 #include "webkit/tools/test_shell/test_web_worker.h" | 75 #include "webkit/tools/test_shell/test_web_worker.h" |
76 | 76 |
77 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
78 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationClientMock.h" | |
79 #endif | |
80 | |
81 #if defined(OS_WIN) | 77 #if defined(OS_WIN) |
82 // TODO(port): make these files work everywhere. | 78 // TODO(port): make these files work everywhere. |
83 #include "webkit/tools/test_shell/drag_delegate.h" | 79 #include "webkit/tools/test_shell/drag_delegate.h" |
84 #include "webkit/tools/test_shell/drop_delegate.h" | 80 #include "webkit/tools/test_shell/drop_delegate.h" |
85 #endif | 81 #endif |
86 | 82 |
87 using appcache::WebApplicationCacheHostImpl; | 83 using appcache::WebApplicationCacheHostImpl; |
88 using WebKit::WebAccessibilityObject; | 84 using WebKit::WebAccessibilityObject; |
89 using WebKit::WebApplicationCacheHost; | 85 using WebKit::WebApplicationCacheHost; |
90 using WebKit::WebApplicationCacheHostClient; | 86 using WebKit::WebApplicationCacheHostClient; |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 void TestWebViewDelegate::focusAccessibilityObject( | 645 void TestWebViewDelegate::focusAccessibilityObject( |
650 const WebAccessibilityObject& object) { | 646 const WebAccessibilityObject& object) { |
651 shell_->accessibility_controller()->SetFocusedElement(object); | 647 shell_->accessibility_controller()->SetFocusedElement(object); |
652 } | 648 } |
653 | 649 |
654 WebNotificationPresenter* TestWebViewDelegate::notificationPresenter() { | 650 WebNotificationPresenter* TestWebViewDelegate::notificationPresenter() { |
655 return shell_->notification_presenter(); | 651 return shell_->notification_presenter(); |
656 } | 652 } |
657 | 653 |
658 WebKit::WebGeolocationClient* TestWebViewDelegate::geolocationClient() { | 654 WebKit::WebGeolocationClient* TestWebViewDelegate::geolocationClient() { |
659 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
660 return shell_->geolocation_client_mock(); | 655 return shell_->geolocation_client_mock(); |
661 #else | |
662 // TODO(jknotten): Remove once building with ENABLE_CLIENT_BASED_GEOLOCATION. | |
663 NOTREACHED(); | |
664 return 0; | |
665 #endif | |
666 } | 656 } |
667 | 657 |
668 WebKit::WebGeolocationService* TestWebViewDelegate::geolocationService() { | |
669 #if defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
670 NOTREACHED(); | |
671 return 0; | |
672 #else | |
673 return GetTestGeolocationService(); | |
674 #endif | |
675 } | |
676 | |
677 | |
678 WebKit::WebDeviceOrientationClient* | 658 WebKit::WebDeviceOrientationClient* |
679 TestWebViewDelegate::deviceOrientationClient() { | 659 TestWebViewDelegate::deviceOrientationClient() { |
680 return shell_->device_orientation_client_mock(); | 660 return shell_->device_orientation_client_mock(); |
681 } | 661 } |
682 | 662 |
683 WebKit::WebSpeechInputController* TestWebViewDelegate::speechInputController( | 663 WebKit::WebSpeechInputController* TestWebViewDelegate::speechInputController( |
684 WebKit::WebSpeechInputListener* listener) { | 664 WebKit::WebSpeechInputListener* listener) { |
685 return shell_->CreateSpeechInputControllerMock(listener); | 665 return shell_->CreateSpeechInputControllerMock(listener); |
686 } | 666 } |
687 | 667 |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 bool is_permissive) { | 1193 bool is_permissive) { |
1214 policy_delegate_enabled_ = is_custom; | 1194 policy_delegate_enabled_ = is_custom; |
1215 policy_delegate_is_permissive_ = is_permissive; | 1195 policy_delegate_is_permissive_ = is_permissive; |
1216 } | 1196 } |
1217 | 1197 |
1218 void TestWebViewDelegate::WaitForPolicyDelegate() { | 1198 void TestWebViewDelegate::WaitForPolicyDelegate() { |
1219 policy_delegate_enabled_ = true; | 1199 policy_delegate_enabled_ = true; |
1220 policy_delegate_should_notify_done_ = true; | 1200 policy_delegate_should_notify_done_ = true; |
1221 } | 1201 } |
1222 | 1202 |
1223 #if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
1224 void TestWebViewDelegate::SetGeolocationPermission(bool allowed) { | |
1225 GetTestGeolocationService()->SetGeolocationPermission(allowed); | |
1226 } | |
1227 #endif | |
1228 | |
1229 // Private methods ----------------------------------------------------------- | 1203 // Private methods ----------------------------------------------------------- |
1230 | 1204 |
1231 void TestWebViewDelegate::UpdateAddressBar(WebView* webView) { | 1205 void TestWebViewDelegate::UpdateAddressBar(WebView* webView) { |
1232 WebFrame* main_frame = webView->mainFrame(); | 1206 WebFrame* main_frame = webView->mainFrame(); |
1233 | 1207 |
1234 WebDataSource* data_source = main_frame->dataSource(); | 1208 WebDataSource* data_source = main_frame->dataSource(); |
1235 if (!data_source) | 1209 if (!data_source) |
1236 data_source = main_frame->provisionalDataSource(); | 1210 data_source = main_frame->provisionalDataSource(); |
1237 if (!data_source) | 1211 if (!data_source) |
1238 return; | 1212 return; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 else | 1313 else |
1340 return L"main frame"; | 1314 return L"main frame"; |
1341 } else { | 1315 } else { |
1342 if (name.length()) | 1316 if (name.length()) |
1343 return L"frame \"" + name + L"\""; | 1317 return L"frame \"" + name + L"\""; |
1344 else | 1318 else |
1345 return L"frame (anonymous)"; | 1319 return L"frame (anonymous)"; |
1346 } | 1320 } |
1347 } | 1321 } |
1348 | 1322 |
1349 #if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) | |
1350 TestGeolocationService* TestWebViewDelegate::GetTestGeolocationService() { | |
1351 if (!test_geolocation_service_.get()) | |
1352 test_geolocation_service_.reset(new TestGeolocationService); | |
1353 return test_geolocation_service_.get(); | |
1354 } | |
1355 #endif | |
1356 | |
1357 void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { | 1323 void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { |
1358 fake_rect_ = rect; | 1324 fake_rect_ = rect; |
1359 using_fake_rect_ = true; | 1325 using_fake_rect_ = true; |
1360 } | 1326 } |
1361 | 1327 |
1362 WebRect TestWebViewDelegate::fake_window_rect() { | 1328 WebRect TestWebViewDelegate::fake_window_rect() { |
1363 return fake_rect_; | 1329 return fake_rect_; |
1364 } | 1330 } |
OLD | NEW |