Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Unified Diff: components/autofill/core/browser/webdata/autofill_table.cc

Issue 310463005: Fill in more name fields with requestAutocomplete (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dont mess with migration code Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 e24ceca1d026d3d75eec6904ebaf145ba0bf1ab4..3f3c42ec5a5a0e577bb4fd4f1e6e9082c6a22377 100644
--- a/components/autofill/core/browser/webdata/autofill_table.cc
+++ b/components/autofill/core/browser/webdata/autofill_table.cc
@@ -167,10 +167,41 @@ scoped_ptr<CreditCard> CreditCardFromStatement(const sql::Statement& s) {
return credit_card.Pass();
}
+// Obsolete version of AddAutofillProfileNamesToProfile, but still needed
+// for MigrateToVersion37MergeAndCullOlderProfiles().
+bool AddAutofillProfileNamesToProfileForVersion37(sql::Connection* db,
+ AutofillProfile* profile) {
+ sql::Statement s(db->GetUniqueStatement(
+ "SELECT guid, first_name, middle_name, last_name "
+ "FROM autofill_profile_names "
+ "WHERE guid=?"));
+ s.BindString(0, profile->guid());
+
+ if (!s.is_valid())
+ return false;
+
+ std::vector<base::string16> first_names;
+ std::vector<base::string16> middle_names;
+ std::vector<base::string16> last_names;
+ while (s.Step()) {
+ DCHECK_EQ(profile->guid(), s.ColumnString(0));
+ first_names.push_back(s.ColumnString16(1));
+ middle_names.push_back(s.ColumnString16(2));
+ last_names.push_back(s.ColumnString16(3));
+ }
+ if (!s.Succeeded())
+ return false;
+
+ profile->SetRawMultiInfo(NAME_FIRST, first_names);
+ profile->SetRawMultiInfo(NAME_MIDDLE, middle_names);
+ profile->SetRawMultiInfo(NAME_LAST, last_names);
+ return true;
+}
+
bool AddAutofillProfileNamesToProfile(sql::Connection* db,
AutofillProfile* profile) {
sql::Statement s(db->GetUniqueStatement(
- "SELECT guid, first_name, middle_name, last_name "
+ "SELECT guid, first_name, middle_name, last_name, full_name "
"FROM autofill_profile_names "
"WHERE guid=?"));
s.BindString(0, profile->guid());
@@ -181,11 +212,13 @@ bool AddAutofillProfileNamesToProfile(sql::Connection* db,
std::vector<base::string16> first_names;
std::vector<base::string16> middle_names;
std::vector<base::string16> last_names;
+ std::vector<base::string16> full_names;
while (s.Step()) {
DCHECK_EQ(profile->guid(), s.ColumnString(0));
first_names.push_back(s.ColumnString16(1));
middle_names.push_back(s.ColumnString16(2));
last_names.push_back(s.ColumnString16(3));
+ full_names.push_back(s.ColumnString16(4));
}
if (!s.Succeeded())
return false;
@@ -193,6 +226,7 @@ bool AddAutofillProfileNamesToProfile(sql::Connection* db,
profile->SetRawMultiInfo(NAME_FIRST, first_names);
profile->SetRawMultiInfo(NAME_MIDDLE, middle_names);
profile->SetRawMultiInfo(NAME_LAST, last_names);
+ profile->SetRawMultiInfo(NAME_FULL, full_names);
return true;
}
@@ -250,20 +284,37 @@ bool AddAutofillProfileNames(const AutofillProfile& profile,
profile.GetRawMultiInfo(NAME_MIDDLE, &middle_names);
std::vector<base::string16> last_names;
profile.GetRawMultiInfo(NAME_LAST, &last_names);
+ std::vector<base::string16> full_names;
+ profile.GetRawMultiInfo(NAME_FULL, &full_names);
DCHECK_EQ(first_names.size(), middle_names.size());
- DCHECK_EQ(middle_names.size(), last_names.size());
+ DCHECK_EQ(first_names.size(), last_names.size());
+ DCHECK_EQ(first_names.size(), full_names.size());
for (size_t i = 0; i < first_names.size(); ++i) {
+ bool has_full_name =
+ db->DoesColumnExist("autofill_profile_names", "full_name");
Scott Hess - ex-Googler 2014/06/09 21:50:50 Sigh - digging around, I don't see a reasonable ch
Evan Stade 2014/06/12 01:55:32 Done.
+
// Add the new name.
- sql::Statement s(db->GetUniqueStatement(
- "INSERT INTO autofill_profile_names"
- " (guid, first_name, middle_name, last_name) "
- "VALUES (?,?,?,?)"));
+ sql::Statement s;
+ if (has_full_name) {
+ s.Assign(db->GetUniqueStatement(
+ "INSERT INTO autofill_profile_names"
+ " (guid, first_name, middle_name, last_name, full_name) "
+ "VALUES (?,?,?,?,?)"));
+ } else {
+ s.Assign(db->GetUniqueStatement(
+ "INSERT INTO autofill_profile_names"
+ " (guid, first_name, middle_name, last_name) "
+ "VALUES (?,?,?,?)"));
+ }
s.BindString(0, profile.guid());
s.BindString16(1, first_names[i]);
s.BindString16(2, middle_names[i]);
s.BindString16(3, last_names[i]);
+ if (has_full_name)
+ s.BindString16(4, full_names[i]);
+
if (!s.Run())
return false;
}
@@ -447,6 +498,9 @@ bool AutofillTable::MigrateToVersion(int version,
case 56:
*update_compatible_version = true;
return MigrateToVersion56AddProfileLanguageCodeForFormatting();
+ case 57:
+ *update_compatible_version = true;
+ return MigrateToVersion57AddFullNameField();
}
return true;
}
@@ -1292,7 +1346,8 @@ bool AutofillTable::InitProfileNamesTable() {
"guid VARCHAR, "
"first_name VARCHAR, "
"middle_name VARCHAR, "
- "last_name VARCHAR)")) {
+ "last_name VARCHAR, "
+ "full_name VARCHAR)")) {
NOTREACHED();
return false;
}
@@ -2005,7 +2060,7 @@ bool AutofillTable::MigrateToVersion37MergeAndCullOlderProfiles() {
profile->set_origin(s.ColumnString(index++));
// Get associated name info.
- AddAutofillProfileNamesToProfile(db_, profile.get());
+ AddAutofillProfileNamesToProfileForVersion37(db_, profile.get());
// Get associated email info.
AddAutofillProfileEmailsToProfile(db_, profile.get());
@@ -2272,4 +2327,9 @@ bool AutofillTable::MigrateToVersion56AddProfileLanguageCodeForFormatting() {
"ADD COLUMN language_code VARCHAR");
}
+bool AutofillTable::MigrateToVersion57AddFullNameField() {
+ return db_->Execute("ALTER TABLE autofill_profile_names "
+ "ADD COLUMN full_name VARCHAR");
+}
+
} // namespace autofill
« no previous file with comments | « components/autofill/core/browser/webdata/autofill_table.h ('k') | components/test/data/web_database/version_56.sql » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698