Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_SETTING_MIGRATER_SERVIC E_H_ | |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_SETTING_MIGRATER_SERVIC E_H_ | |
| 7 | |
| 8 #include "base/memory/singleton.h" | |
| 9 #include "base/prefs/pref_change_registrar.h" | |
| 10 #include "chrome/browser/prefs/pref_service_syncable_observer.h" | |
| 11 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" | |
| 12 #include "components/keyed_service/core/keyed_service.h" | |
| 13 #include "content/public/browser/notification_observer.h" | |
| 14 #include "content/public/browser/notification_registrar.h" | |
| 15 | |
| 16 class Profile; | |
| 17 | |
| 18 namespace sync_driver { | |
| 19 class SyncService; | |
| 20 } | |
| 21 | |
| 22 // PasswordManagerSettingMigraterService is responsible for reconciling Chrome | |
| 23 // password manager and Smart Lock for passwords settings. | |
| 24 // Note: componetization of this service currently is impossible, because it | |
| 25 // depends on PrefServiceSyncable. | |
| 26 class PasswordManagerSettingMigraterService | |
| 27 : public KeyedService, | |
| 28 public PrefServiceSyncableObserver, | |
| 29 public content::NotificationObserver { | |
| 30 public: | |
| 31 class Factory : public BrowserContextKeyedServiceFactory { | |
| 32 public: | |
| 33 static Factory* GetInstance(); | |
| 34 static PasswordManagerSettingMigraterService* GetForProfile( | |
| 35 Profile* profile); | |
| 36 | |
| 37 private: | |
| 38 friend struct DefaultSingletonTraits<Factory>; | |
| 39 friend class PasswordManagerSettingMigraterServiceTest; | |
| 40 | |
| 41 Factory(); | |
| 42 ~Factory() override; | |
| 43 | |
| 44 // BrowserContextKeyedServiceFactory | |
| 45 KeyedService* BuildServiceInstanceFor( | |
| 46 content::BrowserContext* profile) const override; | |
| 47 bool ServiceIsCreatedWithBrowserContext() const override; | |
| 48 }; | |
| 49 | |
| 50 explicit PasswordManagerSettingMigraterService(Profile* profile); | |
| 51 ~PasswordManagerSettingMigraterService() override; | |
| 52 | |
| 53 void Shutdown() override; | |
| 54 | |
| 55 // PrefServiceSyncableObserver | |
| 56 void OnIsSyncingChanged() override; | |
| 57 | |
| 58 // content::NotificationObserver | |
| 59 void Observe(int type, | |
| 60 const content::NotificationSource& source, | |
| 61 const content::NotificationDetails& details) override; | |
| 62 // For unit testing only. | |
|
vabr (Chromium)
2015/08/14 14:11:45
nit: Blank space above.
melandory
2015/08/17 16:28:55
Done.
| |
| 63 PasswordManagerSettingMigraterService(Profile* profile, | |
|
vabr (Chromium)
2015/08/14 14:11:45
You don't seem to use this in the tests any more (
melandory
2015/08/17 16:28:55
Yeah, I did the logic for unfriending but forgot t
| |
| 64 sync_driver::SyncService* sync_service); | |
| 65 | |
| 66 private: | |
| 67 friend class PasswordManagerSettingMigraterServiceTest; | |
|
vabr (Chromium)
2015/08/14 14:11:45
Could you drop this?
melandory
2015/08/17 16:28:55
Sorry, forgot to remove.
| |
| 68 | |
| 69 // Initializes the observers: preferences observers and sync status observers. | |
| 70 void InitObservers(); | |
| 71 | |
| 72 // Called on event of changing kCredentialsEnableService preference. Changes | |
| 73 // the value of kPasswordManagerSavingEnabled preference to be in sync with | |
| 74 // kCredentialsEnableService. | |
| 75 void OnCredentialsEnableServicePrefChanged( | |
| 76 const std::string& changed_pref_name); | |
| 77 | |
| 78 // Called on event of changing kPasswordManagerSavingEnabled preference. | |
| 79 // Changes the value of kCredentialsEnableService preference to be in sync | |
| 80 // with kPasswordManagerSavingEnabled. | |
| 81 void OnPasswordManagerSavingEnabledPrefChanged( | |
| 82 const std::string& changed_pref_name); | |
| 83 | |
| 84 // Turns off CredentialsEnableService when PasswordManagerSavingEnabled is | |
| 85 // turned off. | |
| 86 void MigrateLegacyOffState(PrefService* prefs); | |
| 87 | |
| 88 Profile* const profile_; | |
| 89 sync_driver::SyncService* sync_service_; | |
| 90 PrefChangeRegistrar pref_change_registrar_; | |
| 91 | |
| 92 // Used to register for notification that profile creation is complete. | |
| 93 content::NotificationRegistrar registrar_; | |
| 94 | |
| 95 DISALLOW_COPY_AND_ASSIGN(PasswordManagerSettingMigraterService); | |
| 96 }; | |
| 97 | |
| 98 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_SETTING_MIGRATER_SER VICE_H_ | |
| OLD | NEW |