| 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 <memory> | 8 #include <memory> |
| 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 "components/payments/content/payment_response_helper.h" | 14 #include "components/payments/content/payment_response_helper.h" |
| 15 #include "components/payments/core/address_normalizer.h" |
| 15 #include "components/payments/mojom/payment_request.mojom.h" | 16 #include "components/payments/mojom/payment_request.mojom.h" |
| 16 | 17 |
| 17 namespace autofill { | 18 namespace autofill { |
| 18 class AutofillProfile; | 19 class AutofillProfile; |
| 19 class CreditCard; | 20 class CreditCard; |
| 20 class PersonalDataManager; | 21 class PersonalDataManager; |
| 21 class RegionDataLoader; | 22 class RegionDataLoader; |
| 22 } // namespace autofill | 23 } // namespace autofill |
| 23 | 24 |
| 24 namespace payments { | 25 namespace payments { |
| 25 | 26 |
| 26 class PaymentInstrument; | 27 class PaymentInstrument; |
| 27 class PaymentRequestDelegate; | 28 class PaymentRequestDelegate; |
| 28 class PaymentRequestSpec; | 29 class PaymentRequestSpec; |
| 29 | 30 |
| 30 // Keeps track of the information currently selected by the user and whether the | 31 // Keeps track of the information currently selected by the user and whether the |
| 31 // user is ready to pay. Uses information from the PaymentRequestSpec, which is | 32 // user is ready to pay. Uses information from the PaymentRequestSpec, which is |
| 32 // what the merchant has specified, as input into the "is ready to pay" | 33 // what the merchant has specified, as input into the "is ready to pay" |
| 33 // computation. | 34 // computation. |
| 34 class PaymentRequestState : public PaymentResponseHelper::Delegate { | 35 class PaymentRequestState : public PaymentResponseHelper::Delegate, |
| 36 public AddressNormalizer::Delegate { |
| 35 public: | 37 public: |
| 36 // Any class call add itself as Observer via AddObserver() and receive | 38 // Any class call add itself as Observer via AddObserver() and receive |
| 37 // notification about the state changing. | 39 // notification about the state changing. |
| 38 class Observer { | 40 class Observer { |
| 39 public: | 41 public: |
| 40 // Called when the information (payment method, address/contact info, | 42 // Called when the information (payment method, address/contact info, |
| 41 // shipping option) changes. | 43 // shipping option) changes. |
| 42 virtual void OnSelectedInformationChanged() = 0; | 44 virtual void OnSelectedInformationChanged() = 0; |
| 43 | 45 |
| 44 protected: | 46 protected: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 66 Delegate* delegate, | 68 Delegate* delegate, |
| 67 const std::string& app_locale, | 69 const std::string& app_locale, |
| 68 autofill::PersonalDataManager* personal_data_manager, | 70 autofill::PersonalDataManager* personal_data_manager, |
| 69 PaymentRequestDelegate* payment_request_delegate); | 71 PaymentRequestDelegate* payment_request_delegate); |
| 70 ~PaymentRequestState() override; | 72 ~PaymentRequestState() override; |
| 71 | 73 |
| 72 // PaymentResponseHelper::Delegate | 74 // PaymentResponseHelper::Delegate |
| 73 void OnPaymentResponseReady( | 75 void OnPaymentResponseReady( |
| 74 mojom::PaymentResponsePtr payment_response) override; | 76 mojom::PaymentResponsePtr payment_response) override; |
| 75 | 77 |
| 78 // AddressNormalizer::Delegate |
| 79 void OnAddressNormalized( |
| 80 const autofill::AutofillProfile& normalized_profile) override; |
| 81 void OnCouldNotNormalize(const autofill::AutofillProfile& profile) override; |
| 82 |
| 76 // Returns whether the user has at least one instrument that satisfies the | 83 // Returns whether the user has at least one instrument that satisfies the |
| 77 // specified supported payment methods. | 84 // specified supported payment methods. |
| 78 bool CanMakePayment() const; | 85 bool CanMakePayment() const; |
| 79 | 86 |
| 80 // Returns true if the payment methods that the merchant website have | 87 // Returns true if the payment methods that the merchant website have |
| 81 // requested are supported. For example, may return true for "basic-card", but | 88 // requested are supported. For example, may return true for "basic-card", but |
| 82 // false for "https://bobpay.com". | 89 // false for "https://bobpay.com". |
| 83 bool AreRequestedMethodsSupported() const; | 90 bool AreRequestedMethodsSupported() const; |
| 84 | 91 |
| 85 void AddObserver(Observer* observer); | 92 void AddObserver(Observer* observer); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 std::unique_ptr<PaymentResponseHelper> response_helper_; | 204 std::unique_ptr<PaymentResponseHelper> response_helper_; |
| 198 | 205 |
| 199 base::ObserverList<Observer> observers_; | 206 base::ObserverList<Observer> observers_; |
| 200 | 207 |
| 201 DISALLOW_COPY_AND_ASSIGN(PaymentRequestState); | 208 DISALLOW_COPY_AND_ASSIGN(PaymentRequestState); |
| 202 }; | 209 }; |
| 203 | 210 |
| 204 } // namespace payments | 211 } // namespace payments |
| 205 | 212 |
| 206 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ | 213 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ |
| OLD | NEW |