Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Unified Diff: components/password_manager/core/browser/login_database.cc

Issue 2985373002: Revert of [Password Manager] Send username correction votes (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/password_manager/core/browser/login_database.cc
diff --git a/components/password_manager/core/browser/login_database.cc b/components/password_manager/core/browser/login_database.cc
index 5de021e0ea7f70dfed308a45bfe280a20d6961a4..ff7d4da279494411702d1a367111191618c5bbc3 100644
--- a/components/password_manager/core/browser/login_database.cc
+++ b/components/password_manager/core/browser/login_database.cc
@@ -44,32 +44,26 @@
namespace password_manager {
// The current version number of the login database schema.
-const int kCurrentVersionNumber = 19;
+const int kCurrentVersionNumber = 18;
// 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;
-
-base::Pickle SerializePossibleUsernamePairs(
- const autofill::PossibleUsernamesVector& vec) {
+const int kCompatibleVersionNumber = 18;
+
+base::Pickle SerializeVector(const std::vector<base::string16>& vec) {
base::Pickle p;
for (size_t i = 0; i < vec.size(); ++i) {
- p.WriteString16(vec[i].first);
- p.WriteString16(vec[i].second);
+ p.WriteString16(vec[i]);
}
return p;
}
-autofill::PossibleUsernamesVector DeserializePossibleUsernamePairs(
- const base::Pickle& p) {
- autofill::PossibleUsernamesVector ret;
- base::string16 value;
- base::string16 field_name;
+std::vector<base::string16> DeserializeVector(const base::Pickle& p) {
+ std::vector<base::string16> ret;
+ base::string16 str;
base::PickleIterator iterator(p);
- while (iterator.ReadString16(&value)) {
- bool name_success = iterator.ReadString16(&field_name);
- DCHECK(name_success);
- ret.push_back(autofill::PossibleUsernamePair(value, field_name));
+ while (iterator.ReadString16(&str)) {
+ ret.push_back(str);
}
return ret;
}
@@ -91,6 +85,7 @@
COLUMN_BLACKLISTED_BY_USER,
COLUMN_SCHEME,
COLUMN_PASSWORD_TYPE,
+ COLUMN_POSSIBLE_USERNAMES,
COLUMN_TIMES_USED,
COLUMN_FORM_DATA,
COLUMN_DATE_SYNCED,
@@ -99,7 +94,6 @@
COLUMN_FEDERATION_URL,
COLUMN_SKIP_ZERO_CLICK,
COLUMN_GENERATION_UPLOAD_STATUS,
- COLUMN_POSSIBLE_USERNAME_PAIRS,
COLUMN_NUM // Keep this last.
};
@@ -137,6 +131,11 @@
s->BindInt(COLUMN_BLACKLISTED_BY_USER, form.blacklisted_by_user);
s->BindInt(COLUMN_SCHEME, form.scheme);
s->BindInt(COLUMN_PASSWORD_TYPE, form.type);
+ base::Pickle usernames_pickle =
+ SerializeVector(form.other_possible_usernames);
+ s->BindBlob(COLUMN_POSSIBLE_USERNAMES,
+ usernames_pickle.data(),
+ usernames_pickle.size());
s->BindInt(COLUMN_TIMES_USED, form.times_used);
base::Pickle form_data_pickle;
autofill::SerializeFormData(form.form_data, &form_data_pickle);
@@ -153,10 +152,6 @@
: form.federation_origin.Serialize());
s->BindInt(COLUMN_SKIP_ZERO_CLICK, form.skip_zero_click);
s->BindInt(COLUMN_GENERATION_UPLOAD_STATUS, form.generation_upload_status);
- base::Pickle usernames_pickle =
- SerializePossibleUsernamePairs(form.other_possible_usernames);
- s->BindBlob(COLUMN_POSSIBLE_USERNAME_PAIRS, usernames_pickle.data(),
- usernames_pickle.size());
}
void AddCallback(int err, sql::Statement* /*stmt*/) {
@@ -435,12 +430,6 @@
builder->DropColumn("ssl_valid");
version = builder->SealVersion();
DCHECK_EQ(18u, version);
-
- // Version 19.
- builder->DropColumn("possible_usernames");
- builder->AddColumn("possible_username_pairs", "BLOB");
- version = builder->SealVersion();
- DCHECK_EQ(19u, version);
DCHECK_EQ(static_cast<size_t>(COLUMN_NUM), builder->NumberOfColumns())
<< "Adjust LoginTableColumns if you change column definitions here.";
@@ -855,43 +844,37 @@
DCHECK(!update_statement_.empty());
sql::Statement s(
db_.GetCachedStatement(SQL_FROM_HERE, update_statement_.c_str()));
- int next_param = 0;
- s.BindString(next_param++, form.action.spec());
- s.BindBlob(next_param++, encrypted_password.data(),
+ s.BindString(0, form.action.spec());
+ s.BindBlob(1, encrypted_password.data(),
static_cast<int>(encrypted_password.length()));
- s.BindString16(next_param++, form.submit_element);
- s.BindInt(next_param++, form.preferred);
- s.BindInt64(next_param++, form.date_created.ToInternalValue());
- s.BindInt(next_param++, form.blacklisted_by_user);
- s.BindInt(next_param++, form.scheme);
- s.BindInt(next_param++, form.type);
- s.BindInt(next_param++, form.times_used);
+ s.BindString16(2, form.submit_element);
+ s.BindInt(3, form.preferred);
+ s.BindInt64(4, form.date_created.ToInternalValue());
+ s.BindInt(5, form.blacklisted_by_user);
+ s.BindInt(6, form.scheme);
+ s.BindInt(7, form.type);
+ base::Pickle pickle = SerializeVector(form.other_possible_usernames);
+ s.BindBlob(8, pickle.data(), pickle.size());
+ s.BindInt(9, form.times_used);
base::Pickle form_data_pickle;
autofill::SerializeFormData(form.form_data, &form_data_pickle);
- s.BindBlob(next_param++, form_data_pickle.data(), form_data_pickle.size());
- s.BindInt64(next_param++, form.date_synced.ToInternalValue());
- s.BindString16(next_param++, form.display_name);
- s.BindString(next_param++, form.icon_url.spec());
+ s.BindBlob(10, form_data_pickle.data(), form_data_pickle.size());
+ s.BindInt64(11, form.date_synced.ToInternalValue());
+ s.BindString16(12, form.display_name);
+ s.BindString(13, form.icon_url.spec());
// An empty Origin serializes as "null" which would be strange to store here.
- s.BindString(next_param++, form.federation_origin.unique()
- ? std::string()
- : form.federation_origin.Serialize());
- s.BindInt(next_param++, form.skip_zero_click);
- s.BindInt(next_param++, form.generation_upload_status);
- base::Pickle username_pickle =
- SerializePossibleUsernamePairs(form.other_possible_usernames);
- s.BindBlob(next_param++, username_pickle.data(), username_pickle.size());
- // NOTE: Add new fields here unless the field is a part of the unique key.
- // If so, add new field below.
+ s.BindString(14, form.federation_origin.unique()
+ ? std::string()
+ : form.federation_origin.Serialize());
+ s.BindInt(15, form.skip_zero_click);
+ s.BindInt(16, form.generation_upload_status);
// WHERE starts here.
- s.BindString(next_param++, form.origin.spec());
- s.BindString16(next_param++, form.username_element);
- s.BindString16(next_param++, form.username_value);
- s.BindString16(next_param++, form.password_element);
- s.BindString(next_param++, form.signon_realm);
- // NOTE: Add new fields here only if the field is a part of the unique key.
- // Otherwise, add the field above "WHERE starts here" comment.
+ s.BindString(17, form.origin.spec());
+ s.BindString16(18, form.username_element);
+ s.BindString16(19, form.username_value);
+ s.BindString16(20, form.password_element);
+ s.BindString(21, form.signon_realm);
if (!s.Run())
return PasswordStoreChangeList();
@@ -1015,11 +998,11 @@
int type_int = s.ColumnInt(COLUMN_PASSWORD_TYPE);
DCHECK(type_int >= 0 && type_int <= PasswordForm::TYPE_LAST) << type_int;
form->type = static_cast<PasswordForm::Type>(type_int);
- if (s.ColumnByteLength(COLUMN_POSSIBLE_USERNAME_PAIRS)) {
+ if (s.ColumnByteLength(COLUMN_POSSIBLE_USERNAMES)) {
base::Pickle pickle(
- static_cast<const char*>(s.ColumnBlob(COLUMN_POSSIBLE_USERNAME_PAIRS)),
- s.ColumnByteLength(COLUMN_POSSIBLE_USERNAME_PAIRS));
- form->other_possible_usernames = DeserializePossibleUsernamePairs(pickle);
+ static_cast<const char*>(s.ColumnBlob(COLUMN_POSSIBLE_USERNAMES)),
+ s.ColumnByteLength(COLUMN_POSSIBLE_USERNAMES));
+ form->other_possible_usernames = DeserializeVector(pickle);
}
form->times_used = s.ColumnInt(COLUMN_TIMES_USED);
if (s.ColumnByteLength(COLUMN_FORM_DATA)) {
« no previous file with comments | « components/password_manager/core/browser/BUILD.gn ('k') | components/password_manager/core/browser/login_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698