Chromium Code Reviews| 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 login profile and the user's profile | 783 // the authentication states in the login profile and the user's profile |
|
Nikita (slow)
2014/10/20 12:30:27
nit: nit: login profile > auth context
| |
| 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_profile(), | 790 authenticator_->authentication_context(), |
| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(Profile* profile, | 904 void UserSessionManager::RestoreAuthSessionImpl(Profile* profile, |
| 905 bool restore_from_auth_cookies) { | 905 bool restore_from_auth_cookies) { |
|
Nikita (slow)
2014/10/20 12:30:27
nit: Please fix indentation (I known it's not your
| |
| 906 CHECK((authenticator_.get() && authenticator_->authentication_profile()) || | 906 CHECK((authenticator_.get() && authenticator_->authentication_context()) || |
| 907 !restore_from_auth_cookies); | 907 !restore_from_auth_cookies); |
| 908 | 908 |
| 909 if (chrome::IsRunningInForcedAppMode() || | 909 if (chrome::IsRunningInForcedAppMode() || |
| 910 CommandLine::ForCurrentProcess()->HasSwitch( | 910 CommandLine::ForCurrentProcess()->HasSwitch( |
| 911 chromeos::switches::kDisableGaiaServices)) { | 911 chromeos::switches::kDisableGaiaServices)) { |
| 912 return; | 912 return; |
| 913 } | 913 } |
| 914 | 914 |
| 915 exit_after_session_restore_ = false; | 915 exit_after_session_restore_ = false; |
| 916 | 916 |
| 917 // 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 |
| 918 // have OAuth2 refresh token in OAuth2TokenService that could be used to | 918 // have OAuth2 refresh token in OAuth2TokenService that could be used to |
| 919 // retrieve all other tokens and user_context. | 919 // retrieve all other tokens and user_context. |
| 920 OAuth2LoginManager* login_manager = | 920 OAuth2LoginManager* login_manager = |
| 921 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(profile); | 921 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(profile); |
| 922 login_manager->AddObserver(this); | 922 login_manager->AddObserver(this); |
| 923 login_manager->RestoreSession( | 923 login_manager->RestoreSession( |
| 924 authenticator_.get() && authenticator_->authentication_profile() | 924 authenticator_.get() && authenticator_->authentication_context() |
| 925 ? authenticator_->authentication_profile()->GetRequestContext() | 925 ? authenticator_->authentication_context()->GetRequestContext() |
| 926 : NULL, | 926 : NULL, |
| 927 session_restore_strategy_, | 927 session_restore_strategy_, |
| 928 oauth2_refresh_token_, | 928 oauth2_refresh_token_, |
| 929 user_context_.GetAuthCode()); | 929 user_context_.GetAuthCode()); |
| 930 } | 930 } |
| 931 | 931 |
| 932 void UserSessionManager::InitRlzImpl(Profile* profile, bool disabled) { | 932 void UserSessionManager::InitRlzImpl(Profile* profile, bool disabled) { |
| 933 #if defined(ENABLE_RLZ) | 933 #if defined(ENABLE_RLZ) |
| 934 PrefService* local_state = g_browser_process->local_state(); | 934 PrefService* local_state = g_browser_process->local_state(); |
| 935 if (disabled) { | 935 if (disabled) { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1148 } | 1148 } |
| 1149 | 1149 |
| 1150 EasyUnlockKeyManager* UserSessionManager::GetEasyUnlockKeyManager() { | 1150 EasyUnlockKeyManager* UserSessionManager::GetEasyUnlockKeyManager() { |
| 1151 if (!easy_unlock_key_manager_) | 1151 if (!easy_unlock_key_manager_) |
| 1152 easy_unlock_key_manager_.reset(new EasyUnlockKeyManager); | 1152 easy_unlock_key_manager_.reset(new EasyUnlockKeyManager); |
| 1153 | 1153 |
| 1154 return easy_unlock_key_manager_.get(); | 1154 return easy_unlock_key_manager_.get(); |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 } // namespace chromeos | 1157 } // namespace chromeos |
| OLD | NEW |