Chromium Code Reviews| Index: components/password_manager/core/browser/password_store.h |
| diff --git a/components/password_manager/core/browser/password_store.h b/components/password_manager/core/browser/password_store.h |
| index 852a51e5eea80a9dddcde4cb1e73b82b075221f1..075aca27c5db69688d305d20aa74dc3f7d1b0df9 100644 |
| --- a/components/password_manager/core/browser/password_store.h |
| +++ b/components/password_manager/core/browser/password_store.h |
| @@ -6,6 +6,7 @@ |
| #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_STORE_H_ |
| #include "base/callback.h" |
| +#include "base/gtest_prod_util.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/scoped_vector.h" |
| @@ -74,6 +75,12 @@ class PasswordStore : protected PasswordStoreSync, |
| // initialized if it is non-null. |
| void SetAffiliatedMatchHelper(scoped_ptr<AffiliatedMatchHelper> helper); |
| + // Toggles whether or not to propagate password changes in Android credentials |
| + // to the affiliated Web credentials. |
| + void enable_propagating_password_changes_to_web_credentials(bool enabled) { |
| + is_propagating_password_changes_to_web_credentials_enabled_ = enabled; |
| + } |
| + |
| // Returns whether or not an affiliation-based match helper is set. |
| bool HasAffiliatedMatchHelper() const; |
| @@ -181,16 +188,6 @@ class PasswordStore : protected PasswordStoreSync, |
| virtual void ReportMetricsImpl(const std::string& sync_username, |
| bool custom_passphrase_sync_enabled) = 0; |
| - // Bring PasswordStoreSync methods to the scope of PasswordStore. Otherwise, |
| - // base::Bind can't be used with them because it fails to cast PasswordStore |
| - // to PasswordStoreSync. |
| - PasswordStoreChangeList AddLoginImpl( |
| - const autofill::PasswordForm& form) override = 0; |
| - PasswordStoreChangeList UpdateLoginImpl( |
| - const autofill::PasswordForm& form) override = 0; |
| - PasswordStoreChangeList RemoveLoginImpl( |
| - const autofill::PasswordForm& form) override = 0; |
| - |
| // Synchronous implementation to remove the given logins. |
| virtual PasswordStoreChangeList RemoveLoginsCreatedBetweenImpl( |
| base::Time delete_begin, |
| @@ -211,6 +208,20 @@ class PasswordStore : protected PasswordStoreSync, |
| AuthorizationPromptPolicy prompt_policy, |
| scoped_ptr<GetLoginsRequest> request); |
| + // Synchronous implementation provided by subclasses to add the given login. |
| + virtual PasswordStoreChangeList AddLoginImpl( |
| + const autofill::PasswordForm& form) = 0; |
| + |
| + // Synchronous implementation provided by subclasses to update the given |
| + // login. |
| + virtual PasswordStoreChangeList UpdateLoginImpl( |
| + const autofill::PasswordForm& form) = 0; |
| + |
| + // Synchronous implementation provided by subclasses to remove the given |
| + // login. |
| + virtual PasswordStoreChangeList RemoveLoginImpl( |
| + const autofill::PasswordForm& form) = 0; |
| + |
| // Finds and returns all PasswordForms with the same signon_realm as |form|, |
| // or with a signon_realm that is a PSL-match to that of |form|. |
| virtual ScopedVector<autofill::PasswordForm> FillMatchingLogins( |
| @@ -232,6 +243,13 @@ class PasswordStore : protected PasswordStoreSync, |
| void LogStatsForBulkDeletionDuringRollback(int num_deletions); |
| // PasswordStoreSync: |
| + PasswordStoreChangeList AddLoginSync( |
| + const autofill::PasswordForm& form) override; |
| + PasswordStoreChangeList UpdateLoginSync( |
| + const autofill::PasswordForm& form) override; |
| + PasswordStoreChangeList RemoveLoginSync( |
| + const autofill::PasswordForm& form) override; |
| + |
| // Called by WrapModificationTask() once the underlying data-modifying |
| // operation has been performed. Notifies observers that password store data |
| // may have been changed. |
| @@ -245,6 +263,10 @@ class PasswordStore : protected PasswordStoreSync, |
| scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner_; |
| private: |
| + FRIEND_TEST_ALL_PREFIXES(PasswordStoreTest, GetLoginImpl); |
| + FRIEND_TEST_ALL_PREFIXES(PasswordStoreTest, |
| + UpdatePasswordsStoredForAffiliatedWebsites); |
| + |
| // Schedule the given |func| to be run in the PasswordStore's own thread with |
| // responses delivered to |consumer| on the current thread. |
| void Schedule(void (PasswordStore::*func)(scoped_ptr<GetLoginsRequest>), |
| @@ -286,6 +308,34 @@ class PasswordStore : protected PasswordStoreSync, |
| scoped_ptr<GetLoginsRequest> request, |
| const std::vector<std::string>& additional_android_realms); |
| + // Retrieves the currently stored form, if any, with the same primary key as |
| + // |form|, that is, with the same signon_realm, origin, username_element, |
| + // username_value and password_element attributes. |
| + scoped_ptr<autofill::PasswordForm> GetLoginImpl( |
|
vasilii
2015/04/21 09:20:18
For these functions mention the thread they are ex
engedy
2015/04/21 09:42:25
Done.
|
| + const autofill::PasswordForm& primary_key); |
| + |
| + // Called when a password is added or updated for an Android application, and |
| + // triggers finding web sites affiliated with the Android application and |
| + // propagating the new password to credentials for those web sites, if any. |
| + void FindAndUpdateAffiliatedWebLogins( |
| + const autofill::PasswordForm& added_or_updated_android_form); |
| + |
| + // Posts FindAndUpdateAffiliatedWebLogins() to the main thread. |
| + void ScheduleFindAndUpdateAffiliatedWebLogins( |
| + const autofill::PasswordForm& added_or_updated_android_form); |
| + |
| + // Called when a password is added or updated for an Android application, and |
| + // propagates these changes to credentials stored for |affiliated_web_realms| |
| + // under the same username, if there are any. |
| + void UpdateAffiliatedWebLoginsImpl( |
| + const autofill::PasswordForm& updated_android_form, |
| + const std::vector<std::string>& affiliated_web_realms); |
| + |
| + // Schedules UpdateAffiliatedWebLoginsImpl() to run on the DB thread. |
| + void ScheduleUpdateAffiliatedWebLoginsImpl( |
| + const autofill::PasswordForm& updated_android_form, |
| + const std::vector<std::string>& affiliated_web_realms); |
| + |
| // Creates PasswordSyncableService instance on the background thread. |
| void InitSyncableService( |
| const syncer::SyncableService::StartSyncFlare& flare); |
| @@ -298,6 +348,7 @@ class PasswordStore : protected PasswordStoreSync, |
| scoped_ptr<PasswordSyncableService> syncable_service_; |
| scoped_ptr<AffiliatedMatchHelper> affiliated_match_helper_; |
| + bool is_propagating_password_changes_to_web_credentials_enabled_; |
| bool shutdown_called_; |