| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 NOTREACHED() << "Invalid notification type=" << type; | 161 NOTREACHED() << "Invalid notification type=" << type; |
| 162 break; | 162 break; |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 GoogleServiceAuthError ProfileOAuth2TokenService::GetAuthStatus() const { | 166 GoogleServiceAuthError ProfileOAuth2TokenService::GetAuthStatus() const { |
| 167 return last_auth_error_; | 167 return last_auth_error_; |
| 168 } | 168 } |
| 169 | 169 |
| 170 void ProfileOAuth2TokenService::RegisterCacheEntry( | 170 void ProfileOAuth2TokenService::RegisterCacheEntry( |
| 171 const std::string& client_id, | |
| 172 const std::string& refresh_token, | 171 const std::string& refresh_token, |
| 173 const ScopeSet& scopes, | 172 const ScopeSet& scopes, |
| 174 const std::string& access_token, | 173 const std::string& access_token, |
| 175 const base::Time& expiration_date) { | 174 const base::Time& expiration_date) { |
| 176 if (ShouldCacheForRefreshToken(TokenServiceFactory::GetForProfile(profile_), | 175 if (ShouldCacheForRefreshToken(TokenServiceFactory::GetForProfile(profile_), |
| 177 refresh_token)) { | 176 refresh_token)) { |
| 178 OAuth2TokenService::RegisterCacheEntry(client_id, | 177 OAuth2TokenService::RegisterCacheEntry(refresh_token, |
| 179 refresh_token, | |
| 180 scopes, | 178 scopes, |
| 181 access_token, | 179 access_token, |
| 182 expiration_date); | 180 expiration_date); |
| 183 } | 181 } |
| 184 } | 182 } |
| 185 | 183 |
| 186 bool ProfileOAuth2TokenService::ShouldCacheForRefreshToken( | 184 bool ProfileOAuth2TokenService::ShouldCacheForRefreshToken( |
| 187 TokenService *token_service, | 185 TokenService *token_service, |
| 188 const std::string& refresh_token) { | 186 const std::string& refresh_token) { |
| 189 if (!token_service || | 187 if (!token_service || |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 314 } |
| 317 } | 315 } |
| 318 | 316 |
| 319 if (!old_login_token.empty() && | 317 if (!old_login_token.empty() && |
| 320 refresh_tokens_.count(GetAccountId(profile_)) == 0) { | 318 refresh_tokens_.count(GetAccountId(profile_)) == 0) { |
| 321 UpdateCredentials(GetAccountId(profile_), old_login_token); | 319 UpdateCredentials(GetAccountId(profile_), old_login_token); |
| 322 } | 320 } |
| 323 | 321 |
| 324 FireRefreshTokensLoaded(); | 322 FireRefreshTokensLoaded(); |
| 325 } | 323 } |
| OLD | NEW |