summaryrefslogtreecommitdiffstats
path: root/chrome/browser/webdata
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-17 00:06:54 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-17 00:06:54 +0000
commit4ef55f8c1a419b2be13b2086e424d64abc6a11d2 (patch)
treecf0b2079a18b9945e7ee7512671fb75c95dd8467 /chrome/browser/webdata
parent82b23338f5f774258e11dd1e7e86c6216ffbfb18 (diff)
downloadchromium_src-4ef55f8c1a419b2be13b2086e424d64abc6a11d2.zip
chromium_src-4ef55f8c1a419b2be13b2086e424d64abc6a11d2.tar.gz
chromium_src-4ef55f8c1a419b2be13b2086e424d64abc6a11d2.tar.bz2
Autofill: Remove fax number completely.
BUG=81846 TEST=* R=isherman@chromium.org Review URL: http://codereview.chromium.org/7892048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101602 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/webdata')
-rw-r--r--chrome/browser/webdata/autofill_table.cc79
-rw-r--r--chrome/browser/webdata/autofill_table.h8
-rw-r--r--chrome/browser/webdata/autofill_table_unittest.cc44
-rw-r--r--chrome/browser/webdata/web_database_migration_unittest.cc21
4 files changed, 23 insertions, 129 deletions
diff --git a/chrome/browser/webdata/autofill_table.cc b/chrome/browser/webdata/autofill_table.cc
index 0d0591d..fd152e1 100644
--- a/chrome/browser/webdata/autofill_table.cc
+++ b/chrome/browser/webdata/autofill_table.cc
@@ -33,12 +33,6 @@ using webkit_glue::FormField;
namespace {
-// Constants for the |autofill_profile_phones| |type| column.
-enum AutofillPhoneType {
- kAutofillPhoneNumber = 0,
- kAutofillFaxNumber = 1
-};
-
typedef std::vector<Tuple3<int64, string16, string16> > AutofillElementList;
// TODO(dhollowa): Find a common place for this. It is duplicated in
@@ -201,7 +195,8 @@ bool AddAutofillProfilePhonesToProfile(sql::Connection* db,
return false;
}
s.BindString(0, profile->guid());
- s.BindInt(1, kAutofillPhoneNumber);
+ // Value used to be either [(0, phone), (1, fax)] but fax has been removed.
+ s.BindInt(1, 0);
std::vector<string16> numbers;
while (s.Step()) {
@@ -212,29 +207,6 @@ bool AddAutofillProfilePhonesToProfile(sql::Connection* db,
return true;
}
-bool AddAutofillProfileFaxesToProfile(sql::Connection* db,
- AutofillProfile* profile) {
- sql::Statement s(db->GetUniqueStatement(
- "SELECT guid, type, number "
- "FROM autofill_profile_phones "
- "WHERE guid=? AND type=?"));
- if (!s) {
- NOTREACHED() << "Statement prepare failed";
- return false;
- }
- s.BindString(0, profile->guid());
- s.BindInt(1, kAutofillFaxNumber);
-
- std::vector<string16> numbers;
- while (s.Step()) {
- DCHECK_EQ(profile->guid(), s.ColumnString(0));
- numbers.push_back(s.ColumnString16(2));
- }
- profile->SetMultiInfo(PHONE_FAX_WHOLE_NUMBER, numbers);
- return true;
-}
-
-
bool AddAutofillProfileNames(const AutofillProfile& profile,
sql::Connection* db) {
std::vector<string16> first_names;
@@ -296,20 +268,9 @@ bool AddAutofillProfileEmails(const AutofillProfile& profile,
}
bool AddAutofillProfilePhones(const AutofillProfile& profile,
- AutofillPhoneType phone_type,
sql::Connection* db) {
- AutofillFieldType field_type;
- if (phone_type == kAutofillPhoneNumber) {
- field_type = PHONE_HOME_WHOLE_NUMBER;
- } else if (phone_type == kAutofillFaxNumber) {
- field_type = PHONE_FAX_WHOLE_NUMBER;
- } else {
- NOTREACHED();
- return false;
- }
-
std::vector<string16> numbers;
- profile.GetMultiInfo(field_type, &numbers);
+ profile.GetMultiInfo(PHONE_HOME_WHOLE_NUMBER, &numbers);
for (size_t i = 0; i < numbers.size(); ++i) {
// Add the new number.
@@ -322,7 +283,8 @@ bool AddAutofillProfilePhones(const AutofillProfile& profile,
return false;
}
s.BindString(0, profile.guid());
- s.BindInt(1, phone_type);
+ // Value used to be either [(0, phone), (1, fax)] but fax has been removed.
+ s.BindInt(1, 0);
s.BindString16(2, numbers[i]);
if (!s.Run()) {
@@ -330,6 +292,7 @@ bool AddAutofillProfilePhones(const AutofillProfile& profile,
return false;
}
}
+
return true;
}
@@ -341,10 +304,7 @@ bool AddAutofillProfilePieces(const AutofillProfile& profile,
if (!AddAutofillProfileEmails(profile, db))
return false;
- if (!AddAutofillProfilePhones(profile, kAutofillPhoneNumber, db))
- return false;
-
- if (!AddAutofillProfilePhones(profile, kAutofillFaxNumber, db))
+ if (!AddAutofillProfilePhones(profile, db))
return false;
return true;
@@ -773,9 +733,8 @@ bool AutofillTable::GetAutofillTimestamps(const string16& name,
s.BindString16(0, name);
s.BindString16(1, value);
- while (s.Step()) {
+ while (s.Step())
timestamps->push_back(Time::FromTimeT(s.ColumnInt64(0)));
- }
return s.Succeeded();
}
@@ -943,9 +902,6 @@ bool AutofillTable::GetAutofillProfile(const std::string& guid,
// Get associated phone info.
AddAutofillProfilePhonesToProfile(db_, p.get());
- // Get associated fax info.
- AddAutofillProfileFaxesToProfile(db_, p.get());
-
*profile = p.release();
return true;
}
@@ -1006,10 +962,6 @@ bool AutofillTable::UpdateAutofillProfile(const AutofillProfile& profile) {
values[0] = new_profile.GetInfo(PHONE_HOME_WHOLE_NUMBER);
new_profile.SetMultiInfo(PHONE_HOME_WHOLE_NUMBER, values);
- old_profile->GetMultiInfo(PHONE_FAX_WHOLE_NUMBER, &values);
- values[0] = new_profile.GetInfo(PHONE_FAX_WHOLE_NUMBER);
- new_profile.SetMultiInfo(PHONE_FAX_WHOLE_NUMBER, values);
-
return UpdateAutofillProfileMulti(new_profile);
}
@@ -1048,7 +1000,7 @@ bool AutofillTable::UpdateAutofillProfileMulti(const AutofillProfile& profile) {
if (!result)
return result;
- // Remove the old names, emails, and phone/fax numbers.
+ // Remove the old names, emails, and phone numbers.
if (!RemoveAutofillProfilePieces(profile.guid(), db_))
return false;
@@ -1617,8 +1569,7 @@ bool AutofillTable::MigrateToVersion24CleanupOversizedStringFields() {
" length(middle_name), length(last_name), length(email), "
" length(company_name), length(address_line_1), "
" length(address_line_2), length(city), length(state), "
- " length(zipcode), length(country), length(phone), "
- " length(fax)) > 500";
+ " length(zipcode), length(country), length(phone)) > 500";
std::string query = "DELETE FROM autofill_dates WHERE pair_id IN ("
"SELECT pair_id FROM autofill WHERE " + autofill_is_too_big + ")";
@@ -1869,7 +1820,6 @@ bool AutofillTable::MigrateToVersion32UpdateProfilesAndCreditCards() {
"zipcode VARCHAR, "
"country VARCHAR, "
"phone VARCHAR, "
- "fax VARCHAR, "
"date_modified INTEGER NOT NULL DEFAULT 0)")) {
return false;
}
@@ -1878,7 +1828,7 @@ bool AutofillTable::MigrateToVersion32UpdateProfilesAndCreditCards() {
"INSERT INTO autofill_profiles_temp "
"SELECT guid, label, first_name, middle_name, last_name, email, "
"company_name, address_line_1, address_line_2, city, state, "
- "zipcode, country, phone, fax, date_modified "
+ "zipcode, country, phone, date_modified "
"FROM autofill_profiles")) {
return false;
}
@@ -1947,7 +1897,7 @@ bool AutofillTable::MigrateToVersion33ProfilesBasedOnFirstName() {
sql::Statement s(db_->GetUniqueStatement(
"SELECT guid, first_name, middle_name, last_name, email, "
"company_name, address_line_1, address_line_2, city, state, "
- "zipcode, country, phone, fax, date_modified "
+ "zipcode, country, phone, date_modified "
"FROM autofill_profiles"));
while (s.Step()) {
AutofillProfile profile;
@@ -1966,8 +1916,7 @@ bool AutofillTable::MigrateToVersion33ProfilesBasedOnFirstName() {
profile.SetInfo(ADDRESS_HOME_ZIP, s.ColumnString16(10));
profile.SetInfo(ADDRESS_HOME_COUNTRY, s.ColumnString16(11));
profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, s.ColumnString16(12));
- profile.SetInfo(PHONE_FAX_WHOLE_NUMBER, s.ColumnString16(13));
- int64 date_modified = s.ColumnInt64(14);
+ int64 date_modified = s.ColumnInt64(13);
sql::Statement s_insert(db_->GetUniqueStatement(
"INSERT INTO autofill_profiles_temp"
@@ -1990,7 +1939,7 @@ bool AutofillTable::MigrateToVersion33ProfilesBasedOnFirstName() {
if (!s_insert.Run())
return false;
- // Add the other bits: names, emails, and phone/fax.
+ // Add the other bits: names, emails, and phone numbers.
if (!AddAutofillProfilePieces(profile, db_))
return false;
}
diff --git a/chrome/browser/webdata/autofill_table.h b/chrome/browser/webdata/autofill_table.h
index 6418d96..aceef0b 100644
--- a/chrome/browser/webdata/autofill_table.h
+++ b/chrome/browser/webdata/autofill_table.h
@@ -87,9 +87,11 @@ struct FormField;
// associated with a profile.
//
// guid The guid string that identifies the profile to which
-// the phone or fax number belongs.
-// type An integer constant designating either phone or fax type
-// of the number.
+// the phone number belongs.
+// type An integer constant designating either phone type of the
+// number.
+// TODO(jhawkins): Remove the type column and migrate the
+// database.
// number
//
// autofill_profiles_trash
diff --git a/chrome/browser/webdata/autofill_table_unittest.cc b/chrome/browser/webdata/autofill_table_unittest.cc
index ca37e70..4b2e61e 100644
--- a/chrome/browser/webdata/autofill_table_unittest.cc
+++ b/chrome/browser/webdata/autofill_table_unittest.cc
@@ -559,7 +559,6 @@ TEST_F(AutofillTableTest, AutofillProfile) {
home_profile.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90025"));
home_profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
home_profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567"));
- home_profile.SetInfo(PHONE_FAX_WHOLE_NUMBER, ASCIIToUTF16("1915243678"));
Time pre_creation_time = Time::Now();
EXPECT_TRUE(db.GetAutofillTable()->AddAutofillProfile(home_profile));
@@ -640,7 +639,6 @@ TEST_F(AutofillTableTest, AutofillProfile) {
billing_profile.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("10011"));
billing_profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("United States"));
billing_profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181230000"));
- billing_profile.SetInfo(PHONE_FAX_WHOLE_NUMBER, ASCIIToUTF16("1915240000"));
Time pre_modification_time_2 = Time::Now();
EXPECT_TRUE(db.GetAutofillTable()->UpdateAutofillProfileMulti(
billing_profile));
@@ -828,47 +826,6 @@ TEST_F(AutofillTableTest, AutofillProfileMultiValuePhone) {
delete db_profile;
}
-TEST_F(AutofillTableTest, AutofillProfileMultiValueFax) {
- WebDatabase db;
- ASSERT_EQ(sql::INIT_OK, db.Init(file_));
-
- AutofillProfile p;
- const string16 kJohnDoe(ASCIIToUTF16("4151112222"));
- const string16 kJohnPDoe(ASCIIToUTF16("4151113333"));
- std::vector<string16> set_values;
- set_values.push_back(kJohnDoe);
- set_values.push_back(kJohnPDoe);
- p.SetMultiInfo(PHONE_FAX_WHOLE_NUMBER, set_values);
-
- EXPECT_TRUE(db.GetAutofillTable()->AddAutofillProfile(p));
-
- AutofillProfile* db_profile;
- ASSERT_TRUE(db.GetAutofillTable()->GetAutofillProfile(p.guid(), &db_profile));
- EXPECT_EQ(p, *db_profile);
- EXPECT_EQ(0, p.CompareMulti(*db_profile));
- delete db_profile;
-
- // Update the values.
- const string16 kNoOne(ASCIIToUTF16("4151110000"));
- set_values[1] = kNoOne;
- p.SetMultiInfo(PHONE_FAX_WHOLE_NUMBER, set_values);
- 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));
- delete db_profile;
-
- // Delete values.
- set_values.clear();
- p.SetMultiInfo(PHONE_FAX_WHOLE_NUMBER, set_values);
- 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(string16(), db_profile->GetInfo(EMAIL_ADDRESS));
- delete db_profile;
-}
-
TEST_F(AutofillTableTest, AutofillProfileTrash) {
WebDatabase db;
@@ -1071,7 +1028,6 @@ TEST_F(AutofillTableTest, UpdateAutofillProfile) {
profile.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90025"));
profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567"));
- profile.SetInfo(PHONE_FAX_WHOLE_NUMBER, ASCIIToUTF16("1915243678"));
db.GetAutofillTable()->AddAutofillProfile(profile);
// Set a mocked value for the profile's creation time.
diff --git a/chrome/browser/webdata/web_database_migration_unittest.cc b/chrome/browser/webdata/web_database_migration_unittest.cc
index e6e7355..1fe0315 100644
--- a/chrome/browser/webdata/web_database_migration_unittest.cc
+++ b/chrome/browser/webdata/web_database_migration_unittest.cc
@@ -51,7 +51,6 @@ void AutofillProfile31FromStatement(const sql::Statement& s,
profile->SetInfo(ADDRESS_HOME_ZIP, s.ColumnString16(11));
profile->SetInfo(ADDRESS_HOME_COUNTRY, s.ColumnString16(12));
profile->SetInfo(PHONE_HOME_WHOLE_NUMBER, s.ColumnString16(13));
- profile->SetInfo(PHONE_FAX_WHOLE_NUMBER, s.ColumnString16(14));
*date_modified = s.ColumnInt64(15);
profile->set_guid(s.ColumnString(16));
EXPECT_TRUE(guid::IsValidGUID(profile->guid()));
@@ -1167,10 +1166,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
EXPECT_EQ(ASCIIToUTF16("4151112222"), s4.ColumnString16(2));
// John Doe fax.
- ASSERT_TRUE(s4.Step());
- EXPECT_EQ("00580526-FF81-EE2A-0546-1AC593A32E2F", s4.ColumnString(0));
- EXPECT_EQ(1, s4.ColumnInt(1)); // 1 means phone.
- EXPECT_EQ(ASCIIToUTF16("4153334444"), s4.ColumnString16(2));
+ // Gets culled after fax type removed.
// John P. Doe phone.
// Gets culled during migration from 35 to 37 due to merging of John Doe and
@@ -1187,10 +1183,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
EXPECT_EQ(ASCIIToUTF16(""), s4.ColumnString16(2));
// 2 Main Street fax.
- ASSERT_TRUE(s4.Step());
- EXPECT_EQ("4C74A9D8-7EEE-423E-F9C2-E7FA70ED1396", s4.ColumnString(0));
- EXPECT_EQ(1, s4.ColumnInt(1)); // 1 means fax.
- EXPECT_EQ(ASCIIToUTF16(""), s4.ColumnString16(2));
+ // Gets culled after fax type removed.
// 2 Main St phone.
ASSERT_TRUE(s4.Step());
@@ -1199,10 +1192,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
EXPECT_EQ(ASCIIToUTF16(""), s4.ColumnString16(2));
// 2 Main St fax.
- ASSERT_TRUE(s4.Step());
- EXPECT_EQ("722DF5C4-F74A-294A-46F0-31FFDED0D635", s4.ColumnString(0));
- EXPECT_EQ(1, s4.ColumnInt(1)); // 1 means fax.
- EXPECT_EQ(ASCIIToUTF16(""), s4.ColumnString16(2));
+ // Gets culled after fax type removed.
// Note no phone or fax for Alfred E Newman.
@@ -1213,10 +1203,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
EXPECT_EQ(ASCIIToUTF16(""), s4.ColumnString16(2));
// 2 Main St fax.
- ASSERT_TRUE(s4.Step());
- EXPECT_EQ("9E5FE298-62C7-83DF-6293-381BC589183F", s4.ColumnString(0));
- EXPECT_EQ(1, s4.ColumnInt(1)); // 1 means fax.
- EXPECT_EQ(ASCIIToUTF16(""), s4.ColumnString16(2));
+ // Gets culled after fax type removed.
// Should be all.
EXPECT_FALSE(s4.Step());