| 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 #include "chrome/browser/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 #include "sync/internal_api/public/util/experiments.h" | 61 #include "sync/internal_api/public/util/experiments.h" |
| 62 #include "sync/js/js_arg_list.h" | 62 #include "sync/js/js_arg_list.h" |
| 63 #include "sync/js/js_event_details.h" | 63 #include "sync/js/js_event_details.h" |
| 64 #include "sync/util/cryptographer.h" | 64 #include "sync/util/cryptographer.h" |
| 65 #include "ui/base/l10n/l10n_util.h" | 65 #include "ui/base/l10n/l10n_util.h" |
| 66 | 66 |
| 67 using browser_sync::ChangeProcessor; | 67 using browser_sync::ChangeProcessor; |
| 68 using browser_sync::DataTypeController; | 68 using browser_sync::DataTypeController; |
| 69 using browser_sync::DataTypeManager; | 69 using browser_sync::DataTypeManager; |
| 70 using browser_sync::SyncBackendHost; | 70 using browser_sync::SyncBackendHost; |
| 71 using csync::JsBackend; | 71 using syncer::JsBackend; |
| 72 using csync::JsController; | 72 using syncer::JsController; |
| 73 using csync::JsEventDetails; | 73 using syncer::JsEventDetails; |
| 74 using csync::JsEventHandler; | 74 using syncer::JsEventHandler; |
| 75 using csync::SyncProtocolError; | 75 using syncer::SyncProtocolError; |
| 76 using csync::WeakHandle; | 76 using syncer::WeakHandle; |
| 77 using csync::SyncCredentials; | 77 using syncer::SyncCredentials; |
| 78 | 78 |
| 79 typedef GoogleServiceAuthError AuthError; | 79 typedef GoogleServiceAuthError AuthError; |
| 80 | 80 |
| 81 const char* ProfileSyncService::kSyncServerUrl = | 81 const char* ProfileSyncService::kSyncServerUrl = |
| 82 "https://clients4.google.com/chrome-sync"; | 82 "https://clients4.google.com/chrome-sync"; |
| 83 | 83 |
| 84 const char* ProfileSyncService::kDevServerUrl = | 84 const char* ProfileSyncService::kDevServerUrl = |
| 85 "https://clients4.google.com/chrome-sync/dev"; | 85 "https://clients4.google.com/chrome-sync/dev"; |
| 86 | 86 |
| 87 static const int kSyncClearDataTimeoutInSeconds = 60; // 1 minute. | 87 static const int kSyncClearDataTimeoutInSeconds = 60; // 1 minute. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 98 // Helper to check if the given token service is relevant for sync. | 98 // Helper to check if the given token service is relevant for sync. |
| 99 static bool IsTokenServiceRelevant(const std::string& service) { | 99 static bool IsTokenServiceRelevant(const std::string& service) { |
| 100 for (int i = 0; i < kRelevantTokenServicesCount; ++i) { | 100 for (int i = 0; i < kRelevantTokenServicesCount; ++i) { |
| 101 if (service == kRelevantTokenServices[i]) | 101 if (service == kRelevantTokenServices[i]) |
| 102 return true; | 102 return true; |
| 103 } | 103 } |
| 104 return false; | 104 return false; |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool ShouldShowActionOnUI( | 107 bool ShouldShowActionOnUI( |
| 108 const csync::SyncProtocolError& error) { | 108 const syncer::SyncProtocolError& error) { |
| 109 return (error.action != csync::UNKNOWN_ACTION && | 109 return (error.action != syncer::UNKNOWN_ACTION && |
| 110 error.action != csync::DISABLE_SYNC_ON_CLIENT); | 110 error.action != syncer::DISABLE_SYNC_ON_CLIENT); |
| 111 } | 111 } |
| 112 | 112 |
| 113 ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory, | 113 ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory, |
| 114 Profile* profile, | 114 Profile* profile, |
| 115 SigninManager* signin_manager, | 115 SigninManager* signin_manager, |
| 116 StartBehavior start_behavior) | 116 StartBehavior start_behavior) |
| 117 : last_auth_error_(AuthError::None()), | 117 : last_auth_error_(AuthError::None()), |
| 118 passphrase_required_reason_(csync::REASON_PASSPHRASE_NOT_REQUIRED), | 118 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED), |
| 119 factory_(factory), | 119 factory_(factory), |
| 120 profile_(profile), | 120 profile_(profile), |
| 121 // |profile| may be NULL in unit tests. | 121 // |profile| may be NULL in unit tests. |
| 122 sync_prefs_(profile_ ? profile_->GetPrefs() : NULL), | 122 sync_prefs_(profile_ ? profile_->GetPrefs() : NULL), |
| 123 invalidator_storage_(profile_ ? profile_->GetPrefs(): NULL), | 123 invalidator_storage_(profile_ ? profile_->GetPrefs(): NULL), |
| 124 sync_service_url_(kDevServerUrl), | 124 sync_service_url_(kDevServerUrl), |
| 125 backend_initialized_(false), | 125 backend_initialized_(false), |
| 126 is_auth_in_progress_(false), | 126 is_auth_in_progress_(false), |
| 127 signin_(signin_manager), | 127 signin_(signin_manager), |
| 128 unrecoverable_error_reason_(ERROR_REASON_UNSET), | 128 unrecoverable_error_reason_(ERROR_REASON_UNSET), |
| 129 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 129 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 130 expect_sync_configuration_aborted_(false), | 130 expect_sync_configuration_aborted_(false), |
| 131 encrypted_types_(csync::Cryptographer::SensitiveTypes()), | 131 encrypted_types_(syncer::Cryptographer::SensitiveTypes()), |
| 132 encrypt_everything_(false), | 132 encrypt_everything_(false), |
| 133 encryption_pending_(false), | 133 encryption_pending_(false), |
| 134 auto_start_enabled_(start_behavior == AUTO_START), | 134 auto_start_enabled_(start_behavior == AUTO_START), |
| 135 failed_datatypes_handler_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 135 failed_datatypes_handler_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 136 configure_status_(DataTypeManager::UNKNOWN), | 136 configure_status_(DataTypeManager::UNKNOWN), |
| 137 setup_in_progress_(false) { | 137 setup_in_progress_(false) { |
| 138 #if defined(OS_ANDROID) | 138 #if defined(OS_ANDROID) |
| 139 chrome::VersionInfo version_info; | 139 chrome::VersionInfo version_info; |
| 140 if (version_info.IsOfficialBuild()) { | 140 if (version_info.IsOfficialBuild()) { |
| 141 sync_service_url_ = GURL(kSyncServerUrl); | 141 sync_service_url_ = GURL(kSyncServerUrl); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 registrar_.Remove( | 469 registrar_.Remove( |
| 470 this, | 470 this, |
| 471 chrome::NOTIFICATION_SYNC_CONFIGURE_BLOCKED, | 471 chrome::NOTIFICATION_SYNC_CONFIGURE_BLOCKED, |
| 472 content::Source<DataTypeManager>(data_type_manager_.get())); | 472 content::Source<DataTypeManager>(data_type_manager_.get())); |
| 473 data_type_manager_.reset(); | 473 data_type_manager_.reset(); |
| 474 } | 474 } |
| 475 | 475 |
| 476 // Shutdown the migrator before the backend to ensure it doesn't pull a null | 476 // Shutdown the migrator before the backend to ensure it doesn't pull a null |
| 477 // snapshot. | 477 // snapshot. |
| 478 migrator_.reset(); | 478 migrator_.reset(); |
| 479 sync_js_controller_.AttachJsBackend(WeakHandle<csync::JsBackend>()); | 479 sync_js_controller_.AttachJsBackend(WeakHandle<syncer::JsBackend>()); |
| 480 | 480 |
| 481 // Move aside the backend so nobody else tries to use it while we are | 481 // Move aside the backend so nobody else tries to use it while we are |
| 482 // shutting it down. | 482 // shutting it down. |
| 483 scoped_ptr<SyncBackendHost> doomed_backend(backend_.release()); | 483 scoped_ptr<SyncBackendHost> doomed_backend(backend_.release()); |
| 484 if (doomed_backend.get()) { | 484 if (doomed_backend.get()) { |
| 485 doomed_backend->Shutdown(sync_disabled); | 485 doomed_backend->Shutdown(sync_disabled); |
| 486 | 486 |
| 487 doomed_backend.reset(); | 487 doomed_backend.reset(); |
| 488 } | 488 } |
| 489 base::TimeDelta shutdown_time = base::Time::Now() - shutdown_start_time; | 489 base::TimeDelta shutdown_time = base::Time::Now() - shutdown_start_time; |
| 490 UMA_HISTOGRAM_TIMES("Sync.Shutdown.BackendDestroyedTime", shutdown_time); | 490 UMA_HISTOGRAM_TIMES("Sync.Shutdown.BackendDestroyedTime", shutdown_time); |
| 491 | 491 |
| 492 weak_factory_.InvalidateWeakPtrs(); | 492 weak_factory_.InvalidateWeakPtrs(); |
| 493 | 493 |
| 494 // Clear various flags. | 494 // Clear various flags. |
| 495 expect_sync_configuration_aborted_ = false; | 495 expect_sync_configuration_aborted_ = false; |
| 496 is_auth_in_progress_ = false; | 496 is_auth_in_progress_ = false; |
| 497 backend_initialized_ = false; | 497 backend_initialized_ = false; |
| 498 cached_passphrase_.clear(); | 498 cached_passphrase_.clear(); |
| 499 encryption_pending_ = false; | 499 encryption_pending_ = false; |
| 500 encrypt_everything_ = false; | 500 encrypt_everything_ = false; |
| 501 encrypted_types_ = csync::Cryptographer::SensitiveTypes(); | 501 encrypted_types_ = syncer::Cryptographer::SensitiveTypes(); |
| 502 passphrase_required_reason_ = csync::REASON_PASSPHRASE_NOT_REQUIRED; | 502 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; |
| 503 last_auth_error_ = GoogleServiceAuthError::None(); | 503 last_auth_error_ = GoogleServiceAuthError::None(); |
| 504 | 504 |
| 505 if (sync_global_error_.get()) { | 505 if (sync_global_error_.get()) { |
| 506 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( | 506 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( |
| 507 sync_global_error_.get()); | 507 sync_global_error_.get()); |
| 508 RemoveObserver(sync_global_error_.get()); | 508 RemoveObserver(sync_global_error_.get()); |
| 509 sync_global_error_.reset(NULL); | 509 sync_global_error_.reset(NULL); |
| 510 } | 510 } |
| 511 } | 511 } |
| 512 | 512 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 if (data_type_controllers_.count(data_type) > 0) | 576 if (data_type_controllers_.count(data_type) > 0) |
| 577 return; | 577 return; |
| 578 NOTREACHED(); | 578 NOTREACHED(); |
| 579 } | 579 } |
| 580 | 580 |
| 581 // An invariant has been violated. Transition to an error state where we try | 581 // An invariant has been violated. Transition to an error state where we try |
| 582 // to do as little work as possible, to avoid further corruption or crashes. | 582 // to do as little work as possible, to avoid further corruption or crashes. |
| 583 void ProfileSyncService::OnUnrecoverableError( | 583 void ProfileSyncService::OnUnrecoverableError( |
| 584 const tracked_objects::Location& from_here, | 584 const tracked_objects::Location& from_here, |
| 585 const std::string& message) { | 585 const std::string& message) { |
| 586 // Unrecoverable errors that arrive via the csync::UnrecoverableErrorHandler | 586 // Unrecoverable errors that arrive via the syncer::UnrecoverableErrorHandler |
| 587 // interface are assumed to originate within the syncer. | 587 // interface are assumed to originate within the syncer. |
| 588 unrecoverable_error_reason_ = ERROR_REASON_SYNCER; | 588 unrecoverable_error_reason_ = ERROR_REASON_SYNCER; |
| 589 OnUnrecoverableErrorImpl(from_here, message, true); | 589 OnUnrecoverableErrorImpl(from_here, message, true); |
| 590 } | 590 } |
| 591 | 591 |
| 592 void ProfileSyncService::OnUnrecoverableErrorImpl( | 592 void ProfileSyncService::OnUnrecoverableErrorImpl( |
| 593 const tracked_objects::Location& from_here, | 593 const tracked_objects::Location& from_here, |
| 594 const std::string& message, | 594 const std::string& message, |
| 595 bool delete_sync_database) { | 595 bool delete_sync_database) { |
| 596 DCHECK(HasUnrecoverableError()); | 596 DCHECK(HasUnrecoverableError()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 614 } | 614 } |
| 615 | 615 |
| 616 void ProfileSyncService::DisableBrokenDatatype( | 616 void ProfileSyncService::DisableBrokenDatatype( |
| 617 syncable::ModelType type, | 617 syncable::ModelType type, |
| 618 const tracked_objects::Location& from_here, | 618 const tracked_objects::Location& from_here, |
| 619 std::string message) { | 619 std::string message) { |
| 620 // First deactivate the type so that no further server changes are | 620 // First deactivate the type so that no further server changes are |
| 621 // passed onto the change processor. | 621 // passed onto the change processor. |
| 622 DeactivateDataType(type); | 622 DeactivateDataType(type); |
| 623 | 623 |
| 624 csync::SyncError error(from_here, message, type); | 624 syncer::SyncError error(from_here, message, type); |
| 625 | 625 |
| 626 std::list<csync::SyncError> errors; | 626 std::list<syncer::SyncError> errors; |
| 627 errors.push_back(error); | 627 errors.push_back(error); |
| 628 | 628 |
| 629 // Update this before posting a task. So if a configure happens before | 629 // Update this before posting a task. So if a configure happens before |
| 630 // the task that we are going to post, this type would still be disabled. | 630 // the task that we are going to post, this type would still be disabled. |
| 631 failed_datatypes_handler_.UpdateFailedDatatypes(errors, | 631 failed_datatypes_handler_.UpdateFailedDatatypes(errors, |
| 632 FailedDatatypesHandler::RUNTIME); | 632 FailedDatatypesHandler::RUNTIME); |
| 633 | 633 |
| 634 MessageLoop::current()->PostTask(FROM_HERE, | 634 MessageLoop::current()->PostTask(FROM_HERE, |
| 635 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, | 635 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, |
| 636 weak_factory_.GetWeakPtr())); | 636 weak_factory_.GetWeakPtr())); |
| 637 } | 637 } |
| 638 | 638 |
| 639 void ProfileSyncService::OnBackendInitialized( | 639 void ProfileSyncService::OnBackendInitialized( |
| 640 const csync::WeakHandle<csync::JsBackend>& js_backend, bool success) { | 640 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success) { |
| 641 if (!HasSyncSetupCompleted()) { | 641 if (!HasSyncSetupCompleted()) { |
| 642 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success); | 642 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success); |
| 643 } else { | 643 } else { |
| 644 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeRestoreSuccess", success); | 644 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeRestoreSuccess", success); |
| 645 } | 645 } |
| 646 | 646 |
| 647 if (!success) { | 647 if (!success) { |
| 648 // Something went unexpectedly wrong. Play it safe: stop syncing at once | 648 // Something went unexpectedly wrong. Play it safe: stop syncing at once |
| 649 // and surface error UI to alert the user sync has stopped. | 649 // and surface error UI to alert the user sync has stopped. |
| 650 // Keep the directory around for now so that on restart we will retry | 650 // Keep the directory around for now so that on restart we will retry |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 // rely on the local clock, which may be off significantly. | 699 // rely on the local clock, which may be off significantly. |
| 700 MessageLoop::current()->PostTask(FROM_HERE, | 700 MessageLoop::current()->PostTask(FROM_HERE, |
| 701 base::Bind(&browser_sync::SessionModelAssociator::DeleteStaleSessions, | 701 base::Bind(&browser_sync::SessionModelAssociator::DeleteStaleSessions, |
| 702 GetSessionModelAssociator()->AsWeakPtr())); | 702 GetSessionModelAssociator()->AsWeakPtr())); |
| 703 } | 703 } |
| 704 DVLOG(2) << "Notifying observers sync cycle completed"; | 704 DVLOG(2) << "Notifying observers sync cycle completed"; |
| 705 NotifyObservers(); | 705 NotifyObservers(); |
| 706 } | 706 } |
| 707 | 707 |
| 708 void ProfileSyncService::OnExperimentsChanged( | 708 void ProfileSyncService::OnExperimentsChanged( |
| 709 const csync::Experiments& experiments) { | 709 const syncer::Experiments& experiments) { |
| 710 if (current_experiments.Matches(experiments)) | 710 if (current_experiments.Matches(experiments)) |
| 711 return; | 711 return; |
| 712 | 712 |
| 713 // If this is a first time sync for a client, this will be called before | 713 // If this is a first time sync for a client, this will be called before |
| 714 // OnBackendInitialized() to ensure the new datatypes are available at sync | 714 // OnBackendInitialized() to ensure the new datatypes are available at sync |
| 715 // setup. As a result, the migrator won't exist yet. This is fine because for | 715 // setup. As a result, the migrator won't exist yet. This is fine because for |
| 716 // first time sync cases we're only concerned with making the datatype | 716 // first time sync cases we're only concerned with making the datatype |
| 717 // available. | 717 // available. |
| 718 if (migrator_.get() && | 718 if (migrator_.get() && |
| 719 migrator_->state() != browser_sync::BackendMigrator::IDLE) { | 719 migrator_->state() != browser_sync::BackendMigrator::IDLE) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 is_auth_in_progress_ = false; | 783 is_auth_in_progress_ = false; |
| 784 last_auth_error_ = error; | 784 last_auth_error_ = error; |
| 785 | 785 |
| 786 // Fan the notification out to interested UI-thread components. | 786 // Fan the notification out to interested UI-thread components. |
| 787 NotifyObservers(); | 787 NotifyObservers(); |
| 788 } | 788 } |
| 789 | 789 |
| 790 namespace { | 790 namespace { |
| 791 | 791 |
| 792 GoogleServiceAuthError ConnectionStatusToAuthError( | 792 GoogleServiceAuthError ConnectionStatusToAuthError( |
| 793 csync::ConnectionStatus status) { | 793 syncer::ConnectionStatus status) { |
| 794 switch (status) { | 794 switch (status) { |
| 795 case csync::CONNECTION_OK: | 795 case syncer::CONNECTION_OK: |
| 796 return GoogleServiceAuthError::None(); | 796 return GoogleServiceAuthError::None(); |
| 797 break; | 797 break; |
| 798 case csync::CONNECTION_AUTH_ERROR: | 798 case syncer::CONNECTION_AUTH_ERROR: |
| 799 return GoogleServiceAuthError( | 799 return GoogleServiceAuthError( |
| 800 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 800 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 801 break; | 801 break; |
| 802 case csync::CONNECTION_SERVER_ERROR: | 802 case syncer::CONNECTION_SERVER_ERROR: |
| 803 return GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED); | 803 return GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED); |
| 804 break; | 804 break; |
| 805 default: | 805 default: |
| 806 NOTREACHED(); | 806 NOTREACHED(); |
| 807 return GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED); | 807 return GoogleServiceAuthError(GoogleServiceAuthError::CONNECTION_FAILED); |
| 808 } | 808 } |
| 809 } | 809 } |
| 810 | 810 |
| 811 } // namespace | 811 } // namespace |
| 812 | 812 |
| 813 void ProfileSyncService::OnConnectionStatusChange( | 813 void ProfileSyncService::OnConnectionStatusChange( |
| 814 csync::ConnectionStatus status) { | 814 syncer::ConnectionStatus status) { |
| 815 UpdateAuthErrorState(ConnectionStatusToAuthError(status)); | 815 UpdateAuthErrorState(ConnectionStatusToAuthError(status)); |
| 816 } | 816 } |
| 817 | 817 |
| 818 void ProfileSyncService::OnStopSyncingPermanently() { | 818 void ProfileSyncService::OnStopSyncingPermanently() { |
| 819 UpdateAuthErrorState( | 819 UpdateAuthErrorState( |
| 820 GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE)); | 820 GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE)); |
| 821 sync_prefs_.SetStartSuppressed(true); | 821 sync_prefs_.SetStartSuppressed(true); |
| 822 DisableForUser(); | 822 DisableForUser(); |
| 823 } | 823 } |
| 824 | 824 |
| 825 void ProfileSyncService::OnPassphraseRequired( | 825 void ProfileSyncService::OnPassphraseRequired( |
| 826 csync::PassphraseRequiredReason reason, | 826 syncer::PassphraseRequiredReason reason, |
| 827 const sync_pb::EncryptedData& pending_keys) { | 827 const sync_pb::EncryptedData& pending_keys) { |
| 828 DCHECK(backend_.get()); | 828 DCHECK(backend_.get()); |
| 829 DCHECK(backend_->IsNigoriEnabled()); | 829 DCHECK(backend_->IsNigoriEnabled()); |
| 830 | 830 |
| 831 // TODO(lipalani) : add this check to other locations as well. | 831 // TODO(lipalani) : add this check to other locations as well. |
| 832 if (HasUnrecoverableError()) { | 832 if (HasUnrecoverableError()) { |
| 833 // When unrecoverable error is detected we post a task to shutdown the | 833 // When unrecoverable error is detected we post a task to shutdown the |
| 834 // backend. The task might not have executed yet. | 834 // backend. The task might not have executed yet. |
| 835 return; | 835 return; |
| 836 } | 836 } |
| 837 | 837 |
| 838 DVLOG(1) << "Passphrase required with reason: " | 838 DVLOG(1) << "Passphrase required with reason: " |
| 839 << csync::PassphraseRequiredReasonToString(reason); | 839 << syncer::PassphraseRequiredReasonToString(reason); |
| 840 passphrase_required_reason_ = reason; | 840 passphrase_required_reason_ = reason; |
| 841 | 841 |
| 842 // Notify observers that the passphrase status may have changed. | 842 // Notify observers that the passphrase status may have changed. |
| 843 NotifyObservers(); | 843 NotifyObservers(); |
| 844 } | 844 } |
| 845 | 845 |
| 846 void ProfileSyncService::OnPassphraseAccepted() { | 846 void ProfileSyncService::OnPassphraseAccepted() { |
| 847 DVLOG(1) << "Received OnPassphraseAccepted."; | 847 DVLOG(1) << "Received OnPassphraseAccepted."; |
| 848 // If we are not using an explicit passphrase, and we have a cache of the gaia | 848 // If we are not using an explicit passphrase, and we have a cache of the gaia |
| 849 // password, use it for encryption at this point. | 849 // password, use it for encryption at this point. |
| 850 DCHECK(cached_passphrase_.empty()) << | 850 DCHECK(cached_passphrase_.empty()) << |
| 851 "Passphrase no longer required but there is still a cached passphrase"; | 851 "Passphrase no longer required but there is still a cached passphrase"; |
| 852 | 852 |
| 853 // Reset passphrase_required_reason_ since we know we no longer require the | 853 // Reset passphrase_required_reason_ since we know we no longer require the |
| 854 // passphrase. We do this here rather than down in ResolvePassphraseRequired() | 854 // passphrase. We do this here rather than down in ResolvePassphraseRequired() |
| 855 // because that can be called by OnPassphraseRequired() if no encrypted data | 855 // because that can be called by OnPassphraseRequired() if no encrypted data |
| 856 // types are enabled, and we don't want to clobber the true passphrase error. | 856 // types are enabled, and we don't want to clobber the true passphrase error. |
| 857 passphrase_required_reason_ = csync::REASON_PASSPHRASE_NOT_REQUIRED; | 857 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; |
| 858 | 858 |
| 859 // Make sure the data types that depend on the passphrase are started at | 859 // Make sure the data types that depend on the passphrase are started at |
| 860 // this time. | 860 // this time. |
| 861 const syncable::ModelTypeSet types = GetPreferredDataTypes(); | 861 const syncable::ModelTypeSet types = GetPreferredDataTypes(); |
| 862 | 862 |
| 863 if (data_type_manager_.get()) { | 863 if (data_type_manager_.get()) { |
| 864 // Unblock the data type manager if necessary. | 864 // Unblock the data type manager if necessary. |
| 865 data_type_manager_->Configure(types, | 865 data_type_manager_->Configure(types, |
| 866 csync::CONFIGURE_REASON_RECONFIGURATION); | 866 syncer::CONFIGURE_REASON_RECONFIGURATION); |
| 867 } | 867 } |
| 868 | 868 |
| 869 NotifyObservers(); | 869 NotifyObservers(); |
| 870 } | 870 } |
| 871 | 871 |
| 872 void ProfileSyncService::OnEncryptedTypesChanged( | 872 void ProfileSyncService::OnEncryptedTypesChanged( |
| 873 syncable::ModelTypeSet encrypted_types, | 873 syncable::ModelTypeSet encrypted_types, |
| 874 bool encrypt_everything) { | 874 bool encrypt_everything) { |
| 875 encrypted_types_ = encrypted_types; | 875 encrypted_types_ = encrypted_types; |
| 876 encrypt_everything_ = encrypt_everything; | 876 encrypt_everything_ = encrypt_everything; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 897 DCHECK(data_type_manager_.get()); | 897 DCHECK(data_type_manager_.get()); |
| 898 | 898 |
| 899 // Migrator must be valid, because we don't sync until it is created and this | 899 // Migrator must be valid, because we don't sync until it is created and this |
| 900 // callback originates from a sync cycle. | 900 // callback originates from a sync cycle. |
| 901 migrator_->MigrateTypes(types); | 901 migrator_->MigrateTypes(types); |
| 902 } | 902 } |
| 903 | 903 |
| 904 void ProfileSyncService::OnActionableError(const SyncProtocolError& error) { | 904 void ProfileSyncService::OnActionableError(const SyncProtocolError& error) { |
| 905 last_actionable_error_ = error; | 905 last_actionable_error_ = error; |
| 906 DCHECK_NE(last_actionable_error_.action, | 906 DCHECK_NE(last_actionable_error_.action, |
| 907 csync::UNKNOWN_ACTION); | 907 syncer::UNKNOWN_ACTION); |
| 908 switch (error.action) { | 908 switch (error.action) { |
| 909 case csync::UPGRADE_CLIENT: | 909 case syncer::UPGRADE_CLIENT: |
| 910 case csync::CLEAR_USER_DATA_AND_RESYNC: | 910 case syncer::CLEAR_USER_DATA_AND_RESYNC: |
| 911 case csync::ENABLE_SYNC_ON_ACCOUNT: | 911 case syncer::ENABLE_SYNC_ON_ACCOUNT: |
| 912 case csync::STOP_AND_RESTART_SYNC: | 912 case syncer::STOP_AND_RESTART_SYNC: |
| 913 // TODO(lipalani) : if setup in progress we want to display these | 913 // TODO(lipalani) : if setup in progress we want to display these |
| 914 // actions in the popup. The current experience might not be optimal for | 914 // actions in the popup. The current experience might not be optimal for |
| 915 // the user. We just dismiss the dialog. | 915 // the user. We just dismiss the dialog. |
| 916 if (setup_in_progress_) { | 916 if (setup_in_progress_) { |
| 917 OnStopSyncingPermanently(); | 917 OnStopSyncingPermanently(); |
| 918 expect_sync_configuration_aborted_ = true; | 918 expect_sync_configuration_aborted_ = true; |
| 919 } | 919 } |
| 920 // Trigger an unrecoverable error to stop syncing. | 920 // Trigger an unrecoverable error to stop syncing. |
| 921 OnInternalUnrecoverableError(FROM_HERE, | 921 OnInternalUnrecoverableError(FROM_HERE, |
| 922 last_actionable_error_.error_description, | 922 last_actionable_error_.error_description, |
| 923 true, | 923 true, |
| 924 ERROR_REASON_ACTIONABLE_ERROR); | 924 ERROR_REASON_ACTIONABLE_ERROR); |
| 925 break; | 925 break; |
| 926 case csync::DISABLE_SYNC_ON_CLIENT: | 926 case syncer::DISABLE_SYNC_ON_CLIENT: |
| 927 OnStopSyncingPermanently(); | 927 OnStopSyncingPermanently(); |
| 928 break; | 928 break; |
| 929 default: | 929 default: |
| 930 NOTREACHED(); | 930 NOTREACHED(); |
| 931 } | 931 } |
| 932 NotifyObservers(); | 932 NotifyObservers(); |
| 933 } | 933 } |
| 934 | 934 |
| 935 std::string ProfileSyncService::QuerySyncStatusSummary() { | 935 std::string ProfileSyncService::QuerySyncStatusSummary() { |
| 936 if (HasUnrecoverableError()) { | 936 if (HasUnrecoverableError()) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 bool ProfileSyncService::waiting_for_auth() const { | 984 bool ProfileSyncService::waiting_for_auth() const { |
| 985 return is_auth_in_progress_; | 985 return is_auth_in_progress_; |
| 986 } | 986 } |
| 987 | 987 |
| 988 bool ProfileSyncService::HasUnrecoverableError() const { | 988 bool ProfileSyncService::HasUnrecoverableError() const { |
| 989 return unrecoverable_error_reason_ != ERROR_REASON_UNSET; | 989 return unrecoverable_error_reason_ != ERROR_REASON_UNSET; |
| 990 } | 990 } |
| 991 | 991 |
| 992 bool ProfileSyncService::IsPassphraseRequired() const { | 992 bool ProfileSyncService::IsPassphraseRequired() const { |
| 993 return passphrase_required_reason_ != | 993 return passphrase_required_reason_ != |
| 994 csync::REASON_PASSPHRASE_NOT_REQUIRED; | 994 syncer::REASON_PASSPHRASE_NOT_REQUIRED; |
| 995 } | 995 } |
| 996 | 996 |
| 997 // TODO(zea): Rename this IsPassphraseNeededFromUI and ensure it's used | 997 // TODO(zea): Rename this IsPassphraseNeededFromUI and ensure it's used |
| 998 // appropriately (see http://crbug.com/91379). | 998 // appropriately (see http://crbug.com/91379). |
| 999 bool ProfileSyncService::IsPassphraseRequiredForDecryption() const { | 999 bool ProfileSyncService::IsPassphraseRequiredForDecryption() const { |
| 1000 // If there is an encrypted datatype enabled and we don't have the proper | 1000 // If there is an encrypted datatype enabled and we don't have the proper |
| 1001 // passphrase, we must prompt the user for a passphrase. The only way for the | 1001 // passphrase, we must prompt the user for a passphrase. The only way for the |
| 1002 // user to avoid entering their passphrase is to disable the encrypted types. | 1002 // user to avoid entering their passphrase is to disable the encrypted types. |
| 1003 return IsEncryptedDatatypeEnabled() && IsPassphraseRequired(); | 1003 return IsEncryptedDatatypeEnabled() && IsPassphraseRequired(); |
| 1004 } | 1004 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 browser_sync::user_selectable_type::SELECTABLE_DATATYPE_COUNT + 1); | 1069 browser_sync::user_selectable_type::SELECTABLE_DATATYPE_COUNT + 1); |
| 1070 } | 1070 } |
| 1071 } | 1071 } |
| 1072 } | 1072 } |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 #if defined(OS_CHROMEOS) | 1075 #if defined(OS_CHROMEOS) |
| 1076 void ProfileSyncService::RefreshSpareBootstrapToken( | 1076 void ProfileSyncService::RefreshSpareBootstrapToken( |
| 1077 const std::string& passphrase) { | 1077 const std::string& passphrase) { |
| 1078 browser_sync::ChromeEncryptor encryptor; | 1078 browser_sync::ChromeEncryptor encryptor; |
| 1079 csync::Cryptographer temp_cryptographer(&encryptor); | 1079 syncer::Cryptographer temp_cryptographer(&encryptor); |
| 1080 // The first 2 params (hostname and username) doesn't have any effect here. | 1080 // The first 2 params (hostname and username) doesn't have any effect here. |
| 1081 csync::KeyParams key_params = {"localhost", "dummy", passphrase}; | 1081 syncer::KeyParams key_params = {"localhost", "dummy", passphrase}; |
| 1082 | 1082 |
| 1083 std::string bootstrap_token; | 1083 std::string bootstrap_token; |
| 1084 if (!temp_cryptographer.AddKey(key_params)) { | 1084 if (!temp_cryptographer.AddKey(key_params)) { |
| 1085 NOTREACHED() << "Failed to add key to cryptographer."; | 1085 NOTREACHED() << "Failed to add key to cryptographer."; |
| 1086 } | 1086 } |
| 1087 temp_cryptographer.GetBootstrapToken(&bootstrap_token); | 1087 temp_cryptographer.GetBootstrapToken(&bootstrap_token); |
| 1088 sync_prefs_.SetSpareBootstrapToken(bootstrap_token); | 1088 sync_prefs_.SetSpareBootstrapToken(bootstrap_token); |
| 1089 } | 1089 } |
| 1090 #endif | 1090 #endif |
| 1091 | 1091 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 registered_types.Put(it->first); | 1138 registered_types.Put(it->first); |
| 1139 } | 1139 } |
| 1140 return registered_types; | 1140 return registered_types; |
| 1141 } | 1141 } |
| 1142 | 1142 |
| 1143 bool ProfileSyncService::IsUsingSecondaryPassphrase() const { | 1143 bool ProfileSyncService::IsUsingSecondaryPassphrase() const { |
| 1144 return backend_->IsUsingExplicitPassphrase(); | 1144 return backend_->IsUsingExplicitPassphrase(); |
| 1145 } | 1145 } |
| 1146 | 1146 |
| 1147 bool ProfileSyncService::IsCryptographerReady( | 1147 bool ProfileSyncService::IsCryptographerReady( |
| 1148 const csync::BaseTransaction* trans) const { | 1148 const syncer::BaseTransaction* trans) const { |
| 1149 return backend_.get() && backend_->IsCryptographerReady(trans); | 1149 return backend_.get() && backend_->IsCryptographerReady(trans); |
| 1150 } | 1150 } |
| 1151 | 1151 |
| 1152 SyncBackendHost* ProfileSyncService::GetBackendForTest() { | 1152 SyncBackendHost* ProfileSyncService::GetBackendForTest() { |
| 1153 // We don't check |backend_initialized_|; we assume the test class | 1153 // We don't check |backend_initialized_|; we assume the test class |
| 1154 // knows what it's doing. | 1154 // knows what it's doing. |
| 1155 return backend_.get(); | 1155 return backend_.get(); |
| 1156 } | 1156 } |
| 1157 | 1157 |
| 1158 void ProfileSyncService::ConfigureDataTypeManager() { | 1158 void ProfileSyncService::ConfigureDataTypeManager() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1183 | 1183 |
| 1184 const syncable::ModelTypeSet types = GetPreferredDataTypes(); | 1184 const syncable::ModelTypeSet types = GetPreferredDataTypes(); |
| 1185 if (IsPassphraseRequiredForDecryption()) { | 1185 if (IsPassphraseRequiredForDecryption()) { |
| 1186 // We need a passphrase still. We don't bother to attempt to configure | 1186 // We need a passphrase still. We don't bother to attempt to configure |
| 1187 // until we receive an OnPassphraseAccepted (which triggers a configure). | 1187 // until we receive an OnPassphraseAccepted (which triggers a configure). |
| 1188 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out " | 1188 DVLOG(1) << "ProfileSyncService::ConfigureDataTypeManager bailing out " |
| 1189 << "because a passphrase required"; | 1189 << "because a passphrase required"; |
| 1190 NotifyObservers(); | 1190 NotifyObservers(); |
| 1191 return; | 1191 return; |
| 1192 } | 1192 } |
| 1193 csync::ConfigureReason reason = csync::CONFIGURE_REASON_UNKNOWN; | 1193 syncer::ConfigureReason reason = syncer::CONFIGURE_REASON_UNKNOWN; |
| 1194 if (!HasSyncSetupCompleted()) { | 1194 if (!HasSyncSetupCompleted()) { |
| 1195 reason = csync::CONFIGURE_REASON_NEW_CLIENT; | 1195 reason = syncer::CONFIGURE_REASON_NEW_CLIENT; |
| 1196 } else if (restart == false || | 1196 } else if (restart == false || |
| 1197 csync::InitialSyncEndedForTypes(types, GetUserShare())) { | 1197 syncer::InitialSyncEndedForTypes(types, GetUserShare())) { |
| 1198 reason = csync::CONFIGURE_REASON_RECONFIGURATION; | 1198 reason = syncer::CONFIGURE_REASON_RECONFIGURATION; |
| 1199 } else { | 1199 } else { |
| 1200 DCHECK(restart); | 1200 DCHECK(restart); |
| 1201 reason = csync::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE; | 1201 reason = syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE; |
| 1202 } | 1202 } |
| 1203 DCHECK(reason != csync::CONFIGURE_REASON_UNKNOWN); | 1203 DCHECK(reason != syncer::CONFIGURE_REASON_UNKNOWN); |
| 1204 | 1204 |
| 1205 data_type_manager_->Configure(types, reason); | 1205 data_type_manager_->Configure(types, reason); |
| 1206 } | 1206 } |
| 1207 | 1207 |
| 1208 csync::UserShare* ProfileSyncService::GetUserShare() const { | 1208 syncer::UserShare* ProfileSyncService::GetUserShare() const { |
| 1209 if (backend_.get() && backend_initialized_) { | 1209 if (backend_.get() && backend_initialized_) { |
| 1210 return backend_->GetUserShare(); | 1210 return backend_->GetUserShare(); |
| 1211 } | 1211 } |
| 1212 NOTREACHED(); | 1212 NOTREACHED(); |
| 1213 return NULL; | 1213 return NULL; |
| 1214 } | 1214 } |
| 1215 | 1215 |
| 1216 csync::sessions::SyncSessionSnapshot | 1216 syncer::sessions::SyncSessionSnapshot |
| 1217 ProfileSyncService::GetLastSessionSnapshot() const { | 1217 ProfileSyncService::GetLastSessionSnapshot() const { |
| 1218 if (backend_.get() && backend_initialized_) { | 1218 if (backend_.get() && backend_initialized_) { |
| 1219 return backend_->GetLastSessionSnapshot(); | 1219 return backend_->GetLastSessionSnapshot(); |
| 1220 } | 1220 } |
| 1221 NOTREACHED(); | 1221 NOTREACHED(); |
| 1222 return csync::sessions::SyncSessionSnapshot(); | 1222 return syncer::sessions::SyncSessionSnapshot(); |
| 1223 } | 1223 } |
| 1224 | 1224 |
| 1225 bool ProfileSyncService::HasUnsyncedItems() const { | 1225 bool ProfileSyncService::HasUnsyncedItems() const { |
| 1226 if (backend_.get() && backend_initialized_) { | 1226 if (backend_.get() && backend_initialized_) { |
| 1227 return backend_->HasUnsyncedItems(); | 1227 return backend_->HasUnsyncedItems(); |
| 1228 } | 1228 } |
| 1229 NOTREACHED(); | 1229 NOTREACHED(); |
| 1230 return false; | 1230 return false; |
| 1231 } | 1231 } |
| 1232 | 1232 |
| 1233 browser_sync::BackendMigrator* | 1233 browser_sync::BackendMigrator* |
| 1234 ProfileSyncService::GetBackendMigratorForTest() { | 1234 ProfileSyncService::GetBackendMigratorForTest() { |
| 1235 return migrator_.get(); | 1235 return migrator_.get(); |
| 1236 } | 1236 } |
| 1237 | 1237 |
| 1238 void ProfileSyncService::GetModelSafeRoutingInfo( | 1238 void ProfileSyncService::GetModelSafeRoutingInfo( |
| 1239 csync::ModelSafeRoutingInfo* out) const { | 1239 syncer::ModelSafeRoutingInfo* out) const { |
| 1240 if (backend_.get() && backend_initialized_) { | 1240 if (backend_.get() && backend_initialized_) { |
| 1241 backend_->GetModelSafeRoutingInfo(out); | 1241 backend_->GetModelSafeRoutingInfo(out); |
| 1242 } else { | 1242 } else { |
| 1243 NOTREACHED(); | 1243 NOTREACHED(); |
| 1244 } | 1244 } |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 void ProfileSyncService::ActivateDataType( | 1247 void ProfileSyncService::ActivateDataType( |
| 1248 syncable::ModelType type, csync::ModelSafeGroup group, | 1248 syncable::ModelType type, syncer::ModelSafeGroup group, |
| 1249 ChangeProcessor* change_processor) { | 1249 ChangeProcessor* change_processor) { |
| 1250 if (!backend_.get()) { | 1250 if (!backend_.get()) { |
| 1251 NOTREACHED(); | 1251 NOTREACHED(); |
| 1252 return; | 1252 return; |
| 1253 } | 1253 } |
| 1254 DCHECK(backend_initialized_); | 1254 DCHECK(backend_initialized_); |
| 1255 backend_->ActivateDataType(type, group, change_processor); | 1255 backend_->ActivateDataType(type, group, change_processor); |
| 1256 } | 1256 } |
| 1257 | 1257 |
| 1258 void ProfileSyncService::DeactivateDataType(syncable::ModelType type) { | 1258 void ProfileSyncService::DeactivateDataType(syncable::ModelType type) { |
| 1259 if (!backend_.get()) | 1259 if (!backend_.get()) |
| 1260 return; | 1260 return; |
| 1261 backend_->DeactivateDataType(type); | 1261 backend_->DeactivateDataType(type); |
| 1262 } | 1262 } |
| 1263 | 1263 |
| 1264 void ProfileSyncService::ConsumeCachedPassphraseIfPossible() { | 1264 void ProfileSyncService::ConsumeCachedPassphraseIfPossible() { |
| 1265 // If no cached passphrase, or sync backend hasn't started up yet, just exit. | 1265 // If no cached passphrase, or sync backend hasn't started up yet, just exit. |
| 1266 // If the backend isn't running yet, OnBackendInitialized() will call this | 1266 // If the backend isn't running yet, OnBackendInitialized() will call this |
| 1267 // method again after the backend starts up. | 1267 // method again after the backend starts up. |
| 1268 if (cached_passphrase_.empty() || !sync_initialized()) | 1268 if (cached_passphrase_.empty() || !sync_initialized()) |
| 1269 return; | 1269 return; |
| 1270 | 1270 |
| 1271 // Backend is up and running, so we can consume the cached passphrase. | 1271 // Backend is up and running, so we can consume the cached passphrase. |
| 1272 std::string passphrase = cached_passphrase_; | 1272 std::string passphrase = cached_passphrase_; |
| 1273 cached_passphrase_.clear(); | 1273 cached_passphrase_.clear(); |
| 1274 | 1274 |
| 1275 // If we need a passphrase to decrypt data, try the cached passphrase. | 1275 // If we need a passphrase to decrypt data, try the cached passphrase. |
| 1276 if (passphrase_required_reason() == csync::REASON_DECRYPTION) { | 1276 if (passphrase_required_reason() == syncer::REASON_DECRYPTION) { |
| 1277 if (SetDecryptionPassphrase(passphrase)) { | 1277 if (SetDecryptionPassphrase(passphrase)) { |
| 1278 DVLOG(1) << "Cached passphrase successfully decrypted pending keys"; | 1278 DVLOG(1) << "Cached passphrase successfully decrypted pending keys"; |
| 1279 return; | 1279 return; |
| 1280 } | 1280 } |
| 1281 } | 1281 } |
| 1282 | 1282 |
| 1283 // If we get here, we don't have pending keys (or at least, the passphrase | 1283 // If we get here, we don't have pending keys (or at least, the passphrase |
| 1284 // doesn't decrypt them) - just try to re-encrypt using the encryption | 1284 // doesn't decrypt them) - just try to re-encrypt using the encryption |
| 1285 // passphrase. | 1285 // passphrase. |
| 1286 if (!IsUsingSecondaryPassphrase()) | 1286 if (!IsUsingSecondaryPassphrase()) |
| 1287 SetEncryptionPassphrase(passphrase, IMPLICIT); | 1287 SetEncryptionPassphrase(passphrase, IMPLICIT); |
| 1288 } | 1288 } |
| 1289 | 1289 |
| 1290 void ProfileSyncService::SetEncryptionPassphrase(const std::string& passphrase, | 1290 void ProfileSyncService::SetEncryptionPassphrase(const std::string& passphrase, |
| 1291 PassphraseType type) { | 1291 PassphraseType type) { |
| 1292 // This should only be called when the backend has been initialized. | 1292 // This should only be called when the backend has been initialized. |
| 1293 DCHECK(sync_initialized()); | 1293 DCHECK(sync_initialized()); |
| 1294 DCHECK(!(type == IMPLICIT && IsUsingSecondaryPassphrase())) << | 1294 DCHECK(!(type == IMPLICIT && IsUsingSecondaryPassphrase())) << |
| 1295 "Data is already encrypted using an explicit passphrase"; | 1295 "Data is already encrypted using an explicit passphrase"; |
| 1296 DCHECK(!(type == EXPLICIT && IsPassphraseRequired())) << | 1296 DCHECK(!(type == EXPLICIT && IsPassphraseRequired())) << |
| 1297 "Cannot switch to an explicit passphrase if a passphrase is required"; | 1297 "Cannot switch to an explicit passphrase if a passphrase is required"; |
| 1298 | 1298 |
| 1299 if (type == EXPLICIT) | 1299 if (type == EXPLICIT) |
| 1300 UMA_HISTOGRAM_BOOLEAN("Sync.CustomPassphrase", true); | 1300 UMA_HISTOGRAM_BOOLEAN("Sync.CustomPassphrase", true); |
| 1301 | 1301 |
| 1302 DVLOG(1) << "Setting " << (type == EXPLICIT ? "explicit" : "implicit") | 1302 DVLOG(1) << "Setting " << (type == EXPLICIT ? "explicit" : "implicit") |
| 1303 << " passphrase for encryption."; | 1303 << " passphrase for encryption."; |
| 1304 if (passphrase_required_reason_ == csync::REASON_ENCRYPTION) { | 1304 if (passphrase_required_reason_ == syncer::REASON_ENCRYPTION) { |
| 1305 // REASON_ENCRYPTION implies that the cryptographer does not have pending | 1305 // REASON_ENCRYPTION implies that the cryptographer does not have pending |
| 1306 // keys. Hence, as long as we're not trying to do an invalid passphrase | 1306 // keys. Hence, as long as we're not trying to do an invalid passphrase |
| 1307 // change (e.g. explicit -> explicit or explicit -> implicit), we know this | 1307 // change (e.g. explicit -> explicit or explicit -> implicit), we know this |
| 1308 // will succeed. If for some reason a new encryption key arrives via | 1308 // will succeed. If for some reason a new encryption key arrives via |
| 1309 // sync later, the SBH will trigger another OnPassphraseRequired(). | 1309 // sync later, the SBH will trigger another OnPassphraseRequired(). |
| 1310 passphrase_required_reason_ = csync::REASON_PASSPHRASE_NOT_REQUIRED; | 1310 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; |
| 1311 NotifyObservers(); | 1311 NotifyObservers(); |
| 1312 } | 1312 } |
| 1313 backend_->SetEncryptionPassphrase(passphrase, type == EXPLICIT); | 1313 backend_->SetEncryptionPassphrase(passphrase, type == EXPLICIT); |
| 1314 } | 1314 } |
| 1315 | 1315 |
| 1316 bool ProfileSyncService::SetDecryptionPassphrase( | 1316 bool ProfileSyncService::SetDecryptionPassphrase( |
| 1317 const std::string& passphrase) { | 1317 const std::string& passphrase) { |
| 1318 if (IsPassphraseRequired()) { | 1318 if (IsPassphraseRequired()) { |
| 1319 DVLOG(1) << "Setting passphrase for decryption."; | 1319 DVLOG(1) << "Setting passphrase for decryption."; |
| 1320 return backend_->SetDecryptionPassphrase(passphrase); | 1320 return backend_->SetDecryptionPassphrase(passphrase); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1411 return; | 1411 return; |
| 1412 } | 1412 } |
| 1413 | 1413 |
| 1414 // Handle unrecoverable error. | 1414 // Handle unrecoverable error. |
| 1415 if (configure_status_ != DataTypeManager::OK && | 1415 if (configure_status_ != DataTypeManager::OK && |
| 1416 configure_status_ != DataTypeManager::PARTIAL_SUCCESS) { | 1416 configure_status_ != DataTypeManager::PARTIAL_SUCCESS) { |
| 1417 // Something catastrophic had happened. We should only have one | 1417 // Something catastrophic had happened. We should only have one |
| 1418 // error representing it. | 1418 // error representing it. |
| 1419 DCHECK_EQ(result->failed_data_types.size(), | 1419 DCHECK_EQ(result->failed_data_types.size(), |
| 1420 static_cast<unsigned int>(1)); | 1420 static_cast<unsigned int>(1)); |
| 1421 csync::SyncError error = result->failed_data_types.front(); | 1421 syncer::SyncError error = result->failed_data_types.front(); |
| 1422 DCHECK(error.IsSet()); | 1422 DCHECK(error.IsSet()); |
| 1423 std::string message = | 1423 std::string message = |
| 1424 "Sync configuration failed with status " + | 1424 "Sync configuration failed with status " + |
| 1425 DataTypeManager::ConfigureStatusToString(configure_status_) + | 1425 DataTypeManager::ConfigureStatusToString(configure_status_) + |
| 1426 " during " + syncable::ModelTypeToString(error.type()) + | 1426 " during " + syncable::ModelTypeToString(error.type()) + |
| 1427 ": " + error.message(); | 1427 ": " + error.message(); |
| 1428 LOG(ERROR) << "ProfileSyncService error: " | 1428 LOG(ERROR) << "ProfileSyncService error: " |
| 1429 << message; | 1429 << message; |
| 1430 OnInternalUnrecoverableError(error.location(), | 1430 OnInternalUnrecoverableError(error.location(), |
| 1431 message, | 1431 message, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1547 } | 1547 } |
| 1548 | 1548 |
| 1549 void ProfileSyncService::RemoveObserver(Observer* observer) { | 1549 void ProfileSyncService::RemoveObserver(Observer* observer) { |
| 1550 observers_.RemoveObserver(observer); | 1550 observers_.RemoveObserver(observer); |
| 1551 } | 1551 } |
| 1552 | 1552 |
| 1553 bool ProfileSyncService::HasObserver(Observer* observer) const { | 1553 bool ProfileSyncService::HasObserver(Observer* observer) const { |
| 1554 return observers_.HasObserver(observer); | 1554 return observers_.HasObserver(observer); |
| 1555 } | 1555 } |
| 1556 | 1556 |
| 1557 base::WeakPtr<csync::JsController> ProfileSyncService::GetJsController() { | 1557 base::WeakPtr<syncer::JsController> ProfileSyncService::GetJsController() { |
| 1558 return sync_js_controller_.AsWeakPtr(); | 1558 return sync_js_controller_.AsWeakPtr(); |
| 1559 } | 1559 } |
| 1560 | 1560 |
| 1561 void ProfileSyncService::SyncEvent(SyncEventCodes code) { | 1561 void ProfileSyncService::SyncEvent(SyncEventCodes code) { |
| 1562 UMA_HISTOGRAM_ENUMERATION("Sync.EventCodes", code, MAX_SYNC_EVENT_CODE); | 1562 UMA_HISTOGRAM_ENUMERATION("Sync.EventCodes", code, MAX_SYNC_EVENT_CODE); |
| 1563 } | 1563 } |
| 1564 | 1564 |
| 1565 // static | 1565 // static |
| 1566 bool ProfileSyncService::IsSyncEnabled() { | 1566 bool ProfileSyncService::IsSyncEnabled() { |
| 1567 // We have switches::kEnableSync just in case we need to change back to | 1567 // We have switches::kEnableSync just in case we need to change back to |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. | 1652 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
| 1653 ProfileSyncService* old_this = this; | 1653 ProfileSyncService* old_this = this; |
| 1654 this->~ProfileSyncService(); | 1654 this->~ProfileSyncService(); |
| 1655 new(old_this) ProfileSyncService( | 1655 new(old_this) ProfileSyncService( |
| 1656 new ProfileSyncComponentsFactoryImpl(profile, | 1656 new ProfileSyncComponentsFactoryImpl(profile, |
| 1657 CommandLine::ForCurrentProcess()), | 1657 CommandLine::ForCurrentProcess()), |
| 1658 profile, | 1658 profile, |
| 1659 signin, | 1659 signin, |
| 1660 behavior); | 1660 behavior); |
| 1661 } | 1661 } |
| OLD | NEW |