Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_ | |
| 6 #define CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_ | |
| 7 | |
| 8 #include "chrome/browser/prefs/pref_model_associator.h" | |
| 9 #include "chrome/browser/prefs/pref_service.h" | |
| 10 | |
| 11 // TODO(joi) Move to c/b/prefs and rename PrefServiceSyncableObserver. | |
| 12 class PrefServiceObserver; | |
| 13 | |
| 14 namespace syncer { | |
| 15 class SyncableService; | |
| 16 } | |
| 17 | |
| 18 // A PrefService that can be synced. Users are forced to declare | |
| 19 // whether preferences are syncable or not when registering them to | |
| 20 // this PrefService. | |
| 21 class PrefServiceSyncable : public PrefService { | |
| 22 public: | |
| 23 // Enum used when registering preferences to determine if it should be synced | |
| 24 // or not. This is only used for profile prefs, not local state prefs. | |
| 25 // See the Register*Pref methods for profile prefs below. | |
| 26 enum PrefSyncStatus { | |
| 27 UNSYNCABLE_PREF, | |
| 28 SYNCABLE_PREF | |
| 29 }; | |
| 30 | |
| 31 virtual ~PrefServiceSyncable(); | |
| 32 | |
| 33 // Creates an incognito copy of the pref service that shares most pref stores | |
| 34 // but uses a fresh non-persistent overlay for the user pref store and an | |
| 35 // individual extension pref store (to cache the effective extension prefs for | |
| 36 // incognito windows). | |
| 37 PrefServiceSyncable* CreateIncognitoPrefService( | |
| 38 PrefStore* incognito_extension_prefs); | |
| 39 | |
| 40 // Returns true if preferences state has synchronized with the remote | |
| 41 // preferences. If true is returned it can be assumed the local preferences | |
| 42 // has applied changes from the remote preferences. The two may not be | |
| 43 // identical if a change is in flight (from either side). | |
| 44 bool IsSyncing(); | |
| 45 | |
| 46 void AddObserver(PrefServiceObserver* observer); | |
| 47 void RemoveObserver(PrefServiceObserver* observer); | |
| 48 | |
| 49 virtual void UnregisterPreference(const char* path) OVERRIDE; | |
| 50 | |
| 51 void RegisterBooleanPref(const char* path, | |
| 52 bool default_value, | |
| 53 PrefSyncStatus sync_status); | |
| 54 void RegisterIntegerPref(const char* path, | |
| 55 int default_value, | |
| 56 PrefSyncStatus sync_status); | |
| 57 void RegisterDoublePref(const char* path, | |
| 58 double default_value, | |
| 59 PrefSyncStatus sync_status); | |
| 60 void RegisterStringPref(const char* path, | |
| 61 const std::string& default_value, | |
| 62 PrefSyncStatus sync_status); | |
| 63 void RegisterFilePathPref(const char* path, | |
| 64 const FilePath& default_value, | |
| 65 PrefSyncStatus sync_status); | |
| 66 void RegisterListPref(const char* path, | |
| 67 PrefSyncStatus sync_status); | |
| 68 void RegisterDictionaryPref(const char* path, | |
| 69 PrefSyncStatus sync_status); | |
| 70 void RegisterListPref(const char* path, | |
| 71 base::ListValue* default_value, | |
| 72 PrefSyncStatus sync_status); | |
| 73 void RegisterDictionaryPref(const char* path, | |
| 74 base::DictionaryValue* default_value, | |
| 75 PrefSyncStatus sync_status); | |
| 76 void RegisterLocalizedBooleanPref(const char* path, | |
| 77 int locale_default_message_id, | |
| 78 PrefSyncStatus sync_status); | |
| 79 void RegisterLocalizedIntegerPref(const char* path, | |
| 80 int locale_default_message_id, | |
| 81 PrefSyncStatus sync_status); | |
| 82 void RegisterLocalizedDoublePref(const char* path, | |
| 83 int locale_default_message_id, | |
| 84 PrefSyncStatus sync_status); | |
| 85 void RegisterLocalizedStringPref(const char* path, | |
| 86 int locale_default_message_id, | |
| 87 PrefSyncStatus sync_status); | |
| 88 void RegisterInt64Pref(const char* path, | |
| 89 int64 default_value, | |
| 90 PrefSyncStatus sync_status); | |
| 91 void RegisterUint64Pref(const char* path, | |
| 92 uint64 default_value, | |
| 93 PrefSyncStatus sync_status); | |
| 94 | |
| 95 // syncer::SyncableService getter. | |
| 96 // TODO(zea): Have PrefService implement syncer::SyncableService directly. | |
|
Mattias Nissler (ping if slow)
2012/12/20 13:41:52
update comment
Jói
2012/12/20 16:30:31
Done.
| |
| 97 syncer::SyncableService* GetSyncableService(); | |
| 98 | |
| 99 // Do not call this after having derived an incognito or per tab pref service. | |
| 100 virtual void UpdateCommandLinePrefStore(PrefStore* cmd_line_store) OVERRIDE; | |
| 101 | |
| 102 protected: | |
| 103 // Only use ChromePrefServiceFactory to create initialized PrefServiceSyncable | |
| 104 // objects. | |
| 105 PrefServiceSyncable(); | |
| 106 | |
| 107 virtual void Initialize( | |
| 108 PrefNotifierImpl* pref_notifier, | |
| 109 PrefValueStore* pref_value_store, | |
| 110 PersistentPrefStore* user_prefs, | |
| 111 DefaultPrefStore* default_store, | |
| 112 base::Callback<void(PersistentPrefStore::PrefReadError)> | |
| 113 read_error_callback, | |
| 114 bool async) OVERRIDE; | |
| 115 | |
| 116 private: | |
| 117 friend class PrefModelAssociator; | |
| 118 | |
| 119 // Constructs objects. | |
|
Mattias Nissler (ping if slow)
2012/12/20 13:41:52
s/objects/instances/
Jói
2012/12/20 16:30:31
Done.
| |
| 120 friend class ChromePrefServiceFactory; | |
| 121 friend class PrefServiceMockBuilder; | |
| 122 | |
| 123 // Invoked internally when the IsSyncing() state changes. | |
| 124 void OnIsSyncingChanged(); | |
| 125 | |
|
Mattias Nissler (ping if slow)
2012/12/20 13:41:52
documentation.
Jói
2012/12/20 16:30:31
Done.
| |
| 126 void RegisterSyncablePreference( | |
| 127 const char* path, Value* default_value, PrefSyncStatus sync_status); | |
|
Mattias Nissler (ping if slow)
2012/12/20 13:41:52
param decls on separate lines.
Jói
2012/12/20 16:30:31
Done.
| |
| 128 | |
| 129 // Whether CreateIncognitoPrefService() has been called to create a | |
| 130 // "forked" PrefService. | |
| 131 bool pref_service_forked_; | |
| 132 | |
| 133 PrefModelAssociator pref_sync_associator_; | |
| 134 | |
| 135 ObserverList<PrefServiceObserver> observer_list_; | |
|
Mattias Nissler (ping if slow)
2012/12/20 13:41:52
DISALLOW_COPY_AND_ASSIGN
Jói
2012/12/20 16:30:31
Done.
| |
| 136 }; | |
| 137 | |
| 138 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_ | |
| OLD | NEW |