| 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 is_login_in_progress_ = true; | 444 is_login_in_progress_ = true; |
| 445 if (gaia::ExtractDomainName(user_context.username) == | 445 if (gaia::ExtractDomainName(user_context.username) == |
| 446 UserManager::kLocallyManagedUserDomain) { | 446 UserManager::kLocallyManagedUserDomain) { |
| 447 login_performer_->LoginAsLocallyManagedUser( | 447 login_performer_->LoginAsLocallyManagedUser( |
| 448 UserContext(user_context.username, | 448 UserContext(user_context.username, |
| 449 user_context.password, | 449 user_context.password, |
| 450 std::string())); // auth_code | 450 std::string())); // auth_code |
| 451 } else { | 451 } else { |
| 452 login_performer_->PerformLogin(user_context, auth_mode); | 452 login_performer_->PerformLogin(user_context, auth_mode); |
| 453 } | 453 } |
| 454 accessibility::MaybeSpeak( | 454 AccessibilityManager::Get()->MaybeSpeak( |
| 455 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); | 455 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); |
| 456 } | 456 } |
| 457 | 457 |
| 458 void ExistingUserController::LoginAsRetailModeUser() { | 458 void ExistingUserController::LoginAsRetailModeUser() { |
| 459 // Stop the auto-login timer when attempting login. | 459 // Stop the auto-login timer when attempting login. |
| 460 StopPublicSessionAutoLoginTimer(); | 460 StopPublicSessionAutoLoginTimer(); |
| 461 | 461 |
| 462 // Disable clicking on other windows. | 462 // Disable clicking on other windows. |
| 463 login_display_->SetUIEnabled(false); | 463 login_display_->SetUIEnabled(false); |
| 464 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once | 464 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once |
| 465 // the enterprise policy wiring is done for retail mode. | 465 // the enterprise policy wiring is done for retail mode. |
| 466 | 466 |
| 467 // Only one instance of LoginPerformer should exist at a time. | 467 // Only one instance of LoginPerformer should exist at a time. |
| 468 login_performer_.reset(NULL); | 468 login_performer_.reset(NULL); |
| 469 login_performer_.reset(new LoginPerformer(this)); | 469 login_performer_.reset(new LoginPerformer(this)); |
| 470 is_login_in_progress_ = true; | 470 is_login_in_progress_ = true; |
| 471 login_performer_->LoginRetailMode(); | 471 login_performer_->LoginRetailMode(); |
| 472 accessibility::MaybeSpeak( | 472 AccessibilityManager::Get()->MaybeSpeak( |
| 473 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); | 473 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); |
| 474 } | 474 } |
| 475 | 475 |
| 476 void ExistingUserController::LoginAsGuest() { | 476 void ExistingUserController::LoginAsGuest() { |
| 477 if (is_login_in_progress_ || UserManager::Get()->IsUserLoggedIn()) | 477 if (is_login_in_progress_ || UserManager::Get()->IsUserLoggedIn()) |
| 478 return; | 478 return; |
| 479 | 479 |
| 480 // Stop the auto-login timer when attempting login. | 480 // Stop the auto-login timer when attempting login. |
| 481 StopPublicSessionAutoLoginTimer(); | 481 StopPublicSessionAutoLoginTimer(); |
| 482 | 482 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 StartPublicSessionAutoLoginTimer(); | 515 StartPublicSessionAutoLoginTimer(); |
| 516 display_email_.clear(); | 516 display_email_.clear(); |
| 517 return; | 517 return; |
| 518 } | 518 } |
| 519 | 519 |
| 520 // Only one instance of LoginPerformer should exist at a time. | 520 // Only one instance of LoginPerformer should exist at a time. |
| 521 login_performer_.reset(NULL); | 521 login_performer_.reset(NULL); |
| 522 login_performer_.reset(new LoginPerformer(this)); | 522 login_performer_.reset(new LoginPerformer(this)); |
| 523 is_login_in_progress_ = true; | 523 is_login_in_progress_ = true; |
| 524 login_performer_->LoginOffTheRecord(); | 524 login_performer_->LoginOffTheRecord(); |
| 525 accessibility::MaybeSpeak( | 525 AccessibilityManager::Get()->MaybeSpeak( |
| 526 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); | 526 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); |
| 527 } | 527 } |
| 528 | 528 |
| 529 void ExistingUserController::MigrateUserData(const std::string& old_password) { | 529 void ExistingUserController::MigrateUserData(const std::string& old_password) { |
| 530 // LoginPerformer instance has state of the user so it should exist. | 530 // LoginPerformer instance has state of the user so it should exist. |
| 531 if (login_performer_.get()) | 531 if (login_performer_.get()) |
| 532 login_performer_->RecoverEncryptedData(old_password); | 532 login_performer_->RecoverEncryptedData(old_password); |
| 533 } | 533 } |
| 534 | 534 |
| 535 void ExistingUserController::LoginAsPublicAccount( | 535 void ExistingUserController::LoginAsPublicAccount( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 login_display_->SetUIEnabled(true); | 571 login_display_->SetUIEnabled(true); |
| 572 StartPublicSessionAutoLoginTimer(); | 572 StartPublicSessionAutoLoginTimer(); |
| 573 return; | 573 return; |
| 574 } | 574 } |
| 575 | 575 |
| 576 // Only one instance of LoginPerformer should exist at a time. | 576 // Only one instance of LoginPerformer should exist at a time. |
| 577 login_performer_.reset(NULL); | 577 login_performer_.reset(NULL); |
| 578 login_performer_.reset(new LoginPerformer(this)); | 578 login_performer_.reset(new LoginPerformer(this)); |
| 579 is_login_in_progress_ = true; | 579 is_login_in_progress_ = true; |
| 580 login_performer_->LoginAsPublicAccount(username); | 580 login_performer_->LoginAsPublicAccount(username); |
| 581 accessibility::MaybeSpeak( | 581 AccessibilityManager::Get()->MaybeSpeak( |
| 582 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); | 582 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); |
| 583 } | 583 } |
| 584 | 584 |
| 585 void ExistingUserController::OnSigninScreenReady() { | 585 void ExistingUserController::OnSigninScreenReady() { |
| 586 signin_screen_ready_ = true; | 586 signin_screen_ready_ = true; |
| 587 StartPublicSessionAutoLoginTimer(); | 587 StartPublicSessionAutoLoginTimer(); |
| 588 } | 588 } |
| 589 | 589 |
| 590 void ExistingUserController::OnUserSelected(const std::string& username) { | 590 void ExistingUserController::OnUserSelected(const std::string& username) { |
| 591 login_performer_.reset(NULL); | 591 login_performer_.reset(NULL); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 weak_factory_.GetWeakPtr())); | 967 weak_factory_.GetWeakPtr())); |
| 968 } | 968 } |
| 969 | 969 |
| 970 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { | 970 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { |
| 971 return host_->GetNativeWindow(); | 971 return host_->GetNativeWindow(); |
| 972 } | 972 } |
| 973 | 973 |
| 974 void ExistingUserController::InitializeStartUrls() const { | 974 void ExistingUserController::InitializeStartUrls() const { |
| 975 std::vector<std::string> start_urls; | 975 std::vector<std::string> start_urls; |
| 976 | 976 |
| 977 PrefService* prefs = g_browser_process->local_state(); | |
| 978 const base::ListValue *urls; | 977 const base::ListValue *urls; |
| 979 bool show_getstarted_guide = false; | 978 bool show_getstarted_guide = false; |
| 980 if (UserManager::Get()->IsLoggedInAsDemoUser()) { | 979 if (UserManager::Get()->IsLoggedInAsDemoUser()) { |
| 981 if (CrosSettings::Get()->GetList(kStartUpUrls, &urls)) { | 980 if (CrosSettings::Get()->GetList(kStartUpUrls, &urls)) { |
| 982 // The retail mode user will get start URLs from a special policy if it is | 981 // The retail mode user will get start URLs from a special policy if it is |
| 983 // set. | 982 // set. |
| 984 for (base::ListValue::const_iterator it = urls->begin(); | 983 for (base::ListValue::const_iterator it = urls->begin(); |
| 985 it != urls->end(); ++it) { | 984 it != urls->end(); ++it) { |
| 986 std::string url; | 985 std::string url; |
| 987 if ((*it)->GetAsString(&url)) | 986 if ((*it)->GetAsString(&url)) |
| 988 start_urls.push_back(url); | 987 start_urls.push_back(url); |
| 989 } | 988 } |
| 990 } | 989 } |
| 991 // Skip the default first-run behavior for public accounts. | 990 // Skip the default first-run behavior for public accounts. |
| 992 } else if (!UserManager::Get()->IsLoggedInAsPublicAccount()) { | 991 } else if (!UserManager::Get()->IsLoggedInAsPublicAccount()) { |
| 993 if (prefs->GetBoolean(prefs::kSpokenFeedbackEnabled)) { | 992 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { |
| 994 const char* url = kChromeVoxTutorialURLPattern; | 993 const char* url = kChromeVoxTutorialURLPattern; |
| 994 PrefService* prefs = g_browser_process->local_state(); |
| 995 const std::string current_locale = | 995 const std::string current_locale = |
| 996 StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); | 996 StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); |
| 997 std::string vox_url = base::StringPrintf(url, current_locale.c_str()); | 997 std::string vox_url = base::StringPrintf(url, current_locale.c_str()); |
| 998 start_urls.push_back(vox_url); | 998 start_urls.push_back(vox_url); |
| 999 } else { | 999 } else { |
| 1000 show_getstarted_guide = true; | 1000 show_getstarted_guide = true; |
| 1001 } | 1001 } |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 ServicesCustomizationDocument* customization = | 1004 ServicesCustomizationDocument* customization = |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 // changed. | 1106 // changed. |
| 1107 UserManager::Get()->SaveUserOAuthStatus( | 1107 UserManager::Get()->SaveUserOAuthStatus( |
| 1108 username, | 1108 username, |
| 1109 User::OAUTH2_TOKEN_STATUS_INVALID); | 1109 User::OAUTH2_TOKEN_STATUS_INVALID); |
| 1110 | 1110 |
| 1111 login_display_->SetUIEnabled(true); | 1111 login_display_->SetUIEnabled(true); |
| 1112 login_display_->ShowGaiaPasswordChanged(username); | 1112 login_display_->ShowGaiaPasswordChanged(username); |
| 1113 } | 1113 } |
| 1114 | 1114 |
| 1115 } // namespace chromeos | 1115 } // namespace chromeos |
| OLD | NEW |