r109038 - in trunk/src/chrome: . browser/webdata test/data/web_database

11 views
Skip to first unread message

ava...@chromium.org

unread,
Nov 8, 2011, 11:49:28 AM11/8/11
to chromium...@chromium.org
Author: ava...@chromium.org
Date: Tue Nov 8 08:49:28 2011
New Revision: 109038

Log:
Added internal Protector key to official build
Increase WebData version, rewrite DSP backup signature.

R=s...@chromium.org
BUG=94447
TEST=Verify that Web Data version is 41, Default Search Provider ID Backup Signature is not empty in any build, different for official build.

Review URL: http://codereview.chromium.org/8502019

Added:
trunk/src/chrome/test/data/web_database/version_40.sql
Modified:
trunk/src/chrome/browser/webdata/keyword_table.cc
trunk/src/chrome/browser/webdata/keyword_table.h
trunk/src/chrome/browser/webdata/web_database.cc
trunk/src/chrome/browser/webdata/web_database_migration_unittest.cc
trunk/src/chrome/chrome_browser.gypi

Modified: trunk/src/chrome/browser/webdata/keyword_table.cc
==============================================================================
--- trunk/src/chrome/browser/webdata/keyword_table.cc (original)
+++ trunk/src/chrome/browser/webdata/keyword_table.cc Tue Nov 8 08:49:28 2011
@@ -385,7 +385,18 @@
"ALTER TABLE keywords ADD COLUMN sync_guid VARCHAR");
}

-bool KeywordTable::MigrateToVersion40AddDefaultSearchEngineBackup() {
+bool KeywordTable::MigrateToVersion40AddDefaultSearchProviderBackup() {
+ int64 value = 0;
+ if (!meta_table_->GetValue(kDefaultSearchProviderKey, &value)) {
+ // Set default search provider ID and its backup.
+ return SetDefaultSearchProviderID(0);
+ }
+ return SetDefaultSearchProviderBackupID(value);
+}
+
+bool KeywordTable::MigrateToVersion41RewriteDefaultSearchProviderBackup() {
+ // Due to crbug.com/101815 version 40 may contain corrupt or empty
+ // signature. So ignore the signature and simply rewrite it.
int64 value = 0;
if (!meta_table_->GetValue(kDefaultSearchProviderKey, &value)) {
// Set default search provider ID and its backup.

Modified: trunk/src/chrome/browser/webdata/keyword_table.h
==============================================================================
--- trunk/src/chrome/browser/webdata/keyword_table.h (original)
+++ trunk/src/chrome/browser/webdata/keyword_table.h Tue Nov 8 08:49:28 2011
@@ -103,7 +103,8 @@
bool MigrateToVersion29InstantUrlToSupportsInstant();
bool MigrateToVersion38AddLastModifiedColumn();
bool MigrateToVersion39AddSyncGUIDColumn();
- bool MigrateToVersion40AddDefaultSearchEngineBackup();
+ bool MigrateToVersion40AddDefaultSearchProviderBackup();
+ bool MigrateToVersion41RewriteDefaultSearchProviderBackup();

private:
FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, DefaultSearchProviderBackup);

Modified: trunk/src/chrome/browser/webdata/web_database.cc
==============================================================================
--- trunk/src/chrome/browser/webdata/web_database.cc (original)
+++ trunk/src/chrome/browser/webdata/web_database.cc Tue Nov 8 08:49:28 2011
@@ -22,8 +22,8 @@
// 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 = 40;
-const int kCompatibleVersionNumber = 40;
+const int kCurrentVersionNumber = 41;
+const int kCompatibleVersionNumber = 41;

// Change the version number and possibly the compatibility version of
// |meta_table_|.
@@ -305,12 +305,20 @@
// FALL THROUGH

case 39:
- if (!keyword_table_->MigrateToVersion40AddDefaultSearchEngineBackup())
+ if (!keyword_table_->MigrateToVersion40AddDefaultSearchProviderBackup())
return FailedMigrationTo(40);

ChangeVersion(&meta_table_, 40, true);
// FALL THROUGH

+ case 40:
+ if (!keyword_table_->
+ MigrateToVersion41RewriteDefaultSearchProviderBackup())
+ return FailedMigrationTo(41);
+
+ ChangeVersion(&meta_table_, 41, 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.

Modified: trunk/src/chrome/browser/webdata/web_database_migration_unittest.cc
==============================================================================
--- trunk/src/chrome/browser/webdata/web_database_migration_unittest.cc (original)
+++ trunk/src/chrome/browser/webdata/web_database_migration_unittest.cc Tue Nov 8 08:49:28 2011
@@ -196,7 +196,7 @@
DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
};

-const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 40;
+const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 41;

void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) {
std::string contents;
@@ -1506,7 +1506,7 @@
// Tests that the backup field for the default search provider gets added to
// the meta table of a version 39 database.
TEST_F(WebDatabaseMigrationTest, MigrateVersion39ToCurrent) {
- // This schema is taken from a build prior to the addition of the defaul
+ // This schema is taken from a build prior to the addition of the default
// search provider backup field to the meta table.
ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_39.sql")));

@@ -1577,3 +1577,81 @@
}
}

+// Tests that the backup field for the default search provider is rewritten
+// despite any value in the old version.
+TEST_F(WebDatabaseMigrationTest, MigrateVersion40ToCurrent) {
+ // This schema is taken from a build after the addition of the default
+ // search provider backup field to the meta table. Due to crbug.com/101815
+ // the signature was empty in all build between revisions 106214 and 108111.
+ ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_40.sql")));
+
+ // Verify pre-conditions. These are expectations for version 40 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, 40, 40));
+
+ int64 default_search_provider_id = 0;
+ EXPECT_TRUE(meta_table.GetValue(
+ "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));
+
+ 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_TRUE(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()));
+ }
+
+ // 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));
+ EXPECT_NE(0, 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_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());
+ }
+}
+

Modified: trunk/src/chrome/chrome_browser.gypi
==============================================================================
--- trunk/src/chrome/chrome_browser.gypi (original)
+++ trunk/src/chrome/chrome_browser.gypi Tue Nov 8 08:49:28 2011
@@ -2002,6 +2002,7 @@
'browser/protector/default_search_provider_change.cc',
'browser/protector/histograms.cc',
'browser/protector/histograms.h',
+ 'browser/protector/internal/keys_internal.cc',
'browser/protector/keys.cc',
'browser/protector/keys.h',
'browser/protector/protector.cc',
@@ -4027,6 +4028,16 @@
'<(SHARED_INTERMEDIATE_DIR)/autofill_regex_constants.cc',
],
'conditions': [
+ ['buildtype=="Official"', {
+ 'sources!': [
+ 'browser/protector/keys.cc',
+ ],
+ }],
+ ['buildtype!="Official"', {
+ 'sources!': [
+ 'browser/protector/internal/keys_internal.cc',
+ ],
+ }],
['debug_devtools==1', {
'defines': [
'DEBUG_DEVTOOLS=1',

Added: trunk/src/chrome/test/data/web_database/version_40.sql
==============================================================================
--- (empty file)
+++ trunk/src/chrome/test/data/web_database/version_40.sql Tue Nov 8 08:49:28 2011
@@ -0,0 +1,29 @@
+PRAGMA foreign_keys=OFF;
+BEGIN TRANSACTION;
+CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY,value LONGVARCHAR);
+INSERT INTO "meta" VALUES('version','40');
+INSERT INTO "meta" VALUES('last_compatible_version','40');
+INSERT INTO "meta" VALUES('Default Search Provider ID','2');
+INSERT INTO "meta" VALUES('Default Search Provider ID Backup','2');
+INSERT INTO "meta" VALUES('Default Search Provider ID Backup Signature','');
+INSERT INTO "meta" VALUES('Builtin Keyword Version','33');
+CREATE TABLE keywords (id INTEGER PRIMARY KEY,short_name VARCHAR NOT NULL,keyword VARCHAR NOT NULL,favicon_url VARCHAR NOT NULL,url VARCHAR NOT NULL,show_in_default_list INTEGER,safe_for_autoreplace INTEGER,originating_url VARCHAR,date_created INTEGER DEFAULT 0,usage_count INTEGER DEFAULT 0,input_encodings VARCHAR,suggest_url VARCHAR,prepopulate_id INTEGER DEFAULT 0,autogenerate_keyword INTEGER DEFAULT 0,logo_id INTEGER DEFAULT 0,created_by_policy INTEGER DEFAULT 0,instant_url VARCHAR,last_modified INTEGER DEFAULT 0, sync_guid VARCHAR);
+INSERT INTO "keywords" VALUES(2,'Google','google.com','http://www.google.com/favicon.ico','{google:baseURL}search?{google:RLZ}{google:acceptedSuggestion}{google:originalQueryForSuggestion}sourceid=chrome&ie={inputEncoding}&q={searchTerms}',1,1,'',0,0,'UTF-8','{google:baseSuggestURL}search?client=chrome&hl={language}&q={searchTerms}',1,1,6262,0,'{google:baseURL}webhp?{google:RLZ}sourceid=chrome-instant&ie={inputEncoding}&ion=1{searchTerms}&nord=1',0,'{1234-5678-90AB-CDEF}');
+CREATE TABLE logins (origin_url VARCHAR NOT NULL, action_url VARCHAR, username_element VARCHAR, username_value VARCHAR, password_element VARCHAR, password_value BLOB, submit_element VARCHAR, signon_realm VARCHAR NOT NULL,ssl_valid INTEGER NOT NULL,preferred INTEGER NOT NULL,date_created INTEGER NOT NULL,blacklisted_by_user INTEGER NOT NULL,scheme INTEGER NOT NULL,UNIQUE (origin_url, username_element, username_value, password_element, submit_element, signon_realm));
+CREATE TABLE web_app_icons (url LONGVARCHAR,width int,height int,image BLOB, UNIQUE (url, width, height));
+CREATE TABLE web_apps (url LONGVARCHAR UNIQUE,has_all_images INTEGER NOT NULL);
+CREATE TABLE autofill (name VARCHAR, value VARCHAR, value_lower VARCHAR, pair_id INTEGER PRIMARY KEY, count INTEGER DEFAULT 1);
+CREATE TABLE autofill_dates ( pair_id INTEGER DEFAULT 0, date_created INTEGER DEFAULT 0);
+CREATE TABLE autofill_profiles ( guid VARCHAR PRIMARY KEY, company_name VARCHAR, address_line_1 VARCHAR, address_line_2 VARCHAR, city VARCHAR, state VARCHAR, zipcode VARCHAR, country VARCHAR, country_code VARCHAR, date_modified INTEGER NOT NULL DEFAULT 0);
+CREATE TABLE autofill_profile_names ( guid VARCHAR, first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR);
+CREATE TABLE autofill_profile_emails ( guid VARCHAR, email VARCHAR);
+CREATE TABLE autofill_profile_phones ( guid VARCHAR, type INTEGER DEFAULT 0, number VARCHAR);
+CREATE TABLE credit_cards ( guid VARCHAR PRIMARY KEY, name_on_card VARCHAR, expiration_month INTEGER, expiration_year INTEGER, card_number_encrypted BLOB, date_modified INTEGER NOT NULL DEFAULT 0);
+CREATE TABLE token_service (service VARCHAR PRIMARY KEY NOT NULL,encrypted_token BLOB);
+CREATE INDEX logins_signon ON logins (signon_realm);
+CREATE INDEX web_apps_url_index ON web_apps (url);
+CREATE INDEX autofill_name ON autofill (name);
+CREATE INDEX autofill_name_value_lower ON autofill (name, value_lower);
+CREATE INDEX autofill_dates_pair_id ON autofill_dates (pair_id);
+COMMIT;
+

Reply all
Reply to author
Forward
0 new messages