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_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/sync/backend_unrecoverable_error_handler.h" | 25 #include "chrome/browser/sync/backend_unrecoverable_error_handler.h" |
26 #include "chrome/browser/sync/backup_rollback_controller.h" | 26 #include "chrome/browser/sync/backup_rollback_controller.h" |
27 #include "chrome/browser/sync/glue/sync_backend_host.h" | 27 #include "chrome/browser/sync/glue/sync_backend_host.h" |
28 #include "chrome/browser/sync/protocol_event_observer.h" | 28 #include "chrome/browser/sync/protocol_event_observer.h" |
29 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" | 29 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" |
30 #include "chrome/browser/sync/startup_controller.h" | 30 #include "chrome/browser/sync/startup_controller.h" |
31 #include "chrome/browser/sync/sync_stopped_reporter.h" | 31 #include "chrome/browser/sync/sync_stopped_reporter.h" |
32 #include "components/keyed_service/core/keyed_service.h" | 32 #include "components/keyed_service/core/keyed_service.h" |
33 #include "components/signin/core/browser/signin_manager_base.h" | 33 #include "components/signin/core/browser/signin_manager_base.h" |
34 #include "components/sync_driver/data_type_controller.h" | 34 #include "components/sync_driver/data_type_controller.h" |
35 #include "components/sync_driver/data_type_encryption_handler.h" | |
36 #include "components/sync_driver/data_type_manager.h" | 35 #include "components/sync_driver/data_type_manager.h" |
37 #include "components/sync_driver/data_type_manager_observer.h" | 36 #include "components/sync_driver/data_type_manager_observer.h" |
38 #include "components/sync_driver/data_type_status_table.h" | 37 #include "components/sync_driver/data_type_status_table.h" |
39 #include "components/sync_driver/device_info_sync_service.h" | 38 #include "components/sync_driver/device_info_sync_service.h" |
40 #include "components/sync_driver/local_device_info_provider.h" | 39 #include "components/sync_driver/local_device_info_provider.h" |
41 #include "components/sync_driver/non_blocking_data_type_manager.h" | 40 #include "components/sync_driver/non_blocking_data_type_manager.h" |
42 #include "components/sync_driver/sync_frontend.h" | 41 #include "components/sync_driver/sync_frontend.h" |
43 #include "components/sync_driver/sync_prefs.h" | 42 #include "components/sync_driver/sync_prefs.h" |
44 #include "components/sync_driver/sync_service.h" | 43 #include "components/sync_driver/sync_service.h" |
45 #include "google_apis/gaia/google_service_auth_error.h" | 44 #include "google_apis/gaia/google_service_auth_error.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // SetSyncSetupCompleted() followed by SetSetupInProgress(false) - this will | 178 // SetSyncSetupCompleted() followed by SetSetupInProgress(false) - this will |
180 // tell the sync engine that setup is completed and it can begin downloading | 179 // tell the sync engine that setup is completed and it can begin downloading |
181 // data from the sync server. | 180 // data from the sync server. |
182 // | 181 // |
183 class ProfileSyncService : public sync_driver::SyncService, | 182 class ProfileSyncService : public sync_driver::SyncService, |
184 public sync_driver::SyncFrontend, | 183 public sync_driver::SyncFrontend, |
185 public sync_driver::SyncPrefObserver, | 184 public sync_driver::SyncPrefObserver, |
186 public sync_driver::DataTypeManagerObserver, | 185 public sync_driver::DataTypeManagerObserver, |
187 public syncer::UnrecoverableErrorHandler, | 186 public syncer::UnrecoverableErrorHandler, |
188 public KeyedService, | 187 public KeyedService, |
189 public sync_driver::DataTypeEncryptionHandler, | |
190 public OAuth2TokenService::Consumer, | 188 public OAuth2TokenService::Consumer, |
191 public OAuth2TokenService::Observer, | 189 public OAuth2TokenService::Observer, |
192 public SigninManagerBase::Observer { | 190 public SigninManagerBase::Observer { |
193 public: | 191 public: |
194 typedef browser_sync::SyncBackendHost::Status Status; | 192 typedef browser_sync::SyncBackendHost::Status Status; |
195 | 193 |
196 // Status of sync server connection, sync token and token request. | 194 // Status of sync server connection, sync token and token request. |
197 struct SyncTokenStatus { | 195 struct SyncTokenStatus { |
198 SyncTokenStatus(); | 196 SyncTokenStatus(); |
199 ~SyncTokenStatus(); | 197 ~SyncTokenStatus(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // types and clicking OK. | 229 // types and clicking OK. |
232 // Events resulting in the stoppage of sync service. | 230 // Events resulting in the stoppage of sync service. |
233 STOP_FROM_OPTIONS = 20, // Sync was stopped from Wrench->Options. | 231 STOP_FROM_OPTIONS = 20, // Sync was stopped from Wrench->Options. |
234 STOP_FROM_ADVANCED_DIALOG = 21, // Sync was stopped via advanced settings. | 232 STOP_FROM_ADVANCED_DIALOG = 21, // Sync was stopped via advanced settings. |
235 | 233 |
236 // Miscellaneous events caused by sync service. | 234 // Miscellaneous events caused by sync service. |
237 | 235 |
238 MAX_SYNC_EVENT_CODE | 236 MAX_SYNC_EVENT_CODE |
239 }; | 237 }; |
240 | 238 |
241 // Used to specify the kind of passphrase with which sync data is encrypted. | |
242 enum PassphraseType { | |
243 IMPLICIT, // The user did not provide a custom passphrase for encryption. | |
244 // We implicitly use the GAIA password in such cases. | |
245 EXPLICIT, // The user selected the "use custom passphrase" radio button | |
246 // during sync setup and provided a passphrase. | |
247 }; | |
248 | |
249 enum SyncStatusSummary { | 239 enum SyncStatusSummary { |
250 UNRECOVERABLE_ERROR, | 240 UNRECOVERABLE_ERROR, |
251 NOT_ENABLED, | 241 NOT_ENABLED, |
252 SETUP_INCOMPLETE, | 242 SETUP_INCOMPLETE, |
253 DATATYPES_NOT_INITIALIZED, | 243 DATATYPES_NOT_INITIALIZED, |
254 INITIALIZED, | 244 INITIALIZED, |
255 BACKUP_USER_DATA, | 245 BACKUP_USER_DATA, |
256 ROLLBACK_USER_DATA, | 246 ROLLBACK_USER_DATA, |
257 UNKNOWN_ERROR, | 247 UNKNOWN_ERROR, |
258 }; | 248 }; |
(...skipping 16 matching lines...) Expand all Loading... |
275 Profile* profile, | 265 Profile* profile, |
276 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper, | 266 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper, |
277 ProfileOAuth2TokenService* oauth2_token_service, | 267 ProfileOAuth2TokenService* oauth2_token_service, |
278 browser_sync::ProfileSyncServiceStartBehavior start_behavior); | 268 browser_sync::ProfileSyncServiceStartBehavior start_behavior); |
279 ~ProfileSyncService() override; | 269 ~ProfileSyncService() override; |
280 | 270 |
281 // Initializes the object. This must be called at most once, and | 271 // Initializes the object. This must be called at most once, and |
282 // immediately after an object of this class is constructed. | 272 // immediately after an object of this class is constructed. |
283 void Initialize(); | 273 void Initialize(); |
284 | 274 |
285 void SetSyncSetupCompleted(); | |
286 | |
287 // sync_driver::SyncService implementation | 275 // sync_driver::SyncService implementation |
288 bool HasSyncSetupCompleted() const override; | 276 bool HasSyncSetupCompleted() const override; |
289 bool SyncActive() const override; | 277 bool SyncActive() const override; |
| 278 bool IsSyncEnabledAndLoggedIn() override; |
| 279 void DisableForUser() override; |
| 280 void StopAndSuppress() override; |
| 281 void UnsuppressAndStart() override; |
290 syncer::ModelTypeSet GetActiveDataTypes() const override; | 282 syncer::ModelTypeSet GetActiveDataTypes() const override; |
| 283 syncer::ModelTypeSet GetPreferredDataTypes() const override; |
| 284 void OnUserChoseDatatypes(bool sync_everything, |
| 285 syncer::ModelTypeSet chosen_types) override; |
| 286 void SetSyncSetupCompleted() override; |
| 287 bool FirstSetupInProgress() const override; |
| 288 void SetSetupInProgress(bool setup_in_progress) override; |
| 289 bool setup_in_progress() const override; |
| 290 bool ConfigurationDone() const override; |
| 291 const GoogleServiceAuthError& GetAuthError() const override; |
| 292 bool HasUnrecoverableError() const override; |
| 293 bool backend_initialized() const override; |
| 294 bool IsPassphraseRequiredForDecryption() const override; |
| 295 base::Time GetExplicitPassphraseTime() const override; |
| 296 bool IsUsingSecondaryPassphrase() const override; |
| 297 void EnableEncryptEverything() override; |
| 298 void SetEncryptionPassphrase(const std::string& passphrase, |
| 299 PassphraseType type) override; |
| 300 bool SetDecryptionPassphrase(const std::string& passphrase) override |
| 301 WARN_UNUSED_RESULT; |
291 void AddObserver(sync_driver::SyncServiceObserver* observer) override; | 302 void AddObserver(sync_driver::SyncServiceObserver* observer) override; |
292 void RemoveObserver(sync_driver::SyncServiceObserver* observer) override; | 303 void RemoveObserver(sync_driver::SyncServiceObserver* observer) override; |
293 bool HasObserver( | 304 bool HasObserver( |
294 const sync_driver::SyncServiceObserver* observer) const override; | 305 const sync_driver::SyncServiceObserver* observer) const override; |
295 | 306 |
296 void AddProtocolEventObserver(browser_sync::ProtocolEventObserver* observer); | 307 void AddProtocolEventObserver(browser_sync::ProtocolEventObserver* observer); |
297 void RemoveProtocolEventObserver( | 308 void RemoveProtocolEventObserver( |
298 browser_sync::ProtocolEventObserver* observer); | 309 browser_sync::ProtocolEventObserver* observer); |
299 | 310 |
300 void AddTypeDebugInfoObserver(syncer::TypeDebugInfoObserver* observer); | 311 void AddTypeDebugInfoObserver(syncer::TypeDebugInfoObserver* observer); |
(...skipping 13 matching lines...) Expand all Loading... |
314 // | 325 // |
315 // These requests can live a long time and return when you least expect it. | 326 // These requests can live a long time and return when you least expect it. |
316 // For safety, the callback should be bound to some sort of WeakPtr<> or | 327 // For safety, the callback should be bound to some sort of WeakPtr<> or |
317 // scoped_refptr<>. | 328 // scoped_refptr<>. |
318 void GetAllNodes( | 329 void GetAllNodes( |
319 const base::Callback<void(scoped_ptr<base::ListValue>)>& callback); | 330 const base::Callback<void(scoped_ptr<base::ListValue>)>& callback); |
320 | 331 |
321 void RegisterAuthNotifications(); | 332 void RegisterAuthNotifications(); |
322 void UnregisterAuthNotifications(); | 333 void UnregisterAuthNotifications(); |
323 | 334 |
324 // Returns true if sync is enabled/not suppressed and the user is logged in. | |
325 // (being logged in does not mean that tokens are available - tokens may | |
326 // be missing because they have not loaded yet, or because they were deleted | |
327 // due to http://crbug.com/121755). | |
328 // Virtual to enable mocking in tests. | |
329 // TODO(tim): Remove this? Nothing in ProfileSyncService uses it, and outside | |
330 // callers use a seemingly arbitrary / redundant / bug prone combination of | |
331 // this method, IsSyncAccessible, and others. | |
332 virtual bool IsSyncEnabledAndLoggedIn(); | |
333 | |
334 // Return whether OAuth2 refresh token is loaded and available for the backend | 335 // Return whether OAuth2 refresh token is loaded and available for the backend |
335 // to start up. Virtual to enable mocking in tests. | 336 // to start up. Virtual to enable mocking in tests. |
336 virtual bool IsOAuthRefreshTokenAvailable(); | 337 virtual bool IsOAuthRefreshTokenAvailable(); |
337 | 338 |
338 // Registers a data type controller with the sync service. This | 339 // Registers a data type controller with the sync service. This |
339 // makes the data type controller available for use, it does not | 340 // makes the data type controller available for use, it does not |
340 // enable or activate the synchronization of the data type (see | 341 // enable or activate the synchronization of the data type (see |
341 // ActivateDataType). Takes ownership of the pointer. | 342 // ActivateDataType). Takes ownership of the pointer. |
342 void RegisterDataTypeController( | 343 void RegisterDataTypeController( |
343 sync_driver::DataTypeController* data_type_controller); | 344 sync_driver::DataTypeController* data_type_controller); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 virtual sync_driver::LocalDeviceInfoProvider* GetLocalDeviceInfoProvider(); | 379 virtual sync_driver::LocalDeviceInfoProvider* GetLocalDeviceInfoProvider(); |
379 | 380 |
380 // Returns synced devices tracker. | 381 // Returns synced devices tracker. |
381 virtual sync_driver::DeviceInfoTracker* GetDeviceInfoTracker() const; | 382 virtual sync_driver::DeviceInfoTracker* GetDeviceInfoTracker() const; |
382 | 383 |
383 // Fills state_map with a map of current data types that are possible to | 384 // Fills state_map with a map of current data types that are possible to |
384 // sync, as well as their states. | 385 // sync, as well as their states. |
385 void GetDataTypeControllerStates( | 386 void GetDataTypeControllerStates( |
386 sync_driver::DataTypeController::StateMap* state_map) const; | 387 sync_driver::DataTypeController::StateMap* state_map) const; |
387 | 388 |
388 // Disables sync for user. Use ShowLoginDialog to enable. | |
389 virtual void DisableForUser(); | |
390 | |
391 // Disables sync for the user and prevents it from starting on next restart. | 389 // Disables sync for the user and prevents it from starting on next restart. |
392 virtual void StopSyncingPermanently(); | 390 virtual void StopSyncingPermanently(); |
393 | 391 |
394 // SyncFrontend implementation. | 392 // SyncFrontend implementation. |
395 void OnBackendInitialized( | 393 void OnBackendInitialized( |
396 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 394 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
397 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 395 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
398 debug_info_listener, | 396 debug_info_listener, |
399 const std::string& cache_guid, | 397 const std::string& cache_guid, |
400 bool success) override; | 398 bool success) override; |
(...skipping 29 matching lines...) Expand all Loading... |
430 bool IsPassphraseRequired() const override; | 428 bool IsPassphraseRequired() const override; |
431 syncer::ModelTypeSet GetEncryptedDataTypes() const override; | 429 syncer::ModelTypeSet GetEncryptedDataTypes() const override; |
432 | 430 |
433 // SigninManagerBase::Observer implementation. | 431 // SigninManagerBase::Observer implementation. |
434 void GoogleSigninSucceeded(const std::string& account_id, | 432 void GoogleSigninSucceeded(const std::string& account_id, |
435 const std::string& username, | 433 const std::string& username, |
436 const std::string& password) override; | 434 const std::string& password) override; |
437 void GoogleSignedOut(const std::string& account_id, | 435 void GoogleSignedOut(const std::string& account_id, |
438 const std::string& username) override; | 436 const std::string& username) override; |
439 | 437 |
440 // Called when a user chooses which data types to sync as part of the sync | |
441 // setup wizard. |sync_everything| represents whether they chose the | |
442 // "keep everything synced" option; if true, |chosen_types| will be ignored | |
443 // and all data types will be synced. |sync_everything| means "sync all | |
444 // current and future data types." | |
445 virtual void OnUserChoseDatatypes(bool sync_everything, | |
446 syncer::ModelTypeSet chosen_types); | |
447 | |
448 // Get the sync status code. | 438 // Get the sync status code. |
449 SyncStatusSummary QuerySyncStatusSummary(); | 439 SyncStatusSummary QuerySyncStatusSummary(); |
450 | 440 |
451 // Get a description of the sync status for displaying in the user interface. | 441 // Get a description of the sync status for displaying in the user interface. |
452 std::string QuerySyncStatusSummaryString(); | 442 std::string QuerySyncStatusSummaryString(); |
453 | 443 |
454 // Initializes a struct of status indicators with data from the backend. | 444 // Initializes a struct of status indicators with data from the backend. |
455 // Returns false if the backend was not available for querying; in that case | 445 // Returns false if the backend was not available for querying; in that case |
456 // the struct will be filled with default data. | 446 // the struct will be filled with default data. |
457 virtual bool QueryDetailedSyncStatus( | 447 virtual bool QueryDetailedSyncStatus( |
458 browser_sync::SyncBackendHost::Status* result); | 448 browser_sync::SyncBackendHost::Status* result); |
459 | 449 |
460 virtual const GoogleServiceAuthError& GetAuthError() const; | |
461 | |
462 // Returns true if initial sync setup is in progress (does not return true | |
463 // if the user is customizing sync after already completing setup once). | |
464 // ProfileSyncService uses this to determine if it's OK to start syncing, or | |
465 // if the user is still setting up the initial sync configuration. | |
466 virtual bool FirstSetupInProgress() const; | |
467 | |
468 // Called by the UI to notify the ProfileSyncService that UI is visible so it | |
469 // will not start syncing. This tells sync whether it's safe to start | |
470 // downloading data types yet (we don't start syncing until after sync setup | |
471 // is complete). The UI calls this as soon as any part of the signin wizard is | |
472 // displayed (even just the login UI). | |
473 // If |setup_in_progress| is false, this also kicks the sync engine to ensure | |
474 // that data download starts. In this case, |ReconfigureDatatypeManager| will | |
475 // get triggered. | |
476 virtual void SetSetupInProgress(bool setup_in_progress); | |
477 | |
478 // Reconfigures the data type manager with the latest enabled types. | 450 // Reconfigures the data type manager with the latest enabled types. |
479 // Note: Does not initialize the backend if it is not already initialized. | 451 // Note: Does not initialize the backend if it is not already initialized. |
480 // This function needs to be called only after sync has been initialized | 452 // This function needs to be called only after sync has been initialized |
481 // (i.e.,only for reconfigurations). The reason we don't initialize the | 453 // (i.e.,only for reconfigurations). The reason we don't initialize the |
482 // backend is because if we had encountered an unrecoverable error we don't | 454 // backend is because if we had encountered an unrecoverable error we don't |
483 // want to startup once more. | 455 // want to startup once more. |
484 // This function is called by |SetSetupInProgress|. | 456 // This function is called by |SetSetupInProgress|. |
485 virtual void ReconfigureDatatypeManager(); | 457 virtual void ReconfigureDatatypeManager(); |
486 | 458 |
487 virtual bool HasUnrecoverableError() const; | |
488 const std::string& unrecoverable_error_message() { | 459 const std::string& unrecoverable_error_message() { |
489 return unrecoverable_error_message_; | 460 return unrecoverable_error_message_; |
490 } | 461 } |
491 tracked_objects::Location unrecoverable_error_location() { | 462 tracked_objects::Location unrecoverable_error_location() { |
492 return unrecoverable_error_location_; | 463 return unrecoverable_error_location_; |
493 } | 464 } |
494 | 465 |
495 // Returns true if OnPassphraseRequired has been called for decryption and | |
496 // we have an encrypted data type enabled. | |
497 virtual bool IsPassphraseRequiredForDecryption() const; | |
498 | |
499 syncer::PassphraseRequiredReason passphrase_required_reason() const { | 466 syncer::PassphraseRequiredReason passphrase_required_reason() const { |
500 return passphrase_required_reason_; | 467 return passphrase_required_reason_; |
501 } | 468 } |
502 | 469 |
503 // Returns a user-friendly string form of last synced time (in minutes). | 470 // Returns a user-friendly string form of last synced time (in minutes). |
504 virtual base::string16 GetLastSyncedTimeString() const; | 471 virtual base::string16 GetLastSyncedTimeString() const; |
505 | 472 |
506 // Returns a human readable string describing backend initialization state. | 473 // Returns a human readable string describing backend initialization state. |
507 std::string GetBackendInitializationStateString() const; | 474 std::string GetBackendInitializationStateString() const; |
508 | 475 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 // SyncPrefObserver implementation. | 563 // SyncPrefObserver implementation. |
597 void OnSyncManagedPrefChange(bool is_sync_managed) override; | 564 void OnSyncManagedPrefChange(bool is_sync_managed) override; |
598 | 565 |
599 // Changes which data types we're going to be syncing to |preferred_types|. | 566 // Changes which data types we're going to be syncing to |preferred_types|. |
600 // If it is running, the DataTypeManager will be instructed to reconfigure | 567 // If it is running, the DataTypeManager will be instructed to reconfigure |
601 // the sync backend so that exactly these datatypes are actively synced. See | 568 // the sync backend so that exactly these datatypes are actively synced. See |
602 // class comment for more on what it means for a datatype to be Preferred. | 569 // class comment for more on what it means for a datatype to be Preferred. |
603 virtual void ChangePreferredDataTypes( | 570 virtual void ChangePreferredDataTypes( |
604 syncer::ModelTypeSet preferred_types); | 571 syncer::ModelTypeSet preferred_types); |
605 | 572 |
606 // Returns the set of types which are preferred for enabling. This is a | |
607 // superset of the active types (see GetActiveDataTypes()). | |
608 virtual syncer::ModelTypeSet GetPreferredDataTypes() const; | |
609 | |
610 // Returns the set of directory types which are preferred for enabling. | 573 // Returns the set of directory types which are preferred for enabling. |
611 virtual syncer::ModelTypeSet GetPreferredDirectoryDataTypes() const; | 574 virtual syncer::ModelTypeSet GetPreferredDirectoryDataTypes() const; |
612 | 575 |
613 // Returns the set of off-thread types which are preferred for enabling. | 576 // Returns the set of off-thread types which are preferred for enabling. |
614 virtual syncer::ModelTypeSet GetPreferredNonBlockingDataTypes() const; | 577 virtual syncer::ModelTypeSet GetPreferredNonBlockingDataTypes() const; |
615 | 578 |
616 // Returns the set of types which are enforced programmatically and can not | 579 // Returns the set of types which are enforced programmatically and can not |
617 // be disabled by the user. | 580 // be disabled by the user. |
618 virtual syncer::ModelTypeSet GetForcedDataTypes() const; | 581 virtual syncer::ModelTypeSet GetForcedDataTypes() const; |
619 | 582 |
620 // Gets the set of all data types that could be allowed (the set that | 583 // Gets the set of all data types that could be allowed (the set that |
621 // should be advertised to the user). These will typically only change | 584 // should be advertised to the user). These will typically only change |
622 // via a command-line option. See class comment for more on what it means | 585 // via a command-line option. See class comment for more on what it means |
623 // for a datatype to be Registered. | 586 // for a datatype to be Registered. |
624 virtual syncer::ModelTypeSet GetRegisteredDataTypes() const; | 587 virtual syncer::ModelTypeSet GetRegisteredDataTypes() const; |
625 | 588 |
626 // Gets the set of directory types which could be allowed. | 589 // Gets the set of directory types which could be allowed. |
627 virtual syncer::ModelTypeSet GetRegisteredDirectoryDataTypes() const; | 590 virtual syncer::ModelTypeSet GetRegisteredDirectoryDataTypes() const; |
628 | 591 |
629 // Gets the set of off-thread types which could be allowed. | 592 // Gets the set of off-thread types which could be allowed. |
630 virtual syncer::ModelTypeSet GetRegisteredNonBlockingDataTypes() const; | 593 virtual syncer::ModelTypeSet GetRegisteredNonBlockingDataTypes() const; |
631 | 594 |
632 // Checks whether the Cryptographer is ready to encrypt and decrypt updates | 595 // Checks whether the Cryptographer is ready to encrypt and decrypt updates |
633 // for sensitive data types. Caller must be holding a | 596 // for sensitive data types. Caller must be holding a |
634 // syncapi::BaseTransaction to ensure thread safety. | 597 // syncapi::BaseTransaction to ensure thread safety. |
635 virtual bool IsCryptographerReady( | 598 virtual bool IsCryptographerReady( |
636 const syncer::BaseTransaction* trans) const; | 599 const syncer::BaseTransaction* trans) const; |
637 | 600 |
638 // Returns true if a secondary (explicit) passphrase is being used. It is not | |
639 // legal to call this method before the backend is initialized. | |
640 virtual bool IsUsingSecondaryPassphrase() const; | |
641 | |
642 // Returns the actual passphrase type being used for encryption. | 601 // Returns the actual passphrase type being used for encryption. |
643 virtual syncer::PassphraseType GetPassphraseType() const; | 602 virtual syncer::PassphraseType GetPassphraseType() const; |
644 | 603 |
645 // Returns the time the current explicit passphrase (if any), was set. | |
646 // If no secondary passphrase is in use, or no time is available, returns an | |
647 // unset base::Time. | |
648 virtual base::Time GetExplicitPassphraseTime() const; | |
649 | |
650 // Note about setting passphrases: There are different scenarios under which | 604 // Note about setting passphrases: There are different scenarios under which |
651 // we might want to apply a passphrase. It could be for first-time encryption, | 605 // we might want to apply a passphrase. It could be for first-time encryption, |
652 // re-encryption, or for decryption by clients that sign in at a later time. | 606 // re-encryption, or for decryption by clients that sign in at a later time. |
653 // In addition, encryption can either be done using a custom passphrase, or by | 607 // In addition, encryption can either be done using a custom passphrase, or by |
654 // reusing the GAIA password. Depending on what is happening in the system, | 608 // reusing the GAIA password. Depending on what is happening in the system, |
655 // callers should determine which of the two methods below must be used. | 609 // callers should determine which of the two methods below must be used. |
656 | 610 |
657 // Asynchronously sets the passphrase to |passphrase| for encryption. |type| | |
658 // specifies whether the passphrase is a custom passphrase or the GAIA | |
659 // password being reused as a passphrase. | |
660 // TODO(atwilson): Change this so external callers can only set an EXPLICIT | |
661 // passphrase with this API. | |
662 virtual void SetEncryptionPassphrase(const std::string& passphrase, | |
663 PassphraseType type); | |
664 | |
665 // Asynchronously decrypts pending keys using |passphrase|. Returns false | |
666 // immediately if the passphrase could not be used to decrypt a locally cached | |
667 // copy of encrypted keys; returns true otherwise. | |
668 virtual bool SetDecryptionPassphrase(const std::string& passphrase) | |
669 WARN_UNUSED_RESULT; | |
670 | |
671 // Returns true if encrypting all the sync data is allowed. If this method | 611 // Returns true if encrypting all the sync data is allowed. If this method |
672 // returns false, EnableEncryptEverything() should not be called. | 612 // returns false, EnableEncryptEverything() should not be called. |
673 virtual bool EncryptEverythingAllowed() const; | 613 virtual bool EncryptEverythingAllowed() const; |
674 | 614 |
675 // Sets whether encrypting all the sync data is allowed or not. | 615 // Sets whether encrypting all the sync data is allowed or not. |
676 virtual void SetEncryptEverythingAllowed(bool allowed); | 616 virtual void SetEncryptEverythingAllowed(bool allowed); |
677 | 617 |
678 // Turns on encryption for all data. Callers must call OnUserChoseDatatypes() | |
679 // after calling this to force the encryption to occur. | |
680 virtual void EnableEncryptEverything(); | |
681 | |
682 // Returns true if we are currently set to encrypt all the sync data. Note: | 618 // Returns true if we are currently set to encrypt all the sync data. Note: |
683 // this is based on the cryptographer's settings, so if the user has recently | 619 // this is based on the cryptographer's settings, so if the user has recently |
684 // requested encryption to be turned on, this may not be true yet. For that, | 620 // requested encryption to be turned on, this may not be true yet. For that, |
685 // encryption_pending() must be checked. | 621 // encryption_pending() must be checked. |
686 virtual bool EncryptEverythingEnabled() const; | 622 virtual bool EncryptEverythingEnabled() const; |
687 | 623 |
688 // Returns true if the syncer is waiting for new datatypes to be encrypted. | 624 // Returns true if the syncer is waiting for new datatypes to be encrypted. |
689 virtual bool encryption_pending() const; | 625 virtual bool encryption_pending() const; |
690 | 626 |
691 const GURL& sync_service_url() const { return sync_service_url_; } | 627 const GURL& sync_service_url() const { return sync_service_url_; } |
692 SigninManagerBase* signin() const; | 628 SigninManagerBase* signin() const; |
693 | 629 |
694 // Used by tests. | 630 // Used by tests. |
695 bool auto_start_enabled() const; | 631 bool auto_start_enabled() const; |
696 bool setup_in_progress() const; | |
697 | |
698 // Stops the sync backend and sets the flag for suppressing sync startup. | |
699 void StopAndSuppress(); | |
700 | |
701 // Resets the flag for suppressing sync startup and starts the sync backend. | |
702 virtual void UnsuppressAndStart(); | |
703 | 632 |
704 SyncErrorController* sync_error_controller() { | 633 SyncErrorController* sync_error_controller() { |
705 return sync_error_controller_.get(); | 634 return sync_error_controller_.get(); |
706 } | 635 } |
707 | 636 |
708 // TODO(sync): This is only used in tests. Can we remove it? | 637 // TODO(sync): This is only used in tests. Can we remove it? |
709 const sync_driver::DataTypeStatusTable& data_type_status_table() const; | 638 const sync_driver::DataTypeStatusTable& data_type_status_table() const; |
710 | 639 |
711 sync_driver::DataTypeManager::ConfigureStatus configure_status() { | 640 sync_driver::DataTypeManager::ConfigureStatus configure_status() { |
712 return configure_status_; | 641 return configure_status_; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 | 678 |
750 browser_sync::FaviconCache* GetFaviconCache(); | 679 browser_sync::FaviconCache* GetFaviconCache(); |
751 | 680 |
752 // Overrides the NetworkResources used for Sync connections. | 681 // Overrides the NetworkResources used for Sync connections. |
753 // This function takes ownership of |network_resources|. | 682 // This function takes ownership of |network_resources|. |
754 void OverrideNetworkResourcesForTest( | 683 void OverrideNetworkResourcesForTest( |
755 scoped_ptr<syncer::NetworkResources> network_resources); | 684 scoped_ptr<syncer::NetworkResources> network_resources); |
756 | 685 |
757 virtual bool IsDataTypeControllerRunning(syncer::ModelType type) const; | 686 virtual bool IsDataTypeControllerRunning(syncer::ModelType type) const; |
758 | 687 |
759 // Returns true if the SyncBackendHost has told us it's ready to accept | |
760 // changes. This should only be used for sync's internal configuration logic | |
761 // (such as deciding when to prompt for an encryption passphrase). | |
762 virtual bool backend_initialized() const; | |
763 | |
764 // Returns the current mode the backend is in. | 688 // Returns the current mode the backend is in. |
765 BackendMode backend_mode() const; | 689 BackendMode backend_mode() const; |
766 | 690 |
767 // Whether the data types active for the current mode have finished | |
768 // configuration. | |
769 bool ConfigurationDone() const; | |
770 | |
771 // Helpers for testing rollback. | 691 // Helpers for testing rollback. |
772 void SetBrowsingDataRemoverObserverForTesting( | 692 void SetBrowsingDataRemoverObserverForTesting( |
773 BrowsingDataRemover::Observer* observer); | 693 BrowsingDataRemover::Observer* observer); |
774 void SetClearingBrowseringDataForTesting(base::Callback< | 694 void SetClearingBrowseringDataForTesting(base::Callback< |
775 void(BrowsingDataRemover::Observer*, Profile*, base::Time, base::Time)> | 695 void(BrowsingDataRemover::Observer*, Profile*, base::Time, base::Time)> |
776 c); | 696 c); |
777 | 697 |
778 // Return the base URL of the Sync Server. | 698 // Return the base URL of the Sync Server. |
779 static GURL GetSyncServiceURL(const base::CommandLine& command_line); | 699 static GURL GetSyncServiceURL(const base::CommandLine& command_line); |
780 | 700 |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_; | 1081 base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_; |
1162 | 1082 |
1163 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 1083 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
1164 }; | 1084 }; |
1165 | 1085 |
1166 bool ShouldShowActionOnUI( | 1086 bool ShouldShowActionOnUI( |
1167 const syncer::SyncProtocolError& error); | 1087 const syncer::SyncProtocolError& error); |
1168 | 1088 |
1169 | 1089 |
1170 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 1090 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
OLD | NEW |