| 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> |
| 11 | 11 |
| 12 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
| 16 #include "chrome/browser/chromeos/cros_settings_names.h" | 16 #include "chrome/browser/chromeos/cros_settings_names.h" |
| 17 #include "content/common/notification_observer.h" | 17 #include "content/common/notification_observer.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 template <typename T> struct DefaultLazyInstanceTraits; | 20 template <typename T> struct DefaultLazyInstanceTraits; |
| 21 class Value; |
| 21 } | 22 } |
| 22 | 23 |
| 23 class Value; | |
| 24 | |
| 25 namespace chromeos { | 24 namespace chromeos { |
| 26 | 25 |
| 27 class CrosSettingsProvider; | 26 class CrosSettingsProvider; |
| 28 | 27 |
| 29 // A class manages per-device/global settings. | 28 // A class manages per-device/global settings. |
| 30 class CrosSettings : public base::NonThreadSafe { | 29 class CrosSettings : public base::NonThreadSafe { |
| 31 public: | 30 public: |
| 32 // Class factory. | 31 // Class factory. |
| 33 static CrosSettings* Get(); | 32 static CrosSettings* Get(); |
| 34 | 33 |
| 35 // 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. |
| 36 static bool IsCrosSettings(const std::string& path); | 35 static bool IsCrosSettings(const std::string& path); |
| 37 | 36 |
| 38 // Sets |in_value| to given |path| in cros settings. | 37 // Sets |in_value| to given |path| in cros settings. |
| 39 // Note that this takes ownership of |in_value|. | 38 // Note that this takes ownership of |in_value|. |
| 40 void Set(const std::string& path, Value* in_value); | 39 void Set(const std::string& path, base::Value* in_value); |
| 41 | 40 |
| 42 // Fires system setting change notification. | 41 // Fires system setting change notification. |
| 43 void FireObservers(const char* path); | 42 void FireObservers(const char* path); |
| 44 | 43 |
| 45 // Gets settings value of given |path| to |out_value|. | 44 // Gets settings value of given |path| to |out_value|. |
| 46 // Note that the caller owns |out_value| returned. | 45 // Note that the caller owns |out_value| returned. |
| 47 bool Get(const std::string& path, Value** out_value) const; | 46 bool Get(const std::string& path, base::Value** out_value) const; |
| 48 | 47 |
| 49 // Convenience forms of Set(). These methods will replace any existing | 48 // Convenience forms of Set(). These methods will replace any existing |
| 50 // value at that path, even if it has a different type. | 49 // value at that path, even if it has a different type. |
| 51 void SetBoolean(const std::string& path, bool in_value); | 50 void SetBoolean(const std::string& path, bool in_value); |
| 52 void SetInteger(const std::string& path, int in_value); | 51 void SetInteger(const std::string& path, int in_value); |
| 53 void SetDouble(const std::string& path, double in_value); | 52 void SetDouble(const std::string& path, double in_value); |
| 54 void SetString(const std::string& path, const std::string& in_value); | 53 void SetString(const std::string& path, const std::string& in_value); |
| 55 | 54 |
| 56 // These are convenience forms of Get(). The value will be retrieved | 55 // These are convenience forms of Get(). The value will be retrieved |
| 57 // and the return value will be true if the path is valid and the value at | 56 // and the return value will be true if the path is valid and the value at |
| (...skipping 27 matching lines...) Expand all Loading... |
| 85 ~CrosSettings(); | 84 ~CrosSettings(); |
| 86 CrosSettingsProvider* GetProvider(const std::string& path) const; | 85 CrosSettingsProvider* GetProvider(const std::string& path) const; |
| 87 friend struct base::DefaultLazyInstanceTraits<CrosSettings>; | 86 friend struct base::DefaultLazyInstanceTraits<CrosSettings>; |
| 88 | 87 |
| 89 DISALLOW_COPY_AND_ASSIGN(CrosSettings); | 88 DISALLOW_COPY_AND_ASSIGN(CrosSettings); |
| 90 }; | 89 }; |
| 91 | 90 |
| 92 } // namespace chromeos | 91 } // namespace chromeos |
| 93 | 92 |
| 94 #endif // CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ | 93 #endif // CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ |
| OLD | NEW |