Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: components/payments/core/autofill_payment_instrument.cc

Issue 2874873002: [Payments] Record use stats after payment request completion. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // Record the use of the billing address.
Mathieu 2017/05/11 01:25:27 Yeah I'm not sure about that one, because we use a
sebsg 2017/05/11 17:49:18 Done.
112 DCHECK(credit_card_.billing_address_id() != "");
113 payment_request_delegate_->GetPersonalDataManager()->RecordUseOf(
114 *(payment_request_delegate_->GetPersonalDataManager()->GetProfileByGUID(
115 credit_card_.billing_address_id())));
116 }
117
106 void AutofillPaymentInstrument::OnFullCardRequestSucceeded( 118 void AutofillPaymentInstrument::OnFullCardRequestSucceeded(
107 const autofill::CreditCard& card, 119 const autofill::CreditCard& card,
108 const base::string16& cvc) { 120 const base::string16& cvc) {
109 DCHECK(delegate_); 121 DCHECK(delegate_);
110 credit_card_ = card; 122 credit_card_ = card;
111 cvc_ = cvc; 123 cvc_ = cvc;
112 is_waiting_for_card_unmask_ = false; 124 is_waiting_for_card_unmask_ = false;
113 125
114 if (!is_waiting_for_billing_address_normalization_) 126 if (!is_waiting_for_billing_address_normalization_)
115 GenerateBasicCardResponse(); 127 GenerateBasicCardResponse();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 .ToDictionaryValue(); 163 .ToDictionaryValue();
152 std::string stringified_details; 164 std::string stringified_details;
153 base::JSONWriter::Write(*response_value, &stringified_details); 165 base::JSONWriter::Write(*response_value, &stringified_details);
154 delegate_->OnInstrumentDetailsReady(method_name(), stringified_details); 166 delegate_->OnInstrumentDetailsReady(method_name(), stringified_details);
155 167
156 delegate_ = nullptr; 168 delegate_ = nullptr;
157 cvc_ = base::UTF8ToUTF16(""); 169 cvc_ = base::UTF8ToUTF16("");
158 } 170 }
159 171
160 } // namespace payments 172 } // namespace payments
OLDNEW
« no previous file with comments | « components/payments/core/autofill_payment_instrument.h ('k') | components/payments/core/payment_instrument.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698