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 BASE_PREFS_PREF_VALUE_STORE_H_ | 5 #ifndef BASE_PREFS_PREF_VALUE_STORE_H_ |
6 #define BASE_PREFS_PREF_VALUE_STORE_H_ | 6 #define BASE_PREFS_PREF_VALUE_STORE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // certain changes (e.g. unregistered prefs). | 68 // certain changes (e.g. unregistered prefs). |
69 void set_callback(const PrefChangedCallback& callback); | 69 void set_callback(const PrefChangedCallback& callback); |
70 | 70 |
71 // Gets the value for the given preference name that has the specified value | 71 // Gets the value for the given preference name that has the specified value |
72 // type. Values stored in a PrefStore that have the matching |name| but | 72 // type. Values stored in a PrefStore that have the matching |name| but |
73 // a non-matching |type| are silently skipped. Returns true if a valid value | 73 // a non-matching |type| are silently skipped. Returns true if a valid value |
74 // was found in any of the available PrefStores. Most callers should use | 74 // was found in any of the available PrefStores. Most callers should use |
75 // Preference::GetValue() instead of calling this method directly. | 75 // Preference::GetValue() instead of calling this method directly. |
76 bool GetValue(const std::string& name, | 76 bool GetValue(const std::string& name, |
77 base::Value::Type type, | 77 base::Value::Type type, |
78 const Value** out_value) const; | 78 const base::Value** out_value) const; |
79 | 79 |
80 // Gets the recommended value for the given preference name that has the | 80 // Gets the recommended value for the given preference name that has the |
81 // specified value type. A value stored in the recommended PrefStore that has | 81 // specified value type. A value stored in the recommended PrefStore that has |
82 // the matching |name| but a non-matching |type| is silently ignored. Returns | 82 // the matching |name| but a non-matching |type| is silently ignored. Returns |
83 // true if a valid value was found. Most callers should use | 83 // true if a valid value was found. Most callers should use |
84 // Preference::GetRecommendedValue() instead of calling this method directly. | 84 // Preference::GetRecommendedValue() instead of calling this method directly. |
85 bool GetRecommendedValue(const std::string& name, | 85 bool GetRecommendedValue(const std::string& name, |
86 base::Value::Type type, | 86 base::Value::Type type, |
87 const Value** out_value) const; | 87 const base::Value** out_value) const; |
88 | 88 |
89 // These methods return true if a preference with the given name is in the | 89 // These methods return true if a preference with the given name is in the |
90 // indicated pref store, even if that value is currently being overridden by | 90 // indicated pref store, even if that value is currently being overridden by |
91 // a higher-priority source. | 91 // a higher-priority source. |
92 bool PrefValueInManagedStore(const char* name) const; | 92 bool PrefValueInManagedStore(const char* name) const; |
93 bool PrefValueInExtensionStore(const char* name) const; | 93 bool PrefValueInExtensionStore(const char* name) const; |
94 bool PrefValueInUserStore(const char* name) const; | 94 bool PrefValueInUserStore(const char* name) const; |
95 | 95 |
96 // These methods return true if a preference with the given name is actually | 96 // These methods return true if a preference with the given name is actually |
97 // being controlled by the indicated pref store and not being overridden by | 97 // being controlled by the indicated pref store and not being overridden by |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // Returns the pref store type identifying the source that controls the | 194 // Returns the pref store type identifying the source that controls the |
195 // Preference identified by |name|. If none of the sources has a value, | 195 // Preference identified by |name|. If none of the sources has a value, |
196 // INVALID_STORE is returned. In practice, the default PrefStore | 196 // INVALID_STORE is returned. In practice, the default PrefStore |
197 // should always have a value for any registered preferencem, so INVALID_STORE | 197 // should always have a value for any registered preferencem, so INVALID_STORE |
198 // indicates an error. | 198 // indicates an error. |
199 PrefStoreType ControllingPrefStoreForPref(const char* name) const; | 199 PrefStoreType ControllingPrefStoreForPref(const char* name) const; |
200 | 200 |
201 // Get a value from the specified |store|. | 201 // Get a value from the specified |store|. |
202 bool GetValueFromStore(const char* name, | 202 bool GetValueFromStore(const char* name, |
203 PrefStoreType store, | 203 PrefStoreType store, |
204 const Value** out_value) const; | 204 const base::Value** out_value) const; |
205 | 205 |
206 // Get a value from the specified |store| if its |type| matches. | 206 // Get a value from the specified |store| if its |type| matches. |
207 bool GetValueFromStoreWithType(const char* name, | 207 bool GetValueFromStoreWithType(const char* name, |
208 base::Value::Type type, | 208 base::Value::Type type, |
209 PrefStoreType store, | 209 PrefStoreType store, |
210 const Value** out_value) const; | 210 const base::Value** out_value) const; |
211 | 211 |
212 // Called upon changes in individual pref stores in order to determine whether | 212 // Called upon changes in individual pref stores in order to determine whether |
213 // the user-visible pref value has changed. Triggers the change notification | 213 // the user-visible pref value has changed. Triggers the change notification |
214 // if the effective value of the preference has changed, or if the store | 214 // if the effective value of the preference has changed, or if the store |
215 // controlling the pref has changed. | 215 // controlling the pref has changed. |
216 void NotifyPrefChanged(const char* path, PrefStoreType new_store); | 216 void NotifyPrefChanged(const char* path, PrefStoreType new_store); |
217 | 217 |
218 // Called from the PrefStoreKeeper implementation when a pref value for |key| | 218 // Called from the PrefStoreKeeper implementation when a pref value for |key| |
219 // changed in the pref store for |type|. | 219 // changed in the pref store for |type|. |
220 void OnPrefValueChanged(PrefStoreType type, const std::string& key); | 220 void OnPrefValueChanged(PrefStoreType type, const std::string& key); |
(...skipping 30 matching lines...) Expand all Loading... |
251 // A mapping of preference names to their registered types. | 251 // A mapping of preference names to their registered types. |
252 PrefTypeMap pref_types_; | 252 PrefTypeMap pref_types_; |
253 | 253 |
254 // True if not all of the PrefStores were initialized successfully. | 254 // True if not all of the PrefStores were initialized successfully. |
255 bool initialization_failed_; | 255 bool initialization_failed_; |
256 | 256 |
257 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); | 257 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); |
258 }; | 258 }; |
259 | 259 |
260 #endif // BASE_PREFS_PREF_VALUE_STORE_H_ | 260 #endif // BASE_PREFS_PREF_VALUE_STORE_H_ |
OLD | NEW |