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/download/download_service_factory.h"
16 #include "chrome/browser/favicon/favicon_service_factory.h"
17 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_factory.h"
18 #include "chrome/browser/google/google_url_tracker_factory.h"
19 #include "chrome/browser/history/history_service_factory.h"
20 #include "chrome/browser/invalidation/invalidation_service_factory.h"
21 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h"
22 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
23 #include "chrome/browser/password_manager/password_store_factory.h"
24 #include "chrome/browser/plugins/plugin_prefs_factory.h"
25 #include "chrome/browser/policy/profile_policy_connector_factory.h"
26 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h"
27 #include "chrome/browser/predictors/predictor_database_factory.h"
28 #include "chrome/browser/prerender/prerender_link_manager_factory.h"
29 #include "chrome/browser/prerender/prerender_manager_factory.h"
30 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h"
31 #include "chrome/browser/profiles/gaia_info_update_service_factory.h"
32 #include "chrome/browser/search/hotword_service_factory.h"
33 #include "chrome/browser/search/instant_service_factory.h"
34 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
35 #include "chrome/browser/search_engines/template_url_service_factory.h"
36 #include "chrome/browser/sessions/session_service_factory.h"
37 #include "chrome/browser/sessions/tab_restore_service_factory.h"
38 #include "chrome/browser/signin/about_signin_internals_factory.h"
39 #include "chrome/browser/signin/signin_manager_factory.h"
40 #include "chrome/browser/sync/profile_sync_service_factory.h"
41 #include "chrome/browser/themes/theme_service_factory.h"
42 #include "chrome/browser/thumbnails/thumbnail_service_factory.h"
43 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
44 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h"
45 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
46 #include "chrome/browser/ui/tabs/pinned_tab_service_factory.h"
47 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h"
48 #include "chrome/browser/undo/bookmark_undo_service_factory.h"
49 #include "chrome/browser/webdata/web_data_service_factory.h"
51 #if defined(ENABLE_EXTENSIONS)
52 #include "apps/browser_context_keyed_service_factories.h"
53 #include "chrome/browser/apps/ephemeral_app_service_factory.h"
54 #include "chrome/browser/apps/shortcut_manager_factory.h"
55 #include "chrome/browser/extensions/browser_context_keyed_service_factories.h"
56 #include "extensions/browser/browser_context_keyed_service_factories.h"
59 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
60 #include "chrome/browser/captive_portal/captive_portal_service_factory.h"
63 #if defined(ENABLE_CONFIGURATION_POLICY)
64 #include "chrome/browser/policy/cloud/policy_header_service_factory.h"
65 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator_factory.h"
66 #include "chrome/browser/policy/schema_registry_service_factory.h"
67 #if defined(OS_CHROMEOS)
68 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h"
69 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
70 #include "chrome/browser/chromeos/policy/recommendation_restorer_factory.h"
71 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h"
72 #include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder_factory.h"
73 #include "chrome/browser/chromeos/policy/user_network_configuration_updater_factory.h"
75 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h"
77 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h"
82 #if defined(ENABLE_MANAGED_USERS)
83 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
84 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
85 #if defined(OS_CHROMEOS)
86 #include "chrome/browser/managed_mode/chromeos/managed_user_password_service_factory.h"
87 #include "chrome/browser/managed_mode/chromeos/manager_password_service_factory.h"
92 #include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h"
95 #if defined(OS_ANDROID)
96 #include "chrome/browser/media/protected_media_identifier_permission_context_factory.h"
98 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h"
99 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h"
100 #include "chrome/browser/notifications/sync_notifier/synced_notification_app_info_service_factory.h"
101 #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h"
104 #if defined(ENABLE_SPELLCHECK)
105 #include "chrome/browser/spellchecker/spellcheck_factory.h"
108 #if defined(ENABLE_SERVICE_DISCOVERY)
109 #include "chrome/browser/local_discovery/privet_notifications_factory.h"
114 void AddProfilesExtraParts(ChromeBrowserMainParts
* main_parts
) {
115 main_parts
->AddParts(new ChromeBrowserMainExtraPartsProfiles());
118 } // namespace chrome
120 ChromeBrowserMainExtraPartsProfiles::ChromeBrowserMainExtraPartsProfiles() {
123 ChromeBrowserMainExtraPartsProfiles::~ChromeBrowserMainExtraPartsProfiles() {
126 // This method gets the instance of each ServiceFactory. We do this so that
127 // each ServiceFactory initializes itself and registers its dependencies with
128 // the global PreferenceDependencyManager. We need to have a complete
129 // dependency graph when we create a profile so we can dispatch the profile
130 // creation message to the services that want to create their services at
131 // profile creation time.
133 // TODO(erg): This needs to be something else. I don't think putting every
134 // FooServiceFactory here will scale or is desirable long term.
137 void ChromeBrowserMainExtraPartsProfiles::
138 EnsureBrowserContextKeyedServiceFactoriesBuilt() {
139 #if defined(ENABLE_EXTENSIONS)
140 apps::EnsureBrowserContextKeyedServiceFactoriesBuilt();
141 extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
142 chrome_extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
143 AppShortcutManagerFactory::GetInstance();
144 EphemeralAppServiceFactory::GetInstance();
147 #if defined(ENABLE_APP_LIST)
148 app_list::AppListSyncableServiceFactory::GetInstance();
151 AboutSigninInternalsFactory::GetInstance();
152 autofill::PersonalDataManagerFactory::GetInstance();
153 #if !defined(OS_ANDROID)
154 AutomaticProfileResetterFactory::GetInstance();
156 #if defined(ENABLE_BACKGROUND)
157 BackgroundContentsServiceFactory::GetInstance();
159 BookmarkModelFactory::GetInstance();
160 #if !defined(OS_ANDROID)
161 BookmarkUndoServiceFactory::GetInstance();
163 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
164 CaptivePortalServiceFactory::GetInstance();
166 ChromeGeolocationPermissionContextFactory::GetInstance();
167 #if defined(OS_ANDROID)
168 ProtectedMediaIdentifierPermissionContextFactory::GetInstance();
170 #if defined(ENABLE_FULL_PRINTING)
171 CloudPrintProxyServiceFactory::GetInstance();
173 CookieSettings::Factory::GetInstance();
174 #if defined(ENABLE_NOTIFICATIONS)
175 DesktopNotificationServiceFactory::GetInstance();
177 dom_distiller::DomDistillerServiceFactory::GetInstance();
178 DownloadServiceFactory::GetInstance();
179 FaviconServiceFactory::GetInstance();
180 FindBarStateFactory::GetInstance();
181 GAIAInfoUpdateServiceFactory::GetInstance();
182 #if defined(USE_AURA)
183 GesturePrefsObserverFactoryAura::GetInstance();
185 GlobalErrorServiceFactory::GetInstance();
186 GoogleURLTrackerFactory::GetInstance();
187 HistoryServiceFactory::GetInstance();
188 HotwordServiceFactory::GetInstance();
189 invalidation::InvalidationServiceFactory::GetInstance();
190 InstantServiceFactory::GetInstance();
191 #if defined(ENABLE_SERVICE_DISCOVERY)
192 local_discovery::PrivetNotificationServiceFactory::GetInstance();
194 #if defined(ENABLE_MANAGED_USERS)
195 #if defined(OS_CHROMEOS)
196 chromeos::ManagedUserPasswordServiceFactory::GetInstance();
197 chromeos::ManagerPasswordServiceFactory::GetInstance();
199 ManagedUserServiceFactory::GetInstance();
200 ManagedUserSyncServiceFactory::GetInstance();
202 #if !defined(OS_ANDROID)
203 MediaGalleriesPreferencesFactory::GetInstance();
204 notifier::ChromeNotifierServiceFactory::GetInstance();
205 notifier::SyncedNotificationAppInfoServiceFactory::GetInstance();
206 NTPResourceCacheFactory::GetInstance();
208 PasswordStoreFactory::GetInstance();
209 #if !defined(OS_ANDROID)
210 PinnedTabServiceFactory::GetInstance();
212 #if defined(ENABLE_PLUGINS)
213 PluginPrefsFactory::GetInstance();
215 policy::ProfilePolicyConnectorFactory::GetInstance();
216 #if defined(ENABLE_CONFIGURATION_POLICY)
217 #if defined(OS_CHROMEOS)
218 chromeos::OwnerSettingsServiceFactory::GetInstance();
219 policy::PolicyCertServiceFactory::GetInstance();
220 policy::RecommendationRestorerFactory::GetInstance();
221 policy::UserCloudPolicyManagerFactoryChromeOS::GetInstance();
222 policy::UserCloudPolicyTokenForwarderFactory::GetInstance();
223 policy::UserNetworkConfigurationUpdaterFactory::GetInstance();
225 policy::UserCloudPolicyManagerFactory::GetInstance();
227 policy::UserPolicySigninServiceFactory::GetInstance();
230 policy::PolicyHeaderServiceFactory::GetInstance();
231 policy::SchemaRegistryServiceFactory::GetInstance();
232 policy::UserCloudPolicyInvalidatorFactory::GetInstance();
234 predictors::AutocompleteActionPredictorFactory::GetInstance();
235 predictors::PredictorDatabaseFactory::GetInstance();
236 prerender::PrerenderManagerFactory::GetInstance();
237 prerender::PrerenderLinkManagerFactory::GetInstance();
238 ProfileSyncServiceFactory::GetInstance();
239 ProtocolHandlerRegistryFactory::GetInstance();
240 #if defined(ENABLE_SESSION_SERVICE)
241 SessionServiceFactory::GetInstance();
243 ShortcutsBackendFactory::GetInstance();
244 SigninManagerFactory::GetInstance();
245 #if defined(ENABLE_SPELLCHECK)
246 SpellcheckServiceFactory::GetInstance();
248 ThumbnailServiceFactory::GetInstance();
249 TabRestoreServiceFactory::GetInstance();
250 TemplateURLFetcherFactory::GetInstance();
251 TemplateURLServiceFactory::GetInstance();
252 #if defined(ENABLE_THEMES)
253 ThemeServiceFactory::GetInstance();
255 WebDataServiceFactory::GetInstance();
258 void ChromeBrowserMainExtraPartsProfiles::PreProfileInit() {
259 EnsureBrowserContextKeyedServiceFactoriesBuilt();