chrome_browser_main_extra_parts_profiles.cc revision effb81e5f8246d0db0270817048dc992db66e9fb
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/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/find_bar/find_bar_state_factory.h"
44#include "chrome/browser/ui/global_error/global_error_service_factory.h"
45#include "chrome/browser/ui/tabs/pinned_tab_service_factory.h"
46#include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h"
47#include "chrome/browser/undo/bookmark_undo_service_factory.h"
48#include "chrome/browser/webdata/web_data_service_factory.h"
49
50#if defined(ENABLE_EXTENSIONS)
51#include "apps/browser_context_keyed_service_factories.h"
52#include "chrome/browser/apps/ephemeral_app_service_factory.h"
53#include "chrome/browser/apps/shortcut_manager_factory.h"
54#include "chrome/browser/extensions/browser_context_keyed_service_factories.h"
55#include "extensions/browser/browser_context_keyed_service_factories.h"
56#endif
57
58#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
59#include "chrome/browser/captive_portal/captive_portal_service_factory.h"
60#endif
61
62#if defined(ENABLE_CONFIGURATION_POLICY)
63#include "chrome/browser/policy/cloud/policy_header_service_factory.h"
64#include "chrome/browser/policy/cloud/user_cloud_policy_invalidator_factory.h"
65#include "chrome/browser/policy/schema_registry_service_factory.h"
66#if defined(OS_CHROMEOS)
67#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
68#include "chrome/browser/chromeos/policy/recommendation_restorer_factory.h"
69#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h"
70#include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder_factory.h"
71#include "chrome/browser/chromeos/policy/user_network_configuration_updater_factory.h"
72#else
73#include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h"
74#if !defined(OS_IOS)
75#include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h"
76#endif
77#endif
78#endif
79
80#if defined(ENABLE_MANAGED_USERS)
81#include "chrome/browser/managed_mode/managed_user_service_factory.h"
82#include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
83#if defined(OS_CHROMEOS)
84#include "chrome/browser/managed_mode/chromeos/managed_user_password_service_factory.h"
85#include "chrome/browser/managed_mode/chromeos/manager_password_service_factory.h"
86#endif
87#endif
88
89#if defined(USE_AURA)
90#include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h"
91#endif
92
93#if defined(OS_ANDROID)
94#include "chrome/browser/media/protected_media_identifier_permission_context_factory.h"
95#else
96#include "chrome/browser/media_galleries/media_galleries_preferences_factory.h"
97#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h"
98#include "chrome/browser/notifications/sync_notifier/synced_notification_app_info_service_factory.h"
99#include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h"
100#endif
101
102#if defined(ENABLE_SPELLCHECK)
103#include "chrome/browser/spellchecker/spellcheck_factory.h"
104#endif
105
106#if defined(ENABLE_SERVICE_DISCOVERY)
107#include "chrome/browser/local_discovery/privet_notifications_factory.h"
108#endif
109
110namespace chrome {
111
112void AddProfilesExtraParts(ChromeBrowserMainParts* main_parts) {
113  main_parts->AddParts(new ChromeBrowserMainExtraPartsProfiles());
114}
115
116}  // namespace chrome
117
118ChromeBrowserMainExtraPartsProfiles::ChromeBrowserMainExtraPartsProfiles() {
119}
120
121ChromeBrowserMainExtraPartsProfiles::~ChromeBrowserMainExtraPartsProfiles() {
122}
123
124// This method gets the instance of each ServiceFactory. We do this so that
125// each ServiceFactory initializes itself and registers its dependencies with
126// the global PreferenceDependencyManager. We need to have a complete
127// dependency graph when we create a profile so we can dispatch the profile
128// creation message to the services that want to create their services at
129// profile creation time.
130//
131// TODO(erg): This needs to be something else. I don't think putting every
132// FooServiceFactory here will scale or is desirable long term.
133//
134// static
135void ChromeBrowserMainExtraPartsProfiles::
136EnsureBrowserContextKeyedServiceFactoriesBuilt() {
137#if defined(ENABLE_EXTENSIONS)
138  apps::EnsureBrowserContextKeyedServiceFactoriesBuilt();
139  extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
140  chrome_extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
141
142  AppShortcutManagerFactory::GetInstance();
143  EphemeralAppServiceFactory::GetInstance();
144#endif
145
146  AboutSigninInternalsFactory::GetInstance();
147  autofill::PersonalDataManagerFactory::GetInstance();
148#if !defined(OS_ANDROID)
149  AutomaticProfileResetterFactory::GetInstance();
150#endif
151#if defined(ENABLE_BACKGROUND)
152  BackgroundContentsServiceFactory::GetInstance();
153#endif
154  BookmarkModelFactory::GetInstance();
155#if !defined(OS_ANDROID)
156  BookmarkUndoServiceFactory::GetInstance();
157#endif
158#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
159  captive_portal::CaptivePortalServiceFactory::GetInstance();
160#endif
161  ChromeGeolocationPermissionContextFactory::GetInstance();
162#if defined(OS_ANDROID)
163  ProtectedMediaIdentifierPermissionContextFactory::GetInstance();
164#endif
165#if defined(ENABLE_FULL_PRINTING)
166  CloudPrintProxyServiceFactory::GetInstance();
167#endif
168  CookieSettings::Factory::GetInstance();
169#if defined(ENABLE_NOTIFICATIONS)
170  DesktopNotificationServiceFactory::GetInstance();
171#endif
172  dom_distiller::DomDistillerServiceFactory::GetInstance();
173  DownloadServiceFactory::GetInstance();
174  FaviconServiceFactory::GetInstance();
175  FindBarStateFactory::GetInstance();
176  GAIAInfoUpdateServiceFactory::GetInstance();
177#if defined(USE_AURA)
178  GesturePrefsObserverFactoryAura::GetInstance();
179#endif
180  GlobalErrorServiceFactory::GetInstance();
181  GoogleURLTrackerFactory::GetInstance();
182  HistoryServiceFactory::GetInstance();
183  HotwordServiceFactory::GetInstance();
184  invalidation::InvalidationServiceFactory::GetInstance();
185  InstantServiceFactory::GetInstance();
186#if defined(ENABLE_SERVICE_DISCOVERY)
187  local_discovery::PrivetNotificationServiceFactory::GetInstance();
188#endif
189#if defined(ENABLE_MANAGED_USERS)
190#if defined(OS_CHROMEOS)
191  chromeos::ManagedUserPasswordServiceFactory::GetInstance();
192  chromeos::ManagerPasswordServiceFactory::GetInstance();
193#endif
194  ManagedUserServiceFactory::GetInstance();
195  ManagedUserSyncServiceFactory::GetInstance();
196#endif
197#if !defined(OS_ANDROID)
198  MediaGalleriesPreferencesFactory::GetInstance();
199  notifier::ChromeNotifierServiceFactory::GetInstance();
200  notifier::SyncedNotificationAppInfoServiceFactory::GetInstance();
201#endif
202  NTPResourceCacheFactory::GetInstance();
203  PasswordStoreFactory::GetInstance();
204#if !defined(OS_ANDROID)
205  PinnedTabServiceFactory::GetInstance();
206#endif
207#if defined(ENABLE_PLUGINS)
208  PluginPrefsFactory::GetInstance();
209#endif
210  policy::ProfilePolicyConnectorFactory::GetInstance();
211#if defined(ENABLE_CONFIGURATION_POLICY)
212#if defined(OS_CHROMEOS)
213  policy::PolicyCertServiceFactory::GetInstance();
214  policy::RecommendationRestorerFactory::GetInstance();
215  policy::UserCloudPolicyManagerFactoryChromeOS::GetInstance();
216  policy::UserCloudPolicyTokenForwarderFactory::GetInstance();
217  policy::UserNetworkConfigurationUpdaterFactory::GetInstance();
218#else
219  policy::UserCloudPolicyManagerFactory::GetInstance();
220#if !defined(OS_IOS)
221  policy::UserPolicySigninServiceFactory::GetInstance();
222#endif
223#endif
224  policy::PolicyHeaderServiceFactory::GetInstance();
225  policy::SchemaRegistryServiceFactory::GetInstance();
226  policy::UserCloudPolicyInvalidatorFactory::GetInstance();
227#endif
228  predictors::AutocompleteActionPredictorFactory::GetInstance();
229  predictors::PredictorDatabaseFactory::GetInstance();
230  prerender::PrerenderManagerFactory::GetInstance();
231  prerender::PrerenderLinkManagerFactory::GetInstance();
232  ProfileSyncServiceFactory::GetInstance();
233  ProtocolHandlerRegistryFactory::GetInstance();
234#if defined(ENABLE_SESSION_SERVICE)
235  SessionServiceFactory::GetInstance();
236#endif
237  ShortcutsBackendFactory::GetInstance();
238  SigninManagerFactory::GetInstance();
239#if defined(ENABLE_SPELLCHECK)
240  SpellcheckServiceFactory::GetInstance();
241#endif
242  ThumbnailServiceFactory::GetInstance();
243  TabRestoreServiceFactory::GetInstance();
244  TemplateURLFetcherFactory::GetInstance();
245  TemplateURLServiceFactory::GetInstance();
246#if defined(ENABLE_THEMES)
247  ThemeServiceFactory::GetInstance();
248#endif
249  WebDataServiceFactory::GetInstance();
250}
251
252void ChromeBrowserMainExtraPartsProfiles::PreProfileInit() {
253  EnsureBrowserContextKeyedServiceFactoriesBuilt();
254}
255