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/prefs/prefs_tab_helper.h"
57 #include "chrome/browser/ui/tabs/pinned_tab_service_factory.h"
58 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h"
59 #include "chrome/browser/undo/bookmark_undo_service_factory.h"
60 #include "chrome/browser/web_data_service_factory.h"
62 #if defined(ENABLE_EXTENSIONS)
63 #include "apps/browser_context_keyed_service_factories.h"
64 #include "chrome/browser/apps/ephemeral_app_service_factory.h"
65 #include "chrome/browser/apps/shortcut_manager_factory.h"
66 #include "chrome/browser/extensions/api/networking_private/networking_private_ui_delegate_factory_impl.h"
67 #include "chrome/browser/extensions/api/networking_private/networking_private_verify_delegate_factory_impl.h"
68 #include "chrome/browser/extensions/browser_context_keyed_service_factories.h"
69 #include "chrome/browser/extensions/extension_management.h"
70 #include "chrome/browser/search/hotword_service_factory.h"
71 #include "chrome/browser/signin/easy_unlock_service_factory.h"
72 #include "chrome/browser/ui/bookmarks/enhanced_bookmark_key_service_factory.h"
73 #include "extensions/browser/api/networking_private/networking_private_delegate_factory.h"
74 #include "extensions/browser/browser_context_keyed_service_factories.h"
77 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
78 #include "chrome/browser/captive_portal/captive_portal_service_factory.h"
81 #if defined(ENABLE_CONFIGURATION_POLICY)
82 #include "chrome/browser/policy/cloud/policy_header_service_factory.h"
83 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator_factory.h"
84 #include "chrome/browser/policy/schema_registry_service_factory.h"
85 #if defined(OS_CHROMEOS)
86 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
87 #include "chrome/browser/chromeos/policy/consumer_enrollment_handler_factory.h"
88 #include "chrome/browser/chromeos/policy/consumer_management_notifier_factory.h"
89 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
90 #include "chrome/browser/chromeos/policy/recommendation_restorer_factory.h"
91 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h"
92 #include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder_factory.h"
93 #include "chrome/browser/chromeos/policy/user_network_configuration_updater_factory.h"
95 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h"
96 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h"
100 #if defined(ENABLE_SUPERVISED_USERS)
101 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_factory.h"
102 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
103 #if defined(OS_CHROMEOS)
104 #include "chrome/browser/supervised_user/chromeos/manager_password_service_factory.h"
105 #include "chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.h"
109 #if defined(USE_AURA)
110 #include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h"
113 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
114 #include "chrome/browser/media/protected_media_identifier_permission_context_factory.h"
116 #include "chrome/browser/signin/cross_device_promo_factory.h"
119 #if defined(OS_CHROMEOS)
120 #include "chrome/browser/chromeos/printer_detector/printer_detector_factory.h"
121 #include "chrome/browser/extensions/api/platform_keys/verify_trust_api.h"
124 #if !defined(OS_ANDROID)
125 #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h"
126 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
129 #if defined(ENABLE_SPELLCHECK)
130 #include "chrome/browser/spellchecker/spellcheck_factory.h"
133 #if defined(ENABLE_SERVICE_DISCOVERY)
134 #include "chrome/browser/local_discovery/privet_notifications_factory.h"
139 void AddProfilesExtraParts(ChromeBrowserMainParts
* main_parts
) {
140 main_parts
->AddParts(new ChromeBrowserMainExtraPartsProfiles());
143 } // namespace chrome
145 ChromeBrowserMainExtraPartsProfiles::ChromeBrowserMainExtraPartsProfiles() {
148 ChromeBrowserMainExtraPartsProfiles::~ChromeBrowserMainExtraPartsProfiles() {
151 // This method gets the instance of each ServiceFactory. We do this so that
152 // each ServiceFactory initializes itself and registers its dependencies with
153 // the global PreferenceDependencyManager. We need to have a complete
154 // dependency graph when we create a profile so we can dispatch the profile
155 // creation message to the services that want to create their services at
156 // profile creation time.
158 // TODO(erg): This needs to be something else. I don't think putting every
159 // FooServiceFactory here will scale or is desirable long term.
162 void ChromeBrowserMainExtraPartsProfiles::
163 EnsureBrowserContextKeyedServiceFactoriesBuilt() {
164 #if defined(ENABLE_EXTENSIONS)
165 apps::EnsureBrowserContextKeyedServiceFactoriesBuilt();
166 extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
167 extensions::ExtensionManagementFactory::GetInstance();
168 chrome_extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
169 AppShortcutManagerFactory::GetInstance();
170 EphemeralAppServiceFactory::GetInstance();
173 #if defined(ENABLE_APP_LIST)
174 app_list::AppListSyncableServiceFactory::GetInstance();
177 AboutSigninInternalsFactory::GetInstance();
178 AccountTrackerServiceFactory::GetInstance();
179 AccountFetcherServiceFactory::GetInstance();
180 autofill::PersonalDataManagerFactory::GetInstance();
181 #if !defined(OS_ANDROID)
182 AutomaticProfileResetterFactory::GetInstance();
184 #if defined(ENABLE_BACKGROUND)
185 BackgroundContentsServiceFactory::GetInstance();
187 BookmarkModelFactory::GetInstance();
188 BookmarkUndoServiceFactory::GetInstance();
189 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
190 CaptivePortalServiceFactory::GetInstance();
192 GeolocationPermissionContextFactory::GetInstance();
193 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
194 ProtectedMediaIdentifierPermissionContextFactory::GetInstance();
196 #if defined(ENABLE_PRINT_PREVIEW)
197 CloudPrintProxyServiceFactory::GetInstance();
199 CookieSettingsFactory::GetInstance();
200 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
201 CrossDevicePromoFactory::GetInstance();
203 #if defined(ENABLE_NOTIFICATIONS)
204 #if defined(ENABLE_EXTENSIONS)
205 ExtensionWelcomeNotificationFactory::GetInstance();
207 NotificationPermissionContextFactory::GetInstance();
208 NotifierStateTrackerFactory::GetInstance();
209 #endif // defined(ENABLE_NOTIFICATIONS)
210 dom_distiller::DomDistillerServiceFactory::GetInstance();
211 domain_reliability::DomainReliabilityServiceFactory::GetInstance();
212 DownloadServiceFactory::GetInstance();
213 #if defined(ENABLE_EXTENSIONS)
214 EasyUnlockServiceFactory::GetInstance();
215 EnhancedBookmarkKeyServiceFactory::GetInstance();
217 #if defined(OS_CHROMEOS)
218 chromeos::PrinterDetectorFactory::GetInstance();
219 extensions::VerifyTrustAPI::GetFactoryInstance();
221 FaviconServiceFactory::GetInstance();
222 FindBarStateFactory::GetInstance();
223 GAIAInfoUpdateServiceFactory::GetInstance();
224 #if defined(USE_AURA)
225 GesturePrefsObserverFactoryAura::GetInstance();
227 #if !defined(OS_ANDROID)
228 GlobalErrorServiceFactory::GetInstance();
230 GoogleURLTrackerFactory::GetInstance();
231 HistoryServiceFactory::GetInstance();
232 #if defined(ENABLE_EXTENSIONS)
233 HotwordServiceFactory::GetInstance();
235 HostContentSettingsMapFactory::GetInstance();
236 InMemoryURLIndexFactory::GetInstance();
237 invalidation::ProfileInvalidationProviderFactory::GetInstance();
238 InstantServiceFactory::GetInstance();
239 #if defined(ENABLE_SERVICE_DISCOVERY)
240 local_discovery::PrivetNotificationServiceFactory::GetInstance();
242 #if defined(ENABLE_SUPERVISED_USERS)
243 #if defined(OS_CHROMEOS)
244 chromeos::SupervisedUserPasswordServiceFactory::GetInstance();
245 chromeos::ManagerPasswordServiceFactory::GetInstance();
247 SupervisedUserServiceFactory::GetInstance();
248 #if !defined(OS_ANDROID)
249 SupervisedUserSyncServiceFactory::GetInstance();
252 #if defined(ENABLE_EXTENSIONS)
253 #if defined(OS_CHROMEOS) || defined(OS_WIN) || defined(OS_MACOSX)
254 scoped_ptr
<extensions::NetworkingPrivateVerifyDelegateFactoryImpl
>
255 networking_private_verify_delegate_factory(
256 new extensions::NetworkingPrivateVerifyDelegateFactoryImpl
);
257 extensions::NetworkingPrivateDelegateFactory::GetInstance()
258 ->SetVerifyDelegateFactory(
259 networking_private_verify_delegate_factory
.Pass());
260 scoped_ptr
<extensions::NetworkingPrivateUIDelegateFactoryImpl
>
261 networking_private_ui_delegate_factory(
262 new extensions::NetworkingPrivateUIDelegateFactoryImpl
);
263 extensions::NetworkingPrivateDelegateFactory::GetInstance()
264 ->SetUIDelegateFactory(networking_private_ui_delegate_factory
.Pass());
267 #if !defined(OS_ANDROID)
268 MediaGalleriesPreferencesFactory::GetInstance();
269 NTPResourceCacheFactory::GetInstance();
271 PasswordStoreFactory::GetInstance();
272 #if !defined(OS_ANDROID)
273 PinnedTabServiceFactory::GetInstance();
275 #if defined(ENABLE_PLUGINS)
276 PluginPrefsFactory::GetInstance();
278 PrefsTabHelper::GetServiceInstance();
279 policy::ProfilePolicyConnectorFactory::GetInstance();
280 #if defined(ENABLE_CONFIGURATION_POLICY)
281 #if defined(OS_CHROMEOS)
282 chromeos::OwnerSettingsServiceChromeOSFactory::GetInstance();
283 policy::ConsumerEnrollmentHandlerFactory::GetInstance();
284 policy::ConsumerManagementNotifierFactory::GetInstance();
285 policy::PolicyCertServiceFactory::GetInstance();
286 policy::RecommendationRestorerFactory::GetInstance();
287 policy::UserCloudPolicyManagerFactoryChromeOS::GetInstance();
288 policy::UserCloudPolicyTokenForwarderFactory::GetInstance();
289 policy::UserNetworkConfigurationUpdaterFactory::GetInstance();
291 policy::UserCloudPolicyManagerFactory::GetInstance();
292 policy::UserPolicySigninServiceFactory::GetInstance();
294 policy::PolicyHeaderServiceFactory::GetInstance();
295 policy::SchemaRegistryServiceFactory::GetInstance();
296 policy::UserCloudPolicyInvalidatorFactory::GetInstance();
298 predictors::AutocompleteActionPredictorFactory::GetInstance();
299 predictors::PredictorDatabaseFactory::GetInstance();
300 predictors::ResourcePrefetchPredictorFactory::GetInstance();
301 prerender::PrerenderLinkManagerFactory::GetInstance();
302 prerender::PrerenderManagerFactory::GetInstance();
303 prerender::PrerenderMessageFilter::EnsureShutdownNotifierFactoryBuilt();
304 ProfileSyncServiceFactory::GetInstance();
305 ProtocolHandlerRegistryFactory::GetInstance();
306 #if defined(ENABLE_SESSION_SERVICE)
307 SessionServiceFactory::GetInstance();
309 ShortcutsBackendFactory::GetInstance();
310 SigninManagerFactory::GetInstance();
312 if (SiteEngagementService::IsEnabled())
313 SiteEngagementServiceFactory::GetInstance();
315 #if defined(ENABLE_SPELLCHECK)
316 SpellcheckServiceFactory::GetInstance();
318 suggestions::SuggestionsServiceFactory::GetInstance();
319 ThumbnailServiceFactory::GetInstance();
320 TabRestoreServiceFactory::GetInstance();
321 TemplateURLFetcherFactory::GetInstance();
322 TemplateURLServiceFactory::GetInstance();
323 #if defined(ENABLE_THEMES)
324 ThemeServiceFactory::GetInstance();
326 WebDataServiceFactory::GetInstance();
329 void ChromeBrowserMainExtraPartsProfiles::PreProfileInit() {
330 EnsureBrowserContextKeyedServiceFactoriesBuilt();