| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/webdata/keyword_table.h" | 5 #include "chrome/browser/webdata/keyword_table.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 "last_modified INTEGER DEFAULT 0," | 145 "last_modified INTEGER DEFAULT 0," |
| 146 "sync_guid VARCHAR," | 146 "sync_guid VARCHAR," |
| 147 "alternate_urls VARCHAR," | 147 "alternate_urls VARCHAR," |
| 148 "search_terms_replacement_key VARCHAR)"); | 148 "search_terms_replacement_key VARCHAR)"); |
| 149 } | 149 } |
| 150 | 150 |
| 151 bool KeywordTable::IsSyncable() { | 151 bool KeywordTable::IsSyncable() { |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 bool KeywordTable::MigrateToVersion(int version, |
| 156 const std::string& app_locale, |
| 157 bool* update_compatible_version) { |
| 158 // Migrate if necessary. |
| 159 switch (version) { |
| 160 case 21: |
| 161 *update_compatible_version = true; |
| 162 return MigrateToVersion21AutoGenerateKeywordColumn(); |
| 163 case 25: |
| 164 *update_compatible_version = true; |
| 165 return MigrateToVersion25AddLogoIDColumn(); |
| 166 case 26: |
| 167 *update_compatible_version = true; |
| 168 return MigrateToVersion26AddCreatedByPolicyColumn(); |
| 169 case 28: |
| 170 *update_compatible_version = true; |
| 171 return MigrateToVersion28SupportsInstantColumn(); |
| 172 case 29: |
| 173 *update_compatible_version = true; |
| 174 return MigrateToVersion29InstantURLToSupportsInstant(); |
| 175 case 38: |
| 176 *update_compatible_version = true; |
| 177 return MigrateToVersion38AddLastModifiedColumn(); |
| 178 case 39: |
| 179 *update_compatible_version = true; |
| 180 return MigrateToVersion39AddSyncGUIDColumn(); |
| 181 case 44: |
| 182 *update_compatible_version = true; |
| 183 return MigrateToVersion44AddDefaultSearchProviderBackup(); |
| 184 case 45: |
| 185 *update_compatible_version = true; |
| 186 return MigrateToVersion45RemoveLogoIDAndAutogenerateColumns(); |
| 187 case 47: |
| 188 *update_compatible_version = true; |
| 189 return MigrateToVersion47AddAlternateURLsColumn(); |
| 190 case 48: |
| 191 *update_compatible_version = true; |
| 192 return MigrateToVersion48RemoveKeywordsBackup(); |
| 193 case 49: |
| 194 *update_compatible_version = true; |
| 195 return MigrateToVersion49AddSearchTermsReplacementKeyColumn(); |
| 196 } |
| 197 |
| 198 return true; |
| 199 } |
| 200 |
| 155 bool KeywordTable::AddKeyword(const TemplateURLData& data) { | 201 bool KeywordTable::AddKeyword(const TemplateURLData& data) { |
| 156 DCHECK(data.id); | 202 DCHECK(data.id); |
| 157 std::string query("INSERT INTO keywords (" + GetKeywordColumns() + | 203 std::string query("INSERT INTO keywords (" + GetKeywordColumns() + |
| 158 ") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); | 204 ") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); |
| 159 sql::Statement s(db_->GetUniqueStatement(query.c_str())); | 205 sql::Statement s(db_->GetUniqueStatement(query.c_str())); |
| 160 BindURLToStatement(data, &s, 0, 1); | 206 BindURLToStatement(data, &s, 0, 1); |
| 161 | 207 |
| 162 return s.Run(); | 208 return s.Run(); |
| 163 } | 209 } |
| 164 | 210 |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 } | 594 } |
| 549 } | 595 } |
| 550 | 596 |
| 551 // Replace the old table with the new one. | 597 // Replace the old table with the new one. |
| 552 sql = "DROP TABLE " + name; | 598 sql = "DROP TABLE " + name; |
| 553 if (!db_->Execute(sql.c_str())) | 599 if (!db_->Execute(sql.c_str())) |
| 554 return false; | 600 return false; |
| 555 sql = "ALTER TABLE keywords_temp RENAME TO " + name; | 601 sql = "ALTER TABLE keywords_temp RENAME TO " + name; |
| 556 return db_->Execute(sql.c_str()); | 602 return db_->Execute(sql.c_str()); |
| 557 } | 603 } |
| OLD | NEW |