| 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 f241b0080ab8824878a57f92bfdce11998aaa0b5..619bf63a24691465d79ad4845d29df8cb29d2119 100644
|
| --- a/components/password_manager/core/browser/login_database.cc
|
| +++ b/components/password_manager/core/browser/login_database.cc
|
| @@ -13,6 +13,7 @@
|
| #include "base/metrics/histogram_macros.h"
|
| #include "base/metrics/sparse_histogram.h"
|
| #include "base/pickle.h"
|
| +#include "base/stl_util.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "base/time/time.h"
|
| @@ -878,6 +879,9 @@ PasswordStoreChangeList LoginDatabase::UpdateLogin(const PasswordForm& form) {
|
| &encrypted_password) != ENCRYPTION_RESULT_SUCCESS)
|
| return PasswordStoreChangeList();
|
|
|
| +#if defined(OS_IOS)
|
| + DeleteEncryptedPassword(form);
|
| +#endif
|
| // Replacement is necessary to deal with updating imported credentials. See
|
| // crbug.com/349138 for details.
|
| sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE,
|
| @@ -947,6 +951,9 @@ bool LoginDatabase::RemoveLogin(const PasswordForm& form) {
|
| // credentials.
|
| return false;
|
| }
|
| +#if defined(OS_IOS)
|
| + DeleteEncryptedPassword(form);
|
| +#endif
|
| // Remove a login by UNIQUE-constrained fields.
|
| sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE,
|
| "DELETE FROM logins WHERE "
|
| @@ -968,6 +975,15 @@ bool LoginDatabase::RemoveLogin(const PasswordForm& form) {
|
|
|
| bool LoginDatabase::RemoveLoginsCreatedBetween(base::Time delete_begin,
|
| base::Time delete_end) {
|
| +#if defined(OS_IOS)
|
| + ScopedVector<autofill::PasswordForm> forms;
|
| + if (GetLoginsCreatedBetween(delete_begin, delete_end, &forms)) {
|
| + for (size_t i = 0; i < forms.size(); i++) {
|
| + DeleteEncryptedPassword(*forms[i]);
|
| + }
|
| + }
|
| +#endif
|
| +
|
| sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE,
|
| "DELETE FROM logins WHERE "
|
| "date_created >= ? AND date_created < ?"));
|
| @@ -1207,6 +1223,32 @@ bool LoginDatabase::DeleteAndRecreateDatabaseFile() {
|
| return Init();
|
| }
|
|
|
| +std::string LoginDatabase::GetEncryptedPassword(
|
| + const autofill::PasswordForm& form) const {
|
| + sql::Statement s(
|
| + db_.GetCachedStatement(SQL_FROM_HERE,
|
| + "SELECT password_value FROM logins WHERE "
|
| + "origin_url = ? AND "
|
| + "username_element = ? AND "
|
| + "username_value = ? AND "
|
| + "password_element = ? AND "
|
| + "submit_element = ? AND "
|
| + "signon_realm = ? "));
|
| +
|
| + s.BindString(0, form.origin.spec());
|
| + s.BindString16(1, form.username_element);
|
| + s.BindString16(2, form.username_value);
|
| + s.BindString16(3, form.password_element);
|
| + s.BindString16(4, form.submit_element);
|
| + s.BindString(5, form.signon_realm);
|
| +
|
| + std::string encrypted_password;
|
| + if (s.Step()) {
|
| + s.ColumnBlobAsString(0, &encrypted_password);
|
| + }
|
| + return encrypted_password;
|
| +}
|
| +
|
| // static
|
| bool LoginDatabase::StatementToForms(
|
| sql::Statement* statement,
|
|
|