| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ |
| 6 #define COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ | 6 #define COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "components/sync_driver/data_type_encryption_handler.h" | 12 #include "components/sync_driver/data_type_encryption_handler.h" |
| 13 #include "components/sync_driver/sync_service_observer.h" | 13 #include "components/sync_driver/sync_service_observer.h" |
| 14 #include "sync/internal_api/public/base/model_type.h" | 14 #include "sync/internal_api/public/base/model_type.h" |
| 15 | 15 |
| 16 class GoogleServiceAuthError; | 16 class GoogleServiceAuthError; |
| 17 | 17 |
| 18 namespace syncer { | 18 namespace syncer { |
| 19 class BaseTransaction; | 19 class BaseTransaction; |
| 20 struct UserShare; | 20 struct UserShare; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace sync_driver { | 23 namespace sync_driver { |
| 24 | 24 |
| 25 class DataTypeController; |
| 26 class LocalDeviceInfoProvider; |
| 25 class OpenTabsUIDelegate; | 27 class OpenTabsUIDelegate; |
| 26 | 28 |
| 27 class SyncService : public DataTypeEncryptionHandler { | 29 class SyncService : public DataTypeEncryptionHandler { |
| 28 public: | 30 public: |
| 29 // Used to specify the kind of passphrase with which sync data is encrypted. | 31 // Used to specify the kind of passphrase with which sync data is encrypted. |
| 30 enum PassphraseType { | 32 enum PassphraseType { |
| 31 IMPLICIT, // The user did not provide a custom passphrase for encryption. | 33 IMPLICIT, // The user did not provide a custom passphrase for encryption. |
| 32 // We implicitly use the GAIA password in such cases. | 34 // We implicitly use the GAIA password in such cases. |
| 33 EXPLICIT, // The user selected the "use custom passphrase" radio button | 35 EXPLICIT, // The user selected the "use custom passphrase" radio button |
| 34 // during sync setup and provided a passphrase. | 36 // during sync setup and provided a passphrase. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 virtual syncer::ModelTypeSet GetPreferredDataTypes() const = 0; | 113 virtual syncer::ModelTypeSet GetPreferredDataTypes() const = 0; |
| 112 | 114 |
| 113 // Called when a user chooses which data types to sync as part of the sync | 115 // Called when a user chooses which data types to sync as part of the sync |
| 114 // setup wizard. |sync_everything| represents whether they chose the | 116 // setup wizard. |sync_everything| represents whether they chose the |
| 115 // "keep everything synced" option; if true, |chosen_types| will be ignored | 117 // "keep everything synced" option; if true, |chosen_types| will be ignored |
| 116 // and all data types will be synced. |sync_everything| means "sync all | 118 // and all data types will be synced. |sync_everything| means "sync all |
| 117 // current and future data types." | 119 // current and future data types." |
| 118 virtual void OnUserChoseDatatypes(bool sync_everything, | 120 virtual void OnUserChoseDatatypes(bool sync_everything, |
| 119 syncer::ModelTypeSet chosen_types) = 0; | 121 syncer::ModelTypeSet chosen_types) = 0; |
| 120 | 122 |
| 121 // Overridden by tests. | |
| 122 // TODO(zea): Remove these and have the dtc's call directly into the SBH. | |
| 123 virtual void DeactivateDataType(syncer::ModelType type) = 0; | |
| 124 | |
| 125 // Called whe Sync has been setup by the user and can be started. | 123 // Called whe Sync has been setup by the user and can be started. |
| 126 virtual void SetSyncSetupCompleted() = 0; | 124 virtual void SetSyncSetupCompleted() = 0; |
| 127 | 125 |
| 128 // Returns true if initial sync setup is in progress (does not return true | 126 // Returns true if initial sync setup is in progress (does not return true |
| 129 // if the user is customizing sync after already completing setup once). | 127 // if the user is customizing sync after already completing setup once). |
| 130 // SyncService uses this to determine if it's OK to start syncing, or if the | 128 // SyncService uses this to determine if it's OK to start syncing, or if the |
| 131 // user is still setting up the initial sync configuration. | 129 // user is still setting up the initial sync configuration. |
| 132 virtual bool FirstSetupInProgress() const = 0; | 130 virtual bool FirstSetupInProgress() const = 0; |
| 133 | 131 |
| 134 // Called by the UI to notify the SyncService that UI is visible so it will | 132 // Called by the UI to notify the SyncService that UI is visible so it will |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 virtual base::Time GetExplicitPassphraseTime() const = 0; | 168 virtual base::Time GetExplicitPassphraseTime() const = 0; |
| 171 | 169 |
| 172 // Returns true if a secondary (explicit) passphrase is being used. It is not | 170 // Returns true if a secondary (explicit) passphrase is being used. It is not |
| 173 // legal to call this method before the backend is initialized. | 171 // legal to call this method before the backend is initialized. |
| 174 virtual bool IsUsingSecondaryPassphrase() const = 0; | 172 virtual bool IsUsingSecondaryPassphrase() const = 0; |
| 175 | 173 |
| 176 // Turns on encryption for all data. Callers must call OnUserChoseDatatypes() | 174 // Turns on encryption for all data. Callers must call OnUserChoseDatatypes() |
| 177 // after calling this to force the encryption to occur. | 175 // after calling this to force the encryption to occur. |
| 178 virtual void EnableEncryptEverything() = 0; | 176 virtual void EnableEncryptEverything() = 0; |
| 179 | 177 |
| 178 // Returns true if we are currently set to encrypt all the sync data. |
| 179 virtual bool EncryptEverythingEnabled() const = 0; |
| 180 |
| 180 // Asynchronously sets the passphrase to |passphrase| for encryption. |type| | 181 // Asynchronously sets the passphrase to |passphrase| for encryption. |type| |
| 181 // specifies whether the passphrase is a custom passphrase or the GAIA | 182 // specifies whether the passphrase is a custom passphrase or the GAIA |
| 182 // password being reused as a passphrase. | 183 // password being reused as a passphrase. |
| 183 // TODO(atwilson): Change this so external callers can only set an EXPLICIT | 184 // TODO(atwilson): Change this so external callers can only set an EXPLICIT |
| 184 // passphrase with this API. | 185 // passphrase with this API. |
| 185 virtual void SetEncryptionPassphrase(const std::string& passphrase, | 186 virtual void SetEncryptionPassphrase(const std::string& passphrase, |
| 186 PassphraseType type) = 0; | 187 PassphraseType type) = 0; |
| 187 | 188 |
| 188 // Asynchronously decrypts pending keys using |passphrase|. Returns false | 189 // Asynchronously decrypts pending keys using |passphrase|. Returns false |
| 189 // immediately if the passphrase could not be used to decrypt a locally cached | 190 // immediately if the passphrase could not be used to decrypt a locally cached |
| 190 // copy of encrypted keys; returns true otherwise. | 191 // copy of encrypted keys; returns true otherwise. |
| 191 virtual bool SetDecryptionPassphrase(const std::string& passphrase) | 192 virtual bool SetDecryptionPassphrase(const std::string& passphrase) |
| 192 WARN_UNUSED_RESULT = 0; | 193 WARN_UNUSED_RESULT = 0; |
| 193 | 194 |
| 194 // Checks whether the Cryptographer is ready to encrypt and decrypt updates | 195 // Checks whether the Cryptographer is ready to encrypt and decrypt updates |
| 195 // for sensitive data types. Caller must be holding a | 196 // for sensitive data types. Caller must be holding a |
| 196 // syncapi::BaseTransaction to ensure thread safety. | 197 // syncapi::BaseTransaction to ensure thread safety. |
| 197 virtual bool IsCryptographerReady( | 198 virtual bool IsCryptographerReady( |
| 198 const syncer::BaseTransaction* trans) const = 0; | 199 const syncer::BaseTransaction* trans) const = 0; |
| 199 | 200 |
| 200 // TODO(akalin): This is called mostly by ModelAssociators and | 201 // TODO(akalin): This is called mostly by ModelAssociators and |
| 201 // tests. Figure out how to pass the handle to the ModelAssociators | 202 // tests. Figure out how to pass the handle to the ModelAssociators |
| 202 // directly, figure out how to expose this to tests, and remove this | 203 // directly, figure out how to expose this to tests, and remove this |
| 203 // function. | 204 // function. |
| 204 virtual syncer::UserShare* GetUserShare() const = 0; | 205 virtual syncer::UserShare* GetUserShare() const = 0; |
| 205 | 206 |
| 207 // Returns DeviceInfo provider for the local device. |
| 208 virtual LocalDeviceInfoProvider* GetLocalDeviceInfoProvider() const = 0; |
| 209 |
| 210 // Registers a data type controller with the sync service. This |
| 211 // makes the data type controller available for use, it does not |
| 212 // enable or activate the synchronization of the data type (see |
| 213 // ActivateDataType). Takes ownership of the pointer. |
| 214 virtual void RegisterDataTypeController( |
| 215 DataTypeController* data_type_controller) = 0; |
| 216 |
| 217 // Called to re-enable a type disabled by DisableDatatype(..). Note, this does |
| 218 // not change the preferred state of a datatype, and is not persisted across |
| 219 // restarts. |
| 220 virtual void ReenableDatatype(syncer::ModelType type) = 0; |
| 221 |
| 222 // TODO(zea): Remove these and have the dtc's call directly into the SBH. |
| 223 virtual void DeactivateDataType(syncer::ModelType type) = 0; |
| 224 |
| 206 protected: | 225 protected: |
| 207 SyncService() {} | 226 SyncService() {} |
| 208 | 227 |
| 209 private: | 228 private: |
| 210 DISALLOW_COPY_AND_ASSIGN(SyncService); | 229 DISALLOW_COPY_AND_ASSIGN(SyncService); |
| 211 }; | 230 }; |
| 212 | 231 |
| 213 } // namespace sync_driver | 232 } // namespace sync_driver |
| 214 | 233 |
| 215 #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ | 234 #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ |
| OLD | NEW |