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/managed_mode/managed_user_refresh_token_fetcher.h" | 5 #include "chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 std::string auth_code; | 215 std::string auth_code; |
216 if (!dict->GetString(kCodeKey, &auth_code)) { | 216 if (!dict->GetString(kCodeKey, &auth_code)) { |
217 DispatchNetworkError(net::ERR_INVALID_RESPONSE); | 217 DispatchNetworkError(net::ERR_INVALID_RESPONSE); |
218 return; | 218 return; |
219 } | 219 } |
220 | 220 |
221 gaia::OAuthClientInfo client_info; | 221 gaia::OAuthClientInfo client_info; |
222 GaiaUrls* urls = GaiaUrls::GetInstance(); | 222 GaiaUrls* urls = GaiaUrls::GetInstance(); |
223 client_info.client_id = urls->oauth2_chrome_client_id(); | 223 client_info.client_id = urls->oauth2_chrome_client_id(); |
224 client_info.client_secret = urls->oauth2_chrome_client_secret(); | 224 client_info.client_secret = urls->oauth2_chrome_client_secret(); |
225 gaia_oauth_client_.reset( | 225 gaia_oauth_client_.reset(new gaia::GaiaOAuthClient(context_)); |
226 new gaia::GaiaOAuthClient(GaiaUrls::GetInstance()->oauth2_token_url(), | |
227 context_)); | |
228 gaia_oauth_client_->GetTokensFromAuthCode(client_info, auth_code, kNumRetries, | 226 gaia_oauth_client_->GetTokensFromAuthCode(client_info, auth_code, kNumRetries, |
229 this); | 227 this); |
230 } | 228 } |
231 | 229 |
232 void ManagedUserRefreshTokenFetcherImpl::OnGetTokensResponse( | 230 void ManagedUserRefreshTokenFetcherImpl::OnGetTokensResponse( |
233 const std::string& refresh_token, | 231 const std::string& refresh_token, |
234 const std::string& access_token, | 232 const std::string& access_token, |
235 int expires_in_seconds) { | 233 int expires_in_seconds) { |
236 // TODO(bauerb): It would be nice if we could pass the access token as well, | 234 // TODO(bauerb): It would be nice if we could pass the access token as well, |
237 // so we don't need to fetch another one immediately. | 235 // so we don't need to fetch another one immediately. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 // static | 274 // static |
277 scoped_ptr<ManagedUserRefreshTokenFetcher> | 275 scoped_ptr<ManagedUserRefreshTokenFetcher> |
278 ManagedUserRefreshTokenFetcher::Create(OAuth2TokenService* oauth2_token_service, | 276 ManagedUserRefreshTokenFetcher::Create(OAuth2TokenService* oauth2_token_service, |
279 URLRequestContextGetter* context) { | 277 URLRequestContextGetter* context) { |
280 scoped_ptr<ManagedUserRefreshTokenFetcher> fetcher( | 278 scoped_ptr<ManagedUserRefreshTokenFetcher> fetcher( |
281 new ManagedUserRefreshTokenFetcherImpl(oauth2_token_service, context)); | 279 new ManagedUserRefreshTokenFetcherImpl(oauth2_token_service, context)); |
282 return fetcher.Pass(); | 280 return fetcher.Pass(); |
283 } | 281 } |
284 | 282 |
285 ManagedUserRefreshTokenFetcher::~ManagedUserRefreshTokenFetcher() {} | 283 ManagedUserRefreshTokenFetcher::~ManagedUserRefreshTokenFetcher() {} |
OLD | NEW |