Chromium Code Reviews| Index: apps/shell/browser/shell_extension_system.cc |
| diff --git a/apps/shell/browser/shell_extension_system.cc b/apps/shell/browser/shell_extension_system.cc |
| index 7d56884fcf6bc3e02b7a49a93d104952acbc857e..b0c9f890e58e624fe4542f78f579efb12ef185b4 100644 |
| --- a/apps/shell/browser/shell_extension_system.cc |
| +++ b/apps/shell/browser/shell_extension_system.cc |
| @@ -38,20 +38,29 @@ ShellExtensionSystem::~ShellExtensionSystem() { |
| } |
| bool ShellExtensionSystem::LoadAndLaunchApp(const base::FilePath& app_dir) { |
|
James Cook
2014/06/09 21:59:30
I suggest getting rid of this method and just call
Jun Mukai
2014/06/09 22:04:08
Done.
|
| + if (!extension_) { |
| + if (!LoadApp(app_dir)) |
| + return false; |
| + } |
| + LaunchApp(); |
| + return true; |
| +} |
| + |
| +bool 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; |
| - scoped_refptr<Extension> extension = file_util::LoadExtension( |
| + extension_ = file_util::LoadExtension( |
| app_dir, Manifest::COMMAND_LINE, load_flags, &load_error); |
| - if (!extension) { |
| + if (!extension_) { |
| LOG(ERROR) << "Loading extension at " << app_dir.value() |
| << " failed with: " << load_error; |
| return false; |
| } |
| - app_id_ = extension->id(); |
| + app_id_ = extension_->id(); |
| // TODO(jamescook): We may want to do some of these things here: |
| // * Create a PermissionsUpdater. |
| @@ -60,14 +69,14 @@ bool ShellExtensionSystem::LoadAndLaunchApp(const base::FilePath& app_dir) { |
| // * Call ExtensionPrefs::OnExtensionInstalled(). |
| // * Send NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED. |
| - ExtensionRegistry::Get(browser_context_)->AddEnabled(extension); |
| + ExtensionRegistry::Get(browser_context_)->AddEnabled(extension_); |
| - RegisterExtensionWithRequestContexts(extension); |
| + RegisterExtensionWithRequestContexts(extension_); |
| content::NotificationService::current()->Notify( |
| chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| content::Source<BrowserContext>(browser_context_), |
| - content::Details<const Extension>(extension)); |
| + content::Details<const Extension>(extension_)); |
| // Inform the rest of the extensions system to start. |
| ready_.Signal(); |
| @@ -75,11 +84,13 @@ bool ShellExtensionSystem::LoadAndLaunchApp(const base::FilePath& app_dir) { |
| chrome::NOTIFICATION_EXTENSIONS_READY, |
| content::Source<BrowserContext>(browser_context_), |
| content::NotificationService::NoDetails()); |
| + return true; |
| +} |
| +void ShellExtensionSystem::LaunchApp() { |
| // Send the onLaunched event. |
|
James Cook
2014/06/09 21:59:30
DCHECK(extension_.get()) ?
Jun Mukai
2014/06/09 22:04:08
Done.
|
| - apps::ShellAPI::DispatchOnLaunchedEvent(event_router_.get(), extension.get()); |
| - |
| - return true; |
| + apps::ShellAPI::DispatchOnLaunchedEvent(event_router_.get(), |
| + extension_.get()); |
| } |
| void ShellExtensionSystem::Shutdown() { |