| 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 "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
| 18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 19 #include "base/stringprintf.h" | 19 #include "base/stringprintf.h" |
| 20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 21 #include "base/values.h" | 21 #include "base/values.h" |
| 22 #include "base/version.h" | 22 #include "base/version.h" |
| 23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 24 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 25 #include "chrome/browser/chromeos/boot_times_loader.h" | 25 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 26 #include "chrome/browser/chromeos/cros/cros_library.h" | 26 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 27 #include "chrome/browser/chromeos/customization_document.h" | 27 #include "chrome/browser/chromeos/customization_document.h" |
| 28 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 28 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
| 29 #include "chrome/browser/chromeos/login/helper.h" | 29 #include "chrome/browser/chromeos/login/helper.h" |
| 30 #include "chrome/browser/chromeos/login/login_display_host.h" | 30 #include "chrome/browser/chromeos/login/login_display_host.h" |
| 31 #include "chrome/browser/chromeos/login/login_utils.h" | 31 #include "chrome/browser/chromeos/login/login_utils.h" |
| 32 #include "chrome/browser/chromeos/login/startup_utils.h" | 32 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 33 #include "chrome/browser/chromeos/login/user_manager.h" | 33 #include "chrome/browser/chromeos/login/user_manager.h" |
| 34 #include "chrome/browser/chromeos/login/wizard_controller.h" | 34 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 is_login_in_progress_ = true; | 439 is_login_in_progress_ = true; |
| 440 if (gaia::ExtractDomainName(user_context.username) == | 440 if (gaia::ExtractDomainName(user_context.username) == |
| 441 UserManager::kLocallyManagedUserDomain) { | 441 UserManager::kLocallyManagedUserDomain) { |
| 442 login_performer_->LoginAsLocallyManagedUser( | 442 login_performer_->LoginAsLocallyManagedUser( |
| 443 UserContext(user_context.username, | 443 UserContext(user_context.username, |
| 444 user_context.password, | 444 user_context.password, |
| 445 std::string())); // auth_code | 445 std::string())); // auth_code |
| 446 } else { | 446 } else { |
| 447 login_performer_->PerformLogin(user_context, auth_mode); | 447 login_performer_->PerformLogin(user_context, auth_mode); |
| 448 } | 448 } |
| 449 accessibility::MaybeSpeak( | 449 AccessibilityManager::Get()->MaybeSpeak( |
| 450 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); | 450 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); |
| 451 } | 451 } |
| 452 | 452 |
| 453 void ExistingUserController::LoginAsRetailModeUser() { | 453 void ExistingUserController::LoginAsRetailModeUser() { |
| 454 // Stop the auto-login timer when attempting login. | 454 // Stop the auto-login timer when attempting login. |
| 455 StopPublicSessionAutoLoginTimer(); | 455 StopPublicSessionAutoLoginTimer(); |
| 456 | 456 |
| 457 // Disable clicking on other windows. | 457 // Disable clicking on other windows. |
| 458 login_display_->SetUIEnabled(false); | 458 login_display_->SetUIEnabled(false); |
| 459 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once | 459 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once |
| 460 // the enterprise policy wiring is done for retail mode. | 460 // the enterprise policy wiring is done for retail mode. |
| 461 | 461 |
| 462 // Only one instance of LoginPerformer should exist at a time. | 462 // Only one instance of LoginPerformer should exist at a time. |
| 463 login_performer_.reset(NULL); | 463 login_performer_.reset(NULL); |
| 464 login_performer_.reset(new LoginPerformer(this)); | 464 login_performer_.reset(new LoginPerformer(this)); |
| 465 is_login_in_progress_ = true; | 465 is_login_in_progress_ = true; |
| 466 login_performer_->LoginRetailMode(); | 466 login_performer_->LoginRetailMode(); |
| 467 accessibility::MaybeSpeak( | 467 AccessibilityManager::Get()->MaybeSpeak( |
| 468 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); | 468 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); |
| 469 } | 469 } |
| 470 | 470 |
| 471 void ExistingUserController::LoginAsGuest() { | 471 void ExistingUserController::LoginAsGuest() { |
| 472 if (is_login_in_progress_ || UserManager::Get()->IsUserLoggedIn()) | 472 if (is_login_in_progress_ || UserManager::Get()->IsUserLoggedIn()) |
| 473 return; | 473 return; |
| 474 | 474 |
| 475 // Stop the auto-login timer when attempting login. | 475 // Stop the auto-login timer when attempting login. |
| 476 StopPublicSessionAutoLoginTimer(); | 476 StopPublicSessionAutoLoginTimer(); |
| 477 | 477 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 StartPublicSessionAutoLoginTimer(); | 510 StartPublicSessionAutoLoginTimer(); |
| 511 display_email_.clear(); | 511 display_email_.clear(); |
| 512 return; | 512 return; |
| 513 } | 513 } |
| 514 | 514 |
| 515 // Only one instance of LoginPerformer should exist at a time. | 515 // Only one instance of LoginPerformer should exist at a time. |
| 516 login_performer_.reset(NULL); | 516 login_performer_.reset(NULL); |
| 517 login_performer_.reset(new LoginPerformer(this)); | 517 login_performer_.reset(new LoginPerformer(this)); |
| 518 is_login_in_progress_ = true; | 518 is_login_in_progress_ = true; |
| 519 login_performer_->LoginOffTheRecord(); | 519 login_performer_->LoginOffTheRecord(); |
| 520 accessibility::MaybeSpeak( | 520 AccessibilityManager::Get()->MaybeSpeak( |
| 521 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); | 521 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); |
| 522 } | 522 } |
| 523 | 523 |
| 524 void ExistingUserController::MigrateUserData(const std::string& old_password) { | 524 void ExistingUserController::MigrateUserData(const std::string& old_password) { |
| 525 // LoginPerformer instance has state of the user so it should exist. | 525 // LoginPerformer instance has state of the user so it should exist. |
| 526 if (login_performer_.get()) | 526 if (login_performer_.get()) |
| 527 login_performer_->RecoverEncryptedData(old_password); | 527 login_performer_->RecoverEncryptedData(old_password); |
| 528 } | 528 } |
| 529 | 529 |
| 530 void ExistingUserController::LoginAsPublicAccount( | 530 void ExistingUserController::LoginAsPublicAccount( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 login_display_->SetUIEnabled(true); | 566 login_display_->SetUIEnabled(true); |
| 567 StartPublicSessionAutoLoginTimer(); | 567 StartPublicSessionAutoLoginTimer(); |
| 568 return; | 568 return; |
| 569 } | 569 } |
| 570 | 570 |
| 571 // Only one instance of LoginPerformer should exist at a time. | 571 // Only one instance of LoginPerformer should exist at a time. |
| 572 login_performer_.reset(NULL); | 572 login_performer_.reset(NULL); |
| 573 login_performer_.reset(new LoginPerformer(this)); | 573 login_performer_.reset(new LoginPerformer(this)); |
| 574 is_login_in_progress_ = true; | 574 is_login_in_progress_ = true; |
| 575 login_performer_->LoginAsPublicAccount(username); | 575 login_performer_->LoginAsPublicAccount(username); |
| 576 accessibility::MaybeSpeak( | 576 AccessibilityManager::Get()->MaybeSpeak( |
| 577 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); | 577 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); |
| 578 } | 578 } |
| 579 | 579 |
| 580 void ExistingUserController::OnSigninScreenReady() { | 580 void ExistingUserController::OnSigninScreenReady() { |
| 581 signin_screen_ready_ = true; | 581 signin_screen_ready_ = true; |
| 582 StartPublicSessionAutoLoginTimer(); | 582 StartPublicSessionAutoLoginTimer(); |
| 583 } | 583 } |
| 584 | 584 |
| 585 void ExistingUserController::OnUserSelected(const std::string& username) { | 585 void ExistingUserController::OnUserSelected(const std::string& username) { |
| 586 login_performer_.reset(NULL); | 586 login_performer_.reset(NULL); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 weak_factory_.GetWeakPtr())); | 989 weak_factory_.GetWeakPtr())); |
| 990 } | 990 } |
| 991 | 991 |
| 992 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { | 992 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { |
| 993 return host_->GetNativeWindow(); | 993 return host_->GetNativeWindow(); |
| 994 } | 994 } |
| 995 | 995 |
| 996 void ExistingUserController::InitializeStartUrls() const { | 996 void ExistingUserController::InitializeStartUrls() const { |
| 997 std::vector<std::string> start_urls; | 997 std::vector<std::string> start_urls; |
| 998 | 998 |
| 999 PrefService* prefs = g_browser_process->local_state(); | |
| 1000 const base::ListValue *urls; | 999 const base::ListValue *urls; |
| 1001 if (UserManager::Get()->IsLoggedInAsDemoUser()) { | 1000 if (UserManager::Get()->IsLoggedInAsDemoUser()) { |
| 1002 if (CrosSettings::Get()->GetList(kStartUpUrls, &urls)) { | 1001 if (CrosSettings::Get()->GetList(kStartUpUrls, &urls)) { |
| 1003 // The retail mode user will get start URLs from a special policy if it is | 1002 // The retail mode user will get start URLs from a special policy if it is |
| 1004 // set. | 1003 // set. |
| 1005 for (base::ListValue::const_iterator it = urls->begin(); | 1004 for (base::ListValue::const_iterator it = urls->begin(); |
| 1006 it != urls->end(); ++it) { | 1005 it != urls->end(); ++it) { |
| 1007 std::string url; | 1006 std::string url; |
| 1008 if ((*it)->GetAsString(&url)) | 1007 if ((*it)->GetAsString(&url)) |
| 1009 start_urls.push_back(url); | 1008 start_urls.push_back(url); |
| 1010 } | 1009 } |
| 1011 } | 1010 } |
| 1012 // Skip the default first-run behavior for public accounts. | 1011 // Skip the default first-run behavior for public accounts. |
| 1013 } else if (!UserManager::Get()->IsLoggedInAsPublicAccount()) { | 1012 } else if (!UserManager::Get()->IsLoggedInAsPublicAccount()) { |
| 1014 if (prefs->GetBoolean(prefs::kSpokenFeedbackEnabled)) { | 1013 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { |
| 1015 const char* url = kChromeVoxTutorialURLPattern; | 1014 const char* url = kChromeVoxTutorialURLPattern; |
| 1015 PrefService* prefs = g_browser_process->local_state(); |
| 1016 const std::string current_locale = | 1016 const std::string current_locale = |
| 1017 StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); | 1017 StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); |
| 1018 std::string vox_url = base::StringPrintf(url, current_locale.c_str()); | 1018 std::string vox_url = base::StringPrintf(url, current_locale.c_str()); |
| 1019 start_urls.push_back(vox_url); | 1019 start_urls.push_back(vox_url); |
| 1020 } | 1020 } |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 ServicesCustomizationDocument* customization = | 1023 ServicesCustomizationDocument* customization = |
| 1024 ServicesCustomizationDocument::GetInstance(); | 1024 ServicesCustomizationDocument::GetInstance(); |
| 1025 if (!ServicesCustomizationDocument::WasApplied() && | 1025 if (!ServicesCustomizationDocument::WasApplied() && |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 // changed. | 1121 // changed. |
| 1122 UserManager::Get()->SaveUserOAuthStatus( | 1122 UserManager::Get()->SaveUserOAuthStatus( |
| 1123 username, | 1123 username, |
| 1124 User::OAUTH2_TOKEN_STATUS_INVALID); | 1124 User::OAUTH2_TOKEN_STATUS_INVALID); |
| 1125 | 1125 |
| 1126 login_display_->SetUIEnabled(true); | 1126 login_display_->SetUIEnabled(true); |
| 1127 login_display_->ShowGaiaPasswordChanged(username); | 1127 login_display_->ShowGaiaPasswordChanged(username); |
| 1128 } | 1128 } |
| 1129 | 1129 |
| 1130 } // namespace chromeos | 1130 } // namespace chromeos |
| OLD | NEW |