chrome_browser_main_extra_parts_profiles.cc revision cedac228d2dd51db4b79ea1e72c7f249408ee061
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/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"
50
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"
57#endif
58
59#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
60#include "chrome/browser/captive_portal/captive_portal_service_factory.h"
61#endif
62
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"
74#else
75#include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h"
76#if !defined(OS_IOS)
77#include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h"
78#endif
79#endif
80#endif
81
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"
88#endif
89#endif
90
91#if defined(USE_AURA)
92#include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h"
93#endif
94
95#if defined(OS_ANDROID)
96#include "chrome/browser/media/protected_media_identifier_permission_context_factory.h"
97#else
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"
102#endif
103
104#if defined(ENABLE_SPELLCHECK)
105#include "chrome/browser/spellchecker/spellcheck_factory.h"
106#endif
107
108#if defined(ENABLE_SERVICE_DISCOVERY)
109#include "chrome/browser/local_discovery/privet_notifications_factory.h"
110#endif
111
112namespace chrome {
113
114void AddProfilesExtraParts(ChromeBrowserMainParts* main_parts) {
115  main_parts->AddParts(new ChromeBrowserMainExtraPartsProfiles());
116}
117
118}  // namespace chrome
119
120ChromeBrowserMainExtraPartsProfiles::ChromeBrowserMainExtraPartsProfiles() {
121}
122
123ChromeBrowserMainExtraPartsProfiles::~ChromeBrowserMainExtraPartsProfiles() {
124}
125
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.
132//
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.
135//
136// static
137void ChromeBrowserMainExtraPartsProfiles::
138EnsureBrowserContextKeyedServiceFactoriesBuilt() {
139#if defined(ENABLE_EXTENSIONS)
140  apps::EnsureBrowserContextKeyedServiceFactoriesBuilt();
141  extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
142  chrome_extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
143  AppShortcutManagerFactory::GetInstance();
144  EphemeralAppServiceFactory::GetInstance();
145#endif
146
147#if defined(ENABLE_APP_LIST)
148  app_list::AppListSyncableServiceFactory::GetInstance();
149#endif
150
151  AboutSigninInternalsFactory::GetInstance();
152  autofill::PersonalDataManagerFactory::GetInstance();
153#if !defined(OS_ANDROID)
154  AutomaticProfileResetterFactory::GetInstance();
155#endif
156#if defined(ENABLE_BACKGROUND)
157  BackgroundContentsServiceFactory::GetInstance();
158#endif
159  BookmarkModelFactory::GetInstance();
160#if !defined(OS_ANDROID)
161  BookmarkUndoServiceFactory::GetInstance();
162#endif
163#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
164  CaptivePortalServiceFactory::GetInstance();
165#endif
166  ChromeGeolocationPermissionContextFactory::GetInstance();
167#if defined(OS_ANDROID)
168  ProtectedMediaIdentifierPermissionContextFactory::GetInstance();
169#endif
170#if defined(ENABLE_FULL_PRINTING)
171  CloudPrintProxyServiceFactory::GetInstance();
172#endif
173  CookieSettings::Factory::GetInstance();
174#if defined(ENABLE_NOTIFICATIONS)
175  DesktopNotificationServiceFactory::GetInstance();
176#endif
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();
184#endif
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();
193#endif
194#if defined(ENABLE_MANAGED_USERS)
195#if defined(OS_CHROMEOS)
196  chromeos::ManagedUserPasswordServiceFactory::GetInstance();
197  chromeos::ManagerPasswordServiceFactory::GetInstance();
198#endif
199  ManagedUserServiceFactory::GetInstance();
200  ManagedUserSyncServiceFactory::GetInstance();
201#endif
202#if !defined(OS_ANDROID)
203  MediaGalleriesPreferencesFactory::GetInstance();
204  notifier::ChromeNotifierServiceFactory::GetInstance();
205  notifier::SyncedNotificationAppInfoServiceFactory::GetInstance();
206  NTPResourceCacheFactory::GetInstance();
207#endif
208  PasswordStoreFactory::GetInstance();
209#if !defined(OS_ANDROID)
210  PinnedTabServiceFactory::GetInstance();
211#endif
212#if defined(ENABLE_PLUGINS)
213  PluginPrefsFactory::GetInstance();
214#endif
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();
224#else
225  policy::UserCloudPolicyManagerFactory::GetInstance();
226#if !defined(OS_IOS)
227  policy::UserPolicySigninServiceFactory::GetInstance();
228#endif
229#endif
230  policy::PolicyHeaderServiceFactory::GetInstance();
231  policy::SchemaRegistryServiceFactory::GetInstance();
232  policy::UserCloudPolicyInvalidatorFactory::GetInstance();
233#endif
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();
242#endif
243  ShortcutsBackendFactory::GetInstance();
244  SigninManagerFactory::GetInstance();
245#if defined(ENABLE_SPELLCHECK)
246  SpellcheckServiceFactory::GetInstance();
247#endif
248  ThumbnailServiceFactory::GetInstance();
249  TabRestoreServiceFactory::GetInstance();
250  TemplateURLFetcherFactory::GetInstance();
251  TemplateURLServiceFactory::GetInstance();
252#if defined(ENABLE_THEMES)
253  ThemeServiceFactory::GetInstance();
254#endif
255  WebDataServiceFactory::GetInstance();
256}
257
258void ChromeBrowserMainExtraPartsProfiles::PreProfileInit() {
259  EnsureBrowserContextKeyedServiceFactoriesBuilt();
260}
261