Chromium Code Reviews| 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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 917 g_browser_process->browser_policy_connector(); | 917 g_browser_process->browser_policy_connector(); |
| 918 if (!connector) { | 918 if (!connector) { |
| 919 reply.SendError("Unable to access BrowserPolicyConnector"); | 919 reply.SendError("Unable to access BrowserPolicyConnector"); |
| 920 return; | 920 return; |
| 921 } | 921 } |
| 922 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 922 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 923 return_value->SetBoolean("enterprise", connector->IsEnterpriseManaged()); | 923 return_value->SetBoolean("enterprise", connector->IsEnterpriseManaged()); |
| 924 reply.SendSuccess(return_value.get()); | 924 reply.SendSuccess(return_value.get()); |
| 925 } | 925 } |
| 926 | 926 |
| 927 void TestingAutomationProvider::EnrollEnterpriseDevice( | 927 void TestingAutomationProvider::ShowEnterpriseWizard( |
| 928 DictionaryValue* args, IPC::Message* reply_message) { | 928 DictionaryValue* args, IPC::Message* reply_message) { |
| 929 std::string user, password; | 929 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 = | 930 chromeos::ExistingUserController* user_controller = |
| 937 chromeos::ExistingUserController::current_controller(); | 931 chromeos::ExistingUserController::current_controller(); |
| 938 if (!user_controller) { | 932 if (!user_controller) { |
| 939 AutomationJSONReply(this, reply_message).SendError( | 933 reply.SendError("Unable to access ExistingUserController"); |
| 940 "Unable to access ExistingUserController"); | |
| 941 return; | 934 return; |
| 942 } | 935 } |
| 943 user_controller->login_display_host()->StartWizard( | 936 user_controller->login_display_host()->StartWizard( |
| 944 chromeos::WizardController::kEnterpriseEnrollmentScreenName, | 937 chromeos::WizardController::kEnterpriseEnrollmentScreenName, |
| 945 NULL); | 938 NULL); |
| 946 chromeos::WizardController* wizard_controller = | 939 chromeos::WizardController* wizard_controller = |
| 947 chromeos::WizardController::default_controller(); | 940 chromeos::WizardController::default_controller(); |
| 948 if (!wizard_controller) { | 941 if (!wizard_controller) { |
| 942 reply.SendError("Unable to access WizardController"); | |
| 943 return; | |
| 944 } | |
| 945 chromeos::EnterpriseEnrollmentScreen* enroll_screen = | |
| 946 wizard_controller->GetEnterpriseEnrollmentScreen(); | |
| 947 if (!enroll_screen) { | |
| 948 reply.SendError("Unable to access EnterpriseEnrollmentScreen"); | |
| 949 return; | |
| 950 } | |
|
Mattias Nissler (ping if slow)
2012/05/25 13:17:22
The steps for getting the enrollment screen are no
craigdh
2012/05/25 23:24:47
Done.
| |
| 951 enroll_screen->GetActor()->Show(); | |
| 952 reply.SendSuccess(NULL); | |
| 953 } | |
| 954 | |
| 955 void TestingAutomationProvider::AddEnrollmentObserver( | |
| 956 DictionaryValue* args, IPC::Message* reply_message) { | |
| 957 AutomationJSONReply reply(this, reply_message); | |
| 958 chromeos::WizardController* wizard_controller = | |
| 959 chromeos::WizardController::default_controller(); | |
| 960 if (!wizard_controller) { | |
| 949 AutomationJSONReply(this, reply_message).SendError( | 961 AutomationJSONReply(this, reply_message).SendError( |
| 950 "Unable to access WizardController"); | 962 "Unable to access WizardController"); |
| 951 return; | 963 return; |
| 952 } | 964 } |
| 953 chromeos::EnterpriseEnrollmentScreen* enroll_screen = | 965 chromeos::EnterpriseEnrollmentScreen* enroll_screen = |
| 954 wizard_controller->GetEnterpriseEnrollmentScreen(); | 966 wizard_controller->GetEnterpriseEnrollmentScreen(); |
| 955 if (!enroll_screen) { | 967 if (!enroll_screen) { |
| 956 AutomationJSONReply(this, reply_message).SendError( | 968 AutomationJSONReply(this, reply_message).SendError( |
| 957 "Unable to access EnterpriseEnrollmentScreen"); | 969 "Unable to access EnterpriseEnrollmentScreen"); |
| 958 return; | 970 return; |
| 959 } | 971 } |
| 960 // Set up an observer (it will delete itself). | 972 if (!automation_event_queue_.get()) |
| 961 new EnrollmentObserver(this, reply_message, enroll_screen->GetActor(), | 973 automation_event_queue_.reset(new AutomationEventQueue); |
| 962 enroll_screen); | 974 |
| 963 enroll_screen->GetActor()->SubmitTestCredentials(user, password); | 975 int observer_id = automation_event_queue_->AddObserver( |
| 976 new EnrollmentEventObserver(automation_event_queue_.get(), | |
| 977 enroll_screen->GetActor())); | |
| 978 | |
| 979 // Return the observer's id. | |
| 980 DictionaryValue return_value; | |
| 981 return_value.SetInteger("observer_id", observer_id); | |
| 982 reply.SendSuccess(&return_value); | |
| 964 } | 983 } |
| 965 | 984 |
| 966 void TestingAutomationProvider::ExecuteJavascriptInOOBEWebUI( | 985 void TestingAutomationProvider::ExecuteJavascriptInOOBEWebUI( |
| 967 DictionaryValue* args, IPC::Message* reply_message) { | 986 DictionaryValue* args, IPC::Message* reply_message) { |
| 968 std::string javascript, frame_xpath; | 987 std::string javascript, frame_xpath; |
| 969 if (!args->GetString("javascript", &javascript)) { | 988 if (!args->GetString("javascript", &javascript)) { |
| 970 AutomationJSONReply(this, reply_message) | 989 AutomationJSONReply(this, reply_message) |
| 971 .SendError("'javascript' missing or invalid"); | 990 .SendError("'javascript' missing or invalid"); |
| 972 return; | 991 return; |
| 973 } | 992 } |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1248 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 1267 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 1249 AddObserver(power_manager_observer_); | 1268 AddObserver(power_manager_observer_); |
| 1250 } | 1269 } |
| 1251 | 1270 |
| 1252 void TestingAutomationProvider::RemoveChromeosObservers() { | 1271 void TestingAutomationProvider::RemoveChromeosObservers() { |
| 1253 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 1272 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 1254 RemoveObserver(power_manager_observer_); | 1273 RemoveObserver(power_manager_observer_); |
| 1255 delete power_manager_observer_; | 1274 delete power_manager_observer_; |
| 1256 power_manager_observer_ = NULL; | 1275 power_manager_observer_ = NULL; |
| 1257 } | 1276 } |
| OLD | NEW |