Chromium Code Reviews| 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|. | |
|
battre
2012/01/19 09:52:21
Please add a comment that you must not call this a
Lei Zhang
2012/01/19 20:33:59
Done.
| |
| 301 void UpdateCommandLinePrefStore(CommandLine* command_line); | |
| 302 | |
| 300 protected: | 303 protected: |
| 301 // Construct a new pref service. This constructor is what | 304 // Construct a new pref service. This constructor is what |
| 302 // factory methods end up calling and what is used for unit tests. | 305 // factory methods end up calling and what is used for unit tests. |
| 303 PrefService(PrefNotifierImpl* pref_notifier, | 306 PrefService(PrefNotifierImpl* pref_notifier, |
| 304 PrefValueStore* pref_value_store, | 307 PrefValueStore* pref_value_store, |
| 305 PersistentPrefStore* user_prefs, | 308 PersistentPrefStore* user_prefs, |
| 306 DefaultPrefStore* default_store, | 309 DefaultPrefStore* default_store, |
| 307 PrefModelAssociator* pref_sync_associator, | 310 PrefModelAssociator* pref_sync_associator, |
| 308 bool async); | 311 bool async); |
| 309 | 312 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 // of registered preferences are. | 390 // of registered preferences are. |
| 388 mutable PreferenceSet prefs_; | 391 mutable PreferenceSet prefs_; |
| 389 | 392 |
| 390 // The model associator that maintains the links with the sync db. | 393 // The model associator that maintains the links with the sync db. |
| 391 scoped_ptr<PrefModelAssociator> pref_sync_associator_; | 394 scoped_ptr<PrefModelAssociator> pref_sync_associator_; |
| 392 | 395 |
| 393 DISALLOW_COPY_AND_ASSIGN(PrefService); | 396 DISALLOW_COPY_AND_ASSIGN(PrefService); |
| 394 }; | 397 }; |
| 395 | 398 |
| 396 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_ | 399 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_ |
| OLD | NEW |