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 15 matching lines...) Expand all Loading... |
26 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
27 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 27 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
28 #include "chrome/browser/chromeos/boot_times_loader.h" | 28 #include "chrome/browser/chromeos/boot_times_loader.h" |
29 #include "chrome/browser/chromeos/customization_document.h" | 29 #include "chrome/browser/chromeos/customization_document.h" |
30 #include "chrome/browser/chromeos/first_run/first_run.h" | 30 #include "chrome/browser/chromeos/first_run/first_run.h" |
31 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 31 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
32 #include "chrome/browser/chromeos/login/helper.h" | 32 #include "chrome/browser/chromeos/login/helper.h" |
33 #include "chrome/browser/chromeos/login/login_utils.h" | 33 #include "chrome/browser/chromeos/login/login_utils.h" |
34 #include "chrome/browser/chromeos/login/startup_utils.h" | 34 #include "chrome/browser/chromeos/login/startup_utils.h" |
35 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 35 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
36 #include "chrome/browser/chromeos/login/users/user_manager.h" | 36 #include "chrome/browser/chromeos/login/user_flow.h" |
| 37 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
37 #include "chrome/browser/chromeos/login/wizard_controller.h" | 38 #include "chrome/browser/chromeos/login/wizard_controller.h" |
38 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 39 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
39 #include "chrome/browser/chromeos/policy/device_local_account.h" | 40 #include "chrome/browser/chromeos/policy/device_local_account.h" |
40 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 41 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
41 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 42 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
42 #include "chrome/browser/chromeos/settings/cros_settings.h" | 43 #include "chrome/browser/chromeos/settings/cros_settings.h" |
43 #include "chrome/browser/prefs/session_startup_pref.h" | 44 #include "chrome/browser/prefs/session_startup_pref.h" |
44 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" | 45 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
45 #include "chrome/common/chrome_switches.h" | 46 #include "chrome/common/chrome_switches.h" |
46 #include "chrome/common/chrome_version_info.h" | 47 #include "chrome/common/chrome_version_info.h" |
47 #include "chrome/common/pref_names.h" | 48 #include "chrome/common/pref_names.h" |
48 #include "chrome/common/url_constants.h" | 49 #include "chrome/common/url_constants.h" |
49 #include "chrome/grit/generated_resources.h" | 50 #include "chrome/grit/generated_resources.h" |
50 #include "chromeos/chromeos_switches.h" | 51 #include "chromeos/chromeos_switches.h" |
51 #include "chromeos/dbus/dbus_thread_manager.h" | 52 #include "chromeos/dbus/dbus_thread_manager.h" |
52 #include "chromeos/dbus/power_manager_client.h" | 53 #include "chromeos/dbus/power_manager_client.h" |
53 #include "chromeos/dbus/session_manager_client.h" | 54 #include "chromeos/dbus/session_manager_client.h" |
54 #include "chromeos/login/auth/user_context.h" | 55 #include "chromeos/login/auth/user_context.h" |
55 #include "chromeos/login/user_names.h" | 56 #include "chromeos/login/user_names.h" |
56 #include "chromeos/settings/cros_settings_names.h" | 57 #include "chromeos/settings/cros_settings_names.h" |
57 #include "components/google/core/browser/google_util.h" | 58 #include "components/google/core/browser/google_util.h" |
58 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 59 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
59 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 60 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
60 #include "components/policy/core/common/policy_map.h" | 61 #include "components/policy/core/common/policy_map.h" |
61 #include "components/policy/core/common/policy_service.h" | 62 #include "components/policy/core/common/policy_service.h" |
62 #include "components/policy/core/common/policy_types.h" | 63 #include "components/policy/core/common/policy_types.h" |
| 64 #include "components/user_manager/user_manager.h" |
63 #include "components/user_manager/user_type.h" | 65 #include "components/user_manager/user_type.h" |
64 #include "content/public/browser/browser_thread.h" | 66 #include "content/public/browser/browser_thread.h" |
65 #include "content/public/browser/notification_service.h" | 67 #include "content/public/browser/notification_service.h" |
66 #include "content/public/browser/notification_types.h" | 68 #include "content/public/browser/notification_types.h" |
67 #include "content/public/browser/user_metrics.h" | 69 #include "content/public/browser/user_metrics.h" |
68 #include "google_apis/gaia/gaia_auth_util.h" | 70 #include "google_apis/gaia/gaia_auth_util.h" |
69 #include "google_apis/gaia/google_service_auth_error.h" | 71 #include "google_apis/gaia/google_service_auth_error.h" |
70 #include "net/http/http_auth_cache.h" | 72 #include "net/http/http_auth_cache.h" |
71 #include "net/http/http_network_session.h" | 73 #include "net/http/http_network_session.h" |
72 #include "net/http/http_transaction_factory.h" | 74 #include "net/http/http_transaction_factory.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 user_manager::UserList filtered_users; | 206 user_manager::UserList filtered_users; |
205 | 207 |
206 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, | 208 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, |
207 &show_users_on_signin); | 209 &show_users_on_signin); |
208 for (user_manager::UserList::const_iterator it = users.begin(); | 210 for (user_manager::UserList::const_iterator it = users.begin(); |
209 it != users.end(); | 211 it != users.end(); |
210 ++it) { | 212 ++it) { |
211 // TODO(xiyuan): Clean user profile whose email is not in whitelist. | 213 // TODO(xiyuan): Clean user profile whose email is not in whitelist. |
212 bool meets_supervised_requirements = | 214 bool meets_supervised_requirements = |
213 (*it)->GetType() != user_manager::USER_TYPE_SUPERVISED || | 215 (*it)->GetType() != user_manager::USER_TYPE_SUPERVISED || |
214 UserManager::Get()->AreSupervisedUsersAllowed(); | 216 user_manager::UserManager::Get()->AreSupervisedUsersAllowed(); |
215 bool meets_whitelist_requirements = | 217 bool meets_whitelist_requirements = |
216 LoginUtils::IsWhitelisted((*it)->email(), NULL) || | 218 LoginUtils::IsWhitelisted((*it)->email(), NULL) || |
217 (*it)->GetType() != user_manager::USER_TYPE_REGULAR; | 219 (*it)->GetType() != user_manager::USER_TYPE_REGULAR; |
218 | 220 |
219 // Public session accounts are always shown on login screen. | 221 // Public session accounts are always shown on login screen. |
220 bool meets_show_users_requirements = | 222 bool meets_show_users_requirements = |
221 show_users_on_signin || | 223 show_users_on_signin || |
222 (*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; | 224 (*it)->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; |
223 if (meets_supervised_requirements && | 225 if (meets_supervised_requirements && |
224 meets_whitelist_requirements && | 226 meets_whitelist_requirements && |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 offline_failed_ = false; | 439 offline_failed_ = false; |
438 online_succeeded_for_.clear(); | 440 online_succeeded_for_.clear(); |
439 } | 441 } |
440 num_login_attempts_++; | 442 num_login_attempts_++; |
441 PerformLogin(user_context, LoginPerformer::AUTH_MODE_INTERNAL); | 443 PerformLogin(user_context, LoginPerformer::AUTH_MODE_INTERNAL); |
442 } | 444 } |
443 | 445 |
444 void ExistingUserController::PerformLogin( | 446 void ExistingUserController::PerformLogin( |
445 const UserContext& user_context, | 447 const UserContext& user_context, |
446 LoginPerformer::AuthorizationMode auth_mode) { | 448 LoginPerformer::AuthorizationMode auth_mode) { |
447 UserManager::Get()->GetUserFlow(last_login_attempt_username_)-> | 449 ChromeUserManager::Get()->GetUserFlow(last_login_attempt_username_)->set_host( |
448 set_host(host_); | 450 host_); |
449 | 451 |
450 BootTimesLoader::Get()->RecordLoginAttempted(); | 452 BootTimesLoader::Get()->RecordLoginAttempted(); |
451 | 453 |
452 // Disable UI while loading user profile. | 454 // Disable UI while loading user profile. |
453 login_display_->SetUIEnabled(false); | 455 login_display_->SetUIEnabled(false); |
454 | 456 |
455 // Use the same LoginPerformer for subsequent login as it has state | 457 // Use the same LoginPerformer for subsequent login as it has state |
456 // such as Authenticator instance. | 458 // such as Authenticator instance. |
457 if (!login_performer_.get() || num_login_attempts_ <= 1) { | 459 if (!login_performer_.get() || num_login_attempts_ <= 1) { |
458 // Only one instance of LoginPerformer should exist at a time. | 460 // Only one instance of LoginPerformer should exist at a time. |
(...skipping 24 matching lines...) Expand all Loading... |
483 // Only one instance of LoginPerformer should exist at a time. | 485 // Only one instance of LoginPerformer should exist at a time. |
484 login_performer_.reset(NULL); | 486 login_performer_.reset(NULL); |
485 login_performer_.reset(new LoginPerformer(this)); | 487 login_performer_.reset(new LoginPerformer(this)); |
486 is_login_in_progress_ = true; | 488 is_login_in_progress_ = true; |
487 login_performer_->LoginRetailMode(); | 489 login_performer_->LoginRetailMode(); |
488 SendAccessibilityAlert( | 490 SendAccessibilityAlert( |
489 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); | 491 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); |
490 } | 492 } |
491 | 493 |
492 void ExistingUserController::LoginAsGuest() { | 494 void ExistingUserController::LoginAsGuest() { |
493 if (is_login_in_progress_ || UserManager::Get()->IsUserLoggedIn()) | 495 if (is_login_in_progress_ || |
| 496 user_manager::UserManager::Get()->IsUserLoggedIn()) |
494 return; | 497 return; |
495 | 498 |
496 // Stop the auto-login timer when attempting login. | 499 // Stop the auto-login timer when attempting login. |
497 StopPublicSessionAutoLoginTimer(); | 500 StopPublicSessionAutoLoginTimer(); |
498 | 501 |
499 // Disable clicking on other windows. | 502 // Disable clicking on other windows. |
500 login_display_->SetUIEnabled(false); | 503 login_display_->SetUIEnabled(false); |
501 | 504 |
502 CrosSettingsProvider::TrustedStatus status = | 505 CrosSettingsProvider::TrustedStatus status = |
503 cros_settings_->PrepareTrustedValues( | 506 cros_settings_->PrepareTrustedValues( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 } | 546 } |
544 | 547 |
545 void ExistingUserController::MigrateUserData(const std::string& old_password) { | 548 void ExistingUserController::MigrateUserData(const std::string& old_password) { |
546 // LoginPerformer instance has state of the user so it should exist. | 549 // LoginPerformer instance has state of the user so it should exist. |
547 if (login_performer_.get()) | 550 if (login_performer_.get()) |
548 login_performer_->RecoverEncryptedData(old_password); | 551 login_performer_->RecoverEncryptedData(old_password); |
549 } | 552 } |
550 | 553 |
551 void ExistingUserController::LoginAsPublicSession( | 554 void ExistingUserController::LoginAsPublicSession( |
552 const UserContext& user_context) { | 555 const UserContext& user_context) { |
553 if (is_login_in_progress_ || UserManager::Get()->IsUserLoggedIn()) | 556 if (is_login_in_progress_ || |
| 557 user_manager::UserManager::Get()->IsUserLoggedIn()) |
554 return; | 558 return; |
555 | 559 |
556 // Stop the auto-login timer when attempting login. | 560 // Stop the auto-login timer when attempting login. |
557 StopPublicSessionAutoLoginTimer(); | 561 StopPublicSessionAutoLoginTimer(); |
558 | 562 |
559 // Disable clicking on other windows. | 563 // Disable clicking on other windows. |
560 login_display_->SetUIEnabled(false); | 564 login_display_->SetUIEnabled(false); |
561 | 565 |
562 CrosSettingsProvider::TrustedStatus status = | 566 CrosSettingsProvider::TrustedStatus status = |
563 cros_settings_->PrepareTrustedValues( | 567 cros_settings_->PrepareTrustedValues( |
(...skipping 11 matching lines...) Expand all Loading... |
575 } | 579 } |
576 | 580 |
577 // If device policy is not verified yet, this function will be called again | 581 // If device policy is not verified yet, this function will be called again |
578 // when verification finishes. | 582 // when verification finishes. |
579 if (status != CrosSettingsProvider::TRUSTED) | 583 if (status != CrosSettingsProvider::TRUSTED) |
580 return; | 584 return; |
581 | 585 |
582 // If there is no public account with the given user ID, logging in is not | 586 // If there is no public account with the given user ID, logging in is not |
583 // possible. | 587 // possible. |
584 const user_manager::User* user = | 588 const user_manager::User* user = |
585 UserManager::Get()->FindUser(user_context.GetUserID()); | 589 user_manager::UserManager::Get()->FindUser(user_context.GetUserID()); |
586 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { | 590 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { |
587 // Re-enable clicking on other windows. | 591 // Re-enable clicking on other windows. |
588 login_display_->SetUIEnabled(true); | 592 login_display_->SetUIEnabled(true); |
589 StartPublicSessionAutoLoginTimer(); | 593 StartPublicSessionAutoLoginTimer(); |
590 return; | 594 return; |
591 } | 595 } |
592 | 596 |
593 UserContext new_user_context = user_context; | 597 UserContext new_user_context = user_context; |
594 std::string locale = user_context.GetPublicSessionLocale(); | 598 std::string locale = user_context.GetPublicSessionLocale(); |
595 if (locale.empty()) { | 599 if (locale.empty()) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 // ExistingUserController, LoginPerformer::Delegate implementation: | 764 // ExistingUserController, LoginPerformer::Delegate implementation: |
761 // | 765 // |
762 | 766 |
763 void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { | 767 void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { |
764 is_login_in_progress_ = false; | 768 is_login_in_progress_ = false; |
765 offline_failed_ = true; | 769 offline_failed_ = true; |
766 | 770 |
767 guest_mode_url_ = GURL::EmptyGURL(); | 771 guest_mode_url_ = GURL::EmptyGURL(); |
768 std::string error = failure.GetErrorString(); | 772 std::string error = failure.GetErrorString(); |
769 | 773 |
770 if (UserManager::Get()->GetUserFlow(last_login_attempt_username_)-> | 774 if (ChromeUserManager::Get() |
771 HandleLoginFailure(failure)) { | 775 ->GetUserFlow(last_login_attempt_username_) |
| 776 ->HandleLoginFailure(failure)) { |
772 login_display_->SetUIEnabled(true); | 777 login_display_->SetUIEnabled(true); |
773 return; | 778 return; |
774 } | 779 } |
775 | 780 |
776 if (failure.reason() == AuthFailure::OWNER_REQUIRED) { | 781 if (failure.reason() == AuthFailure::OWNER_REQUIRED) { |
777 ShowError(IDS_LOGIN_ERROR_OWNER_REQUIRED, error); | 782 ShowError(IDS_LOGIN_ERROR_OWNER_REQUIRED, error); |
778 content::BrowserThread::PostDelayedTask( | 783 content::BrowserThread::PostDelayedTask( |
779 content::BrowserThread::UI, FROM_HERE, | 784 content::BrowserThread::UI, FROM_HERE, |
780 base::Bind(&SessionManagerClient::StopSession, | 785 base::Bind(&SessionManagerClient::StopSession, |
781 base::Unretained(DBusThreadManager::Get()-> | 786 base::Unretained(DBusThreadManager::Get()-> |
782 GetSessionManagerClient())), | 787 GetSessionManagerClient())), |
783 base::TimeDelta::FromMilliseconds(kSafeModeRestartUiDelayMs)); | 788 base::TimeDelta::FromMilliseconds(kSafeModeRestartUiDelayMs)); |
784 } else if (failure.reason() == AuthFailure::TPM_ERROR) { | 789 } else if (failure.reason() == AuthFailure::TPM_ERROR) { |
785 ShowTPMError(); | 790 ShowTPMError(); |
786 } else if (!online_succeeded_for_.empty()) { | 791 } else if (!online_succeeded_for_.empty()) { |
787 ShowGaiaPasswordChanged(online_succeeded_for_); | 792 ShowGaiaPasswordChanged(online_succeeded_for_); |
788 } else { | 793 } else { |
789 // Check networking after trying to login in case user is | 794 // Check networking after trying to login in case user is |
790 // cached locally or the local admin account. | 795 // cached locally or the local admin account. |
791 bool is_known_user = | 796 bool is_known_user = user_manager::UserManager::Get()->IsKnownUser( |
792 UserManager::Get()->IsKnownUser(last_login_attempt_username_); | 797 last_login_attempt_username_); |
793 if (!network_state_helper_->IsConnected()) { | 798 if (!network_state_helper_->IsConnected()) { |
794 if (is_known_user) | 799 if (is_known_user) |
795 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); | 800 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
796 else | 801 else |
797 ShowError(IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, error); | 802 ShowError(IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, error); |
798 } else { | 803 } else { |
799 // TODO(nkostylev): Cleanup rest of ClientLogin related code. | 804 // TODO(nkostylev): Cleanup rest of ClientLogin related code. |
800 if (failure.reason() == AuthFailure::NETWORK_AUTH_FAILED && | 805 if (failure.reason() == AuthFailure::NETWORK_AUTH_FAILED && |
801 failure.error().state() == | 806 failure.error().state() == |
802 GoogleServiceAuthError::HOSTED_NOT_ALLOWED) { | 807 GoogleServiceAuthError::HOSTED_NOT_ALLOWED) { |
803 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); | 808 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); |
804 } else { | 809 } else { |
805 if (!is_known_user) | 810 if (!is_known_user) |
806 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); | 811 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); |
807 else | 812 else |
808 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); | 813 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
809 } | 814 } |
810 } | 815 } |
811 // Reenable clicking on other windows and status area. | 816 // Reenable clicking on other windows and status area. |
812 login_display_->SetUIEnabled(true); | 817 login_display_->SetUIEnabled(true); |
813 login_display_->ClearAndEnablePassword(); | 818 login_display_->ClearAndEnablePassword(); |
814 StartPublicSessionAutoLoginTimer(); | 819 StartPublicSessionAutoLoginTimer(); |
815 } | 820 } |
816 | 821 |
817 // Reset user flow to default, so that special flow will not affect next | 822 // Reset user flow to default, so that special flow will not affect next |
818 // attempt. | 823 // attempt. |
819 UserManager::Get()->ResetUserFlow(last_login_attempt_username_); | 824 ChromeUserManager::Get()->ResetUserFlow(last_login_attempt_username_); |
820 | 825 |
821 if (auth_status_consumer_) | 826 if (auth_status_consumer_) |
822 auth_status_consumer_->OnAuthFailure(failure); | 827 auth_status_consumer_->OnAuthFailure(failure); |
823 | 828 |
824 // Clear the recorded displayed email so it won't affect any future attempts. | 829 // Clear the recorded displayed email so it won't affect any future attempts. |
825 display_email_.clear(); | 830 display_email_.clear(); |
826 } | 831 } |
827 | 832 |
828 void ExistingUserController::OnAuthSuccess(const UserContext& user_context) { | 833 void ExistingUserController::OnAuthSuccess(const UserContext& user_context) { |
829 is_login_in_progress_ = false; | 834 is_login_in_progress_ = false; |
830 offline_failed_ = false; | 835 offline_failed_ = false; |
831 login_display_->set_signin_completed(true); | 836 login_display_->set_signin_completed(true); |
832 | 837 |
833 // Login performer will be gone so cache this value to use | 838 // Login performer will be gone so cache this value to use |
834 // once profile is loaded. | 839 // once profile is loaded. |
835 password_changed_ = login_performer_->password_changed(); | 840 password_changed_ = login_performer_->password_changed(); |
836 auth_mode_ = login_performer_->auth_mode(); | 841 auth_mode_ = login_performer_->auth_mode(); |
837 | 842 |
838 UserManager::Get()->GetUserFlow(user_context.GetUserID())-> | 843 ChromeUserManager::Get() |
839 HandleLoginSuccess(user_context); | 844 ->GetUserFlow(user_context.GetUserID()) |
| 845 ->HandleLoginSuccess(user_context); |
840 | 846 |
841 StopPublicSessionAutoLoginTimer(); | 847 StopPublicSessionAutoLoginTimer(); |
842 | 848 |
843 const bool has_auth_cookies = | 849 const bool has_auth_cookies = |
844 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION && | 850 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION && |
845 user_context.GetAuthCode().empty(); | 851 user_context.GetAuthCode().empty(); |
846 | 852 |
847 // LoginPerformer instance will delete itself once online auth result is OK. | 853 // LoginPerformer instance will delete itself once online auth result is OK. |
848 // In case of failure it'll bring up ScreenLock and ask for | 854 // In case of failure it'll bring up ScreenLock and ask for |
849 // correct password/display error message. | 855 // correct password/display error message. |
850 // Even in case when following online,offline protocol and returning | 856 // Even in case when following online,offline protocol and returning |
851 // requests_pending = false, let LoginPerformer delete itself. | 857 // requests_pending = false, let LoginPerformer delete itself. |
852 login_performer_->set_delegate(NULL); | 858 login_performer_->set_delegate(NULL); |
853 ignore_result(login_performer_.release()); | 859 ignore_result(login_performer_.release()); |
854 | 860 |
855 // Update user's displayed email. | 861 // Update user's displayed email. |
856 if (!display_email_.empty()) { | 862 if (!display_email_.empty()) { |
857 UserManager::Get()->SaveUserDisplayEmail(user_context.GetUserID(), | 863 user_manager::UserManager::Get()->SaveUserDisplayEmail( |
858 display_email_); | 864 user_context.GetUserID(), display_email_); |
859 display_email_.clear(); | 865 display_email_.clear(); |
860 } | 866 } |
861 | 867 |
862 // Will call OnProfilePrepared() in the end. | 868 // Will call OnProfilePrepared() in the end. |
863 LoginUtils::Get()->PrepareProfile(user_context, | 869 LoginUtils::Get()->PrepareProfile(user_context, |
864 has_auth_cookies, | 870 has_auth_cookies, |
865 false, // Start session for user. | 871 false, // Start session for user. |
866 this); | 872 this); |
867 } | 873 } |
868 | 874 |
869 void ExistingUserController::OnProfilePrepared(Profile* profile) { | 875 void ExistingUserController::OnProfilePrepared(Profile* profile) { |
870 // Reenable clicking on other windows and status area. | 876 // Reenable clicking on other windows and status area. |
871 login_display_->SetUIEnabled(true); | 877 login_display_->SetUIEnabled(true); |
872 | 878 |
873 UserManager* user_manager = UserManager::Get(); | 879 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
874 if (user_manager->IsCurrentUserNew() && | 880 if (user_manager->IsCurrentUserNew() && |
875 user_manager->IsLoggedInAsSupervisedUser()) { | 881 user_manager->IsLoggedInAsSupervisedUser()) { |
876 // Supervised users should launch into empty desktop on first run. | 882 // Supervised users should launch into empty desktop on first run. |
877 CommandLine::ForCurrentProcess()->AppendSwitch(::switches::kSilentLaunch); | 883 CommandLine::ForCurrentProcess()->AppendSwitch(::switches::kSilentLaunch); |
878 } | 884 } |
879 | 885 |
880 if (user_manager->IsCurrentUserNew() && | 886 if (user_manager->IsCurrentUserNew() && |
881 !user_manager->GetCurrentUserFlow()->ShouldSkipPostLoginScreens() && | 887 !ChromeUserManager::Get() |
| 888 ->GetCurrentUserFlow() |
| 889 ->ShouldSkipPostLoginScreens() && |
882 !WizardController::default_controller()->skip_post_login_screens()) { | 890 !WizardController::default_controller()->skip_post_login_screens()) { |
883 // Don't specify start URLs if the administrator has configured the start | 891 // Don't specify start URLs if the administrator has configured the start |
884 // URLs via policy. | 892 // URLs via policy. |
885 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) | 893 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) |
886 InitializeStartUrls(); | 894 InitializeStartUrls(); |
887 | 895 |
888 // Mark the device as registered., i.e. the second part of OOBE as | 896 // Mark the device as registered., i.e. the second part of OOBE as |
889 // completed. | 897 // completed. |
890 if (!StartupUtils::IsDeviceRegistered()) | 898 if (!StartupUtils::IsDeviceRegistered()) |
891 StartupUtils::MarkDeviceRegistered(base::Closure()); | 899 StartupUtils::MarkDeviceRegistered(base::Closure()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 | 934 |
927 // Must not proceed without signature verification. | 935 // Must not proceed without signature verification. |
928 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( | 936 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( |
929 base::Bind(&ExistingUserController::OnPasswordChangeDetected, | 937 base::Bind(&ExistingUserController::OnPasswordChangeDetected, |
930 weak_factory_.GetWeakPtr()))) { | 938 weak_factory_.GetWeakPtr()))) { |
931 // Value of owner email is still not verified. | 939 // Value of owner email is still not verified. |
932 // Another attempt will be invoked after verification completion. | 940 // Another attempt will be invoked after verification completion. |
933 return; | 941 return; |
934 } | 942 } |
935 | 943 |
936 if (UserManager::Get()->GetUserFlow(last_login_attempt_username_)-> | 944 if (ChromeUserManager::Get() |
937 HandlePasswordChangeDetected()) { | 945 ->GetUserFlow(last_login_attempt_username_) |
| 946 ->HandlePasswordChangeDetected()) { |
938 return; | 947 return; |
939 } | 948 } |
940 | 949 |
941 // True if user has already made an attempt to enter old password and failed. | 950 // True if user has already made an attempt to enter old password and failed. |
942 bool show_invalid_old_password_error = | 951 bool show_invalid_old_password_error = |
943 login_performer_->password_changed_callback_count() > 1; | 952 login_performer_->password_changed_callback_count() > 1; |
944 | 953 |
945 // Note: We allow owner using "full sync" mode which will recreate | 954 // Note: We allow owner using "full sync" mode which will recreate |
946 // cryptohome and deal with owner private key being lost. This also allows | 955 // cryptohome and deal with owner private key being lost. This also allows |
947 // us to recover from a lost owner password/homedir. | 956 // us to recover from a lost owner password/homedir. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 ShowGaiaPasswordChanged(username); | 1007 ShowGaiaPasswordChanged(username); |
999 } | 1008 } |
1000 } | 1009 } |
1001 | 1010 |
1002 //////////////////////////////////////////////////////////////////////////////// | 1011 //////////////////////////////////////////////////////////////////////////////// |
1003 // ExistingUserController, private: | 1012 // ExistingUserController, private: |
1004 | 1013 |
1005 void ExistingUserController::DeviceSettingsChanged() { | 1014 void ExistingUserController::DeviceSettingsChanged() { |
1006 if (host_ != NULL) { | 1015 if (host_ != NULL) { |
1007 // Signed settings or user list changed. Notify views and update them. | 1016 // Signed settings or user list changed. Notify views and update them. |
1008 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); | 1017 UpdateLoginDisplay(user_manager::UserManager::Get()->GetUsers()); |
1009 ConfigurePublicSessionAutoLogin(); | 1018 ConfigurePublicSessionAutoLogin(); |
1010 return; | 1019 return; |
1011 } | 1020 } |
1012 } | 1021 } |
1013 | 1022 |
1014 void ExistingUserController::ActivateWizard(const std::string& screen_name) { | 1023 void ExistingUserController::ActivateWizard(const std::string& screen_name) { |
1015 scoped_ptr<base::DictionaryValue> params; | 1024 scoped_ptr<base::DictionaryValue> params; |
1016 host_->StartWizard(screen_name, params.Pass()); | 1025 host_->StartWizard(screen_name, params.Pass()); |
1017 } | 1026 } |
1018 | 1027 |
(...skipping 21 matching lines...) Expand all Loading... |
1040 public_session_auto_login_username_.clear(); | 1049 public_session_auto_login_username_.clear(); |
1041 for (std::vector<policy::DeviceLocalAccount>::const_iterator | 1050 for (std::vector<policy::DeviceLocalAccount>::const_iterator |
1042 it = device_local_accounts.begin(); | 1051 it = device_local_accounts.begin(); |
1043 it != device_local_accounts.end(); ++it) { | 1052 it != device_local_accounts.end(); ++it) { |
1044 if (it->account_id == auto_login_account_id) { | 1053 if (it->account_id == auto_login_account_id) { |
1045 public_session_auto_login_username_ = it->user_id; | 1054 public_session_auto_login_username_ = it->user_id; |
1046 break; | 1055 break; |
1047 } | 1056 } |
1048 } | 1057 } |
1049 | 1058 |
1050 const user_manager::User* user = | 1059 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
1051 UserManager::Get()->FindUser(public_session_auto_login_username_); | 1060 public_session_auto_login_username_); |
1052 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) | 1061 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) |
1053 public_session_auto_login_username_.clear(); | 1062 public_session_auto_login_username_.clear(); |
1054 | 1063 |
1055 if (!cros_settings_->GetInteger( | 1064 if (!cros_settings_->GetInteger( |
1056 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 1065 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
1057 &public_session_auto_login_delay_)) { | 1066 &public_session_auto_login_delay_)) { |
1058 public_session_auto_login_delay_ = 0; | 1067 public_session_auto_login_delay_ = 0; |
1059 } | 1068 } |
1060 | 1069 |
1061 if (!public_session_auto_login_username_.empty()) | 1070 if (!public_session_auto_login_username_.empty()) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 } | 1116 } |
1108 | 1117 |
1109 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { | 1118 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { |
1110 return host_->GetNativeWindow(); | 1119 return host_->GetNativeWindow(); |
1111 } | 1120 } |
1112 | 1121 |
1113 void ExistingUserController::InitializeStartUrls() const { | 1122 void ExistingUserController::InitializeStartUrls() const { |
1114 std::vector<std::string> start_urls; | 1123 std::vector<std::string> start_urls; |
1115 | 1124 |
1116 const base::ListValue *urls; | 1125 const base::ListValue *urls; |
1117 UserManager* user_manager = UserManager::Get(); | 1126 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
1118 bool can_show_getstarted_guide = | 1127 bool can_show_getstarted_guide = |
1119 user_manager->GetActiveUser()->GetType() == | 1128 user_manager->GetActiveUser()->GetType() == |
1120 user_manager::USER_TYPE_REGULAR && | 1129 user_manager::USER_TYPE_REGULAR && |
1121 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); | 1130 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); |
1122 if (user_manager->IsLoggedInAsDemoUser()) { | 1131 if (user_manager->IsLoggedInAsDemoUser()) { |
1123 if (CrosSettings::Get()->GetList(kStartUpUrls, &urls)) { | 1132 if (CrosSettings::Get()->GetList(kStartUpUrls, &urls)) { |
1124 // The retail mode user will get start URLs from a special policy if it is | 1133 // The retail mode user will get start URLs from a special policy if it is |
1125 // set. | 1134 // set. |
1126 for (base::ListValue::const_iterator it = urls->begin(); | 1135 for (base::ListValue::const_iterator it = urls->begin(); |
1127 it != urls->end(); ++it) { | 1136 it != urls->end(); ++it) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 default: | 1191 default: |
1183 help_topic_id = is_offline ? | 1192 help_topic_id = is_offline ? |
1184 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE : | 1193 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE : |
1185 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT; | 1194 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT; |
1186 break; | 1195 break; |
1187 } | 1196 } |
1188 | 1197 |
1189 if (error_id == IDS_LOGIN_ERROR_AUTHENTICATING) { | 1198 if (error_id == IDS_LOGIN_ERROR_AUTHENTICATING) { |
1190 if (num_login_attempts_ > 1) { | 1199 if (num_login_attempts_ > 1) { |
1191 const user_manager::User* user = | 1200 const user_manager::User* user = |
1192 UserManager::Get()->FindUser(last_login_attempt_username_); | 1201 user_manager::UserManager::Get()->FindUser( |
| 1202 last_login_attempt_username_); |
1193 if (user && (user->GetType() == user_manager::USER_TYPE_SUPERVISED)) | 1203 if (user && (user->GetType() == user_manager::USER_TYPE_SUPERVISED)) |
1194 error_id = IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME_SUPERVISED; | 1204 error_id = IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME_SUPERVISED; |
1195 } | 1205 } |
1196 } | 1206 } |
1197 | 1207 |
1198 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id); | 1208 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id); |
1199 } | 1209 } |
1200 | 1210 |
1201 void ExistingUserController::ShowGaiaPasswordChanged( | 1211 void ExistingUserController::ShowGaiaPasswordChanged( |
1202 const std::string& username) { | 1212 const std::string& username) { |
1203 // Invalidate OAuth token, since it can't be correct after password is | 1213 // Invalidate OAuth token, since it can't be correct after password is |
1204 // changed. | 1214 // changed. |
1205 UserManager::Get()->SaveUserOAuthStatus( | 1215 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
1206 username, user_manager::User::OAUTH2_TOKEN_STATUS_INVALID); | 1216 username, user_manager::User::OAUTH2_TOKEN_STATUS_INVALID); |
1207 | 1217 |
1208 login_display_->SetUIEnabled(true); | 1218 login_display_->SetUIEnabled(true); |
1209 login_display_->ShowGaiaPasswordChanged(username); | 1219 login_display_->ShowGaiaPasswordChanged(username); |
1210 } | 1220 } |
1211 | 1221 |
1212 void ExistingUserController::SendAccessibilityAlert( | 1222 void ExistingUserController::SendAccessibilityAlert( |
1213 const std::string& alert_text) { | 1223 const std::string& alert_text) { |
1214 AccessibilityAlertInfo event(ProfileHelper::GetSigninProfile(), alert_text); | 1224 AccessibilityAlertInfo event(ProfileHelper::GetSigninProfile(), alert_text); |
1215 SendControlAccessibilityNotification( | 1225 SendControlAccessibilityNotification( |
(...skipping 26 matching lines...) Expand all Loading... |
1242 // Only one instance of LoginPerformer should exist at a time. | 1252 // Only one instance of LoginPerformer should exist at a time. |
1243 login_performer_.reset(NULL); | 1253 login_performer_.reset(NULL); |
1244 login_performer_.reset(new LoginPerformer(this)); | 1254 login_performer_.reset(new LoginPerformer(this)); |
1245 is_login_in_progress_ = true; | 1255 is_login_in_progress_ = true; |
1246 login_performer_->LoginAsPublicSession(user_context); | 1256 login_performer_->LoginAsPublicSession(user_context); |
1247 SendAccessibilityAlert( | 1257 SendAccessibilityAlert( |
1248 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); | 1258 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); |
1249 } | 1259 } |
1250 | 1260 |
1251 } // namespace chromeos | 1261 } // namespace chromeos |
OLD | NEW |