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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 468 |
465 doomed_backend.reset(); | 469 doomed_backend.reset(); |
466 } | 470 } |
467 | 471 |
468 scoped_runnable_method_factory_.RevokeAll(); | 472 scoped_runnable_method_factory_.RevokeAll(); |
469 | 473 |
470 // Clear various flags. | 474 // Clear various flags. |
471 expect_sync_configuration_aborted_ = false; | 475 expect_sync_configuration_aborted_ = false; |
472 is_auth_in_progress_ = false; | 476 is_auth_in_progress_ = false; |
473 backend_initialized_ = false; | 477 backend_initialized_ = false; |
474 cached_passphrase_ = CachedPassphrase(); | 478 cached_passphrases_ = CachedPassphrases(); |
475 gaia_password_.clear(); | |
476 pending_types_for_encryption_.clear(); | 479 pending_types_for_encryption_.clear(); |
477 set_backend_encrypted_types_ = false; | 480 set_backend_encrypted_types_ = false; |
478 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; | 481 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; |
479 last_attempted_user_email_.clear(); | 482 last_attempted_user_email_.clear(); |
480 last_auth_error_ = GoogleServiceAuthError::None(); | 483 last_auth_error_ = GoogleServiceAuthError::None(); |
481 } | 484 } |
482 | 485 |
483 void ProfileSyncService::ClearServerData() { | 486 void ProfileSyncService::ClearServerData() { |
484 clear_server_data_state_ = CLEAR_CLEARING; | 487 clear_server_data_state_ = CLEAR_CLEARING; |
485 clear_server_data_timer_.Start(FROM_HERE, | 488 clear_server_data_timer_.Start(FROM_HERE, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 sync_js_controller_.AttachJsBackend(js_backend); | 641 sync_js_controller_.AttachJsBackend(js_backend); |
639 | 642 |
640 // The very first time the backend initializes is effectively the first time | 643 // The very first time the backend initializes is effectively the first time |
641 // we can say we successfully "synced". last_synced_time_ will only be null | 644 // we can say we successfully "synced". last_synced_time_ will only be null |
642 // in this case, because the pref wasn't restored on StartUp. | 645 // in this case, because the pref wasn't restored on StartUp. |
643 if (last_synced_time_.is_null()) { | 646 if (last_synced_time_.is_null()) { |
644 UpdateLastSyncedTime(); | 647 UpdateLastSyncedTime(); |
645 } | 648 } |
646 NotifyObservers(); | 649 NotifyObservers(); |
647 | 650 |
648 if (!cros_user_.empty()) { | 651 if (auto_start_enabled_ && !SetupInProgress()) { |
| 652 // Backend is initialized but we're not in sync setup, so this must be an |
| 653 // autostart - mark our sync setup as completed. |
649 if (profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)) { | 654 if (profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)) { |
| 655 // TODO(sync): This call to ShowConfigure() should go away in favor |
| 656 // of the code below that calls wizard_.Step() - http://crbug.com/95269. |
650 ShowConfigure(true); | 657 ShowConfigure(true); |
651 return; | 658 return; |
652 } else { | 659 } else { |
653 SetSyncSetupCompleted(); | 660 SetSyncSetupCompleted(); |
654 } | 661 } |
655 } | 662 } |
656 | 663 |
657 if (HasSyncSetupCompleted()) { | 664 if (HasSyncSetupCompleted()) { |
658 ConfigureDataTypeManager(); | 665 ConfigureDataTypeManager(); |
659 } else if (SetupInProgress()) { | 666 } else if (SetupInProgress()) { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 if (unrecoverable_error_detected_) { | 810 if (unrecoverable_error_detected_) { |
804 // When unrecoverable error is detected we post a task to shutdown the | 811 // When unrecoverable error is detected we post a task to shutdown the |
805 // backend. The task might not have executed yet. | 812 // backend. The task might not have executed yet. |
806 return; | 813 return; |
807 } | 814 } |
808 | 815 |
809 VLOG(1) << "Passphrase required with reason: " | 816 VLOG(1) << "Passphrase required with reason: " |
810 << sync_api::PassphraseRequiredReasonToString(reason); | 817 << sync_api::PassphraseRequiredReasonToString(reason); |
811 passphrase_required_reason_ = reason; | 818 passphrase_required_reason_ = reason; |
812 | 819 |
813 // Store any passphrases we have into temps and clear out the originals so | |
814 // we don't hold on to the passphrases any longer than we have to. We | |
815 // then use the passphrases if they're present (after OnPassphraseAccepted). | |
816 std::string gaia_password = gaia_password_; | |
817 std::string cached_passphrase = cached_passphrase_.value; | |
818 bool is_explicit = cached_passphrase_.is_explicit; | |
819 bool is_creation = cached_passphrase_.is_creation; | |
820 gaia_password_ = std::string(); | |
821 cached_passphrase_ = CachedPassphrase(); | |
822 | |
823 // We will skip the passphrase prompt and suppress the warning if the | 820 // We will skip the passphrase prompt and suppress the warning if the |
824 // passphrase is needed for decryption but the user is not syncing an | 821 // passphrase is needed for decryption but the user is not syncing an |
825 // encrypted data type on this machine. Otherwise we look for one. | 822 // encrypted data type on this machine. Otherwise we look for one. |
826 if (!IsEncryptedDatatypeEnabled() && IsPassphraseRequiredForDecryption()) { | 823 if (!IsEncryptedDatatypeEnabled() && IsPassphraseRequiredForDecryption()) { |
827 VLOG(1) << "Decrypting and no encrypted datatypes enabled" | 824 VLOG(1) << "Decrypting and no encrypted datatypes enabled" |
828 << ", accepted passphrase."; | 825 << ", accepted passphrase."; |
829 OnPassphraseAccepted(); | 826 OnPassphraseAccepted(); |
830 } | 827 } |
831 | 828 |
832 // First try supplying gaia password as the passphrase. | 829 // First try supplying gaia password as the passphrase. |
833 if (!gaia_password.empty()) { | 830 // TODO(atwilson): This logic seems odd here - we know what kind of passphrase |
| 831 // is required (explicit/gaia) so we should not bother setting the wrong kind |
| 832 // of passphrase - http://crbug.com/95269. |
| 833 if (!cached_passphrases_.gaia_passphrase.empty()) { |
| 834 std::string gaia_passphrase = cached_passphrases_.gaia_passphrase; |
| 835 cached_passphrases_.gaia_passphrase.clear(); |
834 VLOG(1) << "Attempting gaia passphrase."; | 836 VLOG(1) << "Attempting gaia passphrase."; |
835 // SetPassphrase will set gaia_password_ if the syncer isn't ready. | 837 // SetPassphrase will re-cache this passphrase if the syncer isn't ready. |
836 SetPassphrase(gaia_password, false, true); | 838 SetPassphrase(gaia_passphrase, false); |
837 return; | 839 return; |
838 } | 840 } |
839 | 841 |
840 // If the above failed then try the custom passphrase the user might have | 842 // If the above failed then try the custom passphrase the user might have |
841 // entered in setup. | 843 // entered in setup. |
842 if (!cached_passphrase.empty()) { | 844 if (!cached_passphrases_.explicit_passphrase.empty()) { |
843 VLOG(1) << "Attempting cached passphrase."; | 845 std::string explicit_passphrase = cached_passphrases_.explicit_passphrase; |
844 // SetPassphrase will set cached_passphrase_ if the syncer isn't ready. | 846 cached_passphrases_.explicit_passphrase.clear(); |
845 SetPassphrase(cached_passphrase, is_explicit, is_creation); | 847 VLOG(1) << "Attempting explicit passphrase."; |
| 848 // SetPassphrase will re-cache this passphrase if the syncer isn't ready. |
| 849 SetPassphrase(explicit_passphrase, true); |
846 return; | 850 return; |
847 } | 851 } |
848 | 852 |
849 // Prompt the user for a password. | 853 // Prompt the user for a password. |
850 if (WizardIsVisible() && IsEncryptedDatatypeEnabled() && | 854 if (WizardIsVisible() && IsEncryptedDatatypeEnabled() && |
851 IsPassphraseRequiredForDecryption()) { | 855 IsPassphraseRequiredForDecryption()) { |
852 VLOG(1) << "Prompting user for passphrase."; | 856 VLOG(1) << "Prompting user for passphrase."; |
853 wizard_.Step(SyncSetupWizard::ENTER_PASSPHRASE); | 857 wizard_.Step(SyncSetupWizard::ENTER_PASSPHRASE); |
854 } | 858 } |
855 | 859 |
856 NotifyObservers(); | 860 NotifyObservers(); |
857 } | 861 } |
858 | 862 |
859 void ProfileSyncService::OnPassphraseAccepted() { | 863 void ProfileSyncService::OnPassphraseAccepted() { |
860 VLOG(1) << "Received OnPassphraseAccepted."; | 864 VLOG(1) << "Received OnPassphraseAccepted."; |
861 // Don't hold on to a passphrase in raw form longer than needed. | 865 // Don't hold on to a passphrase in raw form longer than needed. |
862 gaia_password_ = std::string(); | 866 cached_passphrases_ = CachedPassphrases(); |
863 cached_passphrase_ = CachedPassphrase(); | |
864 | 867 |
865 // Make sure the data types that depend on the passphrase are started at | 868 // Make sure the data types that depend on the passphrase are started at |
866 // this time. | 869 // this time. |
867 syncable::ModelTypeSet types; | 870 syncable::ModelTypeSet types; |
868 GetPreferredDataTypes(&types); | 871 GetPreferredDataTypes(&types); |
869 | 872 |
870 // Reset passphrase_required_reason_ before configuring the DataTypeManager | 873 // Reset passphrase_required_reason_ before configuring the DataTypeManager |
871 // since we know we no longer require the passphrase. | 874 // since we know we no longer require the passphrase. |
872 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; | 875 passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; |
873 | 876 |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 backend_->ActivateDataType(type, group, change_processor); | 1333 backend_->ActivateDataType(type, group, change_processor); |
1331 } | 1334 } |
1332 | 1335 |
1333 void ProfileSyncService::DeactivateDataType(syncable::ModelType type) { | 1336 void ProfileSyncService::DeactivateDataType(syncable::ModelType type) { |
1334 if (!backend_.get()) | 1337 if (!backend_.get()) |
1335 return; | 1338 return; |
1336 backend_->DeactivateDataType(type); | 1339 backend_->DeactivateDataType(type); |
1337 } | 1340 } |
1338 | 1341 |
1339 void ProfileSyncService::SetPassphrase(const std::string& passphrase, | 1342 void ProfileSyncService::SetPassphrase(const std::string& passphrase, |
1340 bool is_explicit, | 1343 bool is_explicit) { |
1341 bool is_creation) { | |
1342 if (ShouldPushChanges() || IsPassphraseRequired()) { | 1344 if (ShouldPushChanges() || IsPassphraseRequired()) { |
1343 VLOG(1) << "Setting " << (is_explicit ? "explicit" : "implicit") | 1345 VLOG(1) << "Setting " << (is_explicit ? "explicit" : "implicit"); |
1344 << " passphrase" << (is_creation ? " for creation" : ""); | |
1345 backend_->SetPassphrase(passphrase, is_explicit); | 1346 backend_->SetPassphrase(passphrase, is_explicit); |
1346 } else { | 1347 } else { |
1347 if (is_explicit) { | 1348 if (is_explicit) { |
1348 cached_passphrase_.value = passphrase; | 1349 cached_passphrases_.explicit_passphrase = passphrase; |
1349 cached_passphrase_.is_explicit = is_explicit; | |
1350 cached_passphrase_.is_creation = is_creation; | |
1351 } else { | 1350 } else { |
1352 gaia_password_ = passphrase; | 1351 cached_passphrases_.gaia_passphrase = passphrase; |
1353 } | 1352 } |
1354 } | 1353 } |
1355 } | 1354 } |
1356 | 1355 |
1357 void ProfileSyncService::set_pending_types_for_encryption( | 1356 void ProfileSyncService::set_pending_types_for_encryption( |
1358 const syncable::ModelTypeSet& encrypted_types) { | 1357 const syncable::ModelTypeSet& encrypted_types) { |
1359 set_backend_encrypted_types_ = false; | 1358 set_backend_encrypted_types_ = false; |
1360 if (encrypted_types.empty()) { | 1359 if (encrypted_types.empty()) { |
1361 // We can't unencrypt types. | 1360 // We can't unencrypt types. |
1362 VLOG(1) << "No datatypes set for encryption, dropping encryption request."; | 1361 VLOG(1) << "No datatypes set for encryption, dropping encryption request."; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 expect_sync_configuration_aborted_ = false; | 1410 expect_sync_configuration_aborted_ = false; |
1412 return; | 1411 return; |
1413 } | 1412 } |
1414 if (status != DataTypeManager::OK) { | 1413 if (status != DataTypeManager::OK) { |
1415 VLOG(0) << "ProfileSyncService::Observe: Unrecoverable error detected"; | 1414 VLOG(0) << "ProfileSyncService::Observe: Unrecoverable error detected"; |
1416 std::string message = | 1415 std::string message = |
1417 "Sync Configuration failed while configuring " + | 1416 "Sync Configuration failed while configuring " + |
1418 syncable::ModelTypeSetToString(result->failed_types) + | 1417 syncable::ModelTypeSetToString(result->failed_types) + |
1419 ": " + DataTypeManager::ConfigureStatusToString(status); | 1418 ": " + DataTypeManager::ConfigureStatusToString(status); |
1420 OnUnrecoverableError(result->location, message); | 1419 OnUnrecoverableError(result->location, message); |
1421 cached_passphrase_ = CachedPassphrase(); | 1420 cached_passphrases_ = CachedPassphrases(); |
1422 return; | 1421 return; |
1423 } | 1422 } |
1424 | 1423 |
1425 // We should never get in a state where we have no encrypted datatypes | 1424 // We should never get in a state where we have no encrypted datatypes |
1426 // enabled, and yet we still think we require a passphrase for decryption. | 1425 // enabled, and yet we still think we require a passphrase for decryption. |
1427 DCHECK(!(IsPassphraseRequiredForDecryption() && | 1426 DCHECK(!(IsPassphraseRequiredForDecryption() && |
1428 !IsEncryptedDatatypeEnabled())); | 1427 !IsEncryptedDatatypeEnabled())); |
1429 | 1428 |
1430 // In the old world, this would be a no-op. With new syncer thread, | 1429 // In the old world, this would be a no-op. With new syncer thread, |
1431 // this is the point where it is safe to switch from config-mode to | 1430 // this is the point where it is safe to switch from config-mode to |
(...skipping 18 matching lines...) Expand all Loading... |
1450 if (*pref_name == prefs::kSyncManaged) { | 1449 if (*pref_name == prefs::kSyncManaged) { |
1451 NotifyObservers(); | 1450 NotifyObservers(); |
1452 if (*pref_sync_managed_) { | 1451 if (*pref_sync_managed_) { |
1453 DisableForUser(); | 1452 DisableForUser(); |
1454 } else if (HasSyncSetupCompleted() && AreCredentialsAvailable()) { | 1453 } else if (HasSyncSetupCompleted() && AreCredentialsAvailable()) { |
1455 StartUp(); | 1454 StartUp(); |
1456 } | 1455 } |
1457 } | 1456 } |
1458 break; | 1457 break; |
1459 } | 1458 } |
1460 case chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL: { | |
1461 const GoogleServiceSigninSuccessDetails* successful = | |
1462 (Details<const GoogleServiceSigninSuccessDetails>(details).ptr()); | |
1463 // We pass 'false' to SetPassphrase to denote that this is an implicit | |
1464 // request and shouldn't override an explicit one. Thus, we either | |
1465 // update the implicit passphrase (idempotent if the passphrase didn't | |
1466 // actually change), or the user has an explicit passphrase set so this | |
1467 // becomes a no-op. | |
1468 if (browser_sync::IsUsingOAuth()) { | |
1469 // TODO(rickcam): Bug 92323: Fetch password through special Gaia request | |
1470 DCHECK(successful->password.empty()); | |
1471 LOG(WARNING) << "Not initializing sync passphrase."; | |
1472 } else { | |
1473 SetPassphrase(successful->password, false, true); | |
1474 } | |
1475 break; | |
1476 } | |
1477 case chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED: { | 1459 case chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED: { |
1478 GoogleServiceAuthError error = | 1460 GoogleServiceAuthError error = |
1479 *(Details<const GoogleServiceAuthError>(details).ptr()); | 1461 *(Details<const GoogleServiceAuthError>(details).ptr()); |
1480 UpdateAuthErrorState(error); | 1462 UpdateAuthErrorState(error); |
1481 break; | 1463 break; |
1482 } | 1464 } |
1483 case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: { | 1465 case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: { |
1484 GoogleServiceAuthError error( | 1466 GoogleServiceAuthError error( |
1485 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 1467 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
1486 UpdateAuthErrorState(error); | 1468 UpdateAuthErrorState(error); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 syncable::ModelTypeBitSetFromValue( | 1568 syncable::ModelTypeBitSetFromValue( |
1587 *profile_->GetPrefs()->GetList(prefs::kAcknowledgedSyncTypes)); | 1569 *profile_->GetPrefs()->GetList(prefs::kAcknowledgedSyncTypes)); |
1588 syncable::ModelTypeSet registered; | 1570 syncable::ModelTypeSet registered; |
1589 GetRegisteredDataTypes(®istered); | 1571 GetRegisteredDataTypes(®istered); |
1590 syncable::ModelTypeBitSet registered_bit_set = | 1572 syncable::ModelTypeBitSet registered_bit_set = |
1591 syncable::ModelTypeBitSetFromSet(registered); | 1573 syncable::ModelTypeBitSetFromSet(registered); |
1592 unacknowledged = registered_bit_set & ~acknowledged; | 1574 unacknowledged = registered_bit_set & ~acknowledged; |
1593 } | 1575 } |
1594 return unacknowledged; | 1576 return unacknowledged; |
1595 } | 1577 } |
1596 | |
OLD | NEW |