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 definition for LayoutTestController. | 5 // This file contains the definition for LayoutTestController. |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "webkit/tools/test_shell/layout_test_controller.h" | 9 #include "webkit/tools/test_shell/layout_test_controller.h" |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" | 17 #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" |
18 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 18 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
19 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" | 19 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" |
20 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" | 20 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" |
21 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h" | 21 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h" |
22 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" | 22 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" |
23 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" | 23 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" |
24 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" | 24 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" |
25 #include "webkit/glue/dom_operations.h" | 25 #include "webkit/glue/dom_operations.h" |
26 #include "webkit/glue/webkit_glue.h" | 26 #include "webkit/glue/webkit_glue.h" |
27 #include "webkit/glue/webpreferences.h" | 27 #include "webkit/glue/webpreferences.h" |
| 28 #include "webkit/tools/test_shell/notification_presenter.h" |
28 #include "webkit/tools/test_shell/simple_database_system.h" | 29 #include "webkit/tools/test_shell/simple_database_system.h" |
29 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 30 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
30 #include "webkit/tools/test_shell/test_navigation_controller.h" | 31 #include "webkit/tools/test_shell/test_navigation_controller.h" |
31 #include "webkit/tools/test_shell/test_shell.h" | 32 #include "webkit/tools/test_shell/test_shell.h" |
32 #include "webkit/tools/test_shell/test_shell_devtools_agent.h" | 33 #include "webkit/tools/test_shell/test_shell_devtools_agent.h" |
33 #include "webkit/tools/test_shell/test_webview_delegate.h" | 34 #include "webkit/tools/test_shell/test_webview_delegate.h" |
34 | 35 |
35 using std::string; | 36 using std::string; |
36 using std::wstring; | 37 using std::wstring; |
37 | 38 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 BindMethod("setWillSendRequestReturnsNull", &LayoutTestController::setWillSend
RequestReturnsNull); | 129 BindMethod("setWillSendRequestReturnsNull", &LayoutTestController::setWillSend
RequestReturnsNull); |
129 BindMethod("whiteListAccessFromOrigin", &LayoutTestController::whiteListAccess
FromOrigin); | 130 BindMethod("whiteListAccessFromOrigin", &LayoutTestController::whiteListAccess
FromOrigin); |
130 BindMethod("clearAllDatabases", &LayoutTestController::clearAllDatabases); | 131 BindMethod("clearAllDatabases", &LayoutTestController::clearAllDatabases); |
131 BindMethod("setDatabaseQuota", &LayoutTestController::setDatabaseQuota); | 132 BindMethod("setDatabaseQuota", &LayoutTestController::setDatabaseQuota); |
132 BindMethod("setPOSIXLocale", &LayoutTestController::setPOSIXLocale); | 133 BindMethod("setPOSIXLocale", &LayoutTestController::setPOSIXLocale); |
133 BindMethod("counterValueForElementById", &LayoutTestController::counterValueFo
rElementById); | 134 BindMethod("counterValueForElementById", &LayoutTestController::counterValueFo
rElementById); |
134 BindMethod("addUserScript", &LayoutTestController::addUserScript); | 135 BindMethod("addUserScript", &LayoutTestController::addUserScript); |
135 BindMethod("pageNumberForElementById", &LayoutTestController::pageNumberForEle
mentById); | 136 BindMethod("pageNumberForElementById", &LayoutTestController::pageNumberForEle
mentById); |
136 BindMethod("numberOfPages", &LayoutTestController::numberOfPages); | 137 BindMethod("numberOfPages", &LayoutTestController::numberOfPages); |
137 BindMethod("dumpSelectionRect", &LayoutTestController::dumpSelectionRect); | 138 BindMethod("dumpSelectionRect", &LayoutTestController::dumpSelectionRect); |
| 139 BindMethod("grantDesktopNotificationPermission", &LayoutTestController::grantD
esktopNotificationPermission); |
138 | 140 |
139 // The following are stubs. | 141 // The following are stubs. |
140 BindMethod("dumpAsWebArchive", &LayoutTestController::dumpAsWebArchive); | 142 BindMethod("dumpAsWebArchive", &LayoutTestController::dumpAsWebArchive); |
141 BindMethod("setMainFrameIsFirstResponder", &LayoutTestController::setMainFrame
IsFirstResponder); | 143 BindMethod("setMainFrameIsFirstResponder", &LayoutTestController::setMainFrame
IsFirstResponder); |
142 BindMethod("display", &LayoutTestController::display); | 144 BindMethod("display", &LayoutTestController::display); |
143 BindMethod("testRepaint", &LayoutTestController::testRepaint); | 145 BindMethod("testRepaint", &LayoutTestController::testRepaint); |
144 BindMethod("repaintSweepHorizontally", &LayoutTestController::repaintSweepHori
zontally); | 146 BindMethod("repaintSweepHorizontally", &LayoutTestController::repaintSweepHori
zontally); |
145 BindMethod("clearBackForwardList", &LayoutTestController::clearBackForwardList
); | 147 BindMethod("clearBackForwardList", &LayoutTestController::clearBackForwardList
); |
146 BindMethod("keepWebHistory", &LayoutTestController::keepWebHistory); | 148 BindMethod("keepWebHistory", &LayoutTestController::keepWebHistory); |
147 BindMethod("storeWebScriptObject", &LayoutTestController::storeWebScriptObject
); | 149 BindMethod("storeWebScriptObject", &LayoutTestController::storeWebScriptObject
); |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 // We don't use the WebKit icon database. | 820 // We don't use the WebKit icon database. |
819 result->SetNull(); | 821 result->SetNull(); |
820 } | 822 } |
821 | 823 |
822 void LayoutTestController::callShouldCloseOnWebView( | 824 void LayoutTestController::callShouldCloseOnWebView( |
823 const CppArgumentList& args, CppVariant* result) { | 825 const CppArgumentList& args, CppVariant* result) { |
824 bool rv = shell_->webView()->dispatchBeforeUnloadEvent(); | 826 bool rv = shell_->webView()->dispatchBeforeUnloadEvent(); |
825 result->Set(rv); | 827 result->Set(rv); |
826 } | 828 } |
827 | 829 |
| 830 void LayoutTestController::grantDesktopNotificationPermission( |
| 831 const CppArgumentList& args, CppVariant* result) { |
| 832 if (args.size() != 1 || !args[0].isString()) { |
| 833 result->Set(false); |
| 834 return; |
| 835 } |
| 836 std::string origin = args[0].ToString(); |
| 837 shell_->notification_presenter()->grantPermission(origin); |
| 838 result->Set(true); |
| 839 } |
| 840 |
828 // | 841 // |
829 // Unimplemented stubs | 842 // Unimplemented stubs |
830 // | 843 // |
831 | 844 |
832 void LayoutTestController::dumpAsWebArchive( | 845 void LayoutTestController::dumpAsWebArchive( |
833 const CppArgumentList& args, CppVariant* result) { | 846 const CppArgumentList& args, CppVariant* result) { |
834 result->SetNull(); | 847 result->SetNull(); |
835 } | 848 } |
836 | 849 |
837 void LayoutTestController::setMainFrameIsFirstResponder( | 850 void LayoutTestController::setMainFrameIsFirstResponder( |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 } | 1224 } |
1212 | 1225 |
1213 void LayoutTestController::addUserScript(const CppArgumentList& args, | 1226 void LayoutTestController::addUserScript(const CppArgumentList& args, |
1214 CppVariant* result) { | 1227 CppVariant* result) { |
1215 result->SetNull(); | 1228 result->SetNull(); |
1216 if (args.size() < 1 || !args[0].isString() || !args[1].isBool()) | 1229 if (args.size() < 1 || !args[0].isString() || !args[1].isBool()) |
1217 return; | 1230 return; |
1218 shell_->webView()->addUserScript(WebString::fromUTF8(args[0].ToString()), | 1231 shell_->webView()->addUserScript(WebString::fromUTF8(args[0].ToString()), |
1219 args[1].ToBoolean()); | 1232 args[1].ToBoolean()); |
1220 } | 1233 } |
OLD | NEW |