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..ecb19e2dfbcf0ca2d0402a5ab1c060cfb04cf758 100644 |
--- a/components/payments/core/payment_request_data_util.cc |
+++ b/components/payments/core/payment_request_data_util.cc |
@@ -4,6 +4,8 @@ |
#include "components/payments/core/payment_request_data_util.h" |
+#include <algorithm> |
+ |
#include "base/strings/string16.h" |
#include "base/strings/string_split.h" |
#include "base/strings/string_util.h" |
@@ -11,7 +13,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 +155,42 @@ 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()); |
+ |
+ const char kBasicCardMethodName[] = "basic-card"; |
+ for (const PaymentMethodData& method_data_entry : method_data) { |
+ const std::vector<std::string>& supported_methods = |
+ method_data_entry.supported_methods; |
+ // Ignore |supported_types| if |supported_methods| does not contain |
+ // "basic_card". |
+ const auto method_it = |
+ std::find(supported_methods.begin(), supported_methods.end(), |
+ kBasicCardMethodName); |
+ if (method_it == supported_methods.end()) |
please use gerrit instead
2017/06/30 15:49:40
if (!base::ContainsValue(supported_methods, "basic
Moe
2017/06/30 20:47:18
This is cool! Done.
|
+ 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) { |