Chromium Code Reviews| Index: chrome/browser/sync/profile_sync_service.cc |
| diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc |
| index 99299b8d7efb72c9139a19144b0b7cb352e55871..b74136eb2a6257bc5e3d473b992b18151609410e 100644 |
| --- a/chrome/browser/sync/profile_sync_service.cc |
| +++ b/chrome/browser/sync/profile_sync_service.cc |
| @@ -188,19 +188,20 @@ void ProfileSyncService::Initialize() { |
| signin_->Initialize(profile_); |
| } |
| - if (!HasSyncSetupCompleted()) { |
| - // If autostart is enabled, but we haven't completed sync setup, try to |
| - // start sync anyway (it's possible we crashed/shutdown after logging in |
| - // but before the backend finished initializing the last time). |
| - if (auto_start_enabled_ && !sync_prefs_.IsStartSuppressed() && |
| - AreCredentialsAvailable()) { |
| + StartUpIfNotSuppressed(); |
| +} |
| + |
| +void ProfileSyncService::StartUpIfNotSuppressed() { |
| + if (!sync_prefs_.IsStartSuppressed() && AreCredentialsAvailable()) { |
| + if (HasSyncSetupCompleted() || auto_start_enabled_) { |
| + // If sync setup has completed we always start the backend. |
| + // If autostart is enabled, but we haven't completed sync setup, we try to |
| + // start sync anyway, since it's possible we crashed/shutdown after |
| + // logging in but before the backend finished initializing the last time. |
| + // Note that if we haven't finished setting up sync, backend bring up will |
| + // be done by the wizard. |
| StartUp(); |
| } |
| - } else if (AreCredentialsAvailable()) { |
| - // If we have credentials and sync setup finished, autostart the backend. |
| - // Note that if we haven't finished setting up sync, backend bring up will |
| - // be done by the wizard. |
| - StartUp(); |
| } |
| } |
| @@ -1512,6 +1513,22 @@ bool ProfileSyncService::ShouldPushChanges() { |
| return data_type_manager_->state() == DataTypeManager::CONFIGURED; |
| } |
| +void ProfileSyncService::StopSyncAndSuppressStartUp() { |
| + sync_prefs_.SetStartSuppressed(true); |
| + Shutdown(false); |
| +} |
| + |
| +void ProfileSyncService::DisableSyncSuppressionAndStartUpSync() { |
| + DCHECK(profile_); |
| + sync_prefs_.SetStartSuppressed(false); |
| + // Set username in SigninManager, as SigninManager::OnGetUserInfoSuccess |
| + // is never called for some clients. |
| + if (signin_->GetUsername().empty()) { |
| + signin_->SetUsername(profile_->GetProfileName()); |
|
akalin
2011/10/26 18:53:09
What is the username used for? Isn't the profile
|
| + } |
| + StartUpIfNotSuppressed(); |
| +} |
| + |
| void ProfileSyncService::AcknowledgeSyncedTypes() { |
| syncable::ModelTypeSet registered_types; |
| GetRegisteredDataTypes(®istered_types); |