| 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 "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/tray/system_tray_delegate.h" | 8 #include "ash/system/tray/system_tray_delegate.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 policy::PolicyMap::const_iterator i; | 209 policy::PolicyMap::const_iterator i; |
| 210 for (i = policy_map->begin(); i != policy_map->end(); i++) { | 210 for (i = policy_map->begin(); i != policy_map->end(); i++) { |
| 211 if (i->second.level == policy_level) | 211 if (i->second.level == policy_level) |
| 212 dict->Set(i->first, i->second.value->DeepCopy()); | 212 dict->Set(i->first, i->second.value->DeepCopy()); |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 return dict; | 216 return dict; |
| 217 } | 217 } |
| 218 | 218 |
| 219 // Returns the EnterpriseEnrollmentScreen, if it exists. |
| 220 chromeos::EnterpriseEnrollmentScreen* GetEnterpriseEnrollmentScreen() { |
| 221 chromeos::WizardController* wizard_controller = |
| 222 chromeos::WizardController::default_controller(); |
| 223 if (!wizard_controller) |
| 224 return NULL; |
| 225 return wizard_controller->GetEnterpriseEnrollmentScreen(); |
| 226 } |
| 227 |
| 219 // Last reported power status. | 228 // Last reported power status. |
| 220 chromeos::PowerSupplyStatus global_power_status; | 229 chromeos::PowerSupplyStatus global_power_status; |
| 221 | 230 |
| 222 } // namespace | 231 } // namespace |
| 223 | 232 |
| 224 class PowerManagerClientObserverForTesting | 233 class PowerManagerClientObserverForTesting |
| 225 : public chromeos::PowerManagerClient::Observer { | 234 : public chromeos::PowerManagerClient::Observer { |
| 226 public: | 235 public: |
| 227 virtual ~PowerManagerClientObserverForTesting() {} | 236 virtual ~PowerManagerClientObserverForTesting() {} |
| 228 | 237 |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 g_browser_process->browser_policy_connector(); | 926 g_browser_process->browser_policy_connector(); |
| 918 if (!connector) { | 927 if (!connector) { |
| 919 reply.SendError("Unable to access BrowserPolicyConnector"); | 928 reply.SendError("Unable to access BrowserPolicyConnector"); |
| 920 return; | 929 return; |
| 921 } | 930 } |
| 922 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 931 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 923 return_value->SetBoolean("enterprise", connector->IsEnterpriseManaged()); | 932 return_value->SetBoolean("enterprise", connector->IsEnterpriseManaged()); |
| 924 reply.SendSuccess(return_value.get()); | 933 reply.SendSuccess(return_value.get()); |
| 925 } | 934 } |
| 926 | 935 |
| 927 void TestingAutomationProvider::EnrollEnterpriseDevice( | 936 void TestingAutomationProvider::ShowEnterpriseWizard( |
| 928 DictionaryValue* args, IPC::Message* reply_message) { | 937 DictionaryValue* args, IPC::Message* reply_message) { |
| 929 std::string user, password; | 938 AutomationJSONReply reply(this, reply_message); |
| 930 if (!args->GetString("user", &user) || | |
| 931 !args->GetString("password", &password)) { | |
| 932 AutomationJSONReply(this, reply_message) | |
| 933 .SendError("Invalid or missing args."); | |
| 934 return; | |
| 935 } | |
| 936 chromeos::ExistingUserController* user_controller = | 939 chromeos::ExistingUserController* user_controller = |
| 937 chromeos::ExistingUserController::current_controller(); | 940 chromeos::ExistingUserController::current_controller(); |
| 938 if (!user_controller) { | 941 if (!user_controller) { |
| 939 AutomationJSONReply(this, reply_message).SendError( | 942 reply.SendError("Unable to access ExistingUserController"); |
| 940 "Unable to access ExistingUserController"); | |
| 941 return; | 943 return; |
| 942 } | 944 } |
| 943 user_controller->login_display_host()->StartWizard( | 945 user_controller->login_display_host()->StartWizard( |
| 944 chromeos::WizardController::kEnterpriseEnrollmentScreenName, | 946 chromeos::WizardController::kEnterpriseEnrollmentScreenName, |
| 945 NULL); | 947 NULL); |
| 946 chromeos::WizardController* wizard_controller = | 948 chromeos::EnterpriseEnrollmentScreen* enroll_screen = |
| 947 chromeos::WizardController::default_controller(); | 949 GetEnterpriseEnrollmentScreen(); |
| 948 if (!wizard_controller) { | 950 if (!enroll_screen) { |
| 949 AutomationJSONReply(this, reply_message).SendError( | 951 reply.SendError("Unable to access EnterpriseEnrollmentScreen"); |
| 950 "Unable to access WizardController"); | |
| 951 return; | 952 return; |
| 952 } | 953 } |
| 954 enroll_screen->GetActor()->Show(); |
| 955 reply.SendSuccess(NULL); |
| 956 } |
| 957 |
| 958 void TestingAutomationProvider::AddEnrollmentObserver( |
| 959 DictionaryValue* args, IPC::Message* reply_message) { |
| 960 AutomationJSONReply reply(this, reply_message); |
| 953 chromeos::EnterpriseEnrollmentScreen* enroll_screen = | 961 chromeos::EnterpriseEnrollmentScreen* enroll_screen = |
| 954 wizard_controller->GetEnterpriseEnrollmentScreen(); | 962 GetEnterpriseEnrollmentScreen(); |
| 955 if (!enroll_screen) { | 963 if (!enroll_screen) { |
| 956 AutomationJSONReply(this, reply_message).SendError( | 964 AutomationJSONReply(this, reply_message).SendError( |
| 957 "Unable to access EnterpriseEnrollmentScreen"); | 965 "Unable to access EnterpriseEnrollmentScreen"); |
| 958 return; | 966 return; |
| 959 } | 967 } |
| 960 // Set up an observer (it will delete itself). | 968 if (!automation_event_queue_.get()) |
| 961 new EnrollmentObserver(this, reply_message, enroll_screen->GetActor(), | 969 automation_event_queue_.reset(new AutomationEventQueue); |
| 962 enroll_screen); | 970 |
| 963 enroll_screen->GetActor()->SubmitTestCredentials(user, password); | 971 int observer_id = automation_event_queue_->AddObserver( |
| 972 new EnrollmentEventObserver(automation_event_queue_.get(), |
| 973 enroll_screen->GetActor())); |
| 974 |
| 975 // Return the observer's id. |
| 976 DictionaryValue return_value; |
| 977 return_value.SetInteger("observer_id", observer_id); |
| 978 reply.SendSuccess(&return_value); |
| 964 } | 979 } |
| 965 | 980 |
| 966 void TestingAutomationProvider::ExecuteJavascriptInOOBEWebUI( | 981 void TestingAutomationProvider::ExecuteJavascriptInOOBEWebUI( |
| 967 DictionaryValue* args, IPC::Message* reply_message) { | 982 DictionaryValue* args, IPC::Message* reply_message) { |
| 968 std::string javascript, frame_xpath; | 983 std::string javascript, frame_xpath; |
| 969 if (!args->GetString("javascript", &javascript)) { | 984 if (!args->GetString("javascript", &javascript)) { |
| 970 AutomationJSONReply(this, reply_message) | 985 AutomationJSONReply(this, reply_message) |
| 971 .SendError("'javascript' missing or invalid"); | 986 .SendError("'javascript' missing or invalid"); |
| 972 return; | 987 return; |
| 973 } | 988 } |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 1263 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 1249 AddObserver(power_manager_observer_); | 1264 AddObserver(power_manager_observer_); |
| 1250 } | 1265 } |
| 1251 | 1266 |
| 1252 void TestingAutomationProvider::RemoveChromeosObservers() { | 1267 void TestingAutomationProvider::RemoveChromeosObservers() { |
| 1253 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 1268 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 1254 RemoveObserver(power_manager_observer_); | 1269 RemoveObserver(power_manager_observer_); |
| 1255 delete power_manager_observer_; | 1270 delete power_manager_observer_; |
| 1256 power_manager_observer_ = NULL; | 1271 power_manager_observer_ = NULL; |
| 1257 } | 1272 } |
| OLD | NEW |