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

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

Issue 2913223002: Make payment instrument labels dynamic (Closed)
Patch Set: Created 3 years, 6 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 12 matching lines...) Expand all
23 namespace payments { 23 namespace payments {
24 24
25 AutofillPaymentInstrument::AutofillPaymentInstrument( 25 AutofillPaymentInstrument::AutofillPaymentInstrument(
26 const std::string& method_name, 26 const std::string& method_name,
27 const autofill::CreditCard& card, 27 const autofill::CreditCard& card,
28 const std::vector<autofill::AutofillProfile*>& billing_profiles, 28 const std::vector<autofill::AutofillProfile*>& billing_profiles,
29 const std::string& app_locale, 29 const std::string& app_locale,
30 PaymentRequestDelegate* payment_request_delegate) 30 PaymentRequestDelegate* payment_request_delegate)
31 : PaymentInstrument( 31 : PaymentInstrument(
32 method_name, 32 method_name,
33 /* label= */ card.NetworkAndLastFourDigits(),
34 /* sublabel= */
35 card.GetInfo(autofill::AutofillType(autofill::CREDIT_CARD_NAME_FULL),
36 app_locale),
37 autofill::data_util::GetPaymentRequestData(card.network()) 33 autofill::data_util::GetPaymentRequestData(card.network())
38 .icon_resource_id, 34 .icon_resource_id,
39 PaymentInstrument::Type::AUTOFILL), 35 PaymentInstrument::Type::AUTOFILL),
40 credit_card_(card), 36 credit_card_(card),
41 billing_profiles_(billing_profiles), 37 billing_profiles_(billing_profiles),
42 app_locale_(app_locale), 38 app_locale_(app_locale),
43 delegate_(nullptr), 39 delegate_(nullptr),
44 payment_request_delegate_(payment_request_delegate), 40 payment_request_delegate_(payment_request_delegate),
45 weak_ptr_factory_(this) {} 41 weak_ptr_factory_(this) {}
46 AutofillPaymentInstrument::~AutofillPaymentInstrument() {} 42 AutofillPaymentInstrument::~AutofillPaymentInstrument() {}
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 return !(status & autofill::CREDIT_CARD_NO_CARDHOLDER || 98 return !(status & autofill::CREDIT_CARD_NO_CARDHOLDER ||
103 status & autofill::CREDIT_CARD_NO_NUMBER); 99 status & autofill::CREDIT_CARD_NO_NUMBER);
104 } 100 }
105 101
106 void AutofillPaymentInstrument::RecordUse() { 102 void AutofillPaymentInstrument::RecordUse() {
107 // Record the use of the credit card. 103 // Record the use of the credit card.
108 payment_request_delegate_->GetPersonalDataManager()->RecordUseOf( 104 payment_request_delegate_->GetPersonalDataManager()->RecordUseOf(
109 credit_card_); 105 credit_card_);
110 } 106 }
111 107
108 base::string16 AutofillPaymentInstrument::GetLabel() const {
109 return credit_card_.NetworkAndLastFourDigits();
110 }
111
112 base::string16 AutofillPaymentInstrument::GetSublabel() const {
113 return credit_card_.GetInfo(
114 autofill::AutofillType(autofill::CREDIT_CARD_NAME_FULL), app_locale_);
115 }
116
112 void AutofillPaymentInstrument::OnFullCardRequestSucceeded( 117 void AutofillPaymentInstrument::OnFullCardRequestSucceeded(
113 const autofill::CreditCard& card, 118 const autofill::CreditCard& card,
114 const base::string16& cvc) { 119 const base::string16& cvc) {
115 DCHECK(delegate_); 120 DCHECK(delegate_);
116 credit_card_ = card; 121 credit_card_ = card;
117 cvc_ = cvc; 122 cvc_ = cvc;
118 is_waiting_for_card_unmask_ = false; 123 is_waiting_for_card_unmask_ = false;
119 124
120 if (!is_waiting_for_billing_address_normalization_) 125 if (!is_waiting_for_billing_address_normalization_)
121 GenerateBasicCardResponse(); 126 GenerateBasicCardResponse();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 .ToDictionaryValue(); 162 .ToDictionaryValue();
158 std::string stringified_details; 163 std::string stringified_details;
159 base::JSONWriter::Write(*response_value, &stringified_details); 164 base::JSONWriter::Write(*response_value, &stringified_details);
160 delegate_->OnInstrumentDetailsReady(method_name(), stringified_details); 165 delegate_->OnInstrumentDetailsReady(method_name(), stringified_details);
161 166
162 delegate_ = nullptr; 167 delegate_ = nullptr;
163 cvc_ = base::UTF8ToUTF16(""); 168 cvc_ = base::UTF8ToUTF16("");
164 } 169 }
165 170
166 } // namespace payments 171 } // 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