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 #include "components/payments/core/autofill_payment_instrument.h" | 5 #include "components/payments/core/autofill_payment_instrument.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 bool AutofillPaymentInstrument::IsValidForCanMakePayment() { | 96 bool AutofillPaymentInstrument::IsValidForCanMakePayment() { |
97 autofill::CreditCardCompletionStatus status = | 97 autofill::CreditCardCompletionStatus status = |
98 autofill::GetCompletionStatusForCard(credit_card_, app_locale_, | 98 autofill::GetCompletionStatusForCard(credit_card_, app_locale_, |
99 billing_profiles_); | 99 billing_profiles_); |
100 // Card has to have a cardholder name and number for the purposes of | 100 // Card has to have a cardholder name and number for the purposes of |
101 // CanMakePayment. An expired card is still valid at this stage. | 101 // CanMakePayment. An expired card is still valid at this stage. |
102 return !(status & autofill::CREDIT_CARD_NO_CARDHOLDER || | 102 return !(status & autofill::CREDIT_CARD_NO_CARDHOLDER || |
103 status & autofill::CREDIT_CARD_NO_NUMBER); | 103 status & autofill::CREDIT_CARD_NO_NUMBER); |
104 } | 104 } |
105 | 105 |
| 106 void AutofillPaymentInstrument::RecordUse() { |
| 107 // Record the use of the credit card. |
| 108 payment_request_delegate_->GetPersonalDataManager()->RecordUseOf( |
| 109 credit_card_); |
| 110 } |
| 111 |
106 void AutofillPaymentInstrument::OnFullCardRequestSucceeded( | 112 void AutofillPaymentInstrument::OnFullCardRequestSucceeded( |
107 const autofill::CreditCard& card, | 113 const autofill::CreditCard& card, |
108 const base::string16& cvc) { | 114 const base::string16& cvc) { |
109 DCHECK(delegate_); | 115 DCHECK(delegate_); |
110 credit_card_ = card; | 116 credit_card_ = card; |
111 cvc_ = cvc; | 117 cvc_ = cvc; |
112 is_waiting_for_card_unmask_ = false; | 118 is_waiting_for_card_unmask_ = false; |
113 | 119 |
114 if (!is_waiting_for_billing_address_normalization_) | 120 if (!is_waiting_for_billing_address_normalization_) |
115 GenerateBasicCardResponse(); | 121 GenerateBasicCardResponse(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 .ToDictionaryValue(); | 157 .ToDictionaryValue(); |
152 std::string stringified_details; | 158 std::string stringified_details; |
153 base::JSONWriter::Write(*response_value, &stringified_details); | 159 base::JSONWriter::Write(*response_value, &stringified_details); |
154 delegate_->OnInstrumentDetailsReady(method_name(), stringified_details); | 160 delegate_->OnInstrumentDetailsReady(method_name(), stringified_details); |
155 | 161 |
156 delegate_ = nullptr; | 162 delegate_ = nullptr; |
157 cvc_ = base::UTF8ToUTF16(""); | 163 cvc_ = base::UTF8ToUTF16(""); |
158 } | 164 } |
159 | 165 |
160 } // namespace payments | 166 } // namespace payments |
OLD | NEW |