Chromium Code Reviews| 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 e36d7d87afb59df62a884f5d4984f52ac4917199..ae98f69631b6d0d0ddce0a7cff05773aae9fea3b 100644 |
| --- a/chrome/browser/sync/profile_sync_service_factory.cc |
| +++ b/chrome/browser/sync/profile_sync_service_factory.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/memory/ptr_util.h" |
| #include "base/memory/singleton.h" |
| +#include "base/path_service.h" |
| #include "base/time/time.h" |
| #include "build/build_config.h" |
| #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| @@ -31,6 +32,7 @@ |
| #include "chrome/browser/themes/theme_service_factory.h" |
| #include "chrome/browser/web_data_service_factory.h" |
| #include "chrome/common/channel_info.h" |
| +#include "components/browser_sync/browser_sync_switches.h" |
| #include "components/browser_sync/profile_sync_components_factory_impl.h" |
| #include "components/browser_sync/profile_sync_service.h" |
| #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| @@ -74,6 +76,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 |
| @@ -144,33 +151,79 @@ 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(); |
| + init_params.local_sync_backend_enabled = false; |
| + |
| +#if defined(OS_WIN) |
| + init_params.local_sync_backend_enabled = |
| + base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableLocalSyncBackend); |
| + |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
|
Nicolas Zea
2016/11/19 00:36:42
should all of this logic be dependent on local_syn
pastarmovj
2016/11/22 12:38:08
Done.
|
| + switches::kLocalSyncBackendDir)) { |
| + init_params.local_sync_backend_folder = |
| + base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| + switches::kLocalSyncBackendDir); |
| + } else { |
| + // TODO(pastarmovj): Add DIR_ROAMING_USER_DATA to PathService to simplify |
| + // this code and move the logic in its right place. See crbug/657810. |
| + CHECK(base::PathService::Get(base::DIR_APP_DATA, |
| + &init_params.local_sync_backend_folder)); |
| + init_params.local_sync_backend_folder = |
| + init_params.local_sync_backend_folder.Append( |
| + FILE_PATH_LITERAL("Chrome/User Data")); |
| + } |
| + // 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 = |
| + 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); |
| +#endif // defined(OS_WIN) |
| + |
| + if (!init_params.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; |
| + } else { |
| + // In local mode none of the sign-in stuff is required. |
| + init_params.start_behavior = ProfileSyncService::AUTO_START; |
|
Nicolas Zea
2016/11/19 00:36:42
I think it's cleaner to move this up to the #if de
pastarmovj
2016/11/22 12:38:08
Done.
Btw technically all of the above can always
|
| + } |
| if (!client_factory_) { |
| init_params.sync_client = |
| @@ -179,13 +232,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. |