docshell/base/nsIWebNavigationInfo.idlScriptable
Exposes a way to get information on the capabilities of Gecko web navigation objects.
1.0
66
Introduced
Gecko 1.8
Inherits from: nsISupports Last changed in Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)

Implemented by: @mozilla.org/webnavigation-info;1 as a service:

var webNavigationInfo = Components.classes["@mozilla.org/webnavigation-info;1"]
                        .getService(Components.interfaces.nsIWebNavigationInfo);

Method overview

unsigned long isTypeSupported(in ACString aType, in nsIWebNavigation aWebNav);

Constants

Support type constants

Constant Value Description
UNSUPPORTED 0

Returned by isTypeSupported() to indicate lack of support for a type.

Note: This is guaranteed not to change, so that boolean tests can be done on the return value if isTypeSupported to detect whether a type is supported at all.
IMAGE 1 Returned by isTypeSupported() to indicate that a type is supported as an image.
PLUGIN 2 Returned by isTypeSupported() to indicate that a type is supported via an NPAPI ("Netscape 4 API") plug-in. This is not the value returned for "XPCOM plug-ins".
OTHER 1 << 15

Note: Other return types may be added here in the future as they become relevant.

Returned by isTypeSupported() to indicate that a type is supported via some other means.

Methods

isTypeSupported()

Determines whether or not the specified MIME type is supported by the given nsIWebNavigation object. This lets you determine whether a MIME type can be displayed as-is inside a browser, or if the browser will instead forward handling of the data to a plug-in or an external helper application.

Note: This method may cause plug-ins to be rescanned in order to ensure they are properly registered for the types they support.
unsigned long isTypeSupported(
  in ACString aType,
  in nsIWebNavigation aWebNav
);
Parameters
aType
The MIME type to check.
aWebNav
The nsIWebNavigation object on which to check for compatibility. You may specify null to check for compatibility with nsIWebNavigation objects that are in their default state; otherwise, the result is determined based on the configuration of the specified object (that is, how it is configured by using nsIWebBrowserSetup).
Return value

Returns one of the Support type constants, indicating whether or not the specified MIME type is supported, and in what form that support exists.

Example

let webnavigationinfo_service = Components.classes["@mozilla.org/webnavigation-info;1"]
                                .getService(Components.interfaces.nsIWebNavigationInfo);
let support_code = webnavigationinfo_service.isTypeSupported(contentType, null);

if (support_code == webnavigationinfo_service.UNSUPPORTED) {
  dump("Unsupported content-type: not displaying in the browser\n");
}

See also