| 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/autofill_payment_instrument.h" | 14 #include "components/payments/core/autofill_payment_instrument.h" |
| 15 #include "components/payments/core/payment_instrument.h" | 15 #include "components/payments/core/payment_instrument.h" |
| 16 | 16 |
| 17 namespace autofill { | 17 namespace autofill { |
| 18 class AutofillProfile; | 18 class AutofillProfile; |
| 19 class CreditCard; |
| 19 class PersonalDataManager; | 20 class PersonalDataManager; |
| 20 } // namespace autofill | 21 } // namespace autofill |
| 21 | 22 |
| 22 namespace payments { | 23 namespace payments { |
| 23 | 24 |
| 24 class PaymentRequestDelegate; | 25 class PaymentRequestDelegate; |
| 25 class PaymentRequestSpec; | 26 class PaymentRequestSpec; |
| 26 | 27 |
| 27 // Keeps track of the information currently selected by the user and whether the | 28 // Keeps track of the information currently selected by the user and whether the |
| 28 // user is ready to pay. Uses information from the PaymentRequestSpec, which is | 29 // user is ready to pay. Uses information from the PaymentRequestSpec, which is |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 return shipping_profiles_; | 105 return shipping_profiles_; |
| 105 } | 106 } |
| 106 const std::vector<autofill::AutofillProfile*>& contact_profiles() { | 107 const std::vector<autofill::AutofillProfile*>& contact_profiles() { |
| 107 return contact_profiles_; | 108 return contact_profiles_; |
| 108 } | 109 } |
| 109 const std::vector<std::unique_ptr<PaymentInstrument>>& | 110 const std::vector<std::unique_ptr<PaymentInstrument>>& |
| 110 available_instruments() { | 111 available_instruments() { |
| 111 return available_instruments_; | 112 return available_instruments_; |
| 112 } | 113 } |
| 113 | 114 |
| 115 // Creates and adds an AutofillPaymentInstrument, which makes a copy of |
| 116 // |card|. |selected| indicates if the newly-created instrument should be |
| 117 // selected, after which observers will be notified. |
| 118 void AddAutofillPaymentInstrument(bool selected, |
| 119 const autofill::CreditCard& card); |
| 120 |
| 114 // Setters to change the selected information. Will have the side effect of | 121 // Setters to change the selected information. Will have the side effect of |
| 115 // recomputing "is ready to pay" and notify observers. | 122 // recomputing "is ready to pay" and notify observers. |
| 116 void SetSelectedShippingOption(const std::string& shipping_option_id); | 123 void SetSelectedShippingOption(const std::string& shipping_option_id); |
| 117 void SetSelectedShippingProfile(autofill::AutofillProfile* profile); | 124 void SetSelectedShippingProfile(autofill::AutofillProfile* profile); |
| 118 void SetSelectedContactProfile(autofill::AutofillProfile* profile); | 125 void SetSelectedContactProfile(autofill::AutofillProfile* profile); |
| 119 void SetSelectedInstrument(PaymentInstrument* instrument); | 126 void SetSelectedInstrument(PaymentInstrument* instrument); |
| 120 | 127 |
| 121 bool is_ready_to_pay() { return is_ready_to_pay_; } | 128 bool is_ready_to_pay() { return is_ready_to_pay_; } |
| 122 | 129 |
| 123 const std::string& GetApplicationLocale(); | 130 const std::string& GetApplicationLocale(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 PaymentRequestDelegate* payment_request_delegate_; | 182 PaymentRequestDelegate* payment_request_delegate_; |
| 176 | 183 |
| 177 base::ObserverList<Observer> observers_; | 184 base::ObserverList<Observer> observers_; |
| 178 | 185 |
| 179 DISALLOW_COPY_AND_ASSIGN(PaymentRequestState); | 186 DISALLOW_COPY_AND_ASSIGN(PaymentRequestState); |
| 180 }; | 187 }; |
| 181 | 188 |
| 182 } // namespace payments | 189 } // namespace payments |
| 183 | 190 |
| 184 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ | 191 #endif // COMPONENTS_PAYMENTS_CONTENT_PAYMENT_REQUEST_STATE_H_ |
| OLD | NEW |