diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-22 00:32:09 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-22 00:32:09 +0000 |
commit | e20e72f56f0e8fc4284452e64f55754be89c7f21 (patch) | |
tree | 464fccf057c614437dc3f60eb72b3a4540be0197 | |
parent | 21bf3da545219f3c7a0bb42e9babce2e3335c544 (diff) | |
download | chromium_src-e20e72f56f0e8fc4284452e64f55754be89c7f21.zip chromium_src-e20e72f56f0e8fc4284452e64f55754be89c7f21.tar.gz chromium_src-e20e72f56f0e8fc4284452e64f55754be89c7f21.tar.bz2 |
Don't treat empty fields as distinguishing fields for autofill
BUG=66953, 67277
TEST=unit_tests --gtest_filter=AutoFillProfileTest.CreateInferredLabelsSkipsEmptyFields
Review URL: http://codereview.chromium.org/5965002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69905 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autofill/autofill_profile.cc | 4 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_profile_unittest.cc | 12 |
2 files changed, 15 insertions, 1 deletions
diff --git a/chrome/browser/autofill/autofill_profile.cc b/chrome/browser/autofill/autofill_profile.cc index 7fc458b..4426ec2 100644 --- a/chrome/browser/autofill/autofill_profile.cc +++ b/chrome/browser/autofill/autofill_profile.cc @@ -446,7 +446,9 @@ void AutoFillProfile::CreateDifferentiatingLabels( std::map<string16, size_t>& field_text_frequencies = field_text_frequencies_by_field[*field]; - found_differentiating_field |= (field_text_frequencies[field_text] == 1); + found_differentiating_field |= + !field_text_frequencies.count(string16()) && + (field_text_frequencies[field_text] == 1); // Once we've found enough non-empty fields, skip over any remaining // fields that are identical across all the profiles. diff --git a/chrome/browser/autofill/autofill_profile_unittest.cc b/chrome/browser/autofill/autofill_profile_unittest.cc index 12e1b06..93e9602 100644 --- a/chrome/browser/autofill/autofill_profile_unittest.cc +++ b/chrome/browser/autofill/autofill_profile_unittest.cc @@ -484,6 +484,18 @@ TEST(AutoFillProfileTest, CreateInferredLabelsSkipsEmptyFields) { EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Gogole"), labels[0]); EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Ggoole"), labels[1]); EXPECT_EQ(ASCIIToUTF16("John Doe, john.doe@example.com, Goolge"), labels[2]); + + // A field must have a non-empty value for each profile to be considered a + // distinguishing field. + profiles[1]->SetInfo(AutoFillType(ADDRESS_HOME_LINE1), + ASCIIToUTF16("88 Nowhere Ave.")); + AutoFillProfile::CreateInferredLabels(&profiles.get(), NULL, UNKNOWN_TYPE, 1, + &labels); + ASSERT_EQ(3U, labels.size()); + EXPECT_EQ(ASCIIToUTF16("John Doe, doe@example.com, Gogole"), labels[0]); + EXPECT_EQ(ASCIIToUTF16("John Doe, 88 Nowhere Ave., doe@example.com, Ggoole"), + labels[1]) << labels[1]; + EXPECT_EQ(ASCIIToUTF16("John Doe, john.doe@example.com"), labels[2]); } TEST(AutoFillProfileTest, IsSubsetOf) { |