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

Unified Diff: components/payments/core/payment_request_data_util.cc

Issue 2963163002: [Payment Request] Displays accepted card types (credit, debit, etc) in iOS (Closed)
Patch Set: Addressed comment Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/payments/core/payment_request_data_util.h ('k') | ios/chrome/browser/payments/payment_request.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/payments/core/payment_request_data_util.cc
diff --git a/components/payments/core/payment_request_data_util.cc b/components/payments/core/payment_request_data_util.cc
index 8a9585f7c2fc03d1e1870814ed9f7e3019150c9b..bee795f54c8f21157cc6b54dbee0bca7f4f40c40 100644
--- a/components/payments/core/payment_request_data_util.cc
+++ b/components/payments/core/payment_request_data_util.cc
@@ -4,6 +4,7 @@
#include "components/payments/core/payment_request_data_util.h"
+#include "base/stl_util.h"
#include "base/strings/string16.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -11,7 +12,6 @@
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_data_util.h"
#include "components/autofill/core/browser/autofill_profile.h"
-#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/validation.h"
@@ -154,6 +154,36 @@ void ParseBasicCardSupportedNetworks(
}
}
+void ParseSupportedCardTypes(
+ const std::vector<PaymentMethodData>& method_data,
+ std::set<autofill::CreditCard::CardType>* out_supported_card_types_set) {
+ DCHECK(out_supported_card_types_set->empty());
+
+ for (const PaymentMethodData& method_data_entry : method_data) {
+ // Ignore |supported_types| if |supported_methods| does not contain
+ // "basic_card".
+ if (!base::ContainsValue(method_data_entry.supported_methods, "basic-card"))
+ continue;
+
+ for (const autofill::CreditCard::CardType& card_type :
+ method_data_entry.supported_types) {
+ out_supported_card_types_set->insert(card_type);
+ }
+ }
+
+ // Omitting the card types means all 3 card types are supported.
+ if (out_supported_card_types_set->empty()) {
+ out_supported_card_types_set->insert(
+ autofill::CreditCard::CARD_TYPE_CREDIT);
+ out_supported_card_types_set->insert(autofill::CreditCard::CARD_TYPE_DEBIT);
+ out_supported_card_types_set->insert(
+ autofill::CreditCard::CARD_TYPE_PREPAID);
+ }
+
+ // Let the user decide whether an unknown card type should be used.
+ out_supported_card_types_set->insert(autofill::CreditCard::CARD_TYPE_UNKNOWN);
+}
+
base::string16 GetFormattedPhoneNumberForDisplay(
const autofill::AutofillProfile& profile,
const std::string& locale) {
« no previous file with comments | « components/payments/core/payment_request_data_util.h ('k') | ios/chrome/browser/payments/payment_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698