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