OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ |
6 #define CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 25 matching lines...) Expand all Loading... | |
36 | 36 |
37 // Sets |in_value| to given |path| in cros settings. | 37 // Sets |in_value| to given |path| in cros settings. |
38 void Set(const std::string& path, const base::Value& in_value); | 38 void Set(const std::string& path, const base::Value& in_value); |
39 | 39 |
40 // Fires system setting change notification. | 40 // Fires system setting change notification. |
41 // TODO(pastarmovj): Consider to remove this function from the public | 41 // TODO(pastarmovj): Consider to remove this function from the public |
42 // interface. | 42 // interface. |
43 void FireObservers(const char* path); | 43 void FireObservers(const char* path); |
44 | 44 |
45 // Gets settings value of given |path| to |out_value|. | 45 // Gets settings value of given |path| to |out_value|. |
46 const base::Value* GetPref(const std::string& path) const; | 46 base::Value* GetPref(const std::string& path) const; |
Mattias Nissler (ping if slow)
2011/11/30 11:22:44
Why is this now non-const? From the rest of the co
pastarmovj
2011/11/30 17:21:16
Changed as discussed offline.
| |
47 | 47 |
48 // Starts a fetch from the trusted store for the value of |path| if not loaded | 48 // Starts a fetch from the trusted store for the value of |path| if not loaded |
49 // yet. It will call the |callback| function upon completion if a new fetch | 49 // yet. It will call the |callback| function upon completion if a new fetch |
50 // was needed in which case the return value is false. Else it will return | 50 // was needed in which case the return value is false. Else it will return |
51 // true and won't call the |callback|. | 51 // true and won't call the |callback|. |
52 bool GetTrusted(const std::string& path, | 52 bool GetTrusted(const std::string& path, |
53 const base::Closure& callback) const; | 53 const base::Closure& callback) const; |
54 | 54 |
55 // Convenience forms of Set(). These methods will replace any existing | 55 // Convenience forms of Set(). These methods will replace any existing |
56 // value at that path, even if it has a different type. | 56 // value at that path, even if it has a different type. |
(...skipping 28 matching lines...) Expand all Loading... | |
85 // If the pref at the given path changes, we call the observer's Observe | 85 // If the pref at the given path changes, we call the observer's Observe |
86 // method with PREF_CHANGED. | 86 // method with PREF_CHANGED. |
87 void AddSettingsObserver(const char* path, | 87 void AddSettingsObserver(const char* path, |
88 content::NotificationObserver* obs); | 88 content::NotificationObserver* obs); |
89 void RemoveSettingsObserver(const char* path, | 89 void RemoveSettingsObserver(const char* path, |
90 content::NotificationObserver* obs); | 90 content::NotificationObserver* obs); |
91 | 91 |
92 // Returns the provider that handles settings with the path or prefix. | 92 // Returns the provider that handles settings with the path or prefix. |
93 CrosSettingsProvider* GetProvider(const std::string& path) const; | 93 CrosSettingsProvider* GetProvider(const std::string& path) const; |
94 | 94 |
95 void ReloadProviders() const; | |
Mattias Nissler (ping if slow)
2011/11/30 11:22:44
Needs a comment. What does it do? Recreate the pro
pastarmovj
2011/11/30 17:21:16
Sorry my bad I forgot to comment that one. Done.
| |
96 | |
95 private: | 97 private: |
96 // List of ChromeOS system settings providers. | 98 // List of ChromeOS system settings providers. |
97 std::vector<CrosSettingsProvider*> providers_; | 99 std::vector<CrosSettingsProvider*> providers_; |
98 | 100 |
99 // A map from settings names to a list of observers. Observers get fired in | 101 // A map from settings names to a list of observers. Observers get fired in |
100 // the order they are added. | 102 // the order they are added. |
101 typedef ObserverList<content::NotificationObserver> NotificationObserverList; | 103 typedef ObserverList<content::NotificationObserver> NotificationObserverList; |
102 typedef base::hash_map<std::string, NotificationObserverList*> | 104 typedef base::hash_map<std::string, NotificationObserverList*> |
103 SettingsObserverMap; | 105 SettingsObserverMap; |
104 SettingsObserverMap settings_observers_; | 106 SettingsObserverMap settings_observers_; |
105 | 107 |
106 CrosSettings(); | 108 CrosSettings(); |
107 ~CrosSettings(); | 109 ~CrosSettings(); |
108 friend struct base::DefaultLazyInstanceTraits<CrosSettings>; | 110 friend struct base::DefaultLazyInstanceTraits<CrosSettings>; |
109 | 111 |
110 DISALLOW_COPY_AND_ASSIGN(CrosSettings); | 112 DISALLOW_COPY_AND_ASSIGN(CrosSettings); |
111 }; | 113 }; |
112 | 114 |
113 } // namespace chromeos | 115 } // namespace chromeos |
114 | 116 |
115 #endif // CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ | 117 #endif // CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ |
OLD | NEW |