Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: trunk/src/components/autofill/content/browser/wallet/wallet_client.cc

Issue 474483002: Revert 289312 "Move StringToUpperASCII and LowerCaseEqualsASCII ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 base::TrimWhitespaceASCII(error_type, base::TRIM_ALL, &trimmed); 68 base::TrimWhitespaceASCII(error_type, base::TRIM_ALL, &trimmed);
69 if (base::LowerCaseEqualsASCII(trimmed, "buyer_account_error")) 69 if (LowerCaseEqualsASCII(trimmed, "buyer_account_error"))
70 return WalletClient::BUYER_ACCOUNT_ERROR; 70 return WalletClient::BUYER_ACCOUNT_ERROR;
71 if (base::LowerCaseEqualsASCII(trimmed, "unsupported_merchant")) 71 if (LowerCaseEqualsASCII(trimmed, "unsupported_merchant"))
72 return WalletClient::UNSUPPORTED_MERCHANT; 72 return WalletClient::UNSUPPORTED_MERCHANT;
73 if (base::LowerCaseEqualsASCII(trimmed, "internal_error")) 73 if (LowerCaseEqualsASCII(trimmed, "internal_error"))
74 return WalletClient::INTERNAL_ERROR; 74 return WalletClient::INTERNAL_ERROR;
75 if (base::LowerCaseEqualsASCII(trimmed, "invalid_params")) 75 if (LowerCaseEqualsASCII(trimmed, "invalid_params"))
76 return WalletClient::INVALID_PARAMS; 76 return WalletClient::INVALID_PARAMS;
77 if (base::LowerCaseEqualsASCII(trimmed, "service_unavailable")) 77 if (LowerCaseEqualsASCII(trimmed, "service_unavailable"))
78 return WalletClient::SERVICE_UNAVAILABLE; 78 return WalletClient::SERVICE_UNAVAILABLE;
79 if (base::LowerCaseEqualsASCII(trimmed, "unsupported_api_version")) 79 if (LowerCaseEqualsASCII(trimmed, "unsupported_api_version"))
80 return WalletClient::UNSUPPORTED_API_VERSION; 80 return WalletClient::UNSUPPORTED_API_VERSION;
81 if (base::LowerCaseEqualsASCII(trimmed, "unsupported_user_agent")) 81 if (LowerCaseEqualsASCII(trimmed, "unsupported_user_agent"))
82 return WalletClient::UNSUPPORTED_USER_AGENT_OR_API_KEY; 82 return WalletClient::UNSUPPORTED_USER_AGENT_OR_API_KEY;
83 if (base::LowerCaseEqualsASCII(trimmed, "spending_limit_exceeded")) 83 if (LowerCaseEqualsASCII(trimmed, "spending_limit_exceeded"))
84 return WalletClient::SPENDING_LIMIT_EXCEEDED; 84 return WalletClient::SPENDING_LIMIT_EXCEEDED;
85 85
86 DVLOG(1) << "Unknown wallet error string: \"" << error_type << '"'; 86 DVLOG(1) << "Unknown wallet error string: \"" << error_type << '"';
87 return WalletClient::UNKNOWN_ERROR; 87 return WalletClient::UNKNOWN_ERROR;
88 } 88 }
89 89
90 // Get the more specific WalletClient::ErrorType when the error is 90 // Get the more specific WalletClient::ErrorType when the error is
91 // |BUYER_ACCOUNT_ERROR|. 91 // |BUYER_ACCOUNT_ERROR|.
92 WalletClient::ErrorType BuyerErrorStringToErrorType( 92 WalletClient::ErrorType BuyerErrorStringToErrorType(
93 const std::string& message_type_for_buyer) { 93 const std::string& message_type_for_buyer) {
94 std::string trimmed; 94 std::string trimmed;
95 base::TrimWhitespaceASCII(message_type_for_buyer, base::TRIM_ALL, &trimmed); 95 base::TrimWhitespaceASCII(message_type_for_buyer, base::TRIM_ALL, &trimmed);
96 if (base::LowerCaseEqualsASCII(trimmed, "bla_country_not_supported")) 96 if (LowerCaseEqualsASCII(trimmed, "bla_country_not_supported"))
97 return WalletClient::BUYER_LEGAL_ADDRESS_NOT_SUPPORTED; 97 return WalletClient::BUYER_LEGAL_ADDRESS_NOT_SUPPORTED;
98 if (base::LowerCaseEqualsASCII(trimmed, "buyer_kyc_error")) 98 if (LowerCaseEqualsASCII(trimmed, "buyer_kyc_error"))
99 return WalletClient::UNVERIFIED_KNOW_YOUR_CUSTOMER_STATUS; 99 return WalletClient::UNVERIFIED_KNOW_YOUR_CUSTOMER_STATUS;
100 100
101 return WalletClient::BUYER_ACCOUNT_ERROR; 101 return WalletClient::BUYER_ACCOUNT_ERROR;
102 } 102 }
103 103
104 // Gets and parses required actions from a SaveToWallet response. Returns 104 // Gets and parses required actions from a SaveToWallet response. Returns
105 // false if any unknown required actions are seen and true otherwise. 105 // false if any unknown required actions are seen and true otherwise.
106 void GetRequiredActionsForSaveToWallet( 106 void GetRequiredActionsForSaveToWallet(
107 const base::DictionaryValue& dict, 107 const base::DictionaryValue& dict,
108 std::vector<RequiredAction>* required_actions) { 108 std::vector<RequiredAction>* required_actions) {
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 case ACCEPT_LEGAL_DOCUMENTS: 635 case ACCEPT_LEGAL_DOCUMENTS:
636 delegate_->OnDidAcceptLegalDocuments(); 636 delegate_->OnDidAcceptLegalDocuments();
637 break; 637 break;
638 638
639 case AUTHENTICATE_INSTRUMENT: { 639 case AUTHENTICATE_INSTRUMENT: {
640 std::string auth_result; 640 std::string auth_result;
641 if (response_dict->GetString(kAuthResultKey, &auth_result)) { 641 if (response_dict->GetString(kAuthResultKey, &auth_result)) {
642 std::string trimmed; 642 std::string trimmed;
643 base::TrimWhitespaceASCII(auth_result, base::TRIM_ALL, &trimmed); 643 base::TrimWhitespaceASCII(auth_result, base::TRIM_ALL, &trimmed);
644 delegate_->OnDidAuthenticateInstrument( 644 delegate_->OnDidAuthenticateInstrument(
645 base::LowerCaseEqualsASCII(trimmed, "success")); 645 LowerCaseEqualsASCII(trimmed, "success"));
646 } else { 646 } else {
647 HandleMalformedResponse(type, scoped_request.get()); 647 HandleMalformedResponse(type, scoped_request.get());
648 } 648 }
649 break; 649 break;
650 } 650 }
651 651
652 case GET_FULL_WALLET: { 652 case GET_FULL_WALLET: {
653 scoped_ptr<FullWallet> full_wallet( 653 scoped_ptr<FullWallet> full_wallet(
654 FullWallet::CreateFullWallet(*response_dict)); 654 FullWallet::CreateFullWallet(*response_dict));
655 if (full_wallet) { 655 if (full_wallet) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 NOTREACHED(); 792 NOTREACHED();
793 return AutofillMetrics::UNKNOWN_API_CALL; 793 return AutofillMetrics::UNKNOWN_API_CALL;
794 } 794 }
795 795
796 NOTREACHED(); 796 NOTREACHED();
797 return AutofillMetrics::UNKNOWN_API_CALL; 797 return AutofillMetrics::UNKNOWN_API_CALL;
798 } 798 }
799 799
800 } // namespace wallet 800 } // namespace wallet
801 } // namespace autofill 801 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698