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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
(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 <vector>
9
10 #include "base/memory/singleton.h"
11 #include "base/prefs/pref_change_registrar.h"
12 #include "chrome/browser/prefs/pref_service_syncable_observer.h"
13 #include "components/keyed_service/content/browser_context_keyed_service_factory .h"
14 #include "components/keyed_service/core/keyed_service.h"
15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h"
17
18 class Profile;
19
20 namespace sync_driver {
21 class SyncService;
22 }
23
24 // 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.
25 // password manager and Smart Lock for passwords settings.
26 // Note: componetization of this service currently is impossible, because it
27 // depends on PrefServiceSyncable.
28 class PasswordManagerSettingMigraterService
29 : public KeyedService,
30 public PrefServiceSyncableObserver,
31 public content::NotificationObserver {
32 public:
33 class Factory : public BrowserContextKeyedServiceFactory {
34 public:
35 static Factory* GetInstance();
36 static PasswordManagerSettingMigraterService* GetForProfile(
37 Profile* profile);
38
39 private:
40 friend struct DefaultSingletonTraits<Factory>;
41 friend class PasswordManagerSettingMigraterServiceTest;
42
43 Factory();
44 ~Factory() override;
45
46 // 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.
47 KeyedService* BuildServiceInstanceFor(
48 content::BrowserContext* profile) const override;
49 bool ServiceIsCreatedWithBrowserContext() const override;
50 };
51
52 explicit PasswordManagerSettingMigraterService(Profile* profile);
53 ~PasswordManagerSettingMigraterService() override;
54
55 void Shutdown() override;
56
57 // PrefServiceSyncableObserver
58 void OnIsSyncingChanged() override;
59
60 // content::NotificationObserver
61 void Observe(int type,
62 const content::NotificationSource& source,
63 const content::NotificationDetails& details) override;
64
65 private:
66 // Initializes the observers: preferences observers and sync status observers.
67 void InitObservers();
68
69 // 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.
70 // the value of kPasswordManagerSavingEnabled preference to be in sync with
71 // kCredentialsEnableService.
72 void OnCredentialsEnableServicePrefChanged(
73 const std::string& changed_pref_name);
74
75 // Called on event of changing kPasswordManagerSavingEnabled preference.
76 // Changes the value of kCredentialsEnableService preference to be in sync
77 // with kPasswordManagerSavingEnabled.
78 void OnPasswordManagerSavingEnabledPrefChanged(
79 const std::string& changed_pref_name);
80
81 // Turns off one pref if another pref is off.
82 void MigrateOffState(PrefService* prefs);
83
84 // Performs a migration after sync associates models. Migration is performed
85 // based on initial values for both preferences and values received from
86 // sync.
87 void MigrateAfterModelAssociation(PrefService* prefs);
88
89 Profile* const profile_;
90 sync_driver::SyncService* sync_service_;
91 PrefChangeRegistrar pref_change_registrar_;
92
93 // Used to register for notification that profile creation is complete.
94 content::NotificationRegistrar registrar_;
95
96 // This vector contains initial value for both preferences. The vector maximum
97 // size is two, where first element is new kCredentialsEnableService
98 // preference
99 // and second element is legacy kPasswordManagerSavingEnabled preference.
100 std::vector<bool> initial_values_;
101
102 // Contains values which has came from sync during model association step.
103 // After both preferences data types are associated, new value for the both
104 // preferences will be calculated.
105 std::vector<bool> sync_data_;
106
107 DISALLOW_COPY_AND_ASSIGN(PasswordManagerSettingMigraterService);
108 };
109
110 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_SETTING_MIGRATER_SER VICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698