| 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/new_window_delegate.h" | 7 #include "ash/new_window_delegate.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/system/tray/system_tray_delegate.h" | 9 #include "ash/system/tray/system_tray_delegate.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } // namespace | 71 } // namespace |
| 72 | 72 |
| 73 #if defined(OS_CHROMEOS) | 73 #if defined(OS_CHROMEOS) |
| 74 void TestingAutomationProvider::PowerChanged( | 74 void TestingAutomationProvider::PowerChanged( |
| 75 const power_manager::PowerSupplyProperties& proto) { | 75 const power_manager::PowerSupplyProperties& proto) { |
| 76 power_supply_properties_ = proto; | 76 power_supply_properties_ = proto; |
| 77 } | 77 } |
| 78 #endif | 78 #endif |
| 79 | 79 |
| 80 void TestingAutomationProvider::AcceptOOBENetworkScreen( | 80 void TestingAutomationProvider::AcceptOOBENetworkScreen( |
| 81 DictionaryValue* args, | 81 base::DictionaryValue* args, |
| 82 IPC::Message* reply_message) { | 82 IPC::Message* reply_message) { |
| 83 WizardController* wizard_controller = WizardController::default_controller(); | 83 WizardController* wizard_controller = WizardController::default_controller(); |
| 84 if (!wizard_controller || wizard_controller->current_screen()->GetName() != | 84 if (!wizard_controller || wizard_controller->current_screen()->GetName() != |
| 85 WizardController::kNetworkScreenName) { | 85 WizardController::kNetworkScreenName) { |
| 86 AutomationJSONReply(this, reply_message).SendError( | 86 AutomationJSONReply(this, reply_message).SendError( |
| 87 "Network screen not active."); | 87 "Network screen not active."); |
| 88 return; | 88 return; |
| 89 } | 89 } |
| 90 // Observer will delete itself. | 90 // Observer will delete itself. |
| 91 new WizardControllerObserver(wizard_controller, this, reply_message); | 91 new WizardControllerObserver(wizard_controller, this, reply_message); |
| 92 wizard_controller->GetNetworkScreen()->OnContinuePressed(); | 92 wizard_controller->GetNetworkScreen()->OnContinuePressed(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void TestingAutomationProvider::AcceptOOBEEula(DictionaryValue* args, | 95 void TestingAutomationProvider::AcceptOOBEEula(base::DictionaryValue* args, |
| 96 IPC::Message* reply_message) { | 96 IPC::Message* reply_message) { |
| 97 bool accepted; | 97 bool accepted; |
| 98 bool usage_stats_reporting; | 98 bool usage_stats_reporting; |
| 99 if (!args->GetBoolean("accepted", &accepted) || | 99 if (!args->GetBoolean("accepted", &accepted) || |
| 100 !args->GetBoolean("usage_stats_reporting", &usage_stats_reporting)) { | 100 !args->GetBoolean("usage_stats_reporting", &usage_stats_reporting)) { |
| 101 AutomationJSONReply(this, reply_message).SendError( | 101 AutomationJSONReply(this, reply_message).SendError( |
| 102 "Invalid or missing args."); | 102 "Invalid or missing args."); |
| 103 return; | 103 return; |
| 104 } | 104 } |
| 105 | 105 |
| 106 WizardController* wizard_controller = WizardController::default_controller(); | 106 WizardController* wizard_controller = WizardController::default_controller(); |
| 107 if (!wizard_controller || wizard_controller->current_screen()->GetName() != | 107 if (!wizard_controller || wizard_controller->current_screen()->GetName() != |
| 108 WizardController::kEulaScreenName) { | 108 WizardController::kEulaScreenName) { |
| 109 AutomationJSONReply(this, reply_message).SendError( | 109 AutomationJSONReply(this, reply_message).SendError( |
| 110 "EULA screen not active."); | 110 "EULA screen not active."); |
| 111 return; | 111 return; |
| 112 } | 112 } |
| 113 // Observer will delete itself. | 113 // Observer will delete itself. |
| 114 new WizardControllerObserver(wizard_controller, this, reply_message); | 114 new WizardControllerObserver(wizard_controller, this, reply_message); |
| 115 wizard_controller->GetEulaScreen()->OnExit(accepted, usage_stats_reporting); | 115 wizard_controller->GetEulaScreen()->OnExit(accepted, usage_stats_reporting); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void TestingAutomationProvider::CancelOOBEUpdate(DictionaryValue* args, | 118 void TestingAutomationProvider::CancelOOBEUpdate(base::DictionaryValue* args, |
| 119 IPC::Message* reply_message) { | 119 IPC::Message* reply_message) { |
| 120 if (chromeos::StartupUtils::IsOobeCompleted()) { | 120 if (chromeos::StartupUtils::IsOobeCompleted()) { |
| 121 // Update already finished. | 121 // Update already finished. |
| 122 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 122 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 123 return_value->SetString("next_screen", | 123 return_value->SetString("next_screen", |
| 124 WizardController::kLoginScreenName); | 124 WizardController::kLoginScreenName); |
| 125 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 125 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 126 return; | 126 return; |
| 127 } | 127 } |
| 128 WizardController* wizard_controller = WizardController::default_controller(); | 128 WizardController* wizard_controller = WizardController::default_controller(); |
| 129 if (!wizard_controller || wizard_controller->current_screen()->GetName() != | 129 if (!wizard_controller || wizard_controller->current_screen()->GetName() != |
| 130 WizardController::kUpdateScreenName) { | 130 WizardController::kUpdateScreenName) { |
| 131 AutomationJSONReply(this, reply_message).SendError( | 131 AutomationJSONReply(this, reply_message).SendError( |
| 132 "Update screen not active."); | 132 "Update screen not active."); |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 // Observer will delete itself. | 135 // Observer will delete itself. |
| 136 new WizardControllerObserver(wizard_controller, this, reply_message); | 136 new WizardControllerObserver(wizard_controller, this, reply_message); |
| 137 wizard_controller->GetUpdateScreen()->CancelUpdate(); | 137 wizard_controller->GetUpdateScreen()->CancelUpdate(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void TestingAutomationProvider::GetLoginInfo(DictionaryValue* args, | 140 void TestingAutomationProvider::GetLoginInfo(base::DictionaryValue* args, |
| 141 IPC::Message* reply_message) { | 141 IPC::Message* reply_message) { |
| 142 AutomationJSONReply reply(this, reply_message); | 142 AutomationJSONReply reply(this, reply_message); |
| 143 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 143 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 144 | 144 |
| 145 const UserManager* user_manager = UserManager::Get(); | 145 const UserManager* user_manager = UserManager::Get(); |
| 146 if (!user_manager) | 146 if (!user_manager) |
| 147 reply.SendError("No user manager!"); | 147 reply.SendError("No user manager!"); |
| 148 const chromeos::ScreenLocker* screen_locker = | 148 const chromeos::ScreenLocker* screen_locker = |
| 149 chromeos::ScreenLocker::default_screen_locker(); | 149 chromeos::ScreenLocker::default_screen_locker(); |
| 150 | 150 |
| 151 return_value->SetString("login_ui_type", "webui"); | 151 return_value->SetString("login_ui_type", "webui"); |
| 152 return_value->SetBoolean("is_owner", user_manager->IsCurrentUserOwner()); | 152 return_value->SetBoolean("is_owner", user_manager->IsCurrentUserOwner()); |
| 153 return_value->SetBoolean("is_logged_in", user_manager->IsUserLoggedIn()); | 153 return_value->SetBoolean("is_logged_in", user_manager->IsUserLoggedIn()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 170 return_value->SetInteger("user_image", user->image_index()); | 170 return_value->SetInteger("user_image", user->image_index()); |
| 171 break; | 171 break; |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 reply.SendSuccess(return_value.get()); | 175 reply.SendSuccess(return_value.get()); |
| 176 } | 176 } |
| 177 | 177 |
| 178 // See the note under LoginAsGuest(). CreateAccount() causes a login as guest. | 178 // See the note under LoginAsGuest(). CreateAccount() causes a login as guest. |
| 179 void TestingAutomationProvider::ShowCreateAccountUI( | 179 void TestingAutomationProvider::ShowCreateAccountUI( |
| 180 DictionaryValue* args, IPC::Message* reply_message) { | 180 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 181 ExistingUserController* controller = | 181 ExistingUserController* controller = |
| 182 ExistingUserController::current_controller(); | 182 ExistingUserController::current_controller(); |
| 183 // Return immediately, since we're going to die before the login is finished. | 183 // Return immediately, since we're going to die before the login is finished. |
| 184 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 184 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 185 controller->CreateAccount(); | 185 controller->CreateAccount(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 // Logging in as guest will cause session_manager to restart Chrome with new | 188 // Logging in as guest will cause session_manager to restart Chrome with new |
| 189 // flags. If you used EnableChromeTesting, you will have to call it again. | 189 // flags. If you used EnableChromeTesting, you will have to call it again. |
| 190 void TestingAutomationProvider::LoginAsGuest(DictionaryValue* args, | 190 void TestingAutomationProvider::LoginAsGuest(base::DictionaryValue* args, |
| 191 IPC::Message* reply_message) { | 191 IPC::Message* reply_message) { |
| 192 ExistingUserController* controller = | 192 ExistingUserController* controller = |
| 193 ExistingUserController::current_controller(); | 193 ExistingUserController::current_controller(); |
| 194 // Return immediately, since we're going to die before the login is finished. | 194 // Return immediately, since we're going to die before the login is finished. |
| 195 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 195 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 196 controller->LoginAsGuest(); | 196 controller->LoginAsGuest(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void TestingAutomationProvider::SubmitLoginForm(DictionaryValue* args, | 199 void TestingAutomationProvider::SubmitLoginForm(base::DictionaryValue* args, |
| 200 IPC::Message* reply_message) { | 200 IPC::Message* reply_message) { |
| 201 AutomationJSONReply reply(this, reply_message); | 201 AutomationJSONReply reply(this, reply_message); |
| 202 | 202 |
| 203 std::string username, password; | 203 std::string username, password; |
| 204 if (!args->GetString("username", &username) || | 204 if (!args->GetString("username", &username) || |
| 205 !args->GetString("password", &password)) { | 205 !args->GetString("password", &password)) { |
| 206 reply.SendError("Invalid or missing args."); | 206 reply.SendError("Invalid or missing args."); |
| 207 return; | 207 return; |
| 208 } | 208 } |
| 209 | 209 |
| 210 chromeos::ExistingUserController* controller = | 210 chromeos::ExistingUserController* controller = |
| 211 chromeos::ExistingUserController::current_controller(); | 211 chromeos::ExistingUserController::current_controller(); |
| 212 if (!controller) { | 212 if (!controller) { |
| 213 reply.SendError("Unable to access ExistingUserController"); | 213 reply.SendError("Unable to access ExistingUserController"); |
| 214 return; | 214 return; |
| 215 } | 215 } |
| 216 | 216 |
| 217 // WebUI login. | 217 // WebUI login. |
| 218 chromeos::WebUILoginDisplay* webui_login_display = | 218 chromeos::WebUILoginDisplay* webui_login_display = |
| 219 static_cast<chromeos::WebUILoginDisplay*>(controller->login_display()); | 219 static_cast<chromeos::WebUILoginDisplay*>(controller->login_display()); |
| 220 VLOG(2) << "TestingAutomationProvider::SubmitLoginForm " | 220 VLOG(2) << "TestingAutomationProvider::SubmitLoginForm " |
| 221 << "ShowSigninScreenForCreds(" << username << ", " << password << ")"; | 221 << "ShowSigninScreenForCreds(" << username << ", " << password << ")"; |
| 222 | 222 |
| 223 webui_login_display->ShowSigninScreenForCreds(username, password); | 223 webui_login_display->ShowSigninScreenForCreds(username, password); |
| 224 reply.SendSuccess(NULL); | 224 reply.SendSuccess(NULL); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void TestingAutomationProvider::AddLoginEventObserver( | 227 void TestingAutomationProvider::AddLoginEventObserver( |
| 228 DictionaryValue* args, IPC::Message* reply_message) { | 228 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 229 ExistingUserController* controller = | 229 ExistingUserController* controller = |
| 230 ExistingUserController::current_controller(); | 230 ExistingUserController::current_controller(); |
| 231 AutomationJSONReply reply(this, reply_message); | 231 AutomationJSONReply reply(this, reply_message); |
| 232 if (!controller) { | 232 if (!controller) { |
| 233 // This may happen due to SkipToLogin not being called. | 233 // This may happen due to SkipToLogin not being called. |
| 234 reply.SendError("Unable to access ExistingUserController"); | 234 reply.SendError("Unable to access ExistingUserController"); |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 | 237 |
| 238 if (!automation_event_queue_.get()) | 238 if (!automation_event_queue_.get()) |
| 239 automation_event_queue_.reset(new AutomationEventQueue); | 239 automation_event_queue_.reset(new AutomationEventQueue); |
| 240 | 240 |
| 241 int observer_id = automation_event_queue_->AddObserver( | 241 int observer_id = automation_event_queue_->AddObserver( |
| 242 new LoginEventObserver(automation_event_queue_.get(), this)); | 242 new LoginEventObserver(automation_event_queue_.get(), this)); |
| 243 | 243 |
| 244 // Return the observer's id. | 244 // Return the observer's id. |
| 245 DictionaryValue return_value; | 245 base::DictionaryValue return_value; |
| 246 return_value.SetInteger("observer_id", observer_id); | 246 return_value.SetInteger("observer_id", observer_id); |
| 247 reply.SendSuccess(&return_value); | 247 reply.SendSuccess(&return_value); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void TestingAutomationProvider::SignOut(DictionaryValue* args, | 250 void TestingAutomationProvider::SignOut(base::DictionaryValue* args, |
| 251 IPC::Message* reply_message) { | 251 IPC::Message* reply_message) { |
| 252 ash::Shell::GetInstance()->system_tray_delegate()->SignOut(); | 252 ash::Shell::GetInstance()->system_tray_delegate()->SignOut(); |
| 253 // Sign out has the side effect of restarting the session_manager | 253 // Sign out has the side effect of restarting the session_manager |
| 254 // and chrome, thereby severing the automation channel, so it's | 254 // and chrome, thereby severing the automation channel, so it's |
| 255 // not really necessary to send a reply back. The next line is | 255 // not really necessary to send a reply back. The next line is |
| 256 // for consistency with other methods. | 256 // for consistency with other methods. |
| 257 AutomationJSONReply(this, reply_message).SendSuccess(NULL); | 257 AutomationJSONReply(this, reply_message).SendSuccess(NULL); |
| 258 } | 258 } |
| 259 | 259 |
| 260 void TestingAutomationProvider::PickUserImage(DictionaryValue* args, | 260 void TestingAutomationProvider::PickUserImage(base::DictionaryValue* args, |
| 261 IPC::Message* reply_message) { | 261 IPC::Message* reply_message) { |
| 262 std::string image_type; | 262 std::string image_type; |
| 263 int image_number = -1; | 263 int image_number = -1; |
| 264 if (!args->GetString("image", &image_type) | 264 if (!args->GetString("image", &image_type) |
| 265 && !args->GetInteger("image", &image_number)) { | 265 && !args->GetInteger("image", &image_number)) { |
| 266 AutomationJSONReply(this, reply_message).SendError( | 266 AutomationJSONReply(this, reply_message).SendError( |
| 267 "Invalid or missing args."); | 267 "Invalid or missing args."); |
| 268 return; | 268 return; |
| 269 } | 269 } |
| 270 WizardController* wizard_controller = WizardController::default_controller(); | 270 WizardController* wizard_controller = WizardController::default_controller(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 288 chromeos::GetDefaultImageUrl(image_number), image_type, true); | 288 chromeos::GetDefaultImageUrl(image_number), image_type, true); |
| 289 image_screen->OnImageAccepted(); | 289 image_screen->OnImageAccepted(); |
| 290 } else { | 290 } else { |
| 291 AutomationJSONReply(this, reply_message).SendError( | 291 AutomationJSONReply(this, reply_message).SendError( |
| 292 "Invalid or missing args."); | 292 "Invalid or missing args."); |
| 293 delete observer; | 293 delete observer; |
| 294 return; | 294 return; |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 | 297 |
| 298 void TestingAutomationProvider::SkipToLogin(DictionaryValue* args, | 298 void TestingAutomationProvider::SkipToLogin(base::DictionaryValue* args, |
| 299 IPC::Message* reply_message) { | 299 IPC::Message* reply_message) { |
| 300 bool skip_post_login_screens; | 300 bool skip_post_login_screens; |
| 301 // The argument name is a legacy. If set to |true|, this argument causes any | 301 // The argument name is a legacy. If set to |true|, this argument causes any |
| 302 // screens that may otherwise be shown after login (registration, Terms of | 302 // screens that may otherwise be shown after login (registration, Terms of |
| 303 // Service, user image selection) to be skipped. | 303 // Service, user image selection) to be skipped. |
| 304 if (!args->GetBoolean("skip_image_selection", &skip_post_login_screens)) { | 304 if (!args->GetBoolean("skip_image_selection", &skip_post_login_screens)) { |
| 305 AutomationJSONReply reply(this, reply_message); | 305 AutomationJSONReply reply(this, reply_message); |
| 306 reply.SendError("Invalid or missing args."); | 306 reply.SendError("Invalid or missing args."); |
| 307 return; | 307 return; |
| 308 } | 308 } |
| 309 if (skip_post_login_screens) | 309 if (skip_post_login_screens) |
| 310 WizardController::SkipPostLoginScreensForTesting(); | 310 WizardController::SkipPostLoginScreensForTesting(); |
| 311 | 311 |
| 312 WizardController* wizard_controller = WizardController::default_controller(); | 312 WizardController* wizard_controller = WizardController::default_controller(); |
| 313 if (!wizard_controller) { | 313 if (!wizard_controller) { |
| 314 AutomationJSONReply reply(this, reply_message); | 314 AutomationJSONReply reply(this, reply_message); |
| 315 if (ExistingUserController::current_controller()) { | 315 if (ExistingUserController::current_controller()) { |
| 316 // Already at login screen. | 316 // Already at login screen. |
| 317 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 317 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 318 return_value->SetString("next_screen", | 318 return_value->SetString("next_screen", |
| 319 WizardController::kLoginScreenName); | 319 WizardController::kLoginScreenName); |
| 320 reply.SendSuccess(return_value.get()); | 320 reply.SendSuccess(return_value.get()); |
| 321 } else { | 321 } else { |
| 322 reply.SendError("OOBE not active."); | 322 reply.SendError("OOBE not active."); |
| 323 } | 323 } |
| 324 return; | 324 return; |
| 325 } | 325 } |
| 326 | 326 |
| 327 // Observer will delete itself. | 327 // Observer will delete itself. |
| 328 WizardControllerObserver* observer = | 328 WizardControllerObserver* observer = |
| 329 new WizardControllerObserver(wizard_controller, this, reply_message); | 329 new WizardControllerObserver(wizard_controller, this, reply_message); |
| 330 observer->set_screen_to_wait_for(WizardController::kLoginScreenName); | 330 observer->set_screen_to_wait_for(WizardController::kLoginScreenName); |
| 331 wizard_controller->SkipToLoginForTesting(chromeos::LoginScreenContext()); | 331 wizard_controller->SkipToLoginForTesting(chromeos::LoginScreenContext()); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void TestingAutomationProvider::GetOOBEScreenInfo(DictionaryValue* args, | 334 void TestingAutomationProvider::GetOOBEScreenInfo(base::DictionaryValue* args, |
| 335 IPC::Message* reply_message) { | 335 IPC::Message* reply_message) { |
| 336 static const char kScreenNameKey[] = "screen_name"; | 336 static const char kScreenNameKey[] = "screen_name"; |
| 337 AutomationJSONReply reply(this, reply_message); | 337 AutomationJSONReply reply(this, reply_message); |
| 338 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 338 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 339 | 339 |
| 340 WizardController* wizard_controller = WizardController::default_controller(); | 340 WizardController* wizard_controller = WizardController::default_controller(); |
| 341 if (wizard_controller) { | 341 if (wizard_controller) { |
| 342 if (wizard_controller->login_screen_started()) { | 342 if (wizard_controller->login_screen_started()) { |
| 343 return_value->SetString(kScreenNameKey, | 343 return_value->SetString(kScreenNameKey, |
| 344 WizardController::kLoginScreenName); | 344 WizardController::kLoginScreenName); |
| 345 } else { | 345 } else { |
| 346 return_value->SetString(kScreenNameKey, | 346 return_value->SetString(kScreenNameKey, |
| 347 wizard_controller->current_screen()->GetName()); | 347 wizard_controller->current_screen()->GetName()); |
| 348 } | 348 } |
| 349 } else if (ExistingUserController::current_controller()) { | 349 } else if (ExistingUserController::current_controller()) { |
| 350 return_value->SetString(kScreenNameKey, WizardController::kLoginScreenName); | 350 return_value->SetString(kScreenNameKey, WizardController::kLoginScreenName); |
| 351 } else { | 351 } else { |
| 352 // Already logged in. | 352 // Already logged in. |
| 353 reply.SendSuccess(NULL); | 353 reply.SendSuccess(NULL); |
| 354 return; | 354 return; |
| 355 } | 355 } |
| 356 reply.SendSuccess(return_value.get()); | 356 reply.SendSuccess(return_value.get()); |
| 357 } | 357 } |
| 358 | 358 |
| 359 void TestingAutomationProvider::LockScreen(DictionaryValue* args, | 359 void TestingAutomationProvider::LockScreen(base::DictionaryValue* args, |
| 360 IPC::Message* reply_message) { | 360 IPC::Message* reply_message) { |
| 361 new ScreenLockUnlockObserver(this, reply_message, true); | 361 new ScreenLockUnlockObserver(this, reply_message, true); |
| 362 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen(); | 362 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen(); |
| 363 } | 363 } |
| 364 | 364 |
| 365 void TestingAutomationProvider::UnlockScreen(DictionaryValue* args, | 365 void TestingAutomationProvider::UnlockScreen(base::DictionaryValue* args, |
| 366 IPC::Message* reply_message) { | 366 IPC::Message* reply_message) { |
| 367 std::string password; | 367 std::string password; |
| 368 if (!args->GetString("password", &password)) { | 368 if (!args->GetString("password", &password)) { |
| 369 AutomationJSONReply(this, reply_message).SendError( | 369 AutomationJSONReply(this, reply_message).SendError( |
| 370 "Invalid or missing args."); | 370 "Invalid or missing args."); |
| 371 return; | 371 return; |
| 372 } | 372 } |
| 373 | 373 |
| 374 chromeos::ScreenLocker* screen_locker = | 374 chromeos::ScreenLocker* screen_locker = |
| 375 chromeos::ScreenLocker::default_screen_locker(); | 375 chromeos::ScreenLocker::default_screen_locker(); |
| 376 if (!screen_locker) { | 376 if (!screen_locker) { |
| 377 AutomationJSONReply(this, reply_message).SendError( | 377 AutomationJSONReply(this, reply_message).SendError( |
| 378 "No default screen locker. Are you sure the screen is locked?"); | 378 "No default screen locker. Are you sure the screen is locked?"); |
| 379 return; | 379 return; |
| 380 } | 380 } |
| 381 | 381 |
| 382 new ScreenUnlockObserver(this, reply_message); | 382 new ScreenUnlockObserver(this, reply_message); |
| 383 screen_locker->AuthenticateByPassword(password); | 383 screen_locker->AuthenticateByPassword(password); |
| 384 } | 384 } |
| 385 | 385 |
| 386 // Signing out could have undesirable side effects: session_manager is | 386 // Signing out could have undesirable side effects: session_manager is |
| 387 // killed, so its children, including chrome and the window manager, will | 387 // killed, so its children, including chrome and the window manager, will |
| 388 // also be killed. Anything owned by chronos will probably be killed. | 388 // also be killed. Anything owned by chronos will probably be killed. |
| 389 void TestingAutomationProvider::SignoutInScreenLocker( | 389 void TestingAutomationProvider::SignoutInScreenLocker( |
| 390 DictionaryValue* args, IPC::Message* reply_message) { | 390 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 391 AutomationJSONReply reply(this, reply_message); | 391 AutomationJSONReply reply(this, reply_message); |
| 392 chromeos::ScreenLocker* screen_locker = | 392 chromeos::ScreenLocker* screen_locker = |
| 393 chromeos::ScreenLocker::default_screen_locker(); | 393 chromeos::ScreenLocker::default_screen_locker(); |
| 394 if (!screen_locker) { | 394 if (!screen_locker) { |
| 395 reply.SendError( | 395 reply.SendError( |
| 396 "No default screen locker. Are you sure the screen is locked?"); | 396 "No default screen locker. Are you sure the screen is locked?"); |
| 397 return; | 397 return; |
| 398 } | 398 } |
| 399 | 399 |
| 400 // Send success before stopping session because if we're a child of | 400 // Send success before stopping session because if we're a child of |
| 401 // session manager then we'll die when the session is stopped. | 401 // session manager then we'll die when the session is stopped. |
| 402 reply.SendSuccess(NULL); | 402 reply.SendSuccess(NULL); |
| 403 screen_locker->Signout(); | 403 screen_locker->Signout(); |
| 404 } | 404 } |
| 405 | 405 |
| 406 void TestingAutomationProvider::GetBatteryInfo(DictionaryValue* args, | 406 void TestingAutomationProvider::GetBatteryInfo(base::DictionaryValue* args, |
| 407 IPC::Message* reply_message) { | 407 IPC::Message* reply_message) { |
| 408 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 408 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 409 | 409 |
| 410 const bool battery_is_present = power_supply_properties_.battery_state() != | 410 const bool battery_is_present = power_supply_properties_.battery_state() != |
| 411 power_manager::PowerSupplyProperties_BatteryState_NOT_PRESENT; | 411 power_manager::PowerSupplyProperties_BatteryState_NOT_PRESENT; |
| 412 const bool line_power_on = power_supply_properties_.external_power() != | 412 const bool line_power_on = power_supply_properties_.external_power() != |
| 413 power_manager::PowerSupplyProperties_ExternalPower_DISCONNECTED; | 413 power_manager::PowerSupplyProperties_ExternalPower_DISCONNECTED; |
| 414 | 414 |
| 415 return_value->SetBoolean("battery_is_present", battery_is_present); | 415 return_value->SetBoolean("battery_is_present", battery_is_present); |
| 416 return_value->SetBoolean("line_power_on", line_power_on); | 416 return_value->SetBoolean("line_power_on", line_power_on); |
| 417 | 417 |
| 418 if (battery_is_present) { | 418 if (battery_is_present) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 429 int64 time = power_supply_properties_.battery_time_to_empty_sec(); | 429 int64 time = power_supply_properties_.battery_time_to_empty_sec(); |
| 430 if (time > 0) | 430 if (time > 0) |
| 431 return_value->SetInteger("battery_seconds_to_empty", time); | 431 return_value->SetInteger("battery_seconds_to_empty", time); |
| 432 } | 432 } |
| 433 } | 433 } |
| 434 | 434 |
| 435 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 435 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 436 } | 436 } |
| 437 | 437 |
| 438 void TestingAutomationProvider::ExecuteJavascriptInOOBEWebUI( | 438 void TestingAutomationProvider::ExecuteJavascriptInOOBEWebUI( |
| 439 DictionaryValue* args, IPC::Message* reply_message) { | 439 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 440 std::string javascript, frame_xpath; | 440 std::string javascript, frame_xpath; |
| 441 if (!args->GetString("javascript", &javascript)) { | 441 if (!args->GetString("javascript", &javascript)) { |
| 442 AutomationJSONReply(this, reply_message) | 442 AutomationJSONReply(this, reply_message) |
| 443 .SendError("'javascript' missing or invalid"); | 443 .SendError("'javascript' missing or invalid"); |
| 444 return; | 444 return; |
| 445 } | 445 } |
| 446 if (!args->GetString("frame_xpath", &frame_xpath)) { | 446 if (!args->GetString("frame_xpath", &frame_xpath)) { |
| 447 AutomationJSONReply(this, reply_message) | 447 AutomationJSONReply(this, reply_message) |
| 448 .SendError("'frame_xpath' missing or invalid"); | 448 .SendError("'frame_xpath' missing or invalid"); |
| 449 return; | 449 return; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 473 webui_host->GetOobeUI()->web_ui()->GetWebContents(); | 473 webui_host->GetOobeUI()->web_ui()->GetWebContents(); |
| 474 | 474 |
| 475 new DomOperationMessageSender(this, reply_message, true); | 475 new DomOperationMessageSender(this, reply_message, true); |
| 476 ExecuteJavascriptInRenderViewFrame(ASCIIToUTF16(frame_xpath), | 476 ExecuteJavascriptInRenderViewFrame(ASCIIToUTF16(frame_xpath), |
| 477 ASCIIToUTF16(javascript), | 477 ASCIIToUTF16(javascript), |
| 478 reply_message, | 478 reply_message, |
| 479 web_contents->GetRenderViewHost()); | 479 web_contents->GetRenderViewHost()); |
| 480 } | 480 } |
| 481 | 481 |
| 482 void TestingAutomationProvider::EnableSpokenFeedback( | 482 void TestingAutomationProvider::EnableSpokenFeedback( |
| 483 DictionaryValue* args, IPC::Message* reply_message) { | 483 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 484 AutomationJSONReply reply(this, reply_message); | 484 AutomationJSONReply reply(this, reply_message); |
| 485 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 485 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 486 bool enabled; | 486 bool enabled; |
| 487 if (!args->GetBoolean("enabled", &enabled)) { | 487 if (!args->GetBoolean("enabled", &enabled)) { |
| 488 reply.SendError("Invalid or missing args."); | 488 reply.SendError("Invalid or missing args."); |
| 489 return; | 489 return; |
| 490 } | 490 } |
| 491 chromeos::AccessibilityManager::Get()->EnableSpokenFeedback( | 491 chromeos::AccessibilityManager::Get()->EnableSpokenFeedback( |
| 492 enabled, ash::A11Y_NOTIFICATION_NONE); | 492 enabled, ash::A11Y_NOTIFICATION_NONE); |
| 493 | 493 |
| 494 reply.SendSuccess(return_value.get()); | 494 reply.SendSuccess(return_value.get()); |
| 495 } | 495 } |
| 496 | 496 |
| 497 void TestingAutomationProvider::IsSpokenFeedbackEnabled( | 497 void TestingAutomationProvider::IsSpokenFeedbackEnabled( |
| 498 DictionaryValue* args, IPC::Message* reply_message) { | 498 base::DictionaryValue* args, IPC::Message* reply_message) { |
| 499 AutomationJSONReply reply(this, reply_message); | 499 AutomationJSONReply reply(this, reply_message); |
| 500 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 500 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 501 return_value->SetBoolean( | 501 return_value->SetBoolean( |
| 502 "spoken_feedback", | 502 "spoken_feedback", |
| 503 chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 503 chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
| 504 reply.SendSuccess(return_value.get()); | 504 reply.SendSuccess(return_value.get()); |
| 505 } | 505 } |
| 506 | 506 |
| 507 void TestingAutomationProvider::GetTimeInfo(Browser* browser, | 507 void TestingAutomationProvider::GetTimeInfo(Browser* browser, |
| 508 DictionaryValue* args, | 508 base::DictionaryValue* args, |
| 509 IPC::Message* reply_message) { | 509 IPC::Message* reply_message) { |
| 510 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 510 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 511 base::Time time(base::Time::Now()); | 511 base::Time time(base::Time::Now()); |
| 512 bool use_24hour_clock = browser && browser->profile()->GetPrefs()->GetBoolean( | 512 bool use_24hour_clock = browser && browser->profile()->GetPrefs()->GetBoolean( |
| 513 prefs::kUse24HourClock); | 513 prefs::kUse24HourClock); |
| 514 base::HourClockType hour_clock_type = | 514 base::HourClockType hour_clock_type = |
| 515 use_24hour_clock ? base::k24HourClock : base::k12HourClock; | 515 use_24hour_clock ? base::k24HourClock : base::k12HourClock; |
| 516 base::string16 display_time = base::TimeFormatTimeOfDayWithHourClockType( | 516 base::string16 display_time = base::TimeFormatTimeOfDayWithHourClockType( |
| 517 time, hour_clock_type, base::kDropAmPm); | 517 time, hour_clock_type, base::kDropAmPm); |
| 518 base::string16 timezone = | 518 base::string16 timezone = |
| 519 chromeos::system::TimezoneSettings::GetInstance()->GetCurrentTimezoneID(); | 519 chromeos::system::TimezoneSettings::GetInstance()->GetCurrentTimezoneID(); |
| 520 return_value->SetString("display_time", display_time); | 520 return_value->SetString("display_time", display_time); |
| 521 return_value->SetString("display_date", base::TimeFormatFriendlyDate(time)); | 521 return_value->SetString("display_date", base::TimeFormatFriendlyDate(time)); |
| 522 return_value->SetString("timezone", timezone); | 522 return_value->SetString("timezone", timezone); |
| 523 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 523 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 524 } | 524 } |
| 525 | 525 |
| 526 void TestingAutomationProvider::GetTimeInfo(DictionaryValue* args, | 526 void TestingAutomationProvider::GetTimeInfo(base::DictionaryValue* args, |
| 527 IPC::Message* reply_message) { | 527 IPC::Message* reply_message) { |
| 528 GetTimeInfo(NULL, args, reply_message); | 528 GetTimeInfo(NULL, args, reply_message); |
| 529 } | 529 } |
| 530 | 530 |
| 531 void TestingAutomationProvider::SetTimezone(DictionaryValue* args, | 531 void TestingAutomationProvider::SetTimezone(base::DictionaryValue* args, |
| 532 IPC::Message* reply_message) { | 532 IPC::Message* reply_message) { |
| 533 AutomationJSONReply reply(this, reply_message); | 533 AutomationJSONReply reply(this, reply_message); |
| 534 std::string timezone_id; | 534 std::string timezone_id; |
| 535 if (!args->GetString("timezone", &timezone_id)) { | 535 if (!args->GetString("timezone", &timezone_id)) { |
| 536 reply.SendError("Invalid or missing args."); | 536 reply.SendError("Invalid or missing args."); |
| 537 return; | 537 return; |
| 538 } | 538 } |
| 539 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get(); | 539 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get(); |
| 540 settings->SetString(chromeos::kSystemTimezone, timezone_id); | 540 settings->SetString(chromeos::kSystemTimezone, timezone_id); |
| 541 reply.SendSuccess(NULL); | 541 reply.SendSuccess(NULL); |
| 542 } | 542 } |
| 543 | 543 |
| 544 void TestingAutomationProvider::UpdateCheck( | 544 void TestingAutomationProvider::UpdateCheck( |
| 545 DictionaryValue* args, | 545 base::DictionaryValue* args, |
| 546 IPC::Message* reply_message) { | 546 IPC::Message* reply_message) { |
| 547 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); | 547 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); |
| 548 DBusThreadManager::Get()->GetUpdateEngineClient() | 548 DBusThreadManager::Get()->GetUpdateEngineClient() |
| 549 ->RequestUpdateCheck(base::Bind(UpdateCheckCallback, reply)); | 549 ->RequestUpdateCheck(base::Bind(UpdateCheckCallback, reply)); |
| 550 } | 550 } |
| 551 | 551 |
| 552 void TestingAutomationProvider::GetVolumeInfo(DictionaryValue* args, | 552 void TestingAutomationProvider::GetVolumeInfo(base::DictionaryValue* args, |
| 553 IPC::Message* reply_message) { | 553 IPC::Message* reply_message) { |
| 554 AutomationJSONReply reply(this, reply_message); | 554 AutomationJSONReply reply(this, reply_message); |
| 555 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 555 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
| 556 chromeos::CrasAudioHandler* audio_handler = chromeos::CrasAudioHandler::Get(); | 556 chromeos::CrasAudioHandler* audio_handler = chromeos::CrasAudioHandler::Get(); |
| 557 if (!audio_handler) { | 557 if (!audio_handler) { |
| 558 reply.SendError("CrasAudioHandler not initialized."); | 558 reply.SendError("CrasAudioHandler not initialized."); |
| 559 return; | 559 return; |
| 560 } | 560 } |
| 561 return_value->SetDouble("volume", audio_handler->GetOutputVolumePercent()); | 561 return_value->SetDouble("volume", audio_handler->GetOutputVolumePercent()); |
| 562 return_value->SetBoolean("is_mute", audio_handler->IsOutputMuted()); | 562 return_value->SetBoolean("is_mute", audio_handler->IsOutputMuted()); |
| 563 reply.SendSuccess(return_value.get()); | 563 reply.SendSuccess(return_value.get()); |
| 564 } | 564 } |
| 565 | 565 |
| 566 void TestingAutomationProvider::SetVolume(DictionaryValue* args, | 566 void TestingAutomationProvider::SetVolume(base::DictionaryValue* args, |
| 567 IPC::Message* reply_message) { | 567 IPC::Message* reply_message) { |
| 568 AutomationJSONReply reply(this, reply_message); | 568 AutomationJSONReply reply(this, reply_message); |
| 569 double volume_percent; | 569 double volume_percent; |
| 570 if (!args->GetDouble("volume", &volume_percent)) { | 570 if (!args->GetDouble("volume", &volume_percent)) { |
| 571 reply.SendError("Invalid or missing args."); | 571 reply.SendError("Invalid or missing args."); |
| 572 return; | 572 return; |
| 573 } | 573 } |
| 574 chromeos::CrasAudioHandler* audio_handler = chromeos::CrasAudioHandler::Get(); | 574 chromeos::CrasAudioHandler* audio_handler = chromeos::CrasAudioHandler::Get(); |
| 575 if (!audio_handler) { | 575 if (!audio_handler) { |
| 576 reply.SendError("CrasAudioHandler not initialized."); | 576 reply.SendError("CrasAudioHandler not initialized."); |
| 577 return; | 577 return; |
| 578 } | 578 } |
| 579 audio_handler->SetOutputVolumePercent(volume_percent); | 579 audio_handler->SetOutputVolumePercent(volume_percent); |
| 580 reply.SendSuccess(NULL); | 580 reply.SendSuccess(NULL); |
| 581 } | 581 } |
| 582 | 582 |
| 583 void TestingAutomationProvider::SetMute(DictionaryValue* args, | 583 void TestingAutomationProvider::SetMute(base::DictionaryValue* args, |
| 584 IPC::Message* reply_message) { | 584 IPC::Message* reply_message) { |
| 585 AutomationJSONReply reply(this, reply_message); | 585 AutomationJSONReply reply(this, reply_message); |
| 586 bool mute; | 586 bool mute; |
| 587 if (!args->GetBoolean("mute", &mute)) { | 587 if (!args->GetBoolean("mute", &mute)) { |
| 588 reply.SendError("Invalid or missing args."); | 588 reply.SendError("Invalid or missing args."); |
| 589 return; | 589 return; |
| 590 } | 590 } |
| 591 chromeos::CrasAudioHandler* audio_handler = chromeos::CrasAudioHandler::Get(); | 591 chromeos::CrasAudioHandler* audio_handler = chromeos::CrasAudioHandler::Get(); |
| 592 if (!audio_handler) { | 592 if (!audio_handler) { |
| 593 reply.SendError("CrasAudioHandler not initialized."); | 593 reply.SendError("CrasAudioHandler not initialized."); |
| 594 return; | 594 return; |
| 595 } | 595 } |
| 596 audio_handler->SetOutputMute(mute); | 596 audio_handler->SetOutputMute(mute); |
| 597 reply.SendSuccess(NULL); | 597 reply.SendSuccess(NULL); |
| 598 } | 598 } |
| 599 | 599 |
| 600 void TestingAutomationProvider::OpenCrosh(DictionaryValue* args, | 600 void TestingAutomationProvider::OpenCrosh(base::DictionaryValue* args, |
| 601 IPC::Message* reply_message) { | 601 IPC::Message* reply_message) { |
| 602 new NavigationNotificationObserver( | 602 new NavigationNotificationObserver( |
| 603 NULL, this, reply_message, 1, false, true); | 603 NULL, this, reply_message, 1, false, true); |
| 604 ash::Shell::GetInstance()->new_window_delegate()->OpenCrosh(); | 604 ash::Shell::GetInstance()->new_window_delegate()->OpenCrosh(); |
| 605 } | 605 } |
| 606 | 606 |
| 607 void TestingAutomationProvider::AddChromeosObservers() { | 607 void TestingAutomationProvider::AddChromeosObservers() { |
| 608 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 608 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 609 AddObserver(this); | 609 AddObserver(this); |
| 610 } | 610 } |
| 611 | 611 |
| 612 void TestingAutomationProvider::RemoveChromeosObservers() { | 612 void TestingAutomationProvider::RemoveChromeosObservers() { |
| 613 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 613 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 614 RemoveObserver(this); | 614 RemoveObserver(this); |
| 615 } | 615 } |
| OLD | NEW |