You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.


TOC PREV NEXT INDEX

Embedding Gecko API


nsIURIContentListener


This interface is used by components which want to know about (and have a chance to handle) a particular content type. Typical usage scenarios will include running applications which register a nsIURIContentListener for each of its content windows with the URIdispatcher service.

Methods
onStartURIOpen

Gives the original content listener first crack at stopping a load before it happens.

Syntax:

boolean nsIURIContentListener::onStartURIOpen(
	in nsIURI aURI)  

Parameters:

aURI: The URI that is being opened.

Returns:

TRUE if the load can continue.
FALSE if the open should be aborted.
doContent

Notifies the content listener to hook up an nsIStreamListener capable of consuming the data stream.

Syntax:

boolean nsIURIContentListener::doContent(
	in string aContentType, in boolean aIsContentPreferred,
	in nsIRequest aRequest,
	out nsIStreamListener aContentHandler)  

Parameters:

aContentType: The content type of the data.
aIsContentPreferred: A boolean indicating whether the content is preferred by this listener.
aRequest: The request that is providing the data.
aContentHandler: The nsIStreamListener that will consume the data. This should be set to nsnull if no consumer can handle the content type.

Returns:

TRUE if the consumer wants to handle the load completely by itself. This causes the URI Loader do nothing else.
FALSE if the URI Loader should continue handling the load.
isPreferred

Indicates if this content handler "is preferred" for this content type. When given a URI to dispatch, if the URI is specified as 'preferred content' then the URI loader tries to find a preferred content handler for the content type. The thought is that many content listeners may be able to handle the same content type if they have to. i.e. the mail content window can handle text/html just like a browser window content listener. However, if the user clicks on a link with text/html content, then the browser window should handle that content and not the mail window where the user may have clicked the link. This is the difference between isPreferred and canHandleContent.

Syntax:

boolean nsIURIContentListener::isPreferred(
	in string aContentType,out string aDesiredContentType)  

Parameters:

aContentType: The content type of the data.
aDesiredContentType: The desired destination content type. This indicates that aContentType must be converted to aDesiredContentType before processing the data. This causes a stream converter to be inserted into the nsIStreamListener chain. This argument can be nsnull if the content should be consumed directly as aContentType.

Returns:

TRUE if this is a preferred content handler for aContentType.
FALSE otherwise.
canHandleContent

Indicates whether the content listener is capable of handling the content. This is called by the URI loader when given a URI to dispatch where the URI is not specified as 'preferred content'

Note: canHandleContent is best understood as a method implemented by the docshell as the implementation generic to all doc shells. The isPreferred decision is a decision made by a top level application content listener that sits at the top of the docshell hiearchy.

Syntax:

boolean nsIURIContentListener::canHandleContent(
	in string aContentType in boolean aIsContentPreferred,
	out string aDesiredContentType) 

Parameters:

aContentType: The content type of the data.
aIsContentPreferred: A boolean indicating whether the content is preferred by this listener.
aDesiredContentType: The desired destination content type. This indicates that aContentType must be converted to aDesiredContentType before processing the data. This causes a stream converter to be inserted into the nsIStreamListener chain. This argument can be nsnull if the content should be consumed directly as aContentType.

Returns:

TRUE if the data can be consumed.
FALSE otherwise.
Attributes
attribute nsISupports nsIURIContentListener::loadCookie

Gets and sets the load context associated with a particular content listener. The URI Loader stores and accesses this value as needed.

attribute nsIURIContentListener nsIURIContentListener::parentContentListener

Gets and sets the parent content listener if this particular listener is part of a chain of content listeners (i.e.a docshell).


Written by:Ellen Evans | Comments, questions, complaints? Bug 143387
TOC PREV NEXT INDEX