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