| 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 "components/user_prefs/pref_registry_syncable.h" | 10 #include "components/user_prefs/pref_registry_syncable.h" |
| 11 | 11 |
| 12 class PrefRegistrySyncable; | |
| 13 class PrefServiceSyncableObserver; | 12 class PrefServiceSyncableObserver; |
| 14 class Profile; | 13 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. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 33 // version) from a Profile. | 32 // version) from a Profile. |
| 34 static PrefServiceSyncable* FromProfile(Profile* profile); | 33 static PrefServiceSyncable* FromProfile(Profile* profile); |
| 35 static PrefServiceSyncable* IncognitoFromProfile(Profile* profile); | 34 static PrefServiceSyncable* IncognitoFromProfile(Profile* profile); |
| 36 | 35 |
| 37 // You may wish to use PrefServiceBuilder or one of its subclasses | 36 // You may wish to use PrefServiceBuilder or one of its subclasses |
| 38 // for simplified construction. | 37 // for simplified construction. |
| 39 PrefServiceSyncable( | 38 PrefServiceSyncable( |
| 40 PrefNotifierImpl* pref_notifier, | 39 PrefNotifierImpl* pref_notifier, |
| 41 PrefValueStore* pref_value_store, | 40 PrefValueStore* pref_value_store, |
| 42 PersistentPrefStore* user_prefs, | 41 PersistentPrefStore* user_prefs, |
| 43 PrefRegistrySyncable* pref_registry, | 42 user_prefs::PrefRegistrySyncable* pref_registry, |
| 44 base::Callback<void(PersistentPrefStore::PrefReadError)> | 43 base::Callback<void(PersistentPrefStore::PrefReadError)> |
| 45 read_error_callback, | 44 read_error_callback, |
| 46 bool async); | 45 bool async); |
| 47 virtual ~PrefServiceSyncable(); | 46 virtual ~PrefServiceSyncable(); |
| 48 | 47 |
| 49 // Creates an incognito copy of the pref service that shares most pref stores | 48 // Creates an incognito copy of the pref service that shares most pref stores |
| 50 // but uses a fresh non-persistent overlay for the user pref store and an | 49 // but uses a fresh non-persistent overlay for the user pref store and an |
| 51 // individual extension pref store (to cache the effective extension prefs for | 50 // individual extension pref store (to cache the effective extension prefs for |
| 52 // incognito windows). | 51 // incognito windows). |
| 53 PrefServiceSyncable* CreateIncognitoPrefService( | 52 PrefServiceSyncable* CreateIncognitoPrefService( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 75 syncer::SyncableService* GetSyncableService(const syncer::ModelType& type); | 74 syncer::SyncableService* GetSyncableService(const syncer::ModelType& type); |
| 76 | 75 |
| 77 // Do not call this after having derived an incognito or per tab pref service. | 76 // Do not call this after having derived an incognito or per tab pref service. |
| 78 virtual void UpdateCommandLinePrefStore(PrefStore* cmd_line_store) OVERRIDE; | 77 virtual void UpdateCommandLinePrefStore(PrefStore* cmd_line_store) OVERRIDE; |
| 79 | 78 |
| 80 private: | 79 private: |
| 81 friend class PrefModelAssociator; | 80 friend class PrefModelAssociator; |
| 82 | 81 |
| 83 void AddRegisteredSyncablePreference( | 82 void AddRegisteredSyncablePreference( |
| 84 const char* path, | 83 const char* path, |
| 85 const PrefRegistrySyncable::PrefSyncStatus sync_status); | 84 const user_prefs::PrefRegistrySyncable::PrefSyncStatus sync_status); |
| 86 | 85 |
| 87 // Invoked internally when the IsSyncing() state changes. | 86 // Invoked internally when the IsSyncing() state changes. |
| 88 void OnIsSyncingChanged(); | 87 void OnIsSyncingChanged(); |
| 89 | 88 |
| 90 // Process a local preference change. This can trigger new SyncChanges being | 89 // Process a local preference change. This can trigger new SyncChanges being |
| 91 // sent to the syncer. | 90 // sent to the syncer. |
| 92 void ProcessPrefChange(const std::string& name); | 91 void ProcessPrefChange(const std::string& name); |
| 93 | 92 |
| 94 // Whether CreateIncognitoPrefService() has been called to create a | 93 // Whether CreateIncognitoPrefService() has been called to create a |
| 95 // "forked" PrefService. | 94 // "forked" PrefService. |
| 96 bool pref_service_forked_; | 95 bool pref_service_forked_; |
| 97 | 96 |
| 98 PrefModelAssociator pref_sync_associator_; | 97 PrefModelAssociator pref_sync_associator_; |
| 99 PrefModelAssociator priority_pref_sync_associator_; | 98 PrefModelAssociator priority_pref_sync_associator_; |
| 100 | 99 |
| 101 ObserverList<PrefServiceSyncableObserver> observer_list_; | 100 ObserverList<PrefServiceSyncableObserver> observer_list_; |
| 102 | 101 |
| 103 DISALLOW_COPY_AND_ASSIGN(PrefServiceSyncable); | 102 DISALLOW_COPY_AND_ASSIGN(PrefServiceSyncable); |
| 104 }; | 103 }; |
| 105 | 104 |
| 106 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_ | 105 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_ |
| OLD | NEW |