| 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_X_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_X_H_ |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_X_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_X_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/scoped_vector.h" |
| 11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 12 #include "components/password_manager/core/browser/password_store_default.h" | 13 #include "components/password_manager/core/browser/password_store_default.h" |
| 13 | 14 |
| 14 class PrefService; | 15 class PrefService; |
| 15 | 16 |
| 16 namespace user_prefs { | 17 namespace user_prefs { |
| 17 class PrefRegistrySyncable; | 18 class PrefRegistrySyncable; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace password_manager { | 21 namespace password_manager { |
| 21 class LoginDatabase; | 22 class LoginDatabase; |
| 22 } | 23 } |
| 23 | 24 |
| 24 // PasswordStoreX is used on Linux and other non-Windows, non-Mac OS X | 25 // PasswordStoreX is used on Linux and other non-Windows, non-Mac OS X |
| 25 // operating systems. It uses a "native backend" to actually store the password | 26 // operating systems. It uses a "native backend" to actually store the password |
| 26 // data when such a backend is available, and otherwise falls back to using the | 27 // data when such a backend is available, and otherwise falls back to using the |
| 27 // login database like PasswordStoreDefault. It also handles automatically | 28 // login database like PasswordStoreDefault. It also handles automatically |
| 28 // migrating password data to a native backend from the login database. | 29 // migrating password data to a native backend from the login database. |
| 29 // | 30 // |
| 30 // There are currently native backends for GNOME Keyring and KWallet. | 31 // There are currently native backends for GNOME Keyring and KWallet. |
| 31 class PasswordStoreX : public password_manager::PasswordStoreDefault { | 32 class PasswordStoreX : public password_manager::PasswordStoreDefault { |
| 32 public: | 33 public: |
| 33 // NativeBackends more or less implement the PaswordStore interface, but | 34 // NativeBackends more or less implement the PaswordStore interface, but |
| 34 // with return values rather than implicit consumer notification. | 35 // with return values rather than implicit consumer notification. |
| 35 class NativeBackend { | 36 class NativeBackend { |
| 36 public: | 37 public: |
| 37 typedef std::vector<autofill::PasswordForm*> PasswordFormList; | |
| 38 | |
| 39 virtual ~NativeBackend() {} | 38 virtual ~NativeBackend() {} |
| 40 | 39 |
| 41 virtual bool Init() = 0; | 40 virtual bool Init() = 0; |
| 42 | 41 |
| 43 virtual password_manager::PasswordStoreChangeList AddLogin( | 42 virtual password_manager::PasswordStoreChangeList AddLogin( |
| 44 const autofill::PasswordForm& form) = 0; | 43 const autofill::PasswordForm& form) = 0; |
| 45 virtual bool UpdateLogin( | 44 virtual bool UpdateLogin( |
| 46 const autofill::PasswordForm& form, | 45 const autofill::PasswordForm& form, |
| 47 password_manager::PasswordStoreChangeList* changes) = 0; | 46 password_manager::PasswordStoreChangeList* changes) = 0; |
| 48 virtual bool RemoveLogin(const autofill::PasswordForm& form) = 0; | 47 virtual bool RemoveLogin(const autofill::PasswordForm& form) = 0; |
| 49 | 48 |
| 50 // Removes all logins created/synced from |delete_begin| onwards (inclusive) | 49 // Removes all logins created/synced from |delete_begin| onwards (inclusive) |
| 51 // and before |delete_end|. You may use a null Time value to do an unbounded | 50 // and before |delete_end|. You may use a null Time value to do an unbounded |
| 52 // delete in either direction. | 51 // delete in either direction. |
| 53 virtual bool RemoveLoginsCreatedBetween( | 52 virtual bool RemoveLoginsCreatedBetween( |
| 54 base::Time delete_begin, | 53 base::Time delete_begin, |
| 55 base::Time delete_end, | 54 base::Time delete_end, |
| 56 password_manager::PasswordStoreChangeList* changes) = 0; | 55 password_manager::PasswordStoreChangeList* changes) = 0; |
| 57 virtual bool RemoveLoginsSyncedBetween( | 56 virtual bool RemoveLoginsSyncedBetween( |
| 58 base::Time delete_begin, | 57 base::Time delete_begin, |
| 59 base::Time delete_end, | 58 base::Time delete_end, |
| 60 password_manager::PasswordStoreChangeList* changes) = 0; | 59 password_manager::PasswordStoreChangeList* changes) = 0; |
| 61 | 60 |
| 62 virtual bool GetLogins(const autofill::PasswordForm& form, | 61 virtual bool GetLogins(const autofill::PasswordForm& form, |
| 63 PasswordFormList* forms) = 0; | 62 ScopedVector<autofill::PasswordForm>* forms) = 0; |
| 64 virtual bool GetAutofillableLogins(PasswordFormList* forms) = 0; | 63 virtual bool GetAutofillableLogins( |
| 65 virtual bool GetBlacklistLogins(PasswordFormList* forms) = 0; | 64 ScopedVector<autofill::PasswordForm>* forms) = 0; |
| 65 virtual bool GetBlacklistLogins( |
| 66 ScopedVector<autofill::PasswordForm>* forms) = 0; |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 // Takes ownership of |login_db| and |backend|. |backend| may be NULL in which | 69 // Takes ownership of |login_db| and |backend|. |backend| may be NULL in which |
| 69 // case this PasswordStoreX will act the same as PasswordStoreDefault. | 70 // case this PasswordStoreX will act the same as PasswordStoreDefault. |
| 70 PasswordStoreX(scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, | 71 PasswordStoreX(scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, |
| 71 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner, | 72 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner, |
| 72 scoped_ptr<password_manager::LoginDatabase> login_db, | 73 scoped_ptr<password_manager::LoginDatabase> login_db, |
| 73 NativeBackend* backend); | 74 NativeBackend* backend); |
| 74 | 75 |
| 75 private: | 76 private: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 89 base::Time delete_end) override; | 90 base::Time delete_end) override; |
| 90 password_manager::PasswordStoreChangeList RemoveLoginsSyncedBetweenImpl( | 91 password_manager::PasswordStoreChangeList RemoveLoginsSyncedBetweenImpl( |
| 91 base::Time delete_begin, | 92 base::Time delete_begin, |
| 92 base::Time delete_end) override; | 93 base::Time delete_end) override; |
| 93 void GetLoginsImpl(const autofill::PasswordForm& form, | 94 void GetLoginsImpl(const autofill::PasswordForm& form, |
| 94 AuthorizationPromptPolicy prompt_policy, | 95 AuthorizationPromptPolicy prompt_policy, |
| 95 const ConsumerCallbackRunner& callback_runner) override; | 96 const ConsumerCallbackRunner& callback_runner) override; |
| 96 void GetAutofillableLoginsImpl(GetLoginsRequest* request) override; | 97 void GetAutofillableLoginsImpl(GetLoginsRequest* request) override; |
| 97 void GetBlacklistLoginsImpl(GetLoginsRequest* request) override; | 98 void GetBlacklistLoginsImpl(GetLoginsRequest* request) override; |
| 98 bool FillAutofillableLogins( | 99 bool FillAutofillableLogins( |
| 99 std::vector<autofill::PasswordForm*>* forms) override; | 100 ScopedVector<autofill::PasswordForm>* forms) override; |
| 100 bool FillBlacklistLogins( | 101 bool FillBlacklistLogins( |
| 101 std::vector<autofill::PasswordForm*>* forms) override; | 102 ScopedVector<autofill::PasswordForm>* forms) override; |
| 102 | 103 |
| 103 // Sort logins by origin, like the ORDER BY clause in login_database.cc. | 104 // Sort logins by origin, like the ORDER BY clause in login_database.cc. |
| 104 void SortLoginsByOrigin(NativeBackend::PasswordFormList* list); | 105 void SortLoginsByOrigin(std::vector<autofill::PasswordForm*>* list); |
| 105 | 106 |
| 106 // Check to see whether migration is necessary, and perform it if so. | 107 // Check to see whether migration is necessary, and perform it if so. |
| 107 void CheckMigration(); | 108 void CheckMigration(); |
| 108 | 109 |
| 109 // Return true if we should try using the native backend. | 110 // Return true if we should try using the native backend. |
| 110 bool use_native_backend() { return !!backend_.get(); } | 111 bool use_native_backend() { return !!backend_.get(); } |
| 111 | 112 |
| 112 // Return true if we can fall back on the default store, warning the first | 113 // Return true if we can fall back on the default store, warning the first |
| 113 // time we call it when falling back is necessary. See |allow_fallback_|. | 114 // time we call it when falling back is necessary. See |allow_fallback_|. |
| 114 bool allow_default_store(); | 115 bool allow_default_store(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 126 // Whether we should allow falling back to the default store. If there is | 127 // Whether we should allow falling back to the default store. If there is |
| 127 // nothing to migrate, then the first attempt to use the native store will | 128 // nothing to migrate, then the first attempt to use the native store will |
| 128 // be the first time we try to use it and we should allow falling back. If | 129 // be the first time we try to use it and we should allow falling back. If |
| 129 // we have migrated successfully, then we do not allow falling back. | 130 // we have migrated successfully, then we do not allow falling back. |
| 130 bool allow_fallback_; | 131 bool allow_fallback_; |
| 131 | 132 |
| 132 DISALLOW_COPY_AND_ASSIGN(PasswordStoreX); | 133 DISALLOW_COPY_AND_ASSIGN(PasswordStoreX); |
| 133 }; | 134 }; |
| 134 | 135 |
| 135 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_X_H_ | 136 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_X_H_ |
| OLD | NEW |