Chromium Code Reviews| 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 "chrome/browser/chromeos/cros_settings_provider.h" | |
| 17 #include "content/common/notification_observer.h" | 18 #include "content/common/notification_observer.h" |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 template <typename T> struct DefaultLazyInstanceTraits; | 21 template <typename T> struct DefaultLazyInstanceTraits; |
| 21 class Value; | 22 class Value; |
| 23 class ListValue; | |
| 22 } | 24 } |
| 23 | 25 |
| 24 namespace chromeos { | 26 namespace chromeos { |
| 25 | 27 |
| 26 class CrosSettingsProvider; | |
| 27 | |
| 28 // A class manages per-device/global settings. | 28 // A class manages per-device/global settings. |
| 29 class CrosSettings : public base::NonThreadSafe { | 29 class CrosSettings : public base::NonThreadSafe { |
| 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. |
|
Mattias Nissler (ping if slow)
2011/09/21 11:12:59
why is this public?
pastarmovj
2011/09/23 15:19:32
Because the CoreChromeOSOptionsHandler uses it to
| |
| 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 // Note that this takes ownership of |in_value|. | 38 // Note that this takes ownership of |in_value|. |
| 39 void Set(const std::string& path, base::Value* in_value); | 39 void Set(const std::string& path, base::Value* in_value); |
| 40 | 40 |
| 41 // Fires system setting change notification. | 41 // Fires system setting change notification. |
| 42 void FireObservers(const char* path); | 42 void FireObservers(const char* path); |
|
Mattias Nissler (ping if slow)
2011/09/21 11:12:59
why is this public?
pastarmovj
2011/09/23 15:19:32
Right now this is used by the SignedSettingsOps to
| |
| 43 | 43 |
| 44 // Gets settings value of given |path| to |out_value|. | 44 // Gets settings value of given |path| to |out_value|. |
|
Mattias Nissler (ping if slow)
2011/09/21 11:12:59
So there's no way of distinguishing "not set" from
pastarmovj
2011/09/23 15:19:32
What would the difference be for signed settings.
Mattias Nissler (ping if slow)
2011/09/26 17:26:37
I'm not sure I understand your reply. What I meant
| |
| 45 const base::Value* GetPref(const std::string& path) const; | |
| 46 | |
| 47 // Gets settings value of given |path| to |out_value|. | |
| 45 // Note that the caller owns |out_value| returned. | 48 // Note that the caller owns |out_value| returned. |
| 46 bool Get(const std::string& path, base::Value** out_value) const; | 49 bool Get(const std::string& path, base::Value** out_value) const; |
| 47 | 50 |
| 51 // Gets settings value of given |path| from the trusted store. It will call | |
| 52 // the |callback| function with the value of the setting or NULL if it could | |
| 53 // not be retrieved. | |
| 54 bool GetTrusted(const std::string& path, | |
| 55 const CrosSettingsProvider::Callback& callback) const; | |
|
Mattias Nissler (ping if slow)
2011/09/21 11:12:59
Clients shouldn't need to depend on CrosSettingsPr
pastarmovj
2011/09/23 15:19:32
Replaced with base::Closure which it ended up bein
| |
| 56 | |
| 48 // Convenience forms of Set(). These methods will replace any existing | 57 // Convenience forms of Set(). These methods will replace any existing |
| 49 // value at that path, even if it has a different type. | 58 // value at that path, even if it has a different type. |
| 50 void SetBoolean(const std::string& path, bool in_value); | 59 void SetBoolean(const std::string& path, bool in_value); |
| 51 void SetInteger(const std::string& path, int in_value); | 60 void SetInteger(const std::string& path, int in_value); |
| 52 void SetDouble(const std::string& path, double in_value); | 61 void SetDouble(const std::string& path, double in_value); |
| 53 void SetString(const std::string& path, const std::string& in_value); | 62 void SetString(const std::string& path, const std::string& in_value); |
| 54 | 63 |
| 55 // These are convenience forms of Get(). The value will be retrieved | 64 // These are convenience forms of Get(). The value will be retrieved |
| 56 // and the return value will be true if the path is valid and the value at | 65 // and the return value will be true if the path is valid and the value at |
| 57 // the end of the path can be returned in the form specified. | 66 // the end of the path can be returned in the form specified. |
| 58 bool GetBoolean(const std::string& path, bool* out_value) const; | 67 bool GetBoolean(const std::string& path, bool* out_value) const; |
| 59 bool GetInteger(const std::string& path, int* out_value) const; | 68 bool GetInteger(const std::string& path, int* out_value) const; |
| 60 bool GetDouble(const std::string& path, double* out_value) const; | 69 bool GetDouble(const std::string& path, double* out_value) const; |
| 61 bool GetString(const std::string& path, std::string* out_value) const; | 70 bool GetString(const std::string& path, std::string* out_value) const; |
| 71 bool GetList(const std::string& path, | |
| 72 const base::ListValue** out_value) const; | |
| 62 | 73 |
| 63 // adding/removing of providers | 74 // adding/removing of providers |
| 64 bool AddSettingsProvider(CrosSettingsProvider* provider); | 75 bool AddSettingsProvider(CrosSettingsProvider* provider); |
| 65 bool RemoveSettingsProvider(CrosSettingsProvider* provider); | 76 bool RemoveSettingsProvider(CrosSettingsProvider* provider); |
| 66 | 77 |
| 67 // If the pref at the given path changes, we call the observer's Observe | 78 // If the pref at the given path changes, we call the observer's Observe |
| 68 // method with PREF_CHANGED. | 79 // method with PREF_CHANGED. |
| 69 void AddSettingsObserver(const char* path, NotificationObserver* obs); | 80 void AddSettingsObserver(const char* path, NotificationObserver* obs); |
| 70 void RemoveSettingsObserver(const char* path, NotificationObserver* obs); | 81 void RemoveSettingsObserver(const char* path, NotificationObserver* obs); |
| 71 | 82 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 86 CrosSettings(); | 97 CrosSettings(); |
| 87 ~CrosSettings(); | 98 ~CrosSettings(); |
| 88 friend struct base::DefaultLazyInstanceTraits<CrosSettings>; | 99 friend struct base::DefaultLazyInstanceTraits<CrosSettings>; |
| 89 | 100 |
| 90 DISALLOW_COPY_AND_ASSIGN(CrosSettings); | 101 DISALLOW_COPY_AND_ASSIGN(CrosSettings); |
| 91 }; | 102 }; |
| 92 | 103 |
| 93 } // namespace chromeos | 104 } // namespace chromeos |
| 94 | 105 |
| 95 #endif // CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ | 106 #endif // CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ |
| OLD | NEW |