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

Unified Diff: components/autofill/core/browser/personal_data_manager.cc

Issue 447903003: Autofill: improve GetCreditCardSuggestions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ah so there were tests after all Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/personal_data_manager.cc
diff --git a/components/autofill/core/browser/personal_data_manager.cc b/components/autofill/core/browser/personal_data_manager.cc
index d5645559cc3f6cd51d6e9dc338042914599e35ba..a0dc658f0356e5633f23d18a16c25986bce4f6d9 100644
--- a/components/autofill/core/browser/personal_data_manager.cc
+++ b/components/autofill/core/browser/personal_data_manager.cc
@@ -671,11 +671,18 @@ void PersonalDataManager::GetCreditCardSuggestions(
if (type.GetStorableType() == CREDIT_CARD_NUMBER)
creditcard_field_value = credit_card->ObfuscatedNumber();
+ // If the value is the card number, the label is the expiration date.
+ // Otherwise the label is the card number, or if that is empty the
+ // cardholder name. The label should never repeat the value.
base::string16 label;
- if (credit_card->number().empty()) {
- // If there is no CC number, return name to show something.
- label =
- credit_card->GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_);
+ if (type.GetStorableType() == CREDIT_CARD_NUMBER) {
+ label = credit_card->GetInfo(
+ AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_);
+ } else if (credit_card->number().empty()) {
+ if (type.GetStorableType() != CREDIT_CARD_NAME) {
+ label =
+ credit_card->GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_);
+ }
} else {
label = kCreditCardPrefix;
label.append(credit_card->LastFourDigits());

Powered by Google App Engine
This is Rietveld 408576698