Chromium Code Reviews| Index: components/search_engines/keyword_table.cc |
| diff --git a/components/search_engines/keyword_table.cc b/components/search_engines/keyword_table.cc |
| index fcbd52558259ebcaa0206cf1c75fd44cfe3e9d3d..f2a3af487a37ed7a565b24366399c796bacc7e8a 100644 |
| --- a/components/search_engines/keyword_table.cc |
| +++ b/components/search_engines/keyword_table.cc |
| @@ -81,6 +81,10 @@ const std::string ColumnsForVersion(int version, bool concatenated) { |
| // Column added in version 53. |
| columns.push_back("new_tab_url"); |
| } |
| + if (version >= 66) { |
| + // Column added in version 66. |
| + columns.push_back("engine_type"); |
| + } |
| return base::JoinString(columns, std::string(concatenated ? " || " : ", ")); |
| } |
| @@ -134,6 +138,7 @@ void BindURLToStatement(const TemplateURLData& data, |
| s->BindString(starting_column + 21, data.instant_url_post_params); |
| s->BindString(starting_column + 22, data.image_url_post_params); |
| s->BindString(starting_column + 23, data.new_tab_url); |
| + s->BindInt(starting_column + 24, data.engine_type); |
| } |
| WebDatabaseTable::TypeKey GetKey() { |
| @@ -185,7 +190,8 @@ bool KeywordTable::CreateTablesIfNecessary() { |
| "suggest_url_post_params VARCHAR," |
| "instant_url_post_params VARCHAR," |
| "image_url_post_params VARCHAR," |
| - "new_tab_url VARCHAR)"); |
| + "new_tab_url VARCHAR," |
| + "engine_type INTEGER DEFAULT -1)"); |
| } |
| bool KeywordTable::IsSyncable() { |
| @@ -202,6 +208,9 @@ bool KeywordTable::MigrateToVersion(int version, |
| case 59: |
| *update_compatible_version = true; |
| return MigrateToVersion59RemoveExtensionKeywords(); |
| + case 66: |
| + *update_compatible_version = true; |
| + return MigrateToVersion66AddEngineTypeColumn(); |
| } |
| return true; |
| @@ -289,6 +298,11 @@ bool KeywordTable::MigrateToVersion59RemoveExtensionKeywords() { |
| "WHERE url LIKE 'chrome-extension://%'"); |
| } |
| +bool KeywordTable::MigrateToVersion66AddEngineTypeColumn() { |
| + return db_->Execute("ALTER TABLE keywords ADD COLUMN engine_type " |
| + "INTEGER DEFAULT -1"); |
| +} |
| + |
| // static |
| bool KeywordTable::GetKeywordDataFromStatement(const sql::Statement& s, |
| TemplateURLData* data) { |
| @@ -322,6 +336,7 @@ bool KeywordTable::GetKeywordDataFromStatement(const sql::Statement& s, |
| data->last_modified = Time::FromTimeT(s.ColumnInt64(15)); |
| data->created_by_policy = s.ColumnBool(13); |
| data->usage_count = s.ColumnInt(8); |
| + data->engine_type = static_cast<SearchEngineType>(s.ColumnInt(25)); |
| data->prepopulate_id = s.ColumnInt(12); |
| data->sync_guid = s.ColumnString(16); |
| @@ -347,7 +362,7 @@ bool KeywordTable::AddKeyword(const TemplateURLData& data) { |
| DCHECK(data.id); |
| std::string query("INSERT INTO keywords (" + GetKeywordColumns() + ") " |
| "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?," |
| - " ?)"); |
| + " ?,?)"); |
| sql::Statement s(db_->GetCachedStatement(SQL_FROM_HERE, query.c_str())); |
| BindURLToStatement(data, &s, 0, 1); |
| @@ -374,8 +389,8 @@ bool KeywordTable::UpdateKeyword(const TemplateURLData& data) { |
| "last_modified=?, sync_guid=?, alternate_urls=?, " |
| "search_terms_replacement_key=?, image_url=?, search_url_post_params=?, " |
| "suggest_url_post_params=?, instant_url_post_params=?, " |
| - "image_url_post_params=?, new_tab_url=? WHERE id=?")); |
| - BindURLToStatement(data, &s, 24, 0); // "24" binds id() as the last item. |
| + "image_url_post_params=?, new_tab_url=?, engine_type=? WHERE id=?")); |
| + BindURLToStatement(data, &s, 25, 0); // "24" binds id() as the last item. |
|
Peter Kasting
2016/05/17 04:43:04
Nit: 24 -> 25
Vitaly Baranov
2016/06/03 15:31:45
Done.
|
| return s.Run(); |
| } |