Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_PREFS_PREF_REGISTRY_H_ | |
| 6 #define CHROME_BROWSER_PREFS_PREF_REGISTRY_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "base/memory/ref_counted.h" | |
|
Mattias Nissler (ping if slow)
2013/01/25 14:57:11
once is enough ;)
Jói
2013/01/29 16:10:02
Done.
| |
| 10 #include "base/prefs/default_pref_store.h" | |
| 11 | |
| 12 namespace base { | |
| 13 class Value; | |
| 14 } | |
| 15 | |
| 16 class PrefService; | |
| 17 | |
| 18 // Preferences need to be registered with a type and default value | |
| 19 // before they are used. | |
| 20 // | |
| 21 // The way you use a PrefRegistry is that you register all required | |
| 22 // preferences on it, then pass it as a construction parameter to | |
| 23 // PrefService. | |
| 24 // | |
| 25 // Currently, registrations after constructing the PrefService will | |
| 26 // also work, but this is being deprecated. | |
| 27 class PrefRegistry { | |
| 28 public: | |
| 29 PrefRegistry(); | |
| 30 | |
| 31 // Only valid after this object has been used to construct a PrefService. | |
| 32 virtual void DeprecatedUnregisterPreference(const char* path); | |
| 33 | |
| 34 protected: | |
| 35 // Interface used by PrefService to retrieve registered default values. This | |
| 36 // is a transfer of ownership; this object loses its reference to the | |
| 37 // default values when this method is called. | |
| 38 void RetrieveDefaults(scoped_refptr<DefaultPrefStore>* result); | |
|
Mattias Nissler (ping if slow)
2013/01/25 14:57:11
I'd make this public with the eventual goal of rem
Jói
2013/01/29 16:10:02
Done.
| |
| 39 | |
| 40 // Used by subclasses to register a default value for a preference. | |
| 41 void RegisterPreference(const char* path, base::Value* default_value); | |
| 42 | |
| 43 private: | |
| 44 // This friend and member are needed for registrations after | |
| 45 // construction time, and for DeprecatedUnregisterPreference. | |
| 46 // PrefService sets the pref_service_ member once it receives this | |
| 47 // object at construction time. | |
| 48 friend class PrefService; | |
| 49 PrefService* pref_service_; | |
| 50 | |
| 51 // Friend so that PrefRegistry can be used in place of a PrefStore | |
| 52 // for its default_store construction parameter. | |
| 53 friend class PrefValueStore; | |
|
Mattias Nissler (ping if slow)
2013/01/25 14:57:11
I don't understand this comment, why can a PrefReg
Jói
2013/01/29 16:10:02
This bit of ugliness is gone.
| |
| 54 | |
| 55 // TODO(joi): Temporary until we have a PrefRegistrySyncable. | |
| 56 friend class PrefServiceSyncable; | |
| 57 | |
| 58 scoped_refptr<DefaultPrefStore> default_prefs_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(PrefRegistry); | |
| 61 }; | |
| 62 | |
| 63 #endif // CHROME_BROWSER_PREFS_PREF_REGISTRY_H_ | |
| OLD | NEW |