| 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 19 matching lines...) Expand all Loading... |
| 30 enum class UpdateReason { | 30 enum class UpdateReason { |
| 31 NONE, | 31 NONE, |
| 32 SHIPPING_OPTION, | 32 SHIPPING_OPTION, |
| 33 SHIPPING_ADDRESS, | 33 SHIPPING_ADDRESS, |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 // Any class call add itself as Observer via AddObserver() and receive | 36 // Any class call add itself as Observer via AddObserver() and receive |
| 37 // notification about spec events. | 37 // notification about spec events. |
| 38 class Observer { | 38 class Observer { |
| 39 public: | 39 public: |
| 40 // Called when the provided spec (details, options, method_data) is invalid. | |
| 41 virtual void OnInvalidSpecProvided() = 0; | |
| 42 | |
| 43 // Called when the website is notified that the user selected shipping | 40 // Called when the website is notified that the user selected shipping |
| 44 // options or a shipping address. This will be followed by a call to | 41 // options or a shipping address. This will be followed by a call to |
| 45 // OnSpecUpdated or the PaymentRequest being aborted due to a timeout. | 42 // OnSpecUpdated or the PaymentRequest being aborted due to a timeout. |
| 46 virtual void OnStartUpdating(UpdateReason reason) {} | 43 virtual void OnStartUpdating(UpdateReason reason) {} |
| 47 | 44 |
| 48 // Called when the provided spec has changed. | 45 // Called when the provided spec has changed. |
| 49 virtual void OnSpecUpdated() = 0; | 46 virtual void OnSpecUpdated() = 0; |
| 50 | 47 |
| 51 protected: | 48 protected: |
| 52 virtual ~Observer() {} | 49 virtual ~Observer() {} |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // Validates the |method_data| and fills |supported_card_networks_|, | 108 // Validates the |method_data| and fills |supported_card_networks_|, |
| 112 // |supported_card_networks_set_| and |basic_card_specified_networks_|. | 109 // |supported_card_networks_set_| and |basic_card_specified_networks_|. |
| 113 void PopulateValidatedMethodData( | 110 void PopulateValidatedMethodData( |
| 114 const std::vector<mojom::PaymentMethodDataPtr>& method_data); | 111 const std::vector<mojom::PaymentMethodDataPtr>& method_data); |
| 115 | 112 |
| 116 // Updates the selected_shipping_option based on the data passed to this | 113 // Updates the selected_shipping_option based on the data passed to this |
| 117 // payment request by the website. This will set selected_shipping_option_ to | 114 // payment request by the website. This will set selected_shipping_option_ to |
| 118 // the last option marked selected in the options array. | 115 // the last option marked selected in the options array. |
| 119 void UpdateSelectedShippingOption(); | 116 void UpdateSelectedShippingOption(); |
| 120 | 117 |
| 121 // Will notify all observers that the spec is invalid. | |
| 122 void NotifyOnInvalidSpecProvided(); | |
| 123 // Will notify all observers that the spec has changed. | 118 // Will notify all observers that the spec has changed. |
| 124 void NotifyOnSpecUpdated(); | 119 void NotifyOnSpecUpdated(); |
| 125 | 120 |
| 126 // Returns the CurrencyFormatter instance for this PaymentRequest. | 121 // Returns the CurrencyFormatter instance for this PaymentRequest. |
| 127 // |locale_name| should be the result of the browser's GetApplicationLocale(). | 122 // |locale_name| should be the result of the browser's GetApplicationLocale(). |
| 128 // Note: Having multiple currencies per PaymentRequest is not supported; hence | 123 // Note: Having multiple currencies per PaymentRequest is not supported; hence |
| 129 // the CurrencyFormatter is cached here. | 124 // the CurrencyFormatter is cached here. |
| 130 CurrencyFormatter* GetOrCreateCurrencyFormatter( | 125 CurrencyFormatter* GetOrCreateCurrencyFormatter( |
| 131 const std::string& currency_code, | 126 const std::string& currency_code, |
| 132 const std::string& currency_system, | 127 const std::string& currency_system, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 154 // notified. | 149 // notified. |
| 155 base::ObserverList<Observer> observers_; | 150 base::ObserverList<Observer> observers_; |
| 156 Observer* observer_for_testing_; | 151 Observer* observer_for_testing_; |
| 157 | 152 |
| 158 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec); | 153 DISALLOW_COPY_AND_ASSIGN(PaymentRequestSpec); |
| 159 }; | 154 }; |
| 160 | 155 |
| 161 } // namespace payments | 156 } // namespace payments |
| 162 | 157 |
| 163 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ | 158 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_SPEC_H_ |
| OLD | NEW |