OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/net/gaia/gaia_auth_fetcher.h" | 5 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 return false; | 400 return false; |
401 } | 401 } |
402 | 402 |
403 // static | 403 // static |
404 bool GaiaAuthFetcher::ParseOAuth2TokenPairResponse(const std::string& data, | 404 bool GaiaAuthFetcher::ParseOAuth2TokenPairResponse(const std::string& data, |
405 std::string* refresh_token, | 405 std::string* refresh_token, |
406 std::string* access_token, | 406 std::string* access_token, |
407 int* expires_in_secs) { | 407 int* expires_in_secs) { |
408 DCHECK(refresh_token); | 408 DCHECK(refresh_token); |
409 DCHECK(access_token); | 409 DCHECK(access_token); |
410 base::JSONReader reader; | 410 scoped_ptr<base::Value> value(base::JSONReader::Read(data)); |
411 scoped_ptr<base::Value> value(reader.Read(data, false)); | |
412 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) | 411 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) |
413 return false; | 412 return false; |
414 | 413 |
415 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); | 414 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); |
416 std::string rt; | 415 std::string rt; |
417 std::string at; | 416 std::string at; |
418 int exp; | 417 int exp; |
419 | 418 |
420 if (!dict->GetStringWithoutPathExpansion(kOAuth2RefreshTokenKey, &rt) || | 419 if (!dict->GetStringWithoutPathExpansion(kOAuth2RefreshTokenKey, &rt) || |
421 !dict->GetStringWithoutPathExpansion(kOAuth2AccessTokenKey, &at) || | 420 !dict->GetStringWithoutPathExpansion(kOAuth2AccessTokenKey, &at) || |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 NOTREACHED(); | 885 NOTREACHED(); |
887 } | 886 } |
888 } | 887 } |
889 | 888 |
890 // static | 889 // static |
891 bool GaiaAuthFetcher::IsSecondFactorSuccess( | 890 bool GaiaAuthFetcher::IsSecondFactorSuccess( |
892 const std::string& alleged_error) { | 891 const std::string& alleged_error) { |
893 return alleged_error.find(kSecondFactor) != | 892 return alleged_error.find(kSecondFactor) != |
894 std::string::npos; | 893 std::string::npos; |
895 } | 894 } |
OLD | NEW |