Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: chrome/browser/prefs/pref_value_store.h

Issue 10821047: Provide access to recommended pref values (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits addressed. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/prefs/pref_service_unittest.cc ('k') | chrome/browser/prefs/pref_value_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_PREFS_PREF_VALUE_STORE_H_ 5 #ifndef CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_
6 #define CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ 6 #define CHROME_BROWSER_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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 // Gets the value for the given preference name that has the specified value 65 // Gets the value for the given preference name that has the specified value
66 // type. Values stored in a PrefStore that have the matching |name| but 66 // type. Values stored in a PrefStore that have the matching |name| but
67 // a non-matching |type| are silently skipped. Returns true if a valid value 67 // a non-matching |type| are silently skipped. Returns true if a valid value
68 // was found in any of the available PrefStores. Most callers should use 68 // was found in any of the available PrefStores. Most callers should use
69 // Preference::GetValue() instead of calling this method directly. 69 // Preference::GetValue() instead of calling this method directly.
70 bool GetValue(const std::string& name, 70 bool GetValue(const std::string& name,
71 base::Value::Type type, 71 base::Value::Type type,
72 const Value** out_value) const; 72 const Value** out_value) const;
73 73
74 // Gets the recommended value for the given preference name that has the
75 // specified value type. A value stored in the recommended PrefStore that has
76 // the matching |name| but a non-matching |type| is silently ignored. Returns
77 // true if a valid value was found. Most callers should use
78 // Preference::GetRecommendedValue() instead of calling this method directly.
79 bool GetRecommendedValue(const std::string& name,
80 base::Value::Type type,
81 const Value** out_value) const;
82
74 // These methods return true if a preference with the given name is in the 83 // These methods return true if a preference with the given name is in the
75 // indicated pref store, even if that value is currently being overridden by 84 // indicated pref store, even if that value is currently being overridden by
76 // a higher-priority source. 85 // a higher-priority source.
77 bool PrefValueInManagedStore(const char* name) const; 86 bool PrefValueInManagedStore(const char* name) const;
78 bool PrefValueInExtensionStore(const char* name) const; 87 bool PrefValueInExtensionStore(const char* name) const;
79 bool PrefValueInUserStore(const char* name) const; 88 bool PrefValueInUserStore(const char* name) const;
80 89
81 // These methods return true if a preference with the given name is actually 90 // These methods return true if a preference with the given name is actually
82 // being controlled by the indicated pref store and not being overridden by 91 // being controlled by the indicated pref store and not being overridden by
83 // a higher-priority source. 92 // a higher-priority source.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 PrefStoreType first_checked_store, 185 PrefStoreType first_checked_store,
177 PrefStoreType last_checked_store) const; 186 PrefStoreType last_checked_store) const;
178 187
179 // Returns the pref store type identifying the source that controls the 188 // Returns the pref store type identifying the source that controls the
180 // Preference identified by |name|. If none of the sources has a value, 189 // Preference identified by |name|. If none of the sources has a value,
181 // INVALID_STORE is returned. In practice, the default PrefStore 190 // INVALID_STORE is returned. In practice, the default PrefStore
182 // should always have a value for any registered preferencem, so INVALID_STORE 191 // should always have a value for any registered preferencem, so INVALID_STORE
183 // indicates an error. 192 // indicates an error.
184 PrefStoreType ControllingPrefStoreForPref(const char* name) const; 193 PrefStoreType ControllingPrefStoreForPref(const char* name) const;
185 194
186 // Get a value from the specified store type. 195 // Get a value from the specified |store|.
187 bool GetValueFromStore(const char* name, 196 bool GetValueFromStore(const char* name,
188 PrefStoreType store, 197 PrefStoreType store,
189 const Value** out_value) const; 198 const Value** out_value) const;
190 199
200 // Get a value from the specified |store| if its |type| matches.
201 bool GetValueFromStoreWithType(const char* name,
202 base::Value::Type type,
203 PrefStoreType store,
204 const Value** out_value) const;
205
191 // Called upon changes in individual pref stores in order to determine whether 206 // Called upon changes in individual pref stores in order to determine whether
192 // the user-visible pref value has changed. Triggers the change notification 207 // the user-visible pref value has changed. Triggers the change notification
193 // if the effective value of the preference has changed, or if the store 208 // if the effective value of the preference has changed, or if the store
194 // controlling the pref has changed. 209 // controlling the pref has changed.
195 void NotifyPrefChanged(const char* path, PrefStoreType new_store); 210 void NotifyPrefChanged(const char* path, PrefStoreType new_store);
196 211
197 // Called from the PrefStoreKeeper implementation when a pref value for |key| 212 // Called from the PrefStoreKeeper implementation when a pref value for |key|
198 // changed in the pref store for |type|. 213 // changed in the pref store for |type|.
199 void OnPrefValueChanged(PrefStoreType type, const std::string& key); 214 void OnPrefValueChanged(PrefStoreType type, const std::string& key);
200 215
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // A mapping of preference names to their registered types. 247 // A mapping of preference names to their registered types.
233 PrefTypeMap pref_types_; 248 PrefTypeMap pref_types_;
234 249
235 // True if not all of the PrefStores were initialized successfully. 250 // True if not all of the PrefStores were initialized successfully.
236 bool initialization_failed_; 251 bool initialization_failed_;
237 252
238 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); 253 DISALLOW_COPY_AND_ASSIGN(PrefValueStore);
239 }; 254 };
240 255
241 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ 256 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_service_unittest.cc ('k') | chrome/browser/prefs/pref_value_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698