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> |
(...skipping 26 matching lines...) Expand all Loading... |
37 const base::string16& cvc, | 37 const base::string16& cvc, |
38 const std::vector<autofill::AutofillProfile*>& billing_profiles, | 38 const std::vector<autofill::AutofillProfile*>& billing_profiles, |
39 const std::string& app_locale); | 39 const std::string& app_locale); |
40 | 40 |
41 // Parse the supported card networks from supportedMethods and "basic-card"'s | 41 // Parse the supported card networks from supportedMethods and "basic-card"'s |
42 // supportedNetworks. |out_supported_networks| is filled with list of networks | 42 // supportedNetworks. |out_supported_networks| is filled with list of networks |
43 // in the order that they were specified by the merchant. | 43 // in the order that they were specified by the merchant. |
44 // |out_basic_card_supported_networks| is a subset of |out_supported_networks| | 44 // |out_basic_card_supported_networks| is a subset of |out_supported_networks| |
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. Returns true on success, false on | 47 // "basic-card" in the PaymentResponse. |method_data.supported_networks| is |
48 // invalid data specified. |method_data.supported_networks| is expected to only | 48 // expected to only contain basic-card card network names (the list is at |
49 // contain basic-card card network names (the list is at | |
50 // https://www.w3.org/Payments/card-network-ids). | 49 // https://www.w3.org/Payments/card-network-ids). |
51 bool ParseBasicCardSupportedNetworks( | 50 void ParseBasicCardSupportedNetworks( |
52 const std::vector<PaymentMethodData>& method_data, | 51 const std::vector<PaymentMethodData>& method_data, |
53 std::vector<std::string>* out_supported_networks, | 52 std::vector<std::string>* out_supported_networks, |
54 std::set<std::string>* out_basic_card_supported_networks); | 53 std::set<std::string>* out_basic_card_supported_networks); |
55 | 54 |
56 // Formats the given number |phone_number| to | 55 // Formats the given number |phone_number| to |
57 // i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat::INTERNATIONAL format | 56 // i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat::INTERNATIONAL format |
58 // by using i18n::phonenumbers::PhoneNumberUtil::Format. | 57 // by using i18n::phonenumbers::PhoneNumberUtil::Format. |
59 std::string FormatPhoneForDisplay(const std::string& phone_number, | 58 std::string FormatPhoneForDisplay(const std::string& phone_number, |
60 const std::string& country_code); | 59 const std::string& country_code); |
61 | 60 |
62 // Formats the given number |phone_number| to | 61 // Formats the given number |phone_number| to |
63 // i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat::E164 format by using | 62 // i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat::E164 format by using |
64 // i18n::phonenumbers::PhoneNumberUtil::Format, as defined in the Payment | 63 // i18n::phonenumbers::PhoneNumberUtil::Format, as defined in the Payment |
65 // Request spec | 64 // Request spec |
66 // (https://w3c.github.io/browser-payment-api/#paymentrequest-updated-algorithm) | 65 // (https://w3c.github.io/browser-payment-api/#paymentrequest-updated-algorithm) |
67 std::string FormatPhoneForResponse(const std::string& phone_number, | 66 std::string FormatPhoneForResponse(const std::string& phone_number, |
68 const std::string& country_code); | 67 const std::string& country_code); |
69 | 68 |
70 } // namespace data_util | 69 } // namespace data_util |
71 } // namespace payments | 70 } // namespace payments |
72 | 71 |
73 #endif // COMPONENTS_PAYMENTS_CORE_PAYMENT_REQUEST_DATA_UTIL_H_ | 72 #endif // COMPONENTS_PAYMENTS_CORE_PAYMENT_REQUEST_DATA_UTIL_H_ |
OLD | NEW |