| 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_CONTENT_PAYMENT_REQUEST_SPEC_H_ | 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ |
| 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ | 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ |
| 7 | 7 |
| 8 #include <map> |
| 8 #include <set> | 9 #include <set> |
| 9 #include <string> | 10 #include <string> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 15 #include "components/payments/core/currency_formatter.h" | 16 #include "components/payments/core/currency_formatter.h" |
| 16 #include "components/payments/core/payment_options_provider.h" | 17 #include "components/payments/core/payment_options_provider.h" |
| 17 #include "components/payments/mojom/payment_request.mojom.h" | 18 #include "components/payments/mojom/payment_request.mojom.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 bool request_payer_phone() const override; | 71 bool request_payer_phone() const override; |
| 71 bool request_payer_email() const override; | 72 bool request_payer_email() const override; |
| 72 PaymentShippingType shipping_type() const override; | 73 PaymentShippingType shipping_type() const override; |
| 73 | 74 |
| 74 const std::vector<std::string>& supported_card_networks() const { | 75 const std::vector<std::string>& supported_card_networks() const { |
| 75 return supported_card_networks_; | 76 return supported_card_networks_; |
| 76 } | 77 } |
| 77 const std::set<std::string>& supported_card_networks_set() const { | 78 const std::set<std::string>& supported_card_networks_set() const { |
| 78 return supported_card_networks_set_; | 79 return supported_card_networks_set_; |
| 79 } | 80 } |
| 81 const std::map<std::string, std::set<std::string>>& stringified_method_data() |
| 82 const { |
| 83 return stringified_method_data_; |
| 84 } |
| 80 // Returns whether the |method_name| was specified as supported through the | 85 // Returns whether the |method_name| was specified as supported through the |
| 81 // "basic-card" payment method. If false, it means either the |method_name| is | 86 // "basic-card" payment method. If false, it means either the |method_name| is |
| 82 // not supported at all, or specified directly in supportedMethods. | 87 // not supported at all, or specified directly in supportedMethods. |
| 83 bool IsMethodSupportedThroughBasicCard(const std::string& method_name); | 88 bool IsMethodSupportedThroughBasicCard(const std::string& method_name); |
| 84 | 89 |
| 85 // Uses CurrencyFormatter to format |amount| with the currency symbol for this | 90 // Uses CurrencyFormatter to format |amount| with the currency symbol for this |
| 86 // request's currency. Will use currency of the "total" display item, because | 91 // request's currency. Will use currency of the "total" display item, because |
| 87 // all items are supposed to have the same currency in a given request. | 92 // all items are supposed to have the same currency in a given request. |
| 88 base::string16 GetFormattedCurrencyAmount(const std::string& amount); | 93 base::string16 GetFormattedCurrencyAmount(const std::string& amount); |
| 89 | 94 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // A list/set of supported basic card networks. The list is used to keep the | 150 // A list/set of supported basic card networks. The list is used to keep the |
| 146 // order in which they were specified by the merchant. The set is used for | 151 // order in which they were specified by the merchant. The set is used for |
| 147 // fast lookup of supported methods. | 152 // fast lookup of supported methods. |
| 148 std::vector<std::string> supported_card_networks_; | 153 std::vector<std::string> supported_card_networks_; |
| 149 std::set<std::string> supported_card_networks_set_; | 154 std::set<std::string> supported_card_networks_set_; |
| 150 | 155 |
| 151 // Only the set of basic-card specified networks. NOTE: callers should use | 156 // Only the set of basic-card specified networks. NOTE: callers should use |
| 152 // |supported_card_networks_set_| to check merchant support. | 157 // |supported_card_networks_set_| to check merchant support. |
| 153 std::set<std::string> basic_card_specified_networks_; | 158 std::set<std::string> basic_card_specified_networks_; |
| 154 | 159 |
| 160 // A mapping of the payment method names to the corresponding JSON-stringified |
| 161 // payment method specific data. |
| 162 std::map<std::string, std::set<std::string>> stringified_method_data_; |
| 163 |
| 155 // The |observer_for_testing_| will fire after all the |observers_| have been | 164 // The |observer_for_testing_| will fire after all the |observers_| have been |
| 156 // notified. | 165 // notified. |
| 157 base::ObserverList<Observer> observers_; | 166 base::ObserverList<Observer> observers_; |
| 158 Observer* observer_for_testing_; | 167 Observer* observer_for_testing_; |
| 159 | 168 |
| 160 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec); | 169 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec); |
| 161 }; | 170 }; |
| 162 | 171 |
| 163 } // namespace payments | 172 } // namespace payments |
| 164 | 173 |
| 165 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ | 174 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ |
| OLD | NEW |