Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsWebBrowserContentPolicy.cpp File Reference
#include "nsWebBrowserContentPolicy.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDocShell.h"
#include "nsCOMPtr.h"
#include "nsContentPolicyUtils.h"

Go to the source code of this file.

Functions

static nsresult PerformPolicyCheck (PRUint32 contentType, nsISupports *requestingContext, PRInt16 *decision)

Function Documentation

static nsresult PerformPolicyCheck ( PRUint32  contentType,
nsISupports *  requestingContext,
PRInt16 decision 
) [static]

Definition at line 59 of file nsWebBrowserContentPolicy.cpp.

{
    NS_PRECONDITION(decision, "Null out param");

    *decision = nsIContentPolicy::ACCEPT;

    nsIDocShell *shell = NS_CP_GetDocShellFromContext(requestingContext);
    /* We're going to dereference shell, so make sure it isn't null */
    if (!shell)
        return NS_OK;

    nsresult rv;
    PRBool allowed = PR_TRUE;

    switch (contentType) {
      case nsIContentPolicy::TYPE_OBJECT:
        rv = shell->GetAllowPlugins(&allowed);
        break;
      case nsIContentPolicy::TYPE_SCRIPT:
        rv = shell->GetAllowJavascript(&allowed);
        break;
      case nsIContentPolicy::TYPE_SUBDOCUMENT:
        rv = shell->GetAllowSubframes(&allowed);
        break;
#if 0
      /* XXXtw: commented out in old code; add during conpol phase 2 */
      case nsIContentPolicy::TYPE_REFRESH:
        rv = shell->GetAllowMetaRedirects(&allowed); /* meta _refresh_ */
        break;
#endif
      case nsIContentPolicy::TYPE_IMAGE:
        rv = shell->GetAllowImages(&allowed);
        break;
      default:
        return NS_OK;
    }

    if (NS_SUCCEEDED(rv) && !allowed) {
        *decision = nsIContentPolicy::REJECT_TYPE;
    }
    return rv;
}

Here is the call graph for this function: