| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_INTERNAL_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_INTERNAL_H_ |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_INTERNAL_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_INTERNAL_H_ |
| 7 | 7 |
| 8 #include <Security/Security.h> | 8 #include <Security/Security.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 const content::PasswordForm& query_form); | 42 const content::PasswordForm& query_form); |
| 43 | 43 |
| 44 // Returns true if PasswordsMergeableWithForm would return any items. This is | 44 // Returns true if PasswordsMergeableWithForm would return any items. This is |
| 45 // a separate method because calling PasswordsMergeableWithForm and checking | 45 // a separate method because calling PasswordsMergeableWithForm and checking |
| 46 // the return count would require reading the passwords from the keychain, | 46 // the return count would require reading the passwords from the keychain, |
| 47 // thus potentially triggering authorizaiton UI, whereas this won't. | 47 // thus potentially triggering authorizaiton UI, whereas this won't. |
| 48 bool HasPasswordsMergeableWithForm( | 48 bool HasPasswordsMergeableWithForm( |
| 49 const content::PasswordForm& query_form); | 49 const content::PasswordForm& query_form); |
| 50 | 50 |
| 51 // Returns all keychain items of types corresponding to password forms. | 51 // Returns all keychain items of types corresponding to password forms. |
| 52 std::vector<SecKeychainItemRef> GetAllPasswordFormKeychainItems(); |
| 53 |
| 54 // Returns password data from all keychain items of types corresponding to |
| 55 // password forms. Caller is responsible for deleting the returned forms. |
| 52 std::vector<content::PasswordForm*> GetAllPasswordFormPasswords(); | 56 std::vector<content::PasswordForm*> GetAllPasswordFormPasswords(); |
| 53 | 57 |
| 54 // Creates a new keychain entry from |form|, or updates the password of an | 58 // Creates a new keychain entry from |form|, or updates the password of an |
| 55 // existing keychain entry if there is a collision. Returns true if a keychain | 59 // existing keychain entry if there is a collision. Returns true if a keychain |
| 56 // entry was successfully added/updated. | 60 // entry was successfully added/updated. |
| 57 bool AddPassword(const content::PasswordForm& form); | 61 bool AddPassword(const content::PasswordForm& form); |
| 58 | 62 |
| 59 // Removes the keychain password matching |form| if any. Returns true if a | 63 // Removes the keychain password matching |form| if any. Returns true if a |
| 60 // keychain item was found and successfully removed. | 64 // keychain item was found and successfully removed. |
| 61 bool RemovePassword(const content::PasswordForm& form); | 65 bool RemovePassword(const content::PasswordForm& form); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 126 |
| 123 // If true, Keychain searches are restricted to items created by Chrome. | 127 // If true, Keychain searches are restricted to items created by Chrome. |
| 124 bool finds_only_owned_; | 128 bool finds_only_owned_; |
| 125 | 129 |
| 126 DISALLOW_COPY_AND_ASSIGN(MacKeychainPasswordFormAdapter); | 130 DISALLOW_COPY_AND_ASSIGN(MacKeychainPasswordFormAdapter); |
| 127 }; | 131 }; |
| 128 | 132 |
| 129 namespace internal_keychain_helpers { | 133 namespace internal_keychain_helpers { |
| 130 | 134 |
| 131 // Sets the fields of |form| based on the keychain data from |keychain_item|. | 135 // Sets the fields of |form| based on the keychain data from |keychain_item|. |
| 132 // Fields that can't be determined from |keychain_item| will be unchanged. | 136 // Fields that can't be determined from |keychain_item| will be unchanged. If |
| 137 // |extract_password_data| is true, the password data will be copied from |
| 138 // |keychain_item| in addition to its attributes. If it is false, only the |
| 139 // password attributes will be copied. |
| 133 // | 140 // |
| 134 // IMPORTANT: This function can cause the OS to trigger UI (to allow access to | 141 // IMPORTANT: If |extract_password_data| is true, this function can cause the OS |
| 135 // the keychain item if we aren't trusted for the item), and block until the UI | 142 // to trigger UI (to allow access to the keychain item if we aren't trusted for |
| 136 // is dismissed. | 143 // the item), and block until the UI is dismissed. |
| 137 // | 144 // |
| 138 // If excessive prompting for access to other applications' keychain items | 145 // If excessive prompting for access to other applications' keychain items |
| 139 // becomes an issue, the password storage API will need to be refactored to | 146 // becomes an issue, the password storage API will need to intially call this |
| 140 // allow the password to be retrieved later (accessing other fields doesn't | 147 // function with |extract_password_data| set to false, and retrieve the password |
| 141 // require authorization). | 148 // later (accessing other fields doesn't require authorization). |
| 142 bool FillPasswordFormFromKeychainItem(const AppleKeychain& keychain, | 149 bool FillPasswordFormFromKeychainItem(const AppleKeychain& keychain, |
| 143 const SecKeychainItemRef& keychain_item, | 150 const SecKeychainItemRef& keychain_item, |
| 144 content::PasswordForm* form); | 151 content::PasswordForm* form, |
| 152 bool extract_password_data); |
| 145 | 153 |
| 146 // Returns true if the two given forms match based on signon_reaml, scheme, and | 154 // Returns true if the two given forms match based on signon_reaml, scheme, and |
| 147 // username_value, and are thus suitable for merging (see MergePasswordForms). | 155 // username_value, and are thus suitable for merging (see MergePasswordForms). |
| 148 bool FormsMatchForMerge(const content::PasswordForm& form_a, | 156 bool FormsMatchForMerge(const content::PasswordForm& form_a, |
| 149 const content::PasswordForm& form_b); | 157 const content::PasswordForm& form_b); |
| 150 | 158 |
| 151 // Populates merged_forms by combining the password data from keychain_forms and | 159 // Populates merged_forms by combining the password data from keychain_forms and |
| 152 // the metadata from database_forms, removing used entries from the two source | 160 // the metadata from database_forms, removing used entries from the two source |
| 153 // lists. | 161 // lists. |
| 154 // | 162 // |
| (...skipping 10 matching lines...) Expand all Loading... |
| 165 // Fills in the passwords for as many of the forms in |database_forms| as | 173 // Fills in the passwords for as many of the forms in |database_forms| as |
| 166 // possible using entries from |keychain| and returns them. On return, | 174 // possible using entries from |keychain| and returns them. On return, |
| 167 // |database_forms| will contain only the forms for which no password was found. | 175 // |database_forms| will contain only the forms for which no password was found. |
| 168 std::vector<content::PasswordForm*> GetPasswordsForForms( | 176 std::vector<content::PasswordForm*> GetPasswordsForForms( |
| 169 const AppleKeychain& keychain, | 177 const AppleKeychain& keychain, |
| 170 std::vector<content::PasswordForm*>* database_forms); | 178 std::vector<content::PasswordForm*>* database_forms); |
| 171 | 179 |
| 172 } // namespace internal_keychain_helpers | 180 } // namespace internal_keychain_helpers |
| 173 | 181 |
| 174 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_INTERNAL_H_ | 182 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_INTERNAL_H_ |
| OLD | NEW |