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 <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 base::string16 GetFormattedCurrencyAmount(const std::string& amount); | 87 base::string16 GetFormattedCurrencyAmount(const std::string& amount); |
88 | 88 |
89 // Uses CurrencyFormatter to get the formatted currency code for this | 89 // Uses CurrencyFormatter to get the formatted currency code for this |
90 // request's currency. Will use currency of the "total" display item, because | 90 // request's currency. Will use currency of the "total" display item, because |
91 // all items are supposed to have the same currency in a given request. | 91 // all items are supposed to have the same currency in a given request. |
92 std::string GetFormattedCurrencyCode(); | 92 std::string GetFormattedCurrencyCode(); |
93 | 93 |
94 mojom::PaymentShippingOption* selected_shipping_option() const { | 94 mojom::PaymentShippingOption* selected_shipping_option() const { |
95 return selected_shipping_option_; | 95 return selected_shipping_option_; |
96 } | 96 } |
| 97 // if |selected_shipping_option()| is nullptr, this may contain a non-empty |
| 98 // error returned by the merchant. |
| 99 const std::string& selected_shipping_option_error() const { |
| 100 return selected_shipping_option_error_; |
| 101 } |
97 | 102 |
98 const mojom::PaymentDetails& details() const { return *details_.get(); } | 103 const mojom::PaymentDetails& details() const { return *details_.get(); } |
99 | 104 |
100 void StartWaitingForUpdateWith(UpdateReason reason); | 105 void StartWaitingForUpdateWith(UpdateReason reason); |
101 | 106 |
102 private: | 107 private: |
103 friend class PaymentRequestDialogView; | 108 friend class PaymentRequestDialogView; |
104 void add_observer_for_testing(Observer* observer_for_testing) { | 109 void add_observer_for_testing(Observer* observer_for_testing) { |
105 observer_for_testing_ = observer_for_testing; | 110 observer_for_testing_ = observer_for_testing; |
106 } | 111 } |
(...skipping 18 matching lines...) Expand all Loading... |
125 CurrencyFormatter* GetOrCreateCurrencyFormatter( | 130 CurrencyFormatter* GetOrCreateCurrencyFormatter( |
126 const std::string& currency_code, | 131 const std::string& currency_code, |
127 const std::string& currency_system, | 132 const std::string& currency_system, |
128 const std::string& locale_name); | 133 const std::string& locale_name); |
129 | 134 |
130 mojom::PaymentOptionsPtr options_; | 135 mojom::PaymentOptionsPtr options_; |
131 mojom::PaymentDetailsPtr details_; | 136 mojom::PaymentDetailsPtr details_; |
132 const std::string app_locale_; | 137 const std::string app_locale_; |
133 // The currently shipping option as specified by the merchant. | 138 // The currently shipping option as specified by the merchant. |
134 mojom::PaymentShippingOption* selected_shipping_option_; | 139 mojom::PaymentShippingOption* selected_shipping_option_; |
| 140 std::string selected_shipping_option_error_; |
135 | 141 |
136 std::unique_ptr<CurrencyFormatter> currency_formatter_; | 142 std::unique_ptr<CurrencyFormatter> currency_formatter_; |
137 | 143 |
138 // A list/set of supported basic card networks. The list is used to keep the | 144 // A list/set of supported basic card networks. The list is used to keep the |
139 // order in which they were specified by the merchant. The set is used for | 145 // order in which they were specified by the merchant. The set is used for |
140 // fast lookup of supported methods. | 146 // fast lookup of supported methods. |
141 std::vector<std::string> supported_card_networks_; | 147 std::vector<std::string> supported_card_networks_; |
142 std::set<std::string> supported_card_networks_set_; | 148 std::set<std::string> supported_card_networks_set_; |
143 | 149 |
144 // Only the set of basic-card specified networks. NOTE: callers should use | 150 // Only the set of basic-card specified networks. NOTE: callers should use |
145 // |supported_card_networks_set_| to check merchant support. | 151 // |supported_card_networks_set_| to check merchant support. |
146 std::set<std::string> basic_card_specified_networks_; | 152 std::set<std::string> basic_card_specified_networks_; |
147 | 153 |
148 // The |observer_for_testing_| will fire after all the |observers_| have been | 154 // The |observer_for_testing_| will fire after all the |observers_| have been |
149 // notified. | 155 // notified. |
150 base::ObserverList<Observer> observers_; | 156 base::ObserverList<Observer> observers_; |
151 Observer* observer_for_testing_; | 157 Observer* observer_for_testing_; |
152 | 158 |
153 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec); | 159 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec); |
154 }; | 160 }; |
155 | 161 |
156 } // namespace payments | 162 } // namespace payments |
157 | 163 |
158 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ | 164 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ |
OLD | NEW |