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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 // URLs via policy. | 775 // URLs via policy. |
776 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) | 776 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) |
777 InitializeStartUrls(); | 777 InitializeStartUrls(); |
778 #ifndef NDEBUG | 778 #ifndef NDEBUG |
779 if (CommandLine::ForCurrentProcess()->HasSwitch( | 779 if (CommandLine::ForCurrentProcess()->HasSwitch( |
780 switches::kOobeSkipPostLogin)) { | 780 switches::kOobeSkipPostLogin)) { |
781 LoginUtils::Get()->DoBrowserLaunch(profile, host_); | 781 LoginUtils::Get()->DoBrowserLaunch(profile, host_); |
782 host_ = NULL; | 782 host_ = NULL; |
783 } else { | 783 } else { |
784 #endif | 784 #endif |
785 ActivateWizard(WizardController::IsDeviceRegistered() ? | 785 // Mark the device as registered., i.e. the second part of OOBE as |
786 WizardController::kTermsOfServiceScreenName : | 786 // completed. |
787 WizardController::kRegistrationScreenName); | 787 if (!WizardController::IsDeviceRegistered()) |
| 788 WizardController::MarkDeviceRegistered(); |
| 789 |
| 790 ActivateWizard(WizardController::kTermsOfServiceScreenName); |
788 #ifndef NDEBUG | 791 #ifndef NDEBUG |
789 } | 792 } |
790 #endif | 793 #endif |
791 } else { | 794 } else { |
792 LoginUtils::Get()->DoBrowserLaunch(profile, host_); | 795 LoginUtils::Get()->DoBrowserLaunch(profile, host_); |
793 host_ = NULL; | 796 host_ = NULL; |
794 } | 797 } |
795 // Inform |login_status_consumer_| about successful login. Set most | 798 // Inform |login_status_consumer_| about successful login. Set most |
796 // parameters to empty since they're not needed. | 799 // parameters to empty since they're not needed. |
797 if (login_status_consumer_) { | 800 if (login_status_consumer_) { |
798 login_status_consumer_->OnLoginSuccess(UserContext(), | 801 login_status_consumer_->OnLoginSuccess(UserContext(), |
799 false, // pending_requests | 802 false, // pending_requests |
800 false); // using_oauth | 803 false); // using_oauth |
801 } | 804 } |
802 login_display_->OnFadeOut(); | 805 login_display_->OnFadeOut(); |
803 } | 806 } |
804 | 807 |
805 void ExistingUserController::OnOffTheRecordLoginSuccess() { | 808 void ExistingUserController::OnOffTheRecordLoginSuccess() { |
806 is_login_in_progress_ = false; | 809 is_login_in_progress_ = false; |
807 offline_failed_ = false; | 810 offline_failed_ = false; |
808 if (WizardController::IsDeviceRegistered()) { | 811 |
809 LoginUtils::Get()->CompleteOffTheRecordLogin(guest_mode_url_); | 812 // Mark the device as registered., i.e. the second part of OOBE as completed. |
810 } else { | 813 if (!WizardController::IsDeviceRegistered()) |
811 // Postpone CompleteOffTheRecordLogin until registration completion. | 814 WizardController::MarkDeviceRegistered(); |
812 // TODO(nkostylev): Kind of hack. We have to instruct UserManager here | 815 |
813 // that we're actually logged in as Guest user as we'll ask UserManager | 816 LoginUtils::Get()->CompleteOffTheRecordLogin(guest_mode_url_); |
814 // later in the code path whether we've signed in as Guest and depending | |
815 // on that would either show image screen or call CompleteOffTheRecordLogin. | |
816 UserManager::Get()->GuestUserLoggedIn(); | |
817 ActivateWizard(WizardController::kRegistrationScreenName); | |
818 } | |
819 | 817 |
820 if (login_status_consumer_) | 818 if (login_status_consumer_) |
821 login_status_consumer_->OnOffTheRecordLoginSuccess(); | 819 login_status_consumer_->OnOffTheRecordLoginSuccess(); |
822 } | 820 } |
823 | 821 |
824 void ExistingUserController::OnPasswordChangeDetected() { | 822 void ExistingUserController::OnPasswordChangeDetected() { |
825 // Must not proceed without signature verification. | 823 // Must not proceed without signature verification. |
826 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( | 824 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( |
827 base::Bind(&ExistingUserController::OnPasswordChangeDetected, | 825 base::Bind(&ExistingUserController::OnPasswordChangeDetected, |
828 weak_factory_.GetWeakPtr()))) { | 826 weak_factory_.GetWeakPtr()))) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 // Wait for login attempt to end, if it hasn't yet. | 887 // Wait for login attempt to end, if it hasn't yet. |
890 if (offline_failed_ && !is_login_in_progress_) | 888 if (offline_failed_ && !is_login_in_progress_) |
891 ShowGaiaPasswordChanged(username); | 889 ShowGaiaPasswordChanged(username); |
892 } | 890 } |
893 } | 891 } |
894 | 892 |
895 //////////////////////////////////////////////////////////////////////////////// | 893 //////////////////////////////////////////////////////////////////////////////// |
896 // ExistingUserController, private: | 894 // ExistingUserController, private: |
897 | 895 |
898 void ExistingUserController::ActivateWizard(const std::string& screen_name) { | 896 void ExistingUserController::ActivateWizard(const std::string& screen_name) { |
899 DictionaryValue* params = NULL; | 897 host_->StartWizard(screen_name, NULL); |
900 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) { | |
901 params = new DictionaryValue; | |
902 params->SetString("start_url", guest_mode_url_.spec()); | |
903 } | |
904 host_->StartWizard(screen_name, params); | |
905 } | 898 } |
906 | 899 |
907 void ExistingUserController::ConfigurePublicSessionAutoLogin() { | 900 void ExistingUserController::ConfigurePublicSessionAutoLogin() { |
908 if (!cros_settings_->GetString( | 901 if (!cros_settings_->GetString( |
909 kAccountsPrefDeviceLocalAccountAutoLoginId, | 902 kAccountsPrefDeviceLocalAccountAutoLoginId, |
910 &public_session_auto_login_username_)) { | 903 &public_session_auto_login_username_)) { |
911 public_session_auto_login_username_.clear(); | 904 public_session_auto_login_username_.clear(); |
912 } | 905 } |
913 if (!cros_settings_->GetInteger( | 906 if (!cros_settings_->GetInteger( |
914 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 907 kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 // changed. | 1094 // changed. |
1102 UserManager::Get()->SaveUserOAuthStatus( | 1095 UserManager::Get()->SaveUserOAuthStatus( |
1103 username, | 1096 username, |
1104 User::OAUTH2_TOKEN_STATUS_INVALID); | 1097 User::OAUTH2_TOKEN_STATUS_INVALID); |
1105 | 1098 |
1106 login_display_->SetUIEnabled(true); | 1099 login_display_->SetUIEnabled(true); |
1107 login_display_->ShowGaiaPasswordChanged(username); | 1100 login_display_->ShowGaiaPasswordChanged(username); |
1108 } | 1101 } |
1109 | 1102 |
1110 } // namespace chromeos | 1103 } // namespace chromeos |
OLD | NEW |