| 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_STATE_H_ | 5 #ifndef COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ |
| 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ | 6 #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "components/payments/content/payment_request.mojom.h" | 13 #include "components/payments/content/payment_request.mojom.h" |
| 14 #include "components/payments/core/payment_instrument.h" | 14 #include "components/payments/core/payment_instrument.h" |
| 15 | 15 |
| 16 namespace autofill { | 16 namespace autofill { |
| 17 class AutofillProfile; | 17 class AutofillProfile; |
| 18 class PersonalDataManager; | 18 class PersonalDataManager; |
| 19 } // namespace autofill | 19 } // namespace autofill |
| 20 | 20 |
| 21 namespace payments { | 21 namespace payments { |
| 22 | 22 |
| 23 class PaymentRequestSpec; | 23 class PaymentRequestSpec; |
| 24 class PaymentRequestDelegate; |
| 24 | 25 |
| 25 // Keeps track of the information currently selected by the user and whether the | 26 // Keeps track of the information currently selected by the user and whether the |
| 26 // user is ready to pay. Uses information from the PaymentRequestSpec, which is | 27 // user is ready to pay. Uses information from the PaymentRequestSpec, which is |
| 27 // what the merchant has specified, as input into the "is ready to pay" | 28 // what the merchant has specified, as input into the "is ready to pay" |
| 28 // computation. | 29 // computation. |
| 29 class PaymentRequestState : public PaymentInstrument::Delegate { | 30 class PaymentRequestState : public PaymentInstrument::Delegate { |
| 30 public: | 31 public: |
| 31 // Any class call add itself as Observer via AddObserver() and receive | 32 // Any class call add itself as Observer via AddObserver() and receive |
| 32 // notification about the state changing. | 33 // notification about the state changing. |
| 33 class Observer { | 34 class Observer { |
| 34 public: | 35 public: |
| 35 // Called when the information (payment method, address/contact info, | 36 // Called when the information (payment method, address/contact info, |
| 36 // shipping option) changes. | 37 // shipping option) changes. |
| 37 virtual void OnSelectedInformationChanged() = 0; | 38 virtual void OnSelectedInformationChanged() = 0; |
| 38 | 39 |
| 39 protected: | 40 protected: |
| 40 virtual ~Observer() {} | 41 virtual ~Observer() {} |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 class Delegate { | 44 class Delegate { |
| 44 public: | 45 public: |
| 45 // Called when the PaymentResponse is available. | 46 // Called when the PaymentResponse is available. |
| 46 virtual void OnPaymentResponseAvailable( | 47 virtual void OnPaymentResponseAvailable( |
| 47 mojom::PaymentResponsePtr response) = 0; | 48 mojom::PaymentResponsePtr response) = 0; |
| 49 virtual PaymentRequestDelegate* GetPaymentRequestDelegate() = 0; |
| 48 | 50 |
| 49 protected: | 51 protected: |
| 50 virtual ~Delegate() {} | 52 virtual ~Delegate() {} |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 PaymentRequestState(PaymentRequestSpec* spec, | 55 PaymentRequestState(PaymentRequestSpec* spec, |
| 54 Delegate* delegate, | 56 Delegate* delegate, |
| 55 const std::string& app_locale, | 57 const std::string& app_locale, |
| 56 autofill::PersonalDataManager* personal_data_manager); | 58 autofill::PersonalDataManager* personal_data_manager); |
| 57 ~PaymentRequestState() override; | 59 ~PaymentRequestState() override; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 std::vector<std::unique_ptr<PaymentInstrument>> available_instruments_; | 174 std::vector<std::unique_ptr<PaymentInstrument>> available_instruments_; |
| 173 | 175 |
| 174 base::ObserverList<Observer> observers_; | 176 base::ObserverList<Observer> observers_; |
| 175 | 177 |
| 176 DISALLOW_COPY_AND_ASSIGN(PaymentRequestState); | 178 DISALLOW_COPY_AND_ASSIGN(PaymentRequestState); |
| 177 }; | 179 }; |
| 178 | 180 |
| 179 } // namespace payments | 181 } // namespace payments |
| 180 | 182 |
| 181 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ | 183 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ |
| OLD | NEW |