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

Side by Side Diff: ios/chrome/browser/sync/sync_setup_service.cc

Issue 1175243009: [Sync] Rename SyncEnabledAndLoggedIn() to CanStartSync(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missed a const transition. Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « components/sync_driver/sync_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "ios/chrome/browser/sync/sync_setup_service.h" 5 #include "ios/chrome/browser/sync/sync_setup_service.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "components/sync_driver/sync_prefs.h" 10 #include "components/sync_driver/sync_prefs.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 98
99 void SyncSetupService::SetSyncingAllDataTypes(bool sync_all) { 99 void SyncSetupService::SetSyncingAllDataTypes(bool sync_all) {
100 sync_service_->SetSetupInProgress(true); 100 sync_service_->SetSetupInProgress(true);
101 if (sync_all && !IsSyncEnabled()) 101 if (sync_all && !IsSyncEnabled())
102 SetSyncEnabled(true); 102 SetSyncEnabled(true);
103 sync_service_->OnUserChoseDatatypes(sync_all, GetDataTypes()); 103 sync_service_->OnUserChoseDatatypes(sync_all, GetDataTypes());
104 } 104 }
105 105
106 bool SyncSetupService::IsSyncEnabled() const { 106 bool SyncSetupService::IsSyncEnabled() const {
107 return sync_service_->IsSyncEnabledAndLoggedIn(); 107 return sync_service_->CanSyncStart();
108 } 108 }
109 109
110 void SyncSetupService::SetSyncEnabled(bool sync_enabled) { 110 void SyncSetupService::SetSyncEnabled(bool sync_enabled) {
111 SetSyncEnabledWithoutChangingDatatypes(sync_enabled); 111 SetSyncEnabledWithoutChangingDatatypes(sync_enabled);
112 if (sync_enabled && GetDataTypes().Empty()) 112 if (sync_enabled && GetDataTypes().Empty())
113 SetSyncingAllDataTypes(true); 113 SetSyncingAllDataTypes(true);
114 } 114 }
115 115
116 SyncSetupService::SyncServiceState SyncSetupService::GetSyncServiceState() { 116 SyncSetupService::SyncServiceState SyncSetupService::GetSyncServiceState() {
117 switch (sync_service_->GetAuthError().state()) { 117 switch (sync_service_->GetAuthError().state()) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (sync_service_->IsPassphraseRequiredForDecryption()) 152 if (sync_service_->IsPassphraseRequiredForDecryption())
153 return kSyncServiceNeedsPassphrase; 153 return kSyncServiceNeedsPassphrase;
154 return kNoSyncServiceError; 154 return kNoSyncServiceError;
155 } 155 }
156 156
157 bool SyncSetupService::HasFinishedInitialSetup() { 157 bool SyncSetupService::HasFinishedInitialSetup() {
158 // Sync initial setup is considered to finished iff: 158 // Sync initial setup is considered to finished iff:
159 // 1. User is signed in with sync enabled and the sync setup was completed. 159 // 1. User is signed in with sync enabled and the sync setup was completed.
160 // OR 160 // OR
161 // 2. User is not signed in or has disabled sync. 161 // 2. User is not signed in or has disabled sync.
162 return !sync_service_->IsSyncEnabledAndLoggedIn() || 162 return !sync_service_->CanSyncStart() ||
163 sync_service_->HasSyncSetupCompleted(); 163 sync_service_->HasSyncSetupCompleted();
164 } 164 }
165 165
166 void SyncSetupService::PrepareForFirstSyncSetup() { 166 void SyncSetupService::PrepareForFirstSyncSetup() {
167 // |PrepareForFirstSyncSetup| should always be called while the user is signed 167 // |PrepareForFirstSyncSetup| should always be called while the user is signed
168 // out. At that time, sync setup is not completed. 168 // out. At that time, sync setup is not completed.
169 DCHECK(!sync_service_->HasSyncSetupCompleted()); 169 DCHECK(!sync_service_->HasSyncSetupCompleted());
170 sync_service_->SetSetupInProgress(true); 170 sync_service_->SetSetupInProgress(true);
171 } 171 }
172 172
173 void SyncSetupService::CommitChanges() { 173 void SyncSetupService::CommitChanges() {
174 if (sync_service_->FirstSetupInProgress()) { 174 if (sync_service_->FirstSetupInProgress()) {
175 // Turn on the sync setup completed flag only if the user did not turn sync 175 // Turn on the sync setup completed flag only if the user did not turn sync
176 // off. 176 // off.
177 if (sync_service_->IsSyncEnabledAndLoggedIn()) { 177 if (sync_service_->CanSyncStart()) {
178 sync_service_->SetSyncSetupCompleted(); 178 sync_service_->SetSyncSetupCompleted();
179 } 179 }
180 } 180 }
181 181
182 sync_service_->SetSetupInProgress(false); 182 sync_service_->SetSetupInProgress(false);
183 } 183 }
184 184
185 bool SyncSetupService::HasUncommittedChanges() { 185 bool SyncSetupService::HasUncommittedChanges() {
186 return sync_service_->setup_in_progress(); 186 return sync_service_->setup_in_progress();
187 } 187 }
188 188
189 void SyncSetupService::SetSyncEnabledWithoutChangingDatatypes( 189 void SyncSetupService::SetSyncEnabledWithoutChangingDatatypes(
190 bool sync_enabled) { 190 bool sync_enabled) {
191 sync_service_->SetSetupInProgress(true); 191 sync_service_->SetSetupInProgress(true);
192 if (sync_enabled) 192 if (sync_enabled)
193 sync_service_->RequestStart(); 193 sync_service_->RequestStart();
194 else 194 else
195 sync_service_->RequestStop(); 195 sync_service_->RequestStop();
196 } 196 }
OLDNEW
« no previous file with comments | « components/sync_driver/sync_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698