Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1946)

Unified Diff: chrome/browser/sync/profile_sync_service.cc

Issue 8332023: Add support for temporarily disabling sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..70ca58d9c2fd98344ea167d3d72aa84e67cc9a4e 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -188,19 +188,24 @@ 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()) {
Andrew T Wilson (Slow) 2011/10/26 01:23:26 Should we combine this whole if statement into: i
qsr 2011/10/26 07:07:00 That would need changing the else statement and ma
+ // 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_) {
+ StartUp();
+ }
+ } else {
+ // 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();
}
- } 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 +1517,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());
+ }
+ StartUpIfNotSuppressed();
+}
+
void ProfileSyncService::AcknowledgeSyncedTypes() {
syncable::ModelTypeSet registered_types;
GetRegisteredDataTypes(&registered_types);
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698