| 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::ExecuteJavascriptInOOBEWebUI( |
| 964 DictionaryValue* args, IPC::Message* reply_message) { |
| 965 std::string javascript, frame_xpath; |
| 966 if (!args->GetString("javascript", &javascript)) { |
| 967 AutomationJSONReply(this, reply_message) |
| 968 .SendError("'javascript' missing or invalid"); |
| 969 return; |
| 970 } |
| 971 if (!args->GetString("frame_xpath", &frame_xpath)) { |
| 972 AutomationJSONReply(this, reply_message) |
| 973 .SendError("'frame_xpath' missing or invalid"); |
| 974 return; |
| 975 } |
| 976 const UserManager* user_manager = UserManager::Get(); |
| 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 if (!controller) { |
| 990 AutomationJSONReply(this, reply_message).SendError( |
| 991 "Unable to access ExistingUserController"); |
| 992 return; |
| 993 } |
| 994 chromeos::WebUILoginDisplayHost* webui_login_display_host = |
| 995 static_cast<chromeos::WebUILoginDisplayHost*>( |
| 996 controller->login_display_host()); |
| 997 content::WebContents* web_contents = |
| 998 webui_login_display_host->GetOobeUI()->web_ui()->GetWebContents(); |
| 999 |
| 1000 new DomOperationMessageSender(this, reply_message, true); |
| 1001 ExecuteJavascriptInRenderViewFrame(ASCIIToUTF16(frame_xpath), |
| 1002 ASCIIToUTF16(javascript), |
| 1003 reply_message, |
| 1004 web_contents->GetRenderViewHost()); |
| 1005 } |
| 1006 |
| 957 void TestingAutomationProvider::GetEnterprisePolicyInfo( | 1007 void TestingAutomationProvider::GetEnterprisePolicyInfo( |
| 958 DictionaryValue* args, IPC::Message* reply_message) { | 1008 DictionaryValue* args, IPC::Message* reply_message) { |
| 959 AutomationJSONReply reply(this, reply_message); | 1009 AutomationJSONReply reply(this, reply_message); |
| 960 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 1010 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 961 | 1011 |
| 962 policy::BrowserPolicyConnector* connector = | 1012 policy::BrowserPolicyConnector* connector = |
| 963 g_browser_process->browser_policy_connector(); | 1013 g_browser_process->browser_policy_connector(); |
| 964 if (!connector) { | 1014 if (!connector) { |
| 965 reply.SendError("Unable to access BrowserPolicyConnector"); | 1015 reply.SendError("Unable to access BrowserPolicyConnector"); |
| 966 return; | 1016 return; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 1245 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 1196 AddObserver(power_manager_observer_); | 1246 AddObserver(power_manager_observer_); |
| 1197 } | 1247 } |
| 1198 | 1248 |
| 1199 void TestingAutomationProvider::RemoveChromeosObservers() { | 1249 void TestingAutomationProvider::RemoveChromeosObservers() { |
| 1200 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 1250 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 1201 RemoveObserver(power_manager_observer_); | 1251 RemoveObserver(power_manager_observer_); |
| 1202 delete power_manager_observer_; | 1252 delete power_manager_observer_; |
| 1203 power_manager_observer_ = NULL; | 1253 power_manager_observer_ = NULL; |
| 1204 } | 1254 } |
| OLD | NEW |