OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This provides a way to access the application's current preferences. | 5 // This provides a way to access the application's current preferences. |
6 | 6 |
7 #ifndef CHROME_BROWSER_PREFS_PREF_SERVICE_H_ | 7 #ifndef CHROME_BROWSER_PREFS_PREF_SERVICE_H_ |
8 #define CHROME_BROWSER_PREFS_PREF_SERVICE_H_ | 8 #define CHROME_BROWSER_PREFS_PREF_SERVICE_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // Registration of pref change observers must be done using the | 232 // Registration of pref change observers must be done using the |
233 // PrefChangeRegistrar, which is declared as a friend here to grant it | 233 // PrefChangeRegistrar, which is declared as a friend here to grant it |
234 // access to the otherwise protected members Add/RemovePrefObserver. | 234 // access to the otherwise protected members Add/RemovePrefObserver. |
235 // PrefMember registers for preferences changes notification directly to | 235 // PrefMember registers for preferences changes notification directly to |
236 // avoid the storage overhead of the registrar, so its base class must be | 236 // avoid the storage overhead of the registrar, so its base class must be |
237 // declared as a friend, too. | 237 // declared as a friend, too. |
238 friend class PrefChangeRegistrar; | 238 friend class PrefChangeRegistrar; |
239 friend class subtle::PrefMemberBase; | 239 friend class subtle::PrefMemberBase; |
240 | 240 |
241 // If the pref at the given path changes, we call the observer's Observe | 241 // If the pref at the given path changes, we call the observer's Observe |
242 // method with NOTIFY_PREF_CHANGED. Note that observers should not call | 242 // method with PREF_CHANGED. Note that observers should not call these methods |
243 // these methods directly but rather use a PrefChangeRegistrar to make sure | 243 // directly but rather use a PrefChangeRegistrar to make sure the observer |
244 // the observer gets cleaned up properly. | 244 // gets cleaned up properly. |
245 virtual void AddPrefObserver(const char* path, NotificationObserver* obs); | 245 virtual void AddPrefObserver(const char* path, NotificationObserver* obs); |
246 virtual void RemovePrefObserver(const char* path, NotificationObserver* obs); | 246 virtual void RemovePrefObserver(const char* path, NotificationObserver* obs); |
247 | 247 |
248 // Add a preference to the PreferenceMap. If the pref already exists, return | 248 // Add a preference to the PreferenceMap. If the pref already exists, return |
249 // false. This method takes ownership of |default_value|. | 249 // false. This method takes ownership of |default_value|. |
250 void RegisterPreference(const char* path, Value* default_value); | 250 void RegisterPreference(const char* path, Value* default_value); |
251 | 251 |
252 // Returns a copy of the current pref value. The caller is responsible for | 252 // Returns a copy of the current pref value. The caller is responsible for |
253 // deleting the returned object. | 253 // deleting the returned object. |
254 Value* GetPrefCopy(const char* pref_name); | 254 Value* GetPrefCopy(const char* pref_name); |
(...skipping 13 matching lines...) Expand all Loading... |
268 // and owned by this PrefService. Subclasses may access it for unit testing. | 268 // and owned by this PrefService. Subclasses may access it for unit testing. |
269 scoped_refptr<PrefValueStore> pref_value_store_; | 269 scoped_refptr<PrefValueStore> pref_value_store_; |
270 | 270 |
271 // A set of all the registered Preference objects. | 271 // A set of all the registered Preference objects. |
272 PreferenceSet prefs_; | 272 PreferenceSet prefs_; |
273 | 273 |
274 DISALLOW_COPY_AND_ASSIGN(PrefService); | 274 DISALLOW_COPY_AND_ASSIGN(PrefService); |
275 }; | 275 }; |
276 | 276 |
277 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_ | 277 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_ |
OLD | NEW |