Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: chrome/browser/prefs/pref_registry.h

Issue 12211105: Move remaining non-test, non-Chrome-specific Prefs code to base/prefs/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments, merge to LKGR. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/prefs/pref_value_map.h"
11
12 namespace base {
13 class Value;
14 }
15
16 class DefaultPrefStore;
17 class PrefStore;
18
19 // Preferences need to be registered with a type and default value
20 // before they are used.
21 //
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.
25 //
26 // Currently, registrations after constructing the PrefService will
27 // also work, but this is being deprecated.
28 class PrefRegistry : public base::RefCounted<PrefRegistry> {
29 public:
30 typedef PrefValueMap::const_iterator const_iterator;
31 typedef base::Callback<void(const char*, base::Value*)> RegistrationCallback;
32 typedef base::Callback<void(const char*)> UnregistrationCallback;
33
34 PrefRegistry();
35
36 // Gets the registered defaults.
37 scoped_refptr<PrefStore> defaults();
38
39 // Allows iteration over defaults.
40 const_iterator begin() const;
41 const_iterator end() const;
42
43 // Exactly one callback can be set for each of two events:
44 // Registration and unregistration. If either is set, the callback
45 // will be invoked each time registration and/or unregistration has
46 // been performed on this object.
47 //
48 // Calling either of these methods after a callback has already been
49 // set will make the object forget the previous callback and use the
50 // new one instead.
51 void SetRegistrationCallback(const RegistrationCallback& callback);
52 void SetUnregistrationCallback(const UnregistrationCallback& callback);
53
54 // Unregisters a preference. This is going away soon.
55 void DeprecatedUnregisterPreference(const char* path);
56
57 protected:
58 friend class base::RefCounted<PrefRegistry>;
59 virtual ~PrefRegistry();
60
61 // Used by subclasses to register a default value for a preference.
62 void RegisterPreference(const char* path, base::Value* default_value);
63
64 scoped_refptr<DefaultPrefStore> defaults_;
65
66 private:
67 RegistrationCallback registration_callback_;
68 UnregistrationCallback unregistration_callback_;
69
70 DISALLOW_COPY_AND_ASSIGN(PrefRegistry);
71 };
72
73 #endif // CHROME_BROWSER_PREFS_PREF_REGISTRY_H_
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_notifier_impl_unittest.cc ('k') | chrome/browser/prefs/pref_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698