summaryrefslogtreecommitdiffstats
path: root/chrome/browser/webdata
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-06 18:53:06 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-06 18:53:06 +0000
commita5d0f5406e4b03cec41f6aea996c2840bfca9efb (patch)
treefeac59d324e10527a1a9db0d0bb69c6f5f7d10c4 /chrome/browser/webdata
parentc90def171223173fc6d679352150368ebf260af2 (diff)
downloadchromium_src-a5d0f5406e4b03cec41f6aea996c2840bfca9efb.zip
chromium_src-a5d0f5406e4b03cec41f6aea996c2840bfca9efb.tar.gz
chromium_src-a5d0f5406e4b03cec41f6aea996c2840bfca9efb.tar.bz2
Revert 68358 - Don't re-save autofill profiles to the web database if they haven't changed.
BUG=65129 TEST=unit_tests --gtest_filter=WebDatabaseTest.Update* Review URL: http://codereview.chromium.org/5610002 TBR=isherman@chromium.org Review URL: http://codereview.chromium.org/5515006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68360 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/webdata')
-rw-r--r--chrome/browser/webdata/web_database.cc16
-rw-r--r--chrome/browser/webdata/web_database.h2
-rw-r--r--chrome/browser/webdata/web_database_unittest.cc162
3 files changed, 0 insertions, 180 deletions
diff --git a/chrome/browser/webdata/web_database.cc b/chrome/browser/webdata/web_database.cc
index 89325c2..2b9c029 100644
--- a/chrome/browser/webdata/web_database.cc
+++ b/chrome/browser/webdata/web_database.cc
@@ -1693,14 +1693,6 @@ bool WebDatabase::GetAutoFillProfiles(
bool WebDatabase::UpdateAutoFillProfile(const AutoFillProfile& profile) {
DCHECK(guid::IsValidGUID(profile.guid()));
-
- // Preserve appropriate modification dates by not updating unchanged profiles.
- AutoFillProfile* tmp_profile = NULL;
- DCHECK(GetAutoFillProfileForGUID(profile.guid(), &tmp_profile));
- scoped_ptr<AutoFillProfile> old_profile(tmp_profile);
- if (*old_profile == profile)
- return true;
-
sql::Statement s(db_.GetUniqueStatement(
"UPDATE autofill_profiles "
"SET guid=?, label=?, first_name=?, middle_name=?, last_name=?, "
@@ -1821,14 +1813,6 @@ bool WebDatabase::GetCreditCards(
bool WebDatabase::UpdateCreditCard(const CreditCard& credit_card) {
DCHECK(guid::IsValidGUID(credit_card.guid()));
-
- // Preserve appropriate modification dates by not updating unchanged cards.
- CreditCard* tmp_credit_card = NULL;
- DCHECK(GetCreditCardForGUID(credit_card.guid(), &tmp_credit_card));
- scoped_ptr<CreditCard> old_credit_card(tmp_credit_card);
- if (*old_credit_card == credit_card)
- return true;
-
sql::Statement s(db_.GetUniqueStatement(
"UPDATE credit_cards "
"SET guid=?, label=?, name_on_card=?, expiration_month=?, "
diff --git a/chrome/browser/webdata/web_database.h b/chrome/browser/webdata/web_database.h
index 17bc19c..2d80437 100644
--- a/chrome/browser/webdata/web_database.h
+++ b/chrome/browser/webdata/web_database.h
@@ -322,8 +322,6 @@ class WebDatabase {
FRIEND_TEST_ALL_PREFIXES(WebDatabaseTest, Autofill_AddFormFieldValues);
FRIEND_TEST_ALL_PREFIXES(WebDatabaseTest, AutoFillProfile);
FRIEND_TEST_ALL_PREFIXES(WebDatabaseTest, CreditCard);
- FRIEND_TEST_ALL_PREFIXES(WebDatabaseTest, UpdateAutoFillProfile);
- FRIEND_TEST_ALL_PREFIXES(WebDatabaseTest, UpdateCreditCard);
FRIEND_TEST_ALL_PREFIXES(WebDatabaseTest,
RemoveAutoFillProfilesAndCreditCardsModifiedBetween);
diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc
index dcae787..3ac4d2b 100644
--- a/chrome/browser/webdata/web_database_unittest.cc
+++ b/chrome/browser/webdata/web_database_unittest.cc
@@ -1635,168 +1635,6 @@ TEST_F(WebDatabaseTest, CreditCard) {
&db_creditcard));
}
-TEST_F(WebDatabaseTest, UpdateAutoFillProfile) {
- WebDatabase db;
- ASSERT_EQ(sql::INIT_OK, db.Init(file_));
-
- // Add a profile to the db.
- AutoFillProfile profile;
- profile.set_label(ASCIIToUTF16("Test Profile"));
- profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("John"));
- profile.SetInfo(AutoFillType(NAME_MIDDLE), ASCIIToUTF16("Q."));
- profile.SetInfo(AutoFillType(NAME_LAST), ASCIIToUTF16("Smith"));
- profile.SetInfo(AutoFillType(EMAIL_ADDRESS), ASCIIToUTF16("js@example.com"));
- profile.SetInfo(AutoFillType(COMPANY_NAME), ASCIIToUTF16("Google"));
- profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE1),
- ASCIIToUTF16("1234 Apple Way"));
- profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE2), ASCIIToUTF16("unit 5"));
- profile.SetInfo(AutoFillType(ADDRESS_HOME_CITY), ASCIIToUTF16("Los Angeles"));
- profile.SetInfo(AutoFillType(ADDRESS_HOME_STATE), ASCIIToUTF16("CA"));
- profile.SetInfo(AutoFillType(ADDRESS_HOME_ZIP), ASCIIToUTF16("90025"));
- profile.SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("US"));
- profile.SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER),
- ASCIIToUTF16("18181234567"));
- profile.SetInfo(AutoFillType(PHONE_FAX_WHOLE_NUMBER),
- ASCIIToUTF16("1915243678"));
- db.AddAutoFillProfile(profile);
-
- // Set a mocked value for the profile's creation time.
- const time_t mock_creation_date = Time::Now().ToTimeT() - 13;
- sql::Statement s_mock_creation_date(db.db_.GetUniqueStatement(
- "UPDATE autofill_profiles SET date_modified = ?"));
- ASSERT_TRUE(s_mock_creation_date);
- s_mock_creation_date.BindInt64(0, mock_creation_date);
- ASSERT_TRUE(s_mock_creation_date.Run());
-
- // Get the profile.
- AutoFillProfile* tmp_profile;
- ASSERT_TRUE(db.GetAutoFillProfileForGUID(profile.guid(), &tmp_profile));
- scoped_ptr<AutoFillProfile> db_profile(tmp_profile);
- EXPECT_EQ(profile, *db_profile);
- sql::Statement s_original(db.db_.GetUniqueStatement(
- "SELECT date_modified FROM autofill_profiles"));
- ASSERT_TRUE(s_original);
- ASSERT_TRUE(s_original.Step());
- EXPECT_EQ(mock_creation_date, s_original.ColumnInt64(0));
- EXPECT_FALSE(s_original.Step());
-
- // Now, update the profile and save the update to the database.
- // The modification date should change to reflect the update.
- profile.SetInfo(AutoFillType(EMAIL_ADDRESS), ASCIIToUTF16("js@smith.xyz"));
- db.UpdateAutoFillProfile(profile);
-
- // Get the profile.
- ASSERT_TRUE(db.GetAutoFillProfileForGUID(profile.guid(), &tmp_profile));
- db_profile.reset(tmp_profile);
- EXPECT_EQ(profile, *db_profile);
- sql::Statement s_updated(db.db_.GetUniqueStatement(
- "SELECT date_modified FROM autofill_profiles"));
- ASSERT_TRUE(s_updated);
- ASSERT_TRUE(s_updated.Step());
- EXPECT_LT(mock_creation_date, s_updated.ColumnInt64(0));
- EXPECT_FALSE(s_updated.Step());
-
- // Set a mocked value for the profile's modification time.
- const time_t mock_modification_date = Time::Now().ToTimeT() - 7;
- sql::Statement s_mock_modification_date(db.db_.GetUniqueStatement(
- "UPDATE autofill_profiles SET date_modified = ?"));
- ASSERT_TRUE(s_mock_modification_date);
- s_mock_modification_date.BindInt64(0, mock_modification_date);
- ASSERT_TRUE(s_mock_modification_date.Run());
-
- // Finally, call into |UpdateAutoFillProfile()| without changing the profile.
- // The modification date should not change.
- db.UpdateAutoFillProfile(profile);
-
- // Get the profile.
- ASSERT_TRUE(db.GetAutoFillProfileForGUID(profile.guid(), &tmp_profile));
- db_profile.reset(tmp_profile);
- EXPECT_EQ(profile, *db_profile);
- sql::Statement s_unchanged(db.db_.GetUniqueStatement(
- "SELECT date_modified FROM autofill_profiles"));
- ASSERT_TRUE(s_unchanged);
- ASSERT_TRUE(s_unchanged.Step());
- EXPECT_EQ(mock_modification_date, s_unchanged.ColumnInt64(0));
- EXPECT_FALSE(s_unchanged.Step());
-}
-
-TEST_F(WebDatabaseTest, UpdateCreditCard) {
- WebDatabase db;
- ASSERT_EQ(sql::INIT_OK, db.Init(file_));
-
- // Add a credit card to the db.
- CreditCard credit_card;
- credit_card.set_label(ASCIIToUTF16("Test Credit Card"));
- credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME),
- ASCIIToUTF16("Jack Torrance"));
- credit_card.SetInfo(AutoFillType(CREDIT_CARD_NUMBER),
- ASCIIToUTF16("1234567890123456"));
- credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH),
- ASCIIToUTF16("04"));
- credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR),
- ASCIIToUTF16("2013"));
- db.AddCreditCard(credit_card);
-
- // Set a mocked value for the credit card's creation time.
- const time_t mock_creation_date = Time::Now().ToTimeT() - 13;
- sql::Statement s_mock_creation_date(db.db_.GetUniqueStatement(
- "UPDATE credit_cards SET date_modified = ?"));
- ASSERT_TRUE(s_mock_creation_date);
- s_mock_creation_date.BindInt64(0, mock_creation_date);
- ASSERT_TRUE(s_mock_creation_date.Run());
-
- // Get the credit card.
- CreditCard* tmp_credit_card;
- ASSERT_TRUE(db.GetCreditCardForGUID(credit_card.guid(), &tmp_credit_card));
- scoped_ptr<CreditCard> db_credit_card(tmp_credit_card);
- EXPECT_EQ(credit_card, *db_credit_card);
- sql::Statement s_original(db.db_.GetUniqueStatement(
- "SELECT date_modified FROM credit_cards"));
- ASSERT_TRUE(s_original);
- ASSERT_TRUE(s_original.Step());
- EXPECT_EQ(mock_creation_date, s_original.ColumnInt64(0));
- EXPECT_FALSE(s_original.Step());
-
- // Now, update the credit card and save the update to the database.
- // The modification date should change to reflect the update.
- credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("01"));
- db.UpdateCreditCard(credit_card);
-
- // Get the credit card.
- ASSERT_TRUE(db.GetCreditCardForGUID(credit_card.guid(), &tmp_credit_card));
- db_credit_card.reset(tmp_credit_card);
- EXPECT_EQ(credit_card, *db_credit_card);
- sql::Statement s_updated(db.db_.GetUniqueStatement(
- "SELECT date_modified FROM credit_cards"));
- ASSERT_TRUE(s_updated);
- ASSERT_TRUE(s_updated.Step());
- EXPECT_LT(mock_creation_date, s_updated.ColumnInt64(0));
- EXPECT_FALSE(s_updated.Step());
-
- // Set a mocked value for the credit card's modification time.
- const time_t mock_modification_date = Time::Now().ToTimeT() - 7;
- sql::Statement s_mock_modification_date(db.db_.GetUniqueStatement(
- "UPDATE credit_cards SET date_modified = ?"));
- ASSERT_TRUE(s_mock_modification_date);
- s_mock_modification_date.BindInt64(0, mock_modification_date);
- ASSERT_TRUE(s_mock_modification_date.Run());
-
- // Finally, call into |UpdateCreditCard()| without changing the credit card.
- // The modification date should not change.
- db.UpdateCreditCard(credit_card);
-
- // Get the profile.
- ASSERT_TRUE(db.GetCreditCardForGUID(credit_card.guid(), &tmp_credit_card));
- db_credit_card.reset(tmp_credit_card);
- EXPECT_EQ(credit_card, *db_credit_card);
- sql::Statement s_unchanged(db.db_.GetUniqueStatement(
- "SELECT date_modified FROM credit_cards"));
- ASSERT_TRUE(s_unchanged);
- ASSERT_TRUE(s_unchanged.Step());
- EXPECT_EQ(mock_modification_date, s_unchanged.ColumnInt64(0));
- EXPECT_FALSE(s_unchanged.Step());
-}
-
TEST_F(WebDatabaseTest, RemoveAutoFillProfilesAndCreditCardsModifiedBetween) {
WebDatabase db;
ASSERT_EQ(sql::INIT_OK, db.Init(file_));