| 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/history/history_service_factory.h" | 13 #include "chrome/browser/history/history_service_factory.h" |
| 14 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 14 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
| 15 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac
tory.h" | |
| 16 #include "chrome/browser/password_manager/password_store_factory.h" | 15 #include "chrome/browser/password_manager/password_store_factory.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/browser/search_engines/template_url_service_factory.h" | 18 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 20 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 19 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 21 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 20 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 22 #include "chrome/browser/signin/about_signin_internals_factory.h" | 21 #include "chrome/browser/signin/about_signin_internals_factory.h" |
| 23 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 22 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 24 #include "chrome/browser/signin/signin_manager_factory.h" | 23 #include "chrome/browser/signin/signin_manager_factory.h" |
| 25 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" | 24 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" |
| 26 #include "chrome/browser/sync/profile_sync_service.h" | 25 #include "chrome/browser/sync/profile_sync_service.h" |
| 27 #include "chrome/browser/sync/startup_controller.h" | 26 #include "chrome/browser/sync/startup_controller.h" |
| 28 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" | 27 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" |
| 29 #include "chrome/browser/themes/theme_service_factory.h" | 28 #include "chrome/browser/themes/theme_service_factory.h" |
| 30 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 29 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 31 #include "chrome/browser/webdata/web_data_service_factory.h" | 30 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 32 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 33 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 32 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 34 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 33 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 35 #include "components/signin/core/browser/signin_manager.h" | 34 #include "components/signin/core/browser/signin_manager.h" |
| 35 #include "url/gurl.h" |
| 36 |
| 37 #if defined(ENABLE_EXTENSIONS) |
| 38 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac
tory.h" |
| 36 #include "extensions/browser/extension_system_provider.h" | 39 #include "extensions/browser/extension_system_provider.h" |
| 37 #include "extensions/browser/extensions_browser_client.h" | 40 #include "extensions/browser/extensions_browser_client.h" |
| 38 #include "url/gurl.h" | 41 #endif |
| 39 | 42 |
| 40 // static | 43 // static |
| 41 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { | 44 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { |
| 42 return Singleton<ProfileSyncServiceFactory>::get(); | 45 return Singleton<ProfileSyncServiceFactory>::get(); |
| 43 } | 46 } |
| 44 | 47 |
| 45 // static | 48 // static |
| 46 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( | 49 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( |
| 47 Profile* profile) { | 50 Profile* profile) { |
| 48 if (!ProfileSyncService::IsSyncEnabled()) | 51 if (!ProfileSyncService::IsSyncEnabled()) |
| 49 return NULL; | 52 return NULL; |
| 50 | 53 |
| 51 return static_cast<ProfileSyncService*>( | 54 return static_cast<ProfileSyncService*>( |
| 52 GetInstance()->GetServiceForBrowserContext(profile, true)); | 55 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 53 } | 56 } |
| 54 | 57 |
| 55 ProfileSyncServiceFactory::ProfileSyncServiceFactory() | 58 ProfileSyncServiceFactory::ProfileSyncServiceFactory() |
| 56 : BrowserContextKeyedServiceFactory( | 59 : BrowserContextKeyedServiceFactory( |
| 57 "ProfileSyncService", | 60 "ProfileSyncService", |
| 58 BrowserContextDependencyManager::GetInstance()) { | 61 BrowserContextDependencyManager::GetInstance()) { |
| 59 | |
| 60 // The ProfileSyncService depends on various SyncableServices being around | 62 // The ProfileSyncService depends on various SyncableServices being around |
| 61 // when it is shut down. Specify those dependencies here to build the proper | 63 // when it is shut down. Specify those dependencies here to build the proper |
| 62 // destruction order. | 64 // destruction order. |
| 63 DependsOn(AboutSigninInternalsFactory::GetInstance()); | 65 DependsOn(AboutSigninInternalsFactory::GetInstance()); |
| 64 DependsOn(autofill::PersonalDataManagerFactory::GetInstance()); | 66 DependsOn(autofill::PersonalDataManagerFactory::GetInstance()); |
| 65 DependsOn(BookmarkModelFactory::GetInstance()); | 67 DependsOn(BookmarkModelFactory::GetInstance()); |
| 66 DependsOn( | |
| 67 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | |
| 68 DependsOn(GlobalErrorServiceFactory::GetInstance()); | 68 DependsOn(GlobalErrorServiceFactory::GetInstance()); |
| 69 DependsOn(HistoryServiceFactory::GetInstance()); | 69 DependsOn(HistoryServiceFactory::GetInstance()); |
| 70 DependsOn(invalidation::ProfileInvalidationProviderFactory::GetInstance()); | 70 DependsOn(invalidation::ProfileInvalidationProviderFactory::GetInstance()); |
| 71 DependsOn(PasswordStoreFactory::GetInstance()); | 71 DependsOn(PasswordStoreFactory::GetInstance()); |
| 72 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); | 72 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); |
| 73 DependsOn(SigninManagerFactory::GetInstance()); | 73 DependsOn(SigninManagerFactory::GetInstance()); |
| 74 DependsOn(TemplateURLServiceFactory::GetInstance()); | 74 DependsOn(TemplateURLServiceFactory::GetInstance()); |
| 75 #if defined(ENABLE_THEMES) | 75 #if defined(ENABLE_THEMES) |
| 76 DependsOn(ThemeServiceFactory::GetInstance()); | 76 DependsOn(ThemeServiceFactory::GetInstance()); |
| 77 #endif | 77 #endif |
| 78 DependsOn(WebDataServiceFactory::GetInstance()); | 78 DependsOn(WebDataServiceFactory::GetInstance()); |
| 79 #if defined(ENABLE_EXTENSIONS) | 79 #if defined(ENABLE_EXTENSIONS) |
| 80 DependsOn( |
| 81 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| 80 DependsOn(notifier::ChromeNotifierServiceFactory::GetInstance()); | 82 DependsOn(notifier::ChromeNotifierServiceFactory::GetInstance()); |
| 81 #endif | 83 #endif |
| 82 | 84 |
| 83 // The following have not been converted to KeyedServices yet, | 85 // The following have not been converted to KeyedServices yet, |
| 84 // and for now they are explicitly destroyed after the | 86 // and for now they are explicitly destroyed after the |
| 85 // BrowserContextDependencyManager is told to DestroyBrowserContextServices, | 87 // BrowserContextDependencyManager is told to DestroyBrowserContextServices, |
| 86 // so they will be around when the ProfileSyncService is destroyed. | 88 // so they will be around when the ProfileSyncService is destroyed. |
| 87 | 89 |
| 88 // DependsOn(FaviconServiceFactory::GetInstance()); | 90 // DependsOn(FaviconServiceFactory::GetInstance()); |
| 89 } | 91 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 143 |
| 142 pss->factory()->RegisterDataTypes(pss); | 144 pss->factory()->RegisterDataTypes(pss); |
| 143 pss->Initialize(); | 145 pss->Initialize(); |
| 144 return pss; | 146 return pss; |
| 145 } | 147 } |
| 146 | 148 |
| 147 // static | 149 // static |
| 148 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { | 150 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { |
| 149 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; | 151 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; |
| 150 } | 152 } |
| OLD | NEW |