| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef COMPONENTS_PAYMENTS_CORE_PAYMENT_REQUEST_DATA_UTIL_H_ | 5 #ifndef COMPONENTS_PAYMENTS_CORE_PAYMENT_REQUEST_DATA_UTIL_H_ |
| 6 #define COMPONENTS_PAYMENTS_CORE_PAYMENT_REQUEST_DATA_UTIL_H_ | 6 #define COMPONENTS_PAYMENTS_CORE_PAYMENT_REQUEST_DATA_UTIL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "components/autofill/core/browser/credit_card.h" |
| 13 | 14 |
| 14 namespace autofill { | 15 namespace autofill { |
| 15 class AutofillProfile; | 16 class AutofillProfile; |
| 16 class CreditCard; | |
| 17 } // namespace autofill | 17 } // namespace autofill |
| 18 | 18 |
| 19 namespace payments { | 19 namespace payments { |
| 20 | 20 |
| 21 struct BasicCardResponse; | 21 struct BasicCardResponse; |
| 22 struct PaymentAddress; | 22 struct PaymentAddress; |
| 23 class PaymentMethodData; | 23 class PaymentMethodData; |
| 24 | 24 |
| 25 namespace data_util { | 25 namespace data_util { |
| 26 | 26 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 45 // that includes all networks that were specified as part of "basic-card". This | 45 // that includes all networks that were specified as part of "basic-card". This |
| 46 // is used to know whether to return the card network name (e.g., "visa") or | 46 // is used to know whether to return the card network name (e.g., "visa") or |
| 47 // "basic-card" in the PaymentResponse. |method_data.supported_networks| is | 47 // "basic-card" in the PaymentResponse. |method_data.supported_networks| is |
| 48 // expected to only contain basic-card card network names (the list is at | 48 // expected to only contain basic-card card network names (the list is at |
| 49 // https://www.w3.org/Payments/card-network-ids). | 49 // https://www.w3.org/Payments/card-network-ids). |
| 50 void ParseBasicCardSupportedNetworks( | 50 void ParseBasicCardSupportedNetworks( |
| 51 const std::vector<PaymentMethodData>& method_data, | 51 const std::vector<PaymentMethodData>& method_data, |
| 52 std::vector<std::string>* out_supported_networks, | 52 std::vector<std::string>* out_supported_networks, |
| 53 std::set<std::string>* out_basic_card_supported_networks); | 53 std::set<std::string>* out_basic_card_supported_networks); |
| 54 | 54 |
| 55 // Parses the supported card types (e.g., credit, debit, prepaid) from |
| 56 // supportedTypes. |out_supported_card_types_set| is expected to be empty. It |
| 57 // will always contain autofill::CreditCard::CARD_TYPE_UNKNOWN after the call. |
| 58 // Also, it gets filled with all of the card types if supportedTypes is empty. |
| 59 void ParseSupportedCardTypes( |
| 60 const std::vector<PaymentMethodData>& method_data, |
| 61 std::set<autofill::CreditCard::CardType>* out_supported_card_types_set); |
| 62 |
| 55 // Returns the phone number from the given |profile| formatted for display. | 63 // Returns the phone number from the given |profile| formatted for display. |
| 56 base::string16 GetFormattedPhoneNumberForDisplay( | 64 base::string16 GetFormattedPhoneNumberForDisplay( |
| 57 const autofill::AutofillProfile& profile, | 65 const autofill::AutofillProfile& profile, |
| 58 const std::string& locale); | 66 const std::string& locale); |
| 59 | 67 |
| 60 // Formats the given number |phone_number| to | 68 // Formats the given number |phone_number| to |
| 61 // i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat::INTERNATIONAL format | 69 // i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat::INTERNATIONAL format |
| 62 // by using i18n::phonenumbers::PhoneNumberUtil::Format. | 70 // by using i18n::phonenumbers::PhoneNumberUtil::Format. |
| 63 std::string FormatPhoneForDisplay(const std::string& phone_number, | 71 std::string FormatPhoneForDisplay(const std::string& phone_number, |
| 64 const std::string& country_code); | 72 const std::string& country_code); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 79 // Returns a country code to be used when validating this profile. If the | 87 // Returns a country code to be used when validating this profile. If the |
| 80 // profile has a valid country code set, it is returned. If not, a country code | 88 // profile has a valid country code set, it is returned. If not, a country code |
| 81 // associated with |app_locale| is used as a fallback. | 89 // associated with |app_locale| is used as a fallback. |
| 82 std::string GetCountryCodeWithFallback(const autofill::AutofillProfile* profile, | 90 std::string GetCountryCodeWithFallback(const autofill::AutofillProfile* profile, |
| 83 const std::string& app_locale); | 91 const std::string& app_locale); |
| 84 | 92 |
| 85 } // namespace data_util | 93 } // namespace data_util |
| 86 } // namespace payments | 94 } // namespace payments |
| 87 | 95 |
| 88 #endif // COMPONENTS_PAYMENTS_CORE_PAYMENT_REQUEST_DATA_UTIL_H_ | 96 #endif // COMPONENTS_PAYMENTS_CORE_PAYMENT_REQUEST_DATA_UTIL_H_ |
| OLD | NEW |