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 "apps/app_keep_alive_service_factory.h"
8 #include "apps/app_load_service_factory.h"
9 #include "apps/app_restore_service_factory.h"
10 #include "apps/shell_window_geometry_cache.h"
11 #include "chrome/browser/apps/ephemeral_app_service_factory.h"
12 #include "chrome/browser/apps/shortcut_manager_factory.h"
13 #include "chrome/browser/autofill/personal_data_manager_factory.h"
14 #include "chrome/browser/background/background_contents_service_factory.h"
15 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
16 #include "chrome/browser/chrome_browser_main.h"
17 #include "chrome/browser/content_settings/cookie_settings.h"
18 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
19 #include "chrome/browser/download/download_service_factory.h"
20 #include "chrome/browser/favicon/favicon_service_factory.h"
21 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_factory.h"
22 #include "chrome/browser/google/google_url_tracker_factory.h"
23 #include "chrome/browser/history/history_service_factory.h"
24 #include "chrome/browser/history/shortcuts_backend_factory.h"
25 #include "chrome/browser/invalidation/invalidation_service_factory.h"
26 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h"
27 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
28 #include "chrome/browser/password_manager/password_store_factory.h"
29 #include "chrome/browser/plugins/plugin_prefs_factory.h"
30 #include "chrome/browser/policy/profile_policy_connector_factory.h"
31 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h"
32 #include "chrome/browser/predictors/predictor_database_factory.h"
33 #include "chrome/browser/prerender/prerender_link_manager_factory.h"
34 #include "chrome/browser/prerender/prerender_manager_factory.h"
35 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h"
36 #include "chrome/browser/profiles/gaia_info_update_service_factory.h"
37 #include "chrome/browser/search/hotword_service_factory.h"
38 #include "chrome/browser/search/instant_service_factory.h"
39 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
40 #include "chrome/browser/search_engines/template_url_service_factory.h"
41 #include "chrome/browser/sessions/session_service_factory.h"
42 #include "chrome/browser/sessions/tab_restore_service_factory.h"
43 #include "chrome/browser/signin/about_signin_internals_factory.h"
44 #include "chrome/browser/signin/signin_manager_factory.h"
45 #include "chrome/browser/speech/extension_api/tts_extension_api.h"
46 #include "chrome/browser/sync/profile_sync_service_factory.h"
47 #include "chrome/browser/themes/theme_service_factory.h"
48 #include "chrome/browser/thumbnails/thumbnail_service_factory.h"
49 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h"
50 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
51 #include "chrome/browser/ui/tabs/pinned_tab_service_factory.h"
52 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h"
53 #include "chrome/browser/undo/bookmark_undo_service_factory.h"
54 #include "chrome/browser/webdata/web_data_service_factory.h"
56 #if defined(ENABLE_EXTENSIONS)
57 #include "chrome/browser/extensions/activity_log/activity_log.h"
58 #include "chrome/browser/extensions/api/activity_log_private/activity_log_private_api.h"
59 #include "chrome/browser/extensions/api/alarms/alarm_manager.h"
60 #include "chrome/browser/extensions/api/api_resource_manager.h"
61 #include "chrome/browser/extensions/api/audio/audio_api.h"
62 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_factory.h"
63 #include "chrome/browser/extensions/api/bookmarks/bookmarks_api.h"
64 #include "chrome/browser/extensions/api/braille_display_private/braille_display_private_api.h"
65 #include "chrome/browser/extensions/api/commands/command_service.h"
66 #include "chrome/browser/extensions/api/cookies/cookies_api.h"
67 #include "chrome/browser/extensions/api/developer_private/developer_private_api_factory.h"
68 #include "chrome/browser/extensions/api/dial/dial_api_factory.h"
69 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
70 #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h"
71 #include "chrome/browser/extensions/api/font_settings/font_settings_api.h"
72 #include "chrome/browser/extensions/api/history/history_api.h"
73 #include "chrome/browser/extensions/api/identity/identity_api.h"
74 #include "chrome/browser/extensions/api/idle/idle_manager_factory.h"
75 #include "chrome/browser/extensions/api/input/input.h"
76 #include "chrome/browser/extensions/api/location/location_manager.h"
77 #include "chrome/browser/extensions/api/management/management_api.h"
78 #include "chrome/browser/extensions/api/mdns/mdns_api.h"
79 #include "chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h"
80 #include "chrome/browser/extensions/api/networking_private/networking_private_event_router_factory.h"
81 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h"
82 #include "chrome/browser/extensions/api/preference/chrome_direct_setting_api.h"
83 #include "chrome/browser/extensions/api/preference/preference_api.h"
84 #include "chrome/browser/extensions/api/processes/processes_api.h"
85 #include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h"
86 #include "chrome/browser/extensions/api/runtime/runtime_api_factory.h"
87 #include "chrome/browser/extensions/api/serial/serial_connection.h"
88 #include "chrome/browser/extensions/api/sessions/sessions_api.h"
89 #include "chrome/browser/extensions/api/settings_overrides/settings_overrides_api.h"
90 #include "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.h"
91 #include "chrome/browser/extensions/api/socket/socket.h"
92 #include "chrome/browser/extensions/api/socket/tcp_socket.h"
93 #include "chrome/browser/extensions/api/socket/udp_socket.h"
94 #include "chrome/browser/extensions/api/sockets_tcp/tcp_socket_event_dispatcher.h"
95 #include "chrome/browser/extensions/api/sockets_tcp_server/tcp_server_socket_event_dispatcher.h"
96 #include "chrome/browser/extensions/api/sockets_udp/udp_socket_event_dispatcher.h"
97 #include "chrome/browser/extensions/api/streams_private/streams_private_api.h"
98 #include "chrome/browser/extensions/api/system_info/system_info_api.h"
99 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h"
100 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h"
101 #include "chrome/browser/extensions/api/usb/usb_device_resource.h"
102 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
103 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
104 #include "chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.h"
105 #include "chrome/browser/extensions/extension_prefs_factory.h"
106 #include "chrome/browser/extensions/extension_system_factory.h"
107 #include "chrome/browser/extensions/extension_toolbar_model_factory.h"
108 #include "chrome/browser/extensions/extension_web_ui_override_registrar.h"
109 #include "chrome/browser/extensions/install_tracker_factory.h"
110 #include "chrome/browser/extensions/menu_manager_factory.h"
111 #include "chrome/browser/extensions/plugin_manager.h"
112 #include "chrome/browser/extensions/token_cache/token_cache_service_factory.h"
113 #endif // defined(ENABLE_EXTENSIONS)
115 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
116 #include "chrome/browser/captive_portal/captive_portal_service_factory.h"
119 #if defined(ENABLE_CONFIGURATION_POLICY)
120 #include "chrome/browser/policy/cloud/policy_header_service_factory.h"
121 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator_factory.h"
122 #include "chrome/browser/policy/schema_registry_service_factory.h"
123 #if defined(OS_CHROMEOS)
124 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
125 #include "chrome/browser/chromeos/policy/recommendation_restorer_factory.h"
126 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h"
127 #include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder_factory.h"
128 #include "chrome/browser/chromeos/policy/user_network_configuration_updater_factory.h"
130 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h"
131 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h"
135 #if defined(ENABLE_MANAGED_USERS)
136 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
137 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
140 #if defined(OS_CHROMEOS)
141 #include "chrome/browser/chromeos/extensions/input_method_api.h"
142 #include "chrome/browser/chromeos/extensions/media_player_api.h"
143 #include "chrome/browser/chromeos/extensions/screenlock_private_api.h"
144 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h"
145 #if defined(FILE_MANAGER_EXTENSION)
146 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_api_factory.h"
150 #if defined(USE_AURA)
151 #include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h"
154 #if defined(OS_ANDROID)
155 #include "chrome/browser/media/protected_media_identifier_permission_context_factory.h"
157 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h"
158 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h"
159 #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h"
162 #if defined(ENABLE_SPELLCHECK)
163 #include "chrome/browser/extensions/api/spellcheck/spellcheck_api.h"
164 #include "chrome/browser/spellchecker/spellcheck_factory.h"
167 #if defined(ENABLE_MDNS)
168 #include "chrome/browser/local_discovery/privet_notifications_factory.h"
173 void AddProfilesExtraParts(ChromeBrowserMainParts
* main_parts
) {
174 main_parts
->AddParts(new ChromeBrowserMainExtraPartsProfiles());
177 } // namespace chrome
179 ChromeBrowserMainExtraPartsProfiles::ChromeBrowserMainExtraPartsProfiles() {
182 ChromeBrowserMainExtraPartsProfiles::~ChromeBrowserMainExtraPartsProfiles() {
185 // This method gets the instance of each ServiceFactory. We do this so that
186 // each ServiceFactory initializes itself and registers its dependencies with
187 // the global PreferenceDependencyManager. We need to have a complete
188 // dependency graph when we create a profile so we can dispatch the profile
189 // creation message to the services that want to create their services at
190 // profile creation time.
192 // TODO(erg): This needs to be something else. I don't think putting every
193 // FooServiceFactory here will scale or is desirable long term.
196 void ChromeBrowserMainExtraPartsProfiles::
197 EnsureBrowserContextKeyedServiceFactoriesBuilt() {
198 AboutSigninInternalsFactory::GetInstance();
199 autofill::PersonalDataManagerFactory::GetInstance();
200 #if !defined(OS_ANDROID)
201 AutomaticProfileResetterFactory::GetInstance();
203 #if defined(ENABLE_BACKGROUND)
204 BackgroundContentsServiceFactory::GetInstance();
206 BookmarkModelFactory::GetInstance();
207 #if !defined(OS_ANDROID)
208 BookmarkUndoServiceFactory::GetInstance();
210 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
211 captive_portal::CaptivePortalServiceFactory::GetInstance();
213 ChromeGeolocationPermissionContextFactory::GetInstance();
214 #if defined(OS_ANDROID)
215 ProtectedMediaIdentifierPermissionContextFactory::GetInstance();
217 #if defined(ENABLE_FULL_PRINTING)
218 CloudPrintProxyServiceFactory::GetInstance();
220 CookieSettings::Factory::GetInstance();
221 #if defined(ENABLE_NOTIFICATIONS)
222 DesktopNotificationServiceFactory::GetInstance();
224 DownloadServiceFactory::GetInstance();
225 #if defined(ENABLE_EXTENSIONS)
226 AppShortcutManagerFactory::GetInstance();
227 apps::AppLoadServiceFactory::GetInstance();
228 apps::AppRestoreServiceFactory::GetInstance();
229 apps::ShellWindowGeometryCache::Factory::GetInstance();
230 EphemeralAppServiceFactory::GetInstance();
231 extensions::ActivityLogFactory::GetInstance();
232 extensions::ActivityLogAPI::GetFactoryInstance();
233 extensions::AlarmManager::GetFactoryInstance();
234 extensions::ApiResourceManager
<extensions::ResumableTCPServerSocket
>::
235 GetFactoryInstance();
236 extensions::ApiResourceManager
<extensions::ResumableTCPSocket
>::
237 GetFactoryInstance();
238 extensions::ApiResourceManager
<extensions::ResumableUDPSocket
>::
239 GetFactoryInstance();
240 extensions::ApiResourceManager
<extensions::SerialConnection
>::
241 GetFactoryInstance();
242 extensions::ApiResourceManager
<extensions::Socket
>::GetFactoryInstance();
243 extensions::ApiResourceManager
<extensions::UsbDeviceResource
>::
244 GetFactoryInstance();
245 extensions::api::TCPServerSocketEventDispatcher::GetFactoryInstance();
246 extensions::api::TCPSocketEventDispatcher::GetFactoryInstance();
247 extensions::api::UDPSocketEventDispatcher::GetFactoryInstance();
248 extensions::AudioAPI::GetFactoryInstance();
249 extensions::BookmarksAPI::GetFactoryInstance();
250 extensions::BluetoothAPIFactory::GetInstance();
251 extensions::BrailleDisplayPrivateAPI::GetFactoryInstance();
252 extensions::chromedirectsetting::ChromeDirectSettingAPI::GetFactoryInstance();
253 extensions::CommandService::GetFactoryInstance();
254 extensions::CookiesAPI::GetFactoryInstance();
255 extensions::DeveloperPrivateAPIFactory::GetInstance();
256 extensions::DialAPIFactory::GetInstance();
257 extensions::ExtensionActionAPI::GetFactoryInstance();
258 extensions::ExtensionPrefsFactory::GetInstance();
259 extensions::ExtensionSystemFactory::GetInstance();
260 extensions::ExtensionWebUIOverrideRegistrar::GetFactoryInstance();
261 extensions::FeedbackPrivateAPI::GetFactoryInstance();
262 extensions::FontSettingsAPI::GetFactoryInstance();
263 extensions::HistoryAPI::GetFactoryInstance();
264 extensions::IdentityAPI::GetFactoryInstance();
265 extensions::IdleManagerFactory::GetInstance();
266 extensions::InstallTrackerFactory::GetInstance();
267 #if defined(TOOLKIT_VIEWS)
268 extensions::InputAPI::GetFactoryInstance();
270 #if defined(OS_CHROMEOS)
271 extensions::InputImeAPI::GetFactoryInstance();
272 extensions::InputMethodAPI::GetFactoryInstance();
273 extensions::ScreenlockPrivateEventRouter::GetFactoryInstance();
275 extensions::LocationManager::GetFactoryInstance();
276 extensions::ManagementAPI::GetFactoryInstance();
277 extensions::MDnsAPI::GetFactoryInstance();
278 extensions::MediaGalleriesPrivateAPI::GetFactoryInstance();
279 #if defined(OS_CHROMEOS)
280 extensions::MediaPlayerAPI::GetFactoryInstance();
282 extensions::MenuManagerFactory::GetInstance();
283 #if defined(OS_CHROMEOS) || defined(OS_WIN)
284 extensions::NetworkingPrivateEventRouterFactory::GetInstance();
285 #endif // defined(OS_CHROMEOS) || defined(OS_WIN)
286 extensions::OmniboxAPI::GetFactoryInstance();
287 #if defined(ENABLE_PLUGINS)
288 extensions::PluginManager::GetFactoryInstance();
289 #endif // defined(ENABLE_PLUGINS)
290 extensions::PreferenceAPI::GetFactoryInstance();
291 extensions::ProcessesAPI::GetFactoryInstance();
292 extensions::PushMessagingAPI::GetFactoryInstance();
293 extensions::RuntimeAPIFactory::GetInstance();
294 extensions::SessionsAPI::GetFactoryInstance();
295 extensions::SettingsOverridesAPI::GetFactoryInstance();
296 extensions::SignedInDevicesManager::GetFactoryInstance();
297 #if defined(ENABLE_SPELLCHECK)
298 extensions::SpellcheckAPI::GetFactoryInstance();
300 extensions::StreamsPrivateAPI::GetFactoryInstance();
301 extensions::SystemInfoAPI::GetFactoryInstance();
302 extensions::TabCaptureRegistry::GetFactoryInstance();
303 extensions::TabsWindowsAPI::GetFactoryInstance();
304 extensions::TtsAPI::GetFactoryInstance();
305 extensions::WebNavigationAPI::GetFactoryInstance();
306 extensions::WebRequestAPI::GetFactoryInstance();
307 extensions::WebrtcAudioPrivateEventService::GetFactoryInstance();
308 ExtensionToolbarModelFactory::GetInstance();
309 #endif // defined(ENABLE_EXTENSIONS)
310 FaviconServiceFactory::GetInstance();
311 #if defined(OS_CHROMEOS) && defined(FILE_MANAGER_EXTENSION)
312 file_manager::FileBrowserPrivateAPIFactory::GetInstance();
314 FindBarStateFactory::GetInstance();
315 GAIAInfoUpdateServiceFactory::GetInstance();
316 #if defined(USE_AURA)
317 GesturePrefsObserverFactoryAura::GetInstance();
319 GlobalErrorServiceFactory::GetInstance();
320 GoogleURLTrackerFactory::GetInstance();
321 HistoryServiceFactory::GetInstance();
322 HotwordServiceFactory::GetInstance();
323 invalidation::InvalidationServiceFactory::GetInstance();
324 InstantServiceFactory::GetInstance();
325 #if defined(ENABLE_MDNS)
326 local_discovery::PrivetNotificationServiceFactory::GetInstance();
328 #if defined(ENABLE_MANAGED_USERS)
329 ManagedUserServiceFactory::GetInstance();
330 ManagedUserSyncServiceFactory::GetInstance();
332 #if !defined(OS_ANDROID)
333 MediaGalleriesPreferencesFactory::GetInstance();
334 notifier::ChromeNotifierServiceFactory::GetInstance();
336 NTPResourceCacheFactory::GetInstance();
337 PasswordStoreFactory::GetInstance();
338 #if !defined(OS_ANDROID)
339 PinnedTabServiceFactory::GetInstance();
341 #if defined(ENABLE_PLUGINS)
342 PluginPrefsFactory::GetInstance();
344 policy::ProfilePolicyConnectorFactory::GetInstance();
345 #if defined(ENABLE_CONFIGURATION_POLICY)
346 #if defined(OS_CHROMEOS)
347 policy::PolicyCertServiceFactory::GetInstance();
348 policy::RecommendationRestorerFactory::GetInstance();
349 policy::UserCloudPolicyManagerFactoryChromeOS::GetInstance();
350 policy::UserCloudPolicyTokenForwarderFactory::GetInstance();
351 policy::UserNetworkConfigurationUpdaterFactory::GetInstance();
353 policy::UserCloudPolicyManagerFactory::GetInstance();
354 policy::UserPolicySigninServiceFactory::GetInstance();
356 policy::PolicyHeaderServiceFactory::GetInstance();
357 policy::SchemaRegistryServiceFactory::GetInstance();
358 policy::UserCloudPolicyInvalidatorFactory::GetInstance();
360 predictors::AutocompleteActionPredictorFactory::GetInstance();
361 predictors::PredictorDatabaseFactory::GetInstance();
362 prerender::PrerenderManagerFactory::GetInstance();
363 prerender::PrerenderLinkManagerFactory::GetInstance();
364 ProfileSyncServiceFactory::GetInstance();
365 ProtocolHandlerRegistryFactory::GetInstance();
366 #if defined(ENABLE_SESSION_SERVICE)
367 SessionServiceFactory::GetInstance();
369 ShortcutsBackendFactory::GetInstance();
370 SigninManagerFactory::GetInstance();
371 #if defined(ENABLE_SPELLCHECK)
372 SpellcheckServiceFactory::GetInstance();
374 ThumbnailServiceFactory::GetInstance();
375 TabRestoreServiceFactory::GetInstance();
376 TemplateURLFetcherFactory::GetInstance();
377 TemplateURLServiceFactory::GetInstance();
378 #if defined(ENABLE_THEMES)
379 ThemeServiceFactory::GetInstance();
381 #if defined(ENABLE_EXTENSIONS)
382 TokenCacheServiceFactory::GetInstance();
384 WebDataServiceFactory::GetInstance();
387 void ChromeBrowserMainExtraPartsProfiles::PreProfileInit() {
388 EnsureBrowserContextKeyedServiceFactoriesBuilt();