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..7dd651e9035bb3974a7beca6481f9149692e604a 100644 |
--- a/chrome/browser/password_manager/native_backend_gnome_x.cc |
+++ b/chrome/browser/password_manager/native_backend_gnome_x.cc |
@@ -642,26 +642,17 @@ 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, CREATION_TIMESTAMP, 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, SYNC_TIMESTAMP, changes); |
} |
bool NativeBackendGnome::GetLogins(const PasswordForm& form, |
@@ -683,27 +674,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, CREATION_TIMESTAMP, forms); |
} |
bool NativeBackendGnome::GetAutofillableLogins(PasswordFormList* forms) { |
@@ -753,6 +727,61 @@ bool NativeBackendGnome::GetAllLogins(PasswordFormList* forms) { |
return true; |
} |
+bool NativeBackendGnome::GetLoginsBetween(base::Time get_begin, |
+ base::Time get_end, |
+ TimestampToCompare date_to_compare, |
+ 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_to_compare == CREATION_TIMESTAMP |
+ ? &autofill::PasswordForm::date_created |
+ : &autofill::PasswordForm::date_synced; |
+ 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, |
+ TimestampToCompare date_to_compare, |
+ 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_to_compare, &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 |