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

Side by Side Diff: chrome/browser/prefs/preferences_manager.h

Issue 2474653003: PreferencesManager (Closed)
Patch Set: Revert Example Created 4 years 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 2016 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_PREFS_PREFERENCES_MANAGER_H_
6 #define CHROME_BROWSER_PREFS_PREFERENCES_MANAGER_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "services/preferences/public/interfaces/preferences.mojom.h"
12
13 namespace test {
14 class PreferencesManagerTest;
15 }
16
17 class PrefChangeRegistrar;
18 class PrefService;
19 class Profile;
20
21 namespace chrome {
sky 2016/12/06 23:37:37 Same comment about namespaces.
jonross 2016/12/07 15:46:39 Done.
22
23 // Implementation of prefs::mojom::PreferencesManager that accepts a single
24 // prefs::mojom::PreferencesObserver.
25 //
26 // After calling AddObserver PreferencesManager will begin observing changes to
27 // the requested preferences, notifying the client of all changes.
28 class PreferencesManager : public prefs::mojom::PreferencesManager {
29 public:
30 explicit PreferencesManager(Profile* profile);
31 ~PreferencesManager() override;
32
33 // Must be called when the active PrefService is being destroyed.
34 void OnProfileDestroyed();
35
36 private:
37 friend class test::PreferencesManagerTest;
38
39 // PrefChangeRegistrar::NamedChangeCallback:
40 void PreferenceChanged(const std::string& preference_name);
41
42 // mojom::PreferencesManager:
43 void AddObserver(prefs::mojom::PreferencesObserverPtr client) override;
44 void SetPreferences(const base::DictionaryValue& preferences) override;
45 void Subscribe(const std::vector<std::string>& preferences) override;
46
47 // Tracks the desired preferences, and listens for updates.
48 std::unique_ptr<PrefChangeRegistrar> preferences_change_registrar_;
49 prefs::mojom::PreferencesObserverPtr client_;
50 PrefService* service_;
51
52 // Used to prevent notifying |client_| of changes caused by it calling
53 // SetPreferences.
54 bool setting_preferences_;
55
56 DISALLOW_COPY_AND_ASSIGN(PreferencesManager);
57 };
58
59 } // namespace chrome
60
61 #endif // CHROME_BROWSER_PREFS_PREFERENCES_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698