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