Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / profiles / chrome_browser_main_extra_parts_profiles.cc
blob7dfdb8313f09f9b40829c113f0c8674500da07f9
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/in_memory_url_index_factory.h"
8 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h"
9 #include "chrome/browser/autofill/personal_data_manager_factory.h"
10 #include "chrome/browser/background/background_contents_service_factory.h"
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
12 #include "chrome/browser/chrome_browser_main.h"
13 #include "chrome/browser/content_settings/cookie_settings_factory.h"
14 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
15 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
16 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
17 #include "chrome/browser/domain_reliability/service_factory.h"
18 #include "chrome/browser/download/download_service_factory.h"
19 #include "chrome/browser/engagement/site_engagement_service.h"
20 #include "chrome/browser/engagement/site_engagement_service_factory.h"
21 #include "chrome/browser/favicon/favicon_service_factory.h"
22 #include "chrome/browser/geolocation/geolocation_permission_context_factory.h"
23 #include "chrome/browser/google/google_url_tracker_factory.h"
24 #include "chrome/browser/history/history_service_factory.h"
25 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
26 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h"
27 #include "chrome/browser/notifications/extension_welcome_notification_factory.h"
28 #include "chrome/browser/notifications/notification_permission_context_factory.h"
29 #include "chrome/browser/notifications/notifier_state_tracker_factory.h"
30 #include "chrome/browser/password_manager/password_store_factory.h"
31 #include "chrome/browser/plugins/plugin_prefs_factory.h"
32 #include "chrome/browser/policy/profile_policy_connector_factory.h"
33 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h"
34 #include "chrome/browser/predictors/predictor_database_factory.h"
35 #include "chrome/browser/predictors/resource_prefetch_predictor_factory.h"
36 #include "chrome/browser/prerender/prerender_link_manager_factory.h"
37 #include "chrome/browser/prerender/prerender_manager_factory.h"
38 #include "chrome/browser/prerender/prerender_message_filter.h"
39 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h"
40 #include "chrome/browser/profiles/gaia_info_update_service_factory.h"
41 #include "chrome/browser/search/instant_service_factory.h"
42 #include "chrome/browser/search/suggestions/suggestions_service_factory.h"
43 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
44 #include "chrome/browser/search_engines/template_url_service_factory.h"
45 #include "chrome/browser/sessions/session_service_factory.h"
46 #include "chrome/browser/sessions/tab_restore_service_factory.h"
47 #include "chrome/browser/signin/about_signin_internals_factory.h"
48 #include "chrome/browser/signin/account_fetcher_service_factory.h"
49 #include "chrome/browser/signin/account_tracker_service_factory.h"
50 #include "chrome/browser/signin/signin_manager_factory.h"
51 #include "chrome/browser/sync/profile_sync_service_factory.h"
52 #include "chrome/browser/themes/theme_service_factory.h"
53 #include "chrome/browser/thumbnails/thumbnail_service_factory.h"
54 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
55 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h"
56 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
57 #include "chrome/browser/ui/tabs/pinned_tab_service_factory.h"
58 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h"
59 #include "chrome/browser/undo/bookmark_undo_service_factory.h"
60 #include "chrome/browser/web_data_service_factory.h"
62 #if defined(ENABLE_EXTENSIONS)
63 #include "apps/browser_context_keyed_service_factories.h"
64 #include "chrome/browser/apps/ephemeral_app_service_factory.h"
65 #include "chrome/browser/apps/shortcut_manager_factory.h"
66 #include "chrome/browser/extensions/api/networking_private/networking_private_ui_delegate_factory_impl.h"
67 #include "chrome/browser/extensions/api/networking_private/networking_private_verify_delegate_factory_impl.h"
68 #include "chrome/browser/extensions/browser_context_keyed_service_factories.h"
69 #include "chrome/browser/extensions/extension_management.h"
70 #include "chrome/browser/search/hotword_service_factory.h"
71 #include "chrome/browser/signin/easy_unlock_service_factory.h"
72 #include "chrome/browser/ui/bookmarks/enhanced_bookmark_key_service_factory.h"
73 #include "extensions/browser/api/networking_private/networking_private_delegate_factory.h"
74 #include "extensions/browser/browser_context_keyed_service_factories.h"
75 #endif
77 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
78 #include "chrome/browser/captive_portal/captive_portal_service_factory.h"
79 #endif
81 #if defined(ENABLE_CONFIGURATION_POLICY)
82 #include "chrome/browser/policy/cloud/policy_header_service_factory.h"
83 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator_factory.h"
84 #include "chrome/browser/policy/schema_registry_service_factory.h"
85 #if defined(OS_CHROMEOS)
86 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
87 #include "chrome/browser/chromeos/policy/consumer_enrollment_handler_factory.h"
88 #include "chrome/browser/chromeos/policy/consumer_management_notifier_factory.h"
89 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
90 #include "chrome/browser/chromeos/policy/recommendation_restorer_factory.h"
91 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h"
92 #include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder_factory.h"
93 #include "chrome/browser/chromeos/policy/user_network_configuration_updater_factory.h"
94 #else
95 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h"
96 #if !defined(OS_IOS)
97 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h"
98 #endif
99 #endif
100 #endif
102 #if defined(ENABLE_SUPERVISED_USERS)
103 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service_factory.h"
104 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
105 #if defined(OS_CHROMEOS)
106 #include "chrome/browser/supervised_user/chromeos/manager_password_service_factory.h"
107 #include "chrome/browser/supervised_user/chromeos/supervised_user_password_service_factory.h"
108 #endif
109 #endif
111 #if defined(USE_AURA)
112 #include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h"
113 #endif
115 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
116 #include "chrome/browser/media/protected_media_identifier_permission_context_factory.h"
117 #endif
119 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
120 #include "chrome/browser/signin/cross_device_promo_factory.h"
121 #endif
123 #if defined(OS_CHROMEOS)
124 #include "chrome/browser/chromeos/printer_detector/printer_detector_factory.h"
125 #include "chrome/browser/extensions/api/platform_keys/verify_trust_api.h"
126 #endif
128 #if !defined(OS_ANDROID)
129 #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h"
130 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
131 #endif
133 #if defined(ENABLE_SPELLCHECK)
134 #include "chrome/browser/spellchecker/spellcheck_factory.h"
135 #endif
137 #if defined(ENABLE_SERVICE_DISCOVERY)
138 #include "chrome/browser/local_discovery/privet_notifications_factory.h"
139 #endif
141 namespace chrome {
143 void AddProfilesExtraParts(ChromeBrowserMainParts* main_parts) {
144 main_parts->AddParts(new ChromeBrowserMainExtraPartsProfiles());
147 } // namespace chrome
149 ChromeBrowserMainExtraPartsProfiles::ChromeBrowserMainExtraPartsProfiles() {
152 ChromeBrowserMainExtraPartsProfiles::~ChromeBrowserMainExtraPartsProfiles() {
155 // This method gets the instance of each ServiceFactory. We do this so that
156 // each ServiceFactory initializes itself and registers its dependencies with
157 // the global PreferenceDependencyManager. We need to have a complete
158 // dependency graph when we create a profile so we can dispatch the profile
159 // creation message to the services that want to create their services at
160 // profile creation time.
162 // TODO(erg): This needs to be something else. I don't think putting every
163 // FooServiceFactory here will scale or is desirable long term.
165 // static
166 void ChromeBrowserMainExtraPartsProfiles::
167 EnsureBrowserContextKeyedServiceFactoriesBuilt() {
168 #if defined(ENABLE_EXTENSIONS)
169 apps::EnsureBrowserContextKeyedServiceFactoriesBuilt();
170 extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
171 extensions::ExtensionManagementFactory::GetInstance();
172 chrome_extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
173 AppShortcutManagerFactory::GetInstance();
174 EphemeralAppServiceFactory::GetInstance();
175 #endif
177 #if defined(ENABLE_APP_LIST)
178 app_list::AppListSyncableServiceFactory::GetInstance();
179 #endif
181 AboutSigninInternalsFactory::GetInstance();
182 AccountTrackerServiceFactory::GetInstance();
183 AccountFetcherServiceFactory::GetInstance();
184 autofill::PersonalDataManagerFactory::GetInstance();
185 #if !defined(OS_ANDROID)
186 AutomaticProfileResetterFactory::GetInstance();
187 #endif
188 #if defined(ENABLE_BACKGROUND)
189 BackgroundContentsServiceFactory::GetInstance();
190 #endif
191 BookmarkModelFactory::GetInstance();
192 BookmarkUndoServiceFactory::GetInstance();
193 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
194 CaptivePortalServiceFactory::GetInstance();
195 #endif
196 GeolocationPermissionContextFactory::GetInstance();
197 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
198 ProtectedMediaIdentifierPermissionContextFactory::GetInstance();
199 #endif
200 #if defined(ENABLE_PRINT_PREVIEW)
201 CloudPrintProxyServiceFactory::GetInstance();
202 #endif
203 CookieSettingsFactory::GetInstance();
204 #if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
205 CrossDevicePromoFactory::GetInstance();
206 #endif
207 #if defined(ENABLE_NOTIFICATIONS)
208 #if defined(ENABLE_EXTENSIONS)
209 ExtensionWelcomeNotificationFactory::GetInstance();
210 #endif
211 NotificationPermissionContextFactory::GetInstance();
212 NotifierStateTrackerFactory::GetInstance();
213 #endif // defined(ENABLE_NOTIFICATIONS)
214 dom_distiller::DomDistillerServiceFactory::GetInstance();
215 domain_reliability::DomainReliabilityServiceFactory::GetInstance();
216 DownloadServiceFactory::GetInstance();
217 #if defined(ENABLE_EXTENSIONS)
218 EasyUnlockServiceFactory::GetInstance();
219 EnhancedBookmarkKeyServiceFactory::GetInstance();
220 #endif
221 #if defined(OS_CHROMEOS)
222 chromeos::PrinterDetectorFactory::GetInstance();
223 extensions::VerifyTrustAPI::GetFactoryInstance();
224 #endif
225 FaviconServiceFactory::GetInstance();
226 FindBarStateFactory::GetInstance();
227 GAIAInfoUpdateServiceFactory::GetInstance();
228 #if defined(USE_AURA)
229 GesturePrefsObserverFactoryAura::GetInstance();
230 #endif
231 #if !defined(OS_ANDROID)
232 GlobalErrorServiceFactory::GetInstance();
233 #endif
234 GoogleURLTrackerFactory::GetInstance();
235 HistoryServiceFactory::GetInstance();
236 #if defined(ENABLE_EXTENSIONS)
237 HotwordServiceFactory::GetInstance();
238 #endif
239 HostContentSettingsMapFactory::GetInstance();
240 InMemoryURLIndexFactory::GetInstance();
241 invalidation::ProfileInvalidationProviderFactory::GetInstance();
242 InstantServiceFactory::GetInstance();
243 #if defined(ENABLE_SERVICE_DISCOVERY)
244 local_discovery::PrivetNotificationServiceFactory::GetInstance();
245 #endif
246 #if defined(ENABLE_SUPERVISED_USERS)
247 #if defined(OS_CHROMEOS)
248 chromeos::SupervisedUserPasswordServiceFactory::GetInstance();
249 chromeos::ManagerPasswordServiceFactory::GetInstance();
250 #endif
251 SupervisedUserServiceFactory::GetInstance();
252 #if !defined(OS_ANDROID) && !defined(OS_IOS)
253 SupervisedUserSyncServiceFactory::GetInstance();
254 #endif
255 #endif
256 #if defined(ENABLE_EXTENSIONS)
257 #if defined(OS_CHROMEOS) || defined(OS_WIN) || defined(OS_MACOSX)
258 scoped_ptr<extensions::NetworkingPrivateVerifyDelegateFactoryImpl>
259 networking_private_verify_delegate_factory(
260 new extensions::NetworkingPrivateVerifyDelegateFactoryImpl);
261 extensions::NetworkingPrivateDelegateFactory::GetInstance()
262 ->SetVerifyDelegateFactory(
263 networking_private_verify_delegate_factory.Pass());
264 scoped_ptr<extensions::NetworkingPrivateUIDelegateFactoryImpl>
265 networking_private_ui_delegate_factory(
266 new extensions::NetworkingPrivateUIDelegateFactoryImpl);
267 extensions::NetworkingPrivateDelegateFactory::GetInstance()
268 ->SetUIDelegateFactory(networking_private_ui_delegate_factory.Pass());
269 #endif
270 #endif
271 #if !defined(OS_ANDROID)
272 MediaGalleriesPreferencesFactory::GetInstance();
273 NTPResourceCacheFactory::GetInstance();
274 #endif
275 PasswordStoreFactory::GetInstance();
276 #if !defined(OS_ANDROID)
277 PinnedTabServiceFactory::GetInstance();
278 #endif
279 #if defined(ENABLE_PLUGINS)
280 PluginPrefsFactory::GetInstance();
281 #endif
282 PrefsTabHelper::GetServiceInstance();
283 policy::ProfilePolicyConnectorFactory::GetInstance();
284 #if defined(ENABLE_CONFIGURATION_POLICY)
285 #if defined(OS_CHROMEOS)
286 chromeos::OwnerSettingsServiceChromeOSFactory::GetInstance();
287 policy::ConsumerEnrollmentHandlerFactory::GetInstance();
288 policy::ConsumerManagementNotifierFactory::GetInstance();
289 policy::PolicyCertServiceFactory::GetInstance();
290 policy::RecommendationRestorerFactory::GetInstance();
291 policy::UserCloudPolicyManagerFactoryChromeOS::GetInstance();
292 policy::UserCloudPolicyTokenForwarderFactory::GetInstance();
293 policy::UserNetworkConfigurationUpdaterFactory::GetInstance();
294 #else
295 policy::UserCloudPolicyManagerFactory::GetInstance();
296 #if !defined(OS_IOS)
297 policy::UserPolicySigninServiceFactory::GetInstance();
298 #endif
299 #endif
300 policy::PolicyHeaderServiceFactory::GetInstance();
301 policy::SchemaRegistryServiceFactory::GetInstance();
302 policy::UserCloudPolicyInvalidatorFactory::GetInstance();
303 #endif
304 predictors::AutocompleteActionPredictorFactory::GetInstance();
305 predictors::PredictorDatabaseFactory::GetInstance();
306 predictors::ResourcePrefetchPredictorFactory::GetInstance();
307 prerender::PrerenderLinkManagerFactory::GetInstance();
308 prerender::PrerenderManagerFactory::GetInstance();
309 prerender::PrerenderMessageFilter::EnsureShutdownNotifierFactoryBuilt();
310 ProfileSyncServiceFactory::GetInstance();
311 ProtocolHandlerRegistryFactory::GetInstance();
312 #if defined(ENABLE_SESSION_SERVICE)
313 SessionServiceFactory::GetInstance();
314 #endif
315 ShortcutsBackendFactory::GetInstance();
316 SigninManagerFactory::GetInstance();
318 if (SiteEngagementService::IsEnabled())
319 SiteEngagementServiceFactory::GetInstance();
321 #if defined(ENABLE_SPELLCHECK)
322 SpellcheckServiceFactory::GetInstance();
323 #endif
324 suggestions::SuggestionsServiceFactory::GetInstance();
325 ThumbnailServiceFactory::GetInstance();
326 TabRestoreServiceFactory::GetInstance();
327 TemplateURLFetcherFactory::GetInstance();
328 TemplateURLServiceFactory::GetInstance();
329 #if defined(ENABLE_THEMES)
330 ThemeServiceFactory::GetInstance();
331 #endif
332 WebDataServiceFactory::GetInstance();
335 void ChromeBrowserMainExtraPartsProfiles::PreProfileInit() {
336 EnsureBrowserContextKeyedServiceFactoriesBuilt();