Index: components/webdata/autofill/autofill_table.cc |
=================================================================== |
--- components/webdata/autofill/autofill_table.cc (revision 192389) |
+++ components/webdata/autofill/autofill_table.cc (working copy) |
@@ -17,6 +17,7 @@ |
#include "base/strings/string_number_conversions.h" |
#include "base/time.h" |
#include "base/tuple.h" |
+#include "base/utf_string_conversions.h" |
#include "components/autofill/browser/autofill_country.h" |
#include "components/autofill/browser/autofill_profile.h" |
#include "components/autofill/browser/autofill_type.h" |
@@ -51,7 +52,8 @@ |
} |
void BindAutofillProfileToStatement(const AutofillProfile& profile, |
- sql::Statement* s) { |
+ sql::Statement* s, |
+ const std::string& app_locale) { |
DCHECK(base::IsValidGUID(profile.guid())); |
s->BindString(0, profile.guid()); |
@@ -67,14 +69,15 @@ |
s->BindString16(5, LimitDataSize(text)); |
text = profile.GetRawInfo(ADDRESS_HOME_ZIP); |
s->BindString16(6, LimitDataSize(text)); |
+ text = profile.GetInfo(ADDRESS_HOME_COUNTRY, app_locale); |
+ s->BindString16(7, LimitDataSize(text)); |
text = profile.GetRawInfo(ADDRESS_HOME_COUNTRY); |
- s->BindString16(7, LimitDataSize(text)); |
- std::string country_code = profile.CountryCode(); |
- s->BindString(8, country_code); |
+ s->BindString16(8, LimitDataSize(text)); |
s->BindInt64(9, Time::Now().ToTimeT()); |
} |
-AutofillProfile* AutofillProfileFromStatement(const sql::Statement& s) { |
+AutofillProfile* AutofillProfileFromStatement(const sql::Statement& s, |
+ const std::string& app_locale) { |
AutofillProfile* profile = new AutofillProfile; |
profile->set_guid(s.ColumnString(0)); |
DCHECK(base::IsValidGUID(profile->guid())); |
@@ -86,7 +89,13 @@ |
profile->SetRawInfo(ADDRESS_HOME_STATE, s.ColumnString16(5)); |
profile->SetRawInfo(ADDRESS_HOME_ZIP, s.ColumnString16(6)); |
// Intentionally skip column 7, which stores the localized country name. |
- profile->SetCountryCode(s.ColumnString(8)); |
+ string16 country_code = s.ColumnString16(8); |
+ if (country_code.empty()) { |
+ // Old versions put the localized country name in column 7. |
jam
2013/04/05 02:27:26
This is the first time I look at the webdata code.
Ilya Sherman
2013/04/05 05:18:01
We should be able to just keep this code as it was
jam
2013/04/05 06:45:54
Done.
|
+ country_code = ASCIIToUTF16(AutofillCountry::GetCountryCode( |
+ s.ColumnString16(7), app_locale)); |
+ } |
+ profile->SetRawInfo(ADDRESS_HOME_COUNTRY, country_code); |
// Intentionally skip column 9, which stores the profile's modification date. |
return profile; |
@@ -933,7 +942,7 @@ |
"(guid, company_name, address_line_1, address_line_2, city, state," |
" zipcode, country, country_code, date_modified)" |
"VALUES (?,?,?,?,?,?,?,?,?,?)")); |
- BindAutofillProfileToStatement(profile, &s); |
+ BindAutofillProfileToStatement(profile, &s, app_locale_); |
if (!s.Run()) |
return false; |
@@ -955,7 +964,7 @@ |
if (!s.Step()) |
return false; |
- scoped_ptr<AutofillProfile> p(AutofillProfileFromStatement(s)); |
+ scoped_ptr<AutofillProfile> p(AutofillProfileFromStatement(s, app_locale_)); |
// Get associated name info. |
AddAutofillProfileNamesToProfile(db_, p.get()); |
@@ -1048,7 +1057,7 @@ |
" city=?, state=?, zipcode=?, country=?, country_code=?, " |
" date_modified=? " |
"WHERE guid=?")); |
- BindAutofillProfileToStatement(profile, &s); |
+ BindAutofillProfileToStatement(profile, &s, app_locale_); |
s.BindString(10, profile.guid()); |
bool result = s.Run(); |
@@ -1759,6 +1768,7 @@ |
"state VARCHAR, " |
"zipcode VARCHAR, " |
"country VARCHAR, " |
+ "country_code VARCHAR, " |
Ilya Sherman
2013/04/05 05:18:01
You shouldn't change this migration code. The sem
jam
2013/04/05 06:45:54
Done.
|
"phone VARCHAR, " |
"date_modified INTEGER NOT NULL DEFAULT 0)")) { |
return false; |
@@ -1768,7 +1778,7 @@ |
"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, date_modified " |
+ "zipcode, country, country, phone, date_modified " |
Ilya Sherman
2013/04/05 05:18:01
Ditto.
jam
2013/04/05 06:45:54
Done.
|
"FROM autofill_profiles")) { |
return false; |
} |
@@ -1829,6 +1839,7 @@ |
"state VARCHAR, " |
"zipcode VARCHAR, " |
"country VARCHAR, " |
+ "country_code VARCHAR, " |
Ilya Sherman
2013/04/05 05:18:01
Ditto.
jam
2013/04/05 06:45:54
Done.
|
"date_modified INTEGER NOT NULL DEFAULT 0)")) { |
return false; |
} |
@@ -1855,7 +1866,9 @@ |
profile.SetRawInfo(ADDRESS_HOME_CITY, s.ColumnString16(8)); |
profile.SetRawInfo(ADDRESS_HOME_STATE, s.ColumnString16(9)); |
profile.SetRawInfo(ADDRESS_HOME_ZIP, s.ColumnString16(10)); |
- profile.SetRawInfo(ADDRESS_HOME_COUNTRY, s.ColumnString16(11)); |
+ std::string country_code = |
+ AutofillCountry::GetCountryCode(s.ColumnString16(11), app_locale_); |
+ profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16(country_code)); |
Ilya Sherman
2013/04/05 05:18:01
Please call SetInfo() here instead.
jam
2013/04/05 06:45:54
Done.
|
profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, s.ColumnString16(12)); |
int64 date_modified = s.ColumnInt64(13); |