Re-applying reverted changes plus fix. ConfidenceScore now takes flat
[chromium-blink-merge.git] / base / prefs / pref_registry.h
blob896db3ffa62d16f1287c1579ef9105c491665d50
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.
5 #ifndef BASE_PREFS_PREF_REGISTRY_H_
6 #define BASE_PREFS_PREF_REGISTRY_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/prefs/base_prefs_export.h"
10 #include "base/prefs/pref_value_map.h"
12 namespace base {
13 class Value;
16 class DefaultPrefStore;
17 class PrefStore;
19 // Preferences need to be registered with a type and default value
20 // before they are used.
22 // The way you use a PrefRegistry is that you register all required
23 // preferences on it (via one of its subclasses), then pass it as a
24 // construction parameter to PrefService.
26 // Currently, registrations after constructing the PrefService will
27 // also work, but this is being deprecated.
28 class BASE_PREFS_EXPORT PrefRegistry : public base::RefCounted<PrefRegistry> {
29 public:
30 typedef PrefValueMap::const_iterator const_iterator;
32 PrefRegistry();
34 // Gets the registered defaults.
35 scoped_refptr<PrefStore> defaults();
37 // Allows iteration over defaults.
38 const_iterator begin() const;
39 const_iterator end() const;
41 // Changes the default value for a preference. Takes ownership of |value|.
43 // |pref_name| must be a previously registered preference.
44 void SetDefaultPrefValue(const char* pref_name, base::Value* value);
46 protected:
47 friend class base::RefCounted<PrefRegistry>;
48 virtual ~PrefRegistry();
50 // Used by subclasses to register a default value for a preference.
51 void RegisterPreference(const char* path, base::Value* default_value);
53 scoped_refptr<DefaultPrefStore> defaults_;
55 private:
56 DISALLOW_COPY_AND_ASSIGN(PrefRegistry);
59 #endif // BASE_PREFS_PREF_REGISTRY_H_