summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-20 23:12:31 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-20 23:12:31 +0000
commit89ef2e4ef9117683a4e22da5976bfbc08b9bd1b1 (patch)
tree36c59f46039331bf19504a73593bb6a19dc833cf /chrome/browser/autofill
parentffec8075260e4b7157aea414b679e7df6da61f4d (diff)
downloadchromium_src-89ef2e4ef9117683a4e22da5976bfbc08b9bd1b1.zip
chromium_src-89ef2e4ef9117683a4e22da5976bfbc08b9bd1b1.tar.gz
chromium_src-89ef2e4ef9117683a4e22da5976bfbc08b9bd1b1.tar.bz2
AutoFill: Don't match empty profile values with empty field values.
BUG=none TEST=AutoFillManagerTest.* Review URL: http://codereview.chromium.org/1733001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45104 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r--chrome/browser/autofill/autofill_manager.cc6
-rw-r--r--chrome/browser/autofill/autofill_manager_unittest.cc8
2 files changed, 12 insertions, 2 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index ce06a48..f0e72d6 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -502,7 +502,8 @@ void AutoFillManager::GetProfileSuggestions(const FormField& field,
// The value of the stored data for this field type in the |profile|.
string16 profile_field_value = profile->GetFieldText(AutoFillType(type));
- if (StartsWith(profile_field_value, field.value(), false)) {
+ if (!profile_field_value.empty() &&
+ StartsWith(profile_field_value, field.value(), false)) {
values->push_back(profile_field_value);
labels->push_back(profile->Label());
}
@@ -526,7 +527,8 @@ void AutoFillManager::GetCreditCardSuggestions(const FormField& field,
// The value of the stored data for this field type in the |credit_card|.
string16 creditcard_field_value =
credit_card->GetFieldText(AutoFillType(type));
- if (StartsWith(creditcard_field_value, field.value(), false)) {
+ if (!creditcard_field_value.empty() &&
+ StartsWith(creditcard_field_value, field.value(), false)) {
values->push_back(credit_card->ObfuscatedNumber());
labels->push_back(credit_card->Label());
}
diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
index 91ef6ea..65b2ca0 100644
--- a/chrome/browser/autofill/autofill_manager_unittest.cc
+++ b/chrome/browser/autofill/autofill_manager_unittest.cc
@@ -49,6 +49,10 @@ class TestPersonalDataManager : public PersonalDataManager {
"Texas", "79401", "USA", "23456789012",
"");
profiles->push_back(profile);
+ profile = new AutoFillProfile;
+ autofill_unittest::SetProfileInfo(profile, "Empty", "", "", "", "", "", "",
+ "", "", "", "", "", "", "");
+ profiles->push_back(profile);
}
void CreateTestCreditCards(ScopedVector<CreditCard>* credit_cards) {
@@ -62,6 +66,10 @@ class TestPersonalDataManager : public PersonalDataManager {
"Mastercard", "0987654321098765", "10",
"2014", "678", "", "");
credit_cards->push_back(credit_card);
+ credit_card = new CreditCard;
+ autofill_unittest::SetCreditCardInfo(credit_card, "Empty", "", "", "", "",
+ "", "", "", "");
+ credit_cards->push_back(credit_card);
}
DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager);