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; |
| 498 } |
495 | 499 |
496 // Stop the auto-login timer when attempting login. | 500 // Stop the auto-login timer when attempting login. |
497 StopPublicSessionAutoLoginTimer(); | 501 StopPublicSessionAutoLoginTimer(); |
498 | 502 |
499 // Disable clicking on other windows. | 503 // Disable clicking on other windows. |
500 login_display_->SetUIEnabled(false); | 504 login_display_->SetUIEnabled(false); |
501 | 505 |
502 CrosSettingsProvider::TrustedStatus status = | 506 CrosSettingsProvider::TrustedStatus status = |
503 cros_settings_->PrepareTrustedValues( | 507 cros_settings_->PrepareTrustedValues( |
504 base::Bind(&ExistingUserController::LoginAsGuest, | 508 base::Bind(&ExistingUserController::LoginAsGuest, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 } | 547 } |
544 | 548 |
545 void ExistingUserController::MigrateUserData(const std::string& old_password) { | 549 void ExistingUserController::MigrateUserData(const std::string& old_password) { |
546 // LoginPerformer instance has state of the user so it should exist. | 550 // LoginPerformer instance has state of the user so it should exist. |
547 if (login_performer_.get()) | 551 if (login_performer_.get()) |
548 login_performer_->RecoverEncryptedData(old_password); | 552 login_performer_->RecoverEncryptedData(old_password); |
549 } | 553 } |
550 | 554 |
551 void ExistingUserController::LoginAsPublicSession( | 555 void ExistingUserController::LoginAsPublicSession( |
552 const UserContext& user_context) { | 556 const UserContext& user_context) { |
553 if (is_login_in_progress_ || UserManager::Get()->IsUserLoggedIn()) | 557 if (is_login_in_progress_ || |
| 558 user_manager::UserManager::Get()->IsUserLoggedIn()) { |
554 return; | 559 return; |
| 560 } |
555 | 561 |
556 // Stop the auto-login timer when attempting login. | 562 // Stop the auto-login timer when attempting login. |
557 StopPublicSessionAutoLoginTimer(); | 563 StopPublicSessionAutoLoginTimer(); |
558 | 564 |
559 // Disable clicking on other windows. | 565 // Disable clicking on other windows. |
560 login_display_->SetUIEnabled(false); | 566 login_display_->SetUIEnabled(false); |
561 | 567 |
562 CrosSettingsProvider::TrustedStatus status = | 568 CrosSettingsProvider::TrustedStatus status = |
563 cros_settings_->PrepareTrustedValues( | 569 cros_settings_->PrepareTrustedValues( |
564 base::Bind(&ExistingUserController::LoginAsPublicSession, | 570 base::Bind(&ExistingUserController::LoginAsPublicSession, |
(...skipping 10 matching lines...) Expand all Loading... |
575 } | 581 } |
576 | 582 |
577 // If device policy is not verified yet, this function will be called again | 583 // If device policy is not verified yet, this function will be called again |
578 // when verification finishes. | 584 // when verification finishes. |
579 if (status != CrosSettingsProvider::TRUSTED) | 585 if (status != CrosSettingsProvider::TRUSTED) |
580 return; | 586 return; |
581 | 587 |
582 // If there is no public account with the given user ID, logging in is not | 588 // If there is no public account with the given user ID, logging in is not |
583 // possible. | 589 // possible. |
584 const user_manager::User* user = | 590 const user_manager::User* user = |
585 UserManager::Get()->FindUser(user_context.GetUserID()); | 591 user_manager::UserManager::Get()->FindUser(user_context.GetUserID()); |
586 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { | 592 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { |
587 // Re-enable clicking on other windows. | 593 // Re-enable clicking on other windows. |
588 login_display_->SetUIEnabled(true); | 594 login_display_->SetUIEnabled(true); |
589 StartPublicSessionAutoLoginTimer(); | 595 StartPublicSessionAutoLoginTimer(); |
590 return; | 596 return; |
591 } | 597 } |
592 | 598 |
593 UserContext new_user_context = user_context; | 599 UserContext new_user_context = user_context; |
594 std::string locale = user_context.GetPublicSessionLocale(); | 600 std::string locale = user_context.GetPublicSessionLocale(); |
595 if (locale.empty()) { | 601 if (locale.empty()) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 // ExistingUserController, LoginPerformer::Delegate implementation: | 766 // ExistingUserController, LoginPerformer::Delegate implementation: |
761 // | 767 // |
762 | 768 |
763 void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { | 769 void ExistingUserController::OnAuthFailure(const AuthFailure& failure) { |
764 is_login_in_progress_ = false; | 770 is_login_in_progress_ = false; |
765 offline_failed_ = true; | 771 offline_failed_ = true; |
766 | 772 |
767 guest_mode_url_ = GURL::EmptyGURL(); | 773 guest_mode_url_ = GURL::EmptyGURL(); |
768 std::string error = failure.GetErrorString(); | 774 std::string error = failure.GetErrorString(); |
769 | 775 |
770 if (UserManager::Get()->GetUserFlow(last_login_attempt_username_)-> | 776 if (ChromeUserManager::Get() |
771 HandleLoginFailure(failure)) { | 777 ->GetUserFlow(last_login_attempt_username_) |
| 778 ->HandleLoginFailure(failure)) { |
772 login_display_->SetUIEnabled(true); | 779 login_display_->SetUIEnabled(true); |
773 return; | 780 return; |
774 } | 781 } |
775 | 782 |
776 if (failure.reason() == AuthFailure::OWNER_REQUIRED) { | 783 if (failure.reason() == AuthFailure::OWNER_REQUIRED) { |
777 ShowError(IDS_LOGIN_ERROR_OWNER_REQUIRED, error); | 784 ShowError(IDS_LOGIN_ERROR_OWNER_REQUIRED, error); |
778 content::BrowserThread::PostDelayedTask( | 785 content::BrowserThread::PostDelayedTask( |
779 content::BrowserThread::UI, FROM_HERE, | 786 content::BrowserThread::UI, FROM_HERE, |
780 base::Bind(&SessionManagerClient::StopSession, | 787 base::Bind(&SessionManagerClient::StopSession, |
781 base::Unretained(DBusThreadManager::Get()-> | 788 base::Unretained(DBusThreadManager::Get()-> |
782 GetSessionManagerClient())), | 789 GetSessionManagerClient())), |
783 base::TimeDelta::FromMilliseconds(kSafeModeRestartUiDelayMs)); | 790 base::TimeDelta::FromMilliseconds(kSafeModeRestartUiDelayMs)); |
784 } else if (failure.reason() == AuthFailure::TPM_ERROR) { | 791 } else if (failure.reason() == AuthFailure::TPM_ERROR) { |
785 ShowTPMError(); | 792 ShowTPMError(); |
786 } else if (!online_succeeded_for_.empty()) { | 793 } else if (!online_succeeded_for_.empty()) { |
787 ShowGaiaPasswordChanged(online_succeeded_for_); | 794 ShowGaiaPasswordChanged(online_succeeded_for_); |
788 } else { | 795 } else { |
789 // Check networking after trying to login in case user is | 796 // Check networking after trying to login in case user is |
790 // cached locally or the local admin account. | 797 // cached locally or the local admin account. |
791 bool is_known_user = | 798 bool is_known_user = user_manager::UserManager::Get()->IsKnownUser( |
792 UserManager::Get()->IsKnownUser(last_login_attempt_username_); | 799 last_login_attempt_username_); |
793 if (!network_state_helper_->IsConnected()) { | 800 if (!network_state_helper_->IsConnected()) { |
794 if (is_known_user) | 801 if (is_known_user) |
795 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); | 802 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
796 else | 803 else |
797 ShowError(IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, error); | 804 ShowError(IDS_LOGIN_ERROR_OFFLINE_FAILED_NETWORK_NOT_CONNECTED, error); |
798 } else { | 805 } else { |
799 // TODO(nkostylev): Cleanup rest of ClientLogin related code. | 806 // TODO(nkostylev): Cleanup rest of ClientLogin related code. |
800 if (failure.reason() == AuthFailure::NETWORK_AUTH_FAILED && | 807 if (failure.reason() == AuthFailure::NETWORK_AUTH_FAILED && |
801 failure.error().state() == | 808 failure.error().state() == |
802 GoogleServiceAuthError::HOSTED_NOT_ALLOWED) { | 809 GoogleServiceAuthError::HOSTED_NOT_ALLOWED) { |
803 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); | 810 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); |
804 } else { | 811 } else { |
805 if (!is_known_user) | 812 if (!is_known_user) |
806 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); | 813 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); |
807 else | 814 else |
808 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); | 815 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
809 } | 816 } |
810 } | 817 } |
811 // Reenable clicking on other windows and status area. | 818 // Reenable clicking on other windows and status area. |
812 login_display_->SetUIEnabled(true); | 819 login_display_->SetUIEnabled(true); |
813 login_display_->ClearAndEnablePassword(); | 820 login_display_->ClearAndEnablePassword(); |
814 StartPublicSessionAutoLoginTimer(); | 821 StartPublicSessionAutoLoginTimer(); |
815 } | 822 } |
816 | 823 |
817 // Reset user flow to default, so that special flow will not affect next | 824 // Reset user flow to default, so that special flow will not affect next |
818 // attempt. | 825 // attempt. |
819 UserManager::Get()->ResetUserFlow(last_login_attempt_username_); | 826 ChromeUserManager::Get()->ResetUserFlow(last_login_attempt_username_); |
820 | 827 |
821 if (auth_status_consumer_) | 828 if (auth_status_consumer_) |
822 auth_status_consumer_->OnAuthFailure(failure); | 829 auth_status_consumer_->OnAuthFailure(failure); |
823 | 830 |
824 // Clear the recorded displayed email so it won't affect any future attempts. | 831 // Clear the recorded displayed email so it won't affect any future attempts. |
825 display_email_.clear(); | 832 display_email_.clear(); |
826 } | 833 } |
827 | 834 |
828 void ExistingUserController::OnAuthSuccess(const UserContext& user_context) { | 835 void ExistingUserController::OnAuthSuccess(const UserContext& user_context) { |
829 is_login_in_progress_ = false; | 836 is_login_in_progress_ = false; |
830 offline_failed_ = false; | 837 offline_failed_ = false; |
831 login_display_->set_signin_completed(true); | 838 login_display_->set_signin_completed(true); |
832 | 839 |
833 // Login performer will be gone so cache this value to use | 840 // Login performer will be gone so cache this value to use |
834 // once profile is loaded. | 841 // once profile is loaded. |
835 password_changed_ = login_performer_->password_changed(); | 842 password_changed_ = login_performer_->password_changed(); |
836 auth_mode_ = login_performer_->auth_mode(); | 843 auth_mode_ = login_performer_->auth_mode(); |
837 | 844 |
838 UserManager::Get()->GetUserFlow(user_context.GetUserID())-> | 845 ChromeUserManager::Get() |
839 HandleLoginSuccess(user_context); | 846 ->GetUserFlow(user_context.GetUserID()) |
| 847 ->HandleLoginSuccess(user_context); |
840 | 848 |
841 StopPublicSessionAutoLoginTimer(); | 849 StopPublicSessionAutoLoginTimer(); |
842 | 850 |
843 const bool has_auth_cookies = | 851 const bool has_auth_cookies = |
844 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION && | 852 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION && |
845 user_context.GetAuthCode().empty(); | 853 user_context.GetAuthCode().empty(); |
846 | 854 |
847 // LoginPerformer instance will delete itself once online auth result is OK. | 855 // LoginPerformer instance will delete itself once online auth result is OK. |
848 // In case of failure it'll bring up ScreenLock and ask for | 856 // In case of failure it'll bring up ScreenLock and ask for |
849 // correct password/display error message. | 857 // correct password/display error message. |
850 // Even in case when following online,offline protocol and returning | 858 // Even in case when following online,offline protocol and returning |
851 // requests_pending = false, let LoginPerformer delete itself. | 859 // requests_pending = false, let LoginPerformer delete itself. |
852 login_performer_->set_delegate(NULL); | 860 login_performer_->set_delegate(NULL); |
853 ignore_result(login_performer_.release()); | 861 ignore_result(login_performer_.release()); |
854 | 862 |
855 // Update user's displayed email. | 863 // Update user's displayed email. |
856 if (!display_email_.empty()) { | 864 if (!display_email_.empty()) { |
857 UserManager::Get()->SaveUserDisplayEmail(user_context.GetUserID(), | 865 user_manager::UserManager::Get()->SaveUserDisplayEmail( |
858 display_email_); | 866 user_context.GetUserID(), display_email_); |
859 display_email_.clear(); | 867 display_email_.clear(); |
860 } | 868 } |
861 | 869 |
862 // Will call OnProfilePrepared() in the end. | 870 // Will call OnProfilePrepared() in the end. |
863 LoginUtils::Get()->PrepareProfile(user_context, | 871 LoginUtils::Get()->PrepareProfile(user_context, |
864 has_auth_cookies, | 872 has_auth_cookies, |
865 false, // Start session for user. | 873 false, // Start session for user. |
866 this); | 874 this); |
867 } | 875 } |
868 | 876 |
869 void ExistingUserController::OnProfilePrepared(Profile* profile) { | 877 void ExistingUserController::OnProfilePrepared(Profile* profile) { |
870 // Reenable clicking on other windows and status area. | 878 // Reenable clicking on other windows and status area. |
871 login_display_->SetUIEnabled(true); | 879 login_display_->SetUIEnabled(true); |
872 | 880 |
873 UserManager* user_manager = UserManager::Get(); | 881 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
874 if (user_manager->IsCurrentUserNew() && | 882 if (user_manager->IsCurrentUserNew() && |
875 user_manager->IsLoggedInAsSupervisedUser()) { | 883 user_manager->IsLoggedInAsSupervisedUser()) { |
876 // Supervised users should launch into empty desktop on first run. | 884 // Supervised users should launch into empty desktop on first run. |
877 CommandLine::ForCurrentProcess()->AppendSwitch(::switches::kSilentLaunch); | 885 CommandLine::ForCurrentProcess()->AppendSwitch(::switches::kSilentLaunch); |
878 } | 886 } |
879 | 887 |
880 if (user_manager->IsCurrentUserNew() && | 888 if (user_manager->IsCurrentUserNew() && |
881 !user_manager->GetCurrentUserFlow()->ShouldSkipPostLoginScreens() && | 889 !ChromeUserManager::Get() |
| 890 ->GetCurrentUserFlow() |
| 891 ->ShouldSkipPostLoginScreens() && |
882 !WizardController::default_controller()->skip_post_login_screens()) { | 892 !WizardController::default_controller()->skip_post_login_screens()) { |
883 // Don't specify start URLs if the administrator has configured the start | 893 // Don't specify start URLs if the administrator has configured the start |
884 // URLs via policy. | 894 // URLs via policy. |
885 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) | 895 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) |
886 InitializeStartUrls(); | 896 InitializeStartUrls(); |
887 | 897 |
888 // Mark the device as registered., i.e. the second part of OOBE as | 898 // Mark the device as registered., i.e. the second part of OOBE as |
889 // completed. | 899 // completed. |
890 if (!StartupUtils::IsDeviceRegistered()) | 900 if (!StartupUtils::IsDeviceRegistered()) |
891 StartupUtils::MarkDeviceRegistered(base::Closure()); | 901 StartupUtils::MarkDeviceRegistered(base::Closure()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 | 936 |
927 // Must not proceed without signature verification. | 937 // Must not proceed without signature verification. |
928 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( | 938 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( |
929 base::Bind(&ExistingUserController::OnPasswordChangeDetected, | 939 base::Bind(&ExistingUserController::OnPasswordChangeDetected, |
930 weak_factory_.GetWeakPtr()))) { | 940 weak_factory_.GetWeakPtr()))) { |
931 // Value of owner email is still not verified. | 941 // Value of owner email is still not verified. |
932 // Another attempt will be invoked after verification completion. | 942 // Another attempt will be invoked after verification completion. |
933 return; | 943 return; |
934 } | 944 } |
935 | 945 |
936 if (UserManager::Get()->GetUserFlow(last_login_attempt_username_)-> | 946 if (ChromeUserManager::Get() |
937 HandlePasswordChangeDetected()) { | 947 ->GetUserFlow(last_login_attempt_username_) |
| 948 ->HandlePasswordChangeDetected()) { |
938 return; | 949 return; |
939 } | 950 } |
940 | 951 |
941 // True if user has already made an attempt to enter old password and failed. | 952 // True if user has already made an attempt to enter old password and failed. |
942 bool show_invalid_old_password_error = | 953 bool show_invalid_old_password_error = |
943 login_performer_->password_changed_callback_count() > 1; | 954 login_performer_->password_changed_callback_count() > 1; |
944 | 955 |
945 // Note: We allow owner using "full sync" mode which will recreate | 956 // Note: We allow owner using "full sync" mode which will recreate |
946 // cryptohome and deal with owner private key being lost. This also allows | 957 // cryptohome and deal with owner private key being lost. This also allows |
947 // us to recover from a lost owner password/homedir. | 958 // 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); | 1009 ShowGaiaPasswordChanged(username); |
999 } | 1010 } |
1000 } | 1011 } |
1001 | 1012 |
1002 //////////////////////////////////////////////////////////////////////////////// | 1013 //////////////////////////////////////////////////////////////////////////////// |
1003 // ExistingUserController, private: | 1014 // ExistingUserController, private: |
1004 | 1015 |
1005 void ExistingUserController::DeviceSettingsChanged() { | 1016 void ExistingUserController::DeviceSettingsChanged() { |
1006 if (host_ != NULL) { | 1017 if (host_ != NULL) { |
1007 // Signed settings or user list changed. Notify views and update them. | 1018 // Signed settings or user list changed. Notify views and update them. |
1008 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); | 1019 UpdateLoginDisplay(user_manager::UserManager::Get()->GetUsers()); |
1009 ConfigurePublicSessionAutoLogin(); | 1020 ConfigurePublicSessionAutoLogin(); |
1010 return; | 1021 return; |
1011 } | 1022 } |
1012 } | 1023 } |
1013 | 1024 |
1014 void ExistingUserController::ActivateWizard(const std::string& screen_name) { | 1025 void ExistingUserController::ActivateWizard(const std::string& screen_name) { |
1015 scoped_ptr<base::DictionaryValue> params; | 1026 scoped_ptr<base::DictionaryValue> params; |
1016 host_->StartWizard(screen_name, params.Pass()); | 1027 host_->StartWizard(screen_name, params.Pass()); |
1017 } | 1028 } |
1018 | 1029 |
(...skipping 21 matching lines...) Expand all Loading... |
1040 public_session_auto_login_username_.clear(); | 1051 public_session_auto_login_username_.clear(); |
1041 for (std::vector<policy::DeviceLocalAccount>::const_iterator | 1052 for (std::vector<policy::DeviceLocalAccount>::const_iterator |
1042 it = device_local_accounts.begin(); | 1053 it = device_local_accounts.begin(); |
1043 it != device_local_accounts.end(); ++it) { | 1054 it != device_local_accounts.end(); ++it) { |
1044 if (it->account_id == auto_login_account_id) { | 1055 if (it->account_id == auto_login_account_id) { |
1045 public_session_auto_login_username_ = it->user_id; | 1056 public_session_auto_login_username_ = it->user_id; |
1046 break; | 1057 break; |
1047 } | 1058 } |
1048 } | 1059 } |
1049 | 1060 |
1050 const user_manager::User* user = | 1061 const user_manager::User* user = user_manager::UserManager::Get()->FindUser( |
1051 UserManager::Get()->FindUser(public_session_auto_login_username_); | 1062 public_session_auto_login_username_); |
1052 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) | 1063 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) |
1053 public_session_auto_login_username_.clear(); | 1064 public_session_auto_login_username_.clear(); |
1054 | 1065 |
1055 if (!cros_settings_->GetInteger( | 1066 if (!cros_settings_->GetInteger( |
1056 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 1067 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
1057 &public_session_auto_login_delay_)) { | 1068 &public_session_auto_login_delay_)) { |
1058 public_session_auto_login_delay_ = 0; | 1069 public_session_auto_login_delay_ = 0; |
1059 } | 1070 } |
1060 | 1071 |
1061 if (!public_session_auto_login_username_.empty()) | 1072 if (!public_session_auto_login_username_.empty()) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 } | 1118 } |
1108 | 1119 |
1109 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { | 1120 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { |
1110 return host_->GetNativeWindow(); | 1121 return host_->GetNativeWindow(); |
1111 } | 1122 } |
1112 | 1123 |
1113 void ExistingUserController::InitializeStartUrls() const { | 1124 void ExistingUserController::InitializeStartUrls() const { |
1114 std::vector<std::string> start_urls; | 1125 std::vector<std::string> start_urls; |
1115 | 1126 |
1116 const base::ListValue *urls; | 1127 const base::ListValue *urls; |
1117 UserManager* user_manager = UserManager::Get(); | 1128 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
1118 bool can_show_getstarted_guide = | 1129 bool can_show_getstarted_guide = |
1119 user_manager->GetActiveUser()->GetType() == | 1130 user_manager->GetActiveUser()->GetType() == |
1120 user_manager::USER_TYPE_REGULAR && | 1131 user_manager::USER_TYPE_REGULAR && |
1121 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); | 1132 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); |
1122 if (user_manager->IsLoggedInAsDemoUser()) { | 1133 if (user_manager->IsLoggedInAsDemoUser()) { |
1123 if (CrosSettings::Get()->GetList(kStartUpUrls, &urls)) { | 1134 if (CrosSettings::Get()->GetList(kStartUpUrls, &urls)) { |
1124 // The retail mode user will get start URLs from a special policy if it is | 1135 // The retail mode user will get start URLs from a special policy if it is |
1125 // set. | 1136 // set. |
1126 for (base::ListValue::const_iterator it = urls->begin(); | 1137 for (base::ListValue::const_iterator it = urls->begin(); |
1127 it != urls->end(); ++it) { | 1138 it != urls->end(); ++it) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 default: | 1193 default: |
1183 help_topic_id = is_offline ? | 1194 help_topic_id = is_offline ? |
1184 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE : | 1195 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT_OFFLINE : |
1185 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT; | 1196 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT; |
1186 break; | 1197 break; |
1187 } | 1198 } |
1188 | 1199 |
1189 if (error_id == IDS_LOGIN_ERROR_AUTHENTICATING) { | 1200 if (error_id == IDS_LOGIN_ERROR_AUTHENTICATING) { |
1190 if (num_login_attempts_ > 1) { | 1201 if (num_login_attempts_ > 1) { |
1191 const user_manager::User* user = | 1202 const user_manager::User* user = |
1192 UserManager::Get()->FindUser(last_login_attempt_username_); | 1203 user_manager::UserManager::Get()->FindUser( |
| 1204 last_login_attempt_username_); |
1193 if (user && (user->GetType() == user_manager::USER_TYPE_SUPERVISED)) | 1205 if (user && (user->GetType() == user_manager::USER_TYPE_SUPERVISED)) |
1194 error_id = IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME_SUPERVISED; | 1206 error_id = IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME_SUPERVISED; |
1195 } | 1207 } |
1196 } | 1208 } |
1197 | 1209 |
1198 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id); | 1210 login_display_->ShowError(error_id, num_login_attempts_, help_topic_id); |
1199 } | 1211 } |
1200 | 1212 |
1201 void ExistingUserController::ShowGaiaPasswordChanged( | 1213 void ExistingUserController::ShowGaiaPasswordChanged( |
1202 const std::string& username) { | 1214 const std::string& username) { |
1203 // Invalidate OAuth token, since it can't be correct after password is | 1215 // Invalidate OAuth token, since it can't be correct after password is |
1204 // changed. | 1216 // changed. |
1205 UserManager::Get()->SaveUserOAuthStatus( | 1217 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
1206 username, user_manager::User::OAUTH2_TOKEN_STATUS_INVALID); | 1218 username, user_manager::User::OAUTH2_TOKEN_STATUS_INVALID); |
1207 | 1219 |
1208 login_display_->SetUIEnabled(true); | 1220 login_display_->SetUIEnabled(true); |
1209 login_display_->ShowGaiaPasswordChanged(username); | 1221 login_display_->ShowGaiaPasswordChanged(username); |
1210 } | 1222 } |
1211 | 1223 |
1212 void ExistingUserController::SendAccessibilityAlert( | 1224 void ExistingUserController::SendAccessibilityAlert( |
1213 const std::string& alert_text) { | 1225 const std::string& alert_text) { |
1214 AccessibilityAlertInfo event(ProfileHelper::GetSigninProfile(), alert_text); | 1226 AccessibilityAlertInfo event(ProfileHelper::GetSigninProfile(), alert_text); |
1215 SendControlAccessibilityNotification( | 1227 SendControlAccessibilityNotification( |
(...skipping 26 matching lines...) Expand all Loading... |
1242 // Only one instance of LoginPerformer should exist at a time. | 1254 // Only one instance of LoginPerformer should exist at a time. |
1243 login_performer_.reset(NULL); | 1255 login_performer_.reset(NULL); |
1244 login_performer_.reset(new LoginPerformer(this)); | 1256 login_performer_.reset(new LoginPerformer(this)); |
1245 is_login_in_progress_ = true; | 1257 is_login_in_progress_ = true; |
1246 login_performer_->LoginAsPublicSession(user_context); | 1258 login_performer_->LoginAsPublicSession(user_context); |
1247 SendAccessibilityAlert( | 1259 SendAccessibilityAlert( |
1248 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); | 1260 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); |
1249 } | 1261 } |
1250 | 1262 |
1251 } // namespace chromeos | 1263 } // namespace chromeos |
OLD | NEW |