| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/callback_list.h" | 13 #include "base/callback_list.h" |
| 14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/threading/non_thread_safe.h" | 16 #include "base/sequence_checker.h" |
| 17 #include "chromeos/settings/cros_settings_names.h" | 17 #include "chromeos/settings/cros_settings_names.h" |
| 18 #include "chromeos/settings/cros_settings_provider.h" | 18 #include "chromeos/settings/cros_settings_provider.h" |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class DictionaryValue; | 21 class DictionaryValue; |
| 22 class ListValue; | 22 class ListValue; |
| 23 class Value; | 23 class Value; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace chromeos { | 26 namespace chromeos { |
| 27 | 27 |
| 28 class DeviceSettingsService; | 28 class DeviceSettingsService; |
| 29 | 29 |
| 30 // This class manages per-device/global settings. | 30 // This class manages per-device/global settings. |
| 31 class CrosSettings : public base::NonThreadSafe { | 31 class CrosSettings { |
| 32 public: | 32 public: |
| 33 // Manage singleton instance. | 33 // Manage singleton instance. |
| 34 static void Initialize(); | 34 static void Initialize(); |
| 35 static bool IsInitialized(); | 35 static bool IsInitialized(); |
| 36 static void Shutdown(); | 36 static void Shutdown(); |
| 37 static CrosSettings* Get(); | 37 static CrosSettings* Get(); |
| 38 | 38 |
| 39 // Checks if the given username is whitelisted and allowed to sign-in to | 39 // Checks if the given username is whitelisted and allowed to sign-in to |
| 40 // this device. |wildcard_match| may be NULL. If it's present, it'll be set to | 40 // this device. |wildcard_match| may be NULL. If it's present, it'll be set to |
| 41 // true if the whitelist check was satisfied via a wildcard. | 41 // true if the whitelist check was satisfied via a wildcard. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 void FireObservers(const std::string& path); | 127 void FireObservers(const std::string& path); |
| 128 | 128 |
| 129 // List of ChromeOS system settings providers. | 129 // List of ChromeOS system settings providers. |
| 130 std::vector<std::unique_ptr<CrosSettingsProvider>> providers_; | 130 std::vector<std::unique_ptr<CrosSettingsProvider>> providers_; |
| 131 | 131 |
| 132 // A map from settings names to a list of observers. Observers get fired in | 132 // A map from settings names to a list of observers. Observers get fired in |
| 133 // the order they are added. | 133 // the order they are added. |
| 134 base::hash_map<std::string, std::unique_ptr<base::CallbackList<void(void)>>> | 134 base::hash_map<std::string, std::unique_ptr<base::CallbackList<void(void)>>> |
| 135 settings_observers_; | 135 settings_observers_; |
| 136 | 136 |
| 137 SEQUENCE_CHECKER(sequence_checker_); |
| 138 |
| 137 DISALLOW_COPY_AND_ASSIGN(CrosSettings); | 139 DISALLOW_COPY_AND_ASSIGN(CrosSettings); |
| 138 }; | 140 }; |
| 139 | 141 |
| 140 // Helper class for tests. Initializes the CrosSettings singleton on | 142 // Helper class for tests. Initializes the CrosSettings singleton on |
| 141 // construction and tears it down again on destruction. | 143 // construction and tears it down again on destruction. |
| 142 class ScopedTestCrosSettings { | 144 class ScopedTestCrosSettings { |
| 143 public: | 145 public: |
| 144 ScopedTestCrosSettings(); | 146 ScopedTestCrosSettings(); |
| 145 ~ScopedTestCrosSettings(); | 147 ~ScopedTestCrosSettings(); |
| 146 | 148 |
| 147 private: | 149 private: |
| 148 DISALLOW_COPY_AND_ASSIGN(ScopedTestCrosSettings); | 150 DISALLOW_COPY_AND_ASSIGN(ScopedTestCrosSettings); |
| 149 }; | 151 }; |
| 150 | 152 |
| 151 } // namespace chromeos | 153 } // namespace chromeos |
| 152 | 154 |
| 153 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_CROS_SETTINGS_H_ | 155 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_CROS_SETTINGS_H_ |
| OLD | NEW |