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/chromeos/login/existing_user_controller.h" | 5 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/shell.h" | |
|
bartfab (slow)
2013/02/28 10:21:33
This is no longer used.
dconnelly
2013/02/28 12:52:56
Done.
| |
| 10 #include "ash/wm/user_activity_detector.h" | |
|
bartfab (slow)
2013/02/28 10:21:33
This is no longer used.
dconnelly
2013/02/28 12:52:56
Done.
| |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 11 #include "base/callback.h" | 13 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 13 #include "base/logging.h" | 15 #include "base/logging.h" |
| 14 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 15 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 16 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
| 17 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 18 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 ExistingUserController::ExistingUserController(LoginDisplayHost* host) | 138 ExistingUserController::ExistingUserController(LoginDisplayHost* host) |
| 137 : login_status_consumer_(NULL), | 139 : login_status_consumer_(NULL), |
| 138 host_(host), | 140 host_(host), |
| 139 login_display_(host_->CreateLoginDisplay(this)), | 141 login_display_(host_->CreateLoginDisplay(this)), |
| 140 num_login_attempts_(0), | 142 num_login_attempts_(0), |
| 141 cros_settings_(CrosSettings::Get()), | 143 cros_settings_(CrosSettings::Get()), |
| 142 weak_factory_(this), | 144 weak_factory_(this), |
| 143 offline_failed_(false), | 145 offline_failed_(false), |
| 144 is_login_in_progress_(false), | 146 is_login_in_progress_(false), |
| 145 password_changed_(false), | 147 password_changed_(false), |
| 146 do_auto_enrollment_(false) { | 148 do_auto_enrollment_(false), |
| 149 signin_screen_ready_(false) { | |
| 147 DCHECK(current_controller_ == NULL); | 150 DCHECK(current_controller_ == NULL); |
| 148 current_controller_ = this; | 151 current_controller_ = this; |
| 149 | 152 |
| 150 registrar_.Add(this, | 153 registrar_.Add(this, |
| 151 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, | 154 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, |
| 152 content::NotificationService::AllSources()); | 155 content::NotificationService::AllSources()); |
| 153 registrar_.Add(this, | 156 registrar_.Add(this, |
| 154 chrome::NOTIFICATION_USER_LIST_CHANGED, | 157 chrome::NOTIFICATION_USER_LIST_CHANGED, |
| 155 content::NotificationService::AllSources()); | 158 content::NotificationService::AllSources()); |
| 156 registrar_.Add(this, | 159 registrar_.Add(this, |
| 157 chrome::NOTIFICATION_AUTH_SUPPLIED, | 160 chrome::NOTIFICATION_AUTH_SUPPLIED, |
| 158 content::NotificationService::AllSources()); | 161 content::NotificationService::AllSources()); |
| 159 registrar_.Add(this, | 162 registrar_.Add(this, |
| 160 chrome::NOTIFICATION_SESSION_STARTED, | 163 chrome::NOTIFICATION_SESSION_STARTED, |
| 161 content::NotificationService::AllSources()); | 164 content::NotificationService::AllSources()); |
| 162 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this); | 165 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this); |
| 163 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this); | 166 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this); |
| 164 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this); | 167 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this); |
| 165 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this); | 168 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this); |
| 169 cros_settings_->AddSettingsObserver( | |
| 170 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
| 171 this); | |
| 172 cros_settings_->AddSettingsObserver( | |
| 173 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
| 174 this); | |
| 166 } | 175 } |
| 167 | 176 |
| 168 void ExistingUserController::Init(const UserList& users) { | 177 void ExistingUserController::Init(const UserList& users) { |
| 169 time_init_ = base::Time::Now(); | 178 time_init_ = base::Time::Now(); |
| 170 UpdateLoginDisplay(users); | 179 UpdateLoginDisplay(users); |
| 180 ConfigurePublicSessionAutoLogin(); | |
| 171 | 181 |
| 172 LoginUtils::Get()->PrewarmAuthentication(); | 182 LoginUtils::Get()->PrewarmAuthentication(); |
| 173 DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady(); | 183 DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady(); |
| 174 } | 184 } |
| 175 | 185 |
| 176 void ExistingUserController::UpdateLoginDisplay(const UserList& users) { | 186 void ExistingUserController::UpdateLoginDisplay(const UserList& users) { |
| 177 bool show_users_on_signin; | 187 bool show_users_on_signin; |
| 178 UserList filtered_users; | 188 UserList filtered_users; |
| 179 | 189 |
| 180 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, | 190 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 const content::NotificationSource& source, | 240 const content::NotificationSource& source, |
| 231 const content::NotificationDetails& details) { | 241 const content::NotificationDetails& details) { |
| 232 if (type == chrome::NOTIFICATION_SESSION_STARTED) { | 242 if (type == chrome::NOTIFICATION_SESSION_STARTED) { |
| 233 // Stop listening to any notification once session has started. | 243 // Stop listening to any notification once session has started. |
| 234 // Sign in screen objects are marked for deletion with DeleteSoon so | 244 // Sign in screen objects are marked for deletion with DeleteSoon so |
| 235 // make sure no object would be used after session has started. | 245 // make sure no object would be used after session has started. |
| 236 // http://crbug.com/125276 | 246 // http://crbug.com/125276 |
| 237 registrar_.RemoveAll(); | 247 registrar_.RemoveAll(); |
| 238 return; | 248 return; |
| 239 } | 249 } |
| 250 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) { | |
| 251 const std::string setting = *content::Details<const std::string>( | |
| 252 details).ptr(); | |
| 253 if (setting == kAccountsPrefDeviceLocalAccountAutoLoginId || | |
| 254 setting == kAccountsPrefDeviceLocalAccountAutoLoginDelay) { | |
| 255 ConfigurePublicSessionAutoLogin(); | |
| 256 } | |
| 257 } | |
| 240 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || | 258 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || |
| 241 type == chrome::NOTIFICATION_USER_LIST_CHANGED) { | 259 type == chrome::NOTIFICATION_USER_LIST_CHANGED) { |
| 242 if (host_ != NULL) { | 260 if (host_ != NULL) { |
| 243 // Signed settings or user list changed. Notify views and update them. | 261 // Signed settings or user list changed. Notify views and update them. |
| 244 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); | 262 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); |
| 245 return; | 263 return; |
| 246 } | 264 } |
| 247 } | 265 } |
| 248 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { | 266 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { |
| 249 // Possibly the user has authenticated against a proxy server and we might | 267 // Possibly the user has authenticated against a proxy server and we might |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 279 // ExistingUserController, private: | 297 // ExistingUserController, private: |
| 280 | 298 |
| 281 ExistingUserController::~ExistingUserController() { | 299 ExistingUserController::~ExistingUserController() { |
| 282 LoginUtils::Get()->DelegateDeleted(this); | 300 LoginUtils::Get()->DelegateDeleted(this); |
| 283 | 301 |
| 284 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, | 302 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, |
| 285 this); | 303 this); |
| 286 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this); | 304 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this); |
| 287 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this); | 305 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this); |
| 288 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this); | 306 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this); |
| 307 cros_settings_->RemoveSettingsObserver( | |
| 308 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
| 309 this); | |
| 310 cros_settings_->RemoveSettingsObserver( | |
| 311 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
| 312 this); | |
| 289 | 313 |
| 290 if (current_controller_ == this) { | 314 if (current_controller_ == this) { |
| 291 current_controller_ = NULL; | 315 current_controller_ = NULL; |
| 292 } else { | 316 } else { |
| 293 NOTREACHED() << "More than one controller are alive."; | 317 NOTREACHED() << "More than one controller are alive."; |
| 294 } | 318 } |
| 295 DCHECK(login_display_.get()); | 319 DCHECK(login_display_.get()); |
| 296 } | 320 } |
| 297 | 321 |
| 298 //////////////////////////////////////////////////////////////////////////////// | 322 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 // TODO(nkostylev): A11y message. | 357 // TODO(nkostylev): A11y message. |
| 334 } | 358 } |
| 335 | 359 |
| 336 void ExistingUserController::CompleteLogin(const std::string& username, | 360 void ExistingUserController::CompleteLogin(const std::string& username, |
| 337 const std::string& password) { | 361 const std::string& password) { |
| 338 if (!host_) { | 362 if (!host_) { |
| 339 // Complete login event was generated already from UI. Ignore notification. | 363 // Complete login event was generated already from UI. Ignore notification. |
| 340 return; | 364 return; |
| 341 } | 365 } |
| 342 | 366 |
| 367 // Stop the auto-login timer when attempting login. | |
| 368 StopPublicSessionAutoLoginTimer(); | |
| 369 | |
| 343 // Disable UI while loading user profile. | 370 // Disable UI while loading user profile. |
| 344 login_display_->SetUIEnabled(false); | 371 login_display_->SetUIEnabled(false); |
| 345 | 372 |
| 346 if (!time_init_.is_null()) { | 373 if (!time_init_.is_null()) { |
| 347 base::TimeDelta delta = base::Time::Now() - time_init_; | 374 base::TimeDelta delta = base::Time::Now() - time_init_; |
| 348 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); | 375 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); |
| 349 time_init_ = base::Time(); // Reset to null. | 376 time_init_ = base::Time(); // Reset to null. |
| 350 } | 377 } |
| 351 | 378 |
| 352 host_->OnCompleteLogin(); | 379 host_->OnCompleteLogin(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 } | 416 } |
| 390 | 417 |
| 391 string16 ExistingUserController::GetConnectedNetworkName() { | 418 string16 ExistingUserController::GetConnectedNetworkName() { |
| 392 return GetCurrentNetworkName(); | 419 return GetCurrentNetworkName(); |
| 393 } | 420 } |
| 394 | 421 |
| 395 void ExistingUserController::Login(const std::string& username, | 422 void ExistingUserController::Login(const std::string& username, |
| 396 const std::string& password) { | 423 const std::string& password) { |
| 397 if (username.empty() || password.empty()) | 424 if (username.empty() || password.empty()) |
| 398 return; | 425 return; |
| 426 | |
| 427 // Stop the auto-login timer when attempting login. | |
| 428 StopPublicSessionAutoLoginTimer(); | |
| 429 | |
| 399 // Disable clicking on other windows. | 430 // Disable clicking on other windows. |
| 400 login_display_->SetUIEnabled(false); | 431 login_display_->SetUIEnabled(false); |
| 401 | 432 |
| 402 BootTimesLoader::Get()->RecordLoginAttempted(); | 433 BootTimesLoader::Get()->RecordLoginAttempted(); |
| 403 | 434 |
| 404 if (last_login_attempt_username_ != username) { | 435 if (last_login_attempt_username_ != username) { |
| 405 last_login_attempt_username_ = username; | 436 last_login_attempt_username_ = username; |
| 406 num_login_attempts_ = 0; | 437 num_login_attempts_ = 0; |
| 407 // Also reset state variables, which are used to determine password change. | 438 // Also reset state variables, which are used to determine password change. |
| 408 offline_failed_ = false; | 439 offline_failed_ = false; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 436 UserManager::kLocallyManagedUserDomain) { | 467 UserManager::kLocallyManagedUserDomain) { |
| 437 login_performer_->LoginAsLocallyManagedUser(username, password); | 468 login_performer_->LoginAsLocallyManagedUser(username, password); |
| 438 } else { | 469 } else { |
| 439 login_performer_->PerformLogin(username, password, auth_mode); | 470 login_performer_->PerformLogin(username, password, auth_mode); |
| 440 } | 471 } |
| 441 accessibility::MaybeSpeak( | 472 accessibility::MaybeSpeak( |
| 442 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); | 473 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); |
| 443 } | 474 } |
| 444 | 475 |
| 445 void ExistingUserController::LoginAsRetailModeUser() { | 476 void ExistingUserController::LoginAsRetailModeUser() { |
| 477 // Stop the auto-login timer when attempting login. | |
| 478 StopPublicSessionAutoLoginTimer(); | |
| 479 | |
| 446 // Disable clicking on other windows. | 480 // Disable clicking on other windows. |
| 447 login_display_->SetUIEnabled(false); | 481 login_display_->SetUIEnabled(false); |
| 448 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once | 482 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once |
| 449 // the enterprise policy wiring is done for retail mode. | 483 // the enterprise policy wiring is done for retail mode. |
| 450 | 484 |
| 451 // Only one instance of LoginPerformer should exist at a time. | 485 // Only one instance of LoginPerformer should exist at a time. |
| 452 login_performer_.reset(NULL); | 486 login_performer_.reset(NULL); |
| 453 login_performer_.reset(new LoginPerformer(this)); | 487 login_performer_.reset(new LoginPerformer(this)); |
| 454 is_login_in_progress_ = true; | 488 is_login_in_progress_ = true; |
| 455 login_performer_->LoginRetailMode(); | 489 login_performer_->LoginRetailMode(); |
| 456 accessibility::MaybeSpeak( | 490 accessibility::MaybeSpeak( |
| 457 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); | 491 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); |
| 458 } | 492 } |
| 459 | 493 |
| 460 void ExistingUserController::LoginAsGuest() { | 494 void ExistingUserController::LoginAsGuest() { |
| 495 // Stop the auto-login timer when attempting login. | |
| 496 StopPublicSessionAutoLoginTimer(); | |
| 497 | |
| 461 // Disable clicking on other windows. | 498 // Disable clicking on other windows. |
| 462 login_display_->SetUIEnabled(false); | 499 login_display_->SetUIEnabled(false); |
| 463 | 500 |
| 464 CrosSettingsProvider::TrustedStatus status = | 501 CrosSettingsProvider::TrustedStatus status = |
| 465 cros_settings_->PrepareTrustedValues( | 502 cros_settings_->PrepareTrustedValues( |
| 466 base::Bind(&ExistingUserController::LoginAsGuest, | 503 base::Bind(&ExistingUserController::LoginAsGuest, |
| 467 weak_factory_.GetWeakPtr())); | 504 weak_factory_.GetWeakPtr())); |
| 468 // Must not proceed without signature verification. | 505 // Must not proceed without signature verification. |
| 469 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { | 506 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { |
| 470 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, | 507 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, |
| 471 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 508 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
| 472 // Reenable clicking on other windows and status area. | 509 // Reenable clicking on other windows and status area. |
| 473 login_display_->SetUIEnabled(true); | 510 login_display_->SetUIEnabled(true); |
| 511 StartPublicSessionAutoLoginTimer(); | |
| 474 display_email_.clear(); | 512 display_email_.clear(); |
| 475 return; | 513 return; |
| 476 } else if (status != CrosSettingsProvider::TRUSTED) { | 514 } else if (status != CrosSettingsProvider::TRUSTED) { |
| 477 // Value of AllowNewUser setting is still not verified. | 515 // Value of AllowNewUser setting is still not verified. |
| 478 // Another attempt will be invoked after verification completion. | 516 // Another attempt will be invoked after verification completion. |
| 479 return; | 517 return; |
| 480 } | 518 } |
| 481 | 519 |
| 482 bool allow_guest; | 520 bool allow_guest; |
| 483 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 521 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
| 484 if (!allow_guest) { | 522 if (!allow_guest) { |
| 485 // Disallowed. The UI should normally not show the guest pod but if for some | 523 // Disallowed. The UI should normally not show the guest pod but if for some |
| 486 // reason this has been made available to the user here is the time to tell | 524 // reason this has been made available to the user here is the time to tell |
| 487 // this nicely. | 525 // this nicely. |
| 488 login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1, | 526 login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1, |
| 489 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 527 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
| 490 // Reenable clicking on other windows and status area. | 528 // Reenable clicking on other windows and status area. |
| 491 login_display_->SetUIEnabled(true); | 529 login_display_->SetUIEnabled(true); |
| 530 StartPublicSessionAutoLoginTimer(); | |
| 492 display_email_.clear(); | 531 display_email_.clear(); |
| 493 return; | 532 return; |
| 494 } | 533 } |
| 495 | 534 |
| 496 // Only one instance of LoginPerformer should exist at a time. | 535 // Only one instance of LoginPerformer should exist at a time. |
| 497 login_performer_.reset(NULL); | 536 login_performer_.reset(NULL); |
| 498 login_performer_.reset(new LoginPerformer(this)); | 537 login_performer_.reset(new LoginPerformer(this)); |
| 499 is_login_in_progress_ = true; | 538 is_login_in_progress_ = true; |
| 500 login_performer_->LoginOffTheRecord(); | 539 login_performer_->LoginOffTheRecord(); |
| 501 accessibility::MaybeSpeak( | 540 accessibility::MaybeSpeak( |
| 502 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); | 541 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); |
| 503 } | 542 } |
| 504 | 543 |
| 505 void ExistingUserController::MigrateUserData(const std::string& old_password) { | 544 void ExistingUserController::MigrateUserData(const std::string& old_password) { |
| 506 // LoginPerformer instance has state of the user so it should exist. | 545 // LoginPerformer instance has state of the user so it should exist. |
| 507 if (login_performer_.get()) | 546 if (login_performer_.get()) |
| 508 login_performer_->RecoverEncryptedData(old_password); | 547 login_performer_->RecoverEncryptedData(old_password); |
| 509 } | 548 } |
| 510 | 549 |
| 511 void ExistingUserController::LoginAsPublicAccount( | 550 void ExistingUserController::LoginAsPublicAccount( |
| 512 const std::string& username) { | 551 const std::string& username) { |
| 552 // Stop the auto-login timer when attempting login. | |
| 553 StopPublicSessionAutoLoginTimer(); | |
| 554 | |
| 513 // Disable clicking on other windows. | 555 // Disable clicking on other windows. |
| 514 login_display_->SetUIEnabled(false); | 556 login_display_->SetUIEnabled(false); |
| 515 | 557 |
| 516 CrosSettingsProvider::TrustedStatus status = | 558 CrosSettingsProvider::TrustedStatus status = |
| 517 cros_settings_->PrepareTrustedValues( | 559 cros_settings_->PrepareTrustedValues( |
| 518 base::Bind(&ExistingUserController::LoginAsPublicAccount, | 560 base::Bind(&ExistingUserController::LoginAsPublicAccount, |
| 519 weak_factory_.GetWeakPtr(), | 561 weak_factory_.GetWeakPtr(), |
| 520 username)); | 562 username)); |
| 521 // If device policy is permanently unavailable, logging into public accounts | 563 // If device policy is permanently unavailable, logging into public accounts |
| 522 // is not possible. | 564 // is not possible. |
| 523 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { | 565 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { |
| 524 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, | 566 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, |
| 525 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 567 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
| 526 // Re-enable clicking on other windows. | 568 // Re-enable clicking on other windows. |
| 527 login_display_->SetUIEnabled(true); | 569 login_display_->SetUIEnabled(true); |
| 528 return; | 570 return; |
| 529 } | 571 } |
| 530 | 572 |
| 531 // If device policy is not verified yet, this function will be called again | 573 // If device policy is not verified yet, this function will be called again |
| 532 // when verification finishes. | 574 // when verification finishes. |
| 533 if (status != CrosSettingsProvider::TRUSTED) | 575 if (status != CrosSettingsProvider::TRUSTED) |
| 534 return; | 576 return; |
| 535 | 577 |
| 536 // If there is no public account with the given |username|, logging in is not | 578 // If there is no public account with the given |username|, logging in is not |
| 537 // possible. | 579 // possible. |
| 538 const User* user = UserManager::Get()->FindUser(username); | 580 const User* user = UserManager::Get()->FindUser(username); |
| 539 if (!user || user->GetType() != User::USER_TYPE_PUBLIC_ACCOUNT) { | 581 if (!user || user->GetType() != User::USER_TYPE_PUBLIC_ACCOUNT) { |
| 540 // Re-enable clicking on other windows. | 582 // Re-enable clicking on other windows. |
| 541 login_display_->SetUIEnabled(true); | 583 login_display_->SetUIEnabled(true); |
| 584 StartPublicSessionAutoLoginTimer(); | |
| 542 return; | 585 return; |
| 543 } | 586 } |
| 544 | 587 |
| 545 // Only one instance of LoginPerformer should exist at a time. | 588 // Only one instance of LoginPerformer should exist at a time. |
| 546 login_performer_.reset(NULL); | 589 login_performer_.reset(NULL); |
| 547 login_performer_.reset(new LoginPerformer(this)); | 590 login_performer_.reset(new LoginPerformer(this)); |
| 548 is_login_in_progress_ = true; | 591 is_login_in_progress_ = true; |
| 549 login_performer_->LoginAsPublicAccount(username); | 592 login_performer_->LoginAsPublicAccount(username); |
| 550 accessibility::MaybeSpeak( | 593 accessibility::MaybeSpeak( |
| 551 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); | 594 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); |
| 552 } | 595 } |
| 553 | 596 |
| 597 void ExistingUserController::OnSigninScreenReady() { | |
| 598 signin_screen_ready_ = true; | |
| 599 StartPublicSessionAutoLoginTimer(); | |
| 600 } | |
| 601 | |
| 554 void ExistingUserController::OnUserSelected(const std::string& username) { | 602 void ExistingUserController::OnUserSelected(const std::string& username) { |
| 555 login_performer_.reset(NULL); | 603 login_performer_.reset(NULL); |
| 556 num_login_attempts_ = 0; | 604 num_login_attempts_ = 0; |
| 557 } | 605 } |
| 558 | 606 |
| 559 void ExistingUserController::OnStartEnterpriseEnrollment() { | 607 void ExistingUserController::OnStartEnterpriseEnrollment() { |
| 560 DeviceSettingsService::Get()->GetOwnershipStatusAsync( | 608 DeviceSettingsService::Get()->GetOwnershipStatusAsync( |
| 561 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, | 609 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, |
| 562 weak_factory_.GetWeakPtr())); | 610 weak_factory_.GetWeakPtr())); |
| 563 } | 611 } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 682 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); | 730 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); |
| 683 } else { | 731 } else { |
| 684 if (!is_known_user) | 732 if (!is_known_user) |
| 685 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); | 733 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); |
| 686 else | 734 else |
| 687 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); | 735 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
| 688 } | 736 } |
| 689 } | 737 } |
| 690 // Reenable clicking on other windows and status area. | 738 // Reenable clicking on other windows and status area. |
| 691 login_display_->SetUIEnabled(true); | 739 login_display_->SetUIEnabled(true); |
| 740 StartPublicSessionAutoLoginTimer(); | |
| 692 } | 741 } |
| 693 | 742 |
| 694 // Reset user flow to default, so that special flow will not affect next | 743 // Reset user flow to default, so that special flow will not affect next |
| 695 // attempt. | 744 // attempt. |
| 696 UserManager::Get()->ResetUserFlow(last_login_attempt_username_); | 745 UserManager::Get()->ResetUserFlow(last_login_attempt_username_); |
| 697 | 746 |
| 698 if (login_status_consumer_) | 747 if (login_status_consumer_) |
| 699 login_status_consumer_->OnLoginFailure(failure); | 748 login_status_consumer_->OnLoginFailure(failure); |
| 700 | 749 |
| 701 // Clear the recorded displayed email so it won't affect any future attempts. | 750 // Clear the recorded displayed email so it won't affect any future attempts. |
| 702 display_email_.clear(); | 751 display_email_.clear(); |
| 703 } | 752 } |
| 704 | 753 |
| 705 void ExistingUserController::OnLoginSuccess( | 754 void ExistingUserController::OnLoginSuccess( |
| 706 const std::string& username, | 755 const std::string& username, |
| 707 const std::string& password, | 756 const std::string& password, |
| 708 bool pending_requests, | 757 bool pending_requests, |
| 709 bool using_oauth) { | 758 bool using_oauth) { |
| 710 is_login_in_progress_ = false; | 759 is_login_in_progress_ = false; |
| 711 offline_failed_ = false; | 760 offline_failed_ = false; |
| 712 | 761 |
| 762 StopPublicSessionAutoLoginTimer(); | |
| 763 | |
| 713 bool has_cookies = | 764 bool has_cookies = |
| 714 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION; | 765 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION; |
| 715 | 766 |
| 716 // Login performer will be gone so cache this value to use | 767 // Login performer will be gone so cache this value to use |
| 717 // once profile is loaded. | 768 // once profile is loaded. |
| 718 password_changed_ = login_performer_->password_changed(); | 769 password_changed_ = login_performer_->password_changed(); |
| 719 | 770 |
| 720 // LoginPerformer instance will delete itself once online auth result is OK. | 771 // LoginPerformer instance will delete itself once online auth result is OK. |
| 721 // In case of failure it'll bring up ScreenLock and ask for | 772 // In case of failure it'll bring up ScreenLock and ask for |
| 722 // correct password/display error message. | 773 // correct password/display error message. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 828 // Reenable clicking on other windows and status area. | 879 // Reenable clicking on other windows and status area. |
| 829 login_display_->SetUIEnabled(true); | 880 login_display_->SetUIEnabled(true); |
| 830 login_display_->ShowSigninUI(email); | 881 login_display_->ShowSigninUI(email); |
| 831 | 882 |
| 832 if (login_status_consumer_) { | 883 if (login_status_consumer_) { |
| 833 login_status_consumer_->OnLoginFailure(LoginFailure( | 884 login_status_consumer_->OnLoginFailure(LoginFailure( |
| 834 LoginFailure::WHITELIST_CHECK_FAILED)); | 885 LoginFailure::WHITELIST_CHECK_FAILED)); |
| 835 } | 886 } |
| 836 | 887 |
| 837 display_email_.clear(); | 888 display_email_.clear(); |
| 889 | |
| 890 StartPublicSessionAutoLoginTimer(); | |
| 838 } | 891 } |
| 839 | 892 |
| 840 void ExistingUserController::PolicyLoadFailed() { | 893 void ExistingUserController::PolicyLoadFailed() { |
| 841 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); | 894 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); |
| 842 | 895 |
| 843 // Reenable clicking on other windows and status area. | 896 // Reenable clicking on other windows and status area. |
| 844 login_display_->SetUIEnabled(true); | 897 login_display_->SetUIEnabled(true); |
| 845 | 898 |
| 846 display_email_.clear(); | 899 display_email_.clear(); |
| 900 | |
| 901 // Policy load failure stops login attempts -- restart the timer. | |
| 902 StartPublicSessionAutoLoginTimer(); | |
| 847 } | 903 } |
| 848 | 904 |
| 849 void ExistingUserController::OnOnlineChecked(const std::string& username, | 905 void ExistingUserController::OnOnlineChecked(const std::string& username, |
| 850 bool success) { | 906 bool success) { |
| 851 if (success && last_login_attempt_username_ == username) { | 907 if (success && last_login_attempt_username_ == username) { |
| 852 online_succeeded_for_ = username; | 908 online_succeeded_for_ = username; |
| 853 // Wait for login attempt to end, if it hasn't yet. | 909 // Wait for login attempt to end, if it hasn't yet. |
| 854 if (offline_failed_ && !is_login_in_progress_) | 910 if (offline_failed_ && !is_login_in_progress_) |
| 855 ShowGaiaPasswordChanged(username); | 911 ShowGaiaPasswordChanged(username); |
| 856 } | 912 } |
| 857 } | 913 } |
| 858 | 914 |
| 859 //////////////////////////////////////////////////////////////////////////////// | 915 //////////////////////////////////////////////////////////////////////////////// |
| 860 // ExistingUserController, private: | 916 // ExistingUserController, private: |
| 861 | 917 |
| 862 void ExistingUserController::ActivateWizard(const std::string& screen_name) { | 918 void ExistingUserController::ActivateWizard(const std::string& screen_name) { |
| 863 DictionaryValue* params = NULL; | 919 DictionaryValue* params = NULL; |
| 864 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) { | 920 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) { |
| 865 params = new DictionaryValue; | 921 params = new DictionaryValue; |
| 866 params->SetString("start_url", guest_mode_url_.spec()); | 922 params->SetString("start_url", guest_mode_url_.spec()); |
| 867 } | 923 } |
| 868 host_->StartWizard(screen_name, params); | 924 host_->StartWizard(screen_name, params); |
| 869 } | 925 } |
| 870 | 926 |
| 927 base::OneShotTimer<ExistingUserController>& | |
| 928 ExistingUserController::auto_login_timer() { | |
| 929 if (!auto_login_timer_) | |
| 930 auto_login_timer_.reset(new base::OneShotTimer<ExistingUserController>); | |
| 931 return *auto_login_timer_; | |
| 932 } | |
| 933 | |
| 934 void ExistingUserController::ConfigurePublicSessionAutoLogin() { | |
| 935 if (!cros_settings_->GetString( | |
| 936 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
| 937 &public_session_auto_login_username_)) { | |
| 938 public_session_auto_login_username_ = ""; | |
| 939 } | |
| 940 if (!cros_settings_->GetInteger( | |
| 941 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
| 942 &public_session_auto_login_delay_)) { | |
| 943 public_session_auto_login_delay_ = 0; | |
| 944 } | |
| 945 | |
| 946 if (!public_session_auto_login_username_.empty()) | |
| 947 StartPublicSessionAutoLoginTimer(); | |
| 948 else | |
| 949 StopPublicSessionAutoLoginTimer(); | |
| 950 } | |
| 951 | |
| 952 void ExistingUserController::ResetPublicSessionAutoLoginTimer() { | |
| 953 // Only restart the auto-login timer if it's already running. | |
| 954 if (auto_login_timer().IsRunning()) { | |
|
bartfab (slow)
2013/02/28 10:21:33
This and the many calls to StopPublicSessionTimer(
dconnelly
2013/02/28 12:52:56
Done.
| |
| 955 StopPublicSessionAutoLoginTimer(); | |
| 956 StartPublicSessionAutoLoginTimer(); | |
| 957 } | |
| 958 } | |
| 959 | |
| 960 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() { | |
| 961 DCHECK(signin_screen_ready_ && | |
| 962 !is_login_in_progress_ && | |
| 963 !public_session_auto_login_username_.empty()); | |
| 964 LoginAsPublicAccount(public_session_auto_login_username_); | |
| 965 } | |
| 966 | |
| 967 void ExistingUserController::StopPublicSessionAutoLoginTimer() { | |
| 968 auto_login_timer().Stop(); | |
| 969 } | |
| 970 | |
| 971 void ExistingUserController::StartPublicSessionAutoLoginTimer() { | |
| 972 if (!signin_screen_ready_ || | |
| 973 is_login_in_progress_ || | |
| 974 public_session_auto_login_username_.empty()) { | |
| 975 return; | |
| 976 } | |
| 977 | |
| 978 // Start the auto-login timer. | |
| 979 auto_login_timer().Start( | |
| 980 FROM_HERE, | |
| 981 base::TimeDelta::FromMilliseconds( | |
| 982 public_session_auto_login_delay_), | |
| 983 base::Bind( | |
| 984 &ExistingUserController::OnPublicSessionAutoLoginTimerFire, | |
| 985 weak_factory_.GetWeakPtr())); | |
| 986 } | |
| 987 | |
| 871 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { | 988 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { |
| 872 return host_->GetNativeWindow(); | 989 return host_->GetNativeWindow(); |
| 873 } | 990 } |
| 874 | 991 |
| 875 void ExistingUserController::InitializeStartUrls() const { | 992 void ExistingUserController::InitializeStartUrls() const { |
| 876 std::vector<std::string> start_urls; | 993 std::vector<std::string> start_urls; |
| 877 | 994 |
| 878 PrefService* prefs = g_browser_process->local_state(); | 995 PrefService* prefs = g_browser_process->local_state(); |
| 879 const base::ListValue *urls; | 996 const base::ListValue *urls; |
| 880 bool show_getstarted_guide = false; | 997 bool show_getstarted_guide = false; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1008 // changed. | 1125 // changed. |
| 1009 UserManager::Get()->SaveUserOAuthStatus( | 1126 UserManager::Get()->SaveUserOAuthStatus( |
| 1010 username, | 1127 username, |
| 1011 User::OAUTH2_TOKEN_STATUS_INVALID); | 1128 User::OAUTH2_TOKEN_STATUS_INVALID); |
| 1012 | 1129 |
| 1013 login_display_->SetUIEnabled(true); | 1130 login_display_->SetUIEnabled(true); |
| 1014 login_display_->ShowGaiaPasswordChanged(username); | 1131 login_display_->ShowGaiaPasswordChanged(username); |
| 1015 } | 1132 } |
| 1016 | 1133 |
| 1017 } // namespace chromeos | 1134 } // namespace chromeos |
| OLD | NEW |