| 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 PrefService; | 18 class PrefServiceSyncable; |
| 19 | 19 |
| 20 namespace browser_sync { | 20 namespace browser_sync { |
| 21 | 21 |
| 22 class SyncPrefObserver { | 22 class SyncPrefObserver { |
| 23 public: | 23 public: |
| 24 // Called whenever the pref that controls whether sync is managed | 24 // Called whenever the pref that controls whether sync is managed |
| 25 // changes. | 25 // changes. |
| 26 virtual void OnSyncManagedPrefChange(bool is_sync_managed) = 0; | 26 virtual void OnSyncManagedPrefChange(bool is_sync_managed) = 0; |
| 27 | 27 |
| 28 protected: | 28 protected: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 41 // sync_setup_flow.cc | 41 // sync_setup_flow.cc |
| 42 // sync_setup_wizard.cc | 42 // sync_setup_wizard.cc |
| 43 // sync_setup_wizard_unittest.cc | 43 // sync_setup_wizard_unittest.cc |
| 44 // two_client_preferences_sync_test.cc | 44 // two_client_preferences_sync_test.cc |
| 45 class SyncPrefs : NON_EXPORTED_BASE(public base::NonThreadSafe), | 45 class SyncPrefs : NON_EXPORTED_BASE(public base::NonThreadSafe), |
| 46 public base::SupportsWeakPtr<SyncPrefs> { | 46 public base::SupportsWeakPtr<SyncPrefs> { |
| 47 public: | 47 public: |
| 48 // |pref_service| may be NULL (for unit tests), but in that case no | 48 // |pref_service| may be NULL (for unit tests), but in that case no |
| 49 // setter methods should be called. Does not take ownership of | 49 // setter methods should be called. Does not take ownership of |
| 50 // |pref_service|. | 50 // |pref_service|. |
| 51 explicit SyncPrefs(PrefService* pref_service); | 51 explicit SyncPrefs(PrefServiceSyncable* pref_service); |
| 52 | 52 |
| 53 virtual ~SyncPrefs(); | 53 virtual ~SyncPrefs(); |
| 54 | 54 |
| 55 void AddSyncPrefObserver(SyncPrefObserver* sync_pref_observer); | 55 void AddSyncPrefObserver(SyncPrefObserver* sync_pref_observer); |
| 56 void RemoveSyncPrefObserver(SyncPrefObserver* sync_pref_observer); | 56 void RemoveSyncPrefObserver(SyncPrefObserver* sync_pref_observer); |
| 57 | 57 |
| 58 // Clears important sync preferences. | 58 // Clears important sync preferences. |
| 59 void ClearPreferences(); | 59 void ClearPreferences(); |
| 60 | 60 |
| 61 // Getters and setters for global sync prefs. | 61 // Getters and setters for global sync prefs. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 // Returns a ModelTypeSet based on |types| expanded to include pref groups | 131 // Returns a ModelTypeSet based on |types| expanded to include pref groups |
| 132 // (see |pref_groups_|), but as a subset of |registered_types|. | 132 // (see |pref_groups_|), but as a subset of |registered_types|. |
| 133 syncer::ModelTypeSet ResolvePrefGroups( | 133 syncer::ModelTypeSet ResolvePrefGroups( |
| 134 syncer::ModelTypeSet registered_types, | 134 syncer::ModelTypeSet registered_types, |
| 135 syncer::ModelTypeSet types) const; | 135 syncer::ModelTypeSet types) const; |
| 136 | 136 |
| 137 void OnSyncManagedPrefChanged(); | 137 void OnSyncManagedPrefChanged(); |
| 138 | 138 |
| 139 // May be NULL. | 139 // May be NULL. |
| 140 PrefService* const pref_service_; | 140 PrefServiceSyncable* const pref_service_; |
| 141 | 141 |
| 142 ObserverList<SyncPrefObserver> sync_pref_observers_; | 142 ObserverList<SyncPrefObserver> sync_pref_observers_; |
| 143 | 143 |
| 144 // The preference that controls whether sync is under control by | 144 // The preference that controls whether sync is under control by |
| 145 // configuration management. | 145 // configuration management. |
| 146 BooleanPrefMember pref_sync_managed_; | 146 BooleanPrefMember pref_sync_managed_; |
| 147 | 147 |
| 148 // Groups of prefs that always have the same value as a "master" pref. | 148 // Groups of prefs that always have the same value as a "master" pref. |
| 149 // For example, the APPS group has {APP_NOTIFICATIONS, APP_SETTINGS} | 149 // For example, the APPS group has {APP_NOTIFICATIONS, APP_SETTINGS} |
| 150 // (as well as APPS, but that is implied), so | 150 // (as well as APPS, but that is implied), so |
| 151 // pref_groups_[syncer::APPS] = { syncer::APP_NOTIFICATIONS, | 151 // pref_groups_[syncer::APPS] = { syncer::APP_NOTIFICATIONS, |
| 152 // syncer::APP_SETTINGS } | 152 // syncer::APP_SETTINGS } |
| 153 // pref_groups_[syncer::EXTENSIONS] = { syncer::EXTENSION_SETTINGS } | 153 // pref_groups_[syncer::EXTENSIONS] = { syncer::EXTENSION_SETTINGS } |
| 154 // etc. | 154 // etc. |
| 155 typedef std::map<syncer::ModelType, syncer::ModelTypeSet> PrefGroupsMap; | 155 typedef std::map<syncer::ModelType, syncer::ModelTypeSet> PrefGroupsMap; |
| 156 PrefGroupsMap pref_groups_; | 156 PrefGroupsMap pref_groups_; |
| 157 | 157 |
| 158 DISALLOW_COPY_AND_ASSIGN(SyncPrefs); | 158 DISALLOW_COPY_AND_ASSIGN(SyncPrefs); |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 } // namespace browser_sync | 161 } // namespace browser_sync |
| 162 | 162 |
| 163 #endif // CHROME_BROWSER_SYNC_SYNC_PREFS_H_ | 163 #endif // CHROME_BROWSER_SYNC_SYNC_PREFS_H_ |
| OLD | NEW |