Chromium Code Reviews| Index: components/payments/core/autofill_payment_instrument.cc |
| diff --git a/components/payments/core/autofill_payment_instrument.cc b/components/payments/core/autofill_payment_instrument.cc |
| index 00c59b6a925aba1bbd78977b27abd9f7be1cf508..1684645c49e098b69a4c491d01428c7d1c4d733b 100644 |
| --- a/components/payments/core/autofill_payment_instrument.cc |
| +++ b/components/payments/core/autofill_payment_instrument.cc |
| @@ -17,7 +17,8 @@ AutofillPaymentInstrument::AutofillPaymentInstrument( |
| const std::string& method_name, |
| const autofill::CreditCard& card, |
| const std::vector<autofill::AutofillProfile*>& billing_profiles, |
| - const std::string& app_locale) |
| + const std::string& app_locale, |
| + FullCardRequestDelegate* full_card_request_delegate) |
| : PaymentInstrument( |
| method_name, |
| /* label= */ card.TypeAndLastFourDigits(), |
| @@ -28,26 +29,44 @@ AutofillPaymentInstrument::AutofillPaymentInstrument( |
| .icon_resource_id), |
| credit_card_(card), |
| billing_profiles_(billing_profiles), |
| - app_locale_(app_locale) {} |
| + app_locale_(app_locale), |
| + delegate_(nullptr), |
| + full_card_request_delegate_(full_card_request_delegate), |
| + weak_ptr_factory_(this) {} |
| AutofillPaymentInstrument::~AutofillPaymentInstrument() {} |
| void AutofillPaymentInstrument::InvokePaymentApp( |
| PaymentInstrument::Delegate* delegate) { |
| DCHECK(delegate); |
| + DCHECK(!delegate_); |
| + delegate_ = delegate; |
| + |
| + full_card_request_delegate_->DoFullCardRequest( |
| + credit_card_, weak_ptr_factory_.GetWeakPtr()); |
| +} |
| + |
| +bool AutofillPaymentInstrument::IsValid() { |
| + return credit_card_.IsValid(); |
| +} |
| + |
| +void AutofillPaymentInstrument::OnFullCardRequestSucceeded( |
| + const autofill::CreditCard& card, |
| + const base::string16& cvc) { |
| + DCHECK(delegate_); |
| + credit_card_ = card; |
| std::string stringified_details; |
|
Mathieu
2017/04/04 19:05:47
nit: let's bring this one statement down, where it
anthonyvd
2017/04/05 02:12:37
Done.
|
| - // TODO(mathp): Show the CVC dialog and use the data instead of the |
| - // placeholder string. |
| std::unique_ptr<base::DictionaryValue> response_value = |
| payments::data_util::GetBasicCardResponseFromAutofillCreditCard( |
| - credit_card_, base::ASCIIToUTF16("123"), billing_profiles_, |
| - app_locale_) |
| + credit_card_, cvc, billing_profiles_, app_locale_) |
| .ToDictionaryValue(); |
| base::JSONWriter::Write(*response_value, &stringified_details); |
| - delegate->OnInstrumentDetailsReady(method_name(), stringified_details); |
| + delegate_->OnInstrumentDetailsReady(method_name(), stringified_details); |
| + delegate_ = nullptr; |
|
Mathieu
2017/04/04 19:05:47
any specific reason for this line and line 41? Sin
anthonyvd
2017/04/05 02:12:37
Yeah so this + the DCHECK on line 41 are coming as
|
| } |
| -bool AutofillPaymentInstrument::IsValid() { |
| - return credit_card_.IsValid(); |
| +void AutofillPaymentInstrument::OnFullCardRequestFailed() { |
| + // TODO(anthonyvd): Do something with the error. |
| + delegate_ = nullptr; |
| } |
| } // namespace payments |