blob: 33565b29ffa5174c3e234f780b6ff36c12700ddc [file] [log] [blame]
[email protected]31d8f5f22012-04-02 15:22:081// Copyright (c) 2012 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/extensions/extension_system.h"
6
[email protected]53603d22012-11-14 08:31:117#include "base/base_switches.h"
[email protected]31d8f5f22012-04-02 15:22:088#include "base/bind.h"
9#include "base/command_line.h"
[email protected]57999812013-02-24 05:40:5210#include "base/files/file_path.h"
[email protected]f4ebe772013-02-02 00:21:3911#include "base/strings/string_tokenizer.h"
[email protected]31d8f5f22012-04-02 15:22:0812#include "chrome/browser/browser_process.h"
[email protected]31d8f5f22012-04-02 15:22:0813#include "chrome/browser/content_settings/cookie_settings.h"
[email protected]fdd679b2012-11-15 20:49:3914#include "chrome/browser/extensions/blacklist.h"
[email protected]931186e02012-07-20 01:22:0615#include "chrome/browser/extensions/component_loader.h"
[email protected]1b66fdb2013-07-26 09:57:2816#include "chrome/browser/extensions/error_console/error_console.h"
[email protected]31d8f5f22012-04-02 15:22:0817#include "chrome/browser/extensions/extension_error_reporter.h"
[email protected]31d8f5f22012-04-02 15:22:0818#include "chrome/browser/extensions/extension_service.h"
19#include "chrome/browser/extensions/extension_system_factory.h"
[email protected]a7ff4b72013-10-17 20:56:0220#include "chrome/browser/extensions/extension_util.h"
[email protected]b4d3771d2012-11-14 14:44:1021#include "chrome/browser/extensions/extension_warning_badge_service.h"
22#include "chrome/browser/extensions/extension_warning_set.h"
[email protected]ffd2f79e2013-11-14 00:11:4623#include "chrome/browser/extensions/install_verifier.h"
[email protected]d9ede582012-08-14 19:21:3824#include "chrome/browser/extensions/navigation_observer.h"
[email protected]fdd679b2012-11-15 20:49:3925#include "chrome/browser/extensions/standard_management_policy_provider.h"
[email protected]90e800c2012-06-12 23:11:0026#include "chrome/browser/extensions/state_store.h"
[email protected]31d8f5f22012-04-02 15:22:0827#include "chrome/browser/extensions/unpacked_installer.h"
28#include "chrome/browser/extensions/user_script_master.h"
29#include "chrome/browser/profiles/profile.h"
30#include "chrome/browser/profiles/profile_manager.h"
[email protected]31d8f5f22012-04-02 15:22:0831#include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
32#include "chrome/common/chrome_switches.h"
[email protected]d69d7b172012-08-09 04:17:2633#include "chrome/common/chrome_version_info.h"
[email protected]15d4d2d2013-08-09 06:49:0334#include "chrome/common/extensions/features/feature_channel.h"
[email protected]31d8f5f22012-04-02 15:22:0835#include "content/public/browser/browser_thread.h"
[email protected]24ea7a12013-01-27 23:54:5336#include "content/public/browser/url_data_source.h"
[email protected]34423532013-11-21 18:13:1037#include "extensions/browser/event_router.h"
[email protected]489db0842014-01-22 18:20:0338#include "extensions/browser/extension_pref_store.h"
39#include "extensions/browser/extension_pref_value_map.h"
40#include "extensions/browser/extension_pref_value_map_factory.h"
41#include "extensions/browser/extension_prefs.h"
[email protected]38427a12013-11-09 17:34:2042#include "extensions/browser/info_map.h"
[email protected]9fe42042013-10-29 21:13:3343#include "extensions/browser/lazy_background_task_queue.h"
[email protected]301116c62013-11-26 10:37:4544#include "extensions/browser/management_policy.h"
[email protected]98b6d942013-11-10 00:34:0745#include "extensions/browser/process_manager.h"
[email protected]836e2982013-05-16 08:07:4246#include "extensions/common/constants.h"
[email protected]e4452d32013-11-15 23:07:4147#include "extensions/common/extension.h"
[email protected]d42c11152013-08-22 19:36:3248#include "extensions/common/manifest.h"
[email protected]31d8f5f22012-04-02 15:22:0849
[email protected]9afacd22013-11-13 20:23:3150#if defined(ENABLE_NOTIFICATIONS)
51#include "chrome/browser/notifications/desktop_notification_service.h"
52#include "chrome/browser/notifications/desktop_notification_service_factory.h"
53#include "ui/message_center/notifier_settings.h"
54#endif
55
[email protected]bb121482012-12-08 06:49:3856#if defined(OS_CHROMEOS)
[email protected]6ed2e0c2013-04-09 04:48:1357#include "chrome/browser/app_mode/app_mode_utils.h"
[email protected]1a6436112013-10-09 02:49:5858#include "chrome/browser/chromeos/extensions/device_local_account_management_policy_provider.h"
59#include "chrome/browser/chromeos/login/user.h"
60#include "chrome/browser/chromeos/login/user_manager.h"
61#include "chrome/browser/chromeos/policy/device_local_account.h"
[email protected]931d1042013-04-05 17:50:4462#include "chromeos/chromeos_switches.h"
[email protected]c57397a2013-04-18 19:41:1163#include "chromeos/login/login_state.h"
[email protected]bb121482012-12-08 06:49:3864#endif
65
[email protected]31d8f5f22012-04-02 15:22:0866using content::BrowserThread;
67
[email protected]bd306722012-07-11 20:43:5968namespace extensions {
69
[email protected]31d8f5f22012-04-02 15:22:0870//
71// ExtensionSystem
72//
73
74ExtensionSystem::ExtensionSystem() {
[email protected]d57a089c2012-08-16 00:26:4375 // Only set if it hasn't already been set (e.g. by a test).
[email protected]15d4d2d2013-08-09 06:49:0376 if (GetCurrentChannel() == GetDefaultChannel())
77 SetCurrentChannel(chrome::VersionInfo::GetChannel());
[email protected]31d8f5f22012-04-02 15:22:0878}
79
80ExtensionSystem::~ExtensionSystem() {
81}
82
[email protected]749d59a2012-04-05 00:23:2483// static
84ExtensionSystem* ExtensionSystem::Get(Profile* profile) {
85 return ExtensionSystemFactory::GetForProfile(profile);
86}
87
[email protected]9fe42042013-10-29 21:13:3388// static
89ExtensionSystem* ExtensionSystem::GetForBrowserContext(
90 content::BrowserContext* profile) {
91 return ExtensionSystemFactory::GetForProfile(static_cast<Profile*>(profile));
92}
93
[email protected]31d8f5f22012-04-02 15:22:0894//
95// ExtensionSystemImpl::Shared
96//
97
98ExtensionSystemImpl::Shared::Shared(Profile* profile)
99 : profile_(profile) {
100}
101
102ExtensionSystemImpl::Shared::~Shared() {
103}
104
105void ExtensionSystemImpl::Shared::InitPrefs() {
[email protected]c4dc5cc2012-11-09 08:48:39106 lazy_background_task_queue_.reset(new LazyBackgroundTaskQueue(profile_));
[email protected]836e2982013-05-16 08:07:42107 event_router_.reset(new EventRouter(profile_, ExtensionPrefs::Get(profile_)));
[email protected]d3bd6072013-07-26 18:32:14108// TODO(yoz): Remove once crbug.com/159265 is fixed.
109#if defined(ENABLE_EXTENSIONS)
[email protected]a690e292012-12-19 19:22:49110 // Two state stores. The latter, which contains declarative rules, must be
111 // loaded immediately so that the rules are ready before we issue network
112 // requests.
[email protected]bd306722012-07-11 20:43:59113 state_store_.reset(new StateStore(
[email protected]90e800c2012-06-12 23:11:00114 profile_,
[email protected]501105b2013-09-26 05:42:02115 profile_->GetPath().AppendASCII(extensions::kStateStoreName),
[email protected]a690e292012-12-19 19:22:49116 true));
[email protected]d3bd6072013-07-26 18:32:14117
[email protected]a690e292012-12-19 19:22:49118 rules_store_.reset(new StateStore(
119 profile_,
[email protected]501105b2013-09-26 05:42:02120 profile_->GetPath().AppendASCII(extensions::kRulesStoreName),
[email protected]a690e292012-12-19 19:22:49121 false));
[email protected]cb610dc2012-08-31 17:16:56122
[email protected]836e2982013-05-16 08:07:42123 blacklist_.reset(new Blacklist(ExtensionPrefs::Get(profile_)));
[email protected]fdd679b2012-11-15 20:49:39124
125 standard_management_policy_provider_.reset(
[email protected]836e2982013-05-16 08:07:42126 new StandardManagementPolicyProvider(ExtensionPrefs::Get(profile_)));
[email protected]1a6436112013-10-09 02:49:58127
128#if defined (OS_CHROMEOS)
129 const chromeos::User* user = chromeos::UserManager::Get()->GetActiveUser();
130 policy::DeviceLocalAccount::Type device_local_account_type;
131 if (user && policy::IsDeviceLocalAccountUser(user->email(),
132 &device_local_account_type)) {
133 device_local_account_management_policy_provider_.reset(
134 new chromeos::DeviceLocalAccountManagementPolicyProvider(
135 device_local_account_type));
136 }
137#endif // defined (OS_CHROMEOS)
138
139#endif // defined(ENABLE_EXTENSIONS)
[email protected]31d8f5f22012-04-02 15:22:08140}
141
[email protected]65187152012-06-02 13:14:14142void ExtensionSystemImpl::Shared::RegisterManagementPolicyProviders() {
[email protected]d3bd6072013-07-26 18:32:14143// TODO(yoz): Remove once crbug.com/159265 is fixed.
144#if defined(ENABLE_EXTENSIONS)
[email protected]fdd679b2012-11-15 20:49:39145 DCHECK(standard_management_policy_provider_.get());
146 management_policy_->RegisterProvider(
147 standard_management_policy_provider_.get());
[email protected]1a6436112013-10-09 02:49:58148
149#if defined (OS_CHROMEOS)
150 if (device_local_account_management_policy_provider_) {
151 management_policy_->RegisterProvider(
152 device_local_account_management_policy_provider_.get());
153 }
154#endif // defined (OS_CHROMEOS)
155
[email protected]ffd2f79e2013-11-14 00:11:46156 management_policy_->RegisterProvider(install_verifier_.get());
157
[email protected]1a6436112013-10-09 02:49:58158#endif // defined(ENABLE_EXTENSIONS)
[email protected]65187152012-06-02 13:14:14159}
160
[email protected]31d8f5f22012-04-02 15:22:08161void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) {
162 const CommandLine* command_line = CommandLine::ForCurrentProcess();
163
[email protected]d9ede582012-08-14 19:21:38164 navigation_observer_.reset(new NavigationObserver(profile_));
[email protected]31d8f5f22012-04-02 15:22:08165
[email protected]53603d22012-11-14 08:31:11166 bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs);
167 ExtensionErrorReporter::Init(allow_noisy_errors);
[email protected]31d8f5f22012-04-02 15:22:08168
169 user_script_master_ = new UserScriptMaster(profile_);
170
171 bool autoupdate_enabled = true;
172#if defined(OS_CHROMEOS)
173 if (!extensions_enabled)
174 autoupdate_enabled = false;
175 else
[email protected]931d1042013-04-05 17:50:44176 autoupdate_enabled =
177 !command_line->HasSwitch(chromeos::switches::kGuestSession);
[email protected]31d8f5f22012-04-02 15:22:08178#endif
179 extension_service_.reset(new ExtensionService(
180 profile_,
181 CommandLine::ForCurrentProcess(),
[email protected]836e2982013-05-16 08:07:42182 profile_->GetPath().AppendASCII(extensions::kInstallDirectoryName),
183 ExtensionPrefs::Get(profile_),
[email protected]fdd679b2012-11-15 20:49:39184 blacklist_.get(),
[email protected]31d8f5f22012-04-02 15:22:08185 autoupdate_enabled,
[email protected]4a10006a2013-05-17 23:18:35186 extensions_enabled,
187 &ready_));
[email protected]31d8f5f22012-04-02 15:22:08188
[email protected]d7fbc092012-06-18 22:52:00189 // These services must be registered before the ExtensionService tries to
190 // load any extensions.
191 {
[email protected]ffd2f79e2013-11-14 00:11:46192 install_verifier_.reset(new InstallVerifier(ExtensionPrefs::Get(profile_),
193 profile_->GetRequestContext()));
194 install_verifier_->Init();
195
[email protected]bd306722012-07-11 20:43:59196 management_policy_.reset(new ManagementPolicy);
[email protected]d7fbc092012-06-18 22:52:00197 RegisterManagementPolicyProviders();
198 }
[email protected]65187152012-06-02 13:14:14199
[email protected]bb121482012-12-08 06:49:38200 bool skip_session_extensions = false;
201#if defined(OS_CHROMEOS)
202 // Skip loading session extensions if we are not in a user session.
[email protected]c57397a2013-04-18 19:41:11203 skip_session_extensions = !chromeos::LoginState::Get()->IsUserLoggedIn();
[email protected]531593d2014-01-08 18:48:31204 if (chrome::IsRunningInForcedAppMode()) {
205 extension_service_->component_loader()->
206 AddDefaultComponentExtensionsForKioskMode(skip_session_extensions);
207 } else {
[email protected]6ed2e0c2013-04-09 04:48:13208 extension_service_->component_loader()->AddDefaultComponentExtensions(
209 skip_session_extensions);
210 }
211#else
[email protected]bb121482012-12-08 06:49:38212 extension_service_->component_loader()->AddDefaultComponentExtensions(
213 skip_session_extensions);
[email protected]6ed2e0c2013-04-09 04:48:13214#endif
[email protected]31d8f5f22012-04-02 15:22:08215 if (command_line->HasSwitch(switches::kLoadComponentExtension)) {
216 CommandLine::StringType path_list = command_line->GetSwitchValueNative(
217 switches::kLoadComponentExtension);
[email protected]f4ebe772013-02-02 00:21:39218 base::StringTokenizerT<CommandLine::StringType,
[email protected]31d8f5f22012-04-02 15:22:08219 CommandLine::StringType::const_iterator> t(path_list,
220 FILE_PATH_LITERAL(","));
221 while (t.GetNext()) {
222 // Load the component extension manifest synchronously.
223 // Blocking the UI thread is acceptable here since
224 // this flag designated for developers.
225 base::ThreadRestrictions::ScopedAllowIO allow_io;
226 extension_service_->component_loader()->AddOrReplace(
[email protected]650b2d52013-02-10 03:41:45227 base::FilePath(t.token()));
[email protected]31d8f5f22012-04-02 15:22:08228 }
229 }
230 extension_service_->Init();
231
[email protected]c1909afb2013-11-13 21:12:51232 // Make the chrome://extension-icon/ resource available.
233 content::URLDataSource::Add(profile_, new ExtensionIconSource(profile_));
234
235 extension_warning_service_.reset(new ExtensionWarningService(profile_));
236 extension_warning_badge_service_.reset(
237 new ExtensionWarningBadgeService(profile_));
238 extension_warning_service_->AddObserver(
239 extension_warning_badge_service_.get());
240 error_console_.reset(new ErrorConsole(profile_, extension_service_.get()));
241
[email protected]31d8f5f22012-04-02 15:22:08242 if (extensions_enabled) {
243 // Load any extensions specified with --load-extension.
244 // TODO(yoz): Seems like this should move into ExtensionService::Init.
245 // But maybe it's no longer important.
246 if (command_line->HasSwitch(switches::kLoadExtension)) {
247 CommandLine::StringType path_list = command_line->GetSwitchValueNative(
248 switches::kLoadExtension);
[email protected]f4ebe772013-02-02 00:21:39249 base::StringTokenizerT<CommandLine::StringType,
[email protected]31d8f5f22012-04-02 15:22:08250 CommandLine::StringType::const_iterator> t(path_list,
[email protected]dd6d36672013-05-17 22:50:02251 FILE_PATH_LITERAL(","));
[email protected]31d8f5f22012-04-02 15:22:08252 while (t.GetNext()) {
[email protected]2a69b942013-05-31 09:37:53253 std::string extension_id;
[email protected]98270432012-09-11 20:51:24254 UnpackedInstaller::Create(extension_service_.get())->
[email protected]2a69b942013-05-31 09:37:53255 LoadFromCommandLine(base::FilePath(t.token()), &extension_id);
[email protected]31d8f5f22012-04-02 15:22:08256 }
257 }
258 }
[email protected]31d8f5f22012-04-02 15:22:08259}
260
[email protected]47b896562012-08-22 23:55:15261void ExtensionSystemImpl::Shared::Shutdown() {
[email protected]3eeddd892013-04-17 17:00:11262 if (extension_warning_service_) {
[email protected]2def34cd2012-12-08 07:07:54263 extension_warning_service_->RemoveObserver(
264 extension_warning_badge_service_.get());
265 }
[email protected]3eeddd892013-04-17 17:00:11266 if (extension_service_)
[email protected]47b896562012-08-22 23:55:15267 extension_service_->Shutdown();
268}
269
[email protected]bd306722012-07-11 20:43:59270StateStore* ExtensionSystemImpl::Shared::state_store() {
[email protected]90e800c2012-06-12 23:11:00271 return state_store_.get();
272}
273
[email protected]a690e292012-12-19 19:22:49274StateStore* ExtensionSystemImpl::Shared::rules_store() {
275 return rules_store_.get();
276}
277
[email protected]31d8f5f22012-04-02 15:22:08278ExtensionService* ExtensionSystemImpl::Shared::extension_service() {
279 return extension_service_.get();
280}
281
[email protected]bd306722012-07-11 20:43:59282ManagementPolicy* ExtensionSystemImpl::Shared::management_policy() {
[email protected]65187152012-06-02 13:14:14283 return management_policy_.get();
284}
285
[email protected]31d8f5f22012-04-02 15:22:08286UserScriptMaster* ExtensionSystemImpl::Shared::user_script_master() {
287 return user_script_master_.get();
288}
289
[email protected]38427a12013-11-09 17:34:20290InfoMap* ExtensionSystemImpl::Shared::info_map() {
[email protected]dc24976f2013-06-02 21:15:09291 if (!extension_info_map_.get())
[email protected]38427a12013-11-09 17:34:20292 extension_info_map_ = new InfoMap();
[email protected]31d8f5f22012-04-02 15:22:08293 return extension_info_map_.get();
294}
295
[email protected]bd306722012-07-11 20:43:59296LazyBackgroundTaskQueue*
297 ExtensionSystemImpl::Shared::lazy_background_task_queue() {
[email protected]31d8f5f22012-04-02 15:22:08298 return lazy_background_task_queue_.get();
299}
300
[email protected]5a38dfd2012-07-23 23:22:10301EventRouter* ExtensionSystemImpl::Shared::event_router() {
[email protected]c4dc5cc2012-11-09 08:48:39302 return event_router_.get();
[email protected]31d8f5f22012-04-02 15:22:08303}
304
[email protected]2def34cd2012-12-08 07:07:54305ExtensionWarningService* ExtensionSystemImpl::Shared::warning_service() {
306 return extension_warning_service_.get();
307}
308
[email protected]fdd679b2012-11-15 20:49:39309Blacklist* ExtensionSystemImpl::Shared::blacklist() {
310 return blacklist_.get();
311}
312
[email protected]1b66fdb2013-07-26 09:57:28313ErrorConsole* ExtensionSystemImpl::Shared::error_console() {
314 return error_console_.get();
315}
316
[email protected]ffd2f79e2013-11-14 00:11:46317InstallVerifier* ExtensionSystemImpl::Shared::install_verifier() {
318 return install_verifier_.get();
319}
320
[email protected]31d8f5f22012-04-02 15:22:08321//
322// ExtensionSystemImpl
323//
324
325ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile)
[email protected]98b673032012-12-11 10:26:02326 : profile_(profile) {
[email protected]31d8f5f22012-04-02 15:22:08327 shared_ = ExtensionSystemSharedFactory::GetForProfile(profile);
328
329 if (profile->IsOffTheRecord()) {
[email protected]98b6d942013-11-10 00:34:07330 process_manager_.reset(ProcessManager::Create(profile));
[email protected]31d8f5f22012-04-02 15:22:08331 } else {
332 shared_->InitPrefs();
333 }
334}
335
336ExtensionSystemImpl::~ExtensionSystemImpl() {
337}
338
339void ExtensionSystemImpl::Shutdown() {
[email protected]98b6d942013-11-10 00:34:07340 process_manager_.reset();
[email protected]31d8f5f22012-04-02 15:22:08341}
342
[email protected]7cf1ee42013-12-11 09:13:49343void ExtensionSystemImpl::InitForRegularProfile(bool extensions_enabled) {
[email protected]31d8f5f22012-04-02 15:22:08344 DCHECK(!profile_->IsOffTheRecord());
345 if (user_script_master() || extension_service())
346 return; // Already initialized.
347
[email protected]98b6d942013-11-10 00:34:07348 // The InfoMap needs to be created before the ProcessManager.
[email protected]9656bc52012-08-13 17:05:33349 shared_->info_map();
[email protected]31d8f5f22012-04-02 15:22:08350
[email protected]98b6d942013-11-10 00:34:07351 process_manager_.reset(ProcessManager::Create(profile_));
[email protected]931186e02012-07-20 01:22:06352
[email protected]31d8f5f22012-04-02 15:22:08353 shared_->Init(extensions_enabled);
354}
355
356ExtensionService* ExtensionSystemImpl::extension_service() {
357 return shared_->extension_service();
358}
359
[email protected]bd306722012-07-11 20:43:59360ManagementPolicy* ExtensionSystemImpl::management_policy() {
[email protected]65187152012-06-02 13:14:14361 return shared_->management_policy();
362}
363
[email protected]31d8f5f22012-04-02 15:22:08364UserScriptMaster* ExtensionSystemImpl::user_script_master() {
365 return shared_->user_script_master();
366}
367
[email protected]98b6d942013-11-10 00:34:07368ProcessManager* ExtensionSystemImpl::process_manager() {
369 return process_manager_.get();
[email protected]31d8f5f22012-04-02 15:22:08370}
371
[email protected]bd306722012-07-11 20:43:59372StateStore* ExtensionSystemImpl::state_store() {
[email protected]90e800c2012-06-12 23:11:00373 return shared_->state_store();
374}
375
[email protected]a690e292012-12-19 19:22:49376StateStore* ExtensionSystemImpl::rules_store() {
377 return shared_->rules_store();
378}
379
[email protected]38427a12013-11-09 17:34:20380InfoMap* ExtensionSystemImpl::info_map() { return shared_->info_map(); }
[email protected]31d8f5f22012-04-02 15:22:08381
[email protected]bd306722012-07-11 20:43:59382LazyBackgroundTaskQueue* ExtensionSystemImpl::lazy_background_task_queue() {
[email protected]31d8f5f22012-04-02 15:22:08383 return shared_->lazy_background_task_queue();
384}
385
[email protected]5a38dfd2012-07-23 23:22:10386EventRouter* ExtensionSystemImpl::event_router() {
[email protected]31d8f5f22012-04-02 15:22:08387 return shared_->event_router();
388}
389
[email protected]b4d3771d2012-11-14 14:44:10390ExtensionWarningService* ExtensionSystemImpl::warning_service() {
[email protected]2def34cd2012-12-08 07:07:54391 return shared_->warning_service();
[email protected]b4d3771d2012-11-14 14:44:10392}
393
[email protected]fdd679b2012-11-15 20:49:39394Blacklist* ExtensionSystemImpl::blacklist() {
395 return shared_->blacklist();
396}
397
[email protected]4a10006a2013-05-17 23:18:35398const OneShotEvent& ExtensionSystemImpl::ready() const {
399 return shared_->ready();
400}
401
[email protected]1b66fdb2013-07-26 09:57:28402ErrorConsole* ExtensionSystemImpl::error_console() {
403 return shared_->error_console();
404}
405
[email protected]ffd2f79e2013-11-14 00:11:46406InstallVerifier* ExtensionSystemImpl::install_verifier() {
407 return shared_->install_verifier();
408}
409
[email protected]31d8f5f22012-04-02 15:22:08410void ExtensionSystemImpl::RegisterExtensionWithRequestContexts(
[email protected]bd306722012-07-11 20:43:59411 const Extension* extension) {
[email protected]31d8f5f22012-04-02 15:22:08412 base::Time install_time;
[email protected]1d5e58b2013-01-31 08:41:40413 if (extension->location() != Manifest::COMPONENT) {
[email protected]836e2982013-05-16 08:07:42414 install_time = ExtensionPrefs::Get(profile_)->
[email protected]31d8f5f22012-04-02 15:22:08415 GetInstallTime(extension->id());
416 }
417 bool incognito_enabled =
[email protected]a7ff4b72013-10-17 20:56:02418 extension_util::IsIncognitoEnabled(extension->id(), extension_service());
[email protected]9afacd22013-11-13 20:23:31419
420 bool notifications_disabled = false;
421#if defined(ENABLE_NOTIFICATIONS)
422 message_center::NotifierId notifier_id(
423 message_center::NotifierId::APPLICATION,
424 extension->id());
425
426 DesktopNotificationService* notification_service =
427 DesktopNotificationServiceFactory::GetForProfile(profile_);
428 notifications_disabled =
429 !notification_service->IsNotifierEnabled(notifier_id);
430#endif
431
432 BrowserThread::PostTask(
433 BrowserThread::IO, FROM_HERE,
434 base::Bind(&InfoMap::AddExtension, info_map(),
435 make_scoped_refptr(extension), install_time,
436 incognito_enabled, notifications_disabled));
[email protected]31d8f5f22012-04-02 15:22:08437}
438
439void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts(
440 const std::string& extension_id,
[email protected]b0af4792013-10-23 09:12:13441 const UnloadedExtensionInfo::Reason reason) {
[email protected]31d8f5f22012-04-02 15:22:08442 BrowserThread::PostTask(
[email protected]38427a12013-11-09 17:34:20443 BrowserThread::IO,
444 FROM_HERE,
445 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason));
[email protected]31d8f5f22012-04-02 15:22:08446}
[email protected]bd306722012-07-11 20:43:59447
448} // namespace extensions