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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // wasn't, we'll do it now. Unfortunately a previous change deleted this for | 381 // wasn't, we'll do it now. Unfortunately a previous change deleted this for |
382 // some users, so we can't be sure this will succeed (so don't bail on error). | 382 // some users, so we can't be sure this will succeed (so don't bail on error). |
383 meta_table_->DeleteKey("Default Search Provider Backup"); | 383 meta_table_->DeleteKey("Default Search Provider Backup"); |
384 | 384 |
385 if (!MigrateKeywordsTableForVersion45("keywords")) | 385 if (!MigrateKeywordsTableForVersion45("keywords")) |
386 return false; | 386 return false; |
387 | 387 |
388 // Migrate the keywords backup table as well. | 388 // Migrate the keywords backup table as well. |
389 if (!MigrateKeywordsTableForVersion45("keywords_backup") || | 389 if (!MigrateKeywordsTableForVersion45("keywords_backup") || |
390 !meta_table_->SetValue("Default Search Provider ID Backup Signature", | 390 !meta_table_->SetValue("Default Search Provider ID Backup Signature", |
391 "")) | 391 std::string())) |
392 return false; | 392 return false; |
393 | 393 |
394 return transaction.Commit(); | 394 return transaction.Commit(); |
395 } | 395 } |
396 | 396 |
397 bool KeywordTable::MigrateToVersion47AddAlternateURLsColumn() { | 397 bool KeywordTable::MigrateToVersion47AddAlternateURLsColumn() { |
398 sql::Transaction transaction(db_); | 398 sql::Transaction transaction(db_); |
399 | 399 |
400 // Fill the |alternate_urls| column with empty strings, otherwise it breaks | 400 // Fill the |alternate_urls| column with empty strings, otherwise it breaks |
401 // code relying on GetTableContents that concatenates the strings from all | 401 // code relying on GetTableContents that concatenates the strings from all |
402 // the columns. | 402 // the columns. |
403 if (!transaction.Begin() || | 403 if (!transaction.Begin() || |
404 !db_->Execute("ALTER TABLE keywords ADD COLUMN " | 404 !db_->Execute("ALTER TABLE keywords ADD COLUMN " |
405 "alternate_urls VARCHAR DEFAULT ''")) | 405 "alternate_urls VARCHAR DEFAULT ''")) |
406 return false; | 406 return false; |
407 | 407 |
408 // Migrate the keywords backup table as well. | 408 // Migrate the keywords backup table as well. |
409 if (!db_->Execute("ALTER TABLE keywords_backup ADD COLUMN " | 409 if (!db_->Execute("ALTER TABLE keywords_backup ADD COLUMN " |
410 "alternate_urls VARCHAR DEFAULT ''") || | 410 "alternate_urls VARCHAR DEFAULT ''") || |
411 !meta_table_->SetValue("Default Search Provider ID Backup Signature", | 411 !meta_table_->SetValue("Default Search Provider ID Backup Signature", |
412 "")) | 412 std::string())) |
413 return false; | 413 return false; |
414 | 414 |
415 return transaction.Commit(); | 415 return transaction.Commit(); |
416 } | 416 } |
417 | 417 |
418 bool KeywordTable::MigrateToVersion48RemoveKeywordsBackup() { | 418 bool KeywordTable::MigrateToVersion48RemoveKeywordsBackup() { |
419 sql::Transaction transaction(db_); | 419 sql::Transaction transaction(db_); |
420 if (!transaction.Begin()) | 420 if (!transaction.Begin()) |
421 return false; | 421 return false; |
422 | 422 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 } | 607 } |
608 } | 608 } |
609 | 609 |
610 // Replace the old table with the new one. | 610 // Replace the old table with the new one. |
611 sql = "DROP TABLE " + name; | 611 sql = "DROP TABLE " + name; |
612 if (!db_->Execute(sql.c_str())) | 612 if (!db_->Execute(sql.c_str())) |
613 return false; | 613 return false; |
614 sql = "ALTER TABLE keywords_temp RENAME TO " + name; | 614 sql = "ALTER TABLE keywords_temp RENAME TO " + name; |
615 return db_->Execute(sql.c_str()); | 615 return db_->Execute(sql.c_str()); |
616 } | 616 } |
OLD | NEW |