Index: components/autofill/core/browser/webdata/autofill_table.cc |
diff --git a/components/autofill/core/browser/webdata/autofill_table.cc b/components/autofill/core/browser/webdata/autofill_table.cc |
index 279015e4a4ec6c42ece290508f454c09b9edd2f7..c999d5eb0c484de2e8ad78557db3e03d9e8db5c8 100644 |
--- a/components/autofill/core/browser/webdata/autofill_table.cc |
+++ b/components/autofill/core/browser/webdata/autofill_table.cc |
@@ -571,6 +571,9 @@ bool AutofillTable::MigrateToVersion(int version, |
case 61: |
*update_compatible_version = false; |
return MigrateToVersion61AddUsageStats(); |
+ case 62: |
+ *update_compatible_version = false; |
+ return MigrateToVersion62AddServerRecipientName(); |
} |
return true; |
} |
@@ -1001,6 +1004,7 @@ bool AutofillTable::GetAutofillServerProfiles( |
sql::Statement s(db_->GetUniqueStatement( |
"SELECT " |
"id," |
+ "recipient_name," |
"company_name," |
"street_address," |
"address_1," // ADDRESS_HOME_STATE |
@@ -1018,6 +1022,7 @@ bool AutofillTable::GetAutofillServerProfiles( |
scoped_ptr<AutofillProfile> profile(new AutofillProfile( |
AutofillProfile::SERVER_PROFILE, s.ColumnString(index++))); |
+ profile->SetRawInfo(NAME_FULL, s.ColumnString16(index++)); |
profile->SetRawInfo(COMPANY_NAME, s.ColumnString16(index++)); |
profile->SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, s.ColumnString16(index++)); |
profile->SetRawInfo(ADDRESS_HOME_STATE, s.ColumnString16(index++)); |
@@ -1046,6 +1051,7 @@ void AutofillTable::SetAutofillServerProfiles( |
sql::Statement insert(db_->GetUniqueStatement( |
"INSERT INTO server_addresses(" |
"id," |
+ "recipient_name," |
"company_name," |
"street_address," |
"address_1," // ADDRESS_HOME_STATE |
@@ -1056,12 +1062,13 @@ void AutofillTable::SetAutofillServerProfiles( |
"sorting_code," // ADDRESS_HOME_SORTING_CODE |
"country_code," // ADDRESS_HOME_COUNTRY |
"language_code) " |
- "VALUES (?,?,?,?,?,?,?,?,?,?,?)")); |
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?,?)")); |
for (const auto& profile : profiles) { |
DCHECK(profile.record_type() == AutofillProfile::SERVER_PROFILE); |
int index = 0; |
insert.BindString(index++, profile.server_id()); |
+ insert.BindString16(index++, profile.GetRawInfo(NAME_FULL)); |
insert.BindString16(index++, profile.GetRawInfo(COMPANY_NAME)); |
insert.BindString16(index++, |
profile.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS)); |
@@ -1743,6 +1750,12 @@ bool AutofillTable::InitUnmaskedCreditCardsTable() { |
bool AutofillTable::InitServerAddressesTable() { |
if (!db_->DoesTableExist("server_addresses")) { |
+ // The space after language_code is necessary to make the schemas match |
Evan Stade
2015/02/25 23:02:00
I don't think this comment is super necessary. Oth
brettw
2015/02/26 18:54:28
I kept it but pared it down a lot. When I was work
Evan Stade
2015/02/26 19:23:27
right, but it seems unlikely people will see this
|
+ // when creating a new table (where sqlite just saves our literal string |
+ // provided here), and when we do the alter table to append the column |
+ // in version 62 (where sqlite appends it to the string itself and adds |
+ // the space). This makes the upgrade tests pass which just does a dumb |
+ // string compare on the schemas. |
if (!db_->Execute("CREATE TABLE server_addresses (" |
"id VARCHAR," |
"company_name VARCHAR," |
@@ -1754,7 +1767,8 @@ bool AutofillTable::InitServerAddressesTable() { |
"postal_code VARCHAR," |
"sorting_code VARCHAR," |
"country_code VARCHAR," |
- "language_code VARCHAR)")) { |
+ "language_code VARCHAR, " // See comment above. |
+ "recipient_name VARCHAR)")) { |
NOTREACHED(); |
return false; |
} |
@@ -2751,4 +2765,13 @@ bool AutofillTable::MigrateToVersion61AddUsageStats() { |
return transaction.Commit(); |
} |
+bool AutofillTable::MigrateToVersion62AddServerRecipientName() { |
+ if (!db_->DoesColumnExist("server_addresses", "recipient_name") && |
+ !db_->Execute("ALTER TABLE server_addresses ADD COLUMN " |
+ "recipient_name VARCHAR")) { |
+ return false; |
+ } |
+ return true; |
+} |
+ |
} // namespace autofill |