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: chrome/browser/pref_service.h

Issue 3051001: Adjust preference sync code to only sync user modifiable preferences. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: separate out the download_manager_unittest.cc fixes Created 10 years, 5 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
« no previous file with comments | « chrome/browser/pref_member_unittest.cc ('k') | chrome/browser/pref_service.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 provides a way to access the application's current preferences. 5 // This provides a way to access the application's current preferences.
6 6
7 #ifndef CHROME_BROWSER_PREF_SERVICE_H_ 7 #ifndef CHROME_BROWSER_PREF_SERVICE_H_
8 #define CHROME_BROWSER_PREF_SERVICE_H_ 8 #define CHROME_BROWSER_PREF_SERVICE_H_
9 9
10 #include <set> 10 #include <set>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 bool HasUserSetting() const; 66 bool HasUserSetting() const;
67 67
68 // Returns true if the Preference value is currently being controlled by an 68 // Returns true if the Preference value is currently being controlled by an
69 // extension, and not by any higher-priority source. 69 // extension, and not by any higher-priority source.
70 bool IsExtensionControlled() const; 70 bool IsExtensionControlled() const;
71 71
72 // Returns true if the Preference value is currently being controlled by a 72 // Returns true if the Preference value is currently being controlled by a
73 // user setting, and not by any higher-priority source. 73 // user setting, and not by any higher-priority source.
74 bool IsUserControlled() const; 74 bool IsUserControlled() const;
75 75
76 // Returns true if the user can change the Preference value, which is the
77 // case if no higher-priority source than the user store controls the
78 // Preference.
79 bool IsUserModifiable() const;
80
76 private: 81 private:
77 friend class PrefService; 82 friend class PrefService;
78 83
79 Value::ValueType type_; 84 Value::ValueType type_;
80 std::wstring name_; 85 std::wstring name_;
81 scoped_ptr<Value> default_value_; 86 scoped_ptr<Value> default_value_;
82 87
83 // A reference to the pref service's pref_value_store_. 88 // A reference to the pref service's pref_value_store_.
84 PrefValueStore* pref_value_store_; 89 PrefValueStore* pref_value_store_;
85 90
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 219
215 // For the given pref_name, fire any observer of the pref only if |old_value| 220 // For the given pref_name, fire any observer of the pref only if |old_value|
216 // is different from the current value. Virtual so it can be mocked for a 221 // is different from the current value. Virtual so it can be mocked for a
217 // unit test. 222 // unit test.
218 virtual void FireObserversIfChanged(const wchar_t* pref_name, 223 virtual void FireObserversIfChanged(const wchar_t* pref_name,
219 const Value* old_value); 224 const Value* old_value);
220 225
221 bool read_only() const { return pref_value_store_->ReadOnly(); } 226 bool read_only() const { return pref_value_store_->ReadOnly(); }
222 227
223 protected: 228 protected:
229 // For the given pref_name, fire any observer of the pref.
230 void FireObservers(const wchar_t* pref_name);
231
224 // This should only be accessed by subclasses for unit-testing. 232 // This should only be accessed by subclasses for unit-testing.
225 bool PrefIsChanged(const wchar_t* path, const Value* old_value); 233 bool PrefIsChanged(const wchar_t* path, const Value* old_value);
226 234
227 private: 235 private:
228 // Add a preference to the PreferenceMap. If the pref already exists, return 236 // Add a preference to the PreferenceMap. If the pref already exists, return
229 // false. This method takes ownership of |pref|. 237 // false. This method takes ownership of |pref|.
230 void RegisterPreference(Preference* pref); 238 void RegisterPreference(Preference* pref);
231 239
232 // Returns a copy of the current pref value. The caller is responsible for 240 // Returns a copy of the current pref value. The caller is responsible for
233 // deleting the returned object. 241 // deleting the returned object.
234 Value* GetPrefCopy(const wchar_t* pref_name); 242 Value* GetPrefCopy(const wchar_t* pref_name);
235 243
236 // For the given pref_name, fire any observer of the pref.
237 void FireObservers(const wchar_t* pref_name);
238
239 // Load from disk. Returns a non-zero error code on failure. 244 // Load from disk. Returns a non-zero error code on failure.
240 PrefStore::PrefReadError LoadPersistentPrefs(); 245 PrefStore::PrefReadError LoadPersistentPrefs();
241 246
242 // Load preferences from storage, attempting to diagnose and handle errors. 247 // Load preferences from storage, attempting to diagnose and handle errors.
243 // This should only be called from the constructor. 248 // This should only be called from the constructor.
244 void InitFromStorage(); 249 void InitFromStorage();
245 250
246 // The value of a Preference can be: 251 // The value of a Preference can be:
247 // managed, user defined, recommended or default. 252 // managed, user defined, recommended or default.
248 // The PrefValueStore manages enforced, user defined and recommended values 253 // The PrefValueStore manages enforced, user defined and recommended values
(...skipping 11 matching lines...) Expand all
260 typedef base::hash_map<std::wstring, NotificationObserverList*> 265 typedef base::hash_map<std::wstring, NotificationObserverList*>
261 PrefObserverMap; 266 PrefObserverMap;
262 PrefObserverMap pref_observers_; 267 PrefObserverMap pref_observers_;
263 268
264 friend class ScopedPrefUpdate; 269 friend class ScopedPrefUpdate;
265 270
266 DISALLOW_COPY_AND_ASSIGN(PrefService); 271 DISALLOW_COPY_AND_ASSIGN(PrefService);
267 }; 272 };
268 273
269 #endif // CHROME_BROWSER_PREF_SERVICE_H_ 274 #endif // CHROME_BROWSER_PREF_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/pref_member_unittest.cc ('k') | chrome/browser/pref_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698