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> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "base/strings/string16.h" |
14 #include "components/payments/core/currency_formatter.h" | 15 #include "components/payments/core/currency_formatter.h" |
15 #include "components/payments/core/payment_options_provider.h" | 16 #include "components/payments/core/payment_options_provider.h" |
16 #include "components/payments/mojom/payment_request.mojom.h" | 17 #include "components/payments/mojom/payment_request.mojom.h" |
17 | 18 |
18 namespace payments { | 19 namespace payments { |
19 | 20 |
20 // Identifier for the basic card payment method in the PaymentMethodData. | 21 // Identifier for the basic card payment method in the PaymentMethodData. |
21 extern const char kBasicCardMethodName[]; | 22 extern const char kBasicCardMethodName[]; |
22 | 23 |
23 // The spec contains all the options that the merchant has specified about this | 24 // The spec contains all the options that the merchant has specified about this |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 base::string16 GetFormattedCurrencyAmount(const std::string& amount); | 88 base::string16 GetFormattedCurrencyAmount(const std::string& amount); |
88 | 89 |
89 // Uses CurrencyFormatter to get the formatted currency code for this | 90 // Uses CurrencyFormatter to get the formatted currency code for this |
90 // 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 |
91 // 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. |
92 std::string GetFormattedCurrencyCode(); | 93 std::string GetFormattedCurrencyCode(); |
93 | 94 |
94 mojom::PaymentShippingOption* selected_shipping_option() const { | 95 mojom::PaymentShippingOption* selected_shipping_option() const { |
95 return selected_shipping_option_; | 96 return selected_shipping_option_; |
96 } | 97 } |
| 98 // if |selected_shipping_option()| is nullptr, this may contain a non-empty |
| 99 // error returned by the merchant. |
| 100 const base::string16& selected_shipping_option_error() const { |
| 101 return selected_shipping_option_error_; |
| 102 } |
97 | 103 |
98 const mojom::PaymentDetails& details() const { return *details_.get(); } | 104 const mojom::PaymentDetails& details() const { return *details_.get(); } |
99 | 105 |
100 void StartWaitingForUpdateWith(UpdateReason reason); | 106 void StartWaitingForUpdateWith(UpdateReason reason); |
101 | 107 |
102 private: | 108 private: |
103 friend class PaymentRequestDialogView; | 109 friend class PaymentRequestDialogView; |
104 void add_observer_for_testing(Observer* observer_for_testing) { | 110 void add_observer_for_testing(Observer* observer_for_testing) { |
105 observer_for_testing_ = observer_for_testing; | 111 observer_for_testing_ = observer_for_testing; |
106 } | 112 } |
(...skipping 18 matching lines...) Expand all Loading... |
125 CurrencyFormatter* GetOrCreateCurrencyFormatter( | 131 CurrencyFormatter* GetOrCreateCurrencyFormatter( |
126 const std::string& currency_code, | 132 const std::string& currency_code, |
127 const std::string& currency_system, | 133 const std::string& currency_system, |
128 const std::string& locale_name); | 134 const std::string& locale_name); |
129 | 135 |
130 mojom::PaymentOptionsPtr options_; | 136 mojom::PaymentOptionsPtr options_; |
131 mojom::PaymentDetailsPtr details_; | 137 mojom::PaymentDetailsPtr details_; |
132 const std::string app_locale_; | 138 const std::string app_locale_; |
133 // The currently shipping option as specified by the merchant. | 139 // The currently shipping option as specified by the merchant. |
134 mojom::PaymentShippingOption* selected_shipping_option_; | 140 mojom::PaymentShippingOption* selected_shipping_option_; |
| 141 base::string16 selected_shipping_option_error_; |
135 | 142 |
136 std::unique_ptr<CurrencyFormatter> currency_formatter_; | 143 std::unique_ptr<CurrencyFormatter> currency_formatter_; |
137 | 144 |
138 // A list/set of supported basic card networks. The list is used to keep the | 145 // 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 | 146 // order in which they were specified by the merchant. The set is used for |
140 // fast lookup of supported methods. | 147 // fast lookup of supported methods. |
141 std::vector<std::string> supported_card_networks_; | 148 std::vector<std::string> supported_card_networks_; |
142 std::set<std::string> supported_card_networks_set_; | 149 std::set<std::string> supported_card_networks_set_; |
143 | 150 |
144 // Only the set of basic-card specified networks. NOTE: callers should use | 151 // Only the set of basic-card specified networks. NOTE: callers should use |
145 // |supported_card_networks_set_| to check merchant support. | 152 // |supported_card_networks_set_| to check merchant support. |
146 std::set<std::string> basic_card_specified_networks_; | 153 std::set<std::string> basic_card_specified_networks_; |
147 | 154 |
148 // The |observer_for_testing_| will fire after all the |observers_| have been | 155 // The |observer_for_testing_| will fire after all the |observers_| have been |
149 // notified. | 156 // notified. |
150 base::ObserverList<Observer> observers_; | 157 base::ObserverList<Observer> observers_; |
151 Observer* observer_for_testing_; | 158 Observer* observer_for_testing_; |
152 | 159 |
153 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec); | 160 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec); |
154 }; | 161 }; |
155 | 162 |
156 } // namespace payments | 163 } // namespace payments |
157 | 164 |
158 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ | 165 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ |
OLD | NEW |