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 "chrome/browser/autocomplete/shortcuts_backend_factory.h" 8 #include "chrome/browser/autofill/personal_data_manager_factory.h" 9 #include "chrome/browser/background/background_contents_service_factory.h" 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 11 #include "chrome/browser/chrome_browser_main.h" 12 #include "chrome/browser/content_settings/cookie_settings.h" 13 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" 14 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" 15 #include "chrome/browser/domain_reliability/service_factory.h" 16 #include "chrome/browser/download/download_service_factory.h" 17 #include "chrome/browser/favicon/favicon_service_factory.h" 18 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h" 19 #include "chrome/browser/google/google_url_tracker_factory.h" 20 #include "chrome/browser/history/history_service_factory.h" 21 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" 22 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h" 23 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 24 #include "chrome/browser/password_manager/password_store_factory.h" 25 #include "chrome/browser/plugins/plugin_prefs_factory.h" 26 #include "chrome/browser/policy/profile_policy_connector_factory.h" 27 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" 28 #include "chrome/browser/predictors/predictor_database_factory.h" 29 #include "chrome/browser/prerender/prerender_link_manager_factory.h" 30 #include "chrome/browser/prerender/prerender_manager_factory.h" 31 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h" 32 #include "chrome/browser/profiles/gaia_info_update_service_factory.h" 33 #include "chrome/browser/search/hotword_service_factory.h" 34 #include "chrome/browser/search/instant_service_factory.h" 35 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" 36 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" 37 #include "chrome/browser/search_engines/template_url_service_factory.h" 38 #include "chrome/browser/sessions/session_service_factory.h" 39 #include "chrome/browser/sessions/tab_restore_service_factory.h" 40 #include "chrome/browser/signin/about_signin_internals_factory.h" 41 #include "chrome/browser/signin/signin_manager_factory.h" 42 #include "chrome/browser/sync/profile_sync_service_factory.h" 43 #include "chrome/browser/themes/theme_service_factory.h" 44 #include "chrome/browser/thumbnails/thumbnail_service_factory.h" 45 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" 46 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" 47 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 48 #include "chrome/browser/ui/tabs/pinned_tab_service_factory.h" 49 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h" 50 #include "chrome/browser/undo/bookmark_undo_service_factory.h" 51 #include "chrome/browser/webdata/web_data_service_factory.h" 52 53 #if defined(ENABLE_EXTENSIONS) 54 #include "apps/browser_context_keyed_service_factories.h" 55 #include "chrome/browser/apps/ephemeral_app_service_factory.h" 56 #include "chrome/browser/apps/shortcut_manager_factory.h" 57 #include "chrome/browser/extensions/browser_context_keyed_service_factories.h" 58 #include "extensions/browser/browser_context_keyed_service_factories.h" 59 #endif 60 61 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 62 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" 63 #endif 64 65 #if defined(ENABLE_CONFIGURATION_POLICY) 66 #include "chrome/browser/policy/cloud/policy_header_service_factory.h" 67 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator_factory.h" 68 #include "chrome/browser/policy/schema_registry_service_factory.h" 69 #if defined(OS_CHROMEOS) 70 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h" 71 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" 72 #include "chrome/browser/chromeos/policy/recommendation_restorer_factory.h" 73 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h" 74 #include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder_factory.h" 75 #include "chrome/browser/chromeos/policy/user_network_configuration_updater_factory.h" 76 #else 77 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" 78 #if !defined(OS_IOS) 79 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" 80 #endif 81 #endif 82 #endif 83 84 #if defined(ENABLE_MANAGED_USERS) 85 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" 86 #include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h" 87 #if defined(OS_CHROMEOS) 88 #include "chrome/browser/supervised_user/chromeos/manager_password_service_factory.h" 89 #include "chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.h" 90 #endif 91 #endif 92 93 #if defined(USE_AURA) 94 #include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h" 95 #endif 96 97 #if defined(OS_ANDROID) 98 #include "chrome/browser/media/protected_media_identifier_permission_context_factory.h" 99 #else 100 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h" 101 #include "chrome/browser/notifications/sync_notifier/synced_notification_app_info_service_factory.h" 102 #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h" 103 #endif 104 105 #if defined(ENABLE_SPELLCHECK) 106 #include "chrome/browser/spellchecker/spellcheck_factory.h" 107 #endif 108 109 #if defined(ENABLE_SERVICE_DISCOVERY) 110 #include "chrome/browser/local_discovery/privet_notifications_factory.h" 111 #endif 112 113 namespace chrome { 114 AddProfilesExtraParts(ChromeBrowserMainParts * main_parts)115void AddProfilesExtraParts(ChromeBrowserMainParts* main_parts) { 116 main_parts->AddParts(new ChromeBrowserMainExtraPartsProfiles()); 117 } 118 119 } // namespace chrome 120 ChromeBrowserMainExtraPartsProfiles()121ChromeBrowserMainExtraPartsProfiles::ChromeBrowserMainExtraPartsProfiles() { 122 } 123 ~ChromeBrowserMainExtraPartsProfiles()124ChromeBrowserMainExtraPartsProfiles::~ChromeBrowserMainExtraPartsProfiles() { 125 } 126 127 // This method gets the instance of each ServiceFactory. We do this so that 128 // each ServiceFactory initializes itself and registers its dependencies with 129 // the global PreferenceDependencyManager. We need to have a complete 130 // dependency graph when we create a profile so we can dispatch the profile 131 // creation message to the services that want to create their services at 132 // profile creation time. 133 // 134 // TODO(erg): This needs to be something else. I don't think putting every 135 // FooServiceFactory here will scale or is desirable long term. 136 // 137 // static 138 void ChromeBrowserMainExtraPartsProfiles:: EnsureBrowserContextKeyedServiceFactoriesBuilt()139EnsureBrowserContextKeyedServiceFactoriesBuilt() { 140 #if defined(ENABLE_EXTENSIONS) 141 apps::EnsureBrowserContextKeyedServiceFactoriesBuilt(); 142 extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt(); 143 chrome_extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt(); 144 AppShortcutManagerFactory::GetInstance(); 145 EphemeralAppServiceFactory::GetInstance(); 146 #endif 147 148 #if defined(ENABLE_APP_LIST) 149 app_list::AppListSyncableServiceFactory::GetInstance(); 150 #endif 151 152 AboutSigninInternalsFactory::GetInstance(); 153 autofill::PersonalDataManagerFactory::GetInstance(); 154 #if !defined(OS_ANDROID) 155 AutomaticProfileResetterFactory::GetInstance(); 156 #endif 157 #if defined(ENABLE_BACKGROUND) 158 BackgroundContentsServiceFactory::GetInstance(); 159 #endif 160 BookmarkModelFactory::GetInstance(); 161 #if !defined(OS_ANDROID) 162 BookmarkUndoServiceFactory::GetInstance(); 163 #endif 164 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 165 CaptivePortalServiceFactory::GetInstance(); 166 #endif 167 GeolocationPermissionContextFactory::GetInstance(); 168 #if defined(OS_ANDROID) 169 ProtectedMediaIdentifierPermissionContextFactory::GetInstance(); 170 #endif 171 #if defined(ENABLE_FULL_PRINTING) 172 CloudPrintProxyServiceFactory::GetInstance(); 173 #endif 174 CookieSettings::Factory::GetInstance(); 175 #if defined(ENABLE_NOTIFICATIONS) 176 DesktopNotificationServiceFactory::GetInstance(); 177 #endif 178 dom_distiller::DomDistillerServiceFactory::GetInstance(); 179 domain_reliability::DomainReliabilityServiceFactory::GetInstance(); 180 DownloadServiceFactory::GetInstance(); 181 FaviconServiceFactory::GetInstance(); 182 FindBarStateFactory::GetInstance(); 183 GAIAInfoUpdateServiceFactory::GetInstance(); 184 #if defined(USE_AURA) 185 GesturePrefsObserverFactoryAura::GetInstance(); 186 #endif 187 GlobalErrorServiceFactory::GetInstance(); 188 GoogleURLTrackerFactory::GetInstance(); 189 HistoryServiceFactory::GetInstance(); 190 HotwordServiceFactory::GetInstance(); 191 invalidation::ProfileInvalidationProviderFactory::GetInstance(); 192 InstantServiceFactory::GetInstance(); 193 #if defined(ENABLE_SERVICE_DISCOVERY) 194 local_discovery::PrivetNotificationServiceFactory::GetInstance(); 195 #endif 196 #if defined(ENABLE_MANAGED_USERS) 197 #if defined(OS_CHROMEOS) 198 chromeos::SupervisedUserPasswordServiceFactory::GetInstance(); 199 chromeos::ManagerPasswordServiceFactory::GetInstance(); 200 #endif 201 SupervisedUserServiceFactory::GetInstance(); 202 SupervisedUserSyncServiceFactory::GetInstance(); 203 #endif 204 #if !defined(OS_ANDROID) 205 MediaGalleriesPreferencesFactory::GetInstance(); 206 notifier::ChromeNotifierServiceFactory::GetInstance(); 207 notifier::SyncedNotificationAppInfoServiceFactory::GetInstance(); 208 NTPResourceCacheFactory::GetInstance(); 209 #endif 210 PasswordStoreFactory::GetInstance(); 211 #if !defined(OS_ANDROID) 212 PinnedTabServiceFactory::GetInstance(); 213 #endif 214 #if defined(ENABLE_PLUGINS) 215 PluginPrefsFactory::GetInstance(); 216 #endif 217 policy::ProfilePolicyConnectorFactory::GetInstance(); 218 #if defined(ENABLE_CONFIGURATION_POLICY) 219 #if defined(OS_CHROMEOS) 220 chromeos::OwnerSettingsServiceFactory::GetInstance(); 221 policy::PolicyCertServiceFactory::GetInstance(); 222 policy::RecommendationRestorerFactory::GetInstance(); 223 policy::UserCloudPolicyManagerFactoryChromeOS::GetInstance(); 224 policy::UserCloudPolicyTokenForwarderFactory::GetInstance(); 225 policy::UserNetworkConfigurationUpdaterFactory::GetInstance(); 226 #else 227 policy::UserCloudPolicyManagerFactory::GetInstance(); 228 #if !defined(OS_IOS) 229 policy::UserPolicySigninServiceFactory::GetInstance(); 230 #endif 231 #endif 232 policy::PolicyHeaderServiceFactory::GetInstance(); 233 policy::SchemaRegistryServiceFactory::GetInstance(); 234 policy::UserCloudPolicyInvalidatorFactory::GetInstance(); 235 #endif 236 predictors::AutocompleteActionPredictorFactory::GetInstance(); 237 predictors::PredictorDatabaseFactory::GetInstance(); 238 prerender::PrerenderManagerFactory::GetInstance(); 239 prerender::PrerenderLinkManagerFactory::GetInstance(); 240 ProfileSyncServiceFactory::GetInstance(); 241 ProtocolHandlerRegistryFactory::GetInstance(); 242 #if defined(ENABLE_SESSION_SERVICE) 243 SessionServiceFactory::GetInstance(); 244 #endif 245 ShortcutsBackendFactory::GetInstance(); 246 SigninManagerFactory::GetInstance(); 247 #if defined(ENABLE_SPELLCHECK) 248 SpellcheckServiceFactory::GetInstance(); 249 #endif 250 suggestions::SuggestionsServiceFactory::GetInstance(); 251 ThumbnailServiceFactory::GetInstance(); 252 TabRestoreServiceFactory::GetInstance(); 253 TemplateURLFetcherFactory::GetInstance(); 254 TemplateURLServiceFactory::GetInstance(); 255 #if defined(ENABLE_THEMES) 256 ThemeServiceFactory::GetInstance(); 257 #endif 258 WebDataServiceFactory::GetInstance(); 259 } 260 PreProfileInit()261void ChromeBrowserMainExtraPartsProfiles::PreProfileInit() { 262 EnsureBrowserContextKeyedServiceFactoriesBuilt(); 263 } 264