| 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_CORE_AUTOFILL_PAYMENT_INSTRUMENT_H_ | 5 #ifndef COMPONENTS_PAYMENTS_CORE_AUTOFILL_PAYMENT_INSTRUMENT_H_ |
| 6 #define COMPONENTS_PAYMENTS_CORE_AUTOFILL_PAYMENT_INSTRUMENT_H_ | 6 #define COMPONENTS_PAYMENTS_CORE_AUTOFILL_PAYMENT_INSTRUMENT_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 "components/autofill/core/browser/credit_card.h" | 13 #include "components/autofill/core/browser/credit_card.h" |
| 14 #include "components/autofill/core/browser/payments/full_card_request.h" |
| 14 #include "components/payments/core/payment_instrument.h" | 15 #include "components/payments/core/payment_instrument.h" |
| 15 | 16 |
| 16 namespace autofill { | 17 namespace autofill { |
| 17 class AutofillProfile; | 18 class AutofillProfile; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace payments { | 21 namespace payments { |
| 21 | 22 |
| 23 class PaymentRequestDelegate; |
| 24 |
| 22 // Represents an Autofill/Payments credit card form of payment in Payment | 25 // Represents an Autofill/Payments credit card form of payment in Payment |
| 23 // Request. | 26 // Request. |
| 24 class AutofillPaymentInstrument : public PaymentInstrument { | 27 class AutofillPaymentInstrument |
| 28 : public PaymentInstrument, |
| 29 public autofill::payments::FullCardRequest::ResultDelegate { |
| 25 public: | 30 public: |
| 26 // |billing_profiles| is owned by the caller and should outlive this object. | 31 // |billing_profiles| is owned by the caller and should outlive this object. |
| 32 // |payment_request_delegate| must outlive this object. |
| 27 AutofillPaymentInstrument( | 33 AutofillPaymentInstrument( |
| 28 const std::string& method_name, | 34 const std::string& method_name, |
| 29 const autofill::CreditCard& card, | 35 const autofill::CreditCard& card, |
| 30 const std::vector<autofill::AutofillProfile*>& billing_profiles, | 36 const std::vector<autofill::AutofillProfile*>& billing_profiles, |
| 31 const std::string& app_locale); | 37 const std::string& app_locale, |
| 38 PaymentRequestDelegate* payment_request_delegate); |
| 32 ~AutofillPaymentInstrument() override; | 39 ~AutofillPaymentInstrument() override; |
| 33 | 40 |
| 34 // PaymentInstrument: | 41 // PaymentInstrument: |
| 35 void InvokePaymentApp(PaymentInstrument::Delegate* delegate) override; | 42 void InvokePaymentApp(PaymentInstrument::Delegate* delegate) override; |
| 36 bool IsValid() override; | 43 bool IsValid() override; |
| 37 | 44 |
| 45 // autofill::payments::FullCardRequest::ResultDelegate: |
| 46 void OnFullCardRequestSucceeded(const autofill::CreditCard& card, |
| 47 const base::string16& cvc) override; |
| 48 void OnFullCardRequestFailed() override; |
| 49 |
| 38 private: | 50 private: |
| 39 // A copy of the card is owned by this object. | 51 // A copy of the card is owned by this object. |
| 40 const autofill::CreditCard credit_card_; | 52 autofill::CreditCard credit_card_; |
| 41 // Not owned by this object, should outlive this. | 53 // Not owned by this object, should outlive this. |
| 42 const std::vector<autofill::AutofillProfile*>& billing_profiles_; | 54 const std::vector<autofill::AutofillProfile*>& billing_profiles_; |
| 43 | 55 |
| 44 const std::string app_locale_; | 56 const std::string app_locale_; |
| 45 | 57 |
| 58 PaymentInstrument::Delegate* delegate_; |
| 59 PaymentRequestDelegate* payment_request_delegate_; |
| 60 |
| 61 base::WeakPtrFactory<AutofillPaymentInstrument> weak_ptr_factory_; |
| 62 |
| 46 DISALLOW_COPY_AND_ASSIGN(AutofillPaymentInstrument); | 63 DISALLOW_COPY_AND_ASSIGN(AutofillPaymentInstrument); |
| 47 }; | 64 }; |
| 48 | 65 |
| 49 } // namespace payments | 66 } // namespace payments |
| 50 | 67 |
| 51 #endif // COMPONENTS_PAYMENTS_CORE_AUTOFILL_PAYMENT_INSTRUMENT_H_ | 68 #endif // COMPONENTS_PAYMENTS_CORE_AUTOFILL_PAYMENT_INSTRUMENT_H_ |
| OLD | NEW |