Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3065)

Unified Diff: extensions/shell/browser/shell_extension_system.cc

Issue 642383003: Add the ability to load multiple apps into app_shell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..6337108ccb297b4bd170d950cfeb00cd58d911d6 100644
--- a/extensions/shell/browser/shell_extension_system.cc
+++ b/extensions/shell/browser/shell_extension_system.cc
@@ -37,21 +37,20 @@ 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 = file_util::LoadExtension(
app_dir, Manifest::COMMAND_LINE, load_flags, &load_error);
- if (!extension_.get()) {
+ if (!extension.get()) {
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,29 +59,36 @@ bool ShellExtensionSystem::LoadApp(const base::FilePath& app_dir) {
// * Call ExtensionPrefs::OnExtensionInstalled().
// * Send NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED.
- ExtensionRegistry::Get(browser_context_)->AddEnabled(extension_);
+ ExtensionRegistry::Get(browser_context_)->AddEnabled(extension.get());
- RegisterExtensionWithRequestContexts(extension_.get());
+ RegisterExtensionWithRequestContexts(extension.get());
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.get()));
+ return extension.get();
+}
+
+void ShellExtensionSystem::Init() {
// Inform the rest of the extensions system to start.
ready_.Signal();
content::NotificationService::current()->Notify(
extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
content::Source<BrowserContext>(browser_context_),
content::NotificationService::NoDetails());
- 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(ExtensionRegistry::Get(browser_context_)
+ ->enabled_extensions()
+ .Contains(extension_id));
+ const Extension* extension = ExtensionRegistry::Get(browser_context_)
+ ->enabled_extensions()
+ .GetByID(extension_id);
+ AppRuntimeEventRouter::DispatchOnLaunchedEvent(browser_context_, extension);
}
void ShellExtensionSystem::Shutdown() {
« no previous file with comments | « extensions/shell/browser/shell_extension_system.h ('k') | extensions/shell/browser/shell_native_app_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698