| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 virtual void OnSyncCycleCompleted() OVERRIDE; | 259 virtual void OnSyncCycleCompleted() OVERRIDE; |
| 260 virtual void OnSyncConfigureRetry() OVERRIDE; | 260 virtual void OnSyncConfigureRetry() OVERRIDE; |
| 261 virtual void OnConnectionStatusChange( | 261 virtual void OnConnectionStatusChange( |
| 262 syncer::ConnectionStatus status) OVERRIDE; | 262 syncer::ConnectionStatus status) OVERRIDE; |
| 263 virtual void OnStopSyncingPermanently() OVERRIDE; | 263 virtual void OnStopSyncingPermanently() OVERRIDE; |
| 264 virtual void OnPassphraseRequired( | 264 virtual void OnPassphraseRequired( |
| 265 syncer::PassphraseRequiredReason reason, | 265 syncer::PassphraseRequiredReason reason, |
| 266 const sync_pb::EncryptedData& pending_keys) OVERRIDE; | 266 const sync_pb::EncryptedData& pending_keys) OVERRIDE; |
| 267 virtual void OnPassphraseAccepted() OVERRIDE; | 267 virtual void OnPassphraseAccepted() OVERRIDE; |
| 268 virtual void OnEncryptedTypesChanged( | 268 virtual void OnEncryptedTypesChanged( |
| 269 syncable::ModelTypeSet encrypted_types, | 269 syncer::ModelTypeSet encrypted_types, |
| 270 bool encrypt_everything) OVERRIDE; | 270 bool encrypt_everything) OVERRIDE; |
| 271 virtual void OnEncryptionComplete() OVERRIDE; | 271 virtual void OnEncryptionComplete() OVERRIDE; |
| 272 virtual void OnMigrationNeededForTypes( | 272 virtual void OnMigrationNeededForTypes( |
| 273 syncable::ModelTypeSet types) OVERRIDE; | 273 syncer::ModelTypeSet types) OVERRIDE; |
| 274 virtual void OnExperimentsChanged( | 274 virtual void OnExperimentsChanged( |
| 275 const syncer::Experiments& experiments) OVERRIDE; | 275 const syncer::Experiments& experiments) OVERRIDE; |
| 276 virtual void OnActionableError( | 276 virtual void OnActionableError( |
| 277 const syncer::SyncProtocolError& error) OVERRIDE; | 277 const syncer::SyncProtocolError& error) OVERRIDE; |
| 278 | 278 |
| 279 // Update the last auth error and notify observers of error state. | 279 // Update the last auth error and notify observers of error state. |
| 280 void UpdateAuthErrorState(const GoogleServiceAuthError& error); | 280 void UpdateAuthErrorState(const GoogleServiceAuthError& error); |
| 281 | 281 |
| 282 // Called when a user chooses which data types to sync as part of the sync | 282 // Called when a user chooses which data types to sync as part of the sync |
| 283 // setup wizard. |sync_everything| represents whether they chose the | 283 // setup wizard. |sync_everything| represents whether they chose the |
| 284 // "keep everything synced" option; if true, |chosen_types| will be ignored | 284 // "keep everything synced" option; if true, |chosen_types| will be ignored |
| 285 // and all data types will be synced. |sync_everything| means "sync all | 285 // and all data types will be synced. |sync_everything| means "sync all |
| 286 // current and future data types." | 286 // current and future data types." |
| 287 virtual void OnUserChoseDatatypes(bool sync_everything, | 287 virtual void OnUserChoseDatatypes(bool sync_everything, |
| 288 syncable::ModelTypeSet chosen_types); | 288 syncer::ModelTypeSet chosen_types); |
| 289 | 289 |
| 290 // Get various information for displaying in the user interface. | 290 // Get various information for displaying in the user interface. |
| 291 std::string QuerySyncStatusSummary(); | 291 std::string QuerySyncStatusSummary(); |
| 292 virtual browser_sync::SyncBackendHost::Status QueryDetailedSyncStatus(); | 292 virtual browser_sync::SyncBackendHost::Status QueryDetailedSyncStatus(); |
| 293 | 293 |
| 294 virtual const GoogleServiceAuthError& GetAuthError() const; | 294 virtual const GoogleServiceAuthError& GetAuthError() const; |
| 295 | 295 |
| 296 // Returns true if initial sync setup is in progress (does not return true | 296 // Returns true if initial sync setup is in progress (does not return true |
| 297 // if the user is customizing sync after already completing setup once). | 297 // if the user is customizing sync after already completing setup once). |
| 298 // ProfileSyncService uses this to determine if it's OK to start syncing, or | 298 // ProfileSyncService uses this to determine if it's OK to start syncing, or |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 bool IsManaged() const; | 370 bool IsManaged() const; |
| 371 | 371 |
| 372 // syncer::UnrecoverableErrorHandler implementation. | 372 // syncer::UnrecoverableErrorHandler implementation. |
| 373 virtual void OnUnrecoverableError( | 373 virtual void OnUnrecoverableError( |
| 374 const tracked_objects::Location& from_here, | 374 const tracked_objects::Location& from_here, |
| 375 const std::string& message) OVERRIDE; | 375 const std::string& message) OVERRIDE; |
| 376 | 376 |
| 377 // Called when a datatype wishes to disable itself due to having hit an | 377 // Called when a datatype wishes to disable itself due to having hit an |
| 378 // unrecoverable error. | 378 // unrecoverable error. |
| 379 virtual void DisableBrokenDatatype( | 379 virtual void DisableBrokenDatatype( |
| 380 syncable::ModelType type, | 380 syncer::ModelType type, |
| 381 const tracked_objects::Location& from_here, | 381 const tracked_objects::Location& from_here, |
| 382 std::string message); | 382 std::string message); |
| 383 | 383 |
| 384 // The functions below (until ActivateDataType()) should only be | 384 // The functions below (until ActivateDataType()) should only be |
| 385 // called if sync_initialized() is true. | 385 // called if sync_initialized() is true. |
| 386 | 386 |
| 387 // TODO(akalin): This is called mostly by ModelAssociators and | 387 // TODO(akalin): This is called mostly by ModelAssociators and |
| 388 // tests. Figure out how to pass the handle to the ModelAssociators | 388 // tests. Figure out how to pass the handle to the ModelAssociators |
| 389 // directly, figure out how to expose this to tests, and remove this | 389 // directly, figure out how to expose this to tests, and remove this |
| 390 // function. | 390 // function. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 417 // dpending on the type's current status. | 417 // dpending on the type's current status. |
| 418 // | 418 // |
| 419 // This function is used by sync_ui_util.cc to help populate the about:sync | 419 // This function is used by sync_ui_util.cc to help populate the about:sync |
| 420 // page. It returns a ListValue rather than a DictionaryValye in part to make | 420 // page. It returns a ListValue rather than a DictionaryValye in part to make |
| 421 // it easier to iterate over its elements when constructing that page. | 421 // it easier to iterate over its elements when constructing that page. |
| 422 Value* GetTypeStatusMap() const; | 422 Value* GetTypeStatusMap() const; |
| 423 | 423 |
| 424 // Overridden by tests. | 424 // Overridden by tests. |
| 425 // TODO(zea): Remove these and have the dtc's call directly into the SBH. | 425 // TODO(zea): Remove these and have the dtc's call directly into the SBH. |
| 426 virtual void ActivateDataType( | 426 virtual void ActivateDataType( |
| 427 syncable::ModelType type, syncer::ModelSafeGroup group, | 427 syncer::ModelType type, syncer::ModelSafeGroup group, |
| 428 browser_sync::ChangeProcessor* change_processor); | 428 browser_sync::ChangeProcessor* change_processor); |
| 429 virtual void DeactivateDataType(syncable::ModelType type); | 429 virtual void DeactivateDataType(syncer::ModelType type); |
| 430 | 430 |
| 431 // SyncPrefObserver implementation. | 431 // SyncPrefObserver implementation. |
| 432 virtual void OnSyncManagedPrefChange(bool is_sync_managed) OVERRIDE; | 432 virtual void OnSyncManagedPrefChange(bool is_sync_managed) OVERRIDE; |
| 433 | 433 |
| 434 // content::NotificationObserver implementation. | 434 // content::NotificationObserver implementation. |
| 435 virtual void Observe(int type, | 435 virtual void Observe(int type, |
| 436 const content::NotificationSource& source, | 436 const content::NotificationSource& source, |
| 437 const content::NotificationDetails& details) OVERRIDE; | 437 const content::NotificationDetails& details) OVERRIDE; |
| 438 | 438 |
| 439 // Changes which data types we're going to be syncing to |preferred_types|. | 439 // Changes which data types we're going to be syncing to |preferred_types|. |
| 440 // If it is running, the DataTypeManager will be instructed to reconfigure | 440 // If it is running, the DataTypeManager will be instructed to reconfigure |
| 441 // the sync backend so that exactly these datatypes are actively synced. See | 441 // the sync backend so that exactly these datatypes are actively synced. See |
| 442 // class comment for more on what it means for a datatype to be Preferred. | 442 // class comment for more on what it means for a datatype to be Preferred. |
| 443 virtual void ChangePreferredDataTypes( | 443 virtual void ChangePreferredDataTypes( |
| 444 syncable::ModelTypeSet preferred_types); | 444 syncer::ModelTypeSet preferred_types); |
| 445 | 445 |
| 446 // Get the set of currently enabled data types (as chosen or configured by | 446 // Get the set of currently enabled data types (as chosen or configured by |
| 447 // the user). See class comment for more on what it means for a datatype | 447 // the user). See class comment for more on what it means for a datatype |
| 448 // to be Preferred. | 448 // to be Preferred. |
| 449 virtual syncable::ModelTypeSet GetPreferredDataTypes() const; | 449 virtual syncer::ModelTypeSet GetPreferredDataTypes() const; |
| 450 | 450 |
| 451 // Gets the set of all data types that could be allowed (the set that | 451 // Gets the set of all data types that could be allowed (the set that |
| 452 // should be advertised to the user). These will typically only change | 452 // should be advertised to the user). These will typically only change |
| 453 // via a command-line option. See class comment for more on what it means | 453 // via a command-line option. See class comment for more on what it means |
| 454 // for a datatype to be Registered. | 454 // for a datatype to be Registered. |
| 455 virtual syncable::ModelTypeSet GetRegisteredDataTypes() const; | 455 virtual syncer::ModelTypeSet GetRegisteredDataTypes() const; |
| 456 | 456 |
| 457 // Checks whether the Cryptographer is ready to encrypt and decrypt updates | 457 // Checks whether the Cryptographer is ready to encrypt and decrypt updates |
| 458 // for sensitive data types. Caller must be holding a | 458 // for sensitive data types. Caller must be holding a |
| 459 // syncapi::BaseTransaction to ensure thread safety. | 459 // syncapi::BaseTransaction to ensure thread safety. |
| 460 virtual bool IsCryptographerReady( | 460 virtual bool IsCryptographerReady( |
| 461 const syncer::BaseTransaction* trans) const; | 461 const syncer::BaseTransaction* trans) const; |
| 462 | 462 |
| 463 // Returns true if a secondary passphrase is being used. It is not legal | 463 // Returns true if a secondary passphrase is being used. It is not legal |
| 464 // to call this method before the backend is initialized. | 464 // to call this method before the backend is initialized. |
| 465 virtual bool IsUsingSecondaryPassphrase() const; | 465 virtual bool IsUsingSecondaryPassphrase() const; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 490 virtual void EnableEncryptEverything(); | 490 virtual void EnableEncryptEverything(); |
| 491 | 491 |
| 492 // Returns true if we are currently set to encrypt all the sync data. Note: | 492 // Returns true if we are currently set to encrypt all the sync data. Note: |
| 493 // this is based on the cryptographer's settings, so if the user has recently | 493 // this is based on the cryptographer's settings, so if the user has recently |
| 494 // requested encryption to be turned on, this may not be true yet. For that, | 494 // requested encryption to be turned on, this may not be true yet. For that, |
| 495 // encryption_pending() must be checked. | 495 // encryption_pending() must be checked. |
| 496 virtual bool EncryptEverythingEnabled() const; | 496 virtual bool EncryptEverythingEnabled() const; |
| 497 | 497 |
| 498 // Fills |encrypted_types| with the set of currently encrypted types. Does | 498 // Fills |encrypted_types| with the set of currently encrypted types. Does |
| 499 // not account for types pending encryption. | 499 // not account for types pending encryption. |
| 500 virtual syncable::ModelTypeSet GetEncryptedDataTypes() const; | 500 virtual syncer::ModelTypeSet GetEncryptedDataTypes() const; |
| 501 | 501 |
| 502 // Returns true if the syncer is waiting for new datatypes to be encrypted. | 502 // Returns true if the syncer is waiting for new datatypes to be encrypted. |
| 503 virtual bool encryption_pending() const; | 503 virtual bool encryption_pending() const; |
| 504 | 504 |
| 505 // Returns whether processing changes is allowed. Check this before doing | 505 // Returns whether processing changes is allowed. Check this before doing |
| 506 // any model-modifying operations. | 506 // any model-modifying operations. |
| 507 bool ShouldPushChanges(); | 507 bool ShouldPushChanges(); |
| 508 | 508 |
| 509 const GURL& sync_service_url() const { return sync_service_url_; } | 509 const GURL& sync_service_url() const { return sync_service_url_; } |
| 510 bool auto_start_enabled() const { return auto_start_enabled_; } | 510 bool auto_start_enabled() const { return auto_start_enabled_; } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 | 638 |
| 639 void NotifyObservers(); | 639 void NotifyObservers(); |
| 640 | 640 |
| 641 void ClearStaleErrors(); | 641 void ClearStaleErrors(); |
| 642 | 642 |
| 643 void ClearUnrecoverableError(); | 643 void ClearUnrecoverableError(); |
| 644 | 644 |
| 645 // About-flags experiment names for datatypes that aren't enabled by default | 645 // About-flags experiment names for datatypes that aren't enabled by default |
| 646 // yet. | 646 // yet. |
| 647 static std::string GetExperimentNameForDataType( | 647 static std::string GetExperimentNameForDataType( |
| 648 syncable::ModelType data_type); | 648 syncer::ModelType data_type); |
| 649 | 649 |
| 650 // Create and register a new datatype controller. | 650 // Create and register a new datatype controller. |
| 651 void RegisterNewDataType(syncable::ModelType data_type); | 651 void RegisterNewDataType(syncer::ModelType data_type); |
| 652 | 652 |
| 653 // Helper method to process SyncConfigureDone after unwinding the stack that | 653 // Helper method to process SyncConfigureDone after unwinding the stack that |
| 654 // originally posted this SyncConfigureDone. | 654 // originally posted this SyncConfigureDone. |
| 655 void OnSyncConfigureDone( | 655 void OnSyncConfigureDone( |
| 656 browser_sync::DataTypeManager::ConfigureResult result); | 656 browser_sync::DataTypeManager::ConfigureResult result); |
| 657 | 657 |
| 658 // Reconfigures the data type manager with the latest enabled types. | 658 // Reconfigures the data type manager with the latest enabled types. |
| 659 // Note: Does not initialize the backend if it is not already initialized. | 659 // Note: Does not initialize the backend if it is not already initialized. |
| 660 // This function needs to be called only after sync has been initialized | 660 // This function needs to be called only after sync has been initialized |
| 661 // (i.e.,only for reconfigurations). The reason we don't initialize the | 661 // (i.e.,only for reconfigurations). The reason we don't initialize the |
| 662 // backend is because if we had encountered an unrecoverable error we don't | 662 // backend is because if we had encountered an unrecoverable error we don't |
| 663 // want to startup once more. | 663 // want to startup once more. |
| 664 virtual void ReconfigureDatatypeManager(); | 664 virtual void ReconfigureDatatypeManager(); |
| 665 | 665 |
| 666 // Called when the user changes the sync configuration, to update the UMA | 666 // Called when the user changes the sync configuration, to update the UMA |
| 667 // stats. | 667 // stats. |
| 668 void UpdateSelectedTypesHistogram( | 668 void UpdateSelectedTypesHistogram( |
| 669 bool sync_everything, | 669 bool sync_everything, |
| 670 const syncable::ModelTypeSet chosen_types) const; | 670 const syncer::ModelTypeSet chosen_types) const; |
| 671 | 671 |
| 672 #if defined(OS_CHROMEOS) | 672 #if defined(OS_CHROMEOS) |
| 673 // Refresh spare sync bootstrap token for re-enabling the sync service. | 673 // Refresh spare sync bootstrap token for re-enabling the sync service. |
| 674 // Called on successful sign-in notifications. | 674 // Called on successful sign-in notifications. |
| 675 void RefreshSpareBootstrapToken(const std::string& passphrase); | 675 void RefreshSpareBootstrapToken(const std::string& passphrase); |
| 676 #endif | 676 #endif |
| 677 | 677 |
| 678 // Internal unrecoverable error handler. Used to track error reason via | 678 // Internal unrecoverable error handler. Used to track error reason via |
| 679 // Sync.UnrecoverableErrors histogram. | 679 // Sync.UnrecoverableErrors histogram. |
| 680 void OnInternalUnrecoverableError(const tracked_objects::Location& from_here, | 680 void OnInternalUnrecoverableError(const tracked_objects::Location& from_here, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 bool expect_sync_configuration_aborted_; | 746 bool expect_sync_configuration_aborted_; |
| 747 | 747 |
| 748 // Sometimes we need to temporarily hold on to a passphrase because we don't | 748 // Sometimes we need to temporarily hold on to a passphrase because we don't |
| 749 // yet have a backend to send it to. This happens during initialization as | 749 // yet have a backend to send it to. This happens during initialization as |
| 750 // we don't StartUp until we have a valid token, which happens after valid | 750 // we don't StartUp until we have a valid token, which happens after valid |
| 751 // credentials were provided. | 751 // credentials were provided. |
| 752 std::string cached_passphrase_; | 752 std::string cached_passphrase_; |
| 753 | 753 |
| 754 // The current set of encrypted types. Always a superset of | 754 // The current set of encrypted types. Always a superset of |
| 755 // syncer::Cryptographer::SensitiveTypes(). | 755 // syncer::Cryptographer::SensitiveTypes(). |
| 756 syncable::ModelTypeSet encrypted_types_; | 756 syncer::ModelTypeSet encrypted_types_; |
| 757 | 757 |
| 758 // Whether we want to encrypt everything. | 758 // Whether we want to encrypt everything. |
| 759 bool encrypt_everything_; | 759 bool encrypt_everything_; |
| 760 | 760 |
| 761 // Whether we're waiting for an attempt to encryption all sync data to | 761 // Whether we're waiting for an attempt to encryption all sync data to |
| 762 // complete. We track this at this layer in order to allow the user to cancel | 762 // complete. We track this at this layer in order to allow the user to cancel |
| 763 // if they e.g. don't remember their explicit passphrase. | 763 // if they e.g. don't remember their explicit passphrase. |
| 764 bool encryption_pending_; | 764 bool encryption_pending_; |
| 765 | 765 |
| 766 // If true, we want to automatically start sync signin whenever we have | 766 // If true, we want to automatically start sync signin whenever we have |
| (...skipping 27 matching lines...) Expand all Loading... |
| 794 syncer::Experiments current_experiments; | 794 syncer::Experiments current_experiments; |
| 795 | 795 |
| 796 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 796 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 797 }; | 797 }; |
| 798 | 798 |
| 799 bool ShouldShowActionOnUI( | 799 bool ShouldShowActionOnUI( |
| 800 const syncer::SyncProtocolError& error); | 800 const syncer::SyncProtocolError& error); |
| 801 | 801 |
| 802 | 802 |
| 803 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 803 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |