| 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 1035e951af10ade381290ccfce503b879da0180b..b3571d6b3384b2b690b2987418427bb155dae96d 100644
|
| --- a/chrome/browser/password_manager/native_backend_gnome_x.cc
|
| +++ b/chrome/browser/password_manager/native_backend_gnome_x.cc
|
| @@ -147,17 +147,17 @@ scoped_ptr<PasswordForm> FormFromAttributes(GnomeKeyringAttributeList* attrs) {
|
| return form.Pass();
|
| }
|
|
|
| -// Parse all the results from the given GList into a PasswordFormList, and free
|
| -// the GList. PasswordForms are allocated on the heap, and should be deleted by
|
| -// the consumer. If not NULL, |lookup_form| is used to filter out results --
|
| -// only credentials with signon realms passing the PSL matching against
|
| -// |lookup_form->signon_realm| will be kept. PSL matched results get their
|
| -// signon_realm, origin, and action rewritten to those of |lookup_form_|, with
|
| -// the original signon_realm saved into the result's original_signon_realm data
|
| -// member.
|
| +// Parse all the results from the given GList into a
|
| +// ScopedVector<autofill::PasswordForm>, and free the GList. PasswordForms are
|
| +// allocated on the heap, and should be deleted by the consumer. If not NULL,
|
| +// |lookup_form| is used to filter out results -- only credentials with signon
|
| +// realms passing the PSL matching against |lookup_form->signon_realm| will be
|
| +// kept. PSL matched results get their signon_realm, origin, and action
|
| +// rewritten to those of |lookup_form_|, with the original signon_realm saved
|
| +// into the result's original_signon_realm data member.
|
| void ConvertFormList(GList* found,
|
| const PasswordForm* lookup_form,
|
| - NativeBackendGnome::PasswordFormList* forms) {
|
| + ScopedVector<autofill::PasswordForm>* forms) {
|
| password_manager::PSLDomainMatchMetric psl_domain_match_metric =
|
| password_manager::PSL_DOMAIN_MATCH_NONE;
|
| for (GList* element = g_list_first(found); element != NULL;
|
| @@ -255,8 +255,6 @@ const GnomeKeyringPasswordSchema kGnomeSchema = {
|
| // be used in parallel.
|
| class GKRMethod : public GnomeKeyringLoader {
|
| public:
|
| - typedef NativeBackendGnome::PasswordFormList PasswordFormList;
|
| -
|
| GKRMethod() : event_(false, false), result_(GNOME_KEYRING_RESULT_CANCELLED) {}
|
|
|
| // Action methods. These call gnome_keyring_* functions. Call from UI thread.
|
| @@ -274,7 +272,7 @@ class GKRMethod : public GnomeKeyringLoader {
|
|
|
| // Use after AddLoginSearch, UpdateLoginSearch, GetLogins, GetLoginsList,
|
| // GetAllLogins.
|
| - GnomeKeyringResult WaitResult(PasswordFormList* forms);
|
| + GnomeKeyringResult WaitResult(ScopedVector<autofill::PasswordForm>* forms);
|
|
|
| private:
|
| struct GnomeKeyringAttributeListFreeDeleter {
|
| @@ -306,7 +304,7 @@ class GKRMethod : public GnomeKeyringLoader {
|
|
|
| base::WaitableEvent event_;
|
| GnomeKeyringResult result_;
|
| - NativeBackendGnome::PasswordFormList forms_;
|
| + ScopedVector<autofill::PasswordForm> forms_;
|
| // If the credential search is specified by a single form and needs to use PSL
|
| // matching, then the specifying form is stored in |lookup_form_|. If PSL
|
| // matching is used to find a result, then the results signon realm, origin
|
| @@ -466,7 +464,8 @@ GnomeKeyringResult GKRMethod::WaitResult() {
|
| return result_;
|
| }
|
|
|
| -GnomeKeyringResult GKRMethod::WaitResult(PasswordFormList* forms) {
|
| +GnomeKeyringResult GKRMethod::WaitResult(
|
| + ScopedVector<autofill::PasswordForm>* forms) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
|
| event_.Wait();
|
| if (forms->empty()) {
|
| @@ -475,7 +474,7 @@ GnomeKeyringResult GKRMethod::WaitResult(PasswordFormList* forms) {
|
| } else {
|
| // Rare case. Append forms_ to *forms.
|
| forms->insert(forms->end(), forms_.begin(), forms_.end());
|
| - forms_.clear();
|
| + forms_.weak_clear();
|
| }
|
| return result_;
|
| }
|
| @@ -564,7 +563,7 @@ password_manager::PasswordStoreChangeList NativeBackendGnome::AddLogin(
|
| base::Unretained(&method),
|
| form, app_string_.c_str()));
|
| ScopedVector<autofill::PasswordForm> forms;
|
| - GnomeKeyringResult result = method.WaitResult(&forms.get());
|
| + GnomeKeyringResult result = method.WaitResult(&forms);
|
| if (result != GNOME_KEYRING_RESULT_OK &&
|
| result != GNOME_KEYRING_RESULT_NO_MATCH) {
|
| LOG(ERROR) << "Keyring find failed: "
|
| @@ -608,7 +607,7 @@ bool NativeBackendGnome::UpdateLogin(
|
| base::Unretained(&method),
|
| form, app_string_.c_str()));
|
| ScopedVector<autofill::PasswordForm> forms;
|
| - GnomeKeyringResult result = method.WaitResult(&forms.get());
|
| + GnomeKeyringResult result = method.WaitResult(&forms);
|
| if (result != GNOME_KEYRING_RESULT_OK) {
|
| LOG(ERROR) << "Keyring find failed: "
|
| << gnome_keyring_result_to_message(result);
|
| @@ -667,8 +666,9 @@ bool NativeBackendGnome::RemoveLoginsSyncedBetween(
|
| return RemoveLoginsBetween(delete_begin, delete_end, SYNC_TIMESTAMP, changes);
|
| }
|
|
|
| -bool NativeBackendGnome::GetLogins(const PasswordForm& form,
|
| - PasswordFormList* forms) {
|
| +bool NativeBackendGnome::GetLogins(
|
| + const PasswordForm& form,
|
| + ScopedVector<autofill::PasswordForm>* forms) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
|
| GKRMethod method;
|
| BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
| @@ -686,16 +686,19 @@ bool NativeBackendGnome::GetLogins(const PasswordForm& form,
|
| return true;
|
| }
|
|
|
| -bool NativeBackendGnome::GetAutofillableLogins(PasswordFormList* forms) {
|
| - return GetLoginsList(forms, true);
|
| +bool NativeBackendGnome::GetAutofillableLogins(
|
| + ScopedVector<autofill::PasswordForm>* forms) {
|
| + return GetLoginsList(true, forms);
|
| }
|
|
|
| -bool NativeBackendGnome::GetBlacklistLogins(PasswordFormList* forms) {
|
| - return GetLoginsList(forms, false);
|
| +bool NativeBackendGnome::GetBlacklistLogins(
|
| + ScopedVector<autofill::PasswordForm>* forms) {
|
| + return GetLoginsList(false, forms);
|
| }
|
|
|
| -bool NativeBackendGnome::GetLoginsList(PasswordFormList* forms,
|
| - bool autofillable) {
|
| +bool NativeBackendGnome::GetLoginsList(
|
| + bool autofillable,
|
| + ScopedVector<autofill::PasswordForm>* forms) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
|
|
|
| uint32_t blacklisted_by_user = !autofillable;
|
| @@ -716,7 +719,8 @@ bool NativeBackendGnome::GetLoginsList(PasswordFormList* forms,
|
| return true;
|
| }
|
|
|
| -bool NativeBackendGnome::GetAllLogins(PasswordFormList* forms) {
|
| +bool NativeBackendGnome::GetAllLogins(
|
| + ScopedVector<autofill::PasswordForm>* forms) {
|
| GKRMethod method;
|
| BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
| base::Bind(&GKRMethod::GetAllLogins,
|
| @@ -733,14 +737,15 @@ bool NativeBackendGnome::GetAllLogins(PasswordFormList* forms) {
|
| return true;
|
| }
|
|
|
| -bool NativeBackendGnome::GetLoginsBetween(base::Time get_begin,
|
| - base::Time get_end,
|
| - TimestampToCompare date_to_compare,
|
| - PasswordFormList* forms) {
|
| +bool NativeBackendGnome::GetLoginsBetween(
|
| + base::Time get_begin,
|
| + base::Time get_end,
|
| + TimestampToCompare date_to_compare,
|
| + ScopedVector<autofill::PasswordForm>* 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;
|
| + ScopedVector<autofill::PasswordForm> all_forms;
|
| if (!GetAllLogins(&all_forms))
|
| return false;
|
|
|
| @@ -748,12 +753,11 @@ bool NativeBackendGnome::GetLoginsBetween(base::Time get_begin,
|
| 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];
|
| + for (auto& saved_form : all_forms) {
|
| + if (get_begin <= saved_form->*date_member &&
|
| + (get_end.is_null() || saved_form->*date_member < get_end)) {
|
| + forms->push_back(saved_form);
|
| + saved_form = nullptr;
|
| }
|
| }
|
|
|
| @@ -771,7 +775,7 @@ bool NativeBackendGnome::RemoveLoginsBetween(
|
| // 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()))
|
| + if (!GetLoginsBetween(get_begin, get_end, date_to_compare, &forms))
|
| return false;
|
|
|
| bool ok = true;
|
|
|