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 19 matching lines...) Expand all Loading... |
30 public: | 30 public: |
31 // Class factory. | 31 // Class factory. |
32 static CrosSettings* Get(); | 32 static CrosSettings* Get(); |
33 | 33 |
34 // Helper function to test if given path is a value cros settings name. | 34 // Helper function to test if given path is a value cros settings name. |
35 static bool IsCrosSettings(const std::string& path); | 35 static bool IsCrosSettings(const std::string& path); |
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. | |
41 // TODO(pastarmovj): Consider to remove this function from the public | |
42 // interface. | |
43 void FireObservers(const char* path); | |
44 | |
45 // Gets settings value of given |path| to |out_value|. | 40 // Gets settings value of given |path| to |out_value|. |
46 const base::Value* GetPref(const std::string& path) const; | 41 const base::Value* GetPref(const std::string& path) const; |
47 | 42 |
48 // Starts a fetch from the trusted store for the value of |path| if not loaded | 43 // 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 | 44 // 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 | 45 // was needed in which case the return value is false. Else it will return |
51 // true and won't call the |callback|. | 46 // true and won't call the |callback|. |
52 bool GetTrusted(const std::string& path, | 47 bool GetTrusted(const std::string& path, |
53 const base::Closure& callback) const; | 48 const base::Closure& callback) const; |
54 | 49 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 content::NotificationObserver* obs); | 85 content::NotificationObserver* obs); |
91 | 86 |
92 // Returns the provider that handles settings with the path or prefix. | 87 // Returns the provider that handles settings with the path or prefix. |
93 CrosSettingsProvider* GetProvider(const std::string& path) const; | 88 CrosSettingsProvider* GetProvider(const std::string& path) const; |
94 | 89 |
95 // Forces all providers to reload their caches from the respective backing | 90 // Forces all providers to reload their caches from the respective backing |
96 // stores if they have any. | 91 // stores if they have any. |
97 void ReloadProviders(); | 92 void ReloadProviders(); |
98 | 93 |
99 private: | 94 private: |
| 95 friend struct base::DefaultLazyInstanceTraits<CrosSettings>; |
| 96 |
100 // List of ChromeOS system settings providers. | 97 // List of ChromeOS system settings providers. |
101 std::vector<CrosSettingsProvider*> providers_; | 98 std::vector<CrosSettingsProvider*> providers_; |
102 | 99 |
103 // A map from settings names to a list of observers. Observers get fired in | 100 // A map from settings names to a list of observers. Observers get fired in |
104 // the order they are added. | 101 // the order they are added. |
105 typedef ObserverList<content::NotificationObserver> NotificationObserverList; | 102 typedef ObserverList<content::NotificationObserver> NotificationObserverList; |
106 typedef base::hash_map<std::string, NotificationObserverList*> | 103 typedef base::hash_map<std::string, NotificationObserverList*> |
107 SettingsObserverMap; | 104 SettingsObserverMap; |
108 SettingsObserverMap settings_observers_; | 105 SettingsObserverMap settings_observers_; |
109 | 106 |
110 CrosSettings(); | 107 CrosSettings(); |
111 ~CrosSettings(); | 108 ~CrosSettings(); |
112 friend struct base::DefaultLazyInstanceTraits<CrosSettings>; | 109 |
| 110 // Fires system setting change notification. |
| 111 void FireObservers(const std::string& path); |
113 | 112 |
114 DISALLOW_COPY_AND_ASSIGN(CrosSettings); | 113 DISALLOW_COPY_AND_ASSIGN(CrosSettings); |
115 }; | 114 }; |
116 | 115 |
117 } // namespace chromeos | 116 } // namespace chromeos |
118 | 117 |
119 #endif // CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ | 118 #endif // CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ |
OLD | NEW |