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

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 comments 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..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) {
« 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