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 232fca5dc92e1fc7b6abd0db7c57add4e5e1eac9..a74a85e8de9ef60e84f6808c67afbfcb7724d7cb 100644 |
--- a/components/autofill/core/browser/credit_card.cc |
+++ b/components/autofill/core/browser/credit_card.cc |
@@ -379,7 +379,7 @@ base::string16 CreditCard::GetInfo(const AutofillType& type, |
// Web pages should never actually be filled by a masked server card, |
// but this function is used at the preview stage. |
if (record_type() == MASKED_SERVER_CARD) |
- return TypeAndLastFourDigits(); |
+ return TypeAndLastFourDigitsForDisplay(); |
return StripSeparators(number_); |
} |
@@ -430,7 +430,7 @@ const std::pair<base::string16, base::string16> CreditCard::LabelPieces() |
if (number().empty()) |
return std::make_pair(name_on_card_, base::string16()); |
- base::string16 obfuscated_cc_number = TypeAndLastFourDigits(); |
+ base::string16 obfuscated_cc_number = TypeAndLastFourDigitsForDisplay(); |
// No expiration date set. |
if (!expiration_month_ || !expiration_year_) |
return std::make_pair(obfuscated_cc_number, base::string16()); |
@@ -486,21 +486,36 @@ base::string16 CreditCard::LastFourDigits() const { |
return number.substr(number.size() - kNumLastDigits, kNumLastDigits); |
} |
+base::string16 CreditCard::LastFourDigitsForDisplay() const { |
+ base::string16 digits = LastFourDigits(); |
+ // Prepend the midline horizontal ellipsis (U+22EF). |
+ // TODO(estade): i18n? |
+ return digits.empty() ? base::string16() |
+ : base::UTF8ToUTF16("\xE2\x8B\xAF") + digits; |
+} |
+ |
base::string16 CreditCard::TypeForDisplay() const { |
return CreditCard::TypeForDisplay(type_); |
} |
-base::string16 CreditCard::TypeAndLastFourDigits() const { |
+base::string16 CreditCard::TypeAndLastFourDigitsForDisplay() const { |
base::string16 type = TypeForDisplay(); |
- base::string16 digits = LastFourDigits(); |
+ base::string16 digits = LastFourDigitsForDisplay(); |
if (digits.empty()) |
return type; |
- // The separator character is a non breaking space and a horizontal midline |
- // ellipsis. |
- // TODO(estade): i18n? |
- return type + base::UTF8ToUTF16("\xC2\xA0\xE2\x8B\xAF") + digits; |
+ // The separator character is a non breaking space. |
+ return type + base::UTF8ToUTF16("\xC2\xA0") + digits; |
+} |
+ |
+base::string16 CreditCard::AbbreviatedExpirationDateForDisplay() const { |
+ base::string16 month = ExpirationMonthAsString(); |
+ base::string16 year = Expiration2DigitYearAsString(); |
+ return month.empty() || year.empty() |
+ ? base::string16() |
+ : l10n_util::GetStringFUTF16( |
+ IDS_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE_ABBR, month, year); |
} |
void CreditCard::operator=(const CreditCard& credit_card) { |
@@ -608,7 +623,8 @@ bool CreditCard::IsLocalDuplicateOfServerCard(const CreditCard& other) const { |
return StripSeparators(number_) == StripSeparators(other.number_); |
// For masked cards, this is the best we can do to compare card numbers. |
- return TypeAndLastFourDigits() == other.TypeAndLastFourDigits(); |
+ return TypeAndLastFourDigitsForDisplay() == |
+ other.TypeAndLastFourDigitsForDisplay(); |
} |
bool CreditCard::operator==(const CreditCard& credit_card) const { |