| 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 5bb071f5e7a932e41aa277d6eaf196ae8fd1ee3a..9e477e50761b89893f96adcdd8c1ee147f902be6 100644
|
| --- a/components/password_manager/core/browser/login_database.cc
|
| +++ b/components/password_manager/core/browser/login_database.cc
|
| @@ -361,7 +361,8 @@ PasswordStoreChangeList LoginDatabase::UpdateLogin(const PasswordForm& form) {
|
| "preferred = ?, "
|
| "possible_usernames = ?, "
|
| "times_used = ?, "
|
| - "submit_element = ? "
|
| + "submit_element = ?, "
|
| + "date_synced = ? "
|
| "WHERE origin_url = ? AND "
|
| "username_element = ? AND "
|
| "username_value = ? AND "
|
| @@ -376,12 +377,13 @@ PasswordStoreChangeList LoginDatabase::UpdateLogin(const PasswordForm& form) {
|
| s.BindBlob(4, pickle.data(), pickle.size());
|
| s.BindInt(5, form.times_used);
|
| s.BindString16(6, form.submit_element);
|
| + s.BindInt64(7, form.date_synced.ToInternalValue());
|
|
|
| - s.BindString(7, form.origin.spec());
|
| - s.BindString16(8, form.username_element);
|
| - s.BindString16(9, form.username_value);
|
| - s.BindString16(10, form.password_element);
|
| - s.BindString(11, form.signon_realm);
|
| + s.BindString(8, form.origin.spec());
|
| + s.BindString16(9, form.username_element);
|
| + s.BindString16(10, form.username_value);
|
| + s.BindString16(11, form.password_element);
|
| + s.BindString(12, form.signon_realm);
|
|
|
| if (!s.Run())
|
| return PasswordStoreChangeList();
|
| @@ -425,6 +427,18 @@ bool LoginDatabase::RemoveLoginsCreatedBetween(const base::Time delete_begin,
|
| return s.Run();
|
| }
|
|
|
| +bool LoginDatabase::RemoveLoginsSyncedBetween(const base::Time delete_begin,
|
| + const base::Time delete_end) {
|
| + sql::Statement s(db_.GetCachedStatement(
|
| + SQL_FROM_HERE,
|
| + "DELETE FROM logins WHERE date_synced >= ? AND date_synced < ?"));
|
| + s.BindInt64(0, delete_begin.ToInternalValue());
|
| + s.BindInt64(1, delete_end.is_null() ? base::Time::Max().ToInternalValue()
|
| + : delete_end.ToInternalValue());
|
| +
|
| + return s.Run();
|
| +}
|
| +
|
| LoginDatabase::EncryptionResult LoginDatabase::InitPasswordFormFromStatement(
|
| PasswordForm* form,
|
| sql::Statement& s) const {
|
| @@ -603,6 +617,37 @@ bool LoginDatabase::GetLoginsCreatedBetween(
|
| return s.Succeeded();
|
| }
|
|
|
| +bool LoginDatabase::GetLoginsSyncedBetween(
|
| + const base::Time begin,
|
| + const base::Time end,
|
| + std::vector<autofill::PasswordForm*>* forms) const {
|
| + DCHECK(forms);
|
| + sql::Statement s(db_.GetCachedStatement(
|
| + SQL_FROM_HERE,
|
| + "SELECT origin_url, action_url, username_element, username_value, "
|
| + "password_element, password_value, submit_element, signon_realm, "
|
| + "ssl_valid, preferred, date_created, blacklisted_by_user, "
|
| + "scheme, password_type, possible_usernames, times_used, form_data, "
|
| + "use_additional_auth, date_synced FROM logins "
|
| + "WHERE date_synced >= ? AND date_synced < ?"
|
| + "ORDER BY origin_url"));
|
| + s.BindInt64(0, begin.ToInternalValue());
|
| + s.BindInt64(1, end.is_null() ? base::Time::Max().ToInternalValue()
|
| + : end.ToInternalValue());
|
| +
|
| + while (s.Step()) {
|
| + scoped_ptr<PasswordForm> new_form(new PasswordForm());
|
| + EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s);
|
| + if (result == ENCRYPTION_RESULT_SERVICE_FAILURE)
|
| + return false;
|
| + if (result == ENCRYPTION_RESULT_ITEM_FAILURE)
|
| + continue;
|
| + DCHECK(result == ENCRYPTION_RESULT_SUCCESS);
|
| + forms->push_back(new_form.release());
|
| + }
|
| + return s.Succeeded();
|
| +}
|
| +
|
| bool LoginDatabase::GetAutofillableLogins(
|
| std::vector<PasswordForm*>* forms) const {
|
| return GetAllLoginsWithBlacklistSetting(false, forms);
|
|
|