Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2939)

Unified Diff: chrome/browser/password_manager/password_manager_migration_service.h

Issue 1256803002: [Smart Lock, Prefs reconciliation] Prefs migration logic for desktop platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix mac Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/password_manager/password_manager_migration_service.h
diff --git a/chrome/browser/password_manager/password_manager_migration_service.h b/chrome/browser/password_manager/password_manager_migration_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..1c00ae84cff408987027e06f86042fe858d2049b
--- /dev/null
+++ b/chrome/browser/password_manager/password_manager_migration_service.h
@@ -0,0 +1,83 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_MIGRATION_SERVICE_H_
+#define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_MIGRATION_SERVICE_H_
+
+#include "base/memory/singleton.h"
+#include "base/memory/weak_ptr.h"
+#include "base/prefs/pref_change_registrar.h"
+#include "chrome/browser/prefs/pref_service_syncable_observer.h"
+#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
+#include "components/keyed_service/core/keyed_service.h"
+
+class Profile;
+class ProfileSyncService;
+
+namespace password_manager {
+
+// 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.
+// manager and Smart Lock for passwords settings.
+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.
+ public PrefServiceSyncableObserver {
+ public:
+ explicit PasswordSettingsMigrationService(Profile* profile);
+ ~PasswordSettingsMigrationService() override;
+
+ // Initializes the observers: preferences observers and sync status observers.
+ void InitObservers();
+
+ 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.
+ public:
+ static Factory* GetInstance();
+ static PasswordSettingsMigrationService* GetForProfile(Profile* profile);
+
+ private:
+ friend struct DefaultSingletonTraits<Factory>;
+ friend class PasswordSettingsMigrationServiceTest;
vabr (Chromium) 2015/08/07 08:48:02 so far non-actionable note: Friending for tests is
+
+ Factory();
+ ~Factory() override;
+
+ // BrowserContextKeyedServiceFactory implementation
engedy 2015/08/07 11:41:38 optional nit: Some people prefer writing just: //
melandory 2015/08/12 09:03:24 Done.
+ KeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* profile) const override;
+ bool ServiceIsCreatedWithBrowserContext() const override;
+ bool ServiceIsNULLWhileTesting() const override;
+ content::BrowserContext* GetBrowserContextToUse(
+ content::BrowserContext* context) const override;
+ };
+
+ // PrefServiceSyncableObserver:
+ void OnIsSyncingChanged() override;
+
+ private:
+ friend class PasswordSettingsMigrationServiceTest;
+
+ // For unit testing only.
+ PasswordSettingsMigrationService(Profile* profile,
+ 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
+ // 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.
+ // 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
+ // sync with changed preference.
+ 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
+ const std::string& changed_pref_name);
+
+ // Turns off CredentialEnableService when PasswordManagerSavingEnabled is
+ // turned off.
+ 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.
+
+ Profile* profile_;
+
+ ProfileSyncService* profile_sync_service_;
vabr (Chromium) 2015/08/07 08:48:02 Please use the parent interface from components/sy
+ PrefChangeRegistrar pref_change_registrar_;
+
+ 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.
+
+ DISALLOW_COPY_AND_ASSIGN(PasswordSettingsMigrationService);
+};
+
+} // namespace password_manager
+
+#endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_MIGRATION_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698