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

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: Sort tests. 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 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 "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
63 private:
64 // Initializes the observers: preferences observers and sync status observers.
65 void InitObservers();
66
67 // Called on event of changing kCredentialsEnableService preference. Changes
68 // the value of kPasswordManagerSavingEnabled preference to be in sync with
69 // kCredentialsEnableService.
70 void OnCredentialsEnableServicePrefChanged(
71 const std::string& changed_pref_name);
72
73 // Called on event of changing kPasswordManagerSavingEnabled preference.
74 // Changes the value of kCredentialsEnableService preference to be in sync
75 // with kPasswordManagerSavingEnabled.
76 void OnPasswordManagerSavingEnabledPrefChanged(
77 const std::string& changed_pref_name);
78
79 // Turns off one pref if another pref is off.
80 void MigrateOffState(PrefService* prefs);
81
82 Profile* const profile_;
83 sync_driver::SyncService* sync_service_;
84 PrefChangeRegistrar pref_change_registrar_;
85
86 // Used to register for notification that profile creation is complete.
87 content::NotificationRegistrar registrar_;
88
89 bool both_pref_off_;
vabr (Chromium) 2015/08/26 14:42:43 Please comment on the meaning of this flag, and ho
melandory 2015/08/28 14:49:24 Not applicable anymore.
90
91 DISALLOW_COPY_AND_ASSIGN(PasswordManagerSettingMigraterService);
92 };
93
94 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_SETTING_MIGRATER_SER VICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698