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

Unified Diff: chrome/browser/password_manager/password_store_mac_internal.h

Issue 825773003: PasswordStore: Use ScopedVector to express ownership of forms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Leaks fixed + VABR->vabr Created 5 years, 11 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/password_store_mac_internal.h
diff --git a/chrome/browser/password_manager/password_store_mac_internal.h b/chrome/browser/password_manager/password_store_mac_internal.h
index 245ecbbf6cd550794997603edd8e0be61967d101..dc9e35254bf295c178693e6cf1785e6607e993a9 100644
--- a/chrome/browser/password_manager/password_store_mac_internal.h
+++ b/chrome/browser/password_manager/password_store_mac_internal.h
@@ -10,6 +10,7 @@
#include <string>
#include <vector>
+#include "base/memory/scoped_vector.h"
#include "components/autofill/core/common/password_form.h"
#include "crypto/apple_keychain.h"
@@ -24,11 +25,11 @@ class MacKeychainPasswordFormAdapter {
// created object.
explicit MacKeychainPasswordFormAdapter(const AppleKeychain* keychain);
- // Returns PasswordForms for each keychain entry that could be used to fill
- // |form|. Caller is responsible for deleting the returned forms.
- std::vector<autofill::PasswordForm*> PasswordsFillingForm(
- const std::string& signon_realm,
- autofill::PasswordForm::Scheme scheme);
+ // Appends to |forms| all keychain entries matching |signon_realm| and
+ // |scheme|.
+ void PasswordsFillingForm(const std::string& signon_realm,
+ autofill::PasswordForm::Scheme scheme,
+ ScopedVector<autofill::PasswordForm>* forms);
// Returns true if there is the Keychain entry that matches |query_form| on
// all of the fields that uniquely identify a Keychain item.
@@ -45,9 +46,8 @@ class MacKeychainPasswordFormAdapter {
// Returns all keychain items of types corresponding to password forms.
std::vector<SecKeychainItemRef> GetAllPasswordFormKeychainItems();
- // Returns password data from all keychain items of types corresponding to
- // password forms. Caller is responsible for deleting the returned forms.
- std::vector<autofill::PasswordForm*> GetAllPasswordFormPasswords();
+ // Appends to |forms| all keychain entries corresponding to password forms.
+ void GetAllPasswordFormPasswords(ScopedVector<autofill::PasswordForm>* forms);
// Creates a new keychain entry from |form|, or updates the password of an
// existing keychain entry if there is a collision. Returns true if a keychain
@@ -63,11 +63,11 @@ class MacKeychainPasswordFormAdapter {
void SetFindsOnlyOwnedItems(bool finds_only_owned);
private:
- // Returns PasswordForms constructed from the given Keychain items, calling
- // AppleKeychain::Free on all of the keychain items and clearing the vector.
- // Caller is responsible for deleting the returned forms.
- std::vector<autofill::PasswordForm*> ConvertKeychainItemsToForms(
- std::vector<SecKeychainItemRef>* items);
+ // Transforms |items| to PasswordForm instances and appends them to |forms|.
+ // Also calls AppleKeychain::Free on all of the keychain items and clears
+ // |items|.
+ void ConvertKeychainItemsToForms(std::vector<SecKeychainItemRef>* items,
+ ScopedVector<autofill::PasswordForm>* forms);
// Searches |keychain| for the specific keychain entry that corresponds to the
// given form, and returns it (or NULL if no match is found). The caller is
@@ -165,17 +165,16 @@ bool FormsMatchForMerge(const autofill::PasswordForm& form_a,
// password can be found (and which aren't blacklist entries), and for
// keychain_forms its entries that weren't merged into at least one database
// form.
-void MergePasswordForms(
- std::vector<autofill::PasswordForm*>* keychain_forms,
- std::vector<autofill::PasswordForm*>* database_forms,
- std::vector<autofill::PasswordForm*>* merged_forms);
-
-// Fills in the passwords for as many of the forms in |database_forms| as
-// possible using entries from |keychain| and returns them. On return,
-// |database_forms| will contain only the forms for which no password was found.
-std::vector<autofill::PasswordForm*> GetPasswordsForForms(
- const AppleKeychain& keychain,
- std::vector<autofill::PasswordForm*>* database_forms);
+void MergePasswordForms(ScopedVector<autofill::PasswordForm>* keychain_forms,
+ ScopedVector<autofill::PasswordForm>* database_forms,
+ ScopedVector<autofill::PasswordForm>* merged_forms);
+
+// For every form in |database_forms|, if such a form has a corresponding entry
+// in |keychain|, this adds the password from the entry and moves that form from
+// |database_forms| into |passwords|.
+void GetPasswordsForForms(const AppleKeychain& keychain,
+ ScopedVector<autofill::PasswordForm>* database_forms,
+ ScopedVector<autofill::PasswordForm>* passwords);
// Loads all items in the system keychain into |keychain_items|, creates for
// each keychain item a corresponding PasswordForm that doesn't contain any
@@ -206,13 +205,14 @@ bool ExtractSignonRealmComponents(const std::string& signon_realm,
bool FormIsValidAndMatchesOtherForm(const autofill::PasswordForm& query_form,
const autofill::PasswordForm& other_form);
-// Returns PasswordForms populated with password data for each keychain entry
-// in |item_form_pairs| that could be merged with |query_form|.
-// Caller is responsible for deleting the returned forms.
-std::vector<autofill::PasswordForm*> ExtractPasswordsMergeableWithForm(
+// Appends, to |matches|, PasswordForm instances populated with password data
+// for each keychain entry in |item_form_pairs| that could be merged with
+// |query_form|.
+void ExtractPasswordsMergeableWithForm(
const AppleKeychain& keychain,
const std::vector<ItemFormPair>& item_form_pairs,
- const autofill::PasswordForm& query_form);
+ const autofill::PasswordForm& query_form,
+ ScopedVector<autofill::PasswordForm>* matches);
} // namespace internal_keychain_helpers

Powered by Google App Engine
This is Rietveld 408576698