Index: chrome/browser/prefs/pref_service.h |
diff --git a/chrome/browser/prefs/pref_service.h b/chrome/browser/prefs/pref_service.h |
index ff57a72d6bccf928ac2da3e2567f37e67db8a0a1..92d7f402d11de21a4e4982b75d00a83ad4b76e32 100644 |
--- a/chrome/browser/prefs/pref_service.h |
+++ b/chrome/browser/prefs/pref_service.h |
@@ -15,9 +15,9 @@ |
#include <string> |
#include "base/callback.h" |
+#include "base/hash_tables.h" |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
-#include "base/hash_tables.h" |
#include "base/observer_list.h" |
#include "base/prefs/persistent_pref_store.h" |
#include "base/prefs/public/pref_service_base.h" |
@@ -27,6 +27,7 @@ class DefaultPrefStore; |
class PrefNotifier; |
class PrefNotifierImpl; |
class PrefObserver; |
+class PrefRegistry; |
class PrefStore; |
class PrefValueStore; |
@@ -36,7 +37,7 @@ class ScopedUserPrefUpdateBase; |
// Base class for PrefServices. You can use the base class to read and |
// interact with preferences, but not to register new preferences; for |
-// that see subclasses like PrefServiceSimple. |
+// that see e.g. PrefRegistrySimple. |
class PrefService : public PrefServiceBase, public base::NonThreadSafe { |
public: |
enum PrefInitializationStatus { |
@@ -94,7 +95,7 @@ class PrefService : public PrefServiceBase, public base::NonThreadSafe { |
PrefNotifierImpl* pref_notifier, |
PrefValueStore* pref_value_store, |
PersistentPrefStore* user_prefs, |
- DefaultPrefStore* default_store, |
+ scoped_ptr<PrefRegistry> pref_registry, |
base::Callback<void(PersistentPrefStore::PrefReadError)> |
read_error_callback, |
bool async); |
@@ -112,7 +113,6 @@ class PrefService : public PrefServiceBase, public base::NonThreadSafe { |
// PrefServiceBase implementation. |
virtual bool IsManagedPreference(const char* pref_name) const OVERRIDE; |
virtual bool IsUserModifiablePreference(const char* pref_name) const OVERRIDE; |
- virtual void UnregisterPreference(const char* path) OVERRIDE; |
virtual const PrefService::Preference* FindPreference( |
const char* path) const OVERRIDE; |
virtual bool GetBoolean(const char* path) const OVERRIDE; |
@@ -166,12 +166,36 @@ class PrefService : public PrefServiceBase, public base::NonThreadSafe { |
// false for unsuccessful. |
void AddPrefInitObserver(base::Callback<void(bool)> callback); |
+ // Returns the PrefRegistry object for this service. You should not |
+ // use this; the intent is for no registrations to take place after |
+ // PrefService has been constructed. |
+ PrefRegistry* DeprecatedGetPrefRegistry() const; |
Mattias Nissler (ping if slow)
2013/01/25 14:57:11
Does this have to be const? The caller can change
Jói
2013/01/29 16:10:02
Done.
|
+ |
protected: |
+ friend class PrefRegistry; |
+ |
+ // Registers the preferences from the PrefRegistry instance passed |
+ // to us at construction time. |
+ void RegisterInitialPreferences(); |
+ |
// Registers a new preference at |path|. The |default_value| must not be |
// NULL as it determines the preference value's type. |
// RegisterPreference must not be called twice for the same path. |
- // This method takes ownership of |default_value|. |
- void RegisterPreference(const char* path, base::Value* default_value); |
+ // |
+ // If |in_default_store| is true, the preference must already |
+ // exist in default_store_. If not, it is added to default_store_. |
+ void RegisterPreference(const char* path, |
+ base::Value* default_value, |
+ bool in_default_store); |
+ |
+ void UnregisterPreference(const char* path); |
+ |
+ // Subclasses should override this to return false if they do not |
+ // wish to allow PrefRegistrySimple to be used to register |
+ // preferences on this object, e.g. if they wish to ensure more |
+ // parameters are given for each registration than |
+ // PrefRegistrySimple takes. |
+ virtual bool AllowPrefRegistrarSimple() const; |
Mattias Nissler (ping if slow)
2013/01/25 14:57:11
Why would we need that? Subclasses that need more
Jói
2013/01/29 16:10:02
Gone.
|
// The PrefNotifier handles registering and notifying preference observers. |
// It is created and owned by this PrefService. Subclasses may access it for |
@@ -196,9 +220,6 @@ class PrefService : public PrefServiceBase, public base::NonThreadSafe { |
// vs. std::map, and by roughly 180ms vs. std::set of Preference pointers. |
typedef base::hash_map<std::string, Preference> PreferenceMap; |
- // Give access to Initialize(). |
- friend class PrefServiceBuilder; |
- |
// Give access to ReportUserPrefChanged() and GetMutableUserPref(). |
friend class subtle::ScopedUserPrefUpdateBase; |
@@ -242,13 +263,14 @@ class PrefService : public PrefServiceBase, public base::NonThreadSafe { |
// of registered preferences are. |
mutable PreferenceMap prefs_map_; |
+ scoped_ptr<PrefRegistry> pref_registry_; |
+ |
DISALLOW_COPY_AND_ASSIGN(PrefService); |
}; |
// TODO(joi): Remove these forwards. They were placed here temporarily |
// to limit the size of the initial change that split |
// PrefServiceSimple and PrefServiceSyncable out of PrefService. |
-#include "chrome/browser/prefs/pref_service_simple.h" |
#include "chrome/browser/prefs/pref_service_syncable.h" |
#endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_ |