| OLD | NEW |
| 1 // Copyright (c) 2011 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 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 |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/common/json_pref_store.h" | 18 #include "chrome/common/json_pref_store.h" |
| 19 | 19 |
| 20 class CommandLine; |
| 20 class DefaultPrefStore; | 21 class DefaultPrefStore; |
| 21 class FilePath; | 22 class FilePath; |
| 22 class PersistentPrefStore; | 23 class PersistentPrefStore; |
| 23 class PrefModelAssociator; | 24 class PrefModelAssociator; |
| 24 class PrefNotifier; | 25 class PrefNotifier; |
| 25 class PrefNotifierImpl; | 26 class PrefNotifierImpl; |
| 26 class PrefStore; | 27 class PrefStore; |
| 27 class PrefValueStore; | 28 class PrefValueStore; |
| 28 class Profile; | 29 class Profile; |
| 29 class SyncableService; | 30 class SyncableService; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 45 // or not. This is only used for profile prefs, not local state prefs. | 46 // or not. This is only used for profile prefs, not local state prefs. |
| 46 // See the Register*Pref methods for profile prefs below. | 47 // See the Register*Pref methods for profile prefs below. |
| 47 enum PrefSyncStatus { | 48 enum PrefSyncStatus { |
| 48 UNSYNCABLE_PREF, | 49 UNSYNCABLE_PREF, |
| 49 SYNCABLE_PREF | 50 SYNCABLE_PREF |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 // A helper class to store all the information associated with a preference. | 53 // A helper class to store all the information associated with a preference. |
| 53 class Preference { | 54 class Preference { |
| 54 public: | 55 public: |
| 55 | |
| 56 // The type of the preference is determined by the type with which it is | 56 // The type of the preference is determined by the type with which it is |
| 57 // registered. This type needs to be a boolean, integer, double, string, | 57 // registered. This type needs to be a boolean, integer, double, string, |
| 58 // dictionary (a branch), or list. You shouldn't need to construct this on | 58 // dictionary (a branch), or list. You shouldn't need to construct this on |
| 59 // your own; use the PrefService::Register*Pref methods instead. | 59 // your own; use the PrefService::Register*Pref methods instead. |
| 60 Preference(const PrefService* service, | 60 Preference(const PrefService* service, |
| 61 const char* name, | 61 const char* name, |
| 62 base::Value::Type type); | 62 base::Value::Type type); |
| 63 ~Preference() {} | 63 ~Preference() {} |
| 64 | 64 |
| 65 // Returns the name of the Preference (i.e., the key, e.g., | 65 // Returns the name of the Preference (i.e., the key, e.g., |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // A helper method to quickly look up a preference. Returns NULL if the | 290 // A helper method to quickly look up a preference. Returns NULL if the |
| 291 // preference is not registered. | 291 // preference is not registered. |
| 292 const Preference* FindPreference(const char* pref_name) const; | 292 const Preference* FindPreference(const char* pref_name) const; |
| 293 | 293 |
| 294 bool ReadOnly() const; | 294 bool ReadOnly() const; |
| 295 | 295 |
| 296 // SyncableService getter. | 296 // SyncableService getter. |
| 297 // TODO(zea): Have PrefService implement SyncableService directly. | 297 // TODO(zea): Have PrefService implement SyncableService directly. |
| 298 SyncableService* GetSyncableService(); | 298 SyncableService* GetSyncableService(); |
| 299 | 299 |
| 300 // Tell our PrefValueStore to update itself using |command_line|. |
| 301 // Do not call this after having derived an incognito or per tab pref service. |
| 302 void UpdateCommandLinePrefStore(CommandLine* command_line); |
| 303 |
| 300 protected: | 304 protected: |
| 301 // Construct a new pref service. This constructor is what | 305 // Construct a new pref service. This constructor is what |
| 302 // factory methods end up calling and what is used for unit tests. | 306 // factory methods end up calling and what is used for unit tests. |
| 303 PrefService(PrefNotifierImpl* pref_notifier, | 307 PrefService(PrefNotifierImpl* pref_notifier, |
| 304 PrefValueStore* pref_value_store, | 308 PrefValueStore* pref_value_store, |
| 305 PersistentPrefStore* user_prefs, | 309 PersistentPrefStore* user_prefs, |
| 306 DefaultPrefStore* default_store, | 310 DefaultPrefStore* default_store, |
| 307 PrefModelAssociator* pref_sync_associator, | 311 PrefModelAssociator* pref_sync_associator, |
| 308 bool async); | 312 bool async); |
| 309 | 313 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 scoped_refptr<DefaultPrefStore> default_store_; | 387 scoped_refptr<DefaultPrefStore> default_store_; |
| 384 | 388 |
| 385 // Local cache of registered Preference objects. The default_store_ | 389 // Local cache of registered Preference objects. The default_store_ |
| 386 // is authoritative with respect to what the types and default values | 390 // is authoritative with respect to what the types and default values |
| 387 // of registered preferences are. | 391 // of registered preferences are. |
| 388 mutable PreferenceSet prefs_; | 392 mutable PreferenceSet prefs_; |
| 389 | 393 |
| 390 // The model associator that maintains the links with the sync db. | 394 // The model associator that maintains the links with the sync db. |
| 391 scoped_ptr<PrefModelAssociator> pref_sync_associator_; | 395 scoped_ptr<PrefModelAssociator> pref_sync_associator_; |
| 392 | 396 |
| 397 // Whether CreateIncognitoPrefService() or |
| 398 // CreatePrefServiceWithPerTabPrefStore() have been called to create a |
| 399 // "forked" PrefService. |
| 400 bool pref_service_forked_; |
| 401 |
| 393 DISALLOW_COPY_AND_ASSIGN(PrefService); | 402 DISALLOW_COPY_AND_ASSIGN(PrefService); |
| 394 }; | 403 }; |
| 395 | 404 |
| 396 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_ | 405 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_ |
| OLD | NEW |