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

Side by Side Diff: chrome/browser/extensions/extension_web_contents_observer.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 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 "chrome/browser/extensions/extension_web_contents_observer.h" 5 #include "chrome/browser/extensions/extension_web_contents_observer.h"
6 6
7 #include "chrome/browser/extensions/api/messaging/message_service.h" 7 #include "chrome/browser/extensions/api/messaging/message_service.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/extensions/api/messaging/message.h" 11 #include "chrome/common/extensions/api/messaging/message.h"
12 #include "chrome/common/extensions/extension_messages.h" 12 #include "chrome/common/extensions/extension_messages.h"
13 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "content/public/browser/child_process_security_policy.h" 14 #include "content/public/browser/child_process_security_policy.h"
15 #include "content/public/browser/render_process_host.h" 15 #include "content/public/browser/render_process_host.h"
16 #include "content/public/browser/render_view_host.h" 16 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/site_instance.h" 17 #include "content/public/browser/site_instance.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "extensions/browser/extension_registry.h"
19 #include "extensions/browser/view_type_utils.h" 20 #include "extensions/browser/view_type_utils.h"
20 #include "extensions/common/constants.h" 21 #include "extensions/common/constants.h"
21 22
22 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::ExtensionWebContentsObserver); 23 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::ExtensionWebContentsObserver);
23 24
24 namespace extensions { 25 namespace extensions {
25 26
26 ExtensionWebContentsObserver::ExtensionWebContentsObserver( 27 ExtensionWebContentsObserver::ExtensionWebContentsObserver(
27 content::WebContents* web_contents) 28 content::WebContents* web_contents)
28 : content::WebContentsObserver(web_contents), 29 : content::WebContentsObserver(web_contents),
(...skipping 23 matching lines...) Expand all
52 type == Manifest::TYPE_LEGACY_PACKAGED_APP || 53 type == Manifest::TYPE_LEGACY_PACKAGED_APP ||
53 (type == Manifest::TYPE_PLATFORM_APP && 54 (type == Manifest::TYPE_PLATFORM_APP &&
54 extension->location() == Manifest::COMPONENT)) { 55 extension->location() == Manifest::COMPONENT)) {
55 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( 56 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(
56 process->GetID(), chrome::kChromeUIScheme); 57 process->GetID(), chrome::kChromeUIScheme);
57 } 58 }
58 59
59 // Some extensions use file:// URLs. 60 // Some extensions use file:// URLs.
60 if (type == Manifest::TYPE_EXTENSION || 61 if (type == Manifest::TYPE_EXTENSION ||
61 type == Manifest::TYPE_LEGACY_PACKAGED_APP) { 62 type == Manifest::TYPE_LEGACY_PACKAGED_APP) {
62 if (ExtensionSystem::Get(profile_)->extension_service()-> 63 if (ExtensionPrefs::Get(profile_)->AllowFileAccess(extension->id())) {
63 extension_prefs()->AllowFileAccess(extension->id())) {
64 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme( 64 content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(
65 process->GetID(), content::kFileScheme); 65 process->GetID(), content::kFileScheme);
66 } 66 }
67 } 67 }
68 68
69 switch (type) { 69 switch (type) {
70 case Manifest::TYPE_EXTENSION: 70 case Manifest::TYPE_EXTENSION:
71 case Manifest::TYPE_USER_SCRIPT: 71 case Manifest::TYPE_USER_SCRIPT:
72 case Manifest::TYPE_HOSTED_APP: 72 case Manifest::TYPE_HOSTED_APP:
73 case Manifest::TYPE_LEGACY_PACKAGED_APP: 73 case Manifest::TYPE_LEGACY_PACKAGED_APP:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 content::RenderViewHost* render_view_host) { 112 content::RenderViewHost* render_view_host) {
113 // Note that due to ChromeContentBrowserClient::GetEffectiveURL(), hosted apps 113 // Note that due to ChromeContentBrowserClient::GetEffectiveURL(), hosted apps
114 // (excluding bookmark apps) will have a chrome-extension:// URL for their 114 // (excluding bookmark apps) will have a chrome-extension:// URL for their
115 // site, so we can ignore that wrinkle here. 115 // site, so we can ignore that wrinkle here.
116 content::SiteInstance* site_instance = render_view_host->GetSiteInstance(); 116 content::SiteInstance* site_instance = render_view_host->GetSiteInstance();
117 const GURL& site = site_instance->GetSiteURL(); 117 const GURL& site = site_instance->GetSiteURL();
118 118
119 if (!site.SchemeIs(kExtensionScheme)) 119 if (!site.SchemeIs(kExtensionScheme))
120 return NULL; 120 return NULL;
121 121
122 ExtensionService* service = profile_->GetExtensionService(); 122 ExtensionService* service =
123 ExtensionSystem::Get(profile_)->extension_service();
123 if (!service) 124 if (!service)
124 return NULL; 125 return NULL;
125 126
126 // Reload the extension if it has crashed. 127 // Reload the extension if it has crashed.
127 // TODO(yoz): This reload doesn't happen synchronously for unpacked 128 // TODO(yoz): This reload doesn't happen synchronously for unpacked
128 // extensions. It seems to be fast enough, but there is a race. 129 // extensions. It seems to be fast enough, but there is a race.
129 // We should delay loading until the extension has reloaded. 130 // We should delay loading until the extension has reloaded.
130 if (service->GetTerminatedExtension(site.host())) 131 if (service->GetTerminatedExtension(site.host()))
131 service->ReloadExtension(site.host()); 132 service->ReloadExtension(site.host());
132 133
133 // May be null if the extension doesn't exist, for example if somebody typos 134 // May be null if the extension doesn't exist, for example if somebody typos
134 // a chrome-extension:// URL. 135 // a chrome-extension:// URL.
135 return service->extensions()->GetByID(site.host()); 136 return ExtensionRegistry::Get(profile_)->enabled_extensions().GetByID(
137 site.host());
136 } 138 }
137 139
138 } // namespace extensions 140 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/runtime/runtime_api.cc ('k') | chrome/common/extensions/chrome_extensions_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698