| 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 <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" | 46 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" |
| 47 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" | 47 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
| 48 #include "chrome/common/channel_info.h" | 48 #include "chrome/common/channel_info.h" |
| 49 #include "chrome/common/chrome_switches.h" | 49 #include "chrome/common/chrome_switches.h" |
| 50 #include "chrome/common/url_constants.h" | 50 #include "chrome/common/url_constants.h" |
| 51 #include "chrome/grit/generated_resources.h" | 51 #include "chrome/grit/generated_resources.h" |
| 52 #include "chromeos/chromeos_switches.h" | 52 #include "chromeos/chromeos_switches.h" |
| 53 #include "chromeos/dbus/dbus_thread_manager.h" | 53 #include "chromeos/dbus/dbus_thread_manager.h" |
| 54 #include "chromeos/dbus/power_manager_client.h" | 54 #include "chromeos/dbus/power_manager_client.h" |
| 55 #include "chromeos/dbus/session_manager_client.h" | 55 #include "chromeos/dbus/session_manager_client.h" |
| 56 #include "chromeos/login/user_names.h" | |
| 57 #include "chromeos/settings/cros_settings_names.h" | 56 #include "chromeos/settings/cros_settings_names.h" |
| 58 #include "components/google/core/browser/google_util.h" | 57 #include "components/google/core/browser/google_util.h" |
| 59 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 58 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 60 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 59 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 61 #include "components/policy/core/common/policy_map.h" | 60 #include "components/policy/core/common/policy_map.h" |
| 62 #include "components/policy/core/common/policy_service.h" | 61 #include "components/policy/core/common/policy_service.h" |
| 63 #include "components/policy/core/common/policy_types.h" | 62 #include "components/policy/core/common/policy_types.h" |
| 64 #include "components/policy/policy_constants.h" | 63 #include "components/policy/policy_constants.h" |
| 65 #include "components/prefs/pref_service.h" | 64 #include "components/prefs/pref_service.h" |
| 66 #include "components/session_manager/core/session_manager.h" | 65 #include "components/session_manager/core/session_manager.h" |
| 67 #include "components/signin/core/account_id/account_id.h" | 66 #include "components/signin/core/account_id/account_id.h" |
| 68 #include "components/signin/core/browser/signin_client.h" | 67 #include "components/signin/core/browser/signin_client.h" |
| 69 #include "components/user_manager/known_user.h" | 68 #include "components/user_manager/known_user.h" |
| 70 #include "components/user_manager/user_manager.h" | 69 #include "components/user_manager/user_manager.h" |
| 70 #include "components/user_manager/user_names.h" |
| 71 #include "components/user_manager/user_type.h" | 71 #include "components/user_manager/user_type.h" |
| 72 #include "components/version_info/version_info.h" | 72 #include "components/version_info/version_info.h" |
| 73 #include "content/public/browser/browser_thread.h" | 73 #include "content/public/browser/browser_thread.h" |
| 74 #include "content/public/browser/notification_service.h" | 74 #include "content/public/browser/notification_service.h" |
| 75 #include "content/public/browser/notification_types.h" | 75 #include "content/public/browser/notification_types.h" |
| 76 #include "content/public/browser/user_metrics.h" | 76 #include "content/public/browser/user_metrics.h" |
| 77 #include "google_apis/gaia/gaia_auth_util.h" | 77 #include "google_apis/gaia/gaia_auth_util.h" |
| 78 #include "google_apis/gaia/google_service_auth_error.h" | 78 #include "google_apis/gaia/google_service_auth_error.h" |
| 79 #include "net/http/http_auth_cache.h" | 79 #include "net/http/http_auth_cache.h" |
| 80 #include "net/http/http_network_session.h" | 80 #include "net/http/http_network_session.h" |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 405 |
| 406 // Use the same LoginPerformer for subsequent login as it has state | 406 // Use the same LoginPerformer for subsequent login as it has state |
| 407 // such as Authenticator instance. | 407 // such as Authenticator instance. |
| 408 if (!login_performer_.get() || num_login_attempts_ <= 1) { | 408 if (!login_performer_.get() || num_login_attempts_ <= 1) { |
| 409 // Only one instance of LoginPerformer should exist at a time. | 409 // Only one instance of LoginPerformer should exist at a time. |
| 410 login_performer_.reset(nullptr); | 410 login_performer_.reset(nullptr); |
| 411 login_performer_.reset(new ChromeLoginPerformer(this)); | 411 login_performer_.reset(new ChromeLoginPerformer(this)); |
| 412 } | 412 } |
| 413 | 413 |
| 414 if (gaia::ExtractDomainName(user_context.GetAccountId().GetUserEmail()) == | 414 if (gaia::ExtractDomainName(user_context.GetAccountId().GetUserEmail()) == |
| 415 chromeos::login::kSupervisedUserDomain) { | 415 user_manager::kSupervisedUserDomain) { |
| 416 login_performer_->LoginAsSupervisedUser(user_context); | 416 login_performer_->LoginAsSupervisedUser(user_context); |
| 417 } else { | 417 } else { |
| 418 login_performer_->PerformLogin(user_context, auth_mode); | 418 login_performer_->PerformLogin(user_context, auth_mode); |
| 419 RecordPasswordLoginEvent(user_context); | 419 RecordPasswordLoginEvent(user_context); |
| 420 } | 420 } |
| 421 SendAccessibilityAlert( | 421 SendAccessibilityAlert( |
| 422 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); | 422 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); |
| 423 } | 423 } |
| 424 | 424 |
| 425 void ExistingUserController::MigrateUserData(const std::string& old_password) { | 425 void ExistingUserController::MigrateUserData(const std::string& old_password) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 if (failure.reason() == AuthFailure::OWNER_REQUIRED) { | 583 if (failure.reason() == AuthFailure::OWNER_REQUIRED) { |
| 584 ShowError(IDS_LOGIN_ERROR_OWNER_REQUIRED, error); | 584 ShowError(IDS_LOGIN_ERROR_OWNER_REQUIRED, error); |
| 585 content::BrowserThread::PostDelayedTask( | 585 content::BrowserThread::PostDelayedTask( |
| 586 content::BrowserThread::UI, FROM_HERE, | 586 content::BrowserThread::UI, FROM_HERE, |
| 587 base::Bind(&SessionManagerClient::StopSession, | 587 base::Bind(&SessionManagerClient::StopSession, |
| 588 base::Unretained(DBusThreadManager::Get()-> | 588 base::Unretained(DBusThreadManager::Get()-> |
| 589 GetSessionManagerClient())), | 589 GetSessionManagerClient())), |
| 590 base::TimeDelta::FromMilliseconds(kSafeModeRestartUiDelayMs)); | 590 base::TimeDelta::FromMilliseconds(kSafeModeRestartUiDelayMs)); |
| 591 } else if (failure.reason() == AuthFailure::TPM_ERROR) { | 591 } else if (failure.reason() == AuthFailure::TPM_ERROR) { |
| 592 ShowTPMError(); | 592 ShowTPMError(); |
| 593 } else if (last_login_attempt_account_id_ == login::GuestAccountId()) { | 593 } else if (last_login_attempt_account_id_ == user_manager::GuestAccountId()) { |
| 594 // Show no errors, just re-enable input. | 594 // Show no errors, just re-enable input. |
| 595 login_display_->ClearAndEnablePassword(); | 595 login_display_->ClearAndEnablePassword(); |
| 596 StartPublicSessionAutoLoginTimer(); | 596 StartPublicSessionAutoLoginTimer(); |
| 597 } else { | 597 } else { |
| 598 // Check networking after trying to login in case user is | 598 // Check networking after trying to login in case user is |
| 599 // cached locally or the local admin account. | 599 // cached locally or the local admin account. |
| 600 const bool is_known_user = user_manager::UserManager::Get()->IsKnownUser( | 600 const bool is_known_user = user_manager::UserManager::Get()->IsKnownUser( |
| 601 last_login_attempt_account_id_); | 601 last_login_attempt_account_id_); |
| 602 if (!network_state_helper_->IsConnected()) { | 602 if (!network_state_helper_->IsConnected()) { |
| 603 if (is_known_user) | 603 if (is_known_user) |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 } | 801 } |
| 802 | 802 |
| 803 bool ExistingUserController::password_changed() const { | 803 bool ExistingUserController::password_changed() const { |
| 804 if (login_performer_) | 804 if (login_performer_) |
| 805 return login_performer_->password_changed(); | 805 return login_performer_->password_changed(); |
| 806 | 806 |
| 807 return password_changed_; | 807 return password_changed_; |
| 808 } | 808 } |
| 809 | 809 |
| 810 void ExistingUserController::LoginAsGuest() { | 810 void ExistingUserController::LoginAsGuest() { |
| 811 PerformPreLoginActions( | 811 PerformPreLoginActions(UserContext(user_manager::USER_TYPE_GUEST, |
| 812 UserContext(user_manager::USER_TYPE_GUEST, login::GuestAccountId())); | 812 user_manager::GuestAccountId())); |
| 813 | 813 |
| 814 bool allow_guest; | 814 bool allow_guest; |
| 815 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 815 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
| 816 if (!allow_guest) { | 816 if (!allow_guest) { |
| 817 // Disallowed. The UI should normally not show the guest session button. | 817 // Disallowed. The UI should normally not show the guest session button. |
| 818 LOG(ERROR) << "Guest login attempt when guest mode is disallowed."; | 818 LOG(ERROR) << "Guest login attempt when guest mode is disallowed."; |
| 819 PerformLoginFinishedActions(true /* start public session timer */); | 819 PerformLoginFinishedActions(true /* start public session timer */); |
| 820 display_email_.clear(); | 820 display_email_.clear(); |
| 821 return; | 821 return; |
| 822 } | 822 } |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 } | 1263 } |
| 1264 | 1264 |
| 1265 // Otherwise, show the unrecoverable cryptohome error UI and ask user's | 1265 // Otherwise, show the unrecoverable cryptohome error UI and ask user's |
| 1266 // permission to collect a feedback. | 1266 // permission to collect a feedback. |
| 1267 RecordPasswordChangeFlow(LOGIN_PASSWORD_CHANGE_FLOW_CRYPTOHOME_FAILURE); | 1267 RecordPasswordChangeFlow(LOGIN_PASSWORD_CHANGE_FLOW_CRYPTOHOME_FAILURE); |
| 1268 VLOG(1) << "Show unrecoverable cryptohome error dialog."; | 1268 VLOG(1) << "Show unrecoverable cryptohome error dialog."; |
| 1269 login_display_->ShowUnrecoverableCrypthomeErrorDialog(); | 1269 login_display_->ShowUnrecoverableCrypthomeErrorDialog(); |
| 1270 } | 1270 } |
| 1271 | 1271 |
| 1272 } // namespace chromeos | 1272 } // namespace chromeos |
| OLD | NEW |