Commit a125658f authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Passwords] Drop "preferred" column from "logins" table.

Column "preferred" has been deprecated and replaced with
"date_last_used" in M81.

It has been left around though for a grace period to give users enough
time to migrate the old values.

The column is now dropped completely in M87.

For users who will upgrade Chrome from 80 directly to M87, they lose
their preferences for which credentials to be filled by default
where multiple credentials exists per website.

Since we are dropping a column, old Chrome binaries won't be able to
read the current database schema anymore. Those users who use an old
binary with the current database, will lose access to password manager.

This should be aligned with go/cbe-downgrade-snapshot

Bug: 997670
Change-Id: I6be32dfc9f17d5e165ebc236f55f95accb88c397
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2396119
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804890}
parent 25a95dfe
......@@ -534,6 +534,7 @@ bundle_data("unit_tests_bundle_data") {
"//components/test/data/password_manager/login_db_v25.sql",
"//components/test/data/password_manager/login_db_v26.sql",
"//components/test/data/password_manager/login_db_v27.sql",
"//components/test/data/password_manager/login_db_v28.sql",
"//components/test/data/password_manager/login_db_v2_broken.sql",
"//components/test/data/password_manager/login_db_v3.sql",
"//components/test/data/password_manager/login_db_v3_broken.sql",
......
......@@ -58,10 +58,10 @@ using autofill::PasswordForm;
namespace password_manager {
// The current version number of the login database schema.
const int kCurrentVersionNumber = 27;
const int kCurrentVersionNumber = 28;
// The oldest version of the schema such that a legacy Chrome client using that
// version can still read/write the current database.
const int kCompatibleVersionNumber = 19;
const int kCompatibleVersionNumber = 28;
base::Pickle SerializeValueElementPairs(
const autofill::ValueElementVector& vec) {
......@@ -150,9 +150,6 @@ enum LoginDatabaseTableColumns {
COLUMN_PASSWORD_VALUE,
COLUMN_SUBMIT_ELEMENT,
COLUMN_SIGNON_REALM,
// TODO(crbug.com/999949): The "preferred" column isn't used anymore and
// should be dropped from the schema in M84.
COLUMN_PREFERRED,
COLUMN_DATE_CREATED,
COLUMN_BLACKLISTED_BY_USER,
COLUMN_SCHEME,
......@@ -208,8 +205,6 @@ void BindAddStatement(const PasswordForm& form, sql::Statement* s) {
static_cast<int>(form.encrypted_password.length()));
s->BindString16(COLUMN_SUBMIT_ELEMENT, form.submit_element);
s->BindString(COLUMN_SIGNON_REALM, form.signon_realm);
// The "preferred" column has been deprecated in M81.
s->BindInt(COLUMN_PREFERRED, 0);
s->BindInt64(COLUMN_DATE_CREATED, form.date_created.ToInternalValue());
s->BindInt(COLUMN_BLACKLISTED_BY_USER, form.blocked_by_user);
s->BindInt(COLUMN_SCHEME, static_cast<int>(form.scheme));
......@@ -438,6 +433,10 @@ void InitializeBuilders(SQLTableBuilders builders) {
builders.logins->AddColumn("moving_blocked_for", "BLOB");
SealVersion(builders, /*expected_version=*/27u);
// Version 28.
builders.logins->DropColumn("preferred");
SealVersion(builders, /*expected_version=*/28u);
DCHECK_EQ(static_cast<size_t>(COLUMN_NUM), builders.logins->NumberOfColumns())
<< "Adjust LoginDatabaseTableColumns if you change column definitions "
"here.";
......@@ -532,26 +531,6 @@ bool MigrateLogins(unsigned current_version,
return false;
}
// "date_last_used" column has been introduced and we should migrate the data
// in "preferred" column. We set the value of "date_last_used"
// deterministically such the final output will be consistent across syncing
// clients.
// TODO(crbug.com/997670): Drop the "preferred" column together with this
// migration code in M82.
if (current_version < 25) {
sql::Statement preferred_stmt;
preferred_stmt.Assign(db->GetCachedStatement(
SQL_FROM_HERE,
"UPDATE logins SET date_last_used = ? WHERE preferred > 0"));
// Set the preferred password to be last used one day after the Windows
// Epoch to make sure the "preferred" password is used more recently.
// Non-preferred passwords carry the default value of 0 (which maps to the
// Windows Epoch).
preferred_stmt.BindInt64(0, base::TimeDelta::FromDays(1).InMicroseconds());
if (!preferred_stmt.Run())
return false;
}
return true;
}
......@@ -1084,7 +1063,6 @@ void LoginDatabase::ReportDuplicateCredentialsMetrics() {
void LoginDatabase::ReportMetrics(const std::string& sync_username,
bool custom_passphrase_sync_enabled,
BulkCheckDone bulk_check_done) {
TRACE_EVENT0("passwords", "LoginDatabase::ReportMetrics");
ReportNumberOfAccountsMetrics(custom_passphrase_sync_enabled);
......@@ -1207,8 +1185,6 @@ PasswordStoreChangeList LoginDatabase::UpdateLogin(const PasswordForm& form,
s.BindBlob(next_param++, encrypted_password.data(),
static_cast<int>(encrypted_password.length()));
s.BindString16(next_param++, form.submit_element);
// This is the "preferred" column which has been deprecated in M81.
s.BindInt(next_param++, 0);
s.BindInt64(next_param++, form.date_created.ToInternalValue());
s.BindInt(next_param++, form.blocked_by_user);
s.BindInt(next_param++, static_cast<int>(form.scheme));
......
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR);
INSERT INTO "meta" VALUES('last_compatible_version','28');
INSERT INTO "meta" VALUES('version','28');
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,
date_created INTEGER NOT NULL,
blacklisted_by_user INTEGER NOT NULL,
scheme INTEGER NOT NULL,
password_type INTEGER,
times_used INTEGER,
form_data BLOB,
date_synced INTEGER,
display_name VARCHAR,
icon_url VARCHAR,
federation_url VARCHAR,
skip_zero_click INTEGER,
generation_upload_status INTEGER,
possible_username_pairs BLOB,
id INTEGER PRIMARY KEY AUTOINCREMENT,
date_last_used INTEGER,
moving_blocked_for BLOB,
UNIQUE (origin_url, username_element, username_value, password_element, signon_realm));
INSERT INTO "logins" (origin_url,action_url,username_element,username_value,password_element,password_value,submit_element,signon_realm,date_created,blacklisted_by_user,scheme,password_type,times_used,form_data,date_synced,display_name,icon_url,federation_url,skip_zero_click,generation_upload_status,possible_username_pairs,date_last_used,moving_blocked_for) VALUES(
'https://accounts.google.com/ServiceLogin', /* origin_url */
'https://accounts.google.com/ServiceLoginAuth', /* action_url */
'Email', /* username_element */
'theerikchen', /* username_value */
'Passwd', /* password_element */
X'', /* password_value */
'', /* submit_element */
'https://accounts.google.com/', /* signon_realm */
13047429345000000, /* date_created */
0, /* blacklisted_by_user */
0, /* scheme */
0, /* password_type */
1, /* times_used */
X'18000000020000000000000000000000000000000000000000000000', /* form_data */
0, /* date_synced */
'', /* display_name */
'', /* icon_url */
'', /* federation_url */
1, /* skip_zero_click */
0, /* generation_upload_status */
X'00000000', /* possible_username_pairs */
0, /* date_last_used */
X'' /* moving_blocked_for */
);
INSERT INTO "logins" (origin_url,action_url,username_element,username_value,password_element,password_value,submit_element,signon_realm,date_created,blacklisted_by_user,scheme,password_type,times_used,form_data,date_synced,display_name,icon_url,federation_url,skip_zero_click,generation_upload_status,possible_username_pairs,date_last_used,moving_blocked_for) VALUES(
'https://accounts.google.com/ServiceLogin', /* origin_url */
'https://accounts.google.com/ServiceLoginAuth', /* action_url */
'Email', /* username_element */
'theerikchen2', /* username_value */
'Passwd', /* password_element */
X'', /* password_value */
'non-empty', /* submit_element */
'https://accounts.google.com/', /* signon_realm */
13047423600000000, /* date_created */
0, /* blacklisted_by_user */
0, /* scheme */
0, /* password_type */
1, /* times_used */
X'18000000020000000000000000000000000000000000000000000000', /* form_data */
0, /* date_synced */
'', /* display_name */
'https://www.google.com/icon', /* icon_url */
'', /* federation_url */
1, /* skip_zero_click */
0, /* generation_upload_status */
X'00000000', /* possible_username_pairs */
0, /* date_last_used */
X'2400000020000000931DDD1C53CCD2CE11C30C3027798FF7E31CCFE83FB086F3A7797F404D647332' /* moving_blocked_for */
);
INSERT INTO "logins" (origin_url,action_url,username_element,username_value,password_element,password_value,submit_element,signon_realm,date_created,blacklisted_by_user,scheme,password_type,times_used,form_data,date_synced,display_name,icon_url,federation_url,skip_zero_click,generation_upload_status,possible_username_pairs,date_last_used,moving_blocked_for) VALUES(
'http://example.com', /* origin_url */
'http://example.com/landing', /* action_url */
'', /* username_element */
'user', /* username_value */
'', /* password_element */
X'', /* password_value */
'non-empty', /* submit_element */
'http://example.com', /* signon_realm */
13047423600000000, /* date_created */
0, /* blacklisted_by_user */
1, /* scheme */
0, /* password_type */
1, /* times_used */
X'18000000020000000000000000000000000000000000000000000000', /* form_data */
0, /* date_synced */
'', /* display_name */
'https://www.google.com/icon', /* icon_url */
'', /* federation_url */
1, /* skip_zero_click */
0, /* generation_upload_status */
X'00000000', /* possible_username_pairs */
0, /* date_last_used */
X'' /* moving_blocked_for */
);
CREATE INDEX logins_signon ON logins (signon_realm);
CREATE TABLE stats (
origin_domain VARCHAR NOT NULL,
username_value VARCHAR,
dismissal_count INTEGER,
update_time INTEGER NOT NULL,
UNIQUE(origin_domain, username_value));
CREATE INDEX stats_origin ON stats(origin_domain);
CREATE TABLE sync_entities_metadata (
storage_key INTEGER PRIMARY KEY AUTOINCREMENT,
metadata VARCHAR NOT NULL
);
CREATE TABLE sync_model_metadata (
id INTEGER PRIMARY KEY AUTOINCREMENT,
metadata VARCHAR NOT NULL
);
COMMIT;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment