1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h"
7 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h"
8 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h"
9 #include "chrome/browser/autofill/personal_data_manager_factory.h"
10 #include "chrome/browser/background/background_contents_service_factory.h"
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
12 #include "chrome/browser/chrome_browser_main.h"
13 #include "chrome/browser/content_settings/cookie_settings_factory.h"
14 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
15 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
16 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
17 #include "chrome/browser/domain_reliability/service_factory.h"
18 #include "chrome/browser/download/download_service_factory.h"
19 #include "chrome/browser/engagement/site_engagement_service.h"
20 #include "chrome/browser/engagement/site_engagement_service_factory.h"
21 #include "chrome/browser/favicon/favicon_service_factory.h"
22 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h"
23 #include "chrome/browser/google/google_url_tracker_factory.h"
24 #include "chrome/browser/history/history_service_factory.h"
25 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
26 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h"
27 #include "chrome/browser/notifications/extension_welcome_notification_factory.h"
28 #include "chrome/browser/notifications/notification_permission_context_factory.h"
29 #include "chrome/browser/notifications/notifier_state_tracker_factory.h"
30 #include "chrome/browser/password_manager/password_store_factory.h"
31 #include "chrome/browser/plugins/plugin_prefs_factory.h"
32 #include "chrome/browser/policy/profile_policy_connector_factory.h"
33 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h"
34 #include "chrome/browser/predictors/predictor_database_factory.h"
35 #include "chrome/browser/predictors/resource_prefetch_predictor_factory.h"
36 #include "chrome/browser/prerender/prerender_link_manager_factory.h"
37 #include "chrome/browser/prerender/prerender_manager_factory.h"
38 #include "chrome/browser/prerender/prerender_message_filter.h"
39 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h"
40 #include "chrome/browser/profiles/gaia_info_update_service_factory.h"
41 #include "chrome/browser/search/instant_service_factory.h"
42 #include "chrome/browser/search/suggestions/suggestions_service_factory.h"
43 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
44 #include "chrome/browser/search_engines/template_url_service_factory.h"
45 #include "chrome/browser/sessions/session_service_factory.h"
46 #include "chrome/browser/sessions/tab_restore_service_factory.h"
47 #include "chrome/browser/signin/about_signin_internals_factory.h"
48 #include "chrome/browser/signin/account_fetcher_service_factory.h"
49 #include "chrome/browser/signin/account_tracker_service_factory.h"
50 #include "chrome/browser/signin/signin_manager_factory.h"
51 #include "chrome/browser/sync/profile_sync_service_factory.h"
52 #include "chrome/browser/themes/theme_service_factory.h"
53 #include "chrome/browser/thumbnails/thumbnail_service_factory.h"
54 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
55 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h"
56 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
57 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
58 #include "chrome/browser/ui/tabs/pinned_tab_service_factory.h"
59 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h"
60 #include "chrome/browser/undo/bookmark_undo_service_factory.h"
61 #include "chrome/browser/web_data_service_factory.h"
63 #if defined(ENABLE_EXTENSIONS)
64 #include "apps/browser_context_keyed_service_factories.h"
65 #include "chrome/browser/apps/ephemeral_app_service_factory.h"
66 #include "chrome/browser/apps/shortcut_manager_factory.h"
67 #include "chrome/browser/extensions/api/networking_private/networking_private_ui_delegate_factory_impl.h"
68 #include "chrome/browser/extensions/api/networking_private/networking_private_verify_delegate_factory_impl.h"
69 #include "chrome/browser/extensions/browser_context_keyed_service_factories.h"
70 #include "chrome/browser/extensions/extension_management.h"
71 #include "chrome/browser/search/hotword_service_factory.h"
72 #include "chrome/browser/signin/easy_unlock_service_factory.h"
73 #include "chrome/browser/ui/bookmarks/enhanced_bookmark_key_service_factory.h"
74 #include "extensions/browser/api/networking_private/networking_private_delegate_factory.h"
75 #include "extensions/browser/browser_context_keyed_service_factories.h"
78 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
79 #include "chrome/browser/captive_portal/captive_portal_service_factory.h"
82 #if defined(ENABLE_CONFIGURATION_POLICY)
83 #include "chrome/browser/policy/cloud/policy_header_service_factory.h"
84 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator_factory.h"
85 #include "chrome/browser/policy/schema_registry_service_factory.h"
86 #if defined(OS_CHROMEOS)
87 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
88 #include "chrome/browser/chromeos/policy/consumer_enrollment_handler_factory.h"
89 #include "chrome/browser/chromeos/policy/consumer_management_notifier_factory.h"
90 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
91 #include "chrome/browser/chromeos/policy/recommendation_restorer_factory.h"
92 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h"
93 #include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder_factory.h"
94 #include "chrome/browser/chromeos/policy/user_network_configuration_updater_factory.h"
96 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h"
98 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h"
103 #if defined(ENABLE_SUPERVISED_USERS)
104 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_factory.h"
105 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
106 #if defined(OS_CHROMEOS)
107 #include "chrome/browser/supervised_user/chromeos/manager_password_service_factory.h"
108 #include "chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.h"
112 #if defined(USE_AURA)
113 #include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h"
116 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
117 #include "chrome/browser/media/protected_media_identifier_permission_context_factory.h"
120 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
121 #include "chrome/browser/signin/cross_device_promo_factory.h"
124 #if defined(OS_CHROMEOS)
125 #include "chrome/browser/chromeos/printer_detector/printer_detector_factory.h"
126 #include "chrome/browser/extensions/api/platform_keys/verify_trust_api.h"
129 #if !defined(OS_ANDROID)
130 #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h"
133 #if defined(ENABLE_SPELLCHECK)
134 #include "chrome/browser/spellchecker/spellcheck_factory.h"
137 #if defined(ENABLE_SERVICE_DISCOVERY)
138 #include "chrome/browser/local_discovery/privet_notifications_factory.h"
143 void AddProfilesExtraParts(ChromeBrowserMainParts
* main_parts
) {
144 main_parts
->AddParts(new ChromeBrowserMainExtraPartsProfiles());
147 } // namespace chrome
149 ChromeBrowserMainExtraPartsProfiles::ChromeBrowserMainExtraPartsProfiles() {
152 ChromeBrowserMainExtraPartsProfiles::~ChromeBrowserMainExtraPartsProfiles() {
155 // This method gets the instance of each ServiceFactory. We do this so that
156 // each ServiceFactory initializes itself and registers its dependencies with
157 // the global PreferenceDependencyManager. We need to have a complete
158 // dependency graph when we create a profile so we can dispatch the profile
159 // creation message to the services that want to create their services at
160 // profile creation time.
162 // TODO(erg): This needs to be something else. I don't think putting every
163 // FooServiceFactory here will scale or is desirable long term.
166 void ChromeBrowserMainExtraPartsProfiles::
167 EnsureBrowserContextKeyedServiceFactoriesBuilt() {
168 #if defined(ENABLE_EXTENSIONS)
169 apps::EnsureBrowserContextKeyedServiceFactoriesBuilt();
170 extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
171 extensions::ExtensionManagementFactory::GetInstance();
172 chrome_extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
173 AppShortcutManagerFactory::GetInstance();
174 EphemeralAppServiceFactory::GetInstance();
177 #if defined(ENABLE_APP_LIST)
178 app_list::AppListSyncableServiceFactory::GetInstance();
181 AboutSigninInternalsFactory::GetInstance();
182 AccountTrackerServiceFactory::GetInstance();
183 AccountFetcherServiceFactory::GetInstance();
184 autofill::PersonalDataManagerFactory::GetInstance();
185 #if !defined(OS_ANDROID)
186 AutomaticProfileResetterFactory::GetInstance();
188 #if defined(ENABLE_BACKGROUND)
189 BackgroundContentsServiceFactory::GetInstance();
191 BookmarkModelFactory::GetInstance();
192 BookmarkUndoServiceFactory::GetInstance();
193 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
194 CaptivePortalServiceFactory::GetInstance();
196 GeolocationPermissionContextFactory::GetInstance();
197 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
198 ProtectedMediaIdentifierPermissionContextFactory::GetInstance();
200 #if defined(ENABLE_PRINT_PREVIEW)
201 CloudPrintProxyServiceFactory::GetInstance();
203 CookieSettingsFactory::GetInstance();
204 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
205 CrossDevicePromoFactory::GetInstance();
207 #if defined(ENABLE_NOTIFICATIONS)
208 #if defined(ENABLE_EXTENSIONS)
209 ExtensionWelcomeNotificationFactory::GetInstance();
211 NotificationPermissionContextFactory::GetInstance();
212 NotifierStateTrackerFactory::GetInstance();
213 #endif // defined(ENABLE_NOTIFICATIONS)
214 dom_distiller::DomDistillerServiceFactory::GetInstance();
215 domain_reliability::DomainReliabilityServiceFactory::GetInstance();
216 DownloadServiceFactory::GetInstance();
217 #if defined(ENABLE_EXTENSIONS)
218 EasyUnlockServiceFactory::GetInstance();
219 EnhancedBookmarkKeyServiceFactory::GetInstance();
221 #if defined(OS_CHROMEOS)
222 chromeos::PrinterDetectorFactory::GetInstance();
223 extensions::VerifyTrustAPI::GetFactoryInstance();
225 FaviconServiceFactory::GetInstance();
226 FindBarStateFactory::GetInstance();
227 GAIAInfoUpdateServiceFactory::GetInstance();
228 #if defined(USE_AURA)
229 GesturePrefsObserverFactoryAura::GetInstance();
231 GlobalErrorServiceFactory::GetInstance();
232 GoogleURLTrackerFactory::GetInstance();
233 HistoryServiceFactory::GetInstance();
234 #if defined(ENABLE_EXTENSIONS)
235 HotwordServiceFactory::GetInstance();
237 HostContentSettingsMapFactory::GetInstance();
238 InMemoryURLIndexFactory::GetInstance();
239 invalidation::ProfileInvalidationProviderFactory::GetInstance();
240 InstantServiceFactory::GetInstance();
241 #if defined(ENABLE_SERVICE_DISCOVERY)
242 local_discovery::PrivetNotificationServiceFactory::GetInstance();
244 #if defined(ENABLE_SUPERVISED_USERS)
245 #if defined(OS_CHROMEOS)
246 chromeos::SupervisedUserPasswordServiceFactory::GetInstance();
247 chromeos::ManagerPasswordServiceFactory::GetInstance();
249 SupervisedUserServiceFactory::GetInstance();
250 #if !defined(OS_ANDROID) && !defined(OS_IOS)
251 SupervisedUserSyncServiceFactory::GetInstance();
254 #if defined(ENABLE_EXTENSIONS)
255 #if defined(OS_CHROMEOS) || defined(OS_WIN) || defined(OS_MACOSX)
256 scoped_ptr
<extensions::NetworkingPrivateVerifyDelegateFactoryImpl
>
257 networking_private_verify_delegate_factory(
258 new extensions::NetworkingPrivateVerifyDelegateFactoryImpl
);
259 extensions::NetworkingPrivateDelegateFactory::GetInstance()
260 ->SetVerifyDelegateFactory(
261 networking_private_verify_delegate_factory
.Pass());
262 scoped_ptr
<extensions::NetworkingPrivateUIDelegateFactoryImpl
>
263 networking_private_ui_delegate_factory(
264 new extensions::NetworkingPrivateUIDelegateFactoryImpl
);
265 extensions::NetworkingPrivateDelegateFactory::GetInstance()
266 ->SetUIDelegateFactory(networking_private_ui_delegate_factory
.Pass());
269 #if !defined(OS_ANDROID)
270 MediaGalleriesPreferencesFactory::GetInstance();
271 NTPResourceCacheFactory::GetInstance();
273 PasswordStoreFactory::GetInstance();
274 #if !defined(OS_ANDROID)
275 PinnedTabServiceFactory::GetInstance();
277 #if defined(ENABLE_PLUGINS)
278 PluginPrefsFactory::GetInstance();
280 PrefsTabHelper::GetServiceInstance();
281 policy::ProfilePolicyConnectorFactory::GetInstance();
282 #if defined(ENABLE_CONFIGURATION_POLICY)
283 #if defined(OS_CHROMEOS)
284 chromeos::OwnerSettingsServiceChromeOSFactory::GetInstance();
285 policy::ConsumerEnrollmentHandlerFactory::GetInstance();
286 policy::ConsumerManagementNotifierFactory::GetInstance();
287 policy::PolicyCertServiceFactory::GetInstance();
288 policy::RecommendationRestorerFactory::GetInstance();
289 policy::UserCloudPolicyManagerFactoryChromeOS::GetInstance();
290 policy::UserCloudPolicyTokenForwarderFactory::GetInstance();
291 policy::UserNetworkConfigurationUpdaterFactory::GetInstance();
293 policy::UserCloudPolicyManagerFactory::GetInstance();
295 policy::UserPolicySigninServiceFactory::GetInstance();
298 policy::PolicyHeaderServiceFactory::GetInstance();
299 policy::SchemaRegistryServiceFactory::GetInstance();
300 policy::UserCloudPolicyInvalidatorFactory::GetInstance();
302 predictors::AutocompleteActionPredictorFactory::GetInstance();
303 predictors::PredictorDatabaseFactory::GetInstance();
304 predictors::ResourcePrefetchPredictorFactory::GetInstance();
305 prerender::PrerenderLinkManagerFactory::GetInstance();
306 prerender::PrerenderManagerFactory::GetInstance();
307 prerender::PrerenderMessageFilter::EnsureShutdownNotifierFactoryBuilt();
308 ProfileSyncServiceFactory::GetInstance();
309 ProtocolHandlerRegistryFactory::GetInstance();
310 #if defined(ENABLE_SESSION_SERVICE)
311 SessionServiceFactory::GetInstance();
313 ShortcutsBackendFactory::GetInstance();
314 SigninManagerFactory::GetInstance();
316 if (SiteEngagementService::IsEnabled())
317 SiteEngagementServiceFactory::GetInstance();
319 #if defined(ENABLE_SPELLCHECK)
320 SpellcheckServiceFactory::GetInstance();
322 suggestions::SuggestionsServiceFactory::GetInstance();
323 ThumbnailServiceFactory::GetInstance();
324 TabRestoreServiceFactory::GetInstance();
325 TemplateURLFetcherFactory::GetInstance();
326 TemplateURLServiceFactory::GetInstance();
327 #if defined(ENABLE_THEMES)
328 ThemeServiceFactory::GetInstance();
330 WebDataServiceFactory::GetInstance();
333 void ChromeBrowserMainExtraPartsProfiles::PreProfileInit() {
334 EnsureBrowserContextKeyedServiceFactoriesBuilt();