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_REGISTRY_H_ | 5 #ifndef BASE_PREFS_PREF_REGISTRY_H_ |
6 #define BASE_PREFS_PREF_REGISTRY_H_ | 6 #define BASE_PREFS_PREF_REGISTRY_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/prefs/base_prefs_export.h" | 10 #include "base/prefs/base_prefs_export.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 PrefRegistry(); | 34 PrefRegistry(); |
35 | 35 |
36 // Gets the registered defaults. | 36 // Gets the registered defaults. |
37 scoped_refptr<PrefStore> defaults(); | 37 scoped_refptr<PrefStore> defaults(); |
38 | 38 |
39 // Allows iteration over defaults. | 39 // Allows iteration over defaults. |
40 const_iterator begin() const; | 40 const_iterator begin() const; |
41 const_iterator end() const; | 41 const_iterator end() const; |
42 | 42 |
| 43 // Changes the default value for a preference. Takes ownership of |value|. |
| 44 // |
| 45 // |pref_name| must be a previously registered preference. |
| 46 void SetDefaultPrefValue(const char* pref_name, base::Value* value); |
| 47 |
43 // Exactly one callback can be set for registration. The callback | 48 // Exactly one callback can be set for registration. The callback |
44 // will be invoked each time registration has been performed on this | 49 // will be invoked each time registration has been performed on this |
45 // object. | 50 // object. |
46 // | 51 // |
47 // Calling this method after a callback has already been set will | 52 // Calling this method after a callback has already been set will |
48 // make the object forget the previous callback and use the new one | 53 // make the object forget the previous callback and use the new one |
49 // instead. | 54 // instead. |
50 void SetRegistrationCallback(const RegistrationCallback& callback); | 55 void SetRegistrationCallback(const RegistrationCallback& callback); |
51 | 56 |
52 protected: | 57 protected: |
53 friend class base::RefCounted<PrefRegistry>; | 58 friend class base::RefCounted<PrefRegistry>; |
54 virtual ~PrefRegistry(); | 59 virtual ~PrefRegistry(); |
55 | 60 |
56 // Used by subclasses to register a default value for a preference. | 61 // Used by subclasses to register a default value for a preference. |
57 void RegisterPreference(const char* path, base::Value* default_value); | 62 void RegisterPreference(const char* path, base::Value* default_value); |
58 | 63 |
59 scoped_refptr<DefaultPrefStore> defaults_; | 64 scoped_refptr<DefaultPrefStore> defaults_; |
60 | 65 |
61 private: | 66 private: |
62 RegistrationCallback registration_callback_; | 67 RegistrationCallback registration_callback_; |
63 | 68 |
64 DISALLOW_COPY_AND_ASSIGN(PrefRegistry); | 69 DISALLOW_COPY_AND_ASSIGN(PrefRegistry); |
65 }; | 70 }; |
66 | 71 |
67 #endif // BASE_PREFS_PREF_REGISTRY_H_ | 72 #endif // BASE_PREFS_PREF_REGISTRY_H_ |
OLD | NEW |