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

Unified Diff: chrome/browser/prefs/preferences_manager.h

Issue 2474653003: PreferencesManager (Closed)
Patch Set: Update PreferencesManager to account for base::Value API change 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/prefs/preferences_connection_manager.cc ('k') | chrome/browser/prefs/preferences_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/preferences_manager.h
diff --git a/chrome/browser/prefs/preferences_manager.h b/chrome/browser/prefs/preferences_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..9ffc67aa4c2e4c51a18437d5ee72430977f5ba59
--- /dev/null
+++ b/chrome/browser/prefs/preferences_manager.h
@@ -0,0 +1,55 @@
+// Copyright 2016 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_PREFS_PREFERENCES_MANAGER_H_
+#define CHROME_BROWSER_PREFS_PREFERENCES_MANAGER_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "services/preferences/public/interfaces/preferences.mojom.h"
+
+namespace test {
+class PreferencesManagerTest;
+}
+
+class PrefChangeRegistrar;
+class PrefService;
+class Profile;
+
+// Implementation of prefs::mojom::PreferencesManager that accepts a single
+// prefs::mojom::PreferencesObserver.
+//
+// After calling AddObserver PreferencesManager will begin observing changes to
+// the requested preferences, notifying the client of all changes.
+class PreferencesManager : public prefs::mojom::PreferencesManager {
+ public:
+ explicit PreferencesManager(Profile* profile);
+ ~PreferencesManager() override;
+
+ private:
+ friend class test::PreferencesManagerTest;
+
+ // PrefChangeRegistrar::NamedChangeCallback:
+ void PreferenceChanged(const std::string& preference_name);
+
+ // mojom::PreferencesManager:
+ void AddObserver(prefs::mojom::PreferencesObserverPtr client) override;
+ void SetPreferences(
+ std::unique_ptr<base::DictionaryValue> preferences) override;
+ void Subscribe(const std::vector<std::string>& preferences) override;
+
+ // Tracks the desired preferences, and listens for updates.
+ std::unique_ptr<PrefChangeRegistrar> preferences_change_registrar_;
+ prefs::mojom::PreferencesObserverPtr client_;
+ PrefService* service_;
+
+ // Used to prevent notifying |client_| of changes caused by it calling
+ // SetPreferences.
+ bool setting_preferences_;
+
+ DISALLOW_COPY_AND_ASSIGN(PreferencesManager);
+};
+
+#endif // CHROME_BROWSER_PREFS_PREFERENCES_MANAGER_H_
« no previous file with comments | « chrome/browser/prefs/preferences_connection_manager.cc ('k') | chrome/browser/prefs/preferences_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698