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

Side by Side Diff: apps/shell/shell_extension_system.cc

Issue 101203008: Allow app_shell to run past extension manifest parsing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup register_manifest Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « apps/shell/shell_extension_system.h ('k') | apps/shell/shell_extensions_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "apps/shell/shell_extension_system.h" 5 #include "apps/shell/shell_extension_system.h"
6 6
7 #include <string>
8
7 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h"
11 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/extension_prefs.h" 12 #include "chrome/browser/extensions/extension_prefs.h"
13 #include "chrome/common/extensions/extension_file_util.h"
9 #include "content/public/browser/browser_context.h" 14 #include "content/public/browser/browser_context.h"
15 #include "content/public/browser/notification_details.h"
16 #include "content/public/browser/notification_service.h"
17 #include "content/public/browser/notification_source.h"
10 #include "extensions/browser/event_router.h" 18 #include "extensions/browser/event_router.h"
19 #include "extensions/browser/extension_registry.h"
11 #include "extensions/browser/lazy_background_task_queue.h" 20 #include "extensions/browser/lazy_background_task_queue.h"
12 #include "extensions/browser/process_manager.h" 21 #include "extensions/browser/process_manager.h"
13 22
14 using content::BrowserContext; 23 using content::BrowserContext;
15 24
16 namespace extensions { 25 namespace extensions {
17 26
18 ShellExtensionSystem::ShellExtensionSystem(BrowserContext* browser_context) 27 ShellExtensionSystem::ShellExtensionSystem(BrowserContext* browser_context)
19 : browser_context_(browser_context) { 28 : browser_context_(browser_context) {
20 } 29 }
21 30
22 ShellExtensionSystem::~ShellExtensionSystem() { 31 ShellExtensionSystem::~ShellExtensionSystem() {
23 } 32 }
24 33
34 bool ShellExtensionSystem::LoadAndLaunchApp(const base::FilePath& app_dir) {
35 std::string load_error;
36 scoped_refptr<Extension> extension =
37 extension_file_util::LoadExtension(app_dir,
38 extensions::Manifest::COMMAND_LINE,
39 Extension::NO_FLAGS,
40 &load_error);
41 if (!extension) {
42 LOG(ERROR) << "Loading extension at " << app_dir.value()
43 << " failed with: " << load_error;
44 return false;
45 }
46
47 ExtensionRegistry::Get(browser_context_)->AddEnabled(extension);
48
49 // TODO(jamescook): If RegisterExtensionWithRequestContexts() did something,
50 // this would be the place to call it.
51
52 content::NotificationService::current()->Notify(
53 chrome::NOTIFICATION_EXTENSION_LOADED,
54 content::Source<BrowserContext>(browser_context_),
55 content::Details<const Extension>(extension));
56
57 // Inform the rest of the extensions system to start.
58 ready_.Signal();
59 LOG(WARNING) << "-----------------------------------";
60 LOG(WARNING) << "app_shell is expected to crash now.";
61 LOG(WARNING) << "-----------------------------------";
62 content::NotificationService::current()->Notify(
63 chrome::NOTIFICATION_EXTENSIONS_READY,
64 content::Source<BrowserContext>(browser_context_),
65 content::NotificationService::NoDetails());
66
67 return true;
68 }
69
25 void ShellExtensionSystem::Shutdown() { 70 void ShellExtensionSystem::Shutdown() {
26 } 71 }
27 72
28 void ShellExtensionSystem::InitForRegularProfile(bool extensions_enabled) { 73 void ShellExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
29 lazy_background_task_queue_.reset( 74 lazy_background_task_queue_.reset(
30 new LazyBackgroundTaskQueue(browser_context_)); 75 new LazyBackgroundTaskQueue(browser_context_));
31 event_router_.reset( 76 event_router_.reset(
32 new EventRouter(browser_context_, ExtensionPrefs::Get(browser_context_))); 77 new EventRouter(browser_context_, ExtensionPrefs::Get(browser_context_)));
33 process_manager_.reset(ProcessManager::Create(browser_context_)); 78 process_manager_.reset(ProcessManager::Create(browser_context_));
34 } 79 }
35 80
36 ExtensionService* ShellExtensionSystem::extension_service() { 81 ExtensionService* ShellExtensionSystem::extension_service() {
37 // This class only has an ExtensionServiceInterface. 82 NOTREACHED();
38 return NULL; 83 return NULL;
39 } 84 }
40 85
41 ManagementPolicy* ShellExtensionSystem::management_policy() { 86 ManagementPolicy* ShellExtensionSystem::management_policy() {
42 return NULL; 87 return NULL;
43 } 88 }
44 89
45 UserScriptMaster* ShellExtensionSystem::user_script_master() { 90 UserScriptMaster* ShellExtensionSystem::user_script_master() {
46 return NULL; 91 return NULL;
47 } 92 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 void ShellExtensionSystem::UnregisterExtensionWithRequestContexts( 138 void ShellExtensionSystem::UnregisterExtensionWithRequestContexts(
94 const std::string& extension_id, 139 const std::string& extension_id,
95 const UnloadedExtensionInfo::Reason reason) { 140 const UnloadedExtensionInfo::Reason reason) {
96 } 141 }
97 142
98 const OneShotEvent& ShellExtensionSystem::ready() const { 143 const OneShotEvent& ShellExtensionSystem::ready() const {
99 return ready_; 144 return ready_;
100 } 145 }
101 146
102 } // namespace extensions 147 } // namespace extensions
OLDNEW
« no previous file with comments | « apps/shell/shell_extension_system.h ('k') | apps/shell/shell_extensions_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698