chrome_browser_main_extra_parts_profiles.cc revision 8bcbed890bc3ce4d7a057a8f32cab53fa534672e
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. 4 5#include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" 6 7#include "apps/app_load_service_factory.h" 8#include "apps/app_restore_service_factory.h" 9#include "apps/shell_window_geometry_cache.h" 10#include "chrome/browser/apps/shortcut_manager_factory.h" 11#include "chrome/browser/autofill/personal_data_manager_factory.h" 12#include "chrome/browser/background/background_contents_service_factory.h" 13#include "chrome/browser/bookmarks/bookmark_model_factory.h" 14#include "chrome/browser/chrome_browser_main.h" 15#include "chrome/browser/content_settings/cookie_settings.h" 16#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" 17#include "chrome/browser/download/download_service_factory.h" 18#include "chrome/browser/favicon/favicon_service_factory.h" 19#include "chrome/browser/geolocation/chrome_geolocation_permission_context_factory.h" 20#include "chrome/browser/google/google_url_tracker_factory.h" 21#include "chrome/browser/history/history_service_factory.h" 22#include "chrome/browser/history/shortcuts_backend_factory.h" 23#include "chrome/browser/invalidation/invalidation_service_factory.h" 24#include "chrome/browser/media_galleries/media_galleries_preferences_factory.h" 25#include "chrome/browser/notifications/desktop_notification_service_factory.h" 26#include "chrome/browser/password_manager/password_store_factory.h" 27#include "chrome/browser/plugins/plugin_prefs_factory.h" 28#include "chrome/browser/policy/profile_policy_connector_factory.h" 29#include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" 30#include "chrome/browser/predictors/predictor_database_factory.h" 31#include "chrome/browser/predictors/resource_prefetch_predictor_factory.h" 32#include "chrome/browser/prerender/prerender_link_manager_factory.h" 33#include "chrome/browser/prerender/prerender_manager_factory.h" 34#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h" 35#include "chrome/browser/profiles/gaia_info_update_service_factory.h" 36#include "chrome/browser/search/hotword_service_factory.h" 37#include "chrome/browser/search/instant_service_factory.h" 38#include "chrome/browser/search_engines/template_url_fetcher_factory.h" 39#include "chrome/browser/search_engines/template_url_service_factory.h" 40#include "chrome/browser/sessions/session_service_factory.h" 41#include "chrome/browser/sessions/tab_restore_service_factory.h" 42#include "chrome/browser/signin/about_signin_internals_factory.h" 43#include "chrome/browser/signin/signin_manager_factory.h" 44#include "chrome/browser/signin/token_service_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/user_style_sheet_watcher_factory.h" 54#include "chrome/browser/webdata/web_data_service_factory.h" 55 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/discovery/suggested_links_registry_factory.h" 70#include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 71#include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h" 72#include "chrome/browser/extensions/api/font_settings/font_settings_api.h" 73#include "chrome/browser/extensions/api/history/history_api.h" 74#include "chrome/browser/extensions/api/identity/identity_api.h" 75#include "chrome/browser/extensions/api/idle/idle_manager_factory.h" 76#include "chrome/browser/extensions/api/input/input.h" 77#include "chrome/browser/extensions/api/location/location_manager.h" 78#include "chrome/browser/extensions/api/management/management_api.h" 79#include "chrome/browser/extensions/api/mdns/mdns_api.h" 80#include "chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.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/serial/serial_connection.h" 87#include "chrome/browser/extensions/api/sessions/sessions_api.h" 88#include "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.h" 89#include "chrome/browser/extensions/api/socket/socket.h" 90#include "chrome/browser/extensions/api/socket/tcp_socket.h" 91#include "chrome/browser/extensions/api/socket/udp_socket.h" 92#include "chrome/browser/extensions/api/sockets_tcp/tcp_socket_event_dispatcher.h" 93#include "chrome/browser/extensions/api/sockets_tcp_server/tcp_server_socket_event_dispatcher.h" 94#include "chrome/browser/extensions/api/sockets_udp/udp_socket_event_dispatcher.h" 95#include "chrome/browser/extensions/api/streams_private/streams_private_api.h" 96#include "chrome/browser/extensions/api/system_info/system_info_api.h" 97#include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" 98#include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" 99#include "chrome/browser/extensions/api/usb/usb_device_resource.h" 100#include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" 101#include "chrome/browser/extensions/extension_prefs_factory.h" 102#include "chrome/browser/extensions/extension_system_factory.h" 103#include "chrome/browser/extensions/extension_web_ui_override_registrar.h" 104#include "chrome/browser/extensions/install_tracker_factory.h" 105#include "chrome/browser/extensions/plugin_manager.h" 106#include "chrome/browser/extensions/token_cache/token_cache_service_factory.h" 107#endif // defined(ENABLE_EXTENSIONS) 108 109#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 110#include "chrome/browser/captive_portal/captive_portal_service_factory.h" 111#endif 112 113#if defined(ENABLE_CONFIGURATION_POLICY) 114#include "chrome/browser/policy/cloud/user_cloud_policy_invalidator_factory.h" 115#if defined(OS_CHROMEOS) 116#include "chrome/browser/chromeos/policy/recommendation_restorer_factory.h" 117#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h" 118#include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder_factory.h" 119#else 120#include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" 121#include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" 122#endif 123#endif 124 125#if defined(ENABLE_MANAGED_USERS) 126#include "chrome/browser/managed_mode/managed_user_service_factory.h" 127#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h" 128#endif 129 130#if defined(OS_CHROMEOS) 131#include "chrome/browser/chromeos/extensions/input_method_api.h" 132#include "chrome/browser/chromeos/extensions/media_player_api.h" 133#include "chrome/browser/extensions/api/input_ime/input_ime_api.h" 134#include "chrome/browser/extensions/api/networking_private/networking_private_event_router_factory.h" 135#if defined(FILE_MANAGER_EXTENSION) 136#include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_api_factory.h" 137#endif 138#endif 139 140#if defined(USE_AURA) 141#include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h" 142#endif 143 144#if defined(OS_ANDROID) 145#include "chrome/browser/media/protected_media_identifier_permission_context_factory.h" 146#else 147#include "chrome/browser/media_galleries/media_galleries_preferences_factory.h" 148#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h" 149#include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h" 150#endif 151 152#if defined(ENABLE_SPELLCHECK) 153#include "chrome/browser/extensions/api/spellcheck/spellcheck_api.h" 154#include "chrome/browser/spellchecker/spellcheck_factory.h" 155#endif 156 157#if defined(ENABLE_MDNS) 158#include "chrome/browser/local_discovery/privet_notifications_factory.h" 159#endif 160 161namespace chrome { 162 163void AddProfilesExtraParts(ChromeBrowserMainParts* main_parts) { 164 main_parts->AddParts(new ChromeBrowserMainExtraPartsProfiles()); 165} 166 167} // namespace chrome 168 169ChromeBrowserMainExtraPartsProfiles::ChromeBrowserMainExtraPartsProfiles() { 170} 171 172ChromeBrowserMainExtraPartsProfiles::~ChromeBrowserMainExtraPartsProfiles() { 173} 174 175// This method gets the instance of each ServiceFactory. We do this so that 176// each ServiceFactory initializes itself and registers its dependencies with 177// the global PreferenceDependencyManager. We need to have a complete 178// dependency graph when we create a profile so we can dispatch the profile 179// creation message to the services that want to create their services at 180// profile creation time. 181// 182// TODO(erg): This needs to be something else. I don't think putting every 183// FooServiceFactory here will scale or is desirable long term. 184// 185// static 186void ChromeBrowserMainExtraPartsProfiles:: 187EnsureBrowserContextKeyedServiceFactoriesBuilt() { 188 AboutSigninInternalsFactory::GetInstance(); 189 autofill::PersonalDataManagerFactory::GetInstance(); 190#if !defined(OS_ANDROID) 191 AutomaticProfileResetterFactory::GetInstance(); 192#endif 193#if defined(ENABLE_BACKGROUND) 194 BackgroundContentsServiceFactory::GetInstance(); 195#endif 196 BookmarkModelFactory::GetInstance(); 197#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 198 captive_portal::CaptivePortalServiceFactory::GetInstance(); 199#endif 200 ChromeGeolocationPermissionContextFactory::GetInstance(); 201#if defined(OS_ANDROID) 202 ProtectedMediaIdentifierPermissionContextFactory::GetInstance(); 203#endif 204#if defined(OS_CHROMEOS) 205 chromeos::NetworkingPrivateEventRouterFactory::GetInstance(); 206#endif 207#if defined(ENABLE_FULL_PRINTING) 208 CloudPrintProxyServiceFactory::GetInstance(); 209#endif 210 CookieSettings::Factory::GetInstance(); 211#if defined(ENABLE_NOTIFICATIONS) 212 DesktopNotificationServiceFactory::GetInstance(); 213#endif 214 DownloadServiceFactory::GetInstance(); 215#if defined(ENABLE_EXTENSIONS) 216 AppShortcutManagerFactory::GetInstance(); 217 apps::AppLoadServiceFactory::GetInstance(); 218 apps::AppRestoreServiceFactory::GetInstance(); 219 apps::ShellWindowGeometryCache::Factory::GetInstance(); 220 extensions::ActivityLogFactory::GetInstance(); 221 extensions::ActivityLogAPI::GetFactoryInstance(); 222 extensions::AlarmManager::GetFactoryInstance(); 223 extensions::ApiResourceManager<extensions::ResumableTCPServerSocket>:: 224 GetFactoryInstance(); 225 extensions::ApiResourceManager<extensions::ResumableTCPSocket>:: 226 GetFactoryInstance(); 227 extensions::ApiResourceManager<extensions::ResumableUDPSocket>:: 228 GetFactoryInstance(); 229 extensions::ApiResourceManager<extensions::SerialConnection>:: 230 GetFactoryInstance(); 231 extensions::ApiResourceManager<extensions::Socket>::GetFactoryInstance(); 232 extensions::ApiResourceManager<extensions::UsbDeviceResource>:: 233 GetFactoryInstance(); 234 extensions::api::TCPServerSocketEventDispatcher::GetFactoryInstance(); 235 extensions::api::TCPSocketEventDispatcher::GetFactoryInstance(); 236 extensions::api::UDPSocketEventDispatcher::GetFactoryInstance(); 237 extensions::AudioAPI::GetFactoryInstance(); 238 extensions::BookmarksAPI::GetFactoryInstance(); 239 extensions::BluetoothAPIFactory::GetInstance(); 240 extensions::BrailleDisplayPrivateAPI::GetFactoryInstance(); 241 extensions::chromedirectsetting::ChromeDirectSettingAPI::GetFactoryInstance(); 242 extensions::CommandService::GetFactoryInstance(); 243 extensions::CookiesAPI::GetFactoryInstance(); 244 extensions::DeveloperPrivateAPIFactory::GetInstance(); 245 extensions::DialAPIFactory::GetInstance(); 246 extensions::ExtensionActionAPI::GetFactoryInstance(); 247 extensions::ExtensionPrefsFactory::GetInstance(); 248 extensions::ExtensionSystemFactory::GetInstance(); 249 extensions::ExtensionWebUIOverrideRegistrar::GetFactoryInstance(); 250 extensions::FeedbackPrivateAPI::GetFactoryInstance(); 251 extensions::FontSettingsAPI::GetFactoryInstance(); 252 extensions::HistoryAPI::GetFactoryInstance(); 253 extensions::IdentityAPI::GetFactoryInstance(); 254 extensions::IdleManagerFactory::GetInstance(); 255 extensions::InstallTrackerFactory::GetInstance(); 256#if defined(TOOLKIT_VIEWS) 257 extensions::InputAPI::GetFactoryInstance(); 258#endif 259#if defined(OS_CHROMEOS) 260 extensions::InputImeAPI::GetFactoryInstance(); 261 extensions::InputMethodAPI::GetFactoryInstance(); 262#endif 263 extensions::LocationManager::GetFactoryInstance(); 264 extensions::ManagementAPI::GetFactoryInstance(); 265 extensions::MDnsAPI::GetFactoryInstance(); 266 extensions::MediaGalleriesPrivateAPI::GetFactoryInstance(); 267#if defined(OS_CHROMEOS) 268 extensions::MediaPlayerAPI::GetFactoryInstance(); 269#endif 270 extensions::OmniboxAPI::GetFactoryInstance(); 271#if defined(ENABLE_PLUGINS) 272 extensions::PluginManager::GetFactoryInstance(); 273#endif // defined(ENABLE_PLUGINS) 274 extensions::PreferenceAPI::GetFactoryInstance(); 275 extensions::ProcessesAPI::GetFactoryInstance(); 276 extensions::PushMessagingAPI::GetFactoryInstance(); 277 extensions::SessionsAPI::GetFactoryInstance(); 278 extensions::SignedInDevicesManager::GetFactoryInstance(); 279#if defined(ENABLE_SPELLCHECK) 280 extensions::SpellcheckAPI::GetFactoryInstance(); 281#endif 282 extensions::StreamsPrivateAPI::GetFactoryInstance(); 283 extensions::SystemInfoAPI::GetFactoryInstance(); 284 extensions::SuggestedLinksRegistryFactory::GetInstance(); 285 extensions::TabCaptureRegistry::GetFactoryInstance(); 286 extensions::TabsWindowsAPI::GetFactoryInstance(); 287 extensions::TtsAPI::GetFactoryInstance(); 288 extensions::WebNavigationAPI::GetFactoryInstance(); 289#endif // defined(ENABLE_EXTENSIONS) 290 FaviconServiceFactory::GetInstance(); 291#if defined(OS_CHROMEOS) && defined(FILE_MANAGER_EXTENSION) 292 file_manager::FileBrowserPrivateAPIFactory::GetInstance(); 293#endif 294 FindBarStateFactory::GetInstance(); 295 GAIAInfoUpdateServiceFactory::GetInstance(); 296#if defined(USE_AURA) 297 GesturePrefsObserverFactoryAura::GetInstance(); 298#endif 299 GlobalErrorServiceFactory::GetInstance(); 300 GoogleURLTrackerFactory::GetInstance(); 301 HistoryServiceFactory::GetInstance(); 302 HotwordServiceFactory::GetInstance(); 303 invalidation::InvalidationServiceFactory::GetInstance(); 304 InstantServiceFactory::GetInstance(); 305#if defined(ENABLE_MDNS) 306 local_discovery::PrivetNotificationServiceFactory::GetInstance(); 307#endif 308#if defined(ENABLE_MANAGED_USERS) 309 ManagedUserServiceFactory::GetInstance(); 310 ManagedUserSyncServiceFactory::GetInstance(); 311#endif 312#if !defined(OS_ANDROID) 313 MediaGalleriesPreferencesFactory::GetInstance(); 314 notifier::ChromeNotifierServiceFactory::GetInstance(); 315#endif 316 NTPResourceCacheFactory::GetInstance(); 317 PasswordStoreFactory::GetInstance(); 318#if !defined(OS_ANDROID) 319 PinnedTabServiceFactory::GetInstance(); 320#endif 321#if defined(ENABLE_PLUGINS) 322 PluginPrefsFactory::GetInstance(); 323#endif 324 policy::ProfilePolicyConnectorFactory::GetInstance(); 325#if defined(ENABLE_CONFIGURATION_POLICY) 326#if defined(OS_CHROMEOS) 327 policy::RecommendationRestorerFactory::GetInstance(); 328 policy::UserCloudPolicyManagerFactoryChromeOS::GetInstance(); 329 policy::UserCloudPolicyTokenForwarderFactory::GetInstance(); 330#else 331 policy::UserCloudPolicyManagerFactory::GetInstance(); 332 policy::UserPolicySigninServiceFactory::GetInstance(); 333#endif 334 policy::UserCloudPolicyInvalidatorFactory::GetInstance(); 335#endif 336 predictors::AutocompleteActionPredictorFactory::GetInstance(); 337 predictors::PredictorDatabaseFactory::GetInstance(); 338 predictors::ResourcePrefetchPredictorFactory::GetInstance(); 339 prerender::PrerenderManagerFactory::GetInstance(); 340 prerender::PrerenderLinkManagerFactory::GetInstance(); 341 ProfileSyncServiceFactory::GetInstance(); 342 ProtocolHandlerRegistryFactory::GetInstance(); 343#if defined(ENABLE_SESSION_SERVICE) 344 SessionServiceFactory::GetInstance(); 345#endif 346 ShortcutsBackendFactory::GetInstance(); 347 SigninManagerFactory::GetInstance(); 348#if defined(ENABLE_SPELLCHECK) 349 SpellcheckServiceFactory::GetInstance(); 350#endif 351 ThumbnailServiceFactory::GetInstance(); 352 TabRestoreServiceFactory::GetInstance(); 353 TemplateURLFetcherFactory::GetInstance(); 354 TemplateURLServiceFactory::GetInstance(); 355#if defined(ENABLE_THEMES) 356 ThemeServiceFactory::GetInstance(); 357#endif 358#if defined(ENABLE_EXTENSIONS) 359 TokenCacheServiceFactory::GetInstance(); 360#endif 361 TokenServiceFactory::GetInstance(); 362#if !defined(OS_ANDROID) 363 UserStyleSheetWatcherFactory::GetInstance(); 364#endif 365 WebDataServiceFactory::GetInstance(); 366} 367 368void ChromeBrowserMainExtraPartsProfiles::PreProfileInit() { 369 EnsureBrowserContextKeyedServiceFactoriesBuilt(); 370} 371