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

Side by Side Diff: base/prefs/public/pref_service_base.h

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 7 years, 12 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
« no previous file with comments | « base/prefs/public/pref_member_unittest.cc ('k') | chrome/browser/about_flags_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This is the base interface for a preference services that provides 5 // This is the base interface for a preference services that provides
6 // a way to access the application's current preferences. 6 // a way to access the application's current preferences.
7 // 7 //
8 // This base interface assumes all preferences are local. See 8 // This base interface assumes all preferences are local. See
9 // SyncablePrefServiceBase for the interface to a preference service 9 // SyncablePrefServiceBase for the interface to a preference service
10 // that stores preferences that can be synced. 10 // that stores preferences that can be synced.
(...skipping 18 matching lines...) Expand all
29 class FilePath; 29 class FilePath;
30 class PrefObserver; 30 class PrefObserver;
31 31
32 class PrefServiceBase { 32 class PrefServiceBase {
33 public: 33 public:
34 // Retrieves a PrefServiceBase for the given context. 34 // Retrieves a PrefServiceBase for the given context.
35 static PrefServiceBase* FromBrowserContext(content::BrowserContext* context); 35 static PrefServiceBase* FromBrowserContext(content::BrowserContext* context);
36 36
37 virtual ~PrefServiceBase() {} 37 virtual ~PrefServiceBase() {}
38 38
39 // Enum used when registering preferences to determine if it should be synced
40 // or not. This is only used for profile prefs, not local state prefs.
41 // See the Register*Pref methods for profile prefs below.
42 enum PrefSyncStatus {
43 UNSYNCABLE_PREF,
44 SYNCABLE_PREF
45 };
46
47 // Interface to a single preference. 39 // Interface to a single preference.
48 class Preference { 40 class Preference {
49 public: 41 public:
50 virtual ~Preference() {} 42 virtual ~Preference() {}
51 43
52 // Returns the name of the Preference (i.e., the key, e.g., 44 // Returns the name of the Preference (i.e., the key, e.g.,
53 // browser.window_placement). 45 // browser.window_placement).
54 virtual const std::string name() const = 0; 46 virtual const std::string name() const = 0;
55 47
56 // Returns the registered type of the preference. 48 // Returns the registered type of the preference.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 }; 97 };
106 98
107 // Returns true if the preference for the given preference name is available 99 // Returns true if the preference for the given preference name is available
108 // and is managed. 100 // and is managed.
109 virtual bool IsManagedPreference(const char* pref_name) const = 0; 101 virtual bool IsManagedPreference(const char* pref_name) const = 0;
110 102
111 // Returns |true| if a preference with the given name is available and its 103 // Returns |true| if a preference with the given name is available and its
112 // value can be changed by the user. 104 // value can be changed by the user.
113 virtual bool IsUserModifiablePreference(const char* pref_name) const = 0; 105 virtual bool IsUserModifiablePreference(const char* pref_name) const = 0;
114 106
115 // Make the PrefService aware of a pref.
116 // TODO(zea): split local state and profile prefs into their own subclasses.
117 // ---------- Local state prefs ----------
118 virtual void RegisterBooleanPref(const char* path,
119 bool default_value) = 0;
120 virtual void RegisterIntegerPref(const char* path,
121 int default_value) = 0;
122 virtual void RegisterDoublePref(const char* path,
123 double default_value) = 0;
124 virtual void RegisterStringPref(const char* path,
125 const std::string& default_value) = 0;
126 virtual void RegisterFilePathPref(const char* path,
127 const FilePath& default_value) = 0;
128 virtual void RegisterListPref(const char* path) = 0;
129 virtual void RegisterDictionaryPref(const char* path) = 0;
130 // These take ownership of the default_value:
131 virtual void RegisterListPref(const char* path,
132 base::ListValue* default_value) = 0;
133 virtual void RegisterDictionaryPref(
134 const char* path, base::DictionaryValue* default_value) = 0;
135 // These variants use a default value from the locale dll instead.
136 virtual void RegisterLocalizedBooleanPref(
137 const char* path, int locale_default_message_id) = 0;
138 virtual void RegisterLocalizedIntegerPref(
139 const char* path, int locale_default_message_id) = 0;
140 virtual void RegisterLocalizedDoublePref(
141 const char* path, int locale_default_message_id) = 0;
142 virtual void RegisterLocalizedStringPref(
143 const char* path, int locale_default_message_id) = 0;
144 virtual void RegisterInt64Pref(const char* path,
145 int64 default_value) = 0;
146
147 // ---------- Profile prefs ----------
148 // Profile prefs must specify whether the pref should be synchronized across
149 // machines or not (see PrefSyncStatus enum above).
150 virtual void RegisterBooleanPref(const char* path,
151 bool default_value,
152 PrefSyncStatus sync_status) = 0;
153 virtual void RegisterIntegerPref(const char* path,
154 int default_value,
155 PrefSyncStatus sync_status) = 0;
156 virtual void RegisterDoublePref(const char* path,
157 double default_value,
158 PrefSyncStatus sync_status) = 0;
159 virtual void RegisterStringPref(const char* path,
160 const std::string& default_value,
161 PrefSyncStatus sync_status) = 0;
162 virtual void RegisterFilePathPref(const char* path,
163 const FilePath& default_value,
164 PrefSyncStatus sync_status) = 0;
165 virtual void RegisterListPref(const char* path,
166 PrefSyncStatus sync_status) = 0;
167 virtual void RegisterDictionaryPref(const char* path,
168 PrefSyncStatus sync_status) = 0;
169 // These take ownership of the default_value:
170 virtual void RegisterListPref(const char* path,
171 base::ListValue* default_value,
172 PrefSyncStatus sync_status) = 0;
173 virtual void RegisterDictionaryPref(const char* path,
174 base::DictionaryValue* default_value,
175 PrefSyncStatus sync_status) = 0;
176 // These variants use a default value from the locale dll instead.
177 virtual void RegisterLocalizedBooleanPref(
178 const char* path,
179 int locale_default_message_id,
180 PrefSyncStatus sync_status) = 0;
181 virtual void RegisterLocalizedIntegerPref(
182 const char* path,
183 int locale_default_message_id,
184 PrefSyncStatus sync_status) = 0;
185 virtual void RegisterLocalizedDoublePref(
186 const char* path,
187 int locale_default_message_id,
188 PrefSyncStatus sync_status) = 0;
189 virtual void RegisterLocalizedStringPref(
190 const char* path,
191 int locale_default_message_id,
192 PrefSyncStatus sync_status) = 0;
193 virtual void RegisterInt64Pref(const char* path,
194 int64 default_value,
195 PrefSyncStatus sync_status) = 0;
196 virtual void RegisterUint64Pref(const char* path,
197 uint64 default_value,
198 PrefSyncStatus sync_status) = 0;
199 // Unregisters a preference. 107 // Unregisters a preference.
200 virtual void UnregisterPreference(const char* path) = 0; 108 virtual void UnregisterPreference(const char* path) = 0;
201 109
202 // Look up a preference. Returns NULL if the preference is not 110 // Look up a preference. Returns NULL if the preference is not
203 // registered. 111 // registered.
204 virtual const Preference* FindPreference(const char* pref_name) const = 0; 112 virtual const Preference* FindPreference(const char* pref_name) const = 0;
205 113
206 // If the path is valid and the value at the end of the path matches the type 114 // If the path is valid and the value at the end of the path matches the type
207 // specified, it will return the specified value. Otherwise, the default 115 // specified, it will return the specified value. Otherwise, the default
208 // value (set when the pref was registered) will be returned. 116 // value (set when the pref was registered) will be returned.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // 167 //
260 // If the pref at the given path changes, we call the observer's 168 // If the pref at the given path changes, we call the observer's
261 // OnPreferenceChanged method. Note that observers should not call 169 // OnPreferenceChanged method. Note that observers should not call
262 // these methods directly but rather use a PrefChangeRegistrar to 170 // these methods directly but rather use a PrefChangeRegistrar to
263 // make sure the observer gets cleaned up properly. 171 // make sure the observer gets cleaned up properly.
264 virtual void AddPrefObserver(const char* path, PrefObserver* obs) = 0; 172 virtual void AddPrefObserver(const char* path, PrefObserver* obs) = 0;
265 virtual void RemovePrefObserver(const char* path, PrefObserver* obs) = 0; 173 virtual void RemovePrefObserver(const char* path, PrefObserver* obs) = 0;
266 }; 174 };
267 175
268 #endif // BASE_PREFS_PUBLIC_PREF_SERVICE_BASE_H_ 176 #endif // BASE_PREFS_PUBLIC_PREF_SERVICE_BASE_H_
OLDNEW
« no previous file with comments | « base/prefs/public/pref_member_unittest.cc ('k') | chrome/browser/about_flags_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698