OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/oauth2_login_manager.h" | 5 #include "chrome/browser/chromeos/login/oauth2_login_manager.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chromeos/login/user_manager.h" | 10 #include "chrome/browser/chromeos/login/user_manager.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 142 } |
143 | 143 |
144 void OAuth2LoginManager::Observe( | 144 void OAuth2LoginManager::Observe( |
145 int type, | 145 int type, |
146 const content::NotificationSource& source, | 146 const content::NotificationSource& source, |
147 const content::NotificationDetails& details) { | 147 const content::NotificationDetails& details) { |
148 TokenService* token_service = | 148 TokenService* token_service = |
149 TokenServiceFactory::GetForProfile(user_profile_); | 149 TokenServiceFactory::GetForProfile(user_profile_); |
150 switch (type) { | 150 switch (type) { |
151 case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: { | 151 case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: { |
152 refresh_token_ = token_service->GetOAuth2LoginRefreshToken(); | 152 // Don't overwrite the |refresh_token_| if it has already been fetched |
153 // TODO(zelidrag): Figure out why just getting GaiaConstants::kGaiaService | 153 // by the |oauth2_policy_fetcher_|. |
154 // token does not do the trick here. | 154 if (restore_from_auth_cookies_ && |
| 155 !token_service->GetOAuth2LoginRefreshToken().empty()) { |
| 156 refresh_token_ = token_service->GetOAuth2LoginRefreshToken(); |
| 157 } |
155 RestoreSessionCookies(); | 158 RestoreSessionCookies(); |
156 break; | 159 break; |
157 } | 160 } |
158 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { | 161 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { |
159 // This path should kick on only when we mint a new OAuth2 refresh | 162 // This path should kick on only when we mint a new OAuth2 refresh |
160 // token for user cookies. Otherwise, wait for all tokens to load above. | 163 // token for user cookies. Otherwise, wait for all tokens to load above. |
161 if (!restore_from_auth_cookies_) | 164 if (!restore_from_auth_cookies_) |
162 return; | 165 return; |
163 | 166 |
164 TokenService::TokenAvailableDetails* token_details = | 167 TokenService::TokenAvailableDetails* token_details = |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 253 } |
251 | 254 |
252 void OAuth2LoginManager::StartTokenService( | 255 void OAuth2LoginManager::StartTokenService( |
253 const GaiaAuthConsumer::ClientLoginResult& gaia_credentials) { | 256 const GaiaAuthConsumer::ClientLoginResult& gaia_credentials) { |
254 TokenService* token_service = SetupTokenService(); | 257 TokenService* token_service = SetupTokenService(); |
255 token_service->UpdateCredentials(gaia_credentials); | 258 token_service->UpdateCredentials(gaia_credentials); |
256 CompleteAuthentication(); | 259 CompleteAuthentication(); |
257 } | 260 } |
258 | 261 |
259 } // namespace chromeos | 262 } // namespace chromeos |
OLD | NEW |