Chromium Code Reviews| Index: chrome/browser/prefs/pref_registry.h |
| diff --git a/chrome/browser/prefs/pref_registry.h b/chrome/browser/prefs/pref_registry.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d13e72a993a004c3c13d9cfae5a703fd2ca59e42 |
| --- /dev/null |
| +++ b/chrome/browser/prefs/pref_registry.h |
| @@ -0,0 +1,63 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_PREFS_PREF_REGISTRY_H_ |
| +#define CHROME_BROWSER_PREFS_PREF_REGISTRY_H_ |
| + |
| +#include "base/memory/ref_counted.h" |
| +#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.
|
| +#include "base/prefs/default_pref_store.h" |
| + |
| +namespace base { |
| +class Value; |
| +} |
| + |
| +class PrefService; |
| + |
| +// Preferences need to be registered with a type and default value |
| +// before they are used. |
| +// |
| +// The way you use a PrefRegistry is that you register all required |
| +// preferences on it, then pass it as a construction parameter to |
| +// PrefService. |
| +// |
| +// Currently, registrations after constructing the PrefService will |
| +// also work, but this is being deprecated. |
| +class PrefRegistry { |
| + public: |
| + PrefRegistry(); |
| + |
| + // Only valid after this object has been used to construct a PrefService. |
| + virtual void DeprecatedUnregisterPreference(const char* path); |
| + |
| + protected: |
| + // Interface used by PrefService to retrieve registered default values. This |
| + // is a transfer of ownership; this object loses its reference to the |
| + // default values when this method is called. |
| + 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.
|
| + |
| + // Used by subclasses to register a default value for a preference. |
| + void RegisterPreference(const char* path, base::Value* default_value); |
| + |
| + private: |
| + // This friend and member are needed for registrations after |
| + // construction time, and for DeprecatedUnregisterPreference. |
| + // PrefService sets the pref_service_ member once it receives this |
| + // object at construction time. |
| + friend class PrefService; |
| + PrefService* pref_service_; |
| + |
| + // Friend so that PrefRegistry can be used in place of a PrefStore |
| + // for its default_store construction parameter. |
| + 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.
|
| + |
| + // TODO(joi): Temporary until we have a PrefRegistrySyncable. |
| + friend class PrefServiceSyncable; |
| + |
| + scoped_refptr<DefaultPrefStore> default_prefs_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PrefRegistry); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_PREFS_PREF_REGISTRY_H_ |