blob: d15f0ec27437fd6a9cfbeefd4cfb19781b146f2a [file] [log] [blame]
[email protected]59b0e602014-01-30 00:41:241// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]31d8f5f22012-04-02 15:22:082// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]59b0e602014-01-30 00:41:245#include "chrome/browser/extensions/extension_system_impl.h"
[email protected]31d8f5f22012-04-02 15:22:086
asargent8380bd392016-03-21 23:47:337#include <algorithm>
8
[email protected]53603d22012-11-14 08:31:119#include "base/base_switches.h"
[email protected]31d8f5f22012-04-02 15:22:0810#include "base/bind.h"
11#include "base/command_line.h"
[email protected]57999812013-02-24 05:40:5212#include "base/files/file_path.h"
asargent631a99a2015-10-15 21:51:4813#include "base/files/file_util.h"
[email protected]f83bd432014-05-10 20:44:4014#include "base/memory/weak_ptr.h"
[email protected]f4ebe772013-02-02 00:21:3915#include "base/strings/string_tokenizer.h"
rkaplowe65c2ff2015-02-14 16:29:5416#include "base/trace_event/trace_event.h"
avia2f4804a2015-12-24 23:11:1317#include "build/build_config.h"
[email protected]31d8f5f22012-04-02 15:22:0818#include "chrome/browser/browser_process.h"
treib926ee2d2015-08-06 10:55:4219#include "chrome/browser/extensions/chrome_app_sorting.h"
juncaie950b9e552015-06-11 20:25:3120#include "chrome/browser/extensions/chrome_content_verifier_delegate.h"
[email protected]931186e02012-07-20 01:22:0621#include "chrome/browser/extensions/component_loader.h"
[email protected]31d8f5f22012-04-02 15:22:0822#include "chrome/browser/extensions/extension_error_reporter.h"
xiyuanf6a4c6a62016-04-19 18:14:5423#include "chrome/browser/extensions/extension_garbage_collector.h"
binjin1569c9b2014-09-05 13:33:1824#include "chrome/browser/extensions/extension_management.h"
[email protected]31d8f5f22012-04-02 15:22:0825#include "chrome/browser/extensions/extension_service.h"
treib8a6d9892015-08-26 10:23:1926#include "chrome/browser/extensions/extension_sync_service.h"
[email protected]31d8f5f22012-04-02 15:22:0827#include "chrome/browser/extensions/extension_system_factory.h"
[email protected]a7ff4b72013-10-17 20:56:0228#include "chrome/browser/extensions/extension_util.h"
[email protected]ffd2f79e2013-11-14 00:11:4629#include "chrome/browser/extensions/install_verifier.h"
[email protected]d9ede582012-08-14 19:21:3830#include "chrome/browser/extensions/navigation_observer.h"
[email protected]f698c162014-06-13 00:46:2631#include "chrome/browser/extensions/shared_module_service.h"
[email protected]15ad2ee2014-08-15 19:15:2632#include "chrome/browser/extensions/shared_user_script_master.h"
[email protected]479e3922014-07-30 07:12:5733#include "chrome/browser/extensions/state_store_notification_observer.h"
[email protected]13e062e2014-08-09 10:21:5534#include "chrome/browser/extensions/unpacked_installer.h"
xiyuanf6a4c6a62016-04-19 18:14:5435#include "chrome/browser/extensions/update_install_gate.h"
[email protected]31d8f5f22012-04-02 15:22:0836#include "chrome/browser/profiles/profile.h"
37#include "chrome/browser/profiles/profile_manager.h"
[email protected]13e062e2014-08-09 10:21:5538#include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
[email protected]31d8f5f22012-04-02 15:22:0839#include "chrome/common/chrome_switches.h"
[email protected]31d8f5f22012-04-02 15:22:0840#include "content/public/browser/browser_thread.h"
[email protected]24ea7a12013-01-27 23:54:5341#include "content/public/browser/url_data_source.h"
[email protected]fd3df7782014-05-08 23:54:2742#include "extensions/browser/content_verifier.h"
[email protected]489db0842014-01-22 18:20:0343#include "extensions/browser/extension_pref_store.h"
44#include "extensions/browser/extension_pref_value_map.h"
45#include "extensions/browser/extension_pref_value_map_factory.h"
46#include "extensions/browser/extension_prefs.h"
[email protected]45f5b7d2014-01-22 23:47:1347#include "extensions/browser/extension_registry.h"
[email protected]38427a12013-11-09 17:34:2048#include "extensions/browser/info_map.h"
[email protected]aab23102014-02-05 18:57:5549#include "extensions/browser/quota_service.h"
[email protected]45f5b7d2014-01-22 23:47:1350#include "extensions/browser/runtime_data.h"
rdevlin.croninf5863da2015-09-10 19:21:4551#include "extensions/browser/service_worker_manager.h"
[email protected]daf3ffda2014-06-25 06:44:5752#include "extensions/browser/state_store.h"
asargent8380bd392016-03-21 23:47:3353#include "extensions/browser/uninstall_ping_sender.h"
cmumford6ae8d462016-03-24 20:35:2754#include "extensions/browser/value_store/value_store_factory_impl.h"
[email protected]836e2982013-05-16 08:07:4255#include "extensions/common/constants.h"
rdevlin.cronin41227532016-07-13 21:24:3456#include "extensions/common/features/feature_channel.h"
asargent8380bd392016-03-21 23:47:3357#include "extensions/common/manifest_url_handlers.h"
[email protected]31d8f5f22012-04-02 15:22:0858
[email protected]9afacd22013-11-13 20:23:3159#if defined(ENABLE_NOTIFICATIONS)
peterc4007912015-07-31 21:13:3760#include "chrome/browser/notifications/notifier_state_tracker.h"
61#include "chrome/browser/notifications/notifier_state_tracker_factory.h"
[email protected]9afacd22013-11-13 20:23:3162#include "ui/message_center/notifier_settings.h"
63#endif
64
[email protected]bb121482012-12-08 06:49:3865#if defined(OS_CHROMEOS)
[email protected]6ed2e0c2013-04-09 04:48:1366#include "chrome/browser/app_mode/app_mode_utils.h"
xiyuana0a6aaaa2016-04-19 23:34:1667#include "chrome/browser/chromeos/app_mode/kiosk_app_update_install_gate.h"
[email protected]1a6436112013-10-09 02:49:5868#include "chrome/browser/chromeos/extensions/device_local_account_management_policy_provider.h"
antrim58769562016-11-14 14:48:4169#include "chrome/browser/chromeos/extensions/signin_screen_policy_provider.h"
[email protected]1a6436112013-10-09 02:49:5870#include "chrome/browser/chromeos/policy/device_local_account.h"
antrim58769562016-11-14 14:48:4171#include "chrome/browser/chromeos/profiles/profile_helper.h"
[email protected]931d1042013-04-05 17:50:4472#include "chromeos/chromeos_switches.h"
[email protected]c57397a2013-04-18 19:41:1173#include "chromeos/login/login_state.h"
[email protected]2fda9972014-07-23 14:51:5974#include "components/user_manager/user.h"
[email protected]4d390782014-08-15 09:22:5875#include "components/user_manager/user_manager.h"
[email protected]bb121482012-12-08 06:49:3876#endif
77
[email protected]31d8f5f22012-04-02 15:22:0878using content::BrowserThread;
79
[email protected]bd306722012-07-11 20:43:5980namespace extensions {
81
asargent8380bd392016-03-21 23:47:3382namespace {
83
84// Helper to serve as an UninstallPingSender::Filter callback.
85UninstallPingSender::FilterResult ShouldSendUninstallPing(
86 const Extension* extension,
87 UninstallReason reason) {
88 if (extension && (extension->from_webstore() ||
89 ManifestURL::UpdatesFromGallery(extension))) {
90 return UninstallPingSender::SEND_PING;
91 }
92 return UninstallPingSender::DO_NOT_SEND_PING;
93}
94
95} // namespace
96
[email protected]31d8f5f22012-04-02 15:22:0897//
[email protected]31d8f5f22012-04-02 15:22:0898// ExtensionSystemImpl::Shared
99//
100
101ExtensionSystemImpl::Shared::Shared(Profile* profile)
102 : profile_(profile) {
103}
104
105ExtensionSystemImpl::Shared::~Shared() {
106}
107
108void ExtensionSystemImpl::Shared::InitPrefs() {
cmumford6ae8d462016-03-24 20:35:27109 store_factory_ = new ValueStoreFactoryImpl(profile_->GetPath());
110
[email protected]a690e292012-12-19 19:22:49111 // Two state stores. The latter, which contains declarative rules, must be
112 // loaded immediately so that the rules are ready before we issue network
113 // requests.
[email protected]bd306722012-07-11 20:43:59114 state_store_.reset(new StateStore(
cmumford6ae8d462016-03-24 20:35:27115 profile_, store_factory_, ValueStoreFrontend::BackendType::STATE, true));
[email protected]479e3922014-07-30 07:12:57116 state_store_notification_observer_.reset(
117 new StateStoreNotificationObserver(state_store_.get()));
[email protected]d3bd6072013-07-26 18:32:14118
[email protected]a690e292012-12-19 19:22:49119 rules_store_.reset(new StateStore(
cmumford6ae8d462016-03-24 20:35:27120 profile_, store_factory_, ValueStoreFrontend::BackendType::RULES, false));
[email protected]cb610dc2012-08-31 17:16:56121
[email protected]13e062e2014-08-09 10:21:55122#if defined(OS_CHROMEOS)
antrim58769562016-11-14 14:48:41123 // We can not perform check for Signin Profile here, as it would result in
124 // recursive call upon creation of Signin Profile, so we will create
125 // SigninScreenPolicyProvider lazily in RegisterManagementPolicyProviders.
126
[email protected]2fda9972014-07-23 14:51:59127 const user_manager::User* user =
[email protected]4d390782014-08-15 09:22:58128 user_manager::UserManager::Get()->GetActiveUser();
[email protected]1a6436112013-10-09 02:49:58129 policy::DeviceLocalAccount::Type device_local_account_type;
alemate909aa58a2016-11-03 22:49:07130 if (user &&
131 policy::IsDeviceLocalAccountUser(user->GetAccountId().GetUserEmail(),
132 &device_local_account_type)) {
[email protected]1a6436112013-10-09 02:49:58133 device_local_account_management_policy_provider_.reset(
134 new chromeos::DeviceLocalAccountManagementPolicyProvider(
135 device_local_account_type));
136 }
antrim58769562016-11-14 14:48:41137#endif
[email protected]31d8f5f22012-04-02 15:22:08138}
139
[email protected]65187152012-06-02 13:14:14140void ExtensionSystemImpl::Shared::RegisterManagementPolicyProviders() {
binjine6b58b52014-10-31 01:55:57141 management_policy_->RegisterProviders(
binjin1569c9b2014-09-05 13:33:18142 ExtensionManagementFactory::GetForBrowserContext(profile_)
binjine6b58b52014-10-31 01:55:57143 ->GetProviders());
[email protected]1a6436112013-10-09 02:49:58144
[email protected]13e062e2014-08-09 10:21:55145#if defined(OS_CHROMEOS)
antrim58769562016-11-14 14:48:41146 // Lazy creation of SigninScreenPolicyProvider.
147 if (!signin_screen_policy_provider_) {
148 if (chromeos::ProfileHelper::IsSigninProfile(profile_)) {
149 signin_screen_policy_provider_.reset(
150 new chromeos::SigninScreenPolicyProvider());
151 }
152 }
153
[email protected]1a6436112013-10-09 02:49:58154 if (device_local_account_management_policy_provider_) {
155 management_policy_->RegisterProvider(
156 device_local_account_management_policy_provider_.get());
157 }
antrim58769562016-11-14 14:48:41158 if (signin_screen_policy_provider_)
159 management_policy_->RegisterProvider(signin_screen_policy_provider_.get());
[email protected]13e062e2014-08-09 10:21:55160#endif // defined(OS_CHROMEOS)
[email protected]1a6436112013-10-09 02:49:58161
juncai33e462102015-05-18 20:48:44162 management_policy_->RegisterProvider(InstallVerifier::Get(profile_));
[email protected]65187152012-06-02 13:14:14163}
164
xiyuanf6a4c6a62016-04-19 18:14:54165void ExtensionSystemImpl::Shared::InitInstallGates() {
166 update_install_gate_.reset(new UpdateInstallGate(extension_service_.get()));
167 extension_service_->RegisterInstallGate(
168 ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, update_install_gate_.get());
169 extension_service_->RegisterInstallGate(
170 ExtensionPrefs::DELAY_REASON_GC,
171 ExtensionGarbageCollector::Get(profile_));
172 extension_service_->RegisterInstallGate(
173 ExtensionPrefs::DELAY_REASON_WAIT_FOR_IMPORTS,
174 extension_service_->shared_module_service());
xiyuana0a6aaaa2016-04-19 23:34:16175#if defined(OS_CHROMEOS)
176 if (chrome::IsRunningInForcedAppMode()) {
177 kiosk_app_update_install_gate_.reset(
178 new chromeos::KioskAppUpdateInstallGate(profile_));
179 extension_service_->RegisterInstallGate(
180 ExtensionPrefs::DELAY_REASON_WAIT_FOR_OS_UPDATE,
181 kiosk_app_update_install_gate_.get());
182 }
183#endif
xiyuanf6a4c6a62016-04-19 18:14:54184}
185
[email protected]31d8f5f22012-04-02 15:22:08186void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) {
rkaplowe65c2ff2015-02-14 16:29:54187 TRACE_EVENT0("browser,startup", "ExtensionSystemImpl::Shared::Init");
avi3ef9ec9e2014-12-22 22:50:17188 const base::CommandLine* command_line =
189 base::CommandLine::ForCurrentProcess();
[email protected]31d8f5f22012-04-02 15:22:08190
[email protected]d9ede582012-08-14 19:21:38191 navigation_observer_.reset(new NavigationObserver(profile_));
[email protected]31d8f5f22012-04-02 15:22:08192
[email protected]53603d22012-11-14 08:31:11193 bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs);
194 ExtensionErrorReporter::Init(allow_noisy_errors);
[email protected]31d8f5f22012-04-02 15:22:08195
asargent678123d22015-07-31 23:24:10196 content_verifier_ = new ContentVerifier(
197 profile_, new ChromeContentVerifierDelegate(profile_));
198
rdevlin.croninf5863da2015-09-10 19:21:45199 service_worker_manager_.reset(new ServiceWorkerManager(profile_));
200
[email protected]15ad2ee2014-08-15 19:15:26201 shared_user_script_master_.reset(new SharedUserScriptMaster(profile_));
[email protected]31d8f5f22012-04-02 15:22:08202
[email protected]45f5b7d2014-01-22 23:47:13203 // ExtensionService depends on RuntimeData.
204 runtime_data_.reset(new RuntimeData(ExtensionRegistry::Get(profile_)));
205
mlerman7831f57d2015-05-25 11:40:15206 bool autoupdate_enabled = !profile_->IsGuestSession() &&
207 !profile_->IsSystemProfile();
[email protected]31d8f5f22012-04-02 15:22:08208#if defined(OS_CHROMEOS)
209 if (!extensions_enabled)
210 autoupdate_enabled = false;
rkaplowdd66a1342015-03-05 00:31:49211#endif // defined(OS_CHROMEOS)
[email protected]31d8f5f22012-04-02 15:22:08212 extension_service_.reset(new ExtensionService(
avi3ef9ec9e2014-12-22 22:50:17213 profile_, base::CommandLine::ForCurrentProcess(),
[email protected]836e2982013-05-16 08:07:42214 profile_->GetPath().AppendASCII(extensions::kInstallDirectoryName),
avi3ef9ec9e2014-12-22 22:50:17215 ExtensionPrefs::Get(profile_), Blacklist::Get(profile_),
216 autoupdate_enabled, extensions_enabled, &ready_));
[email protected]31d8f5f22012-04-02 15:22:08217
asargent8380bd392016-03-21 23:47:33218 uninstall_ping_sender_.reset(new UninstallPingSender(
219 ExtensionRegistry::Get(profile_), base::Bind(&ShouldSendUninstallPing)));
220
[email protected]d7fbc092012-06-18 22:52:00221 // These services must be registered before the ExtensionService tries to
222 // load any extensions.
223 {
juncai33e462102015-05-18 20:48:44224 InstallVerifier::Get(profile_)->Init();
[email protected]8bb62162014-06-23 09:45:50225 ContentVerifierDelegate::Mode mode =
juncaie950b9e552015-06-11 20:25:31226 ChromeContentVerifierDelegate::GetDefaultMode();
[email protected]8bb62162014-06-23 09:45:50227#if defined(OS_CHROMEOS)
228 mode = std::max(mode, ContentVerifierDelegate::BOOTSTRAP);
rkaplowdd66a1342015-03-05 00:31:49229#endif // defined(OS_CHROMEOS)
[email protected]6a5898e2014-07-22 23:33:54230 if (mode >= ContentVerifierDelegate::BOOTSTRAP)
[email protected]8bb62162014-06-23 09:45:50231 content_verifier_->Start();
[email protected]fd3df7782014-05-08 23:54:27232 info_map()->SetContentVerifier(content_verifier_.get());
[email protected]ffd2f79e2013-11-14 00:11:46233
[email protected]bd306722012-07-11 20:43:59234 management_policy_.reset(new ManagementPolicy);
[email protected]d7fbc092012-06-18 22:52:00235 RegisterManagementPolicyProviders();
236 }
[email protected]65187152012-06-02 13:14:14237
[email protected]bb121482012-12-08 06:49:38238 bool skip_session_extensions = false;
239#if defined(OS_CHROMEOS)
240 // Skip loading session extensions if we are not in a user session.
[email protected]c57397a2013-04-18 19:41:11241 skip_session_extensions = !chromeos::LoginState::Get()->IsUserLoggedIn();
[email protected]531593d2014-01-08 18:48:31242 if (chrome::IsRunningInForcedAppMode()) {
243 extension_service_->component_loader()->
244 AddDefaultComponentExtensionsForKioskMode(skip_session_extensions);
245 } else {
[email protected]6ed2e0c2013-04-09 04:48:13246 extension_service_->component_loader()->AddDefaultComponentExtensions(
247 skip_session_extensions);
248 }
249#else
[email protected]bb121482012-12-08 06:49:38250 extension_service_->component_loader()->AddDefaultComponentExtensions(
251 skip_session_extensions);
[email protected]6ed2e0c2013-04-09 04:48:13252#endif
[email protected]31d8f5f22012-04-02 15:22:08253 if (command_line->HasSwitch(switches::kLoadComponentExtension)) {
avi3ef9ec9e2014-12-22 22:50:17254 base::CommandLine::StringType path_list =
255 command_line->GetSwitchValueNative(switches::kLoadComponentExtension);
256 base::StringTokenizerT<base::CommandLine::StringType,
257 base::CommandLine::StringType::const_iterator>
258 t(path_list, FILE_PATH_LITERAL(","));
[email protected]31d8f5f22012-04-02 15:22:08259 while (t.GetNext()) {
260 // Load the component extension manifest synchronously.
261 // Blocking the UI thread is acceptable here since
262 // this flag designated for developers.
263 base::ThreadRestrictions::ScopedAllowIO allow_io;
264 extension_service_->component_loader()->AddOrReplace(
[email protected]650b2d52013-02-10 03:41:45265 base::FilePath(t.token()));
[email protected]31d8f5f22012-04-02 15:22:08266 }
267 }
treib926ee2d2015-08-06 10:55:42268
269 app_sorting_.reset(new ChromeAppSorting(profile_));
270
xiyuanf6a4c6a62016-04-19 18:14:54271 InitInstallGates();
272
[email protected]31d8f5f22012-04-02 15:22:08273 extension_service_->Init();
274
treib8a6d9892015-08-26 10:23:19275 // Make sure ExtensionSyncService is created.
276 ExtensionSyncService::Get(profile_);
277
[email protected]c1909afb2013-11-13 21:12:51278 // Make the chrome://extension-icon/ resource available.
279 content::URLDataSource::Add(profile_, new ExtensionIconSource(profile_));
280
[email protected]aab23102014-02-05 18:57:55281 quota_service_.reset(new QuotaService);
[email protected]31d8f5f22012-04-02 15:22:08282}
283
[email protected]47b896562012-08-22 23:55:15284void ExtensionSystemImpl::Shared::Shutdown() {
dchengc7047942014-08-26 05:05:31285 if (content_verifier_.get())
[email protected]fd3df7782014-05-08 23:54:27286 content_verifier_->Shutdown();
[email protected]3eeddd892013-04-17 17:00:11287 if (extension_service_)
[email protected]47b896562012-08-22 23:55:15288 extension_service_->Shutdown();
289}
290
rdevlin.croninf5863da2015-09-10 19:21:45291ServiceWorkerManager* ExtensionSystemImpl::Shared::service_worker_manager() {
292 return service_worker_manager_.get();
293}
294
[email protected]bd306722012-07-11 20:43:59295StateStore* ExtensionSystemImpl::Shared::state_store() {
[email protected]90e800c2012-06-12 23:11:00296 return state_store_.get();
297}
298
[email protected]a690e292012-12-19 19:22:49299StateStore* ExtensionSystemImpl::Shared::rules_store() {
300 return rules_store_.get();
301}
302
cmumford6ae8d462016-03-24 20:35:27303scoped_refptr<ValueStoreFactory> ExtensionSystemImpl::Shared::store_factory()
304 const {
305 return store_factory_;
306}
307
[email protected]31d8f5f22012-04-02 15:22:08308ExtensionService* ExtensionSystemImpl::Shared::extension_service() {
309 return extension_service_.get();
310}
311
[email protected]45f5b7d2014-01-22 23:47:13312RuntimeData* ExtensionSystemImpl::Shared::runtime_data() {
313 return runtime_data_.get();
314}
315
[email protected]bd306722012-07-11 20:43:59316ManagementPolicy* ExtensionSystemImpl::Shared::management_policy() {
[email protected]65187152012-06-02 13:14:14317 return management_policy_.get();
318}
319
[email protected]15ad2ee2014-08-15 19:15:26320SharedUserScriptMaster*
321ExtensionSystemImpl::Shared::shared_user_script_master() {
322 return shared_user_script_master_.get();
[email protected]31d8f5f22012-04-02 15:22:08323}
324
[email protected]38427a12013-11-09 17:34:20325InfoMap* ExtensionSystemImpl::Shared::info_map() {
[email protected]dc24976f2013-06-02 21:15:09326 if (!extension_info_map_.get())
[email protected]38427a12013-11-09 17:34:20327 extension_info_map_ = new InfoMap();
[email protected]31d8f5f22012-04-02 15:22:08328 return extension_info_map_.get();
329}
330
[email protected]aab23102014-02-05 18:57:55331QuotaService* ExtensionSystemImpl::Shared::quota_service() {
332 return quota_service_.get();
333}
334
treib926ee2d2015-08-06 10:55:42335AppSorting* ExtensionSystemImpl::Shared::app_sorting() {
336 return app_sorting_.get();
337}
338
[email protected]fd3df7782014-05-08 23:54:27339ContentVerifier* ExtensionSystemImpl::Shared::content_verifier() {
340 return content_verifier_.get();
341}
342
[email protected]31d8f5f22012-04-02 15:22:08343//
344// ExtensionSystemImpl
345//
346
347ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile)
[email protected]98b673032012-12-11 10:26:02348 : profile_(profile) {
[email protected]59b0e602014-01-30 00:41:24349 shared_ = ExtensionSystemSharedFactory::GetForBrowserContext(profile);
[email protected]31d8f5f22012-04-02 15:22:08350
reillyg0ea3fa902014-10-28 15:30:23351 if (!profile->IsOffTheRecord()) {
[email protected]31d8f5f22012-04-02 15:22:08352 shared_->InitPrefs();
353 }
354}
355
356ExtensionSystemImpl::~ExtensionSystemImpl() {
357}
358
359void ExtensionSystemImpl::Shutdown() {
[email protected]31d8f5f22012-04-02 15:22:08360}
361
[email protected]7cf1ee42013-12-11 09:13:49362void ExtensionSystemImpl::InitForRegularProfile(bool extensions_enabled) {
rkaplowe65c2ff2015-02-14 16:29:54363 TRACE_EVENT0("browser,startup", "ExtensionSystemImpl::InitForRegularProfile");
[email protected]31d8f5f22012-04-02 15:22:08364 DCHECK(!profile_->IsOffTheRecord());
[email protected]15ad2ee2014-08-15 19:15:26365 if (shared_user_script_master() || extension_service())
[email protected]31d8f5f22012-04-02 15:22:08366 return; // Already initialized.
367
[email protected]98b6d942013-11-10 00:34:07368 // The InfoMap needs to be created before the ProcessManager.
[email protected]9656bc52012-08-13 17:05:33369 shared_->info_map();
[email protected]31d8f5f22012-04-02 15:22:08370 shared_->Init(extensions_enabled);
371}
372
373ExtensionService* ExtensionSystemImpl::extension_service() {
374 return shared_->extension_service();
375}
376
[email protected]45f5b7d2014-01-22 23:47:13377RuntimeData* ExtensionSystemImpl::runtime_data() {
378 return shared_->runtime_data();
379}
380
[email protected]bd306722012-07-11 20:43:59381ManagementPolicy* ExtensionSystemImpl::management_policy() {
[email protected]65187152012-06-02 13:14:14382 return shared_->management_policy();
383}
384
rdevlin.croninf5863da2015-09-10 19:21:45385ServiceWorkerManager* ExtensionSystemImpl::service_worker_manager() {
386 return shared_->service_worker_manager();
387}
388
[email protected]15ad2ee2014-08-15 19:15:26389SharedUserScriptMaster* ExtensionSystemImpl::shared_user_script_master() {
390 return shared_->shared_user_script_master();
[email protected]31d8f5f22012-04-02 15:22:08391}
392
[email protected]bd306722012-07-11 20:43:59393StateStore* ExtensionSystemImpl::state_store() {
[email protected]90e800c2012-06-12 23:11:00394 return shared_->state_store();
395}
396
[email protected]a690e292012-12-19 19:22:49397StateStore* ExtensionSystemImpl::rules_store() {
398 return shared_->rules_store();
399}
400
cmumford6ae8d462016-03-24 20:35:27401scoped_refptr<ValueStoreFactory> ExtensionSystemImpl::store_factory() {
402 return shared_->store_factory();
403}
404
[email protected]38427a12013-11-09 17:34:20405InfoMap* ExtensionSystemImpl::info_map() { return shared_->info_map(); }
[email protected]31d8f5f22012-04-02 15:22:08406
[email protected]4a10006a2013-05-17 23:18:35407const OneShotEvent& ExtensionSystemImpl::ready() const {
408 return shared_->ready();
409}
410
[email protected]aab23102014-02-05 18:57:55411QuotaService* ExtensionSystemImpl::quota_service() {
412 return shared_->quota_service();
413}
414
treib926ee2d2015-08-06 10:55:42415AppSorting* ExtensionSystemImpl::app_sorting() {
416 return shared_->app_sorting();
417}
418
[email protected]fd3df7782014-05-08 23:54:27419ContentVerifier* ExtensionSystemImpl::content_verifier() {
420 return shared_->content_verifier();
421}
422
dchengc963c7142016-04-08 03:55:22423std::unique_ptr<ExtensionSet> ExtensionSystemImpl::GetDependentExtensions(
[email protected]f698c162014-06-13 00:46:26424 const Extension* extension) {
425 return extension_service()->shared_module_service()->GetDependentExtensions(
426 extension);
427}
428
asargent631a99a2015-10-15 21:51:48429void ExtensionSystemImpl::InstallUpdate(const std::string& extension_id,
430 const base::FilePath& temp_dir) {
431 NOTREACHED() << "Not yet implemented";
432 base::DeleteFile(temp_dir, true /* recursive */);
433}
434
[email protected]31d8f5f22012-04-02 15:22:08435void ExtensionSystemImpl::RegisterExtensionWithRequestContexts(
rockot494f0072015-07-29 17:58:07436 const Extension* extension,
437 const base::Closure& callback) {
[email protected]31d8f5f22012-04-02 15:22:08438 base::Time install_time;
[email protected]1d5e58b2013-01-31 08:41:40439 if (extension->location() != Manifest::COMPONENT) {
[email protected]836e2982013-05-16 08:07:42440 install_time = ExtensionPrefs::Get(profile_)->
[email protected]31d8f5f22012-04-02 15:22:08441 GetInstallTime(extension->id());
442 }
[email protected]1d5cf4142014-01-24 18:25:22443 bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_);
[email protected]9afacd22013-11-13 20:23:31444
445 bool notifications_disabled = false;
446#if defined(ENABLE_NOTIFICATIONS)
447 message_center::NotifierId notifier_id(
448 message_center::NotifierId::APPLICATION,
449 extension->id());
450
peterc4007912015-07-31 21:13:37451 NotifierStateTracker* notifier_state_tracker =
452 NotifierStateTrackerFactory::GetForProfile(profile_);
[email protected]9afacd22013-11-13 20:23:31453 notifications_disabled =
peterc4007912015-07-31 21:13:37454 !notifier_state_tracker->IsNotifierEnabled(notifier_id);
[email protected]9afacd22013-11-13 20:23:31455#endif
456
rockot494f0072015-07-29 17:58:07457 BrowserThread::PostTaskAndReply(
[email protected]9afacd22013-11-13 20:23:31458 BrowserThread::IO, FROM_HERE,
459 base::Bind(&InfoMap::AddExtension, info_map(),
vmpstra34d11322016-03-21 20:28:47460 base::RetainedRef(extension), install_time, incognito_enabled,
rockot494f0072015-07-29 17:58:07461 notifications_disabled),
462 callback);
[email protected]31d8f5f22012-04-02 15:22:08463}
464
465void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts(
466 const std::string& extension_id,
[email protected]b0af4792013-10-23 09:12:13467 const UnloadedExtensionInfo::Reason reason) {
[email protected]31d8f5f22012-04-02 15:22:08468 BrowserThread::PostTask(
[email protected]38427a12013-11-09 17:34:20469 BrowserThread::IO,
470 FROM_HERE,
471 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason));
[email protected]31d8f5f22012-04-02 15:22:08472}
[email protected]bd306722012-07-11 20:43:59473
474} // namespace extensions