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

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

Issue 7838030: WIP: Introduce per-TabContents PrefService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_PREFS_PREF_SERVICE_H_ 7 #ifndef CHROME_BROWSER_PREFS_PREF_SERVICE_H_
8 #define CHROME_BROWSER_PREFS_PREF_SERVICE_H_ 8 #define CHROME_BROWSER_PREFS_PREF_SERVICE_H_
9 #pragma once 9 #pragma once
10 10
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 static PrefService* CreatePrefService(const FilePath& pref_filename, 136 static PrefService* CreatePrefService(const FilePath& pref_filename,
137 PrefStore* extension_pref_store, 137 PrefStore* extension_pref_store,
138 bool async); 138 bool async);
139 139
140 // Creates an incognito copy of the pref service that shares most pref stores 140 // Creates an incognito copy of the pref service that shares most pref stores
141 // but uses a fresh non-persistent overlay for the user pref store and an 141 // but uses a fresh non-persistent overlay for the user pref store and an
142 // individual extension pref store (to cache the effective extension prefs for 142 // individual extension pref store (to cache the effective extension prefs for
143 // incognito windows). 143 // incognito windows).
144 PrefService* CreateIncognitoPrefService(PrefStore* incognito_extension_prefs); 144 PrefService* CreateIncognitoPrefService(PrefStore* incognito_extension_prefs);
145 145
146 // Creates a per-TabContents pref service derived from this PrefService. The
147 // new PrefService will share all PrefStores with the base PrefService, except
148 // for user prefs. Also, it manages a separate set of registered prefs.
149 PrefService* CreateTabContentsPrefService();
150
146 virtual ~PrefService(); 151 virtual ~PrefService();
147 152
148 // Reloads the data from file. This should only be called when the importer 153 // Reloads the data from file. This should only be called when the importer
149 // is running during first run, and the main process may not change pref 154 // is running during first run, and the main process may not change pref
150 // values while the importer process is running. Returns true on success. 155 // values while the importer process is running. Returns true on success.
151 bool ReloadPersistentPrefs(); 156 bool ReloadPersistentPrefs();
152 157
153 // Returns true if the preference for the given preference name is available 158 // Returns true if the preference for the given preference name is available
154 // and is managed. 159 // and is managed.
155 bool IsManagedPreference(const char* pref_name) const; 160 bool IsManagedPreference(const char* pref_name) const;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 // preference is not registered. 292 // preference is not registered.
288 const Preference* FindPreference(const char* pref_name) const; 293 const Preference* FindPreference(const char* pref_name) const;
289 294
290 bool ReadOnly() const; 295 bool ReadOnly() const;
291 296
292 // SyncableService getter. 297 // SyncableService getter.
293 // TODO(zea): Have PrefService implement SyncableService directly. 298 // TODO(zea): Have PrefService implement SyncableService directly.
294 SyncableService* GetSyncableService(); 299 SyncableService* GetSyncableService();
295 300
296 protected: 301 protected:
297 // Construct a new pref service, specifying the pref sources as explicit 302 // Construct a new pref service. This constructor is what CreatePrefService()
298 // PrefStore pointers. This constructor is what CreatePrefService() ends up 303 // ends up calling. It's also used for unit tests.
299 // calling. It's also used for unit tests. 304 PrefService(PrefValueStore* pref_value_store,
300 PrefService(PrefStore* managed_platform_prefs,
301 PrefStore* managed_cloud_prefs,
302 PrefStore* extension_prefs,
303 PrefStore* command_line_prefs,
304 PersistentPrefStore* user_prefs, 305 PersistentPrefStore* user_prefs,
305 PrefStore* recommended_platform_prefs,
306 PrefStore* recommended_cloud_prefs,
307 DefaultPrefStore* default_store, 306 DefaultPrefStore* default_store,
307 PrefNotifierImpl* pref_notifier,
308 bool async); 308 bool async);
309 309
310 // The PrefNotifier handles registering and notifying preference observers. 310 // The PrefNotifier handles registering and notifying preference observers.
311 // It is created and owned by this PrefService. Subclasses may access it for 311 // It is created and owned by this PrefService. Subclasses may access it for
312 // unit testing. 312 // unit testing.
313 scoped_ptr<PrefNotifierImpl> pref_notifier_; 313 scoped_ptr<PrefNotifierImpl> pref_notifier_;
314 314
315 private: 315 private:
316 class PreferencePathComparator { 316 class PreferencePathComparator {
317 public: 317 public:
(...skipping 10 matching lines...) Expand all
328 // access to the otherwise protected members Add/RemovePrefObserver. 328 // access to the otherwise protected members Add/RemovePrefObserver.
329 // PrefMember registers for preferences changes notification directly to 329 // PrefMember registers for preferences changes notification directly to
330 // avoid the storage overhead of the registrar, so its base class must be 330 // avoid the storage overhead of the registrar, so its base class must be
331 // declared as a friend, too. 331 // declared as a friend, too.
332 friend class PrefChangeRegistrar; 332 friend class PrefChangeRegistrar;
333 friend class subtle::PrefMemberBase; 333 friend class subtle::PrefMemberBase;
334 334
335 // Give access to ReportUserPrefChanged() and GetMutableUserPref(). 335 // Give access to ReportUserPrefChanged() and GetMutableUserPref().
336 friend class subtle::ScopedUserPrefUpdateBase; 336 friend class subtle::ScopedUserPrefUpdateBase;
337 337
338 // Construct an incognito version of the pref service. Use
339 // CreateIncognitoPrefService() instead of calling this constructor directly.
340 PrefService(const PrefService& original,
341 PrefStore* incognito_extension_prefs);
342
343 // Sends notification of a changed preference. This needs to be called by 338 // Sends notification of a changed preference. This needs to be called by
344 // a ScopedUserPrefUpdate if a DictionaryValue or ListValue is changed. 339 // a ScopedUserPrefUpdate if a DictionaryValue or ListValue is changed.
345 void ReportUserPrefChanged(const std::string& key); 340 void ReportUserPrefChanged(const std::string& key);
346 341
347 // If the pref at the given path changes, we call the observer's Observe 342 // If the pref at the given path changes, we call the observer's Observe
348 // method with PREF_CHANGED. Note that observers should not call these methods 343 // method with PREF_CHANGED. Note that observers should not call these methods
349 // directly but rather use a PrefChangeRegistrar to make sure the observer 344 // directly but rather use a PrefChangeRegistrar to make sure the observer
350 // gets cleaned up properly. 345 // gets cleaned up properly.
351 virtual void AddPrefObserver(const char* path, NotificationObserver* obs); 346 virtual void AddPrefObserver(const char* path, NotificationObserver* obs);
352 virtual void RemovePrefObserver(const char* path, NotificationObserver* obs); 347 virtual void RemovePrefObserver(const char* path, NotificationObserver* obs);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // of registered preferences are. 385 // of registered preferences are.
391 mutable PreferenceSet prefs_; 386 mutable PreferenceSet prefs_;
392 387
393 // The model associator that maintains the links with the sync db. 388 // The model associator that maintains the links with the sync db.
394 scoped_ptr<PrefModelAssociator> pref_sync_associator_; 389 scoped_ptr<PrefModelAssociator> pref_sync_associator_;
395 390
396 DISALLOW_COPY_AND_ASSIGN(PrefService); 391 DISALLOW_COPY_AND_ASSIGN(PrefService);
397 }; 392 };
398 393
399 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_ 394 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698