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

Unified Diff: chrome/browser/password_manager/native_backend_gnome_x.cc

Issue 335893002: Support to remove passwords by date_synced timestamp. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync integration tests Created 6 years, 6 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: chrome/browser/password_manager/native_backend_gnome_x.cc
diff --git a/chrome/browser/password_manager/native_backend_gnome_x.cc b/chrome/browser/password_manager/native_backend_gnome_x.cc
index 6b4236a0c25c1e02c5949a749c542d8a4de0bd03..f37ae62a0a6c25519d8353572a93f93b3f61d930 100644
--- a/chrome/browser/password_manager/native_backend_gnome_x.cc
+++ b/chrome/browser/password_manager/native_backend_gnome_x.cc
@@ -642,26 +642,16 @@ bool NativeBackendGnome::RemoveLogin(const PasswordForm& form) {
return true;
}
-bool NativeBackendGnome::RemoveLoginsCreatedBetween(
- const base::Time& delete_begin,
- const base::Time& delete_end) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
- bool ok = true;
- // We could walk the list and delete items as we find them, but it is much
- // easier to build the list and use RemoveLogin() to delete them.
- PasswordFormList forms;
- if (!GetAllLogins(&forms))
- return false;
+bool NativeBackendGnome::RemoveLoginsCreatedBetween(base::Time delete_begin,
+ base::Time delete_end) {
+ return RemoveLoginsBetween(delete_begin, delete_end, true, NULL);
+}
- for (size_t i = 0; i < forms.size(); ++i) {
- if (delete_begin <= forms[i]->date_created &&
- (delete_end.is_null() || forms[i]->date_created < delete_end)) {
- if (!RemoveLogin(*forms[i]))
- ok = false;
- }
- delete forms[i];
- }
- return ok;
+bool NativeBackendGnome::RemoveLoginsSyncedBetween(
+ base::Time delete_begin,
+ base::Time delete_end,
+ password_manager::PasswordStoreChangeList* changes) {
+ return RemoveLoginsBetween(delete_begin, delete_end, false, changes);
}
bool NativeBackendGnome::GetLogins(const PasswordForm& form,
@@ -683,27 +673,10 @@ bool NativeBackendGnome::GetLogins(const PasswordForm& form,
return true;
}
-bool NativeBackendGnome::GetLoginsCreatedBetween(const base::Time& get_begin,
- const base::Time& get_end,
+bool NativeBackendGnome::GetLoginsCreatedBetween(base::Time get_begin,
+ base::Time get_end,
PasswordFormList* forms) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
- // We could walk the list and add items as we find them, but it is much
- // easier to build the list and then filter the results.
- PasswordFormList all_forms;
- if (!GetAllLogins(&all_forms))
- return false;
-
- forms->reserve(forms->size() + all_forms.size());
- for (size_t i = 0; i < all_forms.size(); ++i) {
- if (get_begin <= all_forms[i]->date_created &&
- (get_end.is_null() || all_forms[i]->date_created < get_end)) {
- forms->push_back(all_forms[i]);
- } else {
- delete all_forms[i];
- }
- }
-
- return true;
+ return GetLoginsBetween(get_begin, get_end, true, forms);
}
bool NativeBackendGnome::GetAutofillableLogins(PasswordFormList* forms) {
@@ -753,6 +726,61 @@ bool NativeBackendGnome::GetAllLogins(PasswordFormList* forms) {
return true;
}
+bool NativeBackendGnome::GetLoginsBetween(base::Time get_begin,
+ base::Time get_end,
+ bool date_is_creation,
+ PasswordFormList* forms) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
+ // We could walk the list and add items as we find them, but it is much
+ // easier to build the list and then filter the results.
+ PasswordFormList all_forms;
+ if (!GetAllLogins(&all_forms))
+ return false;
+
+ base::Time autofill::PasswordForm::*date_member = date_is_creation ?
+ &autofill::PasswordForm::date_created :
+ &autofill::PasswordForm::date_synced;
+ forms->reserve(forms->size() + all_forms.size());
vabr (Chromium) 2014/06/17 15:28:40 What are the reasons for this speed optimisation?
vasilii 2014/06/17 17:24:14 Done. I copied it from GetLoginsCreatedBetween().
+ for (size_t i = 0; i < all_forms.size(); ++i) {
+ if (get_begin <= all_forms[i]->*date_member &&
+ (get_end.is_null() || all_forms[i]->*date_member < get_end)) {
+ forms->push_back(all_forms[i]);
+ } else {
+ delete all_forms[i];
+ }
+ }
+
+ return true;
+}
+
+bool NativeBackendGnome::RemoveLoginsBetween(
+ base::Time get_begin,
+ base::Time get_end,
+ bool date_is_creation,
+ password_manager::PasswordStoreChangeList* changes) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
+ if (changes)
+ changes->clear();
+ // We could walk the list and delete items as we find them, but it is much
+ // easier to build the list and use RemoveLogin() to delete them.
+ ScopedVector<autofill::PasswordForm> forms;
+ if (!GetLoginsBetween(get_begin, get_end, date_is_creation, &forms.get()))
+ return false;
+
+ bool ok = true;
+ for (size_t i = 0; i < forms.size(); ++i) {
+ if (RemoveLogin(*forms[i])) {
+ if (changes) {
+ changes->push_back(password_manager::PasswordStoreChange(
+ password_manager::PasswordStoreChange::REMOVE, *forms[i]));
+ }
+ } else {
+ ok = false;
+ }
+ }
+ return ok;
+}
+
std::string NativeBackendGnome::GetProfileSpecificAppString() const {
// Originally, the application string was always just "chrome" and used only
// so that we had *something* to search for since GNOME Keyring won't search

Powered by Google App Engine
This is Rietveld 408576698