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

Side by Side Diff: chrome/browser/extensions/api/runtime/runtime_api.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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/runtime/runtime_api.h" 5 #include "chrome/browser/extensions/api/runtime/runtime_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/extensions/extension_host.h" 14 #include "chrome/browser/extensions/extension_host.h"
15 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/extension_system.h" 16 #include "chrome/browser/extensions/extension_system.h"
17 #include "chrome/browser/extensions/updater/extension_updater.h" 17 #include "chrome/browser/extensions/updater/extension_updater.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/ui/browser_finder.h" 20 #include "chrome/browser/ui/browser_finder.h"
21 #include "chrome/browser/ui/browser_navigator.h" 21 #include "chrome/browser/ui/browser_navigator.h"
22 #include "chrome/browser/ui/browser_window.h" 22 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/common/extensions/api/runtime.h" 23 #include "chrome/common/extensions/api/runtime.h"
24 #include "chrome/common/omaha_query_params/omaha_query_params.h" 24 #include "chrome/common/omaha_query_params/omaha_query_params.h"
25 #include "content/public/browser/child_process_security_policy.h" 25 #include "content/public/browser/child_process_security_policy.h"
26 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
27 #include "content/public/browser/render_process_host.h" 27 #include "content/public/browser/render_process_host.h"
28 #include "content/public/browser/render_view_host.h" 28 #include "content/public/browser/render_view_host.h"
29 #include "extensions/browser/event_router.h" 29 #include "extensions/browser/event_router.h"
30 #include "extensions/browser/extension_registry.h"
30 #include "extensions/browser/extensions_browser_client.h" 31 #include "extensions/browser/extensions_browser_client.h"
31 #include "extensions/browser/lazy_background_task_queue.h" 32 #include "extensions/browser/lazy_background_task_queue.h"
32 #include "extensions/browser/process_manager.h" 33 #include "extensions/browser/process_manager.h"
33 #include "extensions/common/error_utils.h" 34 #include "extensions/common/error_utils.h"
34 #include "extensions/common/extension.h" 35 #include "extensions/common/extension.h"
35 #include "extensions/common/manifest_handlers/background_info.h" 36 #include "extensions/common/manifest_handlers/background_info.h"
36 #include "url/gurl.h" 37 #include "url/gurl.h"
37 #include "webkit/browser/fileapi/isolated_context.h" 38 #include "webkit/browser/fileapi/isolated_context.h"
38 39
39 #if defined(OS_CHROMEOS) 40 #if defined(OS_CHROMEOS)
(...skipping 26 matching lines...) Expand all
66 const char kUpdateThrottled[] = "throttled"; 67 const char kUpdateThrottled[] = "throttled";
67 68
68 // A preference key storing the url loaded when an extension is uninstalled. 69 // A preference key storing the url loaded when an extension is uninstalled.
69 const char kUninstallUrl[] = "uninstall_url"; 70 const char kUninstallUrl[] = "uninstall_url";
70 71
71 // The name of the directory to be returned by getPackageDirectoryEntry. This 72 // The name of the directory to be returned by getPackageDirectoryEntry. This
72 // particular value does not matter to user code, but is chosen for consistency 73 // particular value does not matter to user code, but is chosen for consistency
73 // with the equivalent Pepper API. 74 // with the equivalent Pepper API.
74 const char kPackageDirectoryPath[] = "crxfs"; 75 const char kPackageDirectoryPath[] = "crxfs";
75 76
76 static void DispatchOnStartupEventImpl( 77 void DispatchOnStartupEventImpl(BrowserContext* browser_context,
77 Profile* profile, 78 const std::string& extension_id,
78 const std::string& extension_id, 79 bool first_call,
79 bool first_call, 80 ExtensionHost* host) {
80 ExtensionHost* host) {
81 // A NULL host from the LazyBackgroundTaskQueue means the page failed to 81 // A NULL host from the LazyBackgroundTaskQueue means the page failed to
82 // load. Give up. 82 // load. Give up.
83 if (!host && !first_call) 83 if (!host && !first_call)
84 return; 84 return;
85 85
86 // Don't send onStartup events to incognito profiles. 86 // Don't send onStartup events to incognito browser contexts.
87 if (profile->IsOffTheRecord()) 87 if (browser_context->IsOffTheRecord())
88 return; 88 return;
89 89
90 if (g_browser_process->IsShuttingDown() || 90 if (ExtensionsBrowserClient::Get()->IsShuttingDown() ||
91 !g_browser_process->profile_manager()->IsValidProfile(profile)) 91 !ExtensionsBrowserClient::Get()->IsValidContext(browser_context))
92 return; 92 return;
93 ExtensionSystem* system = ExtensionSystem::Get(profile); 93 ExtensionSystem* system =
94 ExtensionSystem::GetForBrowserContext(browser_context);
94 if (!system) 95 if (!system)
95 return; 96 return;
96 97
97 // If this is a persistent background page, we want to wait for it to load 98 // If this is a persistent background page, we want to wait for it to load
98 // (it might not be ready, since this is startup). But only enqueue once. 99 // (it might not be ready, since this is startup). But only enqueue once.
99 // If it fails to load the first time, don't bother trying again. 100 // If it fails to load the first time, don't bother trying again.
100 const Extension* extension = 101 const Extension* extension =
101 system->extension_service()->extensions()->GetByID(extension_id); 102 ExtensionRegistry::Get(browser_context)->enabled_extensions().GetByID(
103 extension_id);
102 if (extension && BackgroundInfo::HasPersistentBackgroundPage(extension) && 104 if (extension && BackgroundInfo::HasPersistentBackgroundPage(extension) &&
103 first_call && 105 first_call &&
104 system->lazy_background_task_queue()-> 106 system->lazy_background_task_queue()->
105 ShouldEnqueueTask(profile, extension)) { 107 ShouldEnqueueTask(browser_context, extension)) {
106 system->lazy_background_task_queue()->AddPendingTask( 108 system->lazy_background_task_queue()->AddPendingTask(
107 profile, extension_id, 109 browser_context, extension_id,
108 base::Bind(&DispatchOnStartupEventImpl, 110 base::Bind(&DispatchOnStartupEventImpl,
109 profile, extension_id, false)); 111 browser_context, extension_id, false));
110 return; 112 return;
111 } 113 }
112 114
113 scoped_ptr<base::ListValue> event_args(new base::ListValue()); 115 scoped_ptr<base::ListValue> event_args(new base::ListValue());
114 scoped_ptr<Event> event(new Event(runtime::OnStartup::kEventName, 116 scoped_ptr<Event> event(new Event(runtime::OnStartup::kEventName,
115 event_args.Pass())); 117 event_args.Pass()));
116 system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); 118 system->event_router()->DispatchEventToExtension(extension_id, event.Pass());
117 } 119 }
118 120
119 void SetUninstallUrl(ExtensionPrefs* prefs, 121 void SetUninstallUrl(ExtensionPrefs* prefs,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 void RuntimeAPI::OnChromeUpdateAvailable() { 255 void RuntimeAPI::OnChromeUpdateAvailable() {
254 Profile* profile = Profile::FromBrowserContext(browser_context_); 256 Profile* profile = Profile::FromBrowserContext(browser_context_);
255 RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent(profile); 257 RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent(profile);
256 } 258 }
257 259
258 /////////////////////////////////////////////////////////////////////////////// 260 ///////////////////////////////////////////////////////////////////////////////
259 261
260 // static 262 // static
261 void RuntimeEventRouter::DispatchOnStartupEvent( 263 void RuntimeEventRouter::DispatchOnStartupEvent(
262 content::BrowserContext* context, const std::string& extension_id) { 264 content::BrowserContext* context, const std::string& extension_id) {
263 // TODO(jamescook): Convert to BrowserContext all the way down. 265 DispatchOnStartupEventImpl(context, extension_id, true, NULL);
264 Profile* profile = static_cast<Profile*>(context);
265 DispatchOnStartupEventImpl(profile, extension_id, true, NULL);
266 } 266 }
267 267
268 // static 268 // static
269 void RuntimeEventRouter::DispatchOnInstalledEvent( 269 void RuntimeEventRouter::DispatchOnInstalledEvent(
270 content::BrowserContext* context, 270 content::BrowserContext* context,
271 const std::string& extension_id, 271 const std::string& extension_id,
272 const Version& old_version, 272 const Version& old_version,
273 bool chrome_updated) { 273 bool chrome_updated) {
274 if (!ExtensionsBrowserClient::Get()->IsValidContext(context)) 274 if (!ExtensionsBrowserClient::Get()->IsValidContext(context))
275 return; 275 return;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 content::ChildProcessSecurityPolicy::GetInstance(); 573 content::ChildProcessSecurityPolicy::GetInstance();
574 policy->GrantReadFileSystem(renderer_id, filesystem_id); 574 policy->GrantReadFileSystem(renderer_id, filesystem_id);
575 base::DictionaryValue* dict = new base::DictionaryValue(); 575 base::DictionaryValue* dict = new base::DictionaryValue();
576 SetResult(dict); 576 SetResult(dict);
577 dict->SetString("fileSystemId", filesystem_id); 577 dict->SetString("fileSystemId", filesystem_id);
578 dict->SetString("baseName", relative_path); 578 dict->SetString("baseName", relative_path);
579 return true; 579 return true;
580 } 580 }
581 581
582 } // namespace extensions 582 } // namespace extensions
OLDNEW
« no previous file with comments | « apps/shell/shell_extensions_client.cc ('k') | chrome/browser/extensions/extension_web_contents_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698