| 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 "components/autofill/content/browser/wallet/wallet_client.h" | 5 #include "components/autofill/content/browser/wallet/wallet_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 return "RELOGIN"; | 58 return "RELOGIN"; |
| 59 case WalletClient::VERIFY_CVC: | 59 case WalletClient::VERIFY_CVC: |
| 60 return "VERIFY_CVC"; | 60 return "VERIFY_CVC"; |
| 61 } | 61 } |
| 62 NOTREACHED(); | 62 NOTREACHED(); |
| 63 return "NOT_POSSIBLE"; | 63 return "NOT_POSSIBLE"; |
| 64 } | 64 } |
| 65 | 65 |
| 66 WalletClient::ErrorType StringToErrorType(const std::string& error_type) { | 66 WalletClient::ErrorType StringToErrorType(const std::string& error_type) { |
| 67 std::string trimmed; | 67 std::string trimmed; |
| 68 TrimWhitespaceASCII(error_type, | 68 base::TrimWhitespaceASCII(error_type, base::TRIM_ALL, &trimmed); |
| 69 TRIM_ALL, | |
| 70 &trimmed); | |
| 71 if (LowerCaseEqualsASCII(trimmed, "buyer_account_error")) | 69 if (LowerCaseEqualsASCII(trimmed, "buyer_account_error")) |
| 72 return WalletClient::BUYER_ACCOUNT_ERROR; | 70 return WalletClient::BUYER_ACCOUNT_ERROR; |
| 73 if (LowerCaseEqualsASCII(trimmed, "unsupported_merchant")) | 71 if (LowerCaseEqualsASCII(trimmed, "unsupported_merchant")) |
| 74 return WalletClient::UNSUPPORTED_MERCHANT; | 72 return WalletClient::UNSUPPORTED_MERCHANT; |
| 75 if (LowerCaseEqualsASCII(trimmed, "internal_error")) | 73 if (LowerCaseEqualsASCII(trimmed, "internal_error")) |
| 76 return WalletClient::INTERNAL_ERROR; | 74 return WalletClient::INTERNAL_ERROR; |
| 77 if (LowerCaseEqualsASCII(trimmed, "invalid_params")) | 75 if (LowerCaseEqualsASCII(trimmed, "invalid_params")) |
| 78 return WalletClient::INVALID_PARAMS; | 76 return WalletClient::INVALID_PARAMS; |
| 79 if (LowerCaseEqualsASCII(trimmed, "service_unavailable")) | 77 if (LowerCaseEqualsASCII(trimmed, "service_unavailable")) |
| 80 return WalletClient::SERVICE_UNAVAILABLE; | 78 return WalletClient::SERVICE_UNAVAILABLE; |
| 81 if (LowerCaseEqualsASCII(trimmed, "unsupported_api_version")) | 79 if (LowerCaseEqualsASCII(trimmed, "unsupported_api_version")) |
| 82 return WalletClient::UNSUPPORTED_API_VERSION; | 80 return WalletClient::UNSUPPORTED_API_VERSION; |
| 83 if (LowerCaseEqualsASCII(trimmed, "unsupported_user_agent")) | 81 if (LowerCaseEqualsASCII(trimmed, "unsupported_user_agent")) |
| 84 return WalletClient::UNSUPPORTED_USER_AGENT_OR_API_KEY; | 82 return WalletClient::UNSUPPORTED_USER_AGENT_OR_API_KEY; |
| 85 | 83 |
| 86 DVLOG(1) << "Unknown wallet error string: \"" << error_type << '"'; | 84 DVLOG(1) << "Unknown wallet error string: \"" << error_type << '"'; |
| 87 return WalletClient::UNKNOWN_ERROR; | 85 return WalletClient::UNKNOWN_ERROR; |
| 88 } | 86 } |
| 89 | 87 |
| 90 // Get the more specific WalletClient::ErrorType when the error is | 88 // Get the more specific WalletClient::ErrorType when the error is |
| 91 // |BUYER_ACCOUNT_ERROR|. | 89 // |BUYER_ACCOUNT_ERROR|. |
| 92 WalletClient::ErrorType BuyerErrorStringToErrorType( | 90 WalletClient::ErrorType BuyerErrorStringToErrorType( |
| 93 const std::string& message_type_for_buyer) { | 91 const std::string& message_type_for_buyer) { |
| 94 std::string trimmed; | 92 std::string trimmed; |
| 95 TrimWhitespaceASCII(message_type_for_buyer, | 93 base::TrimWhitespaceASCII(message_type_for_buyer, base::TRIM_ALL, &trimmed); |
| 96 TRIM_ALL, | |
| 97 &trimmed); | |
| 98 if (LowerCaseEqualsASCII(trimmed, "bla_country_not_supported")) | 94 if (LowerCaseEqualsASCII(trimmed, "bla_country_not_supported")) |
| 99 return WalletClient::BUYER_LEGAL_ADDRESS_NOT_SUPPORTED; | 95 return WalletClient::BUYER_LEGAL_ADDRESS_NOT_SUPPORTED; |
| 100 if (LowerCaseEqualsASCII(trimmed, "buyer_kyc_error")) | 96 if (LowerCaseEqualsASCII(trimmed, "buyer_kyc_error")) |
| 101 return WalletClient::UNVERIFIED_KNOW_YOUR_CUSTOMER_STATUS; | 97 return WalletClient::UNVERIFIED_KNOW_YOUR_CUSTOMER_STATUS; |
| 102 | 98 |
| 103 return WalletClient::BUYER_ACCOUNT_ERROR; | 99 return WalletClient::BUYER_ACCOUNT_ERROR; |
| 104 } | 100 } |
| 105 | 101 |
| 106 // Gets and parses required actions from a SaveToWallet response. Returns | 102 // Gets and parses required actions from a SaveToWallet response. Returns |
| 107 // false if any unknown required actions are seen and true otherwise. | 103 // false if any unknown required actions are seen and true otherwise. |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 | 621 |
| 626 switch (type) { | 622 switch (type) { |
| 627 case ACCEPT_LEGAL_DOCUMENTS: | 623 case ACCEPT_LEGAL_DOCUMENTS: |
| 628 delegate_->OnDidAcceptLegalDocuments(); | 624 delegate_->OnDidAcceptLegalDocuments(); |
| 629 break; | 625 break; |
| 630 | 626 |
| 631 case AUTHENTICATE_INSTRUMENT: { | 627 case AUTHENTICATE_INSTRUMENT: { |
| 632 std::string auth_result; | 628 std::string auth_result; |
| 633 if (response_dict->GetString(kAuthResultKey, &auth_result)) { | 629 if (response_dict->GetString(kAuthResultKey, &auth_result)) { |
| 634 std::string trimmed; | 630 std::string trimmed; |
| 635 TrimWhitespaceASCII(auth_result, | 631 base::TrimWhitespaceASCII(auth_result, base::TRIM_ALL, &trimmed); |
| 636 TRIM_ALL, | |
| 637 &trimmed); | |
| 638 delegate_->OnDidAuthenticateInstrument( | 632 delegate_->OnDidAuthenticateInstrument( |
| 639 LowerCaseEqualsASCII(trimmed, "success")); | 633 LowerCaseEqualsASCII(trimmed, "success")); |
| 640 } else { | 634 } else { |
| 641 HandleMalformedResponse(type, scoped_request.get()); | 635 HandleMalformedResponse(type, scoped_request.get()); |
| 642 } | 636 } |
| 643 break; | 637 break; |
| 644 } | 638 } |
| 645 | 639 |
| 646 case GET_FULL_WALLET: { | 640 case GET_FULL_WALLET: { |
| 647 scoped_ptr<FullWallet> full_wallet( | 641 scoped_ptr<FullWallet> full_wallet( |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 NOTREACHED(); | 777 NOTREACHED(); |
| 784 return AutofillMetrics::UNKNOWN_API_CALL; | 778 return AutofillMetrics::UNKNOWN_API_CALL; |
| 785 } | 779 } |
| 786 | 780 |
| 787 NOTREACHED(); | 781 NOTREACHED(); |
| 788 return AutofillMetrics::UNKNOWN_API_CALL; | 782 return AutofillMetrics::UNKNOWN_API_CALL; |
| 789 } | 783 } |
| 790 | 784 |
| 791 } // namespace wallet | 785 } // namespace wallet |
| 792 } // namespace autofill | 786 } // namespace autofill |
| OLD | NEW |