| OLD | NEW |
| 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/sync/profile_sync_service_factory.h" | 5 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 10 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 12 #include "chrome/browser/defaults.h" | 12 #include "chrome/browser/defaults.h" |
| 13 #include "chrome/browser/extensions/extension_system_factory.h" | |
| 14 #include "chrome/browser/history/history_service_factory.h" | 13 #include "chrome/browser/history/history_service_factory.h" |
| 15 #include "chrome/browser/invalidation/invalidation_service_factory.h" | 14 #include "chrome/browser/invalidation/invalidation_service_factory.h" |
| 16 #include "chrome/browser/managed_mode/managed_user_signin_manager_wrapper.h" | 15 #include "chrome/browser/managed_mode/managed_user_signin_manager_wrapper.h" |
| 17 #include "chrome/browser/password_manager/password_store_factory.h" | 16 #include "chrome/browser/password_manager/password_store_factory.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/browser/search_engines/template_url_service_factory.h" | 19 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 21 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 20 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 22 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 21 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 23 #include "chrome/browser/signin/about_signin_internals_factory.h" | 22 #include "chrome/browser/signin/about_signin_internals_factory.h" |
| 24 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 23 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 26 #include "chrome/browser/signin/signin_manager.h" | 25 #include "chrome/browser/signin/signin_manager.h" |
| 27 #include "chrome/browser/signin/signin_manager_factory.h" | 26 #include "chrome/browser/signin/signin_manager_factory.h" |
| 28 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" | 27 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" |
| 29 #include "chrome/browser/sync/profile_sync_service.h" | 28 #include "chrome/browser/sync/profile_sync_service.h" |
| 30 #include "chrome/browser/themes/theme_service_factory.h" | 29 #include "chrome/browser/themes/theme_service_factory.h" |
| 31 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 30 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 32 #include "chrome/browser/webdata/web_data_service_factory.h" | 31 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 33 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 34 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 33 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 34 #include "extensions/browser/extension_system_provider.h" |
| 35 #include "extensions/browser/extensions_browser_client.h" |
| 35 | 36 |
| 36 // static | 37 // static |
| 37 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { | 38 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { |
| 38 return Singleton<ProfileSyncServiceFactory>::get(); | 39 return Singleton<ProfileSyncServiceFactory>::get(); |
| 39 } | 40 } |
| 40 | 41 |
| 41 // static | 42 // static |
| 42 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( | 43 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( |
| 43 Profile* profile) { | 44 Profile* profile) { |
| 44 if (!ProfileSyncService::IsSyncEnabled()) | 45 if (!ProfileSyncService::IsSyncEnabled()) |
| 45 return NULL; | 46 return NULL; |
| 46 | 47 |
| 47 return static_cast<ProfileSyncService*>( | 48 return static_cast<ProfileSyncService*>( |
| 48 GetInstance()->GetServiceForBrowserContext(profile, true)); | 49 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 49 } | 50 } |
| 50 | 51 |
| 51 ProfileSyncServiceFactory::ProfileSyncServiceFactory() | 52 ProfileSyncServiceFactory::ProfileSyncServiceFactory() |
| 52 : BrowserContextKeyedServiceFactory( | 53 : BrowserContextKeyedServiceFactory( |
| 53 "ProfileSyncService", | 54 "ProfileSyncService", |
| 54 BrowserContextDependencyManager::GetInstance()) { | 55 BrowserContextDependencyManager::GetInstance()) { |
| 55 | 56 |
| 56 // The ProfileSyncService depends on various SyncableServices being around | 57 // The ProfileSyncService depends on various SyncableServices being around |
| 57 // when it is shut down. Specify those dependencies here to build the proper | 58 // when it is shut down. Specify those dependencies here to build the proper |
| 58 // destruction order. | 59 // destruction order. |
| 59 DependsOn(AboutSigninInternalsFactory::GetInstance()); | 60 DependsOn(AboutSigninInternalsFactory::GetInstance()); |
| 60 DependsOn(autofill::PersonalDataManagerFactory::GetInstance()); | 61 DependsOn(autofill::PersonalDataManagerFactory::GetInstance()); |
| 61 DependsOn(BookmarkModelFactory::GetInstance()); | 62 DependsOn(BookmarkModelFactory::GetInstance()); |
| 62 DependsOn(extensions::ExtensionSystemFactory::GetInstance()); | 63 DependsOn( |
| 64 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| 63 DependsOn(GlobalErrorServiceFactory::GetInstance()); | 65 DependsOn(GlobalErrorServiceFactory::GetInstance()); |
| 64 DependsOn(HistoryServiceFactory::GetInstance()); | 66 DependsOn(HistoryServiceFactory::GetInstance()); |
| 65 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); | 67 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); |
| 66 DependsOn(PasswordStoreFactory::GetInstance()); | 68 DependsOn(PasswordStoreFactory::GetInstance()); |
| 67 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); | 69 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); |
| 68 DependsOn(SigninManagerFactory::GetInstance()); | 70 DependsOn(SigninManagerFactory::GetInstance()); |
| 69 DependsOn(TemplateURLServiceFactory::GetInstance()); | 71 DependsOn(TemplateURLServiceFactory::GetInstance()); |
| 70 #if defined(ENABLE_THEMES) | 72 #if defined(ENABLE_THEMES) |
| 71 DependsOn(ThemeServiceFactory::GetInstance()); | 73 DependsOn(ThemeServiceFactory::GetInstance()); |
| 72 #endif | 74 #endif |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 126 |
| 125 pss->factory()->RegisterDataTypes(pss); | 127 pss->factory()->RegisterDataTypes(pss); |
| 126 pss->Initialize(); | 128 pss->Initialize(); |
| 127 return pss; | 129 return pss; |
| 128 } | 130 } |
| 129 | 131 |
| 130 // static | 132 // static |
| 131 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { | 133 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { |
| 132 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; | 134 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; |
| 133 } | 135 } |
| OLD | NEW |