DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (d8847129d134)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * vim: ft=cpp tw=78 sw=2 et ts=2 sts=2 cin
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"
#include "nsIContentPolicy.idl"

interface nsIDOMDocument;
interface nsINode;
interface nsIPrincipal;
interface nsIURI;

typedef unsigned long nsSecurityFlags;

/**
 * An nsILoadOwner represents per-load information about who started the load.
 */
[scriptable, builtinclass, uuid(768a1f20-57d4-462a-812a-41c04e5d1e19)]
interface nsILoadInfo : nsISupports
{
  /**
   * No special security flags:
   */
  const unsigned long SEC_NORMAL = 0;

  /**
   * Force inheriting of the Principal. The resulting resource will use the
   * principal of the document which is doing the load. Setting this flag
   * will cause GetChannelResultPrincipal to return the same principal as
   * the loading principal that's passed in when creating the channel.
   *
   * This will happen independently of the scheme of the URI that the
   * channel is loading.
   *
   * So if the loading document comes from "http://a.com/", and the channel
   * is loading the URI "http://b.com/whatever", GetChannelResultPrincipal
   * will return a principal from "http://a.com/".
   *
   * This flag can not be used together with SEC_SANDBOXED.
   */
  const unsigned long SEC_FORCE_INHERIT_PRINCIPAL = 0x01;

  /**
   * Sandbox the load. The resulting resource will use a freshly created
   * null principal. So GetChannelResultPrincipal will always return a
   * null principal whenever this flag is set.
   *
   * This will happen independently of the scheme of the URI that the
   * channel is loading.
   *
   * This flag can not be used together with SEC_FORCE_INHERIT_PRINCIPAL.
   */
  const unsigned long SEC_SANDBOXED = 0x02;

  /**
   * The loadingPrincipal is the principal that is responsible for the load.
   * It is *NOT* the principal tied to the resource/URI that this
   * channel is loading, it's the principal of the resource's
   * caller or requester. For example, if this channel is loading
   * an image from http://b.com that is embedded in a document
   * who's origin is http://a.com, the loadingPrincipal is http://a.com.
   *
   * The loadingPrincipal will never be null.
   */
  readonly attribute nsIPrincipal loadingPrincipal;

  /**
   * A C++-friendly version of loadingPrincipal.
   */
  [noscript, notxpcom, nostdcall, binaryname(LoadingPrincipal)]
  nsIPrincipal binaryLoadingPrincipal();

  /**
   * The triggeringPrincipal is the principal that triggerd the load.
   * Most likely the triggeringPrincipal and the loadingPrincipal are the same,
   * in which case triggeringPrincipal returns the loadingPrincipal.
   * In some cases the loadingPrincipal and the triggeringPrincipal are different
   * however, e.g. a stylesheet may import a subresource. In that case the
   * stylesheet principal is the triggeringPrincipal and the document that loads
   * the stylesheet provides a loadingContext and hence the loadingPrincipal.
   *
   * If triggeringPrincipal and loadingPrincipal are the same, then
   * triggeringPrincipal returns loadingPrincipal.
   */
  readonly attribute nsIPrincipal triggeringPrincipal;

  /**
   * A C++-friendly version of triggeringPrincipal.
   */
  [noscript, notxpcom, nostdcall, binaryname(TriggeringPrincipal)]
  nsIPrincipal binaryTriggeringPrincipal();

  /**
   * The loadingDocument of the channel.
   *
   * The loadingDocument of a channel is the document that requested the
   * load of the resource. It is *not* the resource itself, it's the
   * resource's caller or requester in which the load is happening.
   *
   * <script> example: Assume a document who's origin is http://a.com embeds
   * a script from http://b.com. The loadingDocument for the channel
   * associated with the http://b.com script load is the document with origin
   * http://a.com
   *
   * <iframe> example: Assume a document with origin http://a.com embeds
   * <iframe src="http://b.com">. The loadingDocument for the channel associated
   * with the http://b.com network request is the document who's origin is
   * http://a.com. Now assume the iframe to http://b.com then further embeds
   * <script src="http://c.com">. The loadingDocument for the channel associated
   * with the http://c.com network request is the iframe with origin http://b.com.
   *
   * Warning: The loadingDocument can be null!
   */
  readonly attribute nsIDOMDocument loadingDocument;

  /**
   * A C++-friendly version of loadingDocument (loadingNode).
   * This is the node most proximally responsible for the load.
   */
  [noscript, notxpcom, nostdcall, binaryname(LoadingNode)]
  nsINode binaryLoadingNode();

  /**
   * The securityFlags of that channel.
   */
  readonly attribute nsSecurityFlags securityFlags;

%{ C++
  inline nsSecurityFlags GetSecurityFlags()
  {
    nsSecurityFlags result;
    mozilla::DebugOnly<nsresult> rv = GetSecurityFlags(&result);
    MOZ_ASSERT(NS_SUCCEEDED(rv));
    return result;
  }
%}

  /**
   * If forceInheritPrincipal is true, the data coming from the channel should
   * use loadingPrincipal for its principal, even when the data is loaded over
   * http:// or another protocol that would normally use a URI-based principal.
   * This attribute will never be true when loadingSandboxed is true.
   */
  [infallible] readonly attribute boolean forceInheritPrincipal;

  /**
   * If loadingSandboxed is true, the data coming from the channel is
   * being loaded sandboxed, so it should have a nonce origin and
   * hence should use a NullPrincipal.
   */
  [infallible] readonly attribute boolean loadingSandboxed;

  /**
   * The contentPolicyType of the channel, used for security checks
   * like Mixed Content Blocking and Content Security Policy.
   */
  readonly attribute nsContentPolicyType contentPolicyType;

%{ C++
  inline nsContentPolicyType GetContentPolicyType()
  {
    nsContentPolicyType result;
    mozilla::DebugOnly<nsresult> rv = GetContentPolicyType(&result);
    MOZ_ASSERT(NS_SUCCEEDED(rv));
    return result;
  }
%}

  /**
   * A base URI for use in situations where it cannot otherwise be inferred.
   * This attribute may be null.  The value of this attribute may be
   * ignored if the base URI can be inferred by the channel's URI.
   */
  readonly attribute nsIURI baseURI;

  /**
   * A C++-friendly version of baseURI.
   */
  [noscript, notxpcom, nostdcall, binaryname(BaseURI)]
  nsIURI binaryBaseURI();

  /**
   * The innerWindowId of the loadingDocument, used to identify
   * the loadingDocument in e10s where the loadingDocument is
   * not available.
   *
   * Warning: If the loadingDocument is null, then the
   * innerWindowId is 0.
   */
  readonly attribute unsigned long innerWindowID;

%{ C++
  inline uint32_t GetInnerWindowID()
  {
    uint32_t result;
    mozilla::DebugOnly<nsresult> rv = GetInnerWindowID(&result);
    MOZ_ASSERT(NS_SUCCEEDED(rv));
    return result;
  }
%}
};