Index: components/autofill/core/browser/credit_card.cc |
diff --git a/components/autofill/core/browser/credit_card.cc b/components/autofill/core/browser/credit_card.cc |
index 0e54c44176abd4a59c4418bb569331a95469e561..694260ddeac4d1ab048bac9b230fe53a499bf204 100644 |
--- a/components/autofill/core/browser/credit_card.cc |
+++ b/components/autofill/core/browser/credit_card.cc |
@@ -512,6 +512,19 @@ base::string16 CreditCard::TypeAndLastFourDigits() const { |
return type + base::string16(kMidlineEllipsis) + digits; |
} |
+base::string16 CreditCard::BankNameAndLastFourDigits() const { |
+ base::string16 digits = LastFourDigits(); |
+ // The length of bank_name will be at most 8 digits. |
+ if (digits.empty()) |
+ return ASCIIToUTF16(bank_name_); |
+ size_t bank_name_length = 8; |
+ if (bank_name_.size() < bank_name_length) { |
+ bank_name_length = bank_name_.size(); |
+ } |
+ return ASCIIToUTF16(bank_name_.substr(0, bank_name_length)) + |
+ base::string16(kMidlineEllipsis) + digits; |
+} |
+ |
base::string16 CreditCard::AbbreviatedExpirationDateForDisplay() const { |
base::string16 month = ExpirationMonthAsString(); |
base::string16 year = Expiration2DigitYearAsString(); |
@@ -538,6 +551,7 @@ void CreditCard::operator=(const CreditCard& credit_card) { |
server_id_ = credit_card.server_id_; |
server_status_ = credit_card.server_status_; |
billing_address_id_ = credit_card.billing_address_id_; |
+ bank_name_ = credit_card.bank_name_; |
set_guid(credit_card.guid()); |
set_origin(credit_card.origin()); |
@@ -653,6 +667,10 @@ int CreditCard::Compare(const CreditCard& credit_card) const { |
if (comparison != 0) |
return comparison; |
+ comparison = bank_name_.compare(credit_card.bank_name_); |
+ if (comparison != 0) |
+ return comparison; |
+ |
if (static_cast<int>(server_status_) < |
static_cast<int>(credit_card.server_status_)) |
return -1; |