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

Side by Side Diff: chrome/browser/profiles/profile.cc

Issue 2494873003: [Sync] Allow sync start without sign-in if the local sync backend is on. (Closed)
Patch Set: Merge pref changes from https://codereview.chromium.org/2528163002/. Created 4 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/profiles/profile.h" 5 #include "chrome/browser/profiles/profile.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 bool Profile::IsNewProfile() { 204 bool Profile::IsNewProfile() {
205 // The profile has been shut down if the prefs were loaded from disk, unless 205 // The profile has been shut down if the prefs were loaded from disk, unless
206 // first-run autoimport wrote them and reloaded the pref service. 206 // first-run autoimport wrote them and reloaded the pref service.
207 // TODO(crbug.com/660346): revisit this when crbug.com/22142 (unifying the 207 // TODO(crbug.com/660346): revisit this when crbug.com/22142 (unifying the
208 // profile import code) is fixed. 208 // profile import code) is fixed.
209 return GetOriginalProfile()->GetPrefs()->GetInitializationStatus() == 209 return GetOriginalProfile()->GetPrefs()->GetInitializationStatus() ==
210 PrefService::INITIALIZATION_STATUS_CREATED_NEW_PREF_STORE; 210 PrefService::INITIALIZATION_STATUS_CREATED_NEW_PREF_STORE;
211 } 211 }
212 212
213 bool Profile::IsSyncAllowed() { 213 bool Profile::IsSyncAllowed() {
214 if (ProfileSyncServiceFactory::HasProfileSyncService(this)) { 214 if (ProfileSyncServiceFactory::HasProfileSyncService(this))
215 return ProfileSyncServiceFactory::GetForProfile(this)->IsSyncAllowed(); 215 return ProfileSyncServiceFactory::GetForProfile(this)->IsSyncAllowed();
216 }
217 216
218 // No ProfileSyncService created yet - we don't want to create one, so just 217 // No ProfileSyncService created yet - we don't want to create one, so just
219 // infer the accessible state by looking at prefs/command line flags. 218 // infer the accessible state by looking at prefs/command line flags.
220 syncer::SyncPrefs prefs(GetPrefs()); 219 syncer::SyncPrefs prefs(GetPrefs());
221 return browser_sync::ProfileSyncService::IsSyncAllowedByFlag() && 220 return browser_sync::ProfileSyncService::IsSyncAllowedByFlag() &&
222 !prefs.IsManaged(); 221 !prefs.IsManaged();
223 } 222 }
224 223
224 bool Profile::IsLocalSyncEnabled() {
Nicolas Zea 2016/12/15 00:37:28 Do we really need this exposed here? Can we just h
pastarmovj 2016/12/16 17:04:48 As suggested reverted this change.
225 if (ProfileSyncServiceFactory::HasProfileSyncService(this))
226 return ProfileSyncServiceFactory::GetForProfile(this)->IsLocalSyncEnabled();
227
228 // No ProfileSyncService created yet - we don't want to create one, so just
229 // infer the accessible state by looking at prefs/command line flags.
230 syncer::SyncPrefs prefs(GetPrefs());
231 return prefs.IsLocalSyncEnabled();
232 }
233
225 void Profile::MaybeSendDestroyedNotification() { 234 void Profile::MaybeSendDestroyedNotification() {
226 if (!sent_destroyed_notification_) { 235 if (!sent_destroyed_notification_) {
227 sent_destroyed_notification_ = true; 236 sent_destroyed_notification_ = true;
228 237
229 NotifyWillBeDestroyed(this); 238 NotifyWillBeDestroyed(this);
230 content::NotificationService::current()->Notify( 239 content::NotificationService::current()->Notify(
231 chrome::NOTIFICATION_PROFILE_DESTROYED, 240 chrome::NOTIFICATION_PROFILE_DESTROYED,
232 content::Source<Profile>(this), 241 content::Source<Profile>(this),
233 content::NotificationService::NoDetails()); 242 content::NotificationService::NoDetails());
234 } 243 }
235 } 244 }
236 245
237 bool ProfileCompare::operator()(Profile* a, Profile* b) const { 246 bool ProfileCompare::operator()(Profile* a, Profile* b) const {
238 DCHECK(a && b); 247 DCHECK(a && b);
239 if (a->IsSameProfile(b)) 248 if (a->IsSameProfile(b))
240 return false; 249 return false;
241 return a->GetOriginalProfile() < b->GetOriginalProfile(); 250 return a->GetOriginalProfile() < b->GetOriginalProfile();
242 } 251 }
243 252
244 double Profile::GetDefaultZoomLevelForProfile() { 253 double Profile::GetDefaultZoomLevelForProfile() {
245 return GetDefaultStoragePartition(this) 254 return GetDefaultStoragePartition(this)
246 ->GetHostZoomMap() 255 ->GetHostZoomMap()
247 ->GetDefaultZoomLevel(); 256 ->GetDefaultZoomLevel();
248 } 257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698