| 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 "google_apis/gaia/gaia_auth_fetcher.h" | 5 #include "google_apis/gaia/gaia_auth_fetcher.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // both of which must exist. If the |refresh_token| is non-NULL, then it also | 46 // both of which must exist. If the |refresh_token| is non-NULL, then it also |
| 47 // must exist and is extraced; if it's NULL, then no extraction is attempted. | 47 // must exist and is extraced; if it's NULL, then no extraction is attempted. |
| 48 bool ExtractOAuth2TokenPairResponse(const std::string& data, | 48 bool ExtractOAuth2TokenPairResponse(const std::string& data, |
| 49 std::string* refresh_token, | 49 std::string* refresh_token, |
| 50 std::string* access_token, | 50 std::string* access_token, |
| 51 int* expires_in_secs) { | 51 int* expires_in_secs) { |
| 52 DCHECK(access_token); | 52 DCHECK(access_token); |
| 53 DCHECK(expires_in_secs); | 53 DCHECK(expires_in_secs); |
| 54 | 54 |
| 55 std::unique_ptr<base::Value> value = base::JSONReader::Read(data); | 55 std::unique_ptr<base::Value> value = base::JSONReader::Read(data); |
| 56 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) | 56 if (!value.get() || value->GetType() != base::Value::Type::DICTIONARY) |
| 57 return false; | 57 return false; |
| 58 | 58 |
| 59 base::DictionaryValue* dict = | 59 base::DictionaryValue* dict = |
| 60 static_cast<base::DictionaryValue*>(value.get()); | 60 static_cast<base::DictionaryValue*>(value.get()); |
| 61 | 61 |
| 62 if (!dict->GetStringWithoutPathExpansion("access_token", access_token) || | 62 if (!dict->GetStringWithoutPathExpansion("access_token", access_token) || |
| 63 !dict->GetIntegerWithoutPathExpansion("expires_in", expires_in_secs)) { | 63 !dict->GetIntegerWithoutPathExpansion("expires_in", expires_in_secs)) { |
| 64 return false; | 64 return false; |
| 65 } | 65 } |
| 66 | 66 |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 } | 474 } |
| 475 return false; | 475 return false; |
| 476 } | 476 } |
| 477 | 477 |
| 478 // static | 478 // static |
| 479 bool GaiaAuthFetcher::ParseListIdpSessionsResponse(const std::string& data, | 479 bool GaiaAuthFetcher::ParseListIdpSessionsResponse(const std::string& data, |
| 480 std::string* login_hint) { | 480 std::string* login_hint) { |
| 481 DCHECK(login_hint); | 481 DCHECK(login_hint); |
| 482 | 482 |
| 483 std::unique_ptr<base::Value> value = base::JSONReader::Read(data); | 483 std::unique_ptr<base::Value> value = base::JSONReader::Read(data); |
| 484 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) | 484 if (!value.get() || value->GetType() != base::Value::Type::DICTIONARY) |
| 485 return false; | 485 return false; |
| 486 | 486 |
| 487 base::DictionaryValue* dict = | 487 base::DictionaryValue* dict = |
| 488 static_cast<base::DictionaryValue*>(value.get()); | 488 static_cast<base::DictionaryValue*>(value.get()); |
| 489 | 489 |
| 490 base::ListValue* sessionsList; | 490 base::ListValue* sessionsList; |
| 491 if (!dict->GetList("sessions", &sessionsList)) | 491 if (!dict->GetList("sessions", &sessionsList)) |
| 492 return false; | 492 return false; |
| 493 | 493 |
| 494 // Find the first login_hint present in any session. | 494 // Find the first login_hint present in any session. |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 return alleged_error.find(kSecondFactor) != | 1011 return alleged_error.find(kSecondFactor) != |
| 1012 std::string::npos; | 1012 std::string::npos; |
| 1013 } | 1013 } |
| 1014 | 1014 |
| 1015 // static | 1015 // static |
| 1016 bool GaiaAuthFetcher::IsWebLoginRequiredSuccess( | 1016 bool GaiaAuthFetcher::IsWebLoginRequiredSuccess( |
| 1017 const std::string& alleged_error) { | 1017 const std::string& alleged_error) { |
| 1018 return alleged_error.find(kWebLoginRequired) != | 1018 return alleged_error.find(kWebLoginRequired) != |
| 1019 std::string::npos; | 1019 std::string::npos; |
| 1020 } | 1020 } |
| OLD | NEW |