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_SYNC_SYNC_PREFS_H_ | 5 #ifndef CHROME_BROWSER_SYNC_SYNC_PREFS_H_ |
6 #define CHROME_BROWSER_SYNC_SYNC_PREFS_H_ | 6 #define CHROME_BROWSER_SYNC_SYNC_PREFS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "base/prefs/public/pref_member.h" | 12 #include "base/prefs/public/pref_member.h" |
13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "sync/internal_api/public/base/model_type.h" | 15 #include "sync/internal_api/public/base/model_type.h" |
16 #include "sync/notifier/invalidation_state_tracker.h" | 16 #include "sync/notifier/invalidation_state_tracker.h" |
17 | 17 |
18 class PrefServiceSyncable; | 18 class PrefRegistrySyncable; |
| 19 class PrefService; |
19 class ProfileIOData; | 20 class ProfileIOData; |
20 | 21 |
21 namespace browser_sync { | 22 namespace browser_sync { |
22 | 23 |
23 class SyncPrefObserver { | 24 class SyncPrefObserver { |
24 public: | 25 public: |
25 // Called whenever the pref that controls whether sync is managed | 26 // Called whenever the pref that controls whether sync is managed |
26 // changes. | 27 // changes. |
27 virtual void OnSyncManagedPrefChange(bool is_sync_managed) = 0; | 28 virtual void OnSyncManagedPrefChange(bool is_sync_managed) = 0; |
28 | 29 |
(...skipping 13 matching lines...) Expand all Loading... |
42 // sync_setup_flow.cc | 43 // sync_setup_flow.cc |
43 // sync_setup_wizard.cc | 44 // sync_setup_wizard.cc |
44 // sync_setup_wizard_unittest.cc | 45 // sync_setup_wizard_unittest.cc |
45 // two_client_preferences_sync_test.cc | 46 // two_client_preferences_sync_test.cc |
46 class SyncPrefs : NON_EXPORTED_BASE(public base::NonThreadSafe), | 47 class SyncPrefs : NON_EXPORTED_BASE(public base::NonThreadSafe), |
47 public base::SupportsWeakPtr<SyncPrefs> { | 48 public base::SupportsWeakPtr<SyncPrefs> { |
48 public: | 49 public: |
49 // |pref_service| may be NULL (for unit tests), but in that case no | 50 // |pref_service| may be NULL (for unit tests), but in that case no |
50 // setter methods should be called. Does not take ownership of | 51 // setter methods should be called. Does not take ownership of |
51 // |pref_service|. | 52 // |pref_service|. |
52 explicit SyncPrefs(PrefServiceSyncable* pref_service); | 53 explicit SyncPrefs(PrefService* pref_service); |
53 | 54 |
54 virtual ~SyncPrefs(); | 55 virtual ~SyncPrefs(); |
55 | 56 |
56 static void RegisterUserPrefs(PrefServiceSyncable* prefs); | 57 static void RegisterUserPrefs(PrefService* prefs, |
| 58 PrefRegistrySyncable* registry); |
57 | 59 |
58 // Checks if sync is enabled for the profile that owns |io_data|. This must | 60 // Checks if sync is enabled for the profile that owns |io_data|. This must |
59 // be invoked on the IO thread, and can be used to check if sync is enabled | 61 // be invoked on the IO thread, and can be used to check if sync is enabled |
60 // on that thread. | 62 // on that thread. |
61 static bool IsSyncAccessibleOnIOThread(ProfileIOData* io_data); | 63 static bool IsSyncAccessibleOnIOThread(ProfileIOData* io_data); |
62 | 64 |
63 void AddSyncPrefObserver(SyncPrefObserver* sync_pref_observer); | 65 void AddSyncPrefObserver(SyncPrefObserver* sync_pref_observer); |
64 void RemoveSyncPrefObserver(SyncPrefObserver* sync_pref_observer); | 66 void RemoveSyncPrefObserver(SyncPrefObserver* sync_pref_observer); |
65 | 67 |
66 // Clears important sync preferences. | 68 // Clears important sync preferences. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 126 |
125 // For testing. | 127 // For testing. |
126 | 128 |
127 void SetManagedForTest(bool is_managed); | 129 void SetManagedForTest(bool is_managed); |
128 syncer::ModelTypeSet GetAcknowledgeSyncedTypesForTest() const; | 130 syncer::ModelTypeSet GetAcknowledgeSyncedTypesForTest() const; |
129 | 131 |
130 private: | 132 private: |
131 void RegisterPrefGroups(); | 133 void RegisterPrefGroups(); |
132 | 134 |
133 static void RegisterDataTypePreferredPref( | 135 static void RegisterDataTypePreferredPref( |
134 PrefServiceSyncable* prefs, syncer::ModelType type, bool is_preferred); | 136 PrefRegistrySyncable* prefs, syncer::ModelType type, bool is_preferred); |
135 bool GetDataTypePreferred(syncer::ModelType type) const; | 137 bool GetDataTypePreferred(syncer::ModelType type) const; |
136 void SetDataTypePreferred(syncer::ModelType type, bool is_preferred); | 138 void SetDataTypePreferred(syncer::ModelType type, bool is_preferred); |
137 | 139 |
138 // Returns a ModelTypeSet based on |types| expanded to include pref groups | 140 // Returns a ModelTypeSet based on |types| expanded to include pref groups |
139 // (see |pref_groups_|), but as a subset of |registered_types|. | 141 // (see |pref_groups_|), but as a subset of |registered_types|. |
140 syncer::ModelTypeSet ResolvePrefGroups( | 142 syncer::ModelTypeSet ResolvePrefGroups( |
141 syncer::ModelTypeSet registered_types, | 143 syncer::ModelTypeSet registered_types, |
142 syncer::ModelTypeSet types) const; | 144 syncer::ModelTypeSet types) const; |
143 | 145 |
144 void OnSyncManagedPrefChanged(); | 146 void OnSyncManagedPrefChanged(); |
145 | 147 |
146 // May be NULL. | 148 // May be NULL. |
147 PrefServiceSyncable* const pref_service_; | 149 PrefService* const pref_service_; |
148 | 150 |
149 ObserverList<SyncPrefObserver> sync_pref_observers_; | 151 ObserverList<SyncPrefObserver> sync_pref_observers_; |
150 | 152 |
151 // The preference that controls whether sync is under control by | 153 // The preference that controls whether sync is under control by |
152 // configuration management. | 154 // configuration management. |
153 BooleanPrefMember pref_sync_managed_; | 155 BooleanPrefMember pref_sync_managed_; |
154 | 156 |
155 // Groups of prefs that always have the same value as a "master" pref. | 157 // Groups of prefs that always have the same value as a "master" pref. |
156 // For example, the APPS group has {APP_NOTIFICATIONS, APP_SETTINGS} | 158 // For example, the APPS group has {APP_NOTIFICATIONS, APP_SETTINGS} |
157 // (as well as APPS, but that is implied), so | 159 // (as well as APPS, but that is implied), so |
158 // pref_groups_[syncer::APPS] = { syncer::APP_NOTIFICATIONS, | 160 // pref_groups_[syncer::APPS] = { syncer::APP_NOTIFICATIONS, |
159 // syncer::APP_SETTINGS } | 161 // syncer::APP_SETTINGS } |
160 // pref_groups_[syncer::EXTENSIONS] = { syncer::EXTENSION_SETTINGS } | 162 // pref_groups_[syncer::EXTENSIONS] = { syncer::EXTENSION_SETTINGS } |
161 // etc. | 163 // etc. |
162 typedef std::map<syncer::ModelType, syncer::ModelTypeSet> PrefGroupsMap; | 164 typedef std::map<syncer::ModelType, syncer::ModelTypeSet> PrefGroupsMap; |
163 PrefGroupsMap pref_groups_; | 165 PrefGroupsMap pref_groups_; |
164 | 166 |
165 DISALLOW_COPY_AND_ASSIGN(SyncPrefs); | 167 DISALLOW_COPY_AND_ASSIGN(SyncPrefs); |
166 }; | 168 }; |
167 | 169 |
168 } // namespace browser_sync | 170 } // namespace browser_sync |
169 | 171 |
170 #endif // CHROME_BROWSER_SYNC_SYNC_PREFS_H_ | 172 #endif // CHROME_BROWSER_SYNC_SYNC_PREFS_H_ |
OLD | NEW |