| Index: chrome/browser/webdata/keyword_table.cc
|
| diff --git a/chrome/browser/webdata/keyword_table.cc b/chrome/browser/webdata/keyword_table.cc
|
| index 6d3a06453dafdd7a3ff111088450ef46809bba3a..a51ca4a1a61cc839237b3149a2b246651eca7aab 100644
|
| --- a/chrome/browser/webdata/keyword_table.cc
|
| +++ b/chrome/browser/webdata/keyword_table.cc
|
| @@ -73,6 +73,10 @@ const std::string ColumnsForVersion(int version, bool concatenated) {
|
| // Column added in version 47.
|
| columns.push_back("alternate_urls");
|
| }
|
| + if (version >= 48) {
|
| + // Column added in version 48.
|
| + columns.push_back("search_terms_replacement_key");
|
| + }
|
|
|
| return JoinString(columns, std::string(concatenated ? " || " : ", "));
|
| }
|
| @@ -118,6 +122,7 @@ void BindURLToStatement(const TemplateURLData& data,
|
| s->BindInt64(starting_column + 14, data.last_modified.ToTimeT());
|
| s->BindString(starting_column + 15, data.sync_guid);
|
| s->BindString(starting_column + 16, alternate_urls);
|
| + s->BindString(starting_column + 17, data.search_terms_replacement_key);
|
| }
|
|
|
| } // anonymous namespace
|
| @@ -149,7 +154,8 @@ bool KeywordTable::Init() {
|
| "instant_url VARCHAR,"
|
| "last_modified INTEGER DEFAULT 0,"
|
| "sync_guid VARCHAR,"
|
| - "alternate_urls VARCHAR)") &&
|
| + "alternate_urls VARCHAR,"
|
| + "search_terms_replacement_key VARCHAR)") &&
|
| UpdateBackupSignature(WebDatabase::kCurrentVersionNumber));
|
| }
|
|
|
| @@ -160,7 +166,7 @@ bool KeywordTable::IsSyncable() {
|
| bool KeywordTable::AddKeyword(const TemplateURLData& data) {
|
| DCHECK(data.id);
|
| std::string query("INSERT INTO keywords (" + GetKeywordColumns() +
|
| - ") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
| + ") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
| sql::Statement s(db_->GetUniqueStatement(query.c_str()));
|
| BindURLToStatement(data, &s, 0, 1);
|
|
|
| @@ -203,8 +209,8 @@ bool KeywordTable::UpdateKeyword(const TemplateURLData& data) {
|
| "originating_url=?, date_created=?, usage_count=?, input_encodings=?, "
|
| "show_in_default_list=?, suggest_url=?, prepopulate_id=?, "
|
| "created_by_policy=?, instant_url=?, last_modified=?, sync_guid=?, "
|
| - "alternate_urls=? WHERE id=?"));
|
| - BindURLToStatement(data, &s, 17, 0); // "17" binds id() as the last item.
|
| + "alternate_urls=?, search_terms_replacement_key=? WHERE id=?"));
|
| + BindURLToStatement(data, &s, 18, 0); // "18" binds id() as the last item.
|
|
|
| return s.Run() && UpdateBackupSignature(WebDatabase::kCurrentVersionNumber);
|
| }
|
| @@ -439,6 +445,34 @@ bool KeywordTable::MigrateToVersion47AddAlternateURLsColumn() {
|
| return transaction.Commit();
|
| }
|
|
|
| +bool KeywordTable::MigrateToVersion48AddSearchTermsReplacementKeyColumn() {
|
| + sql::Transaction transaction(db_);
|
| +
|
| + // Fill the |search_terms_replacement_key| column with empty strings,
|
| + // otherwise it breaks code relying on GetTableContents that concatenates the
|
| + // strings from all the columns.
|
| + if (!transaction.Begin() ||
|
| + !db_->Execute("ALTER TABLE keywords ADD COLUMN "
|
| + "search_terms_replacement_key VARCHAR DEFAULT ''"))
|
| + return false;
|
| +
|
| + if (IsBackupSignatureValid(47)) {
|
| + // Migrate the keywords backup table as well.
|
| + if (!db_->Execute("ALTER TABLE keywords_backup ADD COLUMN "
|
| + "search_terms_replacement_key VARCHAR DEFAULT ''") ||
|
| + !SignBackup(48))
|
| + return false;
|
| + } else {
|
| + // Old backup was invalid; drop the table entirely, which will trigger the
|
| + // protector code to prompt the user and recreate the table.
|
| + if (db_->DoesTableExist("keywords_backup") &&
|
| + !db_->Execute("DROP TABLE keywords_backup"))
|
| + return false;
|
| + }
|
| +
|
| + return transaction.Commit();
|
| +}
|
| +
|
| // static
|
| bool KeywordTable::GetKeywordDataFromStatement(const sql::Statement& s,
|
| TemplateURLData* data) {
|
| @@ -480,6 +514,8 @@ bool KeywordTable::GetKeywordDataFromStatement(const sql::Statement& s,
|
| }
|
| }
|
|
|
| + data->search_terms_replacement_key = s.ColumnString(18);
|
| +
|
| return true;
|
| }
|
|
|
|
|