| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SETTINGS_CROS_SETTINGS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_CROS_SETTINGS_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_CROS_SETTINGS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_CROS_SETTINGS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // If the pref at the given |path| changes, we call the observer's Observe | 84 // If the pref at the given |path| changes, we call the observer's Observe |
| 85 // method with NOTIFICATION_SYSTEM_SETTING_CHANGED. | 85 // method with NOTIFICATION_SYSTEM_SETTING_CHANGED. |
| 86 void AddSettingsObserver(const char* path, | 86 void AddSettingsObserver(const char* path, |
| 87 content::NotificationObserver* obs); | 87 content::NotificationObserver* obs); |
| 88 void RemoveSettingsObserver(const char* path, | 88 void RemoveSettingsObserver(const char* path, |
| 89 content::NotificationObserver* obs); | 89 content::NotificationObserver* obs); |
| 90 | 90 |
| 91 // Returns the provider that handles settings with the |path| or prefix. | 91 // Returns the provider that handles settings with the |path| or prefix. |
| 92 CrosSettingsProvider* GetProvider(const std::string& path) const; | 92 CrosSettingsProvider* GetProvider(const std::string& path) const; |
| 93 | 93 |
| 94 // Forces all providers to reload their caches from the respective backing | |
| 95 // stores if they have any. | |
| 96 void ReloadProviders(); | |
| 97 | |
| 98 private: | 94 private: |
| 99 friend struct base::DefaultLazyInstanceTraits<CrosSettings>; | 95 friend struct base::DefaultLazyInstanceTraits<CrosSettings>; |
| 96 friend class CrosSettingsTest; |
| 97 |
| 98 // Public for testing. |
| 99 CrosSettings(); |
| 100 ~CrosSettings(); |
| 101 |
| 102 // Fires system setting change notification. |
| 103 void FireObservers(const std::string& path); |
| 100 | 104 |
| 101 // List of ChromeOS system settings providers. | 105 // List of ChromeOS system settings providers. |
| 102 std::vector<CrosSettingsProvider*> providers_; | 106 std::vector<CrosSettingsProvider*> providers_; |
| 103 | 107 |
| 104 // A map from settings names to a list of observers. Observers get fired in | 108 // A map from settings names to a list of observers. Observers get fired in |
| 105 // the order they are added. | 109 // the order they are added. |
| 106 typedef ObserverList<content::NotificationObserver, true> | 110 typedef ObserverList<content::NotificationObserver, true> |
| 107 NotificationObserverList; | 111 NotificationObserverList; |
| 108 typedef base::hash_map<std::string, NotificationObserverList*> | 112 typedef base::hash_map<std::string, NotificationObserverList*> |
| 109 SettingsObserverMap; | 113 SettingsObserverMap; |
| 110 SettingsObserverMap settings_observers_; | 114 SettingsObserverMap settings_observers_; |
| 111 | 115 |
| 112 CrosSettings(); | |
| 113 ~CrosSettings(); | |
| 114 | |
| 115 // Fires system setting change notification. | |
| 116 void FireObservers(const std::string& path); | |
| 117 | |
| 118 DISALLOW_COPY_AND_ASSIGN(CrosSettings); | 116 DISALLOW_COPY_AND_ASSIGN(CrosSettings); |
| 119 }; | 117 }; |
| 120 | 118 |
| 121 } // namespace chromeos | 119 } // namespace chromeos |
| 122 | 120 |
| 123 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_CROS_SETTINGS_H_ | 121 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_CROS_SETTINGS_H_ |
| OLD | NEW |