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

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

Issue 2494873003: [Sync] Allow sync start without sign-in if the local sync backend is on. (Closed)
Patch Set: Remove ifdefs around include. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/prefs/chrome_command_line_pref_store.cc ('k') | chrome/browser/ui/sync/sync_promo_ui.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_factory.cc
diff --git a/chrome/browser/sync/profile_sync_service_factory.cc b/chrome/browser/sync/profile_sync_service_factory.cc
index ce61b07df2e422fa92f9b7c3bf5d088850d0b65d..f9c8481e4056ee92b52757fc56c241edb558006e 100644
--- a/chrome/browser/sync/profile_sync_service_factory.cc
+++ b/chrome/browser/sync/profile_sync_service_factory.cc
@@ -74,6 +74,11 @@ void UpdateNetworkTime(const base::Time& network_time,
latency, base::TimeTicks::Now()));
}
+#if defined(OS_WIN)
+static const base::FilePath::CharType kLoopbackServerBackendFilename[] =
+ FILE_PATH_LITERAL("profile.pb");
+#endif
+
} // anonymous namespace
// static
@@ -142,33 +147,68 @@ KeyedService* ProfileSyncServiceFactory::BuildServiceInstanceFor(
Profile* profile = Profile::FromBrowserContext(context);
- SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile);
-
- // Always create the GCMProfileService instance such that we can listen to
- // the profile notifications and purge the GCM store when the profile is
- // being signed out.
- gcm::GCMProfileServiceFactory::GetForProfile(profile);
-
- // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup
- // once http://crbug.com/171406 has been fixed.
- AboutSigninInternalsFactory::GetForProfile(profile);
-
- init_params.signin_wrapper =
- base::MakeUnique<SupervisedUserSigninManagerWrapper>(profile, signin);
- init_params.oauth2_token_service =
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
- init_params.gaia_cookie_manager_service =
- GaiaCookieManagerServiceFactory::GetForProfile(profile);
-
- // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync
- // is set up and *not* a browser restart for a manual-start platform (where
- // sync has already been set up, and should be able to start without user
- // intervention). We can get rid of the browser_default eventually, but
- // need to take care that ProfileSyncService doesn't get tripped up between
- // those two cases. Bug 88109.
- init_params.start_behavior = browser_defaults::kSyncAutoStarts
- ? ProfileSyncService::AUTO_START
- : ProfileSyncService::MANUAL_START;
+ init_params.network_time_update_callback = base::Bind(&UpdateNetworkTime);
+ init_params.base_directory = profile->GetPath();
+ init_params.url_request_context = profile->GetRequestContext();
+ init_params.debug_identifier = profile->GetDebugName();
+ init_params.channel = chrome::GetChannel();
+ init_params.blocking_pool = content::BrowserThread::GetBlockingPool();
+
+ bool local_sync_backend_enabled = false;
+
+// Since the local sync backend is currently only supported on Windows don't
+// even check the pref on other os-es.
+#if defined(OS_WIN)
+ syncer::SyncPrefs prefs(profile->GetPrefs());
+ local_sync_backend_enabled = prefs.IsLocalSyncEnabled();
+ if (local_sync_backend_enabled) {
+ // This code as it is now will assume the same profile order is present on
+ // all machines, which is not a given. It is to be defined if only the
+ // Default profile should get this treatment or all profile as is the case
+ // now. The solution for now will be to assume profiles are created in the
+ // same order on all machines and in the future decide if only the Default
+ // one should be considered roamed.
+ init_params.local_sync_backend_folder = prefs.GetLocalSyncBackendDir();
+ init_params.local_sync_backend_folder =
+ init_params.local_sync_backend_folder.Append(
+ init_params.base_directory.BaseName());
+ init_params.local_sync_backend_folder =
+ init_params.local_sync_backend_folder.Append(
+ kLoopbackServerBackendFilename);
+
+ init_params.start_behavior = ProfileSyncService::AUTO_START;
+ }
+#endif // defined(OS_WIN)
+
+ if (!local_sync_backend_enabled) {
+ SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile);
+
+ // Always create the GCMProfileService instance such that we can listen to
+ // the profile notifications and purge the GCM store when the profile is
+ // being signed out.
+ gcm::GCMProfileServiceFactory::GetForProfile(profile);
+
+ // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup
+ // once http://crbug.com/171406 has been fixed.
+ AboutSigninInternalsFactory::GetForProfile(profile);
+
+ init_params.signin_wrapper =
+ base::MakeUnique<SupervisedUserSigninManagerWrapper>(profile, signin);
+ init_params.oauth2_token_service =
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
+ init_params.gaia_cookie_manager_service =
+ GaiaCookieManagerServiceFactory::GetForProfile(profile);
+
+ // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync
+ // is set up and *not* a browser restart for a manual-start platform (where
+ // sync has already been set up, and should be able to start without user
+ // intervention). We can get rid of the browser_default eventually, but
+ // need to take care that ProfileSyncService doesn't get tripped up between
+ // those two cases. Bug 88109.
+ init_params.start_behavior = browser_defaults::kSyncAutoStarts
+ ? ProfileSyncService::AUTO_START
+ : ProfileSyncService::MANUAL_START;
+ }
if (!client_factory_) {
init_params.sync_client =
@@ -177,13 +217,6 @@ KeyedService* ProfileSyncServiceFactory::BuildServiceInstanceFor(
init_params.sync_client = client_factory_->Run(profile);
}
- init_params.network_time_update_callback = base::Bind(&UpdateNetworkTime);
- init_params.base_directory = profile->GetPath();
- init_params.url_request_context = profile->GetRequestContext();
- init_params.debug_identifier = profile->GetDebugName();
- init_params.channel = chrome::GetChannel();
- init_params.blocking_pool = content::BrowserThread::GetBlockingPool();
-
auto pss = base::MakeUnique<ProfileSyncService>(std::move(init_params));
// Will also initialize the sync client.
« no previous file with comments | « chrome/browser/prefs/chrome_command_line_pref_store.cc ('k') | chrome/browser/ui/sync/sync_promo_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698