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

Unified Diff: chrome/browser/extensions/extension_protocols.cc

Issue 2808051: Refactored extension privilege enumeration and implemented URLPattern compari... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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
« no previous file with comments | « chrome/browser/extensions/extension_install_ui.cc ('k') | chrome/browser/net/chrome_url_request_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_protocols.cc
===================================================================
--- chrome/browser/extensions/extension_protocols.cc (revision 54542)
+++ chrome/browser/extensions/extension_protocols.cc (working copy)
@@ -74,12 +74,24 @@
ChromeURLRequestContext* context =
static_cast<ChromeURLRequestContext*>(request->context());
+ const ResourceDispatcherHostRequestInfo* info =
+ ResourceDispatcherHost::InfoForRequest(request);
+
+ // Don't allow extension resources to be loaded from origins which are not
+ // present in the extension's effective host permissions with the exception
+ // of empty origins and extension schemes.
+ if (!info->frame_origin().empty() &&
+ !GURL(info->frame_origin()).SchemeIs(chrome::kExtensionScheme)) {
+ ExtensionExtent host_permissions =
+ context->GetEffectiveHostPermissionsForExtension(request->url().host());
+ if (!host_permissions.ContainsURL(GURL(info->frame_origin())))
+ return new URLRequestErrorJob(request, net::ERR_ADDRESS_UNREACHABLE);
+ }
+
// Don't allow toplevel navigations to extension resources in incognito mode.
- // This is because an extension must run in a single process, and an incognito
- // tab prevents that.
+ // This is because an extension must run in a single process, and an
+ // incognito tab prevents that.
// TODO(mpcomplete): better error code.
- const ResourceDispatcherHostRequestInfo* info =
- ResourceDispatcherHost::InfoForRequest(request);
if (context->is_off_the_record() &&
info && info->resource_type() == ResourceType::MAIN_FRAME)
return new URLRequestErrorJob(request, net::ERR_ADDRESS_UNREACHABLE);
« no previous file with comments | « chrome/browser/extensions/extension_install_ui.cc ('k') | chrome/browser/net/chrome_url_request_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698