Chromium Code Reviews| Index: extensions/shell/browser/shell_extension_system.cc |
| diff --git a/extensions/shell/browser/shell_extension_system.cc b/extensions/shell/browser/shell_extension_system.cc |
| index 317a410030ca6afbb01b8314e788b990c7d24098..8ec12e060e7bf9895a3c7492a684fd4042f8827e 100644 |
| --- a/extensions/shell/browser/shell_extension_system.cc |
| +++ b/extensions/shell/browser/shell_extension_system.cc |
| @@ -37,21 +37,21 @@ ShellExtensionSystem::ShellExtensionSystem(BrowserContext* browser_context) |
| ShellExtensionSystem::~ShellExtensionSystem() { |
| } |
| -bool ShellExtensionSystem::LoadApp(const base::FilePath& app_dir) { |
| +const Extension* ShellExtensionSystem::LoadApp(const base::FilePath& app_dir) { |
| // app_shell only supports unpacked extensions. |
| // NOTE: If you add packed extension support consider removing the flag |
| // FOLLOW_SYMLINKS_ANYWHERE below. Packed extensions should not have symlinks. |
| CHECK(base::DirectoryExists(app_dir)) << app_dir.AsUTF8Unsafe(); |
| int load_flags = Extension::FOLLOW_SYMLINKS_ANYWHERE; |
| std::string load_error; |
| - extension_ = file_util::LoadExtension( |
| + scoped_refptr<Extension> extension_refptr = file_util::LoadExtension( |
|
James Cook
2014/10/23 21:29:52
nit: I find it awkward to have both extension_refp
lfg
2014/10/23 22:04:05
Done.
|
| app_dir, Manifest::COMMAND_LINE, load_flags, &load_error); |
| - if (!extension_.get()) { |
| + Extension* extension = extension_refptr.get(); |
| + if (!extension) { |
| LOG(ERROR) << "Loading extension at " << app_dir.value() |
| << " failed with: " << load_error; |
| - return false; |
| + return nullptr; |
| } |
| - app_id_ = extension_->id(); |
| // TODO(jamescook): We may want to do some of these things here: |
| // * Create a PermissionsUpdater. |
| @@ -60,15 +60,21 @@ bool ShellExtensionSystem::LoadApp(const base::FilePath& app_dir) { |
| // * Call ExtensionPrefs::OnExtensionInstalled(). |
| // * Send NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED. |
| - ExtensionRegistry::Get(browser_context_)->AddEnabled(extension_); |
| + extensions_.Insert(extension_refptr); |
|
James Cook
2014/10/23 21:29:53
Do you need extensions_ at all? Can you just get t
lfg
2014/10/23 22:04:05
Indeed, that is not necessary. Removed.
|
| - RegisterExtensionWithRequestContexts(extension_.get()); |
| + ExtensionRegistry::Get(browser_context_)->AddEnabled(extension_refptr); |
| + |
| + RegisterExtensionWithRequestContexts(extension); |
| content::NotificationService::current()->Notify( |
| extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| content::Source<BrowserContext>(browser_context_), |
| - content::Details<const Extension>(extension_.get())); |
| + content::Details<const Extension>(extension)); |
| + |
| + return extension; |
| +} |
| +bool ShellExtensionSystem::Init() { |
| // Inform the rest of the extensions system to start. |
| ready_.Signal(); |
| content::NotificationService::current()->Notify( |
| @@ -78,11 +84,11 @@ bool ShellExtensionSystem::LoadApp(const base::FilePath& app_dir) { |
| return true; |
| } |
| -void ShellExtensionSystem::LaunchApp() { |
| +void ShellExtensionSystem::LaunchApp(const ExtensionId& extension_id) { |
| // Send the onLaunched event. |
| - DCHECK(extension_.get()); |
| - AppRuntimeEventRouter::DispatchOnLaunchedEvent(browser_context_, |
| - extension_.get()); |
| + DCHECK(extensions_.Contains(extension_id)); |
| + const Extension* extension = extensions_.GetByID(extension_id); |
| + AppRuntimeEventRouter::DispatchOnLaunchedEvent(browser_context_, extension); |
| } |
| void ShellExtensionSystem::Shutdown() { |