This source file includes following definitions.
- GetInstance
- GetForProfile
- BuildServiceInstanceFor
- HasProfileSyncService
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "base/command_line.h"
#include "base/memory/singleton.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/invalidation/invalidation_service_factory.h"
#include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/signin/about_signin_internals_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/managed_user_signin_manager_wrapper.h"
#include "chrome/browser/sync/profile_sync_components_factory_impl.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/startup_controller.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/global_error/global_error_service_factory.h"
#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/pref_names.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "extensions/browser/extension_system_provider.h"
#include "extensions/browser/extensions_browser_client.h"
ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() {
return Singleton<ProfileSyncServiceFactory>::get();
}
ProfileSyncService* ProfileSyncServiceFactory::GetForProfile(
Profile* profile) {
if (!ProfileSyncService::IsSyncEnabled())
return NULL;
return static_cast<ProfileSyncService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
ProfileSyncServiceFactory::ProfileSyncServiceFactory()
: BrowserContextKeyedServiceFactory(
"ProfileSyncService",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(AboutSigninInternalsFactory::GetInstance());
DependsOn(autofill::PersonalDataManagerFactory::GetInstance());
DependsOn(BookmarkModelFactory::GetInstance());
DependsOn(
extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
DependsOn(GlobalErrorServiceFactory::GetInstance());
DependsOn(HistoryServiceFactory::GetInstance());
DependsOn(invalidation::InvalidationServiceFactory::GetInstance());
DependsOn(PasswordStoreFactory::GetInstance());
DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
DependsOn(SigninManagerFactory::GetInstance());
DependsOn(TemplateURLServiceFactory::GetInstance());
#if defined(ENABLE_THEMES)
DependsOn(ThemeServiceFactory::GetInstance());
#endif
DependsOn(WebDataServiceFactory::GetInstance());
}
ProfileSyncServiceFactory::~ProfileSyncServiceFactory() {
}
KeyedService* ProfileSyncServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = static_cast<Profile*>(context);
SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile);
gcm::GCMProfileServiceFactory::GetForProfile(profile);
AboutSigninInternalsFactory::GetForProfile(profile);
browser_sync::ProfileSyncServiceStartBehavior behavior =
browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START
: browser_sync::MANUAL_START;
ProfileSyncService* pss = new ProfileSyncService(
new ProfileSyncComponentsFactoryImpl(profile,
CommandLine::ForCurrentProcess()),
profile,
new ManagedUserSigninManagerWrapper(profile, signin),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
behavior);
pss->factory()->RegisterDataTypes(pss);
pss->Initialize();
return pss;
}
bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) {
return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL;
}