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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 virtual base::Time GetExplicitPassphraseTime() const = 0; | 168 virtual base::Time GetExplicitPassphraseTime() const = 0; |
167 | 169 |
168 // 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 |
169 // legal to call this method before the backend is initialized. | 171 // legal to call this method before the backend is initialized. |
170 virtual bool IsUsingSecondaryPassphrase() const = 0; | 172 virtual bool IsUsingSecondaryPassphrase() const = 0; |
171 | 173 |
172 // Turns on encryption for all data. Callers must call OnUserChoseDatatypes() | 174 // Turns on encryption for all data. Callers must call OnUserChoseDatatypes() |
173 // after calling this to force the encryption to occur. | 175 // after calling this to force the encryption to occur. |
174 virtual void EnableEncryptEverything() = 0; | 176 virtual void EnableEncryptEverything() = 0; |
175 | 177 |
178 // Returns true if we are currently set to encrypt all the sync data. | |
179 virtual bool EncryptEverythingEnabled() const = 0; | |
180 | |
176 // Asynchronously sets the passphrase to |passphrase| for encryption. |type| | 181 // Asynchronously sets the passphrase to |passphrase| for encryption. |type| |
177 // specifies whether the passphrase is a custom passphrase or the GAIA | 182 // specifies whether the passphrase is a custom passphrase or the GAIA |
178 // password being reused as a passphrase. | 183 // password being reused as a passphrase. |
179 // 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 |
180 // passphrase with this API. | 185 // passphrase with this API. |
181 virtual void SetEncryptionPassphrase(const std::string& passphrase, | 186 virtual void SetEncryptionPassphrase(const std::string& passphrase, |
182 PassphraseType type) = 0; | 187 PassphraseType type) = 0; |
183 | 188 |
184 // Asynchronously decrypts pending keys using |passphrase|. Returns false | 189 // Asynchronously decrypts pending keys using |passphrase|. Returns false |
185 // 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 |
186 // copy of encrypted keys; returns true otherwise. | 191 // copy of encrypted keys; returns true otherwise. |
187 virtual bool SetDecryptionPassphrase(const std::string& passphrase) | 192 virtual bool SetDecryptionPassphrase(const std::string& passphrase) |
188 WARN_UNUSED_RESULT = 0; | 193 WARN_UNUSED_RESULT = 0; |
189 | 194 |
190 // Checks whether the Cryptographer is ready to encrypt and decrypt updates | 195 // Checks whether the Cryptographer is ready to encrypt and decrypt updates |
191 // for sensitive data types. Caller must be holding a | 196 // for sensitive data types. Caller must be holding a |
192 // syncapi::BaseTransaction to ensure thread safety. | 197 // syncapi::BaseTransaction to ensure thread safety. |
193 virtual bool IsCryptographerReady( | 198 virtual bool IsCryptographerReady( |
194 const syncer::BaseTransaction* trans) const = 0; | 199 const syncer::BaseTransaction* trans) const = 0; |
195 | 200 |
196 // TODO(akalin): This is called mostly by ModelAssociators and | 201 // TODO(akalin): This is called mostly by ModelAssociators and |
197 // tests. Figure out how to pass the handle to the ModelAssociators | 202 // tests. Figure out how to pass the handle to the ModelAssociators |
198 // 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 |
199 // function. | 204 // function. |
200 virtual syncer::UserShare* GetUserShare() const = 0; | 205 virtual syncer::UserShare* GetUserShare() const = 0; |
201 | 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; | |
stanisc
2015/08/27 22:14:05
Right! I was going to do something like that to ma
Nicolas Zea
2015/08/27 23:37:16
Interesting, yeah, I agree a registrar that handle
| |
224 | |
202 protected: | 225 protected: |
203 SyncService() {} | 226 SyncService() {} |
204 | 227 |
205 private: | 228 private: |
206 DISALLOW_COPY_AND_ASSIGN(SyncService); | 229 DISALLOW_COPY_AND_ASSIGN(SyncService); |
207 }; | 230 }; |
208 | 231 |
209 } // namespace sync_driver | 232 } // namespace sync_driver |
210 | 233 |
211 #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ | 234 #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_H_ |
OLD | NEW |