| 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 #ifndef CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_ | 5 #ifndef CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_ |
| 6 #define CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_ | 6 #define CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_ |
| 7 | 7 |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/prefs/pref_model_associator.h" | 9 #include "chrome/browser/prefs/pref_model_associator.h" |
| 10 #include "chrome/browser/prefs/synced_pref_observer.h" | 10 #include "chrome/browser/prefs/synced_pref_observer.h" |
| 11 #include "components/pref_registry/pref_registry_syncable.h" | 11 #include "components/pref_registry/pref_registry_syncable.h" |
| 12 | 12 |
| 13 class PrefServiceSyncableObserver; | 13 class PrefServiceSyncableObserver; |
| 14 class Profile; | |
| 15 | 14 |
| 16 namespace syncer { | 15 namespace syncer { |
| 17 class SyncableService; | 16 class SyncableService; |
| 18 } | 17 } |
| 19 | 18 |
| 20 // A PrefService that can be synced. Users are forced to declare | 19 // A PrefService that can be synced. Users are forced to declare |
| 21 // whether preferences are syncable or not when registering them to | 20 // whether preferences are syncable or not when registering them to |
| 22 // this PrefService. | 21 // this PrefService. |
| 23 class PrefServiceSyncable : public PrefService { | 22 class PrefServiceSyncable : public PrefService { |
| 24 public: | 23 public: |
| 25 // PrefServiceSyncable is a PrefService with added integration for | |
| 26 // sync, and knowledge of how to create an incognito | |
| 27 // PrefService. For code that does not need to know about the sync | |
| 28 // integration, you should use only the plain PrefService type. | |
| 29 // | |
| 30 // For this reason, Profile does not expose an accessor for the | |
| 31 // PrefServiceSyncable type. Instead, you can use the utilities | |
| 32 // below to retrieve the PrefServiceSyncable (or its incognito | |
| 33 // version) from a Profile. | |
| 34 static PrefServiceSyncable* FromProfile(Profile* profile); | |
| 35 static PrefServiceSyncable* IncognitoFromProfile(Profile* profile); | |
| 36 | |
| 37 // You may wish to use PrefServiceFactory or one of its subclasses | 24 // You may wish to use PrefServiceFactory or one of its subclasses |
| 38 // for simplified construction. | 25 // for simplified construction. |
| 39 PrefServiceSyncable( | 26 PrefServiceSyncable( |
| 40 PrefNotifierImpl* pref_notifier, | 27 PrefNotifierImpl* pref_notifier, |
| 41 PrefValueStore* pref_value_store, | 28 PrefValueStore* pref_value_store, |
| 42 PersistentPrefStore* user_prefs, | 29 PersistentPrefStore* user_prefs, |
| 43 user_prefs::PrefRegistrySyncable* pref_registry, | 30 user_prefs::PrefRegistrySyncable* pref_registry, |
| 44 base::Callback<void(PersistentPrefStore::PrefReadError)> | 31 base::Callback<void(PersistentPrefStore::PrefReadError)> |
| 45 read_error_callback, | 32 read_error_callback, |
| 46 bool async); | 33 bool async); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 91 |
| 105 PrefModelAssociator pref_sync_associator_; | 92 PrefModelAssociator pref_sync_associator_; |
| 106 PrefModelAssociator priority_pref_sync_associator_; | 93 PrefModelAssociator priority_pref_sync_associator_; |
| 107 | 94 |
| 108 base::ObserverList<PrefServiceSyncableObserver> observer_list_; | 95 base::ObserverList<PrefServiceSyncableObserver> observer_list_; |
| 109 | 96 |
| 110 DISALLOW_COPY_AND_ASSIGN(PrefServiceSyncable); | 97 DISALLOW_COPY_AND_ASSIGN(PrefServiceSyncable); |
| 111 }; | 98 }; |
| 112 | 99 |
| 113 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_ | 100 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_ |
| OLD | NEW |