diff options
author | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-23 22:34:00 +0000 |
---|---|---|
committer | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-23 22:34:00 +0000 |
commit | f2cd8366d10941fc248db85320bee6a8025b18bc (patch) | |
tree | 71818da5f03ff20a1b446e354aba3cb2894ad5e3 /chrome/browser/webdata | |
parent | a999d67a5df08491b6829e4ebb4081681f8f18af (diff) | |
download | chromium_src-f2cd8366d10941fc248db85320bee6a8025b18bc.zip chromium_src-f2cd8366d10941fc248db85320bee6a8025b18bc.tar.gz chromium_src-f2cd8366d10941fc248db85320bee6a8025b18bc.tar.bz2 |
Removed deprecated AutofillProfile::Compare, renamed CompareMulti to Compare, fixed related bugs.
BUG=109797
TEST=unit tests
Review URL: http://codereview.chromium.org/9265023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118750 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/webdata')
-rw-r--r-- | chrome/browser/webdata/autofill_profile_syncable_service.cc | 7 | ||||
-rw-r--r-- | chrome/browser/webdata/autofill_table.cc | 4 | ||||
-rw-r--r-- | chrome/browser/webdata/autofill_table_unittest.cc | 30 |
3 files changed, 20 insertions, 21 deletions
diff --git a/chrome/browser/webdata/autofill_profile_syncable_service.cc b/chrome/browser/webdata/autofill_profile_syncable_service.cc index ee2fc49..892cf88 100644 --- a/chrome/browser/webdata/autofill_profile_syncable_service.cc +++ b/chrome/browser/webdata/autofill_profile_syncable_service.cc @@ -380,7 +380,7 @@ AutofillProfileSyncableService::CreateOrUpdateProfile( // Check if profile appears under a different guid. for (GUIDToProfileMap::iterator i = profile_map->begin(); i != profile_map->end(); ++i) { - if (i->second->CompareMulti(*new_profile) == 0) { + if (i->second->Compare(*new_profile) == 0) { bundle->profiles_to_delete.push_back(i->second->guid()); DVLOG(2) << "[AUTOFILL SYNC]" << "Found in sync db but with a different guid: " @@ -390,7 +390,8 @@ AutofillProfileSyncableService::CreateOrUpdateProfile( << ". Profile to be deleted " << i->second->guid(); profile_map->erase(i); break; - } else if (i->second->PrimaryValue() == new_profile->PrimaryValue()) { + } else if (!i->second->PrimaryValue().empty() && + i->second->PrimaryValue() == new_profile->PrimaryValue()) { // Add it to candidates for merge - if there is no profile with this // guid we will merge them. bundle->candidates_to_merge.insert(std::make_pair(i->second->guid(), @@ -497,7 +498,7 @@ bool AutofillProfileSyncableService::MergeProfile( const AutofillProfile& merge_from, AutofillProfile* merge_into) { merge_into->OverwriteWithOrAddTo(merge_from); - return (merge_into->CompareMulti(merge_from) != 0); + return (merge_into->Compare(merge_from) != 0); } AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const { diff --git a/chrome/browser/webdata/autofill_table.cc b/chrome/browser/webdata/autofill_table.cc index 60f3431..d4a291b 100644 --- a/chrome/browser/webdata/autofill_table.cc +++ b/chrome/browser/webdata/autofill_table.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -876,7 +876,7 @@ bool AutofillTable::UpdateAutofillProfileMulti(const AutofillProfile& profile) { // Preserve appropriate modification dates by not updating unchanged profiles. scoped_ptr<AutofillProfile> old_profile(tmp_profile); - if (old_profile->CompareMulti(profile) == 0) + if (old_profile->Compare(profile) == 0) return true; sql::Statement s(db_->GetUniqueStatement( diff --git a/chrome/browser/webdata/autofill_table_unittest.cc b/chrome/browser/webdata/autofill_table_unittest.cc index 52d457a..2eca221 100644 --- a/chrome/browser/webdata/autofill_table_unittest.cc +++ b/chrome/browser/webdata/autofill_table_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -682,7 +682,7 @@ TEST_F(AutofillTableTest, AutofillProfileMultiValueNames) { AutofillProfile* db_profile; ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(p.guid(), &db_profile)); EXPECT_EQ(p, *db_profile); - EXPECT_EQ(0, p.CompareMulti(*db_profile)); + EXPECT_EQ(0, p.Compare(*db_profile)); delete db_profile; // Update the values. @@ -692,7 +692,7 @@ TEST_F(AutofillTableTest, AutofillProfileMultiValueNames) { EXPECT_TRUE(db.GetAutofillTable()->UpdateAutofillProfileMulti(p)); ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(p.guid(), &db_profile)); EXPECT_EQ(p, *db_profile); - EXPECT_EQ(0, p.CompareMulti(*db_profile)); + EXPECT_EQ(0, p.Compare(*db_profile)); delete db_profile; // Delete values. @@ -701,7 +701,7 @@ TEST_F(AutofillTableTest, AutofillProfileMultiValueNames) { EXPECT_TRUE(db.GetAutofillTable()->UpdateAutofillProfileMulti(p)); ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(p.guid(), &db_profile)); EXPECT_EQ(p, *db_profile); - EXPECT_EQ(0, p.CompareMulti(*db_profile)); + EXPECT_EQ(0, p.Compare(*db_profile)); EXPECT_EQ(string16(), db_profile->GetInfo(NAME_FULL)); delete db_profile; } @@ -723,20 +723,18 @@ TEST_F(AutofillTableTest, AutofillProfileSingleValue) { AutofillProfile* db_profile; ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(p.guid(), &db_profile)); EXPECT_EQ(p, *db_profile); - EXPECT_EQ(0, p.CompareMulti(*db_profile)); + EXPECT_EQ(0, p.Compare(*db_profile)); delete db_profile; - // Update the values. This update is the "single value" update, it should - // not perturb the multi-values following the zeroth entry. This simulates - // the Sync use-case until Sync can be changed to be multi-value aware. const string16 kNoOne(ASCIIToUTF16("No One")); set_values.resize(1); set_values[0] = kNoOne; p.SetMultiInfo(NAME_FULL, set_values); EXPECT_TRUE(db.GetAutofillTable()->UpdateAutofillProfile(p)); ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(p.guid(), &db_profile)); - EXPECT_EQ(p, *db_profile); - EXPECT_NE(0, p.CompareMulti(*db_profile)); + EXPECT_EQ(p.PrimaryValue(), db_profile->PrimaryValue()); + EXPECT_EQ(p.guid(), db_profile->guid()); + EXPECT_NE(0, p.Compare(*db_profile)); db_profile->GetMultiInfo(NAME_FULL, &set_values); ASSERT_EQ(2UL, set_values.size()); EXPECT_EQ(kNoOne, set_values[0]); @@ -761,7 +759,7 @@ TEST_F(AutofillTableTest, AutofillProfileMultiValueEmails) { AutofillProfile* db_profile; ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(p.guid(), &db_profile)); EXPECT_EQ(p, *db_profile); - EXPECT_EQ(0, p.CompareMulti(*db_profile)); + EXPECT_EQ(0, p.Compare(*db_profile)); delete db_profile; // Update the values. @@ -771,7 +769,7 @@ TEST_F(AutofillTableTest, AutofillProfileMultiValueEmails) { EXPECT_TRUE(db.GetAutofillTable()->UpdateAutofillProfileMulti(p)); ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(p.guid(), &db_profile)); EXPECT_EQ(p, *db_profile); - EXPECT_EQ(0, p.CompareMulti(*db_profile)); + EXPECT_EQ(0, p.Compare(*db_profile)); delete db_profile; // Delete values. @@ -780,7 +778,7 @@ TEST_F(AutofillTableTest, AutofillProfileMultiValueEmails) { EXPECT_TRUE(db.GetAutofillTable()->UpdateAutofillProfileMulti(p)); ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(p.guid(), &db_profile)); EXPECT_EQ(p, *db_profile); - EXPECT_EQ(0, p.CompareMulti(*db_profile)); + EXPECT_EQ(0, p.Compare(*db_profile)); EXPECT_EQ(string16(), db_profile->GetInfo(EMAIL_ADDRESS)); delete db_profile; } @@ -802,7 +800,7 @@ TEST_F(AutofillTableTest, AutofillProfileMultiValuePhone) { AutofillProfile* db_profile; ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(p.guid(), &db_profile)); EXPECT_EQ(p, *db_profile); - EXPECT_EQ(0, p.CompareMulti(*db_profile)); + EXPECT_EQ(0, p.Compare(*db_profile)); delete db_profile; // Update the values. @@ -812,7 +810,7 @@ TEST_F(AutofillTableTest, AutofillProfileMultiValuePhone) { EXPECT_TRUE(db.GetAutofillTable()->UpdateAutofillProfileMulti(p)); ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(p.guid(), &db_profile)); EXPECT_EQ(p, *db_profile); - EXPECT_EQ(0, p.CompareMulti(*db_profile)); + EXPECT_EQ(0, p.Compare(*db_profile)); delete db_profile; // Delete values. @@ -821,7 +819,7 @@ TEST_F(AutofillTableTest, AutofillProfileMultiValuePhone) { EXPECT_TRUE(db.GetAutofillTable()->UpdateAutofillProfileMulti(p)); ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(p.guid(), &db_profile)); EXPECT_EQ(p, *db_profile); - EXPECT_EQ(0, p.CompareMulti(*db_profile)); + EXPECT_EQ(0, p.Compare(*db_profile)); EXPECT_EQ(string16(), db_profile->GetInfo(EMAIL_ADDRESS)); delete db_profile; } |