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..c8ea612e11d9ad9fca7d5b5e33507f71afdb65fd 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,9 +25,8 @@ 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( |
+ // Returns all keychain entries matching |signon_realm| and |scheme|. |
+ ScopedVector<autofill::PasswordForm> PasswordsFillingForm( |
const std::string& signon_realm, |
autofill::PasswordForm::Scheme scheme); |
@@ -45,9 +45,9 @@ 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(); |
+ // Returns all keychain entries corresponding to password forms. |
+ // TODO(vabr): This is only used in tests, should be moved there. |
+ ScopedVector<autofill::PasswordForm> GetAllPasswordFormPasswords(); |
// 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,10 +63,9 @@ 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( |
+ // Returns PasswordForm instances transformed from |items|. Also calls |
+ // AppleKeychain::Free on all of the keychain items and clears |items|. |
+ ScopedVector<autofill::PasswordForm> ConvertKeychainItemsToForms( |
std::vector<SecKeychainItemRef>* items); |
// Searches |keychain| for the specific keychain entry that corresponds to the |
@@ -165,17 +164,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,10 +204,9 @@ 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( |
+// Returns PasswordForm instances populated with password data for each keychain |
+// entry in |item_form_pairs| that could be merged with |query_form|. |
+ScopedVector<autofill::PasswordForm> ExtractPasswordsMergeableWithForm( |
const AppleKeychain& keychain, |
const std::vector<ItemFormPair>& item_form_pairs, |
const autofill::PasswordForm& query_form); |