OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 33 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
34 #include "chrome/browser/policy/enterprise_install_attributes.h" | 34 #include "chrome/browser/policy/enterprise_install_attributes.h" |
35 #include "chrome/browser/prefs/pref_service.h" | 35 #include "chrome/browser/prefs/pref_service.h" |
36 #include "chrome/browser/ui/browser_window.h" | 36 #include "chrome/browser/ui/browser_window.h" |
37 #include "chrome/browser/ui/dialog_style.h" | 37 #include "chrome/browser/ui/dialog_style.h" |
38 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 38 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
39 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
40 #include "chromeos/dbus/dbus_thread_manager.h" | 40 #include "chromeos/dbus/dbus_thread_manager.h" |
41 #include "chromeos/dbus/power_manager_client.h" | 41 #include "chromeos/dbus/power_manager_client.h" |
42 #include "chromeos/dbus/update_engine_client.h" | 42 #include "chromeos/dbus/update_engine_client.h" |
43 #include "content/public/browser/web_contents.h" | |
43 #include "net/base/network_change_notifier.h" | 44 #include "net/base/network_change_notifier.h" |
44 #include "policy/policy_constants.h" | 45 #include "policy/policy_constants.h" |
45 #include "ui/views/widget/widget.h" | 46 #include "ui/views/widget/widget.h" |
46 | 47 |
47 using chromeos::CrosLibrary; | 48 using chromeos::CrosLibrary; |
48 using chromeos::DBusThreadManager; | 49 using chromeos::DBusThreadManager; |
49 using chromeos::NetworkLibrary; | 50 using chromeos::NetworkLibrary; |
50 using chromeos::UpdateEngineClient; | 51 using chromeos::UpdateEngineClient; |
51 using chromeos::UserManager; | 52 using chromeos::UserManager; |
52 | 53 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 std::string username, password; | 283 std::string username, password; |
283 if (!args->GetString("username", &username) || | 284 if (!args->GetString("username", &username) || |
284 !args->GetString("password", &password)) { | 285 !args->GetString("password", &password)) { |
285 AutomationJSONReply(this, reply_message).SendError( | 286 AutomationJSONReply(this, reply_message).SendError( |
286 "Invalid or missing args."); | 287 "Invalid or missing args."); |
287 return; | 288 return; |
288 } | 289 } |
289 | 290 |
290 chromeos::ExistingUserController* controller = | 291 chromeos::ExistingUserController* controller = |
291 chromeos::ExistingUserController::current_controller(); | 292 chromeos::ExistingUserController::current_controller(); |
293 if (!controller) { | |
294 AutomationJSONReply(this, reply_message).SendError( | |
295 "Unable to access ExistingUserController"); | |
296 return; | |
297 } | |
292 | 298 |
293 // Set up an observer (it will delete itself). | 299 // Set up an observer (it will delete itself). |
294 new LoginObserver(controller, this, reply_message); | 300 new LoginObserver(controller, this, reply_message); |
295 | 301 |
296 // WebUI login. | 302 // WebUI login. |
297 chromeos::WebUILoginDisplay* webui_login_display = | 303 chromeos::WebUILoginDisplay* webui_login_display = |
298 static_cast<chromeos::WebUILoginDisplay*>(controller->login_display()); | 304 static_cast<chromeos::WebUILoginDisplay*>(controller->login_display()); |
299 LOG(ERROR) << "TestingAutomationProvider::Login ShowSigninScreenForCreds(" | 305 LOG(ERROR) << "TestingAutomationProvider::Login ShowSigninScreenForCreds(" |
300 << username << ", " << password << ")"; | 306 << username << ", " << password << ")"; |
301 | 307 |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
947 AutomationJSONReply(this, reply_message).SendError( | 953 AutomationJSONReply(this, reply_message).SendError( |
948 "Unable to access EnterpriseEnrollmentScreen"); | 954 "Unable to access EnterpriseEnrollmentScreen"); |
949 return; | 955 return; |
950 } | 956 } |
951 // Set up an observer (it will delete itself). | 957 // Set up an observer (it will delete itself). |
952 new EnrollmentObserver(this, reply_message, enroll_screen->GetActor(), | 958 new EnrollmentObserver(this, reply_message, enroll_screen->GetActor(), |
953 enroll_screen); | 959 enroll_screen); |
954 enroll_screen->GetActor()->SubmitTestCredentials(user, password); | 960 enroll_screen->GetActor()->SubmitTestCredentials(user, password); |
955 } | 961 } |
956 | 962 |
963 void TestingAutomationProvider::ExecuteJavascriptInLoginWebUI( | |
964 DictionaryValue* args, IPC::Message* reply_message) { | |
965 std::string javascript, frame_xpath; | |
966 const UserManager* user_manager = UserManager::Get(); | |
dennis_jeffrey
2012/04/28 16:44:05
move this down below right before line 977
craigdh
2012/04/30 18:41:32
Done.
| |
967 if (!args->GetString("javascript", &javascript)) { | |
968 AutomationJSONReply(this, reply_message) | |
969 .SendError("'javascript' missing or invalid"); | |
970 return; | |
971 } | |
972 if (!args->GetString("frame_xpath", &frame_xpath)) { | |
973 AutomationJSONReply(this, reply_message) | |
974 .SendError("'frame_xpath' missing or invalid"); | |
975 return; | |
976 } | |
977 if (!user_manager) { | |
978 AutomationJSONReply(this, reply_message).SendError( | |
979 "No user manager!"); | |
980 return; | |
981 } | |
982 if (user_manager->IsUserLoggedIn()) { | |
983 AutomationJSONReply(this, reply_message).SendError( | |
984 "User is already logged in."); | |
985 return; | |
986 } | |
987 chromeos::ExistingUserController* controller = | |
988 chromeos::ExistingUserController::current_controller(); | |
989 chromeos::WebUILoginDisplayHost* webui_login_display_host = | |
990 static_cast<chromeos::WebUILoginDisplayHost*>( | |
991 controller->login_display_host()); | |
dennis_jeffrey
2012/04/28 16:44:05
is it safe to assume 'controller' exists here? Yo
craigdh
2012/04/30 18:41:32
Done.
| |
992 content::WebContents* web_contents = | |
993 webui_login_display_host->GetOobeUI()->web_ui()->GetWebContents(); | |
994 | |
995 new DomOperationMessageSender(this, reply_message, true); | |
996 ExecuteJavascriptInRenderViewFrame(ASCIIToUTF16(frame_xpath), | |
997 ASCIIToUTF16(javascript), | |
998 reply_message, | |
999 web_contents->GetRenderViewHost()); | |
1000 } | |
1001 | |
957 void TestingAutomationProvider::GetEnterprisePolicyInfo( | 1002 void TestingAutomationProvider::GetEnterprisePolicyInfo( |
958 DictionaryValue* args, IPC::Message* reply_message) { | 1003 DictionaryValue* args, IPC::Message* reply_message) { |
959 AutomationJSONReply reply(this, reply_message); | 1004 AutomationJSONReply reply(this, reply_message); |
960 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 1005 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
961 | 1006 |
962 policy::BrowserPolicyConnector* connector = | 1007 policy::BrowserPolicyConnector* connector = |
963 g_browser_process->browser_policy_connector(); | 1008 g_browser_process->browser_policy_connector(); |
964 if (!connector) { | 1009 if (!connector) { |
965 reply.SendError("Unable to access BrowserPolicyConnector"); | 1010 reply.SendError("Unable to access BrowserPolicyConnector"); |
966 return; | 1011 return; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1195 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 1240 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
1196 AddObserver(power_manager_observer_); | 1241 AddObserver(power_manager_observer_); |
1197 } | 1242 } |
1198 | 1243 |
1199 void TestingAutomationProvider::RemoveChromeosObservers() { | 1244 void TestingAutomationProvider::RemoveChromeosObservers() { |
1200 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 1245 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
1201 RemoveObserver(power_manager_observer_); | 1246 RemoveObserver(power_manager_observer_); |
1202 delete power_manager_observer_; | 1247 delete power_manager_observer_; |
1203 power_manager_observer_ = NULL; | 1248 power_manager_observer_ = NULL; |
1204 } | 1249 } |
OLD | NEW |