| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/autofill/core/browser/payments/payments_client.h" | 5 #include "components/autofill/core/browser/payments/payments_client.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 VLOG(2) << "Got data: " << data; | 451 VLOG(2) << "Got data: " << data; |
| 452 | 452 |
| 453 AutofillClient::PaymentsRpcResult result = AutofillClient::SUCCESS; | 453 AutofillClient::PaymentsRpcResult result = AutofillClient::SUCCESS; |
| 454 | 454 |
| 455 switch (response_code) { | 455 switch (response_code) { |
| 456 // Valid response. | 456 // Valid response. |
| 457 case net::HTTP_OK: { | 457 case net::HTTP_OK: { |
| 458 std::string error_code; | 458 std::string error_code; |
| 459 std::unique_ptr<base::Value> message_value = base::JSONReader::Read(data); | 459 std::unique_ptr<base::Value> message_value = base::JSONReader::Read(data); |
| 460 if (message_value.get() && | 460 if (message_value.get() && |
| 461 message_value->IsType(base::Value::TYPE_DICTIONARY)) { | 461 message_value->IsType(base::Value::Type::DICTIONARY)) { |
| 462 response_dict.reset( | 462 response_dict.reset( |
| 463 static_cast<base::DictionaryValue*>(message_value.release())); | 463 static_cast<base::DictionaryValue*>(message_value.release())); |
| 464 response_dict->GetString("error.code", &error_code); | 464 response_dict->GetString("error.code", &error_code); |
| 465 request_->ParseResponse(std::move(response_dict)); | 465 request_->ParseResponse(std::move(response_dict)); |
| 466 } | 466 } |
| 467 | 467 |
| 468 if (base::LowerCaseEqualsASCII(error_code, "internal")) | 468 if (base::LowerCaseEqualsASCII(error_code, "internal")) |
| 469 result = AutofillClient::TRY_AGAIN_FAILURE; | 469 result = AutofillClient::TRY_AGAIN_FAILURE; |
| 470 else if (!error_code.empty() || !request_->IsResponseComplete()) | 470 else if (!error_code.empty() || !request_->IsResponseComplete()) |
| 471 result = AutofillClient::PERMANENT_FAILURE; | 471 result = AutofillClient::PERMANENT_FAILURE; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 | 551 |
| 552 void PaymentsClient::SetOAuth2TokenAndStartRequest() { | 552 void PaymentsClient::SetOAuth2TokenAndStartRequest() { |
| 553 url_fetcher_->AddExtraRequestHeader(net::HttpRequestHeaders::kAuthorization + | 553 url_fetcher_->AddExtraRequestHeader(net::HttpRequestHeaders::kAuthorization + |
| 554 std::string(": Bearer ") + access_token_); | 554 std::string(": Bearer ") + access_token_); |
| 555 | 555 |
| 556 url_fetcher_->Start(); | 556 url_fetcher_->Start(); |
| 557 } | 557 } |
| 558 | 558 |
| 559 } // namespace payments | 559 } // namespace payments |
| 560 } // namespace autofill | 560 } // namespace autofill |
| OLD | NEW |