Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 cros_user_(cros_user), | 88 cros_user_(cros_user), |
| 89 sync_service_url_(kDevServerUrl), | 89 sync_service_url_(kDevServerUrl), |
| 90 backend_initialized_(false), | 90 backend_initialized_(false), |
| 91 is_auth_in_progress_(false), | 91 is_auth_in_progress_(false), |
| 92 wizard_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 92 wizard_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 93 signin_(signin_manager), | 93 signin_(signin_manager), |
| 94 unrecoverable_error_detected_(false), | 94 unrecoverable_error_detected_(false), |
| 95 scoped_runnable_method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 95 scoped_runnable_method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 96 expect_sync_configuration_aborted_(false), | 96 expect_sync_configuration_aborted_(false), |
| 97 clear_server_data_state_(CLEAR_NOT_STARTED), | 97 clear_server_data_state_(CLEAR_NOT_STARTED), |
| 98 set_backend_encrypted_types_(false) { | 98 set_backend_encrypted_types_(false), |
| 99 auto_start_enabled_(false) { | |
| 99 // By default, dev, canary, and unbranded Chromium users will go to the | 100 // By default, dev, canary, and unbranded Chromium users will go to the |
| 100 // development servers. Development servers have more features than standard | 101 // development servers. Development servers have more features than standard |
| 101 // sync servers. Users with officially-branded Chrome stable and beta builds | 102 // sync servers. Users with officially-branded Chrome stable and beta builds |
| 102 // will go to the standard sync servers. | 103 // will go to the standard sync servers. |
| 103 // | 104 // |
| 104 // GetChannel hits the registry on Windows. See http://crbug.com/70380. | 105 // GetChannel hits the registry on Windows. See http://crbug.com/70380. |
| 105 base::ThreadRestrictions::ScopedAllowIO allow_io; | 106 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 106 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 107 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 107 if (channel == chrome::VersionInfo::CHANNEL_STABLE || | 108 if (channel == chrome::VersionInfo::CHANNEL_STABLE || |
| 108 channel == chrome::VersionInfo::CHANNEL_BETA) { | 109 channel == chrome::VersionInfo::CHANNEL_BETA) { |
| 109 sync_service_url_ = GURL(kSyncServerUrl); | 110 sync_service_url_ = GURL(kSyncServerUrl); |
| 110 } | 111 } |
| 112 | |
| 113 // TODO(atwilson): Set auto_start_enabled_ for other platforms that want this | |
| 114 // functionality. | |
| 115 if (!cros_user_.empty()) | |
| 116 auto_start_enabled_ = true; | |
| 111 } | 117 } |
| 112 | 118 |
| 113 ProfileSyncService::~ProfileSyncService() { | 119 ProfileSyncService::~ProfileSyncService() { |
| 114 Shutdown(false); | 120 Shutdown(false); |
| 115 } | 121 } |
| 116 | 122 |
| 117 bool ProfileSyncService::AreCredentialsAvailable() { | 123 bool ProfileSyncService::AreCredentialsAvailable() { |
| 118 if (IsManaged()) { | 124 if (IsManaged()) { |
| 119 return false; | 125 return false; |
| 120 } | 126 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 // so only initialize this if the token service has not been initialized | 167 // so only initialize this if the token service has not been initialized |
| 162 // (e.g. the browser crashed or is being debugged). | 168 // (e.g. the browser crashed or is being debugged). |
| 163 if (cros_user_.empty() || | 169 if (cros_user_.empty() || |
| 164 !profile_->GetTokenService()->Initialized()) { | 170 !profile_->GetTokenService()->Initialized()) { |
| 165 // Will load tokens from DB and broadcast Token events after. | 171 // Will load tokens from DB and broadcast Token events after. |
| 166 // Note: We rely on signin_ != NULL unless !cros_user_.empty(). | 172 // Note: We rely on signin_ != NULL unless !cros_user_.empty(). |
| 167 signin_->Initialize(profile_); | 173 signin_->Initialize(profile_); |
| 168 } | 174 } |
| 169 | 175 |
| 170 if (!HasSyncSetupCompleted()) { | 176 if (!HasSyncSetupCompleted()) { |
| 171 // Under ChromeOS, just autostart it anyway if creds are here and start | 177 // If autostart is enabled, but we haven't completed sync setup, try to |
| 172 // is not being suppressed by preferences. | 178 // start sync anyway (it's possible we crashed/shutdown after logging in |
| 173 if (!cros_user_.empty() && | 179 // but before the backend finished initializing the last time). |
| 180 if (auto_start_enabled_ && | |
| 174 !profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart) && | 181 !profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart) && |
| 175 AreCredentialsAvailable()) { | 182 AreCredentialsAvailable()) { |
| 176 StartUp(); | 183 StartUp(); |
| 177 } | 184 } |
| 178 } else if (AreCredentialsAvailable()) { | 185 } else if (AreCredentialsAvailable()) { |
| 179 // If we have credentials and sync setup finished, autostart the backend. | 186 // If we have credentials and sync setup finished, autostart the backend. |
| 180 // Note that if we haven't finished setting up sync, backend bring up will | 187 // Note that if we haven't finished setting up sync, backend bring up will |
| 181 // be done by the wizard. | 188 // be done by the wizard. |
| 182 StartUp(); | 189 StartUp(); |
| 183 } | 190 } |
| 184 } | 191 } |
| 185 | 192 |
| 186 void ProfileSyncService::RegisterAuthNotifications() { | 193 void ProfileSyncService::RegisterAuthNotifications() { |
| 187 registrar_.Add(this, | 194 registrar_.Add(this, |
| 188 chrome::NOTIFICATION_TOKEN_AVAILABLE, | 195 chrome::NOTIFICATION_TOKEN_AVAILABLE, |
| 189 Source<TokenService>(profile_->GetTokenService())); | 196 Source<TokenService>(profile_->GetTokenService())); |
| 190 registrar_.Add(this, | 197 registrar_.Add(this, |
| 191 chrome::NOTIFICATION_TOKEN_LOADING_FINISHED, | 198 chrome::NOTIFICATION_TOKEN_LOADING_FINISHED, |
| 192 Source<TokenService>(profile_->GetTokenService())); | 199 Source<TokenService>(profile_->GetTokenService())); |
| 193 registrar_.Add(this, | 200 registrar_.Add(this, |
| 194 chrome::NOTIFICATION_TOKEN_REQUEST_FAILED, | 201 chrome::NOTIFICATION_TOKEN_REQUEST_FAILED, |
| 195 Source<TokenService>(profile_->GetTokenService())); | 202 Source<TokenService>(profile_->GetTokenService())); |
| 196 registrar_.Add(this, | 203 registrar_.Add(this, |
| 197 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, | |
| 198 Source<Profile>(profile_)); | |
| 199 registrar_.Add(this, | |
| 200 chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED, | 204 chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED, |
| 201 Source<Profile>(profile_)); | 205 Source<Profile>(profile_)); |
| 202 } | 206 } |
| 203 | 207 |
| 204 void ProfileSyncService::RegisterDataTypeController( | 208 void ProfileSyncService::RegisterDataTypeController( |
| 205 DataTypeController* data_type_controller) { | 209 DataTypeController* data_type_controller) { |
| 206 DCHECK_EQ(data_type_controllers_.count(data_type_controller->type()), 0U); | 210 DCHECK_EQ(data_type_controllers_.count(data_type_controller->type()), 0U); |
| 207 data_type_controllers_[data_type_controller->type()] = | 211 data_type_controllers_[data_type_controller->type()] = |
| 208 data_type_controller; | 212 data_type_controller; |
| 209 } | 213 } |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 | 463 |
| 460 doomed_backend.reset(); | 464 doomed_backend.reset(); |
| 461 } | 465 } |
| 462 | 466 |
| 463 scoped_runnable_method_factory_.RevokeAll(); | 467 scoped_runnable_method_factory_.RevokeAll(); |
| 464 | 468 |
| 465 // Clear various flags. | 469 // Clear various flags. |
| 466 expect_sync_configuration_aborted_ = false; | 470 expect_sync_configuration_aborted_ = false; |
| 467 is_auth_in_progress_ = false; | 471 is_auth_in_progress_ = false; |
| 468 backend_initialized_ = false; | 472 backend_initialized_ = false; |
| 469 cached_passphrase_ = CachedPassphrase(); | 473 cached_passphrases_ = CachedPassphrases(); |
| 470 gaia_password_.clear(); | |
| 471 pending_types_for_encryption_.clear(); | 474 pending_types_for_encryption_.clear(); |
| 472 set_backend_encrypted_types_ = false; | 475 set_backend_encrypted_types_ = false; |
| 473 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; | 476 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; |
| 474 last_attempted_user_email_.clear(); | 477 last_attempted_user_email_.clear(); |
| 475 last_auth_error_ = GoogleServiceAuthError::None(); | 478 last_auth_error_ = GoogleServiceAuthError::None(); |
| 476 } | 479 } |
| 477 | 480 |
| 478 void ProfileSyncService::ClearServerData() { | 481 void ProfileSyncService::ClearServerData() { |
| 479 clear_server_data_state_ = CLEAR_CLEARING; | 482 clear_server_data_state_ = CLEAR_CLEARING; |
| 480 clear_server_data_timer_.Start( | 483 clear_server_data_timer_.Start( |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 631 sync_js_controller_.AttachJsBackend(js_backend); | 634 sync_js_controller_.AttachJsBackend(js_backend); |
| 632 | 635 |
| 633 // The very first time the backend initializes is effectively the first time | 636 // The very first time the backend initializes is effectively the first time |
| 634 // we can say we successfully "synced". last_synced_time_ will only be null | 637 // we can say we successfully "synced". last_synced_time_ will only be null |
| 635 // in this case, because the pref wasn't restored on StartUp. | 638 // in this case, because the pref wasn't restored on StartUp. |
| 636 if (last_synced_time_.is_null()) { | 639 if (last_synced_time_.is_null()) { |
| 637 UpdateLastSyncedTime(); | 640 UpdateLastSyncedTime(); |
| 638 } | 641 } |
| 639 NotifyObservers(); | 642 NotifyObservers(); |
| 640 | 643 |
| 641 if (!cros_user_.empty()) { | 644 if (auto_start_enabled_ && !SetupInProgress()) { |
| 645 // Backend is initialized but we're not in sync setup, so this must be an | |
| 646 // autostart - mark our sync setup as completed. | |
| 642 if (profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)) { | 647 if (profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)) { |
| 648 // TODO(sync): This call to ShowConfigure() should go away in favor | |
|
Rick Campbell
2011/09/02 18:31:29
Bug number?
Andrew T Wilson (Slow)
2011/09/02 21:40:46
Done.
| |
| 649 // of the code below that calls wizard_.Step(). | |
| 643 ShowConfigure(true); | 650 ShowConfigure(true); |
| 644 return; | 651 return; |
| 645 } else { | 652 } else { |
| 646 SetSyncSetupCompleted(); | 653 SetSyncSetupCompleted(); |
| 647 } | 654 } |
| 648 } | 655 } |
| 649 | 656 |
| 650 if (HasSyncSetupCompleted()) { | 657 if (HasSyncSetupCompleted()) { |
| 651 ConfigureDataTypeManager(); | 658 ConfigureDataTypeManager(); |
| 652 } else if (SetupInProgress()) { | 659 } else if (SetupInProgress()) { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 796 if (unrecoverable_error_detected_) { | 803 if (unrecoverable_error_detected_) { |
| 797 // When unrecoverable error is detected we post a task to shutdown the | 804 // When unrecoverable error is detected we post a task to shutdown the |
| 798 // backend. The task might not have executed yet. | 805 // backend. The task might not have executed yet. |
| 799 return; | 806 return; |
| 800 } | 807 } |
| 801 | 808 |
| 802 VLOG(1) << "Passphrase required with reason: " | 809 VLOG(1) << "Passphrase required with reason: " |
| 803 << sync_api::PassphraseRequiredReasonToString(reason); | 810 << sync_api::PassphraseRequiredReasonToString(reason); |
| 804 passphrase_required_reason_ = reason; | 811 passphrase_required_reason_ = reason; |
| 805 | 812 |
| 806 // Store any passphrases we have into temps and clear out the originals so | |
| 807 // we don't hold on to the passphrases any longer than we have to. We | |
| 808 // then use the passphrases if they're present (after OnPassphraseAccepted). | |
| 809 std::string gaia_password = gaia_password_; | |
| 810 std::string cached_passphrase = cached_passphrase_.value; | |
| 811 bool is_explicit = cached_passphrase_.is_explicit; | |
| 812 bool is_creation = cached_passphrase_.is_creation; | |
| 813 gaia_password_ = std::string(); | |
| 814 cached_passphrase_ = CachedPassphrase(); | |
| 815 | |
| 816 // We will skip the passphrase prompt and suppress the warning if the | 813 // We will skip the passphrase prompt and suppress the warning if the |
| 817 // passphrase is needed for decryption but the user is not syncing an | 814 // passphrase is needed for decryption but the user is not syncing an |
| 818 // encrypted data type on this machine. Otherwise we look for one. | 815 // encrypted data type on this machine. Otherwise we look for one. |
| 819 if (!IsEncryptedDatatypeEnabled() && IsPassphraseRequiredForDecryption()) { | 816 if (!IsEncryptedDatatypeEnabled() && IsPassphraseRequiredForDecryption()) { |
| 820 VLOG(1) << "Decrypting and no encrypted datatypes enabled" | 817 VLOG(1) << "Decrypting and no encrypted datatypes enabled" |
| 821 << ", accepted passphrase."; | 818 << ", accepted passphrase."; |
| 822 OnPassphraseAccepted(); | 819 OnPassphraseAccepted(); |
| 823 } | 820 } |
| 824 | 821 |
| 825 // First try supplying gaia password as the passphrase. | 822 // First try supplying gaia password as the passphrase. |
| 826 if (!gaia_password.empty()) { | 823 if (!cached_passphrases_.gaia_passphrase.empty()) { |
|
Rick Campbell
2011/09/02 18:31:29
Submit a bug to follow-up on the logic here? We m
Andrew T Wilson (Slow)
2011/09/02 21:40:46
Done.
| |
| 824 std::string gaia_passphrase = cached_passphrases_.gaia_passphrase; | |
| 825 cached_passphrases_.gaia_passphrase.clear(); | |
| 827 VLOG(1) << "Attempting gaia passphrase."; | 826 VLOG(1) << "Attempting gaia passphrase."; |
| 828 // SetPassphrase will set gaia_password_ if the syncer isn't ready. | 827 // SetPassphrase will re-cache this passphrase if the syncer isn't ready. |
| 829 SetPassphrase(gaia_password, false, true); | 828 SetPassphrase(gaia_passphrase, false); |
| 830 return; | 829 return; |
| 831 } | 830 } |
| 832 | 831 |
| 833 // If the above failed then try the custom passphrase the user might have | 832 // If the above failed then try the custom passphrase the user might have |
| 834 // entered in setup. | 833 // entered in setup. |
| 835 if (!cached_passphrase.empty()) { | 834 if (!cached_passphrases_.explicit_passphrase.empty()) { |
| 836 VLOG(1) << "Attempting cached passphrase."; | 835 std::string explicit_passphrase = cached_passphrases_.explicit_passphrase; |
| 837 // SetPassphrase will set cached_passphrase_ if the syncer isn't ready. | 836 cached_passphrases_.explicit_passphrase.clear(); |
| 838 SetPassphrase(cached_passphrase, is_explicit, is_creation); | 837 VLOG(1) << "Attempting explicit passphrase."; |
| 838 // SetPassphrase will re-cache this passphrase if the syncer isn't ready. | |
| 839 SetPassphrase(explicit_passphrase, true); | |
| 839 return; | 840 return; |
| 840 } | 841 } |
| 841 | 842 |
| 842 // Prompt the user for a password. | 843 // Prompt the user for a password. |
| 843 if (WizardIsVisible() && IsEncryptedDatatypeEnabled() && | 844 if (WizardIsVisible() && IsEncryptedDatatypeEnabled() && |
| 844 IsPassphraseRequiredForDecryption()) { | 845 IsPassphraseRequiredForDecryption()) { |
| 845 VLOG(1) << "Prompting user for passphrase."; | 846 VLOG(1) << "Prompting user for passphrase."; |
| 846 wizard_.Step(SyncSetupWizard::ENTER_PASSPHRASE); | 847 wizard_.Step(SyncSetupWizard::ENTER_PASSPHRASE); |
| 847 } | 848 } |
| 848 | 849 |
| 849 NotifyObservers(); | 850 NotifyObservers(); |
| 850 } | 851 } |
| 851 | 852 |
| 852 void ProfileSyncService::OnPassphraseAccepted() { | 853 void ProfileSyncService::OnPassphraseAccepted() { |
| 853 VLOG(1) << "Received OnPassphraseAccepted."; | 854 VLOG(1) << "Received OnPassphraseAccepted."; |
| 854 // Don't hold on to a passphrase in raw form longer than needed. | 855 // Don't hold on to a passphrase in raw form longer than needed. |
| 855 gaia_password_ = std::string(); | 856 cached_passphrases_ = CachedPassphrases(); |
| 856 cached_passphrase_ = CachedPassphrase(); | |
| 857 | 857 |
| 858 // Make sure the data types that depend on the passphrase are started at | 858 // Make sure the data types that depend on the passphrase are started at |
| 859 // this time. | 859 // this time. |
| 860 syncable::ModelTypeSet types; | 860 syncable::ModelTypeSet types; |
| 861 GetPreferredDataTypes(&types); | 861 GetPreferredDataTypes(&types); |
| 862 | 862 |
| 863 // Reset passphrase_required_reason_ before configuring the DataTypeManager | 863 // Reset passphrase_required_reason_ before configuring the DataTypeManager |
| 864 // since we know we no longer require the passphrase. | 864 // since we know we no longer require the passphrase. |
| 865 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; | 865 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; |
| 866 | 866 |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1321 backend_->ActivateDataType(type, group, change_processor); | 1321 backend_->ActivateDataType(type, group, change_processor); |
| 1322 } | 1322 } |
| 1323 | 1323 |
| 1324 void ProfileSyncService::DeactivateDataType(syncable::ModelType type) { | 1324 void ProfileSyncService::DeactivateDataType(syncable::ModelType type) { |
| 1325 if (!backend_.get()) | 1325 if (!backend_.get()) |
| 1326 return; | 1326 return; |
| 1327 backend_->DeactivateDataType(type); | 1327 backend_->DeactivateDataType(type); |
| 1328 } | 1328 } |
| 1329 | 1329 |
| 1330 void ProfileSyncService::SetPassphrase(const std::string& passphrase, | 1330 void ProfileSyncService::SetPassphrase(const std::string& passphrase, |
| 1331 bool is_explicit, | 1331 bool is_explicit) { |
| 1332 bool is_creation) { | |
| 1333 if (ShouldPushChanges() || IsPassphraseRequired()) { | 1332 if (ShouldPushChanges() || IsPassphraseRequired()) { |
| 1334 VLOG(1) << "Setting " << (is_explicit ? "explicit" : "implicit") | 1333 VLOG(1) << "Setting " << (is_explicit ? "explicit" : "implicit"); |
| 1335 << " passphrase" << (is_creation ? " for creation" : ""); | |
| 1336 backend_->SetPassphrase(passphrase, is_explicit); | 1334 backend_->SetPassphrase(passphrase, is_explicit); |
| 1337 } else { | 1335 } else { |
| 1338 if (is_explicit) { | 1336 if (is_explicit) { |
| 1339 cached_passphrase_.value = passphrase; | 1337 cached_passphrases_.explicit_passphrase = passphrase; |
| 1340 cached_passphrase_.is_explicit = is_explicit; | |
| 1341 cached_passphrase_.is_creation = is_creation; | |
| 1342 } else { | 1338 } else { |
| 1343 gaia_password_ = passphrase; | 1339 cached_passphrases_.gaia_passphrase = passphrase; |
| 1344 } | 1340 } |
| 1345 } | 1341 } |
| 1346 } | 1342 } |
| 1347 | 1343 |
| 1348 void ProfileSyncService::set_pending_types_for_encryption( | 1344 void ProfileSyncService::set_pending_types_for_encryption( |
| 1349 const syncable::ModelTypeSet& encrypted_types) { | 1345 const syncable::ModelTypeSet& encrypted_types) { |
| 1350 set_backend_encrypted_types_ = false; | 1346 set_backend_encrypted_types_ = false; |
| 1351 if (encrypted_types.empty()) { | 1347 if (encrypted_types.empty()) { |
| 1352 // We can't unencrypt types. | 1348 // We can't unencrypt types. |
| 1353 VLOG(1) << "No datatypes set for encryption, dropping encryption request."; | 1349 VLOG(1) << "No datatypes set for encryption, dropping encryption request."; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1402 expect_sync_configuration_aborted_ = false; | 1398 expect_sync_configuration_aborted_ = false; |
| 1403 return; | 1399 return; |
| 1404 } | 1400 } |
| 1405 if (status != DataTypeManager::OK) { | 1401 if (status != DataTypeManager::OK) { |
| 1406 VLOG(0) << "ProfileSyncService::Observe: Unrecoverable error detected"; | 1402 VLOG(0) << "ProfileSyncService::Observe: Unrecoverable error detected"; |
| 1407 std::string message = | 1403 std::string message = |
| 1408 "Sync Configuration failed while configuring " + | 1404 "Sync Configuration failed while configuring " + |
| 1409 syncable::ModelTypeSetToString(result->failed_types) + | 1405 syncable::ModelTypeSetToString(result->failed_types) + |
| 1410 ": " + DataTypeManager::ConfigureStatusToString(status); | 1406 ": " + DataTypeManager::ConfigureStatusToString(status); |
| 1411 OnUnrecoverableError(result->location, message); | 1407 OnUnrecoverableError(result->location, message); |
| 1412 cached_passphrase_ = CachedPassphrase(); | 1408 cached_passphrases_ = CachedPassphrases(); |
| 1413 return; | 1409 return; |
| 1414 } | 1410 } |
| 1415 | 1411 |
| 1416 // We should never get in a state where we have no encrypted datatypes | 1412 // We should never get in a state where we have no encrypted datatypes |
| 1417 // enabled, and yet we still think we require a passphrase for decryption. | 1413 // enabled, and yet we still think we require a passphrase for decryption. |
| 1418 DCHECK(!(IsPassphraseRequiredForDecryption() && | 1414 DCHECK(!(IsPassphraseRequiredForDecryption() && |
| 1419 !IsEncryptedDatatypeEnabled())); | 1415 !IsEncryptedDatatypeEnabled())); |
| 1420 | 1416 |
| 1421 // In the old world, this would be a no-op. With new syncer thread, | 1417 // In the old world, this would be a no-op. With new syncer thread, |
| 1422 // this is the point where it is safe to switch from config-mode to | 1418 // this is the point where it is safe to switch from config-mode to |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1441 if (*pref_name == prefs::kSyncManaged) { | 1437 if (*pref_name == prefs::kSyncManaged) { |
| 1442 NotifyObservers(); | 1438 NotifyObservers(); |
| 1443 if (*pref_sync_managed_) { | 1439 if (*pref_sync_managed_) { |
| 1444 DisableForUser(); | 1440 DisableForUser(); |
| 1445 } else if (HasSyncSetupCompleted() && AreCredentialsAvailable()) { | 1441 } else if (HasSyncSetupCompleted() && AreCredentialsAvailable()) { |
| 1446 StartUp(); | 1442 StartUp(); |
| 1447 } | 1443 } |
| 1448 } | 1444 } |
| 1449 break; | 1445 break; |
| 1450 } | 1446 } |
| 1451 case chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL: { | |
| 1452 const GoogleServiceSigninSuccessDetails* successful = | |
| 1453 (Details<const GoogleServiceSigninSuccessDetails>(details).ptr()); | |
| 1454 // We pass 'false' to SetPassphrase to denote that this is an implicit | |
| 1455 // request and shouldn't override an explicit one. Thus, we either | |
| 1456 // update the implicit passphrase (idempotent if the passphrase didn't | |
| 1457 // actually change), or the user has an explicit passphrase set so this | |
| 1458 // becomes a no-op. | |
| 1459 if (browser_sync::IsUsingOAuth()) { | |
| 1460 // TODO(rickcam): Bug 92323: Fetch password through special Gaia request | |
| 1461 DCHECK(successful->password.empty()); | |
| 1462 LOG(WARNING) << "Not initializing sync passphrase."; | |
| 1463 } else { | |
| 1464 SetPassphrase(successful->password, false, true); | |
| 1465 } | |
| 1466 break; | |
| 1467 } | |
| 1468 case chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED: { | 1447 case chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED: { |
| 1469 GoogleServiceAuthError error = | 1448 GoogleServiceAuthError error = |
| 1470 *(Details<const GoogleServiceAuthError>(details).ptr()); | 1449 *(Details<const GoogleServiceAuthError>(details).ptr()); |
| 1471 UpdateAuthErrorState(error); | 1450 UpdateAuthErrorState(error); |
| 1472 break; | 1451 break; |
| 1473 } | 1452 } |
| 1474 case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: { | 1453 case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: { |
| 1475 GoogleServiceAuthError error( | 1454 GoogleServiceAuthError error( |
| 1476 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 1455 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 1477 UpdateAuthErrorState(error); | 1456 UpdateAuthErrorState(error); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1573 syncable::ModelTypeBitSetFromValue( | 1552 syncable::ModelTypeBitSetFromValue( |
| 1574 *profile_->GetPrefs()->GetList(prefs::kAcknowledgedSyncTypes)); | 1553 *profile_->GetPrefs()->GetList(prefs::kAcknowledgedSyncTypes)); |
| 1575 syncable::ModelTypeSet registered; | 1554 syncable::ModelTypeSet registered; |
| 1576 GetRegisteredDataTypes(®istered); | 1555 GetRegisteredDataTypes(®istered); |
| 1577 syncable::ModelTypeBitSet registered_bit_set = | 1556 syncable::ModelTypeBitSet registered_bit_set = |
| 1578 syncable::ModelTypeBitSetFromSet(registered); | 1557 syncable::ModelTypeBitSetFromSet(registered); |
| 1579 unacknowledged = registered_bit_set & ~acknowledged; | 1558 unacknowledged = registered_bit_set & ~acknowledged; |
| 1580 } | 1559 } |
| 1581 return unacknowledged; | 1560 return unacknowledged; |
| 1582 } | 1561 } |
| 1583 | |
| OLD | NEW |