| 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_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_H_ |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "components/password_manager/core/browser/login_database.h" | 16 #include "components/password_manager/core/browser/login_database.h" |
| 17 #include "components/password_manager/core/browser/password_store.h" | 17 #include "components/password_manager/core/browser/password_store.h" |
| 18 | 18 |
| 19 namespace crypto { | 19 namespace crypto { |
| 20 class AppleKeychain; | 20 class AppleKeychain; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace password_manager { | 23 namespace password_manager { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 37 MIGRATION_OK, | 37 MIGRATION_OK, |
| 38 LOGIN_DB_UNAVAILABLE, | 38 LOGIN_DB_UNAVAILABLE, |
| 39 LOGIN_DB_FAILURE, | 39 LOGIN_DB_FAILURE, |
| 40 ENCRYPTOR_FAILURE, | 40 ENCRYPTOR_FAILURE, |
| 41 KEYCHAIN_BLOCKED, | 41 KEYCHAIN_BLOCKED, |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 PasswordStoreMac( | 44 PasswordStoreMac( |
| 45 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, | 45 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, |
| 46 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner, | 46 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner, |
| 47 scoped_ptr<crypto::AppleKeychain> keychain); | 47 std::unique_ptr<crypto::AppleKeychain> keychain); |
| 48 | 48 |
| 49 // Sets the background thread. | 49 // Sets the background thread. |
| 50 void InitWithTaskRunner( | 50 void InitWithTaskRunner( |
| 51 scoped_refptr<base::SingleThreadTaskRunner> background_task_runner); | 51 scoped_refptr<base::SingleThreadTaskRunner> background_task_runner); |
| 52 | 52 |
| 53 // Reads all the passwords from the Keychain and stores them in LoginDatabase. | 53 // Reads all the passwords from the Keychain and stores them in LoginDatabase. |
| 54 // After the successful migration PasswordStoreMac should not be used. If the | 54 // After the successful migration PasswordStoreMac should not be used. If the |
| 55 // migration fails, PasswordStoreMac remains the active backend for | 55 // migration fails, PasswordStoreMac remains the active backend for |
| 56 // PasswordStoreProxyMac. | 56 // PasswordStoreProxyMac. |
| 57 MigrationResult ImportFromKeychain(); | 57 MigrationResult ImportFromKeychain(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 base::Time delete_end) override; | 95 base::Time delete_end) override; |
| 96 ScopedVector<autofill::PasswordForm> FillMatchingLogins( | 96 ScopedVector<autofill::PasswordForm> FillMatchingLogins( |
| 97 const autofill::PasswordForm& form) override; | 97 const autofill::PasswordForm& form) override; |
| 98 bool FillAutofillableLogins( | 98 bool FillAutofillableLogins( |
| 99 ScopedVector<autofill::PasswordForm>* forms) override; | 99 ScopedVector<autofill::PasswordForm>* forms) override; |
| 100 bool FillBlacklistLogins( | 100 bool FillBlacklistLogins( |
| 101 ScopedVector<autofill::PasswordForm>* forms) override; | 101 ScopedVector<autofill::PasswordForm>* forms) override; |
| 102 void AddSiteStatsImpl( | 102 void AddSiteStatsImpl( |
| 103 const password_manager::InteractionsStats& stats) override; | 103 const password_manager::InteractionsStats& stats) override; |
| 104 void RemoveSiteStatsImpl(const GURL& origin_domain) override; | 104 void RemoveSiteStatsImpl(const GURL& origin_domain) override; |
| 105 std::vector<scoped_ptr<password_manager::InteractionsStats>> GetSiteStatsImpl( | 105 std::vector<std::unique_ptr<password_manager::InteractionsStats>> |
| 106 const GURL& origin_domain) override; | 106 GetSiteStatsImpl(const GURL& origin_domain) override; |
| 107 | 107 |
| 108 // Adds the given form to the Keychain if it's something we want to store | 108 // Adds the given form to the Keychain if it's something we want to store |
| 109 // there (i.e., not a blacklist entry or a federated login). Returns true if | 109 // there (i.e., not a blacklist entry or a federated login). Returns true if |
| 110 // the operation succeeded (either we added successfully, or we didn't need | 110 // the operation succeeded (either we added successfully, or we didn't need |
| 111 // to). | 111 // to). |
| 112 bool AddToKeychainIfNecessary(const autofill::PasswordForm& form); | 112 bool AddToKeychainIfNecessary(const autofill::PasswordForm& form); |
| 113 | 113 |
| 114 // Returns true if our database contains a form that exactly matches the given | 114 // Returns true if our database contains a form that exactly matches the given |
| 115 // keychain form. | 115 // keychain form. |
| 116 bool DatabaseHasFormMatchingKeychainForm( | 116 bool DatabaseHasFormMatchingKeychainForm( |
| 117 const autofill::PasswordForm& form); | 117 const autofill::PasswordForm& form); |
| 118 | 118 |
| 119 // Removes the given forms from the database. After the call |forms| contains | 119 // Removes the given forms from the database. After the call |forms| contains |
| 120 // only those forms which were successfully removed. | 120 // only those forms which were successfully removed. |
| 121 void RemoveDatabaseForms(ScopedVector<autofill::PasswordForm>* forms); | 121 void RemoveDatabaseForms(ScopedVector<autofill::PasswordForm>* forms); |
| 122 | 122 |
| 123 // Removes the given forms from the Keychain. | 123 // Removes the given forms from the Keychain. |
| 124 void RemoveKeychainForms( | 124 void RemoveKeychainForms( |
| 125 const std::vector<autofill::PasswordForm*>& forms); | 125 const std::vector<autofill::PasswordForm*>& forms); |
| 126 | 126 |
| 127 // Searches the database for forms without a corresponding entry in the | 127 // Searches the database for forms without a corresponding entry in the |
| 128 // keychain. Removes those forms from the database, and adds them to | 128 // keychain. Removes those forms from the database, and adds them to |
| 129 // |orphaned_forms|. | 129 // |orphaned_forms|. |
| 130 void CleanOrphanedForms(ScopedVector<autofill::PasswordForm>* orphaned_forms); | 130 void CleanOrphanedForms(ScopedVector<autofill::PasswordForm>* orphaned_forms); |
| 131 | 131 |
| 132 scoped_ptr<crypto::AppleKeychain> keychain_; | 132 std::unique_ptr<crypto::AppleKeychain> keychain_; |
| 133 | 133 |
| 134 // The login metadata SQL database. The caller is resonsible for initializing | 134 // The login metadata SQL database. The caller is resonsible for initializing |
| 135 // it. | 135 // it. |
| 136 password_manager::LoginDatabase* login_metadata_db_; | 136 password_manager::LoginDatabase* login_metadata_db_; |
| 137 | 137 |
| 138 DISALLOW_COPY_AND_ASSIGN(PasswordStoreMac); | 138 DISALLOW_COPY_AND_ASSIGN(PasswordStoreMac); |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_H_ | 141 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_H_ |
| OLD | NEW |