mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 08:12:05 +00:00
Switch context back to being nsISupports, but make it clear that it's expected
to be an nsIDOMNode or nsIDOMWindow. Bug 252027, r=mvl, sr=shaver
This commit is contained in:
parent
40ca95b00d
commit
02d0d94b73
@ -147,7 +147,7 @@ NS_CP_ContentTypeName(PRUint32 contentType)
|
||||
return NS_ERROR_FAILURE; \
|
||||
\
|
||||
return policy-> action (contentType, contentLocation, requestOrigin, \
|
||||
content, mimeType, extra, decision);
|
||||
context, mimeType, extra, decision);
|
||||
|
||||
/**
|
||||
* Alias for calling ShouldLoad on the content policy service.
|
||||
@ -157,7 +157,7 @@ inline nsresult
|
||||
NS_CheckContentLoadPolicy(PRUint32 contentType,
|
||||
nsIURI *contentLocation,
|
||||
nsIURI *requestOrigin,
|
||||
nsIDOMNode *content,
|
||||
nsISupports *context,
|
||||
const nsACString &mimeType,
|
||||
nsISupports *extra,
|
||||
PRInt16 *decision)
|
||||
@ -173,7 +173,7 @@ inline nsresult
|
||||
NS_CheckContentProcessPolicy(PRUint32 contentType,
|
||||
nsIURI *contentLocation,
|
||||
nsIURI *requestOrigin,
|
||||
nsIDOMNode *content,
|
||||
nsISupports *context,
|
||||
const nsACString &mimeType,
|
||||
nsISupports *extra,
|
||||
PRInt16 *decision)
|
||||
@ -184,36 +184,44 @@ NS_CheckContentProcessPolicy(PRUint32 contentType,
|
||||
#undef CHECK_CONTENT_POLICY
|
||||
|
||||
/**
|
||||
* Helper function to get an nsIDocShell given an nsIDOMNode.
|
||||
* If the node is a document, the corresponding docshell will be returned.
|
||||
* If the node is not a document, the docshell of its ownerDocument will be
|
||||
* Helper function to get an nsIDocShell given a context.
|
||||
* If the context is a document or window, the corresponding docshell will be
|
||||
* returned.
|
||||
* If the context is a non-document DOM node, the docshell of its ownerDocument
|
||||
* will be returned.
|
||||
*
|
||||
* @param node the nsIDOMNode to find a docshell for (can be null)
|
||||
* @param aContext the context to find a docshell for (can be null)
|
||||
* @return a WEAK pointer to the docshell, or nsnull if it could
|
||||
* not be obtained
|
||||
*/
|
||||
static nsIDocShell*
|
||||
NS_CP_GetDocShellFromDOMNode(nsIDOMNode *aNode)
|
||||
NS_CP_GetDocShellFromContext(nsISupports *aContext)
|
||||
{
|
||||
if (!aNode) {
|
||||
if (!aContext) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsIScriptGlobalObject *scriptGlobal = nsnull;
|
||||
nsCOMPtr<nsIScriptGlobalObject> scriptGlobal = do_QueryInterface(aContext);
|
||||
|
||||
// our node might really be a document, so try that first
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aNode);
|
||||
if (!doc) {
|
||||
// we were not a document after all, get our ownerDocument
|
||||
nsCOMPtr<nsIDOMDocument> ownerDoc;
|
||||
aNode->GetOwnerDocument(getter_AddRefs(ownerDoc));
|
||||
// and turn it into an nsIDocument
|
||||
doc = do_QueryInterface(ownerDoc);
|
||||
}
|
||||
if (!scriptGlobal) {
|
||||
// our context might be a document (which also QIs to nsIDOMNode), so
|
||||
// try that first
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aContext);
|
||||
if (!doc) {
|
||||
// we were not a document after all, get our ownerDocument,
|
||||
// hopefully
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aContext);
|
||||
if (node) {
|
||||
nsCOMPtr<nsIDOMDocument> ownerDoc;
|
||||
node->GetOwnerDocument(getter_AddRefs(ownerDoc));
|
||||
// and turn it into an nsIDocument
|
||||
doc = do_QueryInterface(ownerDoc);
|
||||
}
|
||||
}
|
||||
|
||||
if (doc) {
|
||||
scriptGlobal = doc->GetScriptGlobalObject();
|
||||
if (doc) {
|
||||
scriptGlobal = doc->GetScriptGlobalObject();
|
||||
}
|
||||
}
|
||||
|
||||
if (!scriptGlobal) {
|
||||
|
@ -162,8 +162,9 @@ interface nsIContentPolicy : nsISupports
|
||||
* initiated this load request; can be null if
|
||||
* inapplicable
|
||||
*
|
||||
* @param aRequestingNode OPTIONAL. the DOM node that initiated the
|
||||
* request; can be null if inapplicable
|
||||
* @param aContext OPTIONAL. the nsIDOMNode or nsIDOMWindow that
|
||||
* initiated the request, or something that can QI
|
||||
* to one of those; can be null if inapplicable.
|
||||
*
|
||||
* @param aMimeTypeGuess OPTIONAL. a guess for the requested content's
|
||||
* MIME type, based on information available to
|
||||
@ -179,7 +180,7 @@ interface nsIContentPolicy : nsISupports
|
||||
short shouldLoad(in unsigned long aContentType,
|
||||
in nsIURI aContentLocation,
|
||||
in nsIURI aRequestOrigin,
|
||||
in nsIDOMNode aRequestingNode,
|
||||
in nsISupports aContext,
|
||||
in ACString aMimeTypeGuess,
|
||||
in nsISupports aExtra);
|
||||
|
||||
@ -200,8 +201,9 @@ interface nsIContentPolicy : nsISupports
|
||||
* initiated this load request; can be null if
|
||||
* inapplicable
|
||||
*
|
||||
* @param aRequestingNode OPTIONAL. the DOM node that initiated the
|
||||
* request; can be null if inapplicable
|
||||
* @param aContext OPTIONAL. the nsIDOMNode or nsIDOMWindow that
|
||||
* initiated the request, or something that can QI
|
||||
* to one of those; can be null if inapplicable.
|
||||
*
|
||||
* @param aMimeType the MIME type of the requested resource (e.g.,
|
||||
* image/png), as reported by the networking library,
|
||||
@ -216,7 +218,7 @@ interface nsIContentPolicy : nsISupports
|
||||
short shouldProcess(in unsigned long aContentType,
|
||||
in nsIURI aContentLocation,
|
||||
in nsIURI aRequestOrigin,
|
||||
in nsIDOMNode aRequestingNode,
|
||||
in nsISupports aContext,
|
||||
in ACString aMimeType,
|
||||
in nsISupports aExtra);
|
||||
|
||||
|
@ -46,6 +46,8 @@
|
||||
#include "nsContentPolicy.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsContentPolicy, nsIContentPolicy)
|
||||
|
||||
@ -156,7 +158,7 @@ nsContentPolicy::CheckPolicy(CPMethod policyMethod,
|
||||
PRUint32 contentType,
|
||||
nsIURI *contentLocation,
|
||||
nsIURI *requestingLocation,
|
||||
nsIDOMNode *requestingNode,
|
||||
nsISupports *requestingContext,
|
||||
const nsACString &mimeType,
|
||||
nsISupports *extra,
|
||||
PRInt16 *decision)
|
||||
@ -166,6 +168,15 @@ nsContentPolicy::CheckPolicy(CPMethod policyMethod,
|
||||
WARN_IF_URI_UNINITIALIZED(contentLocation, "Request URI");
|
||||
WARN_IF_URI_UNINITIALIZED(requestingLocation, "Requesting URI");
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(requestingContext));
|
||||
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(requestingContext));
|
||||
NS_ASSERTION(!requestingContext || node || window,
|
||||
"Context should be a DOM node or a DOM window!");
|
||||
}
|
||||
#endif
|
||||
|
||||
PRInt32 count = mPolicies.Count();
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@ -182,7 +193,7 @@ nsContentPolicy::CheckPolicy(CPMethod policyMethod,
|
||||
|
||||
/* check the appropriate policy */
|
||||
rv = (policy->*policyMethod)(contentType, contentLocation,
|
||||
requestingLocation, requestingNode,
|
||||
requestingLocation, requestingContext,
|
||||
mimeType, extra, decision);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && NS_CP_REJECTED(*decision)) {
|
||||
@ -235,7 +246,7 @@ NS_IMETHODIMP
|
||||
nsContentPolicy::ShouldLoad(PRUint32 contentType,
|
||||
nsIURI *contentLocation,
|
||||
nsIURI *requestingLocation,
|
||||
nsIDOMNode *requestingNode,
|
||||
nsISupports *requestingContext,
|
||||
const nsACString &mimeType,
|
||||
nsISupports *extra,
|
||||
PRInt16 *decision)
|
||||
@ -244,7 +255,7 @@ nsContentPolicy::ShouldLoad(PRUint32 contentType,
|
||||
NS_PRECONDITION(contentLocation, "Must provide request location");
|
||||
nsresult rv = CheckPolicy(&nsIContentPolicy::ShouldLoad, contentType,
|
||||
contentLocation, requestingLocation,
|
||||
requestingNode, mimeType, extra, decision);
|
||||
requestingContext, mimeType, extra, decision);
|
||||
LOG_CHECK("ShouldLoad");
|
||||
|
||||
return rv;
|
||||
@ -254,14 +265,14 @@ NS_IMETHODIMP
|
||||
nsContentPolicy::ShouldProcess(PRUint32 contentType,
|
||||
nsIURI *contentLocation,
|
||||
nsIURI *requestingLocation,
|
||||
nsIDOMNode *requestingNode,
|
||||
nsISupports *requestingContext,
|
||||
const nsACString &mimeType,
|
||||
nsISupports *extra,
|
||||
PRInt16 *decision)
|
||||
{
|
||||
nsresult rv = CheckPolicy(&nsIContentPolicy::ShouldProcess, contentType,
|
||||
contentLocation, requestingLocation,
|
||||
requestingNode, mimeType, extra, decision);
|
||||
requestingContext, mimeType, extra, decision);
|
||||
LOG_CHECK("ShouldProcess");
|
||||
|
||||
return rv;
|
||||
|
@ -59,14 +59,14 @@ class nsContentPolicy : public nsIContentPolicy
|
||||
typedef
|
||||
NS_STDCALL_FUNCPROTO(nsresult, CPMethod, nsIContentPolicy,
|
||||
ShouldProcess,
|
||||
(PRUint32, nsIURI*, nsIURI*, nsIDOMNode*,
|
||||
(PRUint32, nsIURI*, nsIURI*, nsISupports*,
|
||||
const nsACString &, nsISupports*, PRInt16*));
|
||||
|
||||
//Helper method that applies policyMethod across all policies in mPolicies
|
||||
// with the given parameters
|
||||
nsresult CheckPolicy(CPMethod policyMethod, PRUint32 contentType,
|
||||
nsIURI *aURI, nsIURI *origURI,
|
||||
nsIDOMNode *requestingNode,
|
||||
nsISupports *requestingContext,
|
||||
const nsACString &mimeGuess, nsISupports *extra,
|
||||
PRInt16 *decision);
|
||||
};
|
||||
|
@ -1656,13 +1656,11 @@ nsContentUtils::CanLoadImage(nsIURI* aURI, nsISupports* aContext,
|
||||
nsIURI *docURI = aLoadingDocument->GetDocumentURI();
|
||||
|
||||
PRInt16 decision = nsIContentPolicy::ACCEPT;
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(aContext));
|
||||
//don't care if node is null -- just pass null on if it is
|
||||
|
||||
nsresult rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_IMAGE,
|
||||
aURI,
|
||||
docURI,
|
||||
node,
|
||||
aContext,
|
||||
EmptyCString(), //mime guess
|
||||
nsnull, //extra
|
||||
&decision);
|
||||
@ -1670,6 +1668,7 @@ nsContentUtils::CanLoadImage(nsIURI* aURI, nsISupports* aContext,
|
||||
return NS_FAILED(rv) ? PR_FALSE : NS_CP_ACCEPTED(decision);
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::LoadImage(nsIURI* aURI, nsIDocument* aLoadingDocument,
|
||||
nsIURI* aReferrer, imgIDecoderObserver* aObserver,
|
||||
|
@ -463,11 +463,10 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement,
|
||||
if (globalObject) {
|
||||
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
nsIURI *docURI = mDocument->GetDocumentURI();
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(aElement));
|
||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_SCRIPT,
|
||||
scriptURI,
|
||||
docURI,
|
||||
node,
|
||||
aElement,
|
||||
NS_LossyConvertUCS2toASCII(type),
|
||||
nsnull, //extra
|
||||
&shouldLoad);
|
||||
|
@ -935,13 +935,13 @@ CSSLoaderImpl::IsAlternate(const nsAString& aTitle)
|
||||
*
|
||||
* @param aSourceURI the uri of the document or parent sheet loading the sheet
|
||||
* @param aTargetURI the uri of the sheet to be loaded
|
||||
* @param aNode the node owning the sheet. This is the element or document
|
||||
* owning the stylesheet (possibly indirectly, for child sheets)
|
||||
* @param aContext the node owning the sheet. This is the element or document
|
||||
* owning the stylesheet (possibly indirectly, for child sheets)
|
||||
*/
|
||||
nsresult
|
||||
CSSLoaderImpl::CheckLoadAllowed(nsIURI* aSourceURI,
|
||||
nsIURI* aTargetURI,
|
||||
nsIDOMNode* aNode)
|
||||
nsISupports* aContext)
|
||||
{
|
||||
LOG(("CSSLoaderImpl::CheckLoadAllowed"));
|
||||
|
||||
@ -961,7 +961,7 @@ CSSLoaderImpl::CheckLoadAllowed(nsIURI* aSourceURI,
|
||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET,
|
||||
aTargetURI,
|
||||
aSourceURI,
|
||||
aNode,
|
||||
aContext,
|
||||
NS_LITERAL_CSTRING("text/css"),
|
||||
nsnull, //extra param
|
||||
&shouldLoad);
|
||||
@ -1687,12 +1687,11 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement,
|
||||
nsIURI *docURI = mDocument->GetDocumentURI();
|
||||
if (!docURI) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(aElement));
|
||||
if (!node) {
|
||||
node = do_QueryInterface(mDocument);
|
||||
nsISupports* context = aElement;
|
||||
if (!context) {
|
||||
context = mDocument;
|
||||
}
|
||||
|
||||
nsresult rv = CheckLoadAllowed(docURI, aURL, node);
|
||||
nsresult rv = CheckLoadAllowed(docURI, aURL, context);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
LOG((" Passed load check"));
|
||||
@ -1789,12 +1788,12 @@ CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet,
|
||||
topSheet->GetOwnerNode(getter_AddRefs(owningNode));
|
||||
}
|
||||
|
||||
if (!owningNode) {
|
||||
//failed to get owning node, revert to document
|
||||
owningNode = do_QueryInterface(mDocument);
|
||||
nsISupports* context = owningNode;
|
||||
if (!context) {
|
||||
context = mDocument;
|
||||
}
|
||||
|
||||
rv = CheckLoadAllowed(sheetURI, aURL, owningNode);
|
||||
|
||||
rv = CheckLoadAllowed(sheetURI, aURL, context);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
LOG((" Passed load check"));
|
||||
|
@ -50,7 +50,6 @@
|
||||
#define nsCSSLoader_h__
|
||||
|
||||
class CSSLoaderImpl;
|
||||
class nsIDOMNode;
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsIParser.h"
|
||||
@ -272,7 +271,7 @@ public:
|
||||
private:
|
||||
nsresult CheckLoadAllowed(nsIURI* aSourceURI,
|
||||
nsIURI* aTargetURI,
|
||||
nsIDOMNode* aContext);
|
||||
nsISupports* aContext);
|
||||
|
||||
|
||||
// For inline style, the aURI param is null, but the aLinkingContent
|
||||
|
@ -5124,10 +5124,14 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||
contentType = nsIContentPolicy::TYPE_DOCUMENT;
|
||||
}
|
||||
|
||||
nsISupports* context = requestingElement;
|
||||
if (!context) {
|
||||
context = mScriptGlobal;
|
||||
}
|
||||
rv = NS_CheckContentLoadPolicy(contentType,
|
||||
aURI,
|
||||
aReferrer,
|
||||
requestingElement,
|
||||
context,
|
||||
EmptyCString(), //mime guess
|
||||
nsnull, //extra
|
||||
&shouldLoad);
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
|
||||
nsWebBrowserContentPolicy::nsWebBrowserContentPolicy()
|
||||
@ -57,15 +56,15 @@ nsWebBrowserContentPolicy::~nsWebBrowserContentPolicy()
|
||||
NS_IMPL_ISUPPORTS1(nsWebBrowserContentPolicy, nsIContentPolicy)
|
||||
|
||||
static nsresult
|
||||
PerformPolicyCheck(PRUint32 contentType,
|
||||
nsIDOMNode *requestingNode,
|
||||
PRInt16 *decision)
|
||||
PerformPolicyCheck(PRUint32 contentType,
|
||||
nsISupports *requestingContext,
|
||||
PRInt16 *decision)
|
||||
{
|
||||
NS_PRECONDITION(decision, "Null out param");
|
||||
|
||||
*decision = nsIContentPolicy::ACCEPT;
|
||||
|
||||
nsIDocShell *shell = NS_CP_GetDocShellFromDOMNode(requestingNode);
|
||||
nsIDocShell *shell = NS_CP_GetDocShellFromContext(requestingContext);
|
||||
/* We're going to dereference shell, so make sure it isn't null */
|
||||
if (!shell)
|
||||
return NS_OK;
|
||||
@ -106,19 +105,19 @@ NS_IMETHODIMP
|
||||
nsWebBrowserContentPolicy::ShouldLoad(PRUint32 contentType,
|
||||
nsIURI *contentLocation,
|
||||
nsIURI *requestingLocation,
|
||||
nsIDOMNode *requestingNode,
|
||||
nsISupports *requestingContext,
|
||||
const nsACString &mimeGuess,
|
||||
nsISupports *extra,
|
||||
PRInt16 *shouldLoad)
|
||||
{
|
||||
return PerformPolicyCheck(contentType, requestingNode, shouldLoad);
|
||||
return PerformPolicyCheck(contentType, requestingContext, shouldLoad);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowserContentPolicy::ShouldProcess(PRUint32 contentType,
|
||||
nsIURI *contentLocation,
|
||||
nsIURI *requestingLocation,
|
||||
nsIDOMNode *requestingNode,
|
||||
nsISupports *requestingContext,
|
||||
const nsACString &mimeGuess,
|
||||
nsISupports *extra,
|
||||
PRInt16 *shouldProcess)
|
||||
@ -126,5 +125,5 @@ nsWebBrowserContentPolicy::ShouldProcess(PRUint32 contentType,
|
||||
*shouldProcess = nsIContentPolicy::ACCEPT;
|
||||
return NS_OK;
|
||||
//LATER:
|
||||
// return PerformPolicyCheck(contentType, requestingNode, shouldProcess);
|
||||
// return PerformPolicyCheck(contentType, requestingContext, shouldProcess);
|
||||
}
|
||||
|
@ -129,15 +129,15 @@ nsImgManager::PrefChanged(nsIPrefBranch *aPrefBranch,
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get the root DocShell given a DOMNode
|
||||
* Helper function to get the root DocShell given a context
|
||||
*
|
||||
* @param aNode a DOMNode (cannot be null)
|
||||
* @return the root DocShell containing the DOMNode, if found
|
||||
* @param aContext The context (can be null)
|
||||
* @return the root DocShell containing aContext, if found
|
||||
*/
|
||||
static inline already_AddRefed<nsIDocShell>
|
||||
GetRootDocShell(nsIDOMNode *node)
|
||||
GetRootDocShell(nsISupports *context)
|
||||
{
|
||||
nsIDocShell *docshell = NS_CP_GetDocShellFromDOMNode(node);
|
||||
nsIDocShell *docshell = NS_CP_GetDocShellFromContext(context);
|
||||
if (!docshell)
|
||||
return nsnull;
|
||||
|
||||
@ -161,7 +161,7 @@ GetRootDocShell(nsIDOMNode *node)
|
||||
NS_IMETHODIMP nsImgManager::ShouldLoad(PRUint32 aContentType,
|
||||
nsIURI *aContentLocation,
|
||||
nsIURI *aRequestingLocation,
|
||||
nsIDOMNode *aRequestingNode,
|
||||
nsISupports *aRequestingContext,
|
||||
const nsACString &aMimeGuess,
|
||||
nsISupports *aExtra,
|
||||
PRInt16 *aDecision)
|
||||
@ -195,7 +195,7 @@ NS_IMETHODIMP nsImgManager::ShouldLoad(PRUint32 aContentType,
|
||||
if (!needToCheck)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDocShell> docshell(GetRootDocShell(aRequestingNode));
|
||||
nsCOMPtr<nsIDocShell> docshell(GetRootDocShell(aRequestingContext));
|
||||
if (docshell) {
|
||||
PRUint32 appType;
|
||||
rv = docshell->GetAppType(&appType);
|
||||
@ -222,16 +222,16 @@ NS_IMETHODIMP nsImgManager::ShouldLoad(PRUint32 aContentType,
|
||||
NS_IMETHODIMP nsImgManager::ShouldProcess(PRUint32 aContentType,
|
||||
nsIURI *aContentLocation,
|
||||
nsIURI *aRequestingLocation,
|
||||
nsIDOMNode *aRequestingNode,
|
||||
nsISupports *aRequestingContext,
|
||||
const nsACString &aMimeGuess,
|
||||
nsISupports *aExtra,
|
||||
PRInt16 *aDecision)
|
||||
{
|
||||
// For loads where aRequestingNode is chrome, we should just accept. Those
|
||||
// are most likely toplevel loads in windows, and chrome generally knows
|
||||
// what it's doing anyway.
|
||||
// For loads where aRequestingContext is chrome, we should just
|
||||
// accept. Those are most likely toplevel loads in windows, and
|
||||
// chrome generally knows what it's doing anyway.
|
||||
nsCOMPtr<nsIDocShellTreeItem> item =
|
||||
do_QueryInterface(NS_CP_GetDocShellFromDOMNode(aRequestingNode));
|
||||
do_QueryInterface(NS_CP_GetDocShellFromContext(aRequestingContext));
|
||||
|
||||
if (item) {
|
||||
PRInt32 type;
|
||||
@ -245,7 +245,7 @@ NS_IMETHODIMP nsImgManager::ShouldProcess(PRUint32 aContentType,
|
||||
// This isn't a load from chrome. Just do a ShouldLoad() check --
|
||||
// we want the same answer here
|
||||
return ShouldLoad(aContentType, aContentLocation, aRequestingLocation,
|
||||
aRequestingNode, aMimeGuess, aExtra, aDecision);
|
||||
aRequestingContext, aMimeGuess, aExtra, aDecision);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1253,8 +1253,6 @@ nsObjectFrame::InstantiatePlugin(nsIPresContext* aPresContext,
|
||||
if(aURI)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(mContent, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
rv = aPresContext->PresShell()->GetDocument(getter_AddRefs(document));
|
||||
@ -1270,7 +1268,7 @@ nsObjectFrame::InstantiatePlugin(nsIPresContext* aPresContext,
|
||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT,
|
||||
aURI,
|
||||
docURI,
|
||||
domNode,
|
||||
mContent,
|
||||
nsDependentCString(aMimetype ? aMimetype : ""),
|
||||
nsnull, //extra
|
||||
&shouldLoad);
|
||||
|
@ -1253,8 +1253,6 @@ nsObjectFrame::InstantiatePlugin(nsIPresContext* aPresContext,
|
||||
if(aURI)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(mContent, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
rv = aPresContext->PresShell()->GetDocument(getter_AddRefs(document));
|
||||
@ -1270,7 +1268,7 @@ nsObjectFrame::InstantiatePlugin(nsIPresContext* aPresContext,
|
||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT,
|
||||
aURI,
|
||||
docURI,
|
||||
domNode,
|
||||
mContent,
|
||||
nsDependentCString(aMimetype ? aMimetype : ""),
|
||||
nsnull, //extra
|
||||
&shouldLoad);
|
||||
|
@ -935,13 +935,13 @@ CSSLoaderImpl::IsAlternate(const nsAString& aTitle)
|
||||
*
|
||||
* @param aSourceURI the uri of the document or parent sheet loading the sheet
|
||||
* @param aTargetURI the uri of the sheet to be loaded
|
||||
* @param aNode the node owning the sheet. This is the element or document
|
||||
* owning the stylesheet (possibly indirectly, for child sheets)
|
||||
* @param aContext the node owning the sheet. This is the element or document
|
||||
* owning the stylesheet (possibly indirectly, for child sheets)
|
||||
*/
|
||||
nsresult
|
||||
CSSLoaderImpl::CheckLoadAllowed(nsIURI* aSourceURI,
|
||||
nsIURI* aTargetURI,
|
||||
nsIDOMNode* aNode)
|
||||
nsISupports* aContext)
|
||||
{
|
||||
LOG(("CSSLoaderImpl::CheckLoadAllowed"));
|
||||
|
||||
@ -961,7 +961,7 @@ CSSLoaderImpl::CheckLoadAllowed(nsIURI* aSourceURI,
|
||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET,
|
||||
aTargetURI,
|
||||
aSourceURI,
|
||||
aNode,
|
||||
aContext,
|
||||
NS_LITERAL_CSTRING("text/css"),
|
||||
nsnull, //extra param
|
||||
&shouldLoad);
|
||||
@ -1687,12 +1687,11 @@ CSSLoaderImpl::LoadStyleLink(nsIContent* aElement,
|
||||
nsIURI *docURI = mDocument->GetDocumentURI();
|
||||
if (!docURI) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(aElement));
|
||||
if (!node) {
|
||||
node = do_QueryInterface(mDocument);
|
||||
nsISupports* context = aElement;
|
||||
if (!context) {
|
||||
context = mDocument;
|
||||
}
|
||||
|
||||
nsresult rv = CheckLoadAllowed(docURI, aURL, node);
|
||||
nsresult rv = CheckLoadAllowed(docURI, aURL, context);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
LOG((" Passed load check"));
|
||||
@ -1789,12 +1788,12 @@ CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet,
|
||||
topSheet->GetOwnerNode(getter_AddRefs(owningNode));
|
||||
}
|
||||
|
||||
if (!owningNode) {
|
||||
//failed to get owning node, revert to document
|
||||
owningNode = do_QueryInterface(mDocument);
|
||||
nsISupports* context = owningNode;
|
||||
if (!context) {
|
||||
context = mDocument;
|
||||
}
|
||||
|
||||
rv = CheckLoadAllowed(sheetURI, aURL, owningNode);
|
||||
|
||||
rv = CheckLoadAllowed(sheetURI, aURL, context);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
LOG((" Passed load check"));
|
||||
|
@ -50,7 +50,6 @@
|
||||
#define nsCSSLoader_h__
|
||||
|
||||
class CSSLoaderImpl;
|
||||
class nsIDOMNode;
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsIParser.h"
|
||||
@ -272,7 +271,7 @@ public:
|
||||
private:
|
||||
nsresult CheckLoadAllowed(nsIURI* aSourceURI,
|
||||
nsIURI* aTargetURI,
|
||||
nsIDOMNode* aContext);
|
||||
nsISupports* aContext);
|
||||
|
||||
|
||||
// For inline style, the aURI param is null, but the aLinkingContent
|
||||
|
@ -121,7 +121,7 @@ NS_IMETHODIMP
|
||||
nsMsgContentPolicy::ShouldLoad(PRUint32 aContentType,
|
||||
nsIURI *aContentLocation,
|
||||
nsIURI *aRequestingLocation,
|
||||
nsIDOMNode *aRequestingNode,
|
||||
nsISupports *aRequestingContext,
|
||||
const nsACString &aMimeGuess,
|
||||
nsISupports *aExtra,
|
||||
PRInt16 *aDecision)
|
||||
@ -234,7 +234,7 @@ NS_IMETHODIMP
|
||||
nsMsgContentPolicy::ShouldProcess(PRUint32 aContentType,
|
||||
nsIURI *aContentLocation,
|
||||
nsIURI *aRequestingLocation,
|
||||
nsIDOMNode *aRequestingNode,
|
||||
nsISupports *aRequestingContext,
|
||||
const nsACString &aMimeGuess,
|
||||
nsISupports *aExtra,
|
||||
PRInt16 *aDecision)
|
||||
|
Loading…
Reference in New Issue
Block a user