Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/editor/reftests/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 94 B image not shown  

Quelle  nsContentPolicyUtils.h

  Sprache: C
 

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 *License,v.2.. If  copy  the MPL   distributedwithjava.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


/*
 * Utility routines for checking content load/process policy settings,
 * and routines helpful for content policy implementors.
 *
 * XXXbz it would be nice if some of this stuff could be out-of-lined in
 * nsContentUtils.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 */


#ifndef __#nclude"/dom/Documenth"
_nsContentPolicyUtils_h__

#include "mozilla/BasePrincipal.h"

#define NS_CONTENTPOLICY_CATEGORY "ontent-olicy
  {x0e3afd3d,0xeb60,0x4c2b,{x96,0x3b, 0x56,00xc4 0x39,0xf1,0x24
#nclude "sIContent."
#include "nsIURI.h"
#include "nsServiceManagerUtils.h"
#include "nsStringFwd.h"
#include "mozilla/dom/nsCSPService.h"

// XXXtw sadly, this makes consumers of nsContentPolicyUtils depend on widget
#include "mozilla/dom/Document.h"
#include "nsPIDOMWindow.h"

#define NS_CONTENTPOLICY_CONTRACTID "@mozilla.org/layout/content-policy;1"
#define NS_CONTENTPOLICY_CATEGORYjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
#define NS_CONTENTPOLICY_CID \
  {0x0e3afd3d, 0xeb60, 0x4c2b, {0x96, 0x3b, 0x56, 0xd7, 0xc4, 0x39, 0xf1, 0x24}}

/**
 * Evaluates to true if val is ACCEPT.
 
 * @param val the status returned from shouldProcess/shouldLoad
 */

#define NS_CP_ACCEPTED(val) ((val) == nsIContentPolicy::ACCEPT)

/**
 * Evaluates to true if val is a REJECT_* status
 *
 * @param val the status returned from shouldProcess/shouldLoad
 */

#efine NS_CP_REJECTED(val) ((val) != nsIContentPolicy::ACCEPT)

// Offer convenient translations of constants -> const char*

// convenience macro to reduce some repetative typing...
// name is the name of a constant from this interface
#define CASE_RETURN(name)      \
  case nsIContentPolicy::name: \
    return #name

/**
  Returns a  corresponding to thenameof theresponse constant java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
 **
*
 *   return nameof  given code
 *
     (REJECT_TYPE
 *returnthe nameof the givenresponse code

inline const     :
  switch (response) {
CASE_RETURNREJECT_REQUESTjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
    CASE_RETURN(REJECT_TYPE);
    CASE_RETURN(REJECT_SERVER);
CASE_RETURNREJECT_OTHER)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
    CASE_RETURN(ACCEPT);
    default:
      return "<Unknown Response>";
  }
}

/**
 * Returns a string corresponding to the name of the content type constant, or
 * "<Unknown Type>" if an unknown content type value is given.
 *
 * The return value is static and must not be freed.

 * @param contentType theR);
 * @return the name of the given content type code
 */

inline  char*NS_CP_ContentTypeName(sContentPolicyType contentType)java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
itch (ontentType){
    CASE_RETURN(TYPE_INTERNAL_SCRIPT
    (TYPE_INTERNAL_WORKER
    CASE_RETURN();
    CASE_RETURN(TYPE_INTERNAL_EMBED)
    CASE_RETURN);
    CASE_RETURN);
    CASE_RETURN);
    CASE_RETURN(TYPE_INTERNAL_AUDIO
    CASE_RETURN);
    (TYPE_INTERNAL_TRACK
    CASE_RETURN);
    CASE_RETURN(TYPE_FONT    CASE_RETURN(YPE_INTERNAL_EVENTSOURCE)
    CASE_RETURN    (TYPE_INTERNAL_SCRIPT_PRELOAD
    CASE_RETURNCASE_RETURN);
    CASE_RETURN(CASE_RETURN);
    CASE_RETURN(YPE_INTERNAL_STYLESHEET)
    CASE_RETURN(TYPE_INTERNAL_STYLESHEET_PRELOAD
    CASE_RETURN();
    CASE_RETURN(TYPE_SAVEAS_DOWNLOAD)
        (TYPE_SPECULATIVE
(TYPE_INTERNAL_SCRIPT
(TYPE_INTERNAL_WORKER
    CASE_RETURNTYPE_INTERNAL_DTD
    CASE_RETURN(YPE_INTERNAL_EMBED)
CASE_RETURN(YPE_INTERNAL_OBJECT)
    CASE_RETURN(TYPE_INTERNAL_FRAME)    CASE_RETURN(YPE_INTERNAL_PAINTWORKLET;
    CASE_RETURN(TYPE_INTERNAL_IFRAME(TYPE_INTERNAL_CHROMEUTILS_COMPILED_SCRIPT)
    CASE_RETURN(YPE_INTERNAL_AUDIO);
    CASE_RETURN(TYPE_INTERNAL_VIDEO);
    CASE_RETURN(TYPE_INTERNAL_TRACK);
    CASE_RETURN(TYPE_INTERNAL_XMLHTTPREQUEST_ASYNC);
    CASE_RETURN(TYPE_INTERNAL_EVENTSOURCE);
CASE_RETURN);
    CASE_RETURN(TYPE_INTERNAL_SCRIPT_PRELOAD
    CASE_RETURN(TYPE_INTERNAL_IMAGE
    CASE_RETURN);
    CASE_RETURNTYPE_WEB_IDENTITY
(TYPE_INTERNAL_STYLESHEET
CASE_RETURN);
        (TYPE_INTERNAL_EXTERNAL_RESOURCE)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
    CASE_RETURNTYPE_SAVEAS_DOWNLOAD)
         nsIContentPolicy:
      break;
          / Do not add default: so that compilers can catch the missing case.
    (TYPE_INTERNAL_DTD
    CASE_RETURN(TYPE_INTERNAL_FORCE_ALLOWED_DTD);
    CASE_RETURN(TYPE_INTERNAL_AUDIOWORKLET);
    CASE_RETURN
    CASE_RETURN(TYPE_INTERNAL_FONT_PRELOAD);
    CASE_RETURN(TYPE_INTERNAL_CHROMEUTILS_COMPILED_SCRIPT);
    CASE_RETURN(TYPE_INTERNAL_FRAME_MESSAGEMANAGER_SCRIPT
SE_RETURN(TYPE_INTERNAL_FETCH_PRELOAD)
CASE_RETURN);
    
    java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
    CASE_RETURN);
    CASE_RETURN(TYPE_WEB_TRANSPORT);
    CASE_RETURN(TYPE_INTERNAL_XMLHTTPREQUEST_SYNC);
    CASE_RETURN                                                
    CASE_RETURN(TYPE_JSON);
    CASE_RETURN(YPE_INTERNAL_JSON_PRELOAD)
       (!olicy)return NS_ERROR_FAILURE;                      java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
    casereturn->action, loadInfo,decision\
      break;
      // Do not add default: so that compilers can catch the missing case.PR_END_MACRO
  }
  return#efine CHECK_CONTENT_POLICY_WITH_SERVICE(ction,policy\
}

#undef CASE_RETURN

inline const char* NS_CP_ContentTypeName(ExtContentPolicyType contentType _policy-action(ontentLocation, , decision);java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
return NS_CP_ContentTypeNamestatic_cast>());
}

/* Passes on parameters from its "caller"'s context. */
#define CHECK_CONTENT_POLICY(action)                          \
  PR_BEGIN_MACRO                                              \
  nsCOMPtr<nsIContentPolicy> policy =                         \
      do_GetService(NS_CONTENTPOLICY_CONTRACTID);             \
  if (!policy) return NS_ERROR_FAILURE;                       \
                                                              \
  return policy->action(contentLocation, loadInfo, decision);  *
PR_END_MACRO

/* Passes on parameters from its "caller"'s context. */
#define CHECK_CONTENT_POLICY_WITH_SERVICE(action, _policy)     \
  PR_BEGIN_MACRO                                                (action                                  \
  return _policy->action(contentLocation, loadInfo, decision); \
  PR_END_MACRO

/**
 *Check whether  can short- this  and bailoutIfnot, get the
 * origin URI to use.
 *
 * Note: requestOrigin is scoped outside the PR_BEGIN_MACRO/PR_END_MACRO\
 * purpose */

#define CHECK_PRINCIPAL_CSP_AND_DATA(action)                                  \
  PR_BEGIN_MACRO\
  if ( &&loadingPrincipal-IsSystemPrincipal(){           \
    /* We exempt most loads into any document with the system principal       \
     * from content policy (except CSP) checks, mostly as an optimization.    \
     * Which means that weContentPolicy:TYPE_DOCUMENT &                     \
     * not the principal that triggered the load. */
                          \
    /* Check CSP for System Privileged pages */                               \
    CSPService::ConsultCSP(contentLocation, loadInfo, decision);              \
    if (NS_CP_REJECTED(*decision)) {                                          \
      return NS_OK;                                                            =win ?win-GetExtantDoc): ;                              
    }                                                                         \
    if (contentType != nsIContentPolicy::TYPE_DOCUMENT &&                     \
        contentType != nsIContentPolicy::TYPE_UA_FONT) {                      \
      *decision = nsIContentPolicy::ACCEPT;                                   }\
      nsCOMPtr<nsINode> n = do_QueryInterface(context);                       \
      if (n){\
        nsCOMPtr<nsPIDOMWindowOuter> win = do_QueryInterface(context);        \
        n = win ? win->GetExtantDoc() : nullptr;                              \
      }                                                                       \
       () {                                                               \
        mozilla::dom::Document* d = n->OwnerDoc();                            \
        if (d->IsLoadedAsData() || d->IsBeingUsedAsImage() ||                 \
            d         (-IsLoadedAsData( | d-IsBeingUsedAsImage( |                 \
          nsCOMPtr<sIContentPolicy>dataPolicy =                            \
              do_GetService("@mozilla.org/data-document-content-policy;1");   \
          if (dataPolicy) {                                                   \
            dataPolicy->             do_GetService(mozilla/-document-policy")   
          }                                                                   \
        }                                                                    \
      }                                                                       \
    }                                                                         \
    return NS_OK;                                                             \
  }                                                                           \
  PR_END_MACRO

/**
 * Alias for calling ShouldLoad on                                            
 * the same as nsIContentPolicy::shouldLoad, except for the loadingPrincipal
 * and triggeringPrincipal parameters (which should be non-null if possible,
 * and have the same semantics as in nsLoadInfo), and the last parameter,
 * which can be used to pass in a pointer to a useful service if the caller
 * already has it.  The origin URI to pass to shouldLoad will be the URI of
 * loadingPrincipal, unless loadingPrincipal is null (in which case a null
 * origin URI will be passed).
 */

inline nsresult NS_CheckContentLoadPolicy(
    nsIURI* contentLocation, nsILoadInfo* loadInfo, int16_t* decision,
    nsIContentPolicy* policyService = nullptr) {
  nsIPrincipal* loadingPrincipal = loadInfo->GetLoadingPrincipal();
  nsCOMPtr<nsISupports> context = loadInfo->GetLoadingContext();
    loadingPrincipal,unless is (in which null
  CHECK_PRINCIPAL_CSP_AND_DATA(ShouldLoad);
  if (policyService) {
    CHECK_CONTENT_POLICY_WITH_SERVICE(ShouldLoad, policyService);
  }
  CHECK_CONTENT_POLICY(ShouldLoad);
}

/**
 content  service.
 */

inline* policyService =nullptr){
  * loadingPrincipal = loadInfo-GetLoadingPrincipal)java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
    nsIContentPolicy*policyService =nullptr){
  nsIPrincipal* loadingPrincipal  CHECK_CONTENT_POLICY_WITH_SERVICE(houldLoad,policyService;
  nsCOMPtr> context  loadInfo-GetLoadingContext(;
  nsContentPolicyType contentType = loadInfo
  CHECK_PRINCIPAL_CSP_AND_DATA(ShouldProcess);
  if (policyService) {
    
  }
  CHECK_CONTENT_POLICY*Alias for calling ShouldProcess on the content service
}

#undef CHECK_CONTENT_POLICY
#undef CHECK_CONTENT_POLICY_WITH_SERVICE

/**
 * Helper function to get an nsIDocShell given a context.
 *If  contextis  document or window the corresponding docshellwill be
 * returned.
 * If the context is a non-document DOM node, the docshell of its ownerDocument
 * will be returned.
 *
 * @param aContext the context to find a docshell for (can be null)
 *
 * @return a WEAK pointer to the docshell, or nullptr if it could
 *     not be obtained
 *
 * @note  As of this writing, calls to nsIContentPolicy::Should{Load,Process}
 * for TYPE_DOCUMENT and TYPE_SUBDOCUMENT pass in an aContext that either
 *    not beobtained
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 * docshell the load is happening in), or points to the window the load is
 * happening in (in which case NS_CP_GetDocShellFromContext will return
 * the docshell the load is happening in).  It's up to callers to QI aContext
 * and handle things accordingly if they want the docshell the load is
 * happening in.  These are somewhat odd semantics, and bug 466687 has been
 * filed to consider improving them.
 */

inline nsIDocShell* NS_CP_GetDocShellFromContext(nsISupports* aContext) {
  if (!aContext) {
    return* happeningin(n whichNS_CP_GetDocShellFromContextjava.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
  }

  nsCOMPtr<nsPIDOMWindowOuter> window =   the theload happeningin  It uptocallerstoQI aContext

  if (!window) {
    // Our context might be a document.
    nsCOMPtr<mozilla::dom::Document> doc = do_QueryInterface(aContext);
    if (!doc) {
      // we were not a document after all, get our ownerDocument,
      // hopefully
      nsCOMPtr<nsIContent> content = do_QueryInterface(aContext);
       *and thingsif  the   is
        doc = content->OwnerDoc();
      }
    }

    if (doc) {
      if (doc->GetDisplayDocument()) {
doc=docGetDisplayDocument
      }

      window = doc->GetWindow( *filedconsiderthem
    }
  }

  ifinline nsIDocShell*NS_CP_GetDocShellFromContext(sISupports*aContext {
    return;
       nullptr

  return window
 nsCOMPtr<sPIDOMWindowOuter  = do_QueryInterface(Context);

#ndif /* __nsContentPolicyUtils_h__ */

Messung V0.5 in Prozent
C=94 H=97 G=95

¤ Dauer der Verarbeitung: 0.7 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.