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" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 #include "chromeos/dbus/power_manager_client.h" | 57 #include "chromeos/dbus/power_manager_client.h" |
58 #include "chromeos/dbus/session_manager_client.h" | 58 #include "chromeos/dbus/session_manager_client.h" |
59 #include "chromeos/login/user_names.h" | 59 #include "chromeos/login/user_names.h" |
60 #include "chromeos/settings/cros_settings_names.h" | 60 #include "chromeos/settings/cros_settings_names.h" |
61 #include "components/google/core/browser/google_util.h" | 61 #include "components/google/core/browser/google_util.h" |
62 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 62 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
63 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 63 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
64 #include "components/policy/core/common/policy_map.h" | 64 #include "components/policy/core/common/policy_map.h" |
65 #include "components/policy/core/common/policy_service.h" | 65 #include "components/policy/core/common/policy_service.h" |
66 #include "components/policy/core/common/policy_types.h" | 66 #include "components/policy/core/common/policy_types.h" |
67 #include "components/user_manager/user_id.h" | |
67 #include "components/user_manager/user_manager.h" | 68 #include "components/user_manager/user_manager.h" |
68 #include "components/user_manager/user_type.h" | 69 #include "components/user_manager/user_type.h" |
69 #include "content/public/browser/browser_thread.h" | 70 #include "content/public/browser/browser_thread.h" |
70 #include "content/public/browser/notification_service.h" | 71 #include "content/public/browser/notification_service.h" |
71 #include "content/public/browser/notification_types.h" | 72 #include "content/public/browser/notification_types.h" |
72 #include "content/public/browser/user_metrics.h" | 73 #include "content/public/browser/user_metrics.h" |
73 #include "google_apis/gaia/gaia_auth_util.h" | 74 #include "google_apis/gaia/gaia_auth_util.h" |
74 #include "google_apis/gaia/google_service_auth_error.h" | 75 #include "google_apis/gaia/google_service_auth_error.h" |
75 #include "net/http/http_auth_cache.h" | 76 #include "net/http/http_auth_cache.h" |
76 #include "net/http/http_network_session.h" | 77 #include "net/http/http_network_session.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 | 146 |
146 } // namespace | 147 } // namespace |
147 | 148 |
148 // static | 149 // static |
149 ExistingUserController* ExistingUserController::current_controller_ = NULL; | 150 ExistingUserController* ExistingUserController::current_controller_ = NULL; |
150 | 151 |
151 //////////////////////////////////////////////////////////////////////////////// | 152 //////////////////////////////////////////////////////////////////////////////// |
152 // ExistingUserController, public: | 153 // ExistingUserController, public: |
153 | 154 |
154 ExistingUserController::ExistingUserController(LoginDisplayHost* host) | 155 ExistingUserController::ExistingUserController(LoginDisplayHost* host) |
155 : auth_status_consumer_(NULL), | 156 : public_session_auto_login_user_id_(std::string(), std::string()), |
157 auth_status_consumer_(NULL), | |
158 last_login_attempt_user_id_(std::string(), std::string()), | |
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
EmptyUserID()
here and above?
| |
156 host_(host), | 159 host_(host), |
157 login_display_(host_->CreateLoginDisplay(this)), | 160 login_display_(host_->CreateLoginDisplay(this)), |
158 num_login_attempts_(0), | 161 num_login_attempts_(0), |
159 cros_settings_(CrosSettings::Get()), | 162 cros_settings_(CrosSettings::Get()), |
160 offline_failed_(false), | 163 offline_failed_(false), |
161 is_login_in_progress_(false), | 164 is_login_in_progress_(false), |
165 online_succeeded_for_(std::string(), std::string()), | |
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
EmptyUserID()?
| |
162 password_changed_(false), | 166 password_changed_(false), |
163 auth_mode_(LoginPerformer::AUTH_MODE_EXTENSION), | 167 auth_mode_(LoginPerformer::AUTH_MODE_EXTENSION), |
164 signin_screen_ready_(false), | 168 signin_screen_ready_(false), |
165 network_state_helper_(new login::NetworkStateHelper), | 169 network_state_helper_(new login::NetworkStateHelper), |
166 weak_factory_(this) { | 170 weak_factory_(this) { |
167 DCHECK(current_controller_ == NULL); | 171 DCHECK(current_controller_ == NULL); |
168 current_controller_ = this; | 172 current_controller_ = this; |
169 | 173 |
170 registrar_.Add(this, | 174 registrar_.Add(this, |
171 chrome::NOTIFICATION_USER_LIST_CHANGED, | 175 chrome::NOTIFICATION_USER_LIST_CHANGED, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, | 226 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, |
223 &show_users_on_signin); | 227 &show_users_on_signin); |
224 for (user_manager::UserList::const_iterator it = users.begin(); | 228 for (user_manager::UserList::const_iterator it = users.begin(); |
225 it != users.end(); | 229 it != users.end(); |
226 ++it) { | 230 ++it) { |
227 // TODO(xiyuan): Clean user profile whose email is not in whitelist. | 231 // TODO(xiyuan): Clean user profile whose email is not in whitelist. |
228 bool meets_supervised_requirements = | 232 bool meets_supervised_requirements = |
229 (*it)->GetType() != user_manager::USER_TYPE_SUPERVISED || | 233 (*it)->GetType() != user_manager::USER_TYPE_SUPERVISED || |
230 user_manager::UserManager::Get()->AreSupervisedUsersAllowed(); | 234 user_manager::UserManager::Get()->AreSupervisedUsersAllowed(); |
231 bool meets_whitelist_requirements = | 235 bool meets_whitelist_requirements = |
232 CrosSettings::IsWhitelisted((*it)->email(), NULL) || | 236 CrosSettings::IsWhitelisted((*it)->GetUserID(), NULL) || |
233 !(*it)->HasGaiaAccount(); | 237 !(*it)->HasGaiaAccount(); |
234 | 238 |
235 // Public session accounts are always shown on login screen. | 239 // Public session accounts are always shown on login screen. |
236 bool meets_show_users_requirements = | 240 bool meets_show_users_requirements = |
237 show_users_on_signin || | 241 show_users_on_signin || |
238 (*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; | 242 (*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; |
239 if (meets_supervised_requirements && | 243 if (meets_supervised_requirements && |
240 meets_whitelist_requirements && | 244 meets_whitelist_requirements && |
241 meets_show_users_requirements) { | 245 meets_show_users_requirements) { |
242 filtered_users.push_back(*it); | 246 filtered_users.push_back(*it); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 | 327 |
324 void ExistingUserController::CancelPasswordChangedFlow() { | 328 void ExistingUserController::CancelPasswordChangedFlow() { |
325 login_performer_.reset(NULL); | 329 login_performer_.reset(NULL); |
326 PerformLoginFinishedActions(true /* start public session timer */); | 330 PerformLoginFinishedActions(true /* start public session timer */); |
327 } | 331 } |
328 | 332 |
329 void ExistingUserController::CreateAccount() { | 333 void ExistingUserController::CreateAccount() { |
330 content::RecordAction(base::UserMetricsAction("Login.CreateAccount")); | 334 content::RecordAction(base::UserMetricsAction("Login.CreateAccount")); |
331 guest_mode_url_ = google_util::AppendGoogleLocaleParam( | 335 guest_mode_url_ = google_util::AppendGoogleLocaleParam( |
332 GURL(kCreateAccountURL), g_browser_process->GetApplicationLocale()); | 336 GURL(kCreateAccountURL), g_browser_process->GetApplicationLocale()); |
333 Login(UserContext(user_manager::USER_TYPE_GUEST, std::string()), | 337 Login(UserContext(user_manager::USER_TYPE_GUEST, login::GetGuestUserID()), |
334 SigninSpecifics()); | 338 SigninSpecifics()); |
335 } | 339 } |
336 | 340 |
337 void ExistingUserController::CompleteLogin(const UserContext& user_context) { | 341 void ExistingUserController::CompleteLogin(const UserContext& user_context) { |
338 login_display_->set_signin_completed(true); | 342 login_display_->set_signin_completed(true); |
339 if (!host_) { | 343 if (!host_) { |
340 // Complete login event was generated already from UI. Ignore notification. | 344 // Complete login event was generated already from UI. Ignore notification. |
341 return; | 345 return; |
342 } | 346 } |
343 | 347 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 BootTimesRecorder::Get()->RecordLoginAttempted(); | 380 BootTimesRecorder::Get()->RecordLoginAttempted(); |
377 | 381 |
378 // Use the same LoginPerformer for subsequent login as it has state | 382 // Use the same LoginPerformer for subsequent login as it has state |
379 // such as Authenticator instance. | 383 // such as Authenticator instance. |
380 if (!login_performer_.get() || num_login_attempts_ <= 1) { | 384 if (!login_performer_.get() || num_login_attempts_ <= 1) { |
381 // Only one instance of LoginPerformer should exist at a time. | 385 // Only one instance of LoginPerformer should exist at a time. |
382 login_performer_.reset(NULL); | 386 login_performer_.reset(NULL); |
383 login_performer_.reset(new ChromeLoginPerformer(this)); | 387 login_performer_.reset(new ChromeLoginPerformer(this)); |
384 } | 388 } |
385 | 389 |
386 if (gaia::ExtractDomainName(user_context.GetUserID()) == | 390 if (gaia::ExtractDomainName(user_context.GetUserID().GetUserEmail()) == |
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
Maybe add chromeos::login::IsSupervisedUser(UserID
| |
387 chromeos::login::kSupervisedUserDomain) { | 391 chromeos::login::kSupervisedUserDomain) { |
388 login_performer_->LoginAsSupervisedUser(user_context); | 392 login_performer_->LoginAsSupervisedUser(user_context); |
389 } else { | 393 } else { |
390 login_performer_->PerformLogin(user_context, auth_mode); | 394 login_performer_->PerformLogin(user_context, auth_mode); |
391 RecordPasswordLoginEvent(user_context); | 395 RecordPasswordLoginEvent(user_context); |
392 } | 396 } |
393 SendAccessibilityAlert( | 397 SendAccessibilityAlert( |
394 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); | 398 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); |
395 } | 399 } |
396 | 400 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 // | 514 // |
511 | 515 |
512 void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { | 516 void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { |
513 offline_failed_ = true; | 517 offline_failed_ = true; |
514 guest_mode_url_ = GURL::EmptyGURL(); | 518 guest_mode_url_ = GURL::EmptyGURL(); |
515 std::string error = failure.GetErrorString(); | 519 std::string error = failure.GetErrorString(); |
516 | 520 |
517 PerformLoginFinishedActions(false /* don't start public session timer */); | 521 PerformLoginFinishedActions(false /* don't start public session timer */); |
518 | 522 |
519 if (ChromeUserManager::Get() | 523 if (ChromeUserManager::Get() |
520 ->GetUserFlow(last_login_attempt_username_) | 524 ->GetUserFlow(last_login_attempt_user_id_) |
521 ->HandleLoginFailure(failure)) { | 525 ->HandleLoginFailure(failure)) { |
522 return; | 526 return; |
523 } | 527 } |
524 | 528 |
525 if (failure.reason() == AuthFailure::OWNER_REQUIRED) { | 529 if (failure.reason() == AuthFailure::OWNER_REQUIRED) { |
526 ShowError(IDS_LOGIN_ERROR_OWNER_REQUIRED, error); | 530 ShowError(IDS_LOGIN_ERROR_OWNER_REQUIRED, error); |
527 content::BrowserThread::PostDelayedTask( | 531 content::BrowserThread::PostDelayedTask( |
528 content::BrowserThread::UI, FROM_HERE, | 532 content::BrowserThread::UI, FROM_HERE, |
529 base::Bind(&SessionManagerClient::StopSession, | 533 base::Bind(&SessionManagerClient::StopSession, |
530 base::Unretained(DBusThreadManager::Get()-> | 534 base::Unretained(DBusThreadManager::Get()-> |
531 GetSessionManagerClient())), | 535 GetSessionManagerClient())), |
532 base::TimeDelta::FromMilliseconds(kSafeModeRestartUiDelayMs)); | 536 base::TimeDelta::FromMilliseconds(kSafeModeRestartUiDelayMs)); |
533 } else if (failure.reason() == AuthFailure::TPM_ERROR) { | 537 } else if (failure.reason() == AuthFailure::TPM_ERROR) { |
534 ShowTPMError(); | 538 ShowTPMError(); |
535 } else if (!online_succeeded_for_.empty()) { | 539 } else if (!online_succeeded_for_.empty()) { |
536 ShowGaiaPasswordChanged(online_succeeded_for_); | 540 ShowGaiaPasswordChanged(online_succeeded_for_); |
537 } else if (last_login_attempt_username_ == chromeos::login::kGuestUserName) { | 541 } else if (last_login_attempt_user_id_ == chromeos::login::GetGuestUserID()) { |
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
Maybe introduce chromeos::login::IsGuestUser(UserI
| |
538 // Show no errors, just re-enable input. | 542 // Show no errors, just re-enable input. |
539 login_display_->ClearAndEnablePassword(); | 543 login_display_->ClearAndEnablePassword(); |
540 StartPublicSessionAutoLoginTimer(); | 544 StartPublicSessionAutoLoginTimer(); |
541 } else { | 545 } else { |
542 // Check networking after trying to login in case user is | 546 // Check networking after trying to login in case user is |
543 // cached locally or the local admin account. | 547 // cached locally or the local admin account. |
544 bool is_known_user = user_manager::UserManager::Get()->IsKnownUser( | 548 bool is_known_user = user_manager::UserManager::Get()->IsKnownUser( |
545 last_login_attempt_username_); | 549 last_login_attempt_user_id_); |
546 if (!network_state_helper_->IsConnected()) { | 550 if (!network_state_helper_->IsConnected()) { |
547 if (is_known_user) | 551 if (is_known_user) |
548 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); | 552 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
549 else | 553 else |
550 ShowError(IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, error); | 554 ShowError(IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, error); |
551 } else { | 555 } else { |
552 // TODO(nkostylev): Cleanup rest of ClientLogin related code. | 556 // TODO(nkostylev): Cleanup rest of ClientLogin related code. |
553 if (failure.reason() == AuthFailure::NETWORK_AUTH_FAILED && | 557 if (failure.reason() == AuthFailure::NETWORK_AUTH_FAILED && |
554 failure.error().state() == | 558 failure.error().state() == |
555 GoogleServiceAuthError::HOSTED_NOT_ALLOWED) { | 559 GoogleServiceAuthError::HOSTED_NOT_ALLOWED) { |
556 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); | 560 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); |
557 } else { | 561 } else { |
558 if (!is_known_user) | 562 if (!is_known_user) |
559 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); | 563 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); |
560 else | 564 else |
561 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); | 565 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
562 } | 566 } |
563 } | 567 } |
564 login_display_->ClearAndEnablePassword(); | 568 login_display_->ClearAndEnablePassword(); |
565 StartPublicSessionAutoLoginTimer(); | 569 StartPublicSessionAutoLoginTimer(); |
566 } | 570 } |
567 | 571 |
568 // Reset user flow to default, so that special flow will not affect next | 572 // Reset user flow to default, so that special flow will not affect next |
569 // attempt. | 573 // attempt. |
570 ChromeUserManager::Get()->ResetUserFlow(last_login_attempt_username_); | 574 ChromeUserManager::Get()->ResetUserFlow(last_login_attempt_user_id_); |
571 | 575 |
572 if (auth_status_consumer_) | 576 if (auth_status_consumer_) |
573 auth_status_consumer_->OnAuthFailure(failure); | 577 auth_status_consumer_->OnAuthFailure(failure); |
574 | 578 |
575 // Clear the recorded displayed email so it won't affect any future attempts. | 579 // Clear the recorded displayed email so it won't affect any future attempts. |
576 display_email_.clear(); | 580 display_email_.clear(); |
577 | 581 |
578 // TODO(ginkage): Fix this case once crbug.com/469990 is ready. | 582 // TODO(ginkage): Fix this case once crbug.com/469990 is ready. |
579 /* | 583 /* |
580 if (failure.reason() == AuthFailure::COULD_NOT_MOUNT_CRYPTOHOME) { | 584 if (failure.reason() == AuthFailure::COULD_NOT_MOUNT_CRYPTOHOME) { |
581 RecordReauthReason(last_login_attempt_username_, | 585 RecordReauthReason(last_login_attempt_user_id_, |
582 ReauthReason::MISSING_CRYPTOHOME); | 586 ReauthReason::MISSING_CRYPTOHOME); |
583 } | 587 } |
584 */ | 588 */ |
585 } | 589 } |
586 | 590 |
587 void ExistingUserController::OnAuthSuccess(const UserContext& user_context) { | 591 void ExistingUserController::OnAuthSuccess(const UserContext& user_context) { |
588 is_login_in_progress_ = false; | 592 is_login_in_progress_ = false; |
589 offline_failed_ = false; | 593 offline_failed_ = false; |
590 login_display_->set_signin_completed(true); | 594 login_display_->set_signin_completed(true); |
591 | 595 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 // Reenable clicking on other windows and status area. | 641 // Reenable clicking on other windows and status area. |
638 login_display_->SetUIEnabled(true); | 642 login_display_->SetUIEnabled(true); |
639 | 643 |
640 if (browser_launched) | 644 if (browser_launched) |
641 host_ = NULL; | 645 host_ = NULL; |
642 | 646 |
643 // Inform |auth_status_consumer_| about successful login. | 647 // Inform |auth_status_consumer_| about successful login. |
644 // TODO(nkostylev): Pass UserContext back crbug.com/424550 | 648 // TODO(nkostylev): Pass UserContext back crbug.com/424550 |
645 if (auth_status_consumer_) { | 649 if (auth_status_consumer_) { |
646 auth_status_consumer_-> | 650 auth_status_consumer_-> |
647 OnAuthSuccess(UserContext(last_login_attempt_username_)); | 651 OnAuthSuccess(UserContext(last_login_attempt_user_id_)); |
648 } | 652 } |
649 } | 653 } |
650 | 654 |
651 void ExistingUserController::OnOffTheRecordAuthSuccess() { | 655 void ExistingUserController::OnOffTheRecordAuthSuccess() { |
652 is_login_in_progress_ = false; | 656 is_login_in_progress_ = false; |
653 offline_failed_ = false; | 657 offline_failed_ = false; |
654 | 658 |
655 // Mark the device as registered., i.e. the second part of OOBE as completed. | 659 // Mark the device as registered., i.e. the second part of OOBE as completed. |
656 if (!StartupUtils::IsDeviceRegistered()) | 660 if (!StartupUtils::IsDeviceRegistered()) |
657 StartupUtils::MarkDeviceRegistered(base::Closure()); | 661 StartupUtils::MarkDeviceRegistered(base::Closure()); |
(...skipping 11 matching lines...) Expand all Loading... | |
669 // Must not proceed without signature verification. | 673 // Must not proceed without signature verification. |
670 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( | 674 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( |
671 base::Bind(&ExistingUserController::OnPasswordChangeDetected, | 675 base::Bind(&ExistingUserController::OnPasswordChangeDetected, |
672 weak_factory_.GetWeakPtr()))) { | 676 weak_factory_.GetWeakPtr()))) { |
673 // Value of owner email is still not verified. | 677 // Value of owner email is still not verified. |
674 // Another attempt will be invoked after verification completion. | 678 // Another attempt will be invoked after verification completion. |
675 return; | 679 return; |
676 } | 680 } |
677 | 681 |
678 if (ChromeUserManager::Get() | 682 if (ChromeUserManager::Get() |
679 ->GetUserFlow(last_login_attempt_username_) | 683 ->GetUserFlow(last_login_attempt_user_id_) |
680 ->HandlePasswordChangeDetected()) { | 684 ->HandlePasswordChangeDetected()) { |
681 return; | 685 return; |
682 } | 686 } |
683 | 687 |
684 // True if user has already made an attempt to enter old password and failed. | 688 // True if user has already made an attempt to enter old password and failed. |
685 bool show_invalid_old_password_error = | 689 bool show_invalid_old_password_error = |
686 login_performer_->password_changed_callback_count() > 1; | 690 login_performer_->password_changed_callback_count() > 1; |
687 | 691 |
688 // Note: We allow owner using "full sync" mode which will recreate | 692 // Note: We allow owner using "full sync" mode which will recreate |
689 // cryptohome and deal with owner private key being lost. This also allows | 693 // cryptohome and deal with owner private key being lost. This also allows |
690 // us to recover from a lost owner password/homedir. | 694 // us to recover from a lost owner password/homedir. |
691 // TODO(gspencer): We shouldn't have to erase stateful data when | 695 // TODO(gspencer): We shouldn't have to erase stateful data when |
692 // doing this. See http://crosbug.com/9115 http://crosbug.com/7792 | 696 // doing this. See http://crosbug.com/9115 http://crosbug.com/7792 |
693 login_display_->ShowPasswordChangedDialog(show_invalid_old_password_error, | 697 login_display_->ShowPasswordChangedDialog(show_invalid_old_password_error, |
694 display_email_); | 698 user_manager::UserID::FromUserEmail( display_email_)); |
695 | 699 |
696 if (auth_status_consumer_) | 700 if (auth_status_consumer_) |
697 auth_status_consumer_->OnPasswordChangeDetected(); | 701 auth_status_consumer_->OnPasswordChangeDetected(); |
698 | 702 |
699 display_email_.clear(); | 703 display_email_.clear(); |
700 } | 704 } |
701 | 705 |
702 void ExistingUserController::WhiteListCheckFailed(const std::string& email) { | 706 void ExistingUserController::WhiteListCheckFailed(const user_manager::UserID& us er_id) { |
703 PerformLoginFinishedActions(true /* start public session timer */); | 707 PerformLoginFinishedActions(true /* start public session timer */); |
704 offline_failed_ = false; | 708 offline_failed_ = false; |
705 | 709 |
706 if (StartupUtils::IsWebviewSigninEnabled()) { | 710 if (StartupUtils::IsWebviewSigninEnabled()) { |
707 login_display_->ShowWhitelistCheckFailedError(); | 711 login_display_->ShowWhitelistCheckFailedError(); |
708 } else { | 712 } else { |
709 if (g_browser_process->platform_part() | 713 if (g_browser_process->platform_part() |
710 ->browser_policy_connector_chromeos() | 714 ->browser_policy_connector_chromeos() |
711 ->IsEnterpriseManaged()) { | 715 ->IsEnterpriseManaged()) { |
712 ShowError(IDS_ENTERPRISE_LOGIN_ERROR_WHITELIST, email); | 716 ShowError(IDS_ENTERPRISE_LOGIN_ERROR_WHITELIST, user_id.GetUserEmail()); |
713 } else { | 717 } else { |
714 ShowError(IDS_LOGIN_ERROR_WHITELIST, email); | 718 ShowError(IDS_LOGIN_ERROR_WHITELIST, user_id.GetUserEmail()); |
715 } | 719 } |
716 login_display_->ShowSigninUI(email); | 720 login_display_->ShowSigninUI(user_id); |
717 } | 721 } |
718 | 722 |
719 if (auth_status_consumer_) { | 723 if (auth_status_consumer_) { |
720 auth_status_consumer_->OnAuthFailure( | 724 auth_status_consumer_->OnAuthFailure( |
721 AuthFailure(AuthFailure::WHITELIST_CHECK_FAILED)); | 725 AuthFailure(AuthFailure::WHITELIST_CHECK_FAILED)); |
722 } | 726 } |
723 | 727 |
724 display_email_.clear(); | 728 display_email_.clear(); |
725 } | 729 } |
726 | 730 |
727 void ExistingUserController::PolicyLoadFailed() { | 731 void ExistingUserController::PolicyLoadFailed() { |
728 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); | 732 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); |
729 | 733 |
730 PerformLoginFinishedActions(false /* don't start public session timer */); | 734 PerformLoginFinishedActions(false /* don't start public session timer */); |
731 offline_failed_ = false; | 735 offline_failed_ = false; |
732 display_email_.clear(); | 736 display_email_.clear(); |
733 } | 737 } |
734 | 738 |
735 void ExistingUserController::OnOnlineChecked(const std::string& username, | 739 void ExistingUserController::OnOnlineChecked(const user_manager::UserID& user_id , |
736 bool success) { | 740 bool success) { |
737 if (success && last_login_attempt_username_ == username) { | 741 if (success && last_login_attempt_user_id_ == user_id) { |
738 online_succeeded_for_ = username; | 742 online_succeeded_for_ = user_id; |
739 // Wait for login attempt to end, if it hasn't yet. | 743 // Wait for login attempt to end, if it hasn't yet. |
740 if (offline_failed_ && !is_login_in_progress_) | 744 if (offline_failed_ && !is_login_in_progress_) |
741 ShowGaiaPasswordChanged(username); | 745 ShowGaiaPasswordChanged(user_id); |
742 } | 746 } |
743 } | 747 } |
744 | 748 |
745 //////////////////////////////////////////////////////////////////////////////// | 749 //////////////////////////////////////////////////////////////////////////////// |
746 // ExistingUserController, private: | 750 // ExistingUserController, private: |
747 | 751 |
748 void ExistingUserController::DeviceSettingsChanged() { | 752 void ExistingUserController::DeviceSettingsChanged() { |
749 // If login was already completed, we should avoid any signin screen | 753 // If login was already completed, we should avoid any signin screen |
750 // transitions, see http://crbug.com/461604 for example. | 754 // transitions, see http://crbug.com/461604 for example. |
751 if (host_ != NULL && !login_display_->is_signin_completed()) { | 755 if (host_ != NULL && !login_display_->is_signin_completed()) { |
(...skipping 12 matching lines...) Expand all Loading... | |
764 | 768 |
765 bool ExistingUserController::password_changed() const { | 769 bool ExistingUserController::password_changed() const { |
766 if (login_performer_) | 770 if (login_performer_) |
767 return login_performer_->password_changed(); | 771 return login_performer_->password_changed(); |
768 | 772 |
769 return password_changed_; | 773 return password_changed_; |
770 } | 774 } |
771 | 775 |
772 void ExistingUserController::LoginAsGuest() { | 776 void ExistingUserController::LoginAsGuest() { |
773 PerformPreLoginActions(UserContext(user_manager::USER_TYPE_GUEST, | 777 PerformPreLoginActions(UserContext(user_manager::USER_TYPE_GUEST, |
774 chromeos::login::kGuestUserName)); | 778 chromeos::login::GetGuestUserID())); |
775 | 779 |
776 bool allow_guest; | 780 bool allow_guest; |
777 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 781 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
778 if (!allow_guest) { | 782 if (!allow_guest) { |
779 // Disallowed. The UI should normally not show the guest pod but if for some | 783 // Disallowed. The UI should normally not show the guest pod but if for some |
780 // reason this has been made available to the user here is the time to tell | 784 // reason this has been made available to the user here is the time to tell |
781 // this nicely. | 785 // this nicely. |
782 if (g_browser_process->platform_part() | 786 if (g_browser_process->platform_part() |
783 ->browser_policy_connector_chromeos() | 787 ->browser_policy_connector_chromeos() |
784 ->IsEnterpriseManaged()) { | 788 ->IsEnterpriseManaged()) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
860 new_user_context), | 864 new_user_context), |
861 locale); | 865 locale); |
862 return; | 866 return; |
863 } | 867 } |
864 | 868 |
865 // The user chose a locale and a suitable keyboard layout or left both unset. | 869 // The user chose a locale and a suitable keyboard layout or left both unset. |
866 // Login can continue immediately. | 870 // Login can continue immediately. |
867 LoginAsPublicSessionInternal(new_user_context); | 871 LoginAsPublicSessionInternal(new_user_context); |
868 } | 872 } |
869 | 873 |
870 void ExistingUserController::LoginAsKioskApp(const std::string& app_id, | 874 void ExistingUserController::LoginAsKioskApp(const user_manager::UserID& user_id , |
871 bool diagnostic_mode) { | 875 bool diagnostic_mode) { |
872 const bool auto_start = false; | 876 const bool auto_start = false; |
873 host_->StartAppLaunch(app_id, diagnostic_mode, auto_start); | 877 host_->StartAppLaunch(user_id.GetUserEmail(), diagnostic_mode, auto_start); |
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
Please add ToDo that app id can be at some point b
| |
874 } | 878 } |
875 | 879 |
876 void ExistingUserController::ConfigurePublicSessionAutoLogin() { | 880 void ExistingUserController::ConfigurePublicSessionAutoLogin() { |
877 std::string auto_login_account_id; | 881 std::string auto_login_account_id; |
878 cros_settings_->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId, | 882 cros_settings_->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId, |
879 &auto_login_account_id); | 883 &auto_login_account_id); |
880 const std::vector<policy::DeviceLocalAccount> device_local_accounts = | 884 const std::vector<policy::DeviceLocalAccount> device_local_accounts = |
881 policy::GetDeviceLocalAccounts(cros_settings_); | 885 policy::GetDeviceLocalAccounts(cros_settings_); |
882 | 886 |
883 public_session_auto_login_username_.clear(); | 887 public_session_auto_login_user_id_.clear(); |
884 for (std::vector<policy::DeviceLocalAccount>::const_iterator | 888 for (std::vector<policy::DeviceLocalAccount>::const_iterator |
885 it = device_local_accounts.begin(); | 889 it = device_local_accounts.begin(); |
886 it != device_local_accounts.end(); ++it) { | 890 it != device_local_accounts.end(); ++it) { |
887 if (it->account_id == auto_login_account_id) { | 891 if (it->account_id == auto_login_account_id) { |
888 public_session_auto_login_username_ = it->user_id; | 892 public_session_auto_login_user_id_ = it->user_id; |
889 break; | 893 break; |
890 } | 894 } |
891 } | 895 } |
892 | 896 |
893 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( | 897 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
894 public_session_auto_login_username_); | 898 public_session_auto_login_user_id_); |
895 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) | 899 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) |
896 public_session_auto_login_username_.clear(); | 900 public_session_auto_login_user_id_.clear(); |
897 | 901 |
898 if (!cros_settings_->GetInteger( | 902 if (!cros_settings_->GetInteger( |
899 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 903 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
900 &public_session_auto_login_delay_)) { | 904 &public_session_auto_login_delay_)) { |
901 public_session_auto_login_delay_ = 0; | 905 public_session_auto_login_delay_ = 0; |
902 } | 906 } |
903 | 907 |
904 if (!public_session_auto_login_username_.empty()) | 908 if (!public_session_auto_login_user_id_.empty()) |
905 StartPublicSessionAutoLoginTimer(); | 909 StartPublicSessionAutoLoginTimer(); |
906 else | 910 else |
907 StopPublicSessionAutoLoginTimer(); | 911 StopPublicSessionAutoLoginTimer(); |
908 } | 912 } |
909 | 913 |
910 void ExistingUserController::ResetPublicSessionAutoLoginTimer() { | 914 void ExistingUserController::ResetPublicSessionAutoLoginTimer() { |
911 // Only restart the auto-login timer if it's already running. | 915 // Only restart the auto-login timer if it's already running. |
912 if (auto_login_timer_ && auto_login_timer_->IsRunning()) { | 916 if (auto_login_timer_ && auto_login_timer_->IsRunning()) { |
913 StopPublicSessionAutoLoginTimer(); | 917 StopPublicSessionAutoLoginTimer(); |
914 StartPublicSessionAutoLoginTimer(); | 918 StartPublicSessionAutoLoginTimer(); |
915 } | 919 } |
916 } | 920 } |
917 | 921 |
918 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() { | 922 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() { |
919 CHECK(signin_screen_ready_ && !public_session_auto_login_username_.empty()); | 923 CHECK(signin_screen_ready_ && !public_session_auto_login_user_id_.empty()); |
920 Login(UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 924 Login(UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
921 public_session_auto_login_username_), | 925 public_session_auto_login_user_id_), |
922 SigninSpecifics()); | 926 SigninSpecifics()); |
923 } | 927 } |
924 | 928 |
925 void ExistingUserController::StopPublicSessionAutoLoginTimer() { | 929 void ExistingUserController::StopPublicSessionAutoLoginTimer() { |
926 if (auto_login_timer_) | 930 if (auto_login_timer_) |
927 auto_login_timer_->Stop(); | 931 auto_login_timer_->Stop(); |
928 } | 932 } |
929 | 933 |
930 void ExistingUserController::StartPublicSessionAutoLoginTimer() { | 934 void ExistingUserController::StartPublicSessionAutoLoginTimer() { |
931 if (!signin_screen_ready_ || | 935 if (!signin_screen_ready_ || |
932 is_login_in_progress_ || | 936 is_login_in_progress_ || |
933 public_session_auto_login_username_.empty()) { | 937 public_session_auto_login_user_id_.empty()) { |
934 return; | 938 return; |
935 } | 939 } |
936 | 940 |
937 // Start the auto-login timer. | 941 // Start the auto-login timer. |
938 if (!auto_login_timer_) | 942 if (!auto_login_timer_) |
939 auto_login_timer_.reset(new base::OneShotTimer<ExistingUserController>); | 943 auto_login_timer_.reset(new base::OneShotTimer<ExistingUserController>); |
940 | 944 |
941 auto_login_timer_->Start( | 945 auto_login_timer_->Start( |
942 FROM_HERE, | 946 FROM_HERE, |
943 base::TimeDelta::FromMilliseconds( | 947 base::TimeDelta::FromMilliseconds( |
(...skipping 26 matching lines...) Expand all Loading... | |
970 } else { | 974 } else { |
971 // login_performer_ will be null if an error occurred during OAuth2 token | 975 // login_performer_ will be null if an error occurred during OAuth2 token |
972 // fetch. In this case, show a generic error. | 976 // fetch. In this case, show a generic error. |
973 help_topic_id = HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT; | 977 help_topic_id = HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT; |
974 } | 978 } |
975 | 979 |
976 if (error_id == IDS_LOGIN_ERROR_AUTHENTICATING) { | 980 if (error_id == IDS_LOGIN_ERROR_AUTHENTICATING) { |
977 if (num_login_attempts_ > 1) { | 981 if (num_login_attempts_ > 1) { |
978 const user_manager::User* user = | 982 const user_manager::User* user = |
979 user_manager::UserManager::Get()->FindUser( | 983 user_manager::UserManager::Get()->FindUser( |
980 last_login_attempt_username_); | 984 last_login_attempt_user_id_); |
981 if (user && (user->GetType() == user_manager::USER_TYPE_SUPERVISED)) | 985 if (user && (user->GetType() == user_manager::USER_TYPE_SUPERVISED)) |
982 error_id = IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME_SUPERVISED; | 986 error_id = IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME_SUPERVISED; |
983 } | 987 } |
984 } | 988 } |
985 | 989 |
986 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id); | 990 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id); |
987 } | 991 } |
988 | 992 |
989 void ExistingUserController::ShowGaiaPasswordChanged( | 993 void ExistingUserController::ShowGaiaPasswordChanged( |
990 const std::string& username) { | 994 const user_manager::UserID& user_id) { |
991 // Invalidate OAuth token, since it can't be correct after password is | 995 // Invalidate OAuth token, since it can't be correct after password is |
992 // changed. | 996 // changed. |
993 user_manager::UserManager::Get()->SaveUserOAuthStatus( | 997 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
994 username, user_manager::User::OAUTH2_TOKEN_STATUS_INVALID); | 998 user_id, user_manager::User::OAUTH2_TOKEN_STATUS_INVALID); |
995 RecordReauthReason(username, ReauthReason::OTHER); | 999 RecordReauthReason(user_id, ReauthReason::OTHER); |
996 | 1000 |
997 login_display_->SetUIEnabled(true); | 1001 login_display_->SetUIEnabled(true); |
998 login_display_->ShowGaiaPasswordChanged(username); | 1002 login_display_->ShowGaiaPasswordChanged(user_id); |
999 } | 1003 } |
1000 | 1004 |
1001 void ExistingUserController::SendAccessibilityAlert( | 1005 void ExistingUserController::SendAccessibilityAlert( |
1002 const std::string& alert_text) { | 1006 const std::string& alert_text) { |
1003 AutomationManagerAura::GetInstance()->HandleAlert( | 1007 AutomationManagerAura::GetInstance()->HandleAlert( |
1004 ProfileHelper::GetSigninProfile(), alert_text); | 1008 ProfileHelper::GetSigninProfile(), alert_text); |
1005 } | 1009 } |
1006 | 1010 |
1007 void ExistingUserController::SetPublicSessionKeyboardLayoutAndLogin( | 1011 void ExistingUserController::SetPublicSessionKeyboardLayoutAndLogin( |
1008 const UserContext& user_context, | 1012 const UserContext& user_context, |
(...skipping 24 matching lines...) Expand all Loading... | |
1033 login_performer_->LoginAsPublicSession(user_context); | 1037 login_performer_->LoginAsPublicSession(user_context); |
1034 SendAccessibilityAlert( | 1038 SendAccessibilityAlert( |
1035 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); | 1039 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); |
1036 } | 1040 } |
1037 | 1041 |
1038 void ExistingUserController::PerformPreLoginActions( | 1042 void ExistingUserController::PerformPreLoginActions( |
1039 const UserContext& user_context) { | 1043 const UserContext& user_context) { |
1040 // Disable clicking on other windows and status tray. | 1044 // Disable clicking on other windows and status tray. |
1041 login_display_->SetUIEnabled(false); | 1045 login_display_->SetUIEnabled(false); |
1042 | 1046 |
1043 if (last_login_attempt_username_ != user_context.GetUserID()) { | 1047 if (last_login_attempt_user_id_ != user_context.GetUserID()) { |
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
Same question about (un)equality as above.
| |
1044 last_login_attempt_username_ = user_context.GetUserID(); | 1048 last_login_attempt_user_id_ = user_context.GetUserID(); |
1045 num_login_attempts_ = 0; | 1049 num_login_attempts_ = 0; |
1046 | 1050 |
1047 // Also reset state variables, which are used to determine password change. | 1051 // Also reset state variables, which are used to determine password change. |
1048 offline_failed_ = false; | 1052 offline_failed_ = false; |
1049 online_succeeded_for_.clear(); | 1053 online_succeeded_for_.clear(); |
1050 } | 1054 } |
1051 | 1055 |
1052 // Guard in cases when we're called twice but login process is still active. | 1056 // Guard in cases when we're called twice but login process is still active. |
1053 // This might happen when login process is paused till signed settings status | 1057 // This might happen when login process is paused till signed settings status |
1054 // is verified which results in Login* method called again as a callback. | 1058 // is verified which results in Login* method called again as a callback. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1122 | 1126 |
1123 void ExistingUserController::DoCompleteLogin( | 1127 void ExistingUserController::DoCompleteLogin( |
1124 const UserContext& user_context_wo_device_id) { | 1128 const UserContext& user_context_wo_device_id) { |
1125 UserContext user_context = user_context_wo_device_id; | 1129 UserContext user_context = user_context_wo_device_id; |
1126 std::string device_id = | 1130 std::string device_id = |
1127 user_manager::UserManager::Get()->GetKnownUserDeviceId( | 1131 user_manager::UserManager::Get()->GetKnownUserDeviceId( |
1128 user_context.GetUserID()); | 1132 user_context.GetUserID()); |
1129 if (device_id.empty()) { | 1133 if (device_id.empty()) { |
1130 bool is_ephemeral = | 1134 bool is_ephemeral = |
1131 ChromeUserManager::Get()->AreEphemeralUsersEnabled() && | 1135 ChromeUserManager::Get()->AreEphemeralUsersEnabled() && |
1132 user_context.GetUserID() != ChromeUserManager::Get()->GetOwnerEmail(); | 1136 user_context.GetUserID() != ChromeUserManager::Get()->GetOwnerID(); |
1133 device_id = ChromeSigninClient::GenerateSigninScopedDeviceID(is_ephemeral); | 1137 device_id = ChromeSigninClient::GenerateSigninScopedDeviceID(is_ephemeral); |
1134 } | 1138 } |
1135 user_context.SetDeviceId(device_id); | 1139 user_context.SetDeviceId(device_id); |
1136 | 1140 |
1137 PerformPreLoginActions(user_context); | 1141 PerformPreLoginActions(user_context); |
1138 | 1142 |
1139 if (!time_init_.is_null()) { | 1143 if (!time_init_.is_null()) { |
1140 base::TimeDelta delta = base::Time::Now() - time_init_; | 1144 base::TimeDelta delta = base::Time::Now() - time_init_; |
1141 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); | 1145 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); |
1142 time_init_ = base::Time(); // Reset to null. | 1146 time_init_ = base::Time(); // Reset to null. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1248 if (!success) { | 1252 if (!success) { |
1249 LOG(ERROR) << "OAuth2 token fetch failed."; | 1253 LOG(ERROR) << "OAuth2 token fetch failed."; |
1250 OnAuthFailure(AuthFailure(AuthFailure::FAILED_TO_INITIALIZE_TOKEN)); | 1254 OnAuthFailure(AuthFailure(AuthFailure::FAILED_TO_INITIALIZE_TOKEN)); |
1251 return; | 1255 return; |
1252 } | 1256 } |
1253 UserSessionManager::GetInstance()->OnOAuth2TokensFetched(user_context); | 1257 UserSessionManager::GetInstance()->OnOAuth2TokensFetched(user_context); |
1254 PerformLogin(user_context, LoginPerformer::AUTH_MODE_EXTENSION); | 1258 PerformLogin(user_context, LoginPerformer::AUTH_MODE_EXTENSION); |
1255 } | 1259 } |
1256 | 1260 |
1257 } // namespace chromeos | 1261 } // namespace chromeos |
OLD | NEW |