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

Side by Side 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, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/shell/browser/shell_extension_system.h" 5 #include "extensions/shell/browser/shell_extension_system.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 19 matching lines...) Expand all
30 30
31 namespace extensions { 31 namespace extensions {
32 32
33 ShellExtensionSystem::ShellExtensionSystem(BrowserContext* browser_context) 33 ShellExtensionSystem::ShellExtensionSystem(BrowserContext* browser_context)
34 : browser_context_(browser_context) { 34 : browser_context_(browser_context) {
35 } 35 }
36 36
37 ShellExtensionSystem::~ShellExtensionSystem() { 37 ShellExtensionSystem::~ShellExtensionSystem() {
38 } 38 }
39 39
40 bool ShellExtensionSystem::LoadApp(const base::FilePath& app_dir) { 40 const Extension* ShellExtensionSystem::LoadApp(const base::FilePath& app_dir) {
41 // app_shell only supports unpacked extensions. 41 // app_shell only supports unpacked extensions.
42 // NOTE: If you add packed extension support consider removing the flag 42 // NOTE: If you add packed extension support consider removing the flag
43 // FOLLOW_SYMLINKS_ANYWHERE below. Packed extensions should not have symlinks. 43 // FOLLOW_SYMLINKS_ANYWHERE below. Packed extensions should not have symlinks.
44 CHECK(base::DirectoryExists(app_dir)) << app_dir.AsUTF8Unsafe(); 44 CHECK(base::DirectoryExists(app_dir)) << app_dir.AsUTF8Unsafe();
45 int load_flags = Extension::FOLLOW_SYMLINKS_ANYWHERE; 45 int load_flags = Extension::FOLLOW_SYMLINKS_ANYWHERE;
46 std::string load_error; 46 std::string load_error;
47 extension_ = file_util::LoadExtension( 47 scoped_refptr<Extension> extension = file_util::LoadExtension(
48 app_dir, Manifest::COMMAND_LINE, load_flags, &load_error); 48 app_dir, Manifest::COMMAND_LINE, load_flags, &load_error);
49 if (!extension_.get()) { 49 if (!extension.get()) {
50 LOG(ERROR) << "Loading extension at " << app_dir.value() 50 LOG(ERROR) << "Loading extension at " << app_dir.value()
51 << " failed with: " << load_error; 51 << " failed with: " << load_error;
52 return false; 52 return nullptr;
53 } 53 }
54 app_id_ = extension_->id();
55 54
56 // TODO(jamescook): We may want to do some of these things here: 55 // TODO(jamescook): We may want to do some of these things here:
57 // * Create a PermissionsUpdater. 56 // * Create a PermissionsUpdater.
58 // * Call PermissionsUpdater::GrantActivePermissions(). 57 // * Call PermissionsUpdater::GrantActivePermissions().
59 // * Call ExtensionService::SatisfyImports(). 58 // * Call ExtensionService::SatisfyImports().
60 // * Call ExtensionPrefs::OnExtensionInstalled(). 59 // * Call ExtensionPrefs::OnExtensionInstalled().
61 // * Send NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED. 60 // * Send NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED.
62 61
63 ExtensionRegistry::Get(browser_context_)->AddEnabled(extension_); 62 ExtensionRegistry::Get(browser_context_)->AddEnabled(extension.get());
64 63
65 RegisterExtensionWithRequestContexts(extension_.get()); 64 RegisterExtensionWithRequestContexts(extension.get());
66 65
67 content::NotificationService::current()->Notify( 66 content::NotificationService::current()->Notify(
68 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, 67 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
69 content::Source<BrowserContext>(browser_context_), 68 content::Source<BrowserContext>(browser_context_),
70 content::Details<const Extension>(extension_.get())); 69 content::Details<const Extension>(extension.get()));
71 70
71 return extension.get();
72 }
73
74 void ShellExtensionSystem::Init() {
72 // Inform the rest of the extensions system to start. 75 // Inform the rest of the extensions system to start.
73 ready_.Signal(); 76 ready_.Signal();
74 content::NotificationService::current()->Notify( 77 content::NotificationService::current()->Notify(
75 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED, 78 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
76 content::Source<BrowserContext>(browser_context_), 79 content::Source<BrowserContext>(browser_context_),
77 content::NotificationService::NoDetails()); 80 content::NotificationService::NoDetails());
78 return true;
79 } 81 }
80 82
81 void ShellExtensionSystem::LaunchApp() { 83 void ShellExtensionSystem::LaunchApp(const ExtensionId& extension_id) {
82 // Send the onLaunched event. 84 // Send the onLaunched event.
83 DCHECK(extension_.get()); 85 DCHECK(ExtensionRegistry::Get(browser_context_)
84 AppRuntimeEventRouter::DispatchOnLaunchedEvent(browser_context_, 86 ->enabled_extensions()
85 extension_.get()); 87 .Contains(extension_id));
88 const Extension* extension = ExtensionRegistry::Get(browser_context_)
89 ->enabled_extensions()
90 .GetByID(extension_id);
91 AppRuntimeEventRouter::DispatchOnLaunchedEvent(browser_context_, extension);
86 } 92 }
87 93
88 void ShellExtensionSystem::Shutdown() { 94 void ShellExtensionSystem::Shutdown() {
89 } 95 }
90 96
91 void ShellExtensionSystem::InitForRegularProfile(bool extensions_enabled) { 97 void ShellExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
92 runtime_data_.reset( 98 runtime_data_.reset(
93 new RuntimeData(ExtensionRegistry::Get(browser_context_))); 99 new RuntimeData(ExtensionRegistry::Get(browser_context_)));
94 lazy_background_task_queue_.reset( 100 lazy_background_task_queue_.reset(
95 new LazyBackgroundTaskQueue(browser_context_)); 101 new LazyBackgroundTaskQueue(browser_context_));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 return make_scoped_ptr(new ExtensionSet()); 197 return make_scoped_ptr(new ExtensionSet());
192 } 198 }
193 199
194 DeclarativeUserScriptMaster* 200 DeclarativeUserScriptMaster*
195 ShellExtensionSystem::GetDeclarativeUserScriptMasterByExtension( 201 ShellExtensionSystem::GetDeclarativeUserScriptMasterByExtension(
196 const ExtensionId& extension_id) { 202 const ExtensionId& extension_id) {
197 return NULL; 203 return NULL;
198 } 204 }
199 205
200 } // namespace extensions 206 } // namespace extensions
OLDNEW
« 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