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

Unified Diff: chrome/browser/chromeos/cros_settings.h

Issue 3143009: Reenabled ChromeOS system setting for timezone selection.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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/chromeos/cros_settings.h
===================================================================
--- chrome/browser/chromeos/cros_settings.h (revision 56142)
+++ chrome/browser/chromeos/cros_settings.h (working copy)
@@ -8,9 +8,13 @@
#include <string>
#include <vector>
+
+#include "base/hash_tables.h"
+#include "base/non_thread_safe.h"
+#include "base/observer_list.h"
#include "base/singleton.h"
-
#include "chrome/browser/chromeos/cros_settings_names.h"
+#include "chrome/common/notification_observer.h"
class Value;
@@ -19,7 +23,7 @@
class CrosSettingsProvider;
// A class manages per-device/global settings.
-class CrosSettings {
+class CrosSettings : public NonThreadSafe {
public:
// Class factory.
static CrosSettings* Get();
@@ -31,6 +35,9 @@
// Note that this takes ownership of |in_value|.
void Set(const std::string& path, Value* in_value);
+ // Fires system setting change notification.
+ void FireObservers(const char* path);
+
// Gets settings value of given |path| to |out_value|.
// Note that |out_value| is still owned by this class.
bool Get(const std::string& path, Value** out_value) const;
@@ -50,17 +57,31 @@
bool GetReal(const std::string& path, double* out_value) const;
bool GetString(const std::string& path, std::string* out_value) const;
- private:
// adding/removing of providers
- bool AddProvider(CrosSettingsProvider* provider);
- bool RemoveProvider(CrosSettingsProvider* provider);
+ bool AddSettingsProvider(CrosSettingsProvider* provider);
+ bool RemoveSettingsProvider(CrosSettingsProvider* provider);
+ // If the pref at the given path changes, we call the observer's Observe
+ // method with NOTIFY_PREF_CHANGED.
+ void AddSettingsObserver(const char* path, NotificationObserver* obs);
+ void RemoveSettingsObserver(const char* path, NotificationObserver* obs);
+
+ private:
+ // List of ChromeOS system settings providers.
std::vector<CrosSettingsProvider*> providers_;
+ // A map from settings names to a list of observers. Observers get fired in
+ // the order they are added.
+ typedef ObserverList<NotificationObserver> NotificationObserverList;
+ typedef base::hash_map<std::string, NotificationObserverList*>
+ SettingsObserverMap;
+ SettingsObserverMap settings_observers_;
+
CrosSettings();
~CrosSettings();
CrosSettingsProvider* GetProvider(const std::string& path) const;
friend struct DefaultSingletonTraits<CrosSettings>;
+
DISALLOW_COPY_AND_ASSIGN(CrosSettings);
};

Powered by Google App Engine
This is Rietveld 408576698