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

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

Issue 8568019: Introduce per-tab preferences service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 static PrefService* CreatePrefService(const FilePath& pref_filename, 139 static PrefService* CreatePrefService(const FilePath& pref_filename,
140 PrefStore* extension_pref_store, 140 PrefStore* extension_pref_store,
141 bool async); 141 bool async);
142 142
143 // Creates an incognito copy of the pref service that shares most pref stores 143 // Creates an incognito copy of the pref service that shares most pref stores
144 // but uses a fresh non-persistent overlay for the user pref store and an 144 // but uses a fresh non-persistent overlay for the user pref store and an
145 // individual extension pref store (to cache the effective extension prefs for 145 // individual extension pref store (to cache the effective extension prefs for
146 // incognito windows). 146 // incognito windows).
147 PrefService* CreateIncognitoPrefService(PrefStore* incognito_extension_prefs); 147 PrefService* CreateIncognitoPrefService(PrefStore* incognito_extension_prefs);
148 148
149 // Creates a per-tab copy of the pref service that shares most pref stores
150 // and allows WebKit-related preferences to be overridden on per-tab basis.
151 PrefService* CreatePrefServiceWithPerTabPrefStore();
152
149 virtual ~PrefService(); 153 virtual ~PrefService();
150 154
151 // Reloads the data from file. This should only be called when the importer 155 // Reloads the data from file. This should only be called when the importer
152 // is running during first run, and the main process may not change pref 156 // is running during first run, and the main process may not change pref
153 // values while the importer process is running. Returns true on success. 157 // values while the importer process is running. Returns true on success.
154 bool ReloadPersistentPrefs(); 158 bool ReloadPersistentPrefs();
155 159
156 // Returns true if the preference for the given preference name is available 160 // Returns true if the preference for the given preference name is available
157 // and is managed. 161 // and is managed.
158 bool IsManagedPreference(const char* pref_name) const; 162 bool IsManagedPreference(const char* pref_name) const;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 // preference is not registered. 294 // preference is not registered.
291 const Preference* FindPreference(const char* pref_name) const; 295 const Preference* FindPreference(const char* pref_name) const;
292 296
293 bool ReadOnly() const; 297 bool ReadOnly() const;
294 298
295 // SyncableService getter. 299 // SyncableService getter.
296 // TODO(zea): Have PrefService implement SyncableService directly. 300 // TODO(zea): Have PrefService implement SyncableService directly.
297 SyncableService* GetSyncableService(); 301 SyncableService* GetSyncableService();
298 302
299 protected: 303 protected:
300 // Construct a new pref service, specifying the pref sources as explicit 304 // Construct a new pref service. This constructor is what
301 // PrefStore pointers. This constructor is what CreatePrefService() ends up 305 // CreateXXXPrefService() end up calling. It's also used for unit tests.
302 // calling. It's also used for unit tests. 306 PrefService(PrefValueStore* pref_value_store,
303 PrefService(PrefStore* managed_platform_prefs,
304 PrefStore* managed_cloud_prefs,
305 PrefStore* extension_prefs,
306 PrefStore* command_line_prefs,
307 PersistentPrefStore* user_prefs,
308 PrefStore* recommended_platform_prefs,
309 PrefStore* recommended_cloud_prefs,
310 DefaultPrefStore* default_store,
311 bool async); 307 bool async);
312 308
313 // The PrefNotifier handles registering and notifying preference observers.
314 // It is created and owned by this PrefService. Subclasses may access it for
315 // unit testing.
316 scoped_ptr<PrefNotifierImpl> pref_notifier_;
317
318 private: 309 private:
319 class PreferencePathComparator { 310 class PreferencePathComparator {
320 public: 311 public:
321 bool operator() (Preference* lhs, Preference* rhs) const { 312 bool operator() (Preference* lhs, Preference* rhs) const {
322 return lhs->name() < rhs->name(); 313 return lhs->name() < rhs->name();
323 } 314 }
324 }; 315 };
325 typedef std::set<Preference*, PreferencePathComparator> PreferenceSet; 316 typedef std::set<Preference*, PreferencePathComparator> PreferenceSet;
326 317
327 friend class PrefServiceMockBuilder; 318 friend class PrefServiceMockBuilder;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // |type| may only be Values::TYPE_DICTIONARY or Values::TYPE_LIST and 370 // |type| may only be Values::TYPE_DICTIONARY or Values::TYPE_LIST and
380 // |path| must point to a registered preference of type |type|. 371 // |path| must point to a registered preference of type |type|.
381 // Ownership of the returned value remains at the user pref store. 372 // Ownership of the returned value remains at the user pref store.
382 base::Value* GetMutableUserPref(const char* path, 373 base::Value* GetMutableUserPref(const char* path,
383 base::Value::Type type); 374 base::Value::Type type);
384 375
385 // The PrefValueStore provides prioritized preference values. It is created 376 // The PrefValueStore provides prioritized preference values. It is created
386 // and owned by this PrefService. Subclasses may access it for unit testing. 377 // and owned by this PrefService. Subclasses may access it for unit testing.
387 scoped_ptr<PrefValueStore> pref_value_store_; 378 scoped_ptr<PrefValueStore> pref_value_store_;
388 379
380 // The PrefNotifier handles registering and notifying preference observers.
381 // It is created and owned by this PrefService.
382 scoped_ptr<PrefNotifierImpl> pref_notifier_;
383
389 // Pref Stores and profile that we passed to the PrefValueStore. 384 // Pref Stores and profile that we passed to the PrefValueStore.
390 scoped_refptr<PersistentPrefStore> user_pref_store_; 385 scoped_refptr<PersistentPrefStore> user_pref_store_;
391 scoped_refptr<DefaultPrefStore> default_store_; 386 scoped_refptr<DefaultPrefStore> default_store_;
392 387
393 // Local cache of registered Preference objects. The default_store_ 388 // Local cache of registered Preference objects. The default_store_
394 // is authoritative with respect to what the types and default values 389 // is authoritative with respect to what the types and default values
395 // of registered preferences are. 390 // of registered preferences are.
396 mutable PreferenceSet prefs_; 391 mutable PreferenceSet prefs_;
397 392
398 // The model associator that maintains the links with the sync db. 393 // The model associator that maintains the links with the sync db.
399 scoped_ptr<PrefModelAssociator> pref_sync_associator_; 394 scoped_ptr<PrefModelAssociator> pref_sync_associator_;
400 395
401 DISALLOW_COPY_AND_ASSIGN(PrefService); 396 DISALLOW_COPY_AND_ASSIGN(PrefService);
402 }; 397 };
403 398
404 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_ 399 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698