OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/session/user_session_manager.h" | 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 CrosSettings::Get()->GetBoolean( | 773 CrosSettings::Get()->GetBoolean( |
774 kAccountsPrefTransferSAMLCookies, | 774 kAccountsPrefTransferSAMLCookies, |
775 &transfer_saml_auth_cookies_on_subsequent_login); | 775 &transfer_saml_auth_cookies_on_subsequent_login); |
776 } | 776 } |
777 | 777 |
778 // Transfers authentication-related data from the profile that was used for | 778 // Transfers authentication-related data from the profile that was used for |
779 // authentication to the user's profile. The proxy authentication state is | 779 // authentication to the user's profile. The proxy authentication state is |
780 // transferred unconditionally. If the user authenticated via an auth | 780 // transferred unconditionally. If the user authenticated via an auth |
781 // extension, authentication cookies and channel IDs will be transferred as | 781 // extension, authentication cookies and channel IDs will be transferred as |
782 // well when the user's cookie jar is empty. If the cookie jar is not empty, | 782 // well when the user's cookie jar is empty. If the cookie jar is not empty, |
783 // the authentication states in the browser context and the user's profile | 783 // the authentication states in the login profile and the user's profile |
784 // must be merged using /MergeSession instead. Authentication cookies set by | 784 // must be merged using /MergeSession instead. Authentication cookies set by |
785 // a SAML IdP will also be transferred when the user's cookie jar is not | 785 // a SAML IdP will also be transferred when the user's cookie jar is not |
786 // empty if |transfer_saml_auth_cookies_on_subsequent_login| is true. | 786 // empty if |transfer_saml_auth_cookies_on_subsequent_login| is true. |
787 const bool transfer_auth_cookies_and_channel_ids_on_first_login = | 787 const bool transfer_auth_cookies_and_channel_ids_on_first_login = |
788 has_auth_cookies_; | 788 has_auth_cookies_; |
789 ProfileAuthData::Transfer( | 789 ProfileAuthData::Transfer( |
790 authenticator_->authentication_context(), | 790 authenticator_->authentication_profile(), |
791 profile, | 791 profile, |
792 transfer_auth_cookies_and_channel_ids_on_first_login, | 792 transfer_auth_cookies_and_channel_ids_on_first_login, |
793 transfer_saml_auth_cookies_on_subsequent_login, | 793 transfer_saml_auth_cookies_on_subsequent_login, |
794 base::Bind(&UserSessionManager::CompleteProfileCreateAfterAuthTransfer, | 794 base::Bind(&UserSessionManager::CompleteProfileCreateAfterAuthTransfer, |
795 AsWeakPtr(), | 795 AsWeakPtr(), |
796 profile)); | 796 profile)); |
797 return; | 797 return; |
798 } | 798 } |
799 | 799 |
800 FinalizePrepareProfile(profile); | 800 FinalizePrepareProfile(profile); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 if (has_auth_cookies_) { | 894 if (has_auth_cookies_) { |
895 session_restore_strategy_ = OAuth2LoginManager::RESTORE_FROM_COOKIE_JAR; | 895 session_restore_strategy_ = OAuth2LoginManager::RESTORE_FROM_COOKIE_JAR; |
896 } else if (!user_context_.GetAuthCode().empty()) { | 896 } else if (!user_context_.GetAuthCode().empty()) { |
897 session_restore_strategy_ = OAuth2LoginManager::RESTORE_FROM_AUTH_CODE; | 897 session_restore_strategy_ = OAuth2LoginManager::RESTORE_FROM_AUTH_CODE; |
898 } else { | 898 } else { |
899 session_restore_strategy_ = | 899 session_restore_strategy_ = |
900 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN; | 900 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN; |
901 } | 901 } |
902 } | 902 } |
903 | 903 |
904 void UserSessionManager::RestoreAuthSessionImpl( | 904 void UserSessionManager::RestoreAuthSessionImpl(Profile* profile, |
905 Profile* profile, | 905 bool restore_from_auth_cookies) { |
906 bool restore_from_auth_cookies) { | 906 CHECK((authenticator_.get() && authenticator_->authentication_profile()) || |
907 CHECK((authenticator_.get() && authenticator_->authentication_context()) || | |
908 !restore_from_auth_cookies); | 907 !restore_from_auth_cookies); |
909 | 908 |
910 if (chrome::IsRunningInForcedAppMode() || | 909 if (chrome::IsRunningInForcedAppMode() || |
911 CommandLine::ForCurrentProcess()->HasSwitch( | 910 CommandLine::ForCurrentProcess()->HasSwitch( |
912 chromeos::switches::kDisableGaiaServices)) { | 911 chromeos::switches::kDisableGaiaServices)) { |
913 return; | 912 return; |
914 } | 913 } |
915 | 914 |
916 exit_after_session_restore_ = false; | 915 exit_after_session_restore_ = false; |
917 | 916 |
918 // Remove legacy OAuth1 token if we have one. If it's valid, we should already | 917 // Remove legacy OAuth1 token if we have one. If it's valid, we should already |
919 // have OAuth2 refresh token in OAuth2TokenService that could be used to | 918 // have OAuth2 refresh token in OAuth2TokenService that could be used to |
920 // retrieve all other tokens and user_context. | 919 // retrieve all other tokens and user_context. |
921 OAuth2LoginManager* login_manager = | 920 OAuth2LoginManager* login_manager = |
922 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(profile); | 921 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(profile); |
923 login_manager->AddObserver(this); | 922 login_manager->AddObserver(this); |
924 login_manager->RestoreSession( | 923 login_manager->RestoreSession( |
925 authenticator_.get() && authenticator_->authentication_context() | 924 authenticator_.get() && authenticator_->authentication_profile() |
926 ? authenticator_->authentication_context()->GetRequestContext() | 925 ? authenticator_->authentication_profile()->GetRequestContext() |
927 : NULL, | 926 : NULL, |
928 session_restore_strategy_, | 927 session_restore_strategy_, |
929 oauth2_refresh_token_, | 928 oauth2_refresh_token_, |
930 user_context_.GetAuthCode()); | 929 user_context_.GetAuthCode()); |
931 } | 930 } |
932 | 931 |
933 void UserSessionManager::InitRlzImpl(Profile* profile, bool disabled) { | 932 void UserSessionManager::InitRlzImpl(Profile* profile, bool disabled) { |
934 #if defined(ENABLE_RLZ) | 933 #if defined(ENABLE_RLZ) |
935 PrefService* local_state = g_browser_process->local_state(); | 934 PrefService* local_state = g_browser_process->local_state(); |
936 if (disabled) { | 935 if (disabled) { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 } | 1148 } |
1150 | 1149 |
1151 EasyUnlockKeyManager* UserSessionManager::GetEasyUnlockKeyManager() { | 1150 EasyUnlockKeyManager* UserSessionManager::GetEasyUnlockKeyManager() { |
1152 if (!easy_unlock_key_manager_) | 1151 if (!easy_unlock_key_manager_) |
1153 easy_unlock_key_manager_.reset(new EasyUnlockKeyManager); | 1152 easy_unlock_key_manager_.reset(new EasyUnlockKeyManager); |
1154 | 1153 |
1155 return easy_unlock_key_manager_.get(); | 1154 return easy_unlock_key_manager_.get(); |
1156 } | 1155 } |
1157 | 1156 |
1158 } // namespace chromeos | 1157 } // namespace chromeos |
OLD | NEW |