summaryrefslogtreecommitdiff
path: root/chromium/components/webdata
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2014-03-18 13:16:26 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-03-20 15:55:39 +0100
commit3f0f86b0caed75241fa71c95a5d73bc0164348c5 (patch)
tree92b9fb00f2e9e90b0be2262093876d4f43b6cd13 /chromium/components/webdata
parente90d7c4b152c56919d963987e2503f9909a666d2 (diff)
downloadqtwebengine-chromium-3f0f86b0caed75241fa71c95a5d73bc0164348c5.tar.gz
Update to new stable branch 1750
This also includes an updated ninja and chromium dependencies needed on Windows. Change-Id: Icd597d80ed3fa4425933c9f1334c3c2e31291c42 Reviewed-by: Zoltan Arvai <zarvai@inf.u-szeged.hu> Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'chromium/components/webdata')
-rw-r--r--chromium/components/webdata/DEPS1
-rw-r--r--chromium/components/webdata/common/web_data_results.h2
-rw-r--r--chromium/components/webdata/common/web_database.cc4
-rw-r--r--chromium/components/webdata/common/web_database_migration_unittest.cc268
-rw-r--r--chromium/components/webdata/encryptor/ie7_password_unittest_win.cc110
-rw-r--r--chromium/components/webdata/encryptor/ie7_password_win.cc (renamed from chromium/components/webdata/encryptor/ie7_password.cc)48
-rw-r--r--chromium/components/webdata/encryptor/ie7_password_win.h (renamed from chromium/components/webdata/encryptor/ie7_password.h)24
7 files changed, 326 insertions, 131 deletions
diff --git a/chromium/components/webdata/DEPS b/chromium/components/webdata/DEPS
index 1d575c83aaf..bb777759399 100644
--- a/chromium/components/webdata/DEPS
+++ b/chromium/components/webdata/DEPS
@@ -17,6 +17,7 @@ specific_include_rules = {
"+chrome/browser/webdata/web_data_service.h",
"+chrome/browser/webdata/web_data_service_factory.h",
"+chrome/browser/webdata/web_intents_table.h",
+ "+components/autofill/core",
"+content/public/test",
],
}
diff --git a/chromium/components/webdata/common/web_data_results.h b/chromium/components/webdata/common/web_data_results.h
index 7a225e9c6ee..1878dc0cc18 100644
--- a/chromium/components/webdata/common/web_data_results.h
+++ b/chromium/components/webdata/common/web_data_results.h
@@ -23,7 +23,7 @@ typedef enum {
#endif
WEB_APP_IMAGES, // WDResult<WDAppImagesResult>
TOKEN_RESULT, // WDResult<std::vector<std::string>>
- AUTOFILL_VALUE_RESULT, // WDResult<std::vector<string16>>
+ AUTOFILL_VALUE_RESULT, // WDResult<std::vector<base::string16>>
AUTOFILL_CHANGES, // WDResult<std::vector<AutofillChange>>
AUTOFILL_PROFILE_RESULT, // WDResult<AutofillProfile>
AUTOFILL_PROFILES_RESULT, // WDResult<std::vector<AutofillProfile*>>
diff --git a/chromium/components/webdata/common/web_database.cc b/chromium/components/webdata/common/web_database.cc
index 161fb80bae4..44b67904d56 100644
--- a/chromium/components/webdata/common/web_database.cc
+++ b/chromium/components/webdata/common/web_database.cc
@@ -14,11 +14,11 @@
// corresponding changes must happen in the unit tests, and new migration test
// added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|.
// static
-const int WebDatabase::kCurrentVersionNumber = 53;
+const int WebDatabase::kCurrentVersionNumber = 54;
namespace {
-const int kCompatibleVersionNumber = 48;
+const int kCompatibleVersionNumber = 54;
// Change the version number and possibly the compatibility version of
// |meta_table_|.
diff --git a/chromium/components/webdata/common/web_database_migration_unittest.cc b/chromium/components/webdata/common/web_database_migration_unittest.cc
index 57ef02dc175..9b12facc19d 100644
--- a/chromium/components/webdata/common/web_database_migration_unittest.cc
+++ b/chromium/components/webdata/common/web_database_migration_unittest.cc
@@ -76,15 +76,15 @@ void AutofillProfile33FromStatement(const sql::Statement& s,
profile->set_guid(s.ColumnString(0));
EXPECT_TRUE(base::IsValidGUID(profile->guid()));
profile->SetRawInfo(autofill::COMPANY_NAME, s.ColumnString16(1));
- profile->SetRawInfo(autofill::ADDRESS_HOME_LINE1, s.ColumnString16(2));
- profile->SetRawInfo(autofill::ADDRESS_HOME_LINE2, s.ColumnString16(3));
- profile->SetRawInfo(autofill::ADDRESS_HOME_CITY, s.ColumnString16(4));
- profile->SetRawInfo(autofill::ADDRESS_HOME_STATE, s.ColumnString16(5));
- profile->SetRawInfo(autofill::ADDRESS_HOME_ZIP, s.ColumnString16(6));
+ profile->SetRawInfo(autofill::ADDRESS_HOME_STREET_ADDRESS,
+ s.ColumnString16(2));
+ profile->SetRawInfo(autofill::ADDRESS_HOME_CITY, s.ColumnString16(3));
+ profile->SetRawInfo(autofill::ADDRESS_HOME_STATE, s.ColumnString16(4));
+ profile->SetRawInfo(autofill::ADDRESS_HOME_ZIP, s.ColumnString16(5));
profile->SetInfo(
autofill::AutofillType(autofill::ADDRESS_HOME_COUNTRY),
- s.ColumnString16(7), "en-US");
- *date_modified = s.ColumnInt64(8);
+ s.ColumnString16(6), "en-US");
+ *date_modified = s.ColumnInt64(7);
}
void CreditCard31FromStatement(const sql::Statement& s,
@@ -247,7 +247,7 @@ class WebDatabaseMigrationTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
};
-const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 53;
+const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 54;
void WebDatabaseMigrationTest::LoadDatabase(
const base::FilePath::StringType& file) {
@@ -805,8 +805,8 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion31ToCurrent) {
// Verify data in the database after the migration.
sql::Statement s1(
connection.GetUniqueStatement(
- "SELECT guid, company_name, address_line_1, address_line_2, "
- "city, state, zipcode, country, date_modified "
+ "SELECT guid, company_name, street_address, city, state, zipcode,"
+ " country_code, date_modified "
"FROM autofill_profiles"));
ASSERT_TRUE(s1.Step());
@@ -916,13 +916,12 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles",
"company_name"));
EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles",
- "address_line_1"));
- EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles",
- "address_line_2"));
+ "street_address"));
EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles", "city"));
EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles", "state"));
EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles", "zipcode"));
- EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles", "country"));
+ EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles",
+ "country_code"));
EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles", "phone"));
EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles", "fax"));
EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles",
@@ -943,7 +942,6 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
// New "phones" table.
EXPECT_TRUE(connection.DoesColumnExist("autofill_profile_phones", "guid"));
- EXPECT_TRUE(connection.DoesColumnExist("autofill_profile_phones", "type"));
EXPECT_TRUE(connection.DoesColumnExist("autofill_profile_phones",
"number"));
@@ -952,21 +950,22 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
// Verify data in the database after the migration.
sql::Statement s1(
connection.GetUniqueStatement(
- "SELECT guid, company_name, address_line_1, address_line_2, "
- "city, state, zipcode, country, date_modified "
+ "SELECT guid, company_name, street_address, city, state, zipcode, "
+ " country_code, date_modified "
"FROM autofill_profiles"));
// John Doe.
ASSERT_TRUE(s1.Step());
EXPECT_EQ("00580526-FF81-EE2A-0546-1AC593A32E2F", s1.ColumnString(0));
EXPECT_EQ(ASCIIToUTF16("Doe Enterprises"), s1.ColumnString16(1));
- EXPECT_EQ(ASCIIToUTF16("1 Main St"), s1.ColumnString16(2));
- EXPECT_EQ(ASCIIToUTF16("Apt 1"), s1.ColumnString16(3));
- EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4));
- EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5));
- EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6));
- EXPECT_EQ(ASCIIToUTF16("United States"), s1.ColumnString16(7));
- EXPECT_EQ(1297882100L, s1.ColumnInt64(8));
+ EXPECT_EQ(ASCIIToUTF16("1 Main St\n"
+ "Apt 1"),
+ s1.ColumnString16(2));
+ EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(3));
+ EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(4));
+ EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(5));
+ EXPECT_EQ(ASCIIToUTF16("US"), s1.ColumnString16(6));
+ EXPECT_EQ(1297882100L, s1.ColumnInt64(7));
// John P. Doe.
// Gets merged during migration from 35 to 37 due to multi-valued fields.
@@ -976,24 +975,22 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
EXPECT_EQ("4C74A9D8-7EEE-423E-F9C2-E7FA70ED1396", s1.ColumnString(0));
EXPECT_EQ(base::string16(), s1.ColumnString16(1));
EXPECT_EQ(ASCIIToUTF16("2 Main Street"), s1.ColumnString16(2));
- EXPECT_EQ(base::string16(), s1.ColumnString16(3));
- EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4));
- EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5));
- EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6));
- EXPECT_EQ(ASCIIToUTF16("United States"), s1.ColumnString16(7));
- EXPECT_EQ(1297882100L, s1.ColumnInt64(8));
+ EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(3));
+ EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(4));
+ EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(5));
+ EXPECT_EQ(ASCIIToUTF16("US"), s1.ColumnString16(6));
+ EXPECT_EQ(1297882100L, s1.ColumnInt64(7));
// Dave Smith (Part 2).
ASSERT_TRUE(s1.Step());
EXPECT_EQ("722DF5C4-F74A-294A-46F0-31FFDED0D635", s1.ColumnString(0));
EXPECT_EQ(base::string16(), s1.ColumnString16(1));
EXPECT_EQ(ASCIIToUTF16("2 Main St"), s1.ColumnString16(2));
- EXPECT_EQ(base::string16(), s1.ColumnString16(3));
- EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4));
- EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5));
- EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6));
- EXPECT_EQ(ASCIIToUTF16("United States"), s1.ColumnString16(7));
- EXPECT_EQ(1297882100L, s1.ColumnInt64(8));
+ EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(3));
+ EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(4));
+ EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(5));
+ EXPECT_EQ(ASCIIToUTF16("US"), s1.ColumnString16(6));
+ EXPECT_EQ(1297882100L, s1.ColumnInt64(7));
// Alfred E Newman.
// Gets culled during migration from 35 to 36 due to incomplete address.
@@ -1003,12 +1000,11 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
EXPECT_EQ("9E5FE298-62C7-83DF-6293-381BC589183F", s1.ColumnString(0));
EXPECT_EQ(base::string16(), s1.ColumnString16(1));
EXPECT_EQ(ASCIIToUTF16("3 Main St"), s1.ColumnString16(2));
- EXPECT_EQ(base::string16(), s1.ColumnString16(3));
- EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4));
- EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5));
- EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6));
- EXPECT_EQ(ASCIIToUTF16("United States"), s1.ColumnString16(7));
- EXPECT_EQ(1297882100L, s1.ColumnInt64(8));
+ EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(3));
+ EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(4));
+ EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(5));
+ EXPECT_EQ(ASCIIToUTF16("US"), s1.ColumnString16(6));
+ EXPECT_EQ(1297882100L, s1.ColumnInt64(7));
// That should be all.
EXPECT_FALSE(s1.Step());
@@ -1097,14 +1093,13 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
sql::Statement s4(
connection.GetUniqueStatement(
- "SELECT guid, type, number "
+ "SELECT guid, number "
"FROM autofill_profile_phones"));
// John Doe phone.
ASSERT_TRUE(s4.Step());
EXPECT_EQ("00580526-FF81-EE2A-0546-1AC593A32E2F", s4.ColumnString(0));
- EXPECT_EQ(0, s4.ColumnInt(1)); // 0 means phone.
- EXPECT_EQ(ASCIIToUTF16("4151112222"), s4.ColumnString16(2));
+ EXPECT_EQ(ASCIIToUTF16("4151112222"), s4.ColumnString16(1));
// John Doe fax.
// Gets culled after fax type removed.
@@ -1120,8 +1115,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
// 2 Main Street phone.
ASSERT_TRUE(s4.Step());
EXPECT_EQ("4C74A9D8-7EEE-423E-F9C2-E7FA70ED1396", s4.ColumnString(0));
- EXPECT_EQ(0, s4.ColumnInt(1)); // 0 means phone.
- EXPECT_EQ(base::string16(), s4.ColumnString16(2));
+ EXPECT_EQ(base::string16(), s4.ColumnString16(1));
// 2 Main Street fax.
// Gets culled after fax type removed.
@@ -1140,8 +1134,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) {
// 3 Main St phone.
ASSERT_TRUE(s4.Step());
EXPECT_EQ("9E5FE298-62C7-83DF-6293-381BC589183F", s4.ColumnString(0));
- EXPECT_EQ(0, s4.ColumnInt(1)); // 0 means phone.
- EXPECT_EQ(base::string16(), s4.ColumnString16(2));
+ EXPECT_EQ(base::string16(), s4.ColumnString16(1));
// 2 Main St fax.
// Gets culled after fax type removed.
@@ -1295,21 +1288,22 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion35ToCurrent) {
// Verify data in the database after the migration.
sql::Statement s1(
connection.GetUniqueStatement(
- "SELECT guid, company_name, address_line_1, address_line_2, "
- "city, state, zipcode, country, date_modified "
+ "SELECT guid, company_name, street_address, city, state, zipcode,"
+ " country_code, date_modified "
"FROM autofill_profiles"));
// John Doe.
ASSERT_TRUE(s1.Step());
EXPECT_EQ("00000000-0000-0000-0000-000000000001", s1.ColumnString(0));
EXPECT_EQ(ASCIIToUTF16("Acme Inc."), s1.ColumnString16(1));
- EXPECT_EQ(ASCIIToUTF16("1 Main Street"), s1.ColumnString16(2));
- EXPECT_EQ(ASCIIToUTF16("Apt 2"), s1.ColumnString16(3));
- EXPECT_EQ(ASCIIToUTF16("San Francisco"), s1.ColumnString16(4));
- EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5));
- EXPECT_EQ(ASCIIToUTF16("94102"), s1.ColumnString16(6));
- EXPECT_EQ(ASCIIToUTF16("United States"), s1.ColumnString16(7));
- EXPECT_EQ(1300131704, s1.ColumnInt64(8));
+ EXPECT_EQ(ASCIIToUTF16("1 Main Street\n"
+ "Apt 2"),
+ s1.ColumnString16(2));
+ EXPECT_EQ(ASCIIToUTF16("San Francisco"), s1.ColumnString16(3));
+ EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(4));
+ EXPECT_EQ(ASCIIToUTF16("94102"), s1.ColumnString16(5));
+ EXPECT_EQ(ASCIIToUTF16("US"), s1.ColumnString16(6));
+ EXPECT_EQ(1300131704, s1.ColumnInt64(7));
// That should be it.
ASSERT_FALSE(s1.Step());
@@ -2117,3 +2111,161 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion52ToCurrent) {
EXPECT_TRUE(connection.DoesColumnExist("keywords", "new_tab_url"));
}
}
+
+// Tests that for a version 54 database,
+// (a) The street_address, dependent_locality, and sorting_code columns are
+// added to the autofill_profiles table schema.
+// (b) The address_line1, address_line2, and country columns are dropped from
+// the autofill_profiles table schema.
+// (c) The type column is dropped from the autofill_profile_phones schema.
+TEST_F(WebDatabaseMigrationTest, MigrateVersion53ToCurrent) {
+ ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_53.sql")));
+
+ // Verify pre-conditions. These are expectations for version 53 of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+
+ EXPECT_TRUE(
+ connection.DoesColumnExist("autofill_profiles", "address_line_1"));
+ EXPECT_TRUE(
+ connection.DoesColumnExist("autofill_profiles", "address_line_2"));
+ EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles", "country"));
+ EXPECT_FALSE(
+ connection.DoesColumnExist("autofill_profiles", "street_address"));
+ EXPECT_FALSE(
+ connection.DoesColumnExist("autofill_profiles", "dependent_locality"));
+ EXPECT_FALSE(
+ connection.DoesColumnExist("autofill_profiles", "sorting_code"));
+ EXPECT_TRUE(connection.DoesColumnExist("autofill_profile_phones", "type"));
+ }
+
+ DoMigration();
+
+ // 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));
+
+ // Columns should have been added and removed appropriately.
+ EXPECT_FALSE(
+ connection.DoesColumnExist("autofill_profiles", "address_line1"));
+ EXPECT_FALSE(
+ connection.DoesColumnExist("autofill_profiles", "address_line2"));
+ EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles", "country"));
+ EXPECT_TRUE(
+ connection.DoesColumnExist("autofill_profiles", "street_address"));
+ EXPECT_TRUE(
+ connection.DoesColumnExist("autofill_profiles", "dependent_locality"));
+ EXPECT_TRUE(
+ connection.DoesColumnExist("autofill_profiles", "sorting_code"));
+ EXPECT_FALSE(connection.DoesColumnExist("autofill_profile_phones", "type"));
+
+ // Data should have been preserved.
+ sql::Statement s_profiles(
+ connection.GetUniqueStatement(
+ "SELECT guid, company_name, street_address, dependent_locality,"
+ " city, state, zipcode, sorting_code, country_code, date_modified,"
+ " origin "
+ "FROM autofill_profiles"));
+
+ // Address lines 1 and 2.
+ ASSERT_TRUE(s_profiles.Step());
+ EXPECT_EQ("00000000-0000-0000-0000-000000000001",
+ s_profiles.ColumnString(0));
+ EXPECT_EQ(ASCIIToUTF16("Google, Inc."), s_profiles.ColumnString16(1));
+ EXPECT_EQ(ASCIIToUTF16("1950 Charleston Rd.\n"
+ "(2nd floor)"),
+ s_profiles.ColumnString16(2));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(3));
+ EXPECT_EQ(ASCIIToUTF16("Mountain View"), s_profiles.ColumnString16(4));
+ EXPECT_EQ(ASCIIToUTF16("CA"), s_profiles.ColumnString16(5));
+ EXPECT_EQ(ASCIIToUTF16("94043"), s_profiles.ColumnString16(6));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(7));
+ EXPECT_EQ(ASCIIToUTF16("US"), s_profiles.ColumnString16(8));
+ EXPECT_EQ(1386046731, s_profiles.ColumnInt(9));
+ EXPECT_EQ(ASCIIToUTF16("Chrome settings"), s_profiles.ColumnString16(10));
+
+ // Only address line 1.
+ ASSERT_TRUE(s_profiles.Step());
+ EXPECT_EQ("00000000-0000-0000-0000-000000000002",
+ s_profiles.ColumnString(0));
+ EXPECT_EQ(ASCIIToUTF16("Google!"), s_profiles.ColumnString16(1));
+ EXPECT_EQ(ASCIIToUTF16("1600 Amphitheatre Pkwy."),
+ s_profiles.ColumnString16(2));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(3));
+ EXPECT_EQ(ASCIIToUTF16("Mtn. View"), s_profiles.ColumnString16(4));
+ EXPECT_EQ(ASCIIToUTF16("California"), s_profiles.ColumnString16(5));
+ EXPECT_EQ(ASCIIToUTF16("94043-1234"), s_profiles.ColumnString16(6));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(7));
+ EXPECT_EQ(ASCIIToUTF16("US"), s_profiles.ColumnString16(8));
+ EXPECT_EQ(1386046800, s_profiles.ColumnInt(9));
+ EXPECT_EQ(ASCIIToUTF16("Chrome settings"), s_profiles.ColumnString16(10));
+
+ // Only address line 2.
+ ASSERT_TRUE(s_profiles.Step());
+ EXPECT_EQ("00000000-0000-0000-0000-000000000003",
+ s_profiles.ColumnString(0));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(1));
+ EXPECT_EQ(ASCIIToUTF16("\nOnly line 2???"), s_profiles.ColumnString16(2));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(3));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(4));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(5));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(6));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(7));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(8));
+ EXPECT_EQ(1386046834, s_profiles.ColumnInt(9));
+ EXPECT_EQ(ASCIIToUTF16("Chrome settings"), s_profiles.ColumnString16(10));
+
+ // No address lines.
+ ASSERT_TRUE(s_profiles.Step());
+ EXPECT_EQ("00000000-0000-0000-0000-000000000004",
+ s_profiles.ColumnString(0));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(1));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(2));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(3));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(4));
+ EXPECT_EQ(ASCIIToUTF16("Texas"), s_profiles.ColumnString16(5));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(6));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(7));
+ EXPECT_EQ(base::string16(), s_profiles.ColumnString16(8));
+ EXPECT_EQ(1386046847, s_profiles.ColumnInt(9));
+ EXPECT_EQ(ASCIIToUTF16("Chrome settings"), s_profiles.ColumnString16(10));
+
+ // That should be it.
+ EXPECT_FALSE(s_profiles.Step());
+
+ // Verify the phone number data as well.
+ sql::Statement s_phones(
+ connection.GetUniqueStatement(
+ "SELECT guid, number FROM autofill_profile_phones"));
+
+ ASSERT_TRUE(s_phones.Step());
+ EXPECT_EQ("00000000-0000-0000-0000-000000000001", s_phones.ColumnString(0));
+ EXPECT_EQ(ASCIIToUTF16("1.800.555.1234"), s_phones.ColumnString16(1));
+
+ ASSERT_TRUE(s_phones.Step());
+ EXPECT_EQ("00000000-0000-0000-0000-000000000001", s_phones.ColumnString(0));
+ EXPECT_EQ(ASCIIToUTF16("+1 (800) 555-4321"), s_phones.ColumnString16(1));
+
+ ASSERT_TRUE(s_phones.Step());
+ EXPECT_EQ("00000000-0000-0000-0000-000000000002", s_phones.ColumnString(0));
+ EXPECT_EQ(base::string16(), s_phones.ColumnString16(1));
+
+ ASSERT_TRUE(s_phones.Step());
+ EXPECT_EQ("00000000-0000-0000-0000-000000000003", s_phones.ColumnString(0));
+ EXPECT_EQ(ASCIIToUTF16("6505557890"), s_phones.ColumnString16(1));
+
+ ASSERT_TRUE(s_phones.Step());
+ EXPECT_EQ("00000000-0000-0000-0000-000000000004", s_phones.ColumnString(0));
+ EXPECT_EQ(base::string16(), s_phones.ColumnString16(1));
+
+ EXPECT_FALSE(s_phones.Step());
+ }
+}
diff --git a/chromium/components/webdata/encryptor/ie7_password_unittest_win.cc b/chromium/components/webdata/encryptor/ie7_password_unittest_win.cc
index 37021e8b99e..adfdf3f95c6 100644
--- a/chromium/components/webdata/encryptor/ie7_password_unittest_win.cc
+++ b/chromium/components/webdata/encryptor/ie7_password_unittest_win.cc
@@ -2,59 +2,89 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "testing/gtest/include/gtest/gtest.h"
+#include "components/webdata/encryptor/ie7_password_win.h"
#include <windows.h>
#include <vector>
-#include "base/strings/string16.h"
-#include "components/webdata/encryptor/ie7_password.h"
+#include "testing/gtest/include/gtest/gtest.h"
TEST(IE7PasswordTest, GetUserPassword) {
// This is the unencrypted values of my keys under Storage2.
// The passwords have been manually changed to abcdef... but the size remains
// the same.
- unsigned char data1[] = "\x0c\x00\x00\x00\x38\x00\x00\x00\x2c\x00\x00\x00"
- "\x57\x49\x43\x4b\x18\x00\x00\x00\x02\x00\x00\x00"
- "\x67\x00\x72\x00\x01\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x4e\xfa\x67\x76\x22\x94\xc8\x01"
- "\x08\x00\x00\x00\x12\x00\x00\x00\x4e\xfa\x67\x76"
- "\x22\x94\xc8\x01\x0c\x00\x00\x00\x61\x00\x62\x00"
- "\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00"
- "\x00\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00"
- "\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00"
- "\x6c\x00\x00\x00";
-
- unsigned char data2[] = "\x0c\x00\x00\x00\x38\x00\x00\x00\x24\x00\x00\x00"
- "\x57\x49\x43\x4b\x18\x00\x00\x00\x02\x00\x00\x00"
- "\x67\x00\x72\x00\x01\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\xa8\xea\xf4\xe5\x9f\x9a\xc8\x01"
- "\x09\x00\x00\x00\x14\x00\x00\x00\xa8\xea\xf4\xe5"
- "\x9f\x9a\xc8\x01\x07\x00\x00\x00\x61\x00\x62\x00"
- "\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00"
- "\x69\x00\x00\x00\x61\x00\x62\x00\x63\x00\x64\x00"
- "\x65\x00\x66\x00\x67\x00\x00\x00";
-
+ const unsigned char kData1[] =
+ "\x0c\x00\x00\x00\x38\x00\x00\x00\x2c\x00\x00\x00"
+ "\x57\x49\x43\x4b\x18\x00\x00\x00\x02\x00\x00\x00"
+ "\x67\x00\x72\x00\x01\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x4e\xfa\x67\x76\x22\x94\xc8\x01"
+ "\x08\x00\x00\x00\x12\x00\x00\x00\x4e\xfa\x67\x76"
+ "\x22\x94\xc8\x01\x0c\x00\x00\x00\x61\x00\x62\x00"
+ "\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00"
+ "\x00\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00"
+ "\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00"
+ "\x6c\x00\x00\x00";
+ const unsigned char kData2[] =
+ "\x0c\x00\x00\x00\x38\x00\x00\x00\x24\x00\x00\x00"
+ "\x57\x49\x43\x4b\x18\x00\x00\x00\x02\x00\x00\x00"
+ "\x67\x00\x72\x00\x01\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\xa8\xea\xf4\xe5\x9f\x9a\xc8\x01"
+ "\x09\x00\x00\x00\x14\x00\x00\x00\xa8\xea\xf4\xe5"
+ "\x9f\x9a\xc8\x01\x07\x00\x00\x00\x61\x00\x62\x00"
+ "\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00"
+ "\x69\x00\x00\x00\x61\x00\x62\x00\x63\x00\x64\x00"
+ "\x65\x00\x66\x00\x67\x00\x00\x00";
std::vector<unsigned char> decrypted_data1;
- decrypted_data1.resize(arraysize(data1));
- memcpy(&decrypted_data1.front(), data1, sizeof(data1));
+ decrypted_data1.resize(arraysize(kData1));
+ memcpy(&decrypted_data1.front(), kData1, sizeof(kData1));
std::vector<unsigned char> decrypted_data2;
- decrypted_data2.resize(arraysize(data2));
- memcpy(&decrypted_data2.front(), data2, sizeof(data2));
-
- string16 password;
- string16 username;
- ASSERT_TRUE(ie7_password::GetUserPassFromData(decrypted_data1, &username,
- &password));
- EXPECT_EQ(L"abcdefgh", username);
- EXPECT_EQ(L"abcdefghijkl", password);
-
- ASSERT_TRUE(ie7_password::GetUserPassFromData(decrypted_data2, &username,
- &password));
- EXPECT_EQ(L"abcdefghi", username);
- EXPECT_EQ(L"abcdefg", password);
+ decrypted_data2.resize(arraysize(kData2));
+ memcpy(&decrypted_data2.front(), kData2, sizeof(kData2));
+
+ std::vector<ie7_password::DecryptedCredentials> credentials;
+ ASSERT_TRUE(ie7_password::GetUserPassFromData(decrypted_data1, &credentials));
+ ASSERT_EQ(1u, credentials.size());
+ EXPECT_EQ(L"abcdefgh", credentials[0].username);
+ EXPECT_EQ(L"abcdefghijkl", credentials[0].password);
+
+ credentials.clear();
+ ASSERT_TRUE(ie7_password::GetUserPassFromData(decrypted_data2, &credentials));
+ ASSERT_EQ(1u, credentials.size());
+ EXPECT_EQ(L"abcdefghi", credentials[0].username);
+ EXPECT_EQ(L"abcdefg", credentials[0].password);
+}
+
+TEST(IE7PasswordTest, GetThreeUserPasswords) {
+ // Unencrypted binary data holding 3 sets of credentials
+ const unsigned char kData[] =
+ "\x0c\x00\x00\x00\x78\x00\x00\x00\x48\x00\x00\x00\x57\x49\x43\x4b\x18"
+ "\x00\x00\x00\x06\x00\x00\x00\x5c\x00\x55\x00\x01\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\xc3\xf2\x4b\xda\x1d\xc4\xce\x01\x04\x00\x00"
+ "\x00\x0a\x00\x00\x00\xc3\xf2\x4b\xda\x1d\xc4\xce\x01\x06\x00\x00\x00"
+ "\x18\x00\x00\x00\xbe\x5e\xe9\xe1\x1d\xc4\xce\x01\x04\x00\x00\x00\x22"
+ "\x00\x00\x00\xbe\x5e\xe9\xe1\x1d\xc4\xce\x01\x06\x00\x00\x00\x30\x00"
+ "\x00\x00\x07\x50\x1f\xe6\x1d\xc4\xce\x01\x04\x00\x00\x00\x3a\x00\x00"
+ "\x00\x07\x50\x1f\xe6\x1d\xc4\xce\x01\x06\x00\x00\x00\x71\x00\x77\x00"
+ "\x65\x00\x72\x00\x00\x00\x71\x00\x77\x00\x65\x00\x72\x00\x74\x00\x79"
+ "\x00\x00\x00\x61\x00\x73\x00\x64\x00\x66\x00\x00\x00\x61\x00\x73\x00"
+ "\x64\x00\x66\x00\x67\x00\x68\x00\x00\x00\x7a\x00\x78\x00\x63\x00\x76"
+ "\x00\x00\x00\x7a\x00\x78\x00\x63\x00\x76\x00\x62\x00\x6e\x00\x00\x00";
+
+ std::vector<unsigned char> decrypted_data;
+ decrypted_data.resize(arraysize(kData));
+ memcpy(&decrypted_data.front(), kData, sizeof(kData));
+
+ std::vector<ie7_password::DecryptedCredentials> credentials;
+ ASSERT_TRUE(ie7_password::GetUserPassFromData(decrypted_data, &credentials));
+ ASSERT_EQ(3u, credentials.size());
+ EXPECT_EQ(L"qwer", credentials[0].username);
+ EXPECT_EQ(L"qwerty", credentials[0].password);
+ EXPECT_EQ(L"asdf", credentials[1].username);
+ EXPECT_EQ(L"asdfgh", credentials[1].password);
+ EXPECT_EQ(L"zxcv", credentials[2].username);
+ EXPECT_EQ(L"zxcvbn", credentials[2].password);
}
diff --git a/chromium/components/webdata/encryptor/ie7_password.cc b/chromium/components/webdata/encryptor/ie7_password_win.cc
index e7db3ab3be0..d2d523b3722 100644
--- a/chromium/components/webdata/encryptor/ie7_password.cc
+++ b/chromium/components/webdata/encryptor/ie7_password_win.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright 2013 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.
-#include "components/webdata/encryptor/ie7_password.h"
+#include "components/webdata/encryptor/ie7_password_win.h"
#include <wincrypt.h>
#include <string>
@@ -28,8 +28,7 @@ struct Header {
char wick[4]; // The string "WICK". I don't know what it means.
DWORD fixed_header_size; // The size of this structure without the entries:
// sizeof(Header).
- DWORD item_count; // Number of entries. It should always be 2. One for
- // the username, and one for the password.
+ DWORD item_count; // Number of entries. Should be even.
wchar_t two_letters[2]; // Two unknown bytes.
DWORD unknown[2]; // Two unknown DWORDs.
};
@@ -45,17 +44,16 @@ struct Entry {
struct PasswordEntry {
PreHeader pre_header; // Contains the size of the different sections.
Header header; // Contains the number of items.
- Entry entry[1]; // List of entries containing a string. The first one
- // is the username, the second one if the password.
+ Entry entry[1]; // List of entries containing a string. Even-indexed
+ // are usernames, odd are passwords. There may be
+ // several sets saved for a single url hash.
};
-
} // namespace
namespace ie7_password {
bool GetUserPassFromData(const std::vector<unsigned char>& data,
- std::wstring* username,
- std::wstring* password) {
+ std::vector<DecryptedCredentials>* credentials) {
const PasswordEntry* information =
reinterpret_cast<const PasswordEntry*>(&data.front());
@@ -64,23 +62,29 @@ bool GetUserPassFromData(const std::vector<unsigned char>& data,
if (information->pre_header.pre_header_size != sizeof(PreHeader))
return false;
- if (information->header.item_count != 2) // Username and Password
+ const int entry_count = information->header.item_count;
+ if (entry_count % 2) // Usernames and Passwords
return false;
if (information->header.fixed_header_size != sizeof(Header))
return false;
- const uint8* ptr = &data.front();
- const uint8* offset_to_data = ptr + information->pre_header.header_size +
+ const uint8* offset_to_data = &data[0] +
+ information->pre_header.header_size +
information->pre_header.pre_header_size;
- const Entry* user_entry = information->entry;
- const Entry* pass_entry = user_entry+1;
+ for (int i = 0; i < entry_count / 2; ++i) {
+
+ const Entry* user_entry = &information->entry[2*i];
+ const Entry* pass_entry = user_entry+1;
- *username = reinterpret_cast<const wchar_t*>(offset_to_data +
- user_entry->offset);
- *password = reinterpret_cast<const wchar_t*>(offset_to_data +
- pass_entry->offset);
+ DecryptedCredentials c;
+ c.username = reinterpret_cast<const wchar_t*>(offset_to_data +
+ user_entry->offset);
+ c.password = reinterpret_cast<const wchar_t*>(offset_to_data +
+ pass_entry->offset);
+ credentials->push_back(c);
+ }
return true;
}
@@ -108,9 +112,9 @@ std::wstring GetUrlHash(const std::wstring& url) {
return url_hash;
}
-bool DecryptPassword(const std::wstring& url,
- const std::vector<unsigned char>& data,
- std::wstring* username, std::wstring* password) {
+bool DecryptPasswords(const std::wstring& url,
+ const std::vector<unsigned char>& data,
+ std::vector<DecryptedCredentials>* credentials) {
std::wstring lower_case_url = StringToLowerASCII(url);
DATA_BLOB input = {0};
DATA_BLOB output = {0};
@@ -132,7 +136,7 @@ bool DecryptPassword(const std::wstring& url,
decrypted_data.resize(output.cbData);
memcpy(&decrypted_data.front(), output.pbData, output.cbData);
- GetUserPassFromData(decrypted_data, username, password);
+ GetUserPassFromData(decrypted_data, credentials);
LocalFree(output.pbData);
return true;
diff --git a/chromium/components/webdata/encryptor/ie7_password.h b/chromium/components/webdata/encryptor/ie7_password_win.h
index 458426640d8..78f91c44d8d 100644
--- a/chromium/components/webdata/encryptor/ie7_password.h
+++ b/chromium/components/webdata/encryptor/ie7_password_win.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright 2013 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.
@@ -27,16 +27,24 @@ struct IE7PasswordInfo {
namespace ie7_password {
-// Parses a data structure to find the password and the username.
+struct DecryptedCredentials {
+ std::wstring username;
+ std::wstring password;
+};
+
+// Parses a data structure to find passwords and usernames.
+// The collection of bytes in |data| is interpreted as a special PasswordEntry
+// structure. IE saves the login information as a binary dump of this structure.
+// Credentials extracted from |data| end up in |credentials|.
bool GetUserPassFromData(const std::vector<unsigned char>& data,
- std::wstring* username,
- std::wstring* password);
+ std::vector<DecryptedCredentials>* credentials);
-// Decrypts the username and password for a given data vector using the url as
+// Decrypts usernames and passwords for a given data vector using the url as
// the key.
-bool DecryptPassword(const std::wstring& url,
- const std::vector<unsigned char>& data,
- std::wstring* username, std::wstring* password);
+// Output ends up in |credentials|.
+bool DecryptPasswords(const std::wstring& url,
+ const std::vector<unsigned char>& data,
+ std::vector<DecryptedCredentials>* credentials);
// Returns the hash of a url.
std::wstring GetUrlHash(const std::wstring& url);