Chromium Code Reviews| 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 COMPONENTS_SYNC_DRIVER_SYNC_PREFS_H_ |
| 6 #define CHROME_BROWSER_SYNC_SYNC_PREFS_H_ | 6 #define COMPONENTS_SYNC_DRIVER_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/pref_member.h" | 12 #include "base/prefs/pref_member.h" |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/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 PrefService; |
| 19 class ProfileIOData; | 19 class ProfileIOData; |
| 20 | 20 |
| 21 namespace user_prefs { | 21 namespace user_prefs { |
| 22 class PrefRegistrySyncable; | 22 class PrefRegistrySyncable; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace browser_sync { | 25 namespace sync_driver { |
| 26 | 26 |
| 27 class SyncPrefObserver { | 27 class SyncPrefObserver { |
| 28 public: | 28 public: |
| 29 // Called whenever the pref that controls whether sync is managed | 29 // Called whenever the pref that controls whether sync is managed |
| 30 // changes. | 30 // changes. |
| 31 virtual void OnSyncManagedPrefChange(bool is_sync_managed) = 0; | 31 virtual void OnSyncManagedPrefChange(bool is_sync_managed) = 0; |
| 32 | 32 |
| 33 protected: | 33 protected: |
| 34 virtual ~SyncPrefObserver(); | 34 virtual ~SyncPrefObserver(); |
| 35 }; | 35 }; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 | 68 |
| 69 bool HasSyncSetupCompleted() const; | 69 bool HasSyncSetupCompleted() const; |
| 70 void SetSyncSetupCompleted(); | 70 void SetSyncSetupCompleted(); |
| 71 | 71 |
| 72 bool SyncHasAuthError() const; | 72 bool SyncHasAuthError() const; |
| 73 void SetSyncAuthError(bool error); | 73 void SetSyncAuthError(bool error); |
| 74 | 74 |
| 75 bool IsStartSuppressed() const; | 75 bool IsStartSuppressed() const; |
| 76 void SetStartSuppressed(bool is_suppressed); | 76 void SetStartSuppressed(bool is_suppressed); |
| 77 | 77 |
| 78 std::string GetGoogleServicesUsername() const; | |
|
Nicolas Zea
2014/03/14 23:47:41
only had one callsite, that could just as easily q
| |
| 79 | |
| 80 base::Time GetLastSyncedTime() const; | 78 base::Time GetLastSyncedTime() const; |
| 81 void SetLastSyncedTime(base::Time time); | 79 void SetLastSyncedTime(base::Time time); |
| 82 | 80 |
| 83 bool HasKeepEverythingSynced() const; | 81 bool HasKeepEverythingSynced() const; |
| 84 void SetKeepEverythingSynced(bool keep_everything_synced); | 82 void SetKeepEverythingSynced(bool keep_everything_synced); |
| 85 | 83 |
| 86 // The returned set is guaranteed to be a subset of | 84 // The returned set is guaranteed to be a subset of |
| 87 // |registered_types|. Returns |registered_types| directly if | 85 // |registered_types|. Returns |registered_types| directly if |
| 88 // HasKeepEverythingSynced() is true. | 86 // HasKeepEverythingSynced() is true. |
| 89 syncer::ModelTypeSet GetPreferredDataTypes( | 87 syncer::ModelTypeSet GetPreferredDataTypes( |
| 90 syncer::ModelTypeSet registered_types) const; | 88 syncer::ModelTypeSet registered_types) const; |
| 91 // |preferred_types| should be a subset of |registered_types|. All | 89 // |preferred_types| should be a subset of |registered_types|. All |
| 92 // types in |preferred_types| are marked preferred, and all types in | 90 // types in |preferred_types| are marked preferred, and all types in |
| 93 // |registered_types| \ |preferred_types| are marked not preferred. | 91 // |registered_types| \ |preferred_types| are marked not preferred. |
| 94 // Changes are still made to the prefs even if | 92 // Changes are still made to the prefs even if |
| 95 // HasKeepEverythingSynced() is true, but won't be visible until | 93 // HasKeepEverythingSynced() is true, but won't be visible until |
| 96 // SetKeepEverythingSynced(false) is called. | 94 // SetKeepEverythingSynced(false) is called. |
| 97 void SetPreferredDataTypes( | 95 void SetPreferredDataTypes(syncer::ModelTypeSet registered_types, |
| 98 syncer::ModelTypeSet registered_types, | 96 syncer::ModelTypeSet preferred_types); |
| 99 syncer::ModelTypeSet preferred_types); | |
| 100 | 97 |
| 101 // This pref is set outside of sync. | 98 // This pref is set outside of sync. |
| 102 bool IsManaged() const; | 99 bool IsManaged() const; |
| 103 | 100 |
| 104 // Use this encryption bootstrap token if we're using an explicit passphrase. | 101 // Use this encryption bootstrap token if we're using an explicit passphrase. |
| 105 std::string GetEncryptionBootstrapToken() const; | 102 std::string GetEncryptionBootstrapToken() const; |
| 106 void SetEncryptionBootstrapToken(const std::string& token); | 103 void SetEncryptionBootstrapToken(const std::string& token); |
| 107 | 104 |
| 108 // Use this keystore bootstrap token if we're not using an explicit | 105 // Use this keystore bootstrap token if we're not using an explicit |
| 109 // passphrase. | 106 // passphrase. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 137 | 134 |
| 138 static void RegisterDataTypePreferredPref( | 135 static void RegisterDataTypePreferredPref( |
| 139 user_prefs::PrefRegistrySyncable* prefs, | 136 user_prefs::PrefRegistrySyncable* prefs, |
| 140 syncer::ModelType type, | 137 syncer::ModelType type, |
| 141 bool is_preferred); | 138 bool is_preferred); |
| 142 bool GetDataTypePreferred(syncer::ModelType type) const; | 139 bool GetDataTypePreferred(syncer::ModelType type) const; |
| 143 void SetDataTypePreferred(syncer::ModelType type, bool is_preferred); | 140 void SetDataTypePreferred(syncer::ModelType type, bool is_preferred); |
| 144 | 141 |
| 145 // Returns a ModelTypeSet based on |types| expanded to include pref groups | 142 // Returns a ModelTypeSet based on |types| expanded to include pref groups |
| 146 // (see |pref_groups_|), but as a subset of |registered_types|. | 143 // (see |pref_groups_|), but as a subset of |registered_types|. |
| 147 syncer::ModelTypeSet ResolvePrefGroups( | 144 syncer::ModelTypeSet ResolvePrefGroups(syncer::ModelTypeSet registered_types, |
| 148 syncer::ModelTypeSet registered_types, | 145 syncer::ModelTypeSet types) const; |
| 149 syncer::ModelTypeSet types) const; | |
| 150 | 146 |
| 151 void OnSyncManagedPrefChanged(); | 147 void OnSyncManagedPrefChanged(); |
| 152 | 148 |
| 153 // May be NULL. | 149 // May be NULL. |
| 154 PrefService* const pref_service_; | 150 PrefService* const pref_service_; |
| 155 | 151 |
| 156 ObserverList<SyncPrefObserver> sync_pref_observers_; | 152 ObserverList<SyncPrefObserver> sync_pref_observers_; |
| 157 | 153 |
| 158 // The preference that controls whether sync is under control by | 154 // The preference that controls whether sync is under control by |
| 159 // configuration management. | 155 // configuration management. |
| 160 BooleanPrefMember pref_sync_managed_; | 156 BooleanPrefMember pref_sync_managed_; |
| 161 | 157 |
| 162 // Groups of prefs that always have the same value as a "master" pref. | 158 // Groups of prefs that always have the same value as a "master" pref. |
| 163 // For example, the APPS group has {APP_NOTIFICATIONS, APP_SETTINGS} | 159 // For example, the APPS group has {APP_NOTIFICATIONS, APP_SETTINGS} |
| 164 // (as well as APPS, but that is implied), so | 160 // (as well as APPS, but that is implied), so |
| 165 // pref_groups_[syncer::APPS] = { syncer::APP_NOTIFICATIONS, | 161 // pref_groups_[syncer::APPS] = { syncer::APP_NOTIFICATIONS, |
| 166 // syncer::APP_SETTINGS } | 162 // syncer::APP_SETTINGS } |
| 167 // pref_groups_[syncer::EXTENSIONS] = { syncer::EXTENSION_SETTINGS } | 163 // pref_groups_[syncer::EXTENSIONS] = { syncer::EXTENSION_SETTINGS } |
| 168 // etc. | 164 // etc. |
| 169 typedef std::map<syncer::ModelType, syncer::ModelTypeSet> PrefGroupsMap; | 165 typedef std::map<syncer::ModelType, syncer::ModelTypeSet> PrefGroupsMap; |
| 170 PrefGroupsMap pref_groups_; | 166 PrefGroupsMap pref_groups_; |
| 171 | 167 |
| 172 DISALLOW_COPY_AND_ASSIGN(SyncPrefs); | 168 DISALLOW_COPY_AND_ASSIGN(SyncPrefs); |
| 173 }; | 169 }; |
| 174 | 170 |
| 175 } // namespace browser_sync | 171 } // namespace browser_sync |
| 176 | 172 |
| 177 #endif // CHROME_BROWSER_SYNC_SYNC_PREFS_H_ | 173 #endif // COMPONENTS_SYNC_DRIVER_SYNC_PREFS_H_ |
| OLD | NEW |