summaryrefslogtreecommitdiffstats
path: root/chrome/browser/webdata
diff options
context:
space:
mode:
authorivankr@chromium.org <ivankr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-16 11:58:38 +0000
committerivankr@chromium.org <ivankr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-16 11:58:38 +0000
commitfbfc372ffd855c0be0665be251a4eb0968787de9 (patch)
tree97ad425e1b14f99f70b0fda4ad0a14fe7348f00a /chrome/browser/webdata
parent9061bee8add0e744e50811f7feb77333622775e3 (diff)
downloadchromium_src-fbfc372ffd855c0be0665be251a4eb0968787de9.zip
chromium_src-fbfc372ffd855c0be0665be251a4eb0968787de9.tar.gz
chromium_src-fbfc372ffd855c0be0665be251a4eb0968787de9.tar.bz2
Bump WebData version to 44: force clean Protector state.
1) WebData version update to 44. No real schema changes; migration does silently updare keywords backup so Protector will have a clean state. 2) Also fixed typo in 42->43 migration test SQL. BUG=None TEST=unit_tests:WebDatabaseMigrationTest.* Review URL: http://codereview.chromium.org/9213001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117846 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/webdata')
-rw-r--r--chrome/browser/webdata/keyword_table.cc6
-rw-r--r--chrome/browser/webdata/keyword_table.h3
-rw-r--r--chrome/browser/webdata/web_database.cc13
-rw-r--r--chrome/browser/webdata/web_database_migration_unittest.cc90
4 files changed, 105 insertions, 7 deletions
diff --git a/chrome/browser/webdata/keyword_table.cc b/chrome/browser/webdata/keyword_table.cc
index 9e97474..0cb2265 100644
--- a/chrome/browser/webdata/keyword_table.cc
+++ b/chrome/browser/webdata/keyword_table.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -440,6 +440,10 @@ bool KeywordTable::MigrateToVersion43AddKeywordsBackupTable() {
UpdateBackupSignature();
}
+bool KeywordTable::MigrateToVersion44UpdateKeywordsBackup() {
+ return UpdateBackupSignature();
+}
+
bool KeywordTable::GetSignatureData(std::string* backup) {
DCHECK(backup);
diff --git a/chrome/browser/webdata/keyword_table.h b/chrome/browser/webdata/keyword_table.h
index 504dcd7..38e90ed 100644
--- a/chrome/browser/webdata/keyword_table.h
+++ b/chrome/browser/webdata/keyword_table.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -132,6 +132,7 @@ class KeywordTable : public WebDatabaseTable {
bool MigrateToVersion41RewriteDefaultSearchProviderBackup();
bool MigrateToVersion42AddFullDefaultSearchProviderBackup();
bool MigrateToVersion43AddKeywordsBackupTable();
+ bool MigrateToVersion44UpdateKeywordsBackup();
private:
FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, DefaultSearchProviderBackup);
diff --git a/chrome/browser/webdata/web_database.cc b/chrome/browser/webdata/web_database.cc
index 0d0883f..485fcc2 100644
--- a/chrome/browser/webdata/web_database.cc
+++ b/chrome/browser/webdata/web_database.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -22,8 +22,8 @@ namespace {
// Current version number. Note: when changing the current version number,
// corresponding changes must happen in the unit tests, and new migration test
// added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|.
-const int kCurrentVersionNumber = 43;
-const int kCompatibleVersionNumber = 43;
+const int kCurrentVersionNumber = 44;
+const int kCompatibleVersionNumber = 44;
// Change the version number and possibly the compatibility version of
// |meta_table_|.
@@ -334,6 +334,13 @@ sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded() {
ChangeVersion(&meta_table_, 43, true);
// FALL THROUGH
+ case 43:
+ if (!keyword_table_->MigrateToVersion44UpdateKeywordsBackup())
+ return FailedMigrationTo(44);
+
+ ChangeVersion(&meta_table_, 44, true);
+ // FALL THROUGH
+
// Add successive versions here. Each should set the version number and
// compatible version number as appropriate, then fall through to the next
// case.
diff --git a/chrome/browser/webdata/web_database_migration_unittest.cc b/chrome/browser/webdata/web_database_migration_unittest.cc
index 874d572..44ea365 100644
--- a/chrome/browser/webdata/web_database_migration_unittest.cc
+++ b/chrome/browser/webdata/web_database_migration_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -18,6 +18,7 @@
#include "chrome/browser/autofill/credit_card.h"
#include "chrome/browser/webdata/autofill_change.h"
#include "chrome/browser/webdata/autofill_entry.h"
+#include "chrome/browser/webdata/keyword_table.h"
#include "chrome/browser/webdata/web_database.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/guid.h"
@@ -196,7 +197,7 @@ class WebDatabaseMigrationTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
};
-const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 43;
+const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 44;
void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) {
std::string contents;
@@ -1875,3 +1876,88 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion42ToCurrent) {
EXPECT_FALSE(s.Step());
}
}
+
+// Tests that the default search provider is backed up and signed.
+TEST_F(WebDatabaseMigrationTest, MigrateVersion43ToCurrent) {
+ ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_43.sql")));
+
+ int64 previous_default_search_provider_id;
+
+ // Verify pre-conditions. These are expectations for version 43 of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+ ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
+
+ sql::MetaTable meta_table;
+ ASSERT_TRUE(meta_table.Init(&connection, 43, 43));
+
+ int64 default_search_provider_id = 0;
+ EXPECT_TRUE(meta_table.GetValue(
+ "Default Search Provider ID",
+ &default_search_provider_id));
+ EXPECT_NE(default_search_provider_id, 0);
+ previous_default_search_provider_id = default_search_provider_id;
+
+ int64 default_search_provider_id_backup = 0;
+ EXPECT_TRUE(meta_table.GetValue(
+ "Default Search Provider ID Backup",
+ &default_search_provider_id_backup));
+ EXPECT_NE(default_search_provider_id_backup, 0);
+
+ // Backup ID is invalid, signature is invalid as well.
+ EXPECT_NE(default_search_provider_id, default_search_provider_id_backup);
+
+ std::string default_search_provider_id_backup_signature;
+ EXPECT_TRUE(meta_table.GetValue(
+ "Default Search Provider ID Backup Signature",
+ &default_search_provider_id_backup_signature));
+ EXPECT_FALSE(default_search_provider_id_backup_signature.empty());
+ }
+
+ // Load the database via the WebDatabase class and migrate the database to
+ // the current version.
+ {
+ WebDatabase db;
+ ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath()));
+ ASSERT_FALSE(db.GetKeywordTable()->DidDefaultSearchProviderChange());
+ }
+
+ // Verify post-conditions. These are expectations for current version of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+ ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
+
+ // Check version.
+ EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
+
+ sql::MetaTable meta_table;
+ ASSERT_TRUE(meta_table.Init(
+ &connection,
+ kCurrentTestedVersionNumber,
+ kCurrentTestedVersionNumber));
+
+ int64 default_search_provider_id = 0;
+ EXPECT_TRUE(meta_table.GetValue(
+ "Default Search Provider ID",
+ &default_search_provider_id));
+ // Default search provider ID should not change.
+ EXPECT_EQ(previous_default_search_provider_id, default_search_provider_id);
+
+ int64 default_search_provider_id_backup = 0;
+ EXPECT_TRUE(meta_table.GetValue(
+ "Default Search Provider ID Backup",
+ &default_search_provider_id_backup));
+ // Backup ID must be updated to match the old default search provider ID.
+ EXPECT_EQ(default_search_provider_id, default_search_provider_id_backup);
+
+ std::string default_search_provider_id_backup_signature;
+ EXPECT_TRUE(meta_table.GetValue(
+ "Default Search Provider ID Backup Signature",
+ &default_search_provider_id_backup_signature));
+ EXPECT_FALSE(default_search_provider_id_backup_signature.empty());
+ }
+}