content/base/public/nsIContentPolicy.idl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ft=cpp tw=78 sw=2 et ts=8 : */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "nsISupports.idl"
michael@0 8
michael@0 9 interface nsIURI;
michael@0 10 interface nsIDOMNode;
michael@0 11 interface nsIPrincipal;
michael@0 12
michael@0 13 /**
michael@0 14 * The type of nsIContentPolicy::TYPE_*
michael@0 15 */
michael@0 16 typedef unsigned long nsContentPolicyType;
michael@0 17
michael@0 18 /**
michael@0 19 * Interface for content policy mechanism. Implementations of this
michael@0 20 * interface can be used to control loading of various types of out-of-line
michael@0 21 * content, or processing of certain types of in-line content.
michael@0 22 *
michael@0 23 * WARNING: do not block the caller from shouldLoad or shouldProcess (e.g.,
michael@0 24 * by launching a dialog to prompt the user for something).
michael@0 25 */
michael@0 26
michael@0 27 [scriptable,uuid(b6a71698-c117-441d-86b9-480cf06e3952)]
michael@0 28 interface nsIContentPolicy : nsISupports
michael@0 29 {
michael@0 30 /**
michael@0 31 * Gecko/Firefox developers: Do not use TYPE_OTHER under any circumstances.
michael@0 32 *
michael@0 33 * Extension developers: Whenever it is reasonable, use one of the existing
michael@0 34 * content types. If none of the existing content types are right for
michael@0 35 * something you are doing, file a bug in the Core/DOM component that
michael@0 36 * includes a patch that adds your new content type to the end of the list of
michael@0 37 * TYPE_* constants here. But, don't start using your new content type until
michael@0 38 * your patch has been accepted, because it will be uncertain what exact
michael@0 39 * value and name your new content type will have; in that interim period,
michael@0 40 * use TYPE_OTHER. In your patch, document your new content type in the style
michael@0 41 * of the existing ones. In the bug you file, provide a more detailed
michael@0 42 * description of the new type of content you want Gecko to support, so that
michael@0 43 * the existing implementations of nsIContentPolicy can be properly modified
michael@0 44 * to deal with that new type of content.
michael@0 45 *
michael@0 46 * Implementations of nsIContentPolicy should treat this the same way they
michael@0 47 * treat unknown types, because existing users of TYPE_OTHER may be converted
michael@0 48 * to use new content types.
michael@0 49 */
michael@0 50 const nsContentPolicyType TYPE_OTHER = 1;
michael@0 51
michael@0 52 /**
michael@0 53 * Indicates an executable script (such as JavaScript).
michael@0 54 */
michael@0 55 const nsContentPolicyType TYPE_SCRIPT = 2;
michael@0 56
michael@0 57 /**
michael@0 58 * Indicates an image (e.g., IMG elements).
michael@0 59 */
michael@0 60 const nsContentPolicyType TYPE_IMAGE = 3;
michael@0 61
michael@0 62 /**
michael@0 63 * Indicates a stylesheet (e.g., STYLE elements).
michael@0 64 */
michael@0 65 const nsContentPolicyType TYPE_STYLESHEET = 4;
michael@0 66
michael@0 67 /**
michael@0 68 * Indicates a generic object (plugin-handled content typically falls under
michael@0 69 * this category).
michael@0 70 */
michael@0 71 const nsContentPolicyType TYPE_OBJECT = 5;
michael@0 72
michael@0 73 /**
michael@0 74 * Indicates a document at the top-level (i.e., in a browser).
michael@0 75 */
michael@0 76 const nsContentPolicyType TYPE_DOCUMENT = 6;
michael@0 77
michael@0 78 /**
michael@0 79 * Indicates a document contained within another document (e.g., IFRAMEs,
michael@0 80 * FRAMES, and OBJECTs).
michael@0 81 */
michael@0 82 const nsContentPolicyType TYPE_SUBDOCUMENT = 7;
michael@0 83
michael@0 84 /**
michael@0 85 * Indicates a timed refresh.
michael@0 86 *
michael@0 87 * shouldLoad will never get this, because it does not represent content
michael@0 88 * to be loaded (the actual load triggered by the refresh will go through
michael@0 89 * shouldLoad as expected).
michael@0 90 *
michael@0 91 * shouldProcess will get this for, e.g., META Refresh elements and HTTP
michael@0 92 * Refresh headers.
michael@0 93 */
michael@0 94 const nsContentPolicyType TYPE_REFRESH = 8;
michael@0 95
michael@0 96 /**
michael@0 97 * Indicates an XBL binding request, triggered either by -moz-binding CSS
michael@0 98 * property.
michael@0 99 */
michael@0 100 const nsContentPolicyType TYPE_XBL = 9;
michael@0 101
michael@0 102 /**
michael@0 103 * Indicates a ping triggered by a click on <A PING="..."> element.
michael@0 104 */
michael@0 105 const nsContentPolicyType TYPE_PING = 10;
michael@0 106
michael@0 107 /**
michael@0 108 * Indicates an XMLHttpRequest. Also used for document.load and for EventSource.
michael@0 109 */
michael@0 110 const nsContentPolicyType TYPE_XMLHTTPREQUEST = 11;
michael@0 111 const nsContentPolicyType TYPE_DATAREQUEST = 11; // alias
michael@0 112
michael@0 113 /**
michael@0 114 * Indicates a request by a plugin.
michael@0 115 */
michael@0 116 const nsContentPolicyType TYPE_OBJECT_SUBREQUEST = 12;
michael@0 117
michael@0 118 /**
michael@0 119 * Indicates a DTD loaded by an XML document.
michael@0 120 */
michael@0 121 const nsContentPolicyType TYPE_DTD = 13;
michael@0 122
michael@0 123 /**
michael@0 124 * Indicates a font loaded via @font-face rule.
michael@0 125 */
michael@0 126 const nsContentPolicyType TYPE_FONT = 14;
michael@0 127
michael@0 128 /**
michael@0 129 * Indicates a video or audio load.
michael@0 130 */
michael@0 131 const nsContentPolicyType TYPE_MEDIA = 15;
michael@0 132
michael@0 133 /**
michael@0 134 * Indicates a WebSocket load.
michael@0 135 */
michael@0 136 const nsContentPolicyType TYPE_WEBSOCKET = 16;
michael@0 137
michael@0 138 /**
michael@0 139 * Indicates a Content Security Policy report.
michael@0 140 */
michael@0 141 const nsContentPolicyType TYPE_CSP_REPORT = 17;
michael@0 142
michael@0 143 /**
michael@0 144 * Indicates a style sheet transformation.
michael@0 145 */
michael@0 146 const nsContentPolicyType TYPE_XSLT = 18;
michael@0 147
michael@0 148 /**
michael@0 149 * Indicates a beacon post.
michael@0 150 */
michael@0 151 const nsContentPolicyType TYPE_BEACON = 19;
michael@0 152
michael@0 153 /* When adding new content types, please update nsContentBlocker,
michael@0 154 * NS_CP_ContentTypeName, contentSecurityPolicy.js, all nsIContentPolicy
michael@0 155 * implementations, and other things that are not listed here that are
michael@0 156 * related to nsIContentPolicy. */
michael@0 157
michael@0 158 //////////////////////////////////////////////////////////////////////
michael@0 159
michael@0 160 /**
michael@0 161 * Returned from shouldLoad or shouldProcess if the load or process request
michael@0 162 * is rejected based on details of the request.
michael@0 163 */
michael@0 164 const short REJECT_REQUEST = -1;
michael@0 165
michael@0 166 /**
michael@0 167 * Returned from shouldLoad or shouldProcess if the load/process is rejected
michael@0 168 * based solely on its type (of the above flags).
michael@0 169 *
michael@0 170 * NOTE that it is not meant to stop future requests for this type--only the
michael@0 171 * current request.
michael@0 172 */
michael@0 173 const short REJECT_TYPE = -2;
michael@0 174
michael@0 175 /**
michael@0 176 * Returned from shouldLoad or shouldProcess if the load/process is rejected
michael@0 177 * based on the server it is hosted on or requested from (aContentLocation or
michael@0 178 * aRequestOrigin), e.g., if you block an IMAGE because it is served from
michael@0 179 * goatse.cx (even if you don't necessarily block other types from that
michael@0 180 * server/domain).
michael@0 181 *
michael@0 182 * NOTE that it is not meant to stop future requests for this server--only the
michael@0 183 * current request.
michael@0 184 */
michael@0 185 const short REJECT_SERVER = -3;
michael@0 186
michael@0 187 /**
michael@0 188 * Returned from shouldLoad or shouldProcess if the load/process is rejected
michael@0 189 * based on some other criteria. Mozilla callers will handle this like
michael@0 190 * REJECT_REQUEST; third-party implementors may, for example, use this to
michael@0 191 * direct their own callers to consult the extra parameter for additional
michael@0 192 * details.
michael@0 193 */
michael@0 194 const short REJECT_OTHER = -4;
michael@0 195
michael@0 196 /**
michael@0 197 * Returned from shouldLoad or shouldProcess if the load or process request
michael@0 198 * is not rejected.
michael@0 199 */
michael@0 200 const short ACCEPT = 1;
michael@0 201
michael@0 202 //////////////////////////////////////////////////////////////////////
michael@0 203
michael@0 204 /**
michael@0 205 * Should the resource at this location be loaded?
michael@0 206 * ShouldLoad will be called before loading the resource at aContentLocation
michael@0 207 * to determine whether to start the load at all.
michael@0 208 *
michael@0 209 * @param aContentType the type of content being tested. This will be one
michael@0 210 * one of the TYPE_* constants.
michael@0 211 *
michael@0 212 * @param aContentLocation the location of the content being checked; must
michael@0 213 * not be null
michael@0 214 *
michael@0 215 * @param aRequestOrigin OPTIONAL. the location of the resource that
michael@0 216 * initiated this load request; can be null if
michael@0 217 * inapplicable
michael@0 218 *
michael@0 219 * @param aContext OPTIONAL. the nsIDOMNode or nsIDOMWindow that
michael@0 220 * initiated the request, or something that can QI
michael@0 221 * to one of those; can be null if inapplicable.
michael@0 222 * Note that for navigation events (new windows and
michael@0 223 * link clicks), this is the NEW window.
michael@0 224 *
michael@0 225 * @param aMimeTypeGuess OPTIONAL. a guess for the requested content's
michael@0 226 * MIME type, based on information available to
michael@0 227 * the request initiator (e.g., an OBJECT's type
michael@0 228 * attribute); does not reliably reflect the
michael@0 229 * actual MIME type of the requested content
michael@0 230 *
michael@0 231 * @param aExtra an OPTIONAL argument, pass-through for non-Gecko
michael@0 232 * callers to pass extra data to callees.
michael@0 233 *
michael@0 234 * @param aRequestPrincipal an OPTIONAL argument, defines the principal that
michael@0 235 * caused the load. This is optional only for
michael@0 236 * non-gecko code: all gecko code should set this
michael@0 237 * argument. For navigation events, this is
michael@0 238 * the principal of the page that caused this load.
michael@0 239 *
michael@0 240 * @return ACCEPT or REJECT_*
michael@0 241 *
michael@0 242 * @note shouldLoad can be called while the DOM and layout of the document
michael@0 243 * involved is in an inconsistent state. This means that implementors of
michael@0 244 * this method MUST NOT do any of the following:
michael@0 245 * 1) Modify the DOM in any way (e.g. setting attributes is a no-no).
michael@0 246 * 2) Query any DOM properties that depend on layout (e.g. offset*
michael@0 247 * properties).
michael@0 248 * 3) Query any DOM properties that depend on style (e.g. computed style).
michael@0 249 * 4) Query any DOM properties that depend on the current state of the DOM
michael@0 250 * outside the "context" node (e.g. lengths of node lists).
michael@0 251 * 5) [JavaScript implementations only] Access properties of any sort on any
michael@0 252 * object without using XPCNativeWrapper (either explicitly or
michael@0 253 * implicitly). Due to various DOM0 things, this leads to item 4.
michael@0 254 * If you do any of these things in your shouldLoad implementation, expect
michael@0 255 * unpredictable behavior, possibly including crashes, content not showing
michael@0 256 * up, content showing up doubled, etc. If you need to do any of the things
michael@0 257 * above, do them off timeout or event.
michael@0 258 */
michael@0 259 short shouldLoad(in nsContentPolicyType aContentType,
michael@0 260 in nsIURI aContentLocation,
michael@0 261 in nsIURI aRequestOrigin,
michael@0 262 in nsISupports aContext,
michael@0 263 in ACString aMimeTypeGuess,
michael@0 264 in nsISupports aExtra,
michael@0 265 [optional] in nsIPrincipal aRequestPrincipal);
michael@0 266
michael@0 267 /**
michael@0 268 * Should the resource be processed?
michael@0 269 * ShouldProcess will be called once all the information passed to it has
michael@0 270 * been determined about the resource, typically after part of the resource
michael@0 271 * has been loaded.
michael@0 272 *
michael@0 273 * @param aContentType the type of content being tested. This will be one
michael@0 274 * one of the TYPE_* constants.
michael@0 275 *
michael@0 276 * @param aContentLocation OPTIONAL; the location of the resource being
michael@0 277 * requested: MAY be, e.g., a post-redirection URI
michael@0 278 * for the resource.
michael@0 279 *
michael@0 280 * @param aRequestOrigin OPTIONAL. the location of the resource that
michael@0 281 * initiated this load request; can be null if
michael@0 282 * inapplicable
michael@0 283 *
michael@0 284 * @param aContext OPTIONAL. the nsIDOMNode or nsIDOMWindow that
michael@0 285 * initiated the request, or something that can QI
michael@0 286 * to one of those; can be null if inapplicable.
michael@0 287 *
michael@0 288 * @param aMimeType the MIME type of the requested resource (e.g.,
michael@0 289 * image/png), as reported by the networking library,
michael@0 290 * if available (may be empty if inappropriate for
michael@0 291 * the type, e.g., TYPE_REFRESH).
michael@0 292 *
michael@0 293 * @param aExtra an OPTIONAL argument, pass-through for non-Gecko
michael@0 294 * callers to pass extra data to callees.
michael@0 295 *
michael@0 296 * @return ACCEPT or REJECT_*
michael@0 297 *
michael@0 298 * @note shouldProcess can be called while the DOM and layout of the document
michael@0 299 * involved is in an inconsistent state. See the note on shouldLoad to see
michael@0 300 * what this means for implementors of this method.
michael@0 301 */
michael@0 302 short shouldProcess(in nsContentPolicyType aContentType,
michael@0 303 in nsIURI aContentLocation,
michael@0 304 in nsIURI aRequestOrigin,
michael@0 305 in nsISupports aContext,
michael@0 306 in ACString aMimeType,
michael@0 307 in nsISupports aExtra,
michael@0 308 [optional] in nsIPrincipal aRequestPrincipal);
michael@0 309
michael@0 310 };

mercurial