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

Unified Diff: chrome/browser/password_manager/password_manager_setting_migrater_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: Follow one variable per declaration rule. 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_setting_migrater_service.h
diff --git a/chrome/browser/password_manager/password_manager_setting_migrater_service.h b/chrome/browser/password_manager/password_manager_setting_migrater_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..9b80ee77886b2bf467d70b047c58147afac73f68
--- /dev/null
+++ b/chrome/browser/password_manager/password_manager_setting_migrater_service.h
@@ -0,0 +1,110 @@
+// 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_SETTING_MIGRATER_SERVICE_H_
+#define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_SETTING_MIGRATER_SERVICE_H_
+
+#include <vector>
+
+#include "base/memory/singleton.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"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+class Profile;
+
+namespace sync_driver {
+class SyncService;
+}
+
+// PasswordManagerSettingMigraterService is responsible for reconciling Chrome
engedy 2015/08/31 18:17:23 Phrasing nit: Given the complexity and the vast n
melandory 2015/09/02 13:15:39 Done.
+// password manager and Smart Lock for passwords settings.
+// Note: componetization of this service currently is impossible, because it
+// depends on PrefServiceSyncable.
+class PasswordManagerSettingMigraterService
+ : public KeyedService,
+ public PrefServiceSyncableObserver,
+ public content::NotificationObserver {
+ public:
+ class Factory : public BrowserContextKeyedServiceFactory {
+ public:
+ static Factory* GetInstance();
+ static PasswordManagerSettingMigraterService* GetForProfile(
+ Profile* profile);
+
+ private:
+ friend struct DefaultSingletonTraits<Factory>;
+ friend class PasswordManagerSettingMigraterServiceTest;
+
+ Factory();
+ ~Factory() override;
+
+ // BrowserContextKeyedServiceFactory
engedy 2015/08/31 18:17:23 nit: Add colon (:) at the end. Same below, 3 place
melandory 2015/09/02 13:15:39 Done.
+ KeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* profile) const override;
+ bool ServiceIsCreatedWithBrowserContext() const override;
+ };
+
+ explicit PasswordManagerSettingMigraterService(Profile* profile);
+ ~PasswordManagerSettingMigraterService() override;
+
+ void Shutdown() override;
+
+ // PrefServiceSyncableObserver
+ void OnIsSyncingChanged() override;
+
+ // content::NotificationObserver
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) override;
+
+ private:
+ // Initializes the observers: preferences observers and sync status observers.
+ void InitObservers();
+
+ // Called on event of changing kCredentialsEnableService preference. Changes
engedy 2015/08/31 18:17:23 Phrasing nit: What do you think about simply sayin
melandory 2015/09/02 13:15:39 Done.
+ // the value of kPasswordManagerSavingEnabled preference to be in sync with
+ // kCredentialsEnableService.
+ void OnCredentialsEnableServicePrefChanged(
+ const std::string& changed_pref_name);
+
+ // Called on event of changing kPasswordManagerSavingEnabled preference.
+ // Changes the value of kCredentialsEnableService preference to be in sync
+ // with kPasswordManagerSavingEnabled.
+ void OnPasswordManagerSavingEnabledPrefChanged(
+ const std::string& changed_pref_name);
+
+ // Turns off one pref if another pref is off.
+ void MigrateOffState(PrefService* prefs);
+
+ // Performs a migration after sync associates models. Migration is performed
+ // based on initial values for both preferences and values received from
+ // sync.
+ void MigrateAfterModelAssociation(PrefService* prefs);
+
+ Profile* const profile_;
+ sync_driver::SyncService* sync_service_;
+ PrefChangeRegistrar pref_change_registrar_;
+
+ // Used to register for notification that profile creation is complete.
+ content::NotificationRegistrar registrar_;
+
+ // This vector contains initial value for both preferences. The vector maximum
+ // size is two, where first element is new kCredentialsEnableService
+ // preference
+ // and second element is legacy kPasswordManagerSavingEnabled preference.
+ std::vector<bool> initial_values_;
+
+ // Contains values which has came from sync during model association step.
+ // After both preferences data types are associated, new value for the both
+ // preferences will be calculated.
+ std::vector<bool> sync_data_;
+
+ DISALLOW_COPY_AND_ASSIGN(PasswordManagerSettingMigraterService);
+};
+
+#endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_SETTING_MIGRATER_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698