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/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 DLOG(WARNING) << "HTTP error " << response_code; | 197 DLOG(WARNING) << "HTTP error " << response_code; |
198 DispatchGoogleServiceAuthError( | 198 DispatchGoogleServiceAuthError( |
199 GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED), | 199 GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED), |
200 std::string()); | 200 std::string()); |
201 return; | 201 return; |
202 } | 202 } |
203 | 203 |
204 std::string response_body; | 204 std::string response_body; |
205 source->GetResponseAsString(&response_body); | 205 source->GetResponseAsString(&response_body); |
206 scoped_ptr<base::Value> value(base::JSONReader::Read(response_body)); | 206 scoped_ptr<base::Value> value(base::JSONReader::Read(response_body)); |
207 DictionaryValue* dict = NULL; | 207 base::DictionaryValue* dict = NULL; |
208 if (!value.get() || !value->GetAsDictionary(&dict)) { | 208 if (!value.get() || !value->GetAsDictionary(&dict)) { |
209 DispatchNetworkError(net::ERR_INVALID_RESPONSE); | 209 DispatchNetworkError(net::ERR_INVALID_RESPONSE); |
210 return; | 210 return; |
211 } | 211 } |
212 std::string auth_code; | 212 std::string auth_code; |
213 if (!dict->GetString(kCodeKey, &auth_code)) { | 213 if (!dict->GetString(kCodeKey, &auth_code)) { |
214 DispatchNetworkError(net::ERR_INVALID_RESPONSE); | 214 DispatchNetworkError(net::ERR_INVALID_RESPONSE); |
215 return; | 215 return; |
216 } | 216 } |
217 | 217 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 ManagedUserRefreshTokenFetcher::Create(OAuth2TokenService* oauth2_token_service, | 273 ManagedUserRefreshTokenFetcher::Create(OAuth2TokenService* oauth2_token_service, |
274 const std::string& account_id, | 274 const std::string& account_id, |
275 URLRequestContextGetter* context) { | 275 URLRequestContextGetter* context) { |
276 scoped_ptr<ManagedUserRefreshTokenFetcher> fetcher( | 276 scoped_ptr<ManagedUserRefreshTokenFetcher> fetcher( |
277 new ManagedUserRefreshTokenFetcherImpl(oauth2_token_service, account_id, | 277 new ManagedUserRefreshTokenFetcherImpl(oauth2_token_service, account_id, |
278 context)); | 278 context)); |
279 return fetcher.Pass(); | 279 return fetcher.Pass(); |
280 } | 280 } |
281 | 281 |
282 ManagedUserRefreshTokenFetcher::~ManagedUserRefreshTokenFetcher() {} | 282 ManagedUserRefreshTokenFetcher::~ManagedUserRefreshTokenFetcher() {} |
OLD | NEW |