nsIContentPolicy
| IID: | a32a984a-7a6b-ea92-75fe-1166be801a0e |
| Inherits From: | nsISupports |
Interface for content policy mechanism. Implementations of this interface can be used to control loading of various types of out-of-line content, or processing of certain types of in-line content.
WARNING: do not block the caller from shouldLoad or shouldProcess (e.g., by launching a dialog to prompt the user for something).
This interface is implemented by the following components:
Constants
| PRUint32 | TYPE_OTHER | = 1 |
| Indicates an executable script (such as JavaScript). | ||
| PRUint32 | TYPE_SCRIPT | = 2 |
| Indicates an image (e.g., IMG elements). | ||
| PRUint32 | TYPE_IMAGE | = 3 |
| Indicates a stylesheet (e.g., STYLE elements). | ||
| PRUint32 | TYPE_STYLESHEET | = 4 |
| Indicates a generic object (plugin-handled content typically falls under this category). | ||
| PRUint32 | TYPE_OBJECT | = 5 |
| Indicates a document at the top-level (i.e., in a browser). | ||
| PRUint32 | TYPE_DOCUMENT | = 6 |
| Indicates a document contained within another document (e.g., IFRAMEs, FRAMES, and OBJECTs). | ||
| PRUint32 | TYPE_SUBDOCUMENT | = 7 |
| Indicates a timed refresh.
ShouldLoad will never get this, because it does not represent content to be loaded (the actual load triggered by the refresh will go through shouldLoad as expected). ShouldProcess will get this for, e.g., META Refresh elements and HTTP Refresh headers. | ||
| PRUint32 | TYPE_REFRESH | = 8 |
| Indicates an XBL binding request, triggered either by -moz-binding CSS property or Document.addBinding method. | ||
| PRUint32 | TYPE_XBL | = 9 |
| Indicates a ping triggered by a click on element. | ||
| PRUint32 | TYPE_PING | = 10 |
| Indicates an XMLHttpRequest. | ||
| PRUint32 | TYPE_XMLHTTPREQUEST | = 11 |
| Indicates a request by a plugin. | ||
| PRUint32 | TYPE_OBJECT_SUBREQUEST | = 12 |
| Returned from shouldLoad or shouldProcess if the load or process request is rejected based on details of the request. | ||
| PRInt16 | REJECT_REQUEST | = -1 |
| Returned from shouldLoad or shouldProcess if the load/process is rejected
based solely on its type (of the above flags).
NOTE that it is not meant to stop future requests for this type--only the current request. | ||
| PRInt16 | REJECT_TYPE | = -2 |
| Returned from shouldLoad or shouldProcess if the load/process is rejected
based on the server it is hosted on or requested from (aContentLocation or
aRequestOrigin), e.g., if you block an IMAGE because it is served from
goatse.cx (even if you don't necessarily block other types from that
server/domain).
NOTE that it is not meant to stop future requests for this server--only the current request. | ||
| PRInt16 | REJECT_SERVER | = -3 |
| Returned from shouldLoad or shouldProcess if the load/process is rejected based on some other criteria. Mozilla callers will handle this like REJECT_REQUEST; third-party implementors may, for example, use this to direct their own callers to consult the extra parameter for additional details. | ||
| PRInt16 | REJECT_OTHER | = -4 |
| Returned from shouldLoad or shouldProcess if the load or process request is not rejected. | ||
| PRInt16 | ACCEPT | = 1 |
Methods
PRInt16 shouldLoad ( PRUint32 contentType , nsIURI contentLocation , nsIURI requestOrigin , nsISupports context , ACString mimeTypeGuess , nsISupports extra )
PRInt16 shouldProcess ( PRUint32 contentType , nsIURI contentLocation , nsIURI requestOrigin , nsISupports context , ACString mimeType , nsISupports extra )
PRInt16 shouldLoad ( PRUint32 contentType , nsIURI contentLocation , nsIURI requestOrigin , nsISupports context , ACString mimeTypeGuess , nsISupports extra )
Should the resource at this location be loaded? ShouldLoad will be called before loading the resource at contentLocation to determine whether to start the load at all.
- Arguments:
- contentType: the type of content being tested. This will be one one of the TYPE_* constants.
- contentLocation: the location of the content being checked; must not be null
- requestOrigin: OPTIONAL. the location of the resource that initiated this load request; can be null if inapplicable
- context: OPTIONAL. the nsIDOMNode or nsIDOMWindow that initiated the request, or something that can QI to one of those; can be null if inapplicable.
- mimeTypeGuess: OPTIONAL. a guess for the requested content's MIME type, based on information available to the request initiator (e.g., an OBJECT's type attribute); does not reliably reflect the actual MIME type of the requested content
- extra: an OPTIONAL argument, pass-through for non-Gecko callers to pass extra data to callees.
- Returns:
- ACCEPT or REJECT_*
PRInt16 shouldProcess ( PRUint32 contentType , nsIURI contentLocation , nsIURI requestOrigin , nsISupports context , ACString mimeType , nsISupports extra )
Should the resource be processed? ShouldProcess will be called once all the information passed to it has been determined about the resource, typically after part of the resource has been loaded.
- Arguments:
- contentType: the type of content being tested. This will be one one of the TYPE_* constants.
- contentLocation: OPTIONAL; the location of the resource being requested: MAY be, e.g., a post-redirection URI for the resource.
- requestOrigin: OPTIONAL. the location of the resource that initiated this load request; can be null if inapplicable
- context: OPTIONAL. the nsIDOMNode or nsIDOMWindow that initiated the request, or something that can QI to one of those; can be null if inapplicable.
- mimeType: the MIME type of the requested resource (e.g., image/png), as reported by the networking library, if available (may be empty if inappropriate for the type, e.g., TYPE_REFRESH).
- extra: an OPTIONAL argument, pass-through for non-Gecko callers to pass extra data to callees.
- Returns:
- ACCEPT or REJECT_*
Reference documentation is generated from Mozilla's source.
