Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
nsContentPolicyUtils.h File Reference
#include "prlog.h"
#include "nsString.h"
#include "nsIContentPolicy.h"
#include "nsIMemory.h"
#include "nsIServiceManager.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIScriptGlobalObject.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define NS_CONTENTPOLICY_CONTRACTID   "@mozilla.org/layout/content-policy;1"
#define NS_CONTENTPOLICY_CATEGORY   "content-policy"
#define NS_CONTENTPOLICY_CID
#define NS_CP_ACCEPTED(val)   ((val) == nsIContentPolicy::ACCEPT)
 Evaluates to true if val is ACCEPT.
#define NS_CP_REJECTED(val)   ((val) != nsIContentPolicy::ACCEPT)
 Evaluates to true if val is a REJECT_* status.
#define CASE_RETURN(name)
#define CHECK_CONTENT_POLICY(action)

Functions

nsresult NS_CheckContentLoadPolicy (PRUint32 contentType, nsIURI *contentLocation, nsIURI *requestOrigin, nsISupports *context, const nsACString &mimeType, nsISupports *extra, PRInt16 *decision)
 Alias for calling ShouldLoad on the content policy service.
nsresult NS_CheckContentProcessPolicy (PRUint32 contentType, nsIURI *contentLocation, nsIURI *requestOrigin, nsISupports *context, const nsACString &mimeType, nsISupports *extra, PRInt16 *decision)
 Alias for calling ShouldProcess on the content policy service.
static nsIDocShellNS_CP_GetDocShellFromContext (nsISupports *aContext)
 Helper function to get an nsIDocShell given a context.

Define Documentation

Value:
case nsIContentPolicy:: name :   \
    return #name

Definition at line 84 of file nsContentPolicyUtils.h.

Value:
nsCOMPtr<nsIContentPolicy> policy =                                       \
         do_GetService(NS_CONTENTPOLICY_CONTRACTID);                          \
    if (!policy)                                                              \
        return NS_ERROR_FAILURE;                                              \
                                                                              \
    return policy-> action (contentType, contentLocation, requestOrigin,      \
                            context, mimeType, extra, decision);

Definition at line 143 of file nsContentPolicyUtils.h.

#define NS_CONTENTPOLICY_CATEGORY   "content-policy"

Definition at line 61 of file nsContentPolicyUtils.h.

Value:
{0x0e3afd3d, 0xeb60, 0x4c2b,                            \
     { 0x96, 0x3b, 0x56, 0xd7, 0xc4, 0x39, 0xf1, 0x24 }}

Definition at line 62 of file nsContentPolicyUtils.h.

#define NS_CONTENTPOLICY_CONTRACTID   "@mozilla.org/layout/content-policy;1"

Definition at line 60 of file nsContentPolicyUtils.h.

Evaluates to true if val is ACCEPT.

Parameters:
valthe status returned from shouldProcess/shouldLoad

Definition at line 71 of file nsContentPolicyUtils.h.

Evaluates to true if val is a REJECT_* status.

Parameters:
valthe status returned from shouldProcess/shouldLoad

Definition at line 78 of file nsContentPolicyUtils.h.


Function Documentation

nsresult NS_CheckContentLoadPolicy ( PRUint32  contentType,
nsIURI contentLocation,
nsIURI requestOrigin,
nsISupports *  context,
const nsACString &  mimeType,
nsISupports *  extra,
PRInt16 decision 
) [inline]

Alias for calling ShouldLoad on the content policy service.

Parameters are the same as nsIContentPolicy::shouldLoad.

Definition at line 157 of file nsContentPolicyUtils.h.

{
    CHECK_CONTENT_POLICY(ShouldLoad);
}

Here is the caller graph for this function:

nsresult NS_CheckContentProcessPolicy ( PRUint32  contentType,
nsIURI contentLocation,
nsIURI requestOrigin,
nsISupports *  context,
const nsACString &  mimeType,
nsISupports *  extra,
PRInt16 decision 
) [inline]

Alias for calling ShouldProcess on the content policy service.

Parameters are the same as nsIContentPolicy::shouldProcess.

Definition at line 173 of file nsContentPolicyUtils.h.

{
    CHECK_CONTENT_POLICY(ShouldProcess);
}
static nsIDocShell* NS_CP_GetDocShellFromContext ( nsISupports *  aContext) [static]

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.

Parameters:
aContextthe context to find a docshell for (can be null)
Returns:
a WEAK pointer to the docshell, or nsnull if it could not be obtained

Definition at line 198 of file nsContentPolicyUtils.h.

{
    if (!aContext) {
        return nsnull;
    }

    nsCOMPtr<nsIScriptGlobalObject> scriptGlobal = do_QueryInterface(aContext);

    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<nsIContent> content = do_QueryInterface(aContext);
            if (content) {
                doc = content->GetOwnerDoc();
            }
        }

        if (doc) {
            scriptGlobal = doc->GetScriptGlobalObject();
        }
    }

    if (!scriptGlobal) {
        return nsnull;
    }

    return scriptGlobal->GetDocShell();
}

Here is the call graph for this function:

Here is the caller graph for this function: