Bug 1038756: Extend nsILoadInfo to include a loadingContext and contentPolicyType (r=bz)
* * * Updating comments for loadingNode, loadingPrincipal, and loadingDocument
This commit is contained in:
@@ -7,20 +7,27 @@
|
||||
#include "mozilla/LoadInfo.h"
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
LoadInfo::LoadInfo(nsIPrincipal* aPrincipal,
|
||||
InheritType aInheritPrincipal,
|
||||
SandboxType aSandboxed)
|
||||
nsINode* aLoadingContext,
|
||||
nsSecurityFlags aSecurityFlags,
|
||||
nsContentPolicyType aContentPolicyType)
|
||||
: mPrincipal(aPrincipal)
|
||||
, mInheritPrincipal(aInheritPrincipal == eInheritPrincipal &&
|
||||
aSandboxed != eSandboxed)
|
||||
, mSandboxed(aSandboxed == eSandboxed)
|
||||
, mLoadingContext(do_GetWeakReference(aLoadingContext))
|
||||
, mSecurityFlags(aSecurityFlags)
|
||||
, mContentPolicyType(aContentPolicyType)
|
||||
{
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
// if the load is sandboxed, we can not also inherit the principal
|
||||
if (mSecurityFlags & nsILoadInfo::SEC_SANDBOXED) {
|
||||
mSecurityFlags ^= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
|
||||
}
|
||||
}
|
||||
|
||||
LoadInfo::~LoadInfo()
|
||||
@@ -42,17 +49,49 @@ LoadInfo::LoadingPrincipal()
|
||||
return mPrincipal;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetLoadingDocument(nsIDOMDocument** outLoadingDocument)
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryReferent(mLoadingContext);
|
||||
if (node) {
|
||||
nsCOMPtr<nsIDOMDocument> context = do_QueryInterface(node->OwnerDoc());
|
||||
context.forget(outLoadingDocument);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsINode*
|
||||
LoadInfo::LoadingNode()
|
||||
{
|
||||
nsCOMPtr<nsINode> node = do_QueryReferent(mLoadingContext);
|
||||
return node;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetSecurityFlags(nsSecurityFlags* outSecurityFlags)
|
||||
{
|
||||
*outSecurityFlags = mSecurityFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetForceInheritPrincipal(bool* aInheritPrincipal)
|
||||
{
|
||||
*aInheritPrincipal = mInheritPrincipal;
|
||||
*aInheritPrincipal = (mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetLoadingSandboxed(bool* aLoadingSandboxed)
|
||||
{
|
||||
*aLoadingSandboxed = mSandboxed;
|
||||
*aLoadingSandboxed = (mSecurityFlags & nsILoadInfo::SEC_SANDBOXED);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetContentPolicyType(nsContentPolicyType* outContentPolicyType)
|
||||
{
|
||||
*outContentPolicyType = mContentPolicyType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user