| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/signin/profile_oauth2_token_service.h" | 5 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 NOTREACHED() << "Invalid notification type=" << type; | 170 NOTREACHED() << "Invalid notification type=" << type; |
| 171 break; | 171 break; |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 GoogleServiceAuthError ProfileOAuth2TokenService::GetAuthStatus() const { | 175 GoogleServiceAuthError ProfileOAuth2TokenService::GetAuthStatus() const { |
| 176 return last_auth_error_; | 176 return last_auth_error_; |
| 177 } | 177 } |
| 178 | 178 |
| 179 void ProfileOAuth2TokenService::RegisterCacheEntry( | 179 void ProfileOAuth2TokenService::RegisterCacheEntry( |
| 180 const std::string& client_id, |
| 180 const std::string& refresh_token, | 181 const std::string& refresh_token, |
| 181 const ScopeSet& scopes, | 182 const ScopeSet& scopes, |
| 182 const std::string& access_token, | 183 const std::string& access_token, |
| 183 const base::Time& expiration_date) { | 184 const base::Time& expiration_date) { |
| 184 if (ShouldCacheForRefreshToken(TokenServiceFactory::GetForProfile(profile_), | 185 if (ShouldCacheForRefreshToken(TokenServiceFactory::GetForProfile(profile_), |
| 185 refresh_token)) { | 186 refresh_token)) { |
| 186 OAuth2TokenService::RegisterCacheEntry(refresh_token, | 187 OAuth2TokenService::RegisterCacheEntry(client_id, |
| 188 refresh_token, |
| 187 scopes, | 189 scopes, |
| 188 access_token, | 190 access_token, |
| 189 expiration_date); | 191 expiration_date); |
| 190 } | 192 } |
| 191 } | 193 } |
| 192 | 194 |
| 193 bool ProfileOAuth2TokenService::ShouldCacheForRefreshToken( | 195 bool ProfileOAuth2TokenService::ShouldCacheForRefreshToken( |
| 194 TokenService *token_service, | 196 TokenService *token_service, |
| 195 const std::string& refresh_token) { | 197 const std::string& refresh_token) { |
| 196 if (!token_service || | 198 if (!token_service || |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 } | 325 } |
| 324 } | 326 } |
| 325 | 327 |
| 326 if (!old_login_token.empty() && | 328 if (!old_login_token.empty() && |
| 327 refresh_tokens_.count(GetAccountId(profile_)) == 0) { | 329 refresh_tokens_.count(GetAccountId(profile_)) == 0) { |
| 328 UpdateCredentials(GetAccountId(profile_), old_login_token); | 330 UpdateCredentials(GetAccountId(profile_), old_login_token); |
| 329 } | 331 } |
| 330 | 332 |
| 331 FireRefreshTokensLoaded(); | 333 FireRefreshTokensLoaded(); |
| 332 } | 334 } |
| OLD | NEW |