| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 GoogleServiceAuthError ProfileOAuth2TokenService::GetAuthStatus() const { | 185 GoogleServiceAuthError ProfileOAuth2TokenService::GetAuthStatus() const { |
| 186 return last_auth_error_; | 186 return last_auth_error_; |
| 187 } | 187 } |
| 188 | 188 |
| 189 net::URLRequestContextGetter* ProfileOAuth2TokenService::GetRequestContext() { | 189 net::URLRequestContextGetter* ProfileOAuth2TokenService::GetRequestContext() { |
| 190 return profile_->GetRequestContext(); | 190 return profile_->GetRequestContext(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void ProfileOAuth2TokenService::RegisterCacheEntry( | 193 void ProfileOAuth2TokenService::RegisterCacheEntry( |
| 194 const std::string& request_origin, |
| 195 const std::string& client_id, |
| 194 const std::string& refresh_token, | 196 const std::string& refresh_token, |
| 195 const ScopeSet& scopes, | 197 const ScopeSet& scopes, |
| 196 const std::string& access_token, | 198 const std::string& access_token, |
| 197 const base::Time& expiration_date) { | 199 const base::Time& expiration_date) { |
| 198 if (ShouldCacheForRefreshToken(TokenServiceFactory::GetForProfile(profile_), | 200 if (ShouldCacheForRefreshToken(TokenServiceFactory::GetForProfile(profile_), |
| 199 refresh_token)) { | 201 refresh_token)) { |
| 200 OAuth2TokenService::RegisterCacheEntry(refresh_token, | 202 OAuth2TokenService::RegisterCacheEntry(request_origin, |
| 203 client_id, |
| 204 refresh_token, |
| 201 scopes, | 205 scopes, |
| 202 access_token, | 206 access_token, |
| 203 expiration_date); | 207 expiration_date); |
| 204 } | 208 } |
| 205 } | 209 } |
| 206 | 210 |
| 207 bool ProfileOAuth2TokenService::ShouldCacheForRefreshToken( | 211 bool ProfileOAuth2TokenService::ShouldCacheForRefreshToken( |
| 208 TokenService *token_service, | 212 TokenService *token_service, |
| 209 const std::string& refresh_token) { | 213 const std::string& refresh_token) { |
| 210 if (!token_service || | 214 if (!token_service || |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 } | 343 } |
| 340 } | 344 } |
| 341 | 345 |
| 342 if (!old_login_token.empty() && | 346 if (!old_login_token.empty() && |
| 343 refresh_tokens_.count(GetAccountId(profile_)) == 0) { | 347 refresh_tokens_.count(GetAccountId(profile_)) == 0) { |
| 344 UpdateCredentials(GetAccountId(profile_), old_login_token); | 348 UpdateCredentials(GetAccountId(profile_), old_login_token); |
| 345 } | 349 } |
| 346 | 350 |
| 347 FireRefreshTokensLoaded(); | 351 FireRefreshTokensLoaded(); |
| 348 } | 352 } |
| OLD | NEW |