diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-11 09:18:32 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-11 09:18:32 +0000 |
commit | d119f99cf64fb1b8825f438aa2dd260417cee51e (patch) | |
tree | d2ded24582b6ef18b6c04b1c669f1a1703d7ba4d /apps/shell | |
parent | 806125bd2123385f89a0f9c774b37b178d180799 (diff) | |
download | chromium_src-d119f99cf64fb1b8825f438aa2dd260417cee51e.zip chromium_src-d119f99cf64fb1b8825f438aa2dd260417cee51e.tar.gz chromium_src-d119f99cf64fb1b8825f438aa2dd260417cee51e.tar.bz2 |
Introduces --app flag to athena to load an app.
Just loading, do nothing to the loaded app for now. Following CL
will embed the loaded app into AppActivity (combined with
crrev.com/311113005)
BUG=380421
R=jamescook@chromium.org, oshima@chromium.org
TEST=manually
Review URL: https://codereview.chromium.org/313733005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276316 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps/shell')
-rw-r--r-- | apps/shell/browser/default_shell_browser_main_delegate.cc | 4 | ||||
-rw-r--r-- | apps/shell/browser/shell_extension_system.cc | 23 | ||||
-rw-r--r-- | apps/shell/browser/shell_extension_system.h | 10 | ||||
-rw-r--r-- | apps/shell/test/shell_test.cc | 5 |
4 files changed, 27 insertions, 15 deletions
diff --git a/apps/shell/browser/default_shell_browser_main_delegate.cc b/apps/shell/browser/default_shell_browser_main_delegate.cc index 3efabbb..b9a8baf 100644 --- a/apps/shell/browser/default_shell_browser_main_delegate.cc +++ b/apps/shell/browser/default_shell_browser_main_delegate.cc @@ -29,7 +29,9 @@ void DefaultShellBrowserMainDelegate::Start( extensions::ShellExtensionSystem* extension_system = static_cast<extensions::ShellExtensionSystem*>( extensions::ExtensionSystem::Get(browser_context)); - extension_system->LoadAndLaunchApp(app_absolute_dir); + if (!extension_system->LoadApp(app_absolute_dir)) + return; + extension_system->LaunchApp(); } else { LOG(ERROR) << "--" << kAppSwitch << " unset; boredom is in your future"; } diff --git a/apps/shell/browser/shell_extension_system.cc b/apps/shell/browser/shell_extension_system.cc index 7d56884..11dfbc6 100644 --- a/apps/shell/browser/shell_extension_system.cc +++ b/apps/shell/browser/shell_extension_system.cc @@ -37,21 +37,21 @@ ShellExtensionSystem::ShellExtensionSystem(BrowserContext* browser_context) ShellExtensionSystem::~ShellExtensionSystem() { } -bool ShellExtensionSystem::LoadAndLaunchApp(const base::FilePath& app_dir) { +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 +60,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 +75,14 @@ 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. - apps::ShellAPI::DispatchOnLaunchedEvent(event_router_.get(), extension.get()); - - return true; + DCHECK(extension_.get()); + apps::ShellAPI::DispatchOnLaunchedEvent(event_router_.get(), + extension_.get()); } void ShellExtensionSystem::Shutdown() { diff --git a/apps/shell/browser/shell_extension_system.h b/apps/shell/browser/shell_extension_system.h index a287d2d..2c1f818 100644 --- a/apps/shell/browser/shell_extension_system.h +++ b/apps/shell/browser/shell_extension_system.h @@ -36,9 +36,11 @@ class ShellExtensionSystem : public ExtensionSystem { explicit ShellExtensionSystem(content::BrowserContext* browser_context); virtual ~ShellExtensionSystem(); - // Loads an unpacked application from a directory and attempts to launch it. - // Returns true on success. - bool LoadAndLaunchApp(const base::FilePath& app_dir); + // Loads an unpacked application from a directory. Returns true on success. + bool LoadApp(const base::FilePath& app_dir); + + // Launch the currently loaded app. + void LaunchApp(); // KeyedService implementation: virtual void Shutdown() OVERRIDE; @@ -75,6 +77,8 @@ class ShellExtensionSystem : public ExtensionSystem { // Extension ID for the app. std::string app_id_; + scoped_refptr<Extension> extension_; + // Data to be accessed on the IO thread. Must outlive process_manager_. scoped_refptr<InfoMap> info_map_; diff --git a/apps/shell/test/shell_test.cc b/apps/shell/test/shell_test.cc index 3d2cfee..bdd19a7 100644 --- a/apps/shell/test/shell_test.cc +++ b/apps/shell/test/shell_test.cc @@ -47,7 +47,10 @@ void AppShellTest::RunTestOnMainThreadLoop() { } bool AppShellTest::LoadAndLaunchApp(const base::FilePath& app_dir) { - return extension_system_->LoadAndLaunchApp(app_dir); + bool loaded = extension_system_->LoadApp(app_dir); + if (loaded) + extension_system_->LaunchApp(); + return loaded; } } // namespace apps |