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

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

Issue 1237403003: [Password manager IOS upsteaming] Upstreaming login database (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Histograms Created 5 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 52b726da47080ac93ccb7961feee27602ba1e04e..7236dcf765030d92a83636300417e147e68a7750 100644
--- a/components/password_manager/core/browser/login_database.cc
+++ b/components/password_manager/core/browser/login_database.cc
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/metrics/histogram_macros.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"
@@ -601,6 +602,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,
@@ -665,6 +669,9 @@ PasswordStoreChangeList LoginDatabase::UpdateLogin(const PasswordForm& form) {
}
bool LoginDatabase::RemoveLogin(const PasswordForm& form) {
+#if defined(OS_IOS)
+ DeleteEncryptedPassword(form);
+#endif
if (form.IsPublicSuffixMatch()) {
// Do not try to remove |form|. It is a modified copy of a password stored
// for a different origin, and it is not contained in the database.
@@ -691,6 +698,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 < ?"));
@@ -929,6 +945,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,

Powered by Google App Engine
This is Rietveld 408576698