OLD | NEW |
1 // Copyright (c) 2012 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 // Chromium settings and storage represent user-selected preferences and | 7 // Chromium settings and storage represent user-selected preferences and |
8 // information and MUST not be extracted, overwritten or modified except | 8 // information and MUST not be extracted, overwritten or modified except |
9 // through Chromium defined APIs. | 9 // through Chromium defined APIs. |
10 | 10 |
11 #ifndef CHROME_BROWSER_PREFS_PREF_SERVICE_H_ | 11 #ifndef CHROME_BROWSER_PREFS_PREF_SERVICE_H_ |
12 #define CHROME_BROWSER_PREFS_PREF_SERVICE_H_ | 12 #define CHROME_BROWSER_PREFS_PREF_SERVICE_H_ |
13 | 13 |
14 #include <set> | 14 #include <set> |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/hash_tables.h" | 19 #include "base/hash_tables.h" |
| 20 #include "base/observer_list.h" |
20 #include "base/prefs/public/pref_service_base.h" | 21 #include "base/prefs/public/pref_service_base.h" |
21 #include "base/threading/non_thread_safe.h" | 22 #include "base/threading/non_thread_safe.h" |
22 | 23 |
23 class CommandLine; | 24 class CommandLine; |
24 class DefaultPrefStore; | 25 class DefaultPrefStore; |
25 class PersistentPrefStore; | 26 class PersistentPrefStore; |
26 class PrefModelAssociator; | 27 class PrefModelAssociator; |
27 class PrefNotifier; | 28 class PrefNotifier; |
28 class PrefNotifierImpl; | 29 class PrefNotifierImpl; |
| 30 class PrefServiceObserver; |
29 class PrefStore; | 31 class PrefStore; |
30 class PrefValueStore; | 32 class PrefValueStore; |
31 | 33 |
32 namespace syncer { | 34 namespace syncer { |
33 class SyncableService; | 35 class SyncableService; |
34 } | 36 } |
35 | 37 |
36 namespace policy { | 38 namespace policy { |
37 class PolicyService; | 39 class PolicyService; |
38 } | 40 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 123 |
122 // Reloads the data from file. This should only be called when the importer | 124 // Reloads the data from file. This should only be called when the importer |
123 // is running during first run, and the main process may not change pref | 125 // is running during first run, and the main process may not change pref |
124 // values while the importer process is running. Returns true on success. | 126 // values while the importer process is running. Returns true on success. |
125 bool ReloadPersistentPrefs(); | 127 bool ReloadPersistentPrefs(); |
126 | 128 |
127 // Lands pending writes to disk. This should only be used if we need to save | 129 // Lands pending writes to disk. This should only be used if we need to save |
128 // immediately (basically, during shutdown). | 130 // immediately (basically, during shutdown). |
129 void CommitPendingWrite(); | 131 void CommitPendingWrite(); |
130 | 132 |
| 133 void AddObserver(PrefServiceObserver* observer); |
| 134 void RemoveObserver(PrefServiceObserver* observer); |
| 135 |
| 136 // Returns true if preferences state has synchronized with the remote |
| 137 // preferences. If true is returned it can be assumed the local preferences |
| 138 // has applied changes from the remote preferences. The two may not be |
| 139 // identical if a change is in flight (from either side). |
| 140 bool HasSynced(); |
| 141 |
| 142 // Invoked internally when the HasSynced() state changes. |
| 143 void HasSyncedChanged(); |
| 144 |
131 // PrefServiceBase implementation. | 145 // PrefServiceBase implementation. |
132 virtual bool IsManagedPreference(const char* pref_name) const OVERRIDE; | 146 virtual bool IsManagedPreference(const char* pref_name) const OVERRIDE; |
133 virtual bool IsUserModifiablePreference(const char* pref_name) const OVERRIDE; | 147 virtual bool IsUserModifiablePreference(const char* pref_name) const OVERRIDE; |
134 virtual void RegisterBooleanPref(const char* path, | 148 virtual void RegisterBooleanPref(const char* path, |
135 bool default_value) OVERRIDE; | 149 bool default_value) OVERRIDE; |
136 virtual void RegisterIntegerPref(const char* path, | 150 virtual void RegisterIntegerPref(const char* path, |
137 int default_value) OVERRIDE; | 151 int default_value) OVERRIDE; |
138 virtual void RegisterDoublePref(const char* path, | 152 virtual void RegisterDoublePref(const char* path, |
139 double default_value) OVERRIDE; | 153 double default_value) OVERRIDE; |
140 virtual void RegisterStringPref(const char* path, | 154 virtual void RegisterStringPref(const char* path, |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 mutable PreferenceMap prefs_map_; | 348 mutable PreferenceMap prefs_map_; |
335 | 349 |
336 // The model associator that maintains the links with the sync db. | 350 // The model associator that maintains the links with the sync db. |
337 scoped_ptr<PrefModelAssociator> pref_sync_associator_; | 351 scoped_ptr<PrefModelAssociator> pref_sync_associator_; |
338 | 352 |
339 // Whether CreateIncognitoPrefService() or | 353 // Whether CreateIncognitoPrefService() or |
340 // CreatePrefServiceWithPerTabPrefStore() have been called to create a | 354 // CreatePrefServiceWithPerTabPrefStore() have been called to create a |
341 // "forked" PrefService. | 355 // "forked" PrefService. |
342 bool pref_service_forked_; | 356 bool pref_service_forked_; |
343 | 357 |
| 358 ObserverList<PrefServiceObserver> observer_list_; |
| 359 |
344 DISALLOW_COPY_AND_ASSIGN(PrefService); | 360 DISALLOW_COPY_AND_ASSIGN(PrefService); |
345 }; | 361 }; |
346 | 362 |
347 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_ | 363 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_H_ |
OLD | NEW |