diff options
author | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-09 00:19:55 +0000 |
---|---|---|
committer | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-09 00:19:55 +0000 |
commit | f3fdcc774f633efe8a66dcdf95b2e123153502c4 (patch) | |
tree | 558b419a8a75e47b9d6b8067128c101599e7ebf0 | |
parent | 5fc206694689fc42f608ba21cf797272209e203c (diff) | |
download | chromium_src-f3fdcc774f633efe8a66dcdf95b2e123153502c4.zip chromium_src-f3fdcc774f633efe8a66dcdf95b2e123153502c4.tar.gz chromium_src-f3fdcc774f633efe8a66dcdf95b2e123153502c4.tar.bz2 |
Fix for Autofill credit card label should be non-empty even when there is no credit card number
BUG=65174
TEST=unit-tested
Review URL: http://codereview.chromium.org/6627002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77381 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autofill/autofill_manager.cc | 11 | ||||
-rw-r--r-- | chrome/browser/autofill/credit_card.cc | 2 | ||||
-rw-r--r-- | chrome/browser/autofill/credit_card_unittest.cc | 4 |
3 files changed, 13 insertions, 4 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index 9ca8737..4dbc8b1 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -861,8 +861,17 @@ void AutofillManager::GetCreditCardSuggestions(FormStructure* form, if (type.field_type() == CREDIT_CARD_NUMBER) creditcard_field_value = credit_card->ObfuscatedNumber(); + string16 label; + if (credit_card->number().empty()) { + // If there is no CC number, return name to show something. + label = credit_card->GetFieldText(AutofillType(CREDIT_CARD_NAME)); + } else { + label = kCreditCardPrefix; + label.append(credit_card->LastFourDigits()); + } + values->push_back(creditcard_field_value); - labels->push_back(kCreditCardPrefix + credit_card->LastFourDigits()); + labels->push_back(label); icons->push_back(credit_card->type()); unique_ids->push_back(PackGUIDs(credit_card->guid(), std::string())); } diff --git a/chrome/browser/autofill/credit_card.cc b/chrome/browser/autofill/credit_card.cc index 3954a99..442c1e6 100644 --- a/chrome/browser/autofill/credit_card.cc +++ b/chrome/browser/autofill/credit_card.cc @@ -368,7 +368,7 @@ string16 CreditCard::ObfuscatedNumber() const { string16 CreditCard::PreviewSummary() const { string16 preview; if (number().empty()) - return preview; // No CC number, means empty preview. + return name_on_card_; // No CC number, return name only. string16 obfuscated_cc_number = ObfuscatedNumber(); if (!expiration_month() || !expiration_year()) return obfuscated_cc_number; // No expiration date set. diff --git a/chrome/browser/autofill/credit_card_unittest.cc b/chrome/browser/autofill/credit_card_unittest.cc index 009a4f7..9de4446 100644 --- a/chrome/browser/autofill/credit_card_unittest.cc +++ b/chrome/browser/autofill/credit_card_unittest.cc @@ -26,7 +26,7 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { autofill_test::SetCreditCardInfo(&credit_card00, "John Dillinger", "", "", ""); string16 summary00 = credit_card00.PreviewSummary(); - EXPECT_EQ(string16(), summary00); + EXPECT_EQ(string16(ASCIIToUTF16("John Dillinger")), summary00); string16 obfuscated00 = credit_card00.ObfuscatedNumber(); EXPECT_EQ(string16(), obfuscated00); @@ -35,7 +35,7 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { autofill_test::SetCreditCardInfo(&credit_card1, "John Dillinger", "", "01", "2010"); string16 summary1 = credit_card1.PreviewSummary(); - EXPECT_EQ(string16(), summary1); + EXPECT_EQ(string16(ASCIIToUTF16("John Dillinger")), summary1); string16 obfuscated1 = credit_card1.ObfuscatedNumber(); EXPECT_EQ(string16(), obfuscated1); |