From b3d20bffbcc893fb04f3aefcf3796d60d4a6e2d1 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 10 Jul 2014 02:56:36 -0400 Subject: [PATCH] Bug 965413 part 4. Teach the security manager about nsILoadInfo. r=smaug --- caps/src/nsScriptSecurityManager.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/caps/src/nsScriptSecurityManager.cpp b/caps/src/nsScriptSecurityManager.cpp index acb3c9ebfa8..91270ec0b49 100644 --- a/caps/src/nsScriptSecurityManager.cpp +++ b/caps/src/nsScriptSecurityManager.cpp @@ -64,6 +64,7 @@ #include "nsContentUtils.h" #include "nsCxPusher.h" #include "nsJSUtils.h" +#include "nsILoadInfo.h" // This should be probably defined on some other place... but I couldn't find it #define WEBAPPS_PERM_NAME "webapps-manage" @@ -265,6 +266,20 @@ nsScriptSecurityManager::GetChannelPrincipal(nsIChannel* aChannel, } } + // Check whether we have an nsILoadInfo that says what we should do. + nsCOMPtr loadInfo; + aChannel->GetLoadInfo(getter_AddRefs(loadInfo)); + if (loadInfo) { + if (loadInfo->GetLoadingSandboxed()) { + return CallCreateInstance(NS_NULLPRINCIPAL_CONTRACTID, aPrincipal); + } + + if (loadInfo->GetForceInheritPrincipal()) { + NS_ADDREF(*aPrincipal = loadInfo->LoadingPrincipal()); + return NS_OK; + } + } + // OK, get the principal from the URI. Make sure this does the same thing // as nsDocument::Reset and XULDocument::StartDocumentLoad. nsCOMPtr uri;