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_MIGRATION_SERVICE_H_ | |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_MIGRATION_SERVICE_H_ | |
| 7 | |
| 8 #include "base/memory/singleton.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 #include "base/prefs/pref_change_registrar.h" | |
| 11 #include "chrome/browser/prefs/pref_service_syncable_observer.h" | |
| 12 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" | |
| 13 #include "components/keyed_service/core/keyed_service.h" | |
| 14 | |
| 15 class Profile; | |
| 16 class ProfileSyncService; | |
| 17 | |
| 18 namespace password_manager { | |
| 19 | |
| 20 // PasswordSettingsMigrationService is responsible for reconcile Chrome password | |
|
vabr (Chromium)
2015/08/07 08:48:02
nit: reconciling
melandory
2015/08/12 09:03:23
Done.
| |
| 21 // manager and Smart Lock for passwords settings. | |
| 22 class PasswordSettingsMigrationService : public KeyedService, | |
|
engedy
2015/08/07 11:41:38
I'd also suggest to slightly change the class name
melandory
2015/08/12 09:03:24
Done.
| |
| 23 public PrefServiceSyncableObserver { | |
| 24 public: | |
| 25 explicit PasswordSettingsMigrationService(Profile* profile); | |
| 26 ~PasswordSettingsMigrationService() override; | |
| 27 | |
| 28 // Initializes the observers: preferences observers and sync status observers. | |
| 29 void InitObservers(); | |
| 30 | |
| 31 class Factory : public BrowserContextKeyedServiceFactory { | |
|
engedy
2015/08/07 11:41:38
nit: Declare nested types first within a section.
melandory
2015/08/12 09:03:24
Done.
| |
| 32 public: | |
| 33 static Factory* GetInstance(); | |
| 34 static PasswordSettingsMigrationService* GetForProfile(Profile* profile); | |
| 35 | |
| 36 private: | |
| 37 friend struct DefaultSingletonTraits<Factory>; | |
| 38 friend class PasswordSettingsMigrationServiceTest; | |
|
vabr (Chromium)
2015/08/07 08:48:02
so far non-actionable note:
Friending for tests is
| |
| 39 | |
| 40 Factory(); | |
| 41 ~Factory() override; | |
| 42 | |
| 43 // BrowserContextKeyedServiceFactory implementation | |
|
engedy
2015/08/07 11:41:38
optional nit: Some people prefer writing just:
//
melandory
2015/08/12 09:03:24
Done.
| |
| 44 KeyedService* BuildServiceInstanceFor( | |
| 45 content::BrowserContext* profile) const override; | |
| 46 bool ServiceIsCreatedWithBrowserContext() const override; | |
| 47 bool ServiceIsNULLWhileTesting() const override; | |
| 48 content::BrowserContext* GetBrowserContextToUse( | |
| 49 content::BrowserContext* context) const override; | |
| 50 }; | |
| 51 | |
| 52 // PrefServiceSyncableObserver: | |
| 53 void OnIsSyncingChanged() override; | |
| 54 | |
| 55 private: | |
| 56 friend class PasswordSettingsMigrationServiceTest; | |
| 57 | |
| 58 // For unit testing only. | |
| 59 PasswordSettingsMigrationService(Profile* profile, | |
| 60 ProfileSyncService* profile_sync_service); | |
|
engedy
2015/08/07 11:41:38
You could promote this to be the main constructor,
melandory
2015/08/12 09:03:23
Unfortunately, can't do this anymore because of Pr
| |
| 61 // Called on event of changing either PasswordManagerSavingEnabled or | |
|
vabr (Chromium)
2015/08/07 08:48:02
nit: blank line above
melandory
2015/08/12 09:03:23
Done.
| |
| 62 // CredentialEnableService. Change the value of another preference to be in | |
|
vabr (Chromium)
2015/08/07 08:48:02
What is CredentialEnableService?
engedy
2015/08/07 11:41:38
It's the preference name. But, yes, we would proba
| |
| 63 // sync with changed preference. | |
| 64 void OnPrefChanged(const std::string& other_pref_name, | |
|
engedy
2015/08/07 11:41:38
nit: I think we could have two separate methods, O
melandory
2015/08/12 09:03:23
Done with correction that I changed New and Legacy
| |
| 65 const std::string& changed_pref_name); | |
| 66 | |
| 67 // Turns off CredentialEnableService when PasswordManagerSavingEnabled is | |
| 68 // turned off. | |
| 69 void Reconcile(PrefService* prefs); | |
|
vabr (Chromium)
2015/08/07 08:48:02
The name does not seem to match the comment. Recon
engedy
2015/08/07 11:41:38
Apologies, I am afraid it was me who originally ca
vabr (Chromium)
2015/08/07 11:56:19
SGTM!
melandory
2015/08/12 09:03:24
Done.
| |
| 70 | |
| 71 Profile* profile_; | |
| 72 | |
| 73 ProfileSyncService* profile_sync_service_; | |
|
vabr (Chromium)
2015/08/07 08:48:02
Please use the parent interface from components/sy
| |
| 74 PrefChangeRegistrar pref_change_registrar_; | |
| 75 | |
| 76 base::WeakPtrFactory<PasswordSettingsMigrationService> weak_factory_; | |
|
engedy
2015/08/07 11:41:38
nit: Do we actually use the |weak_factory_|?
melandory
2015/08/12 09:03:23
Done.
| |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(PasswordSettingsMigrationService); | |
| 79 }; | |
| 80 | |
| 81 } // namespace password_manager | |
| 82 | |
| 83 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_MIGRATION_SERVICE_H_ | |
| OLD | NEW |