Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

nsIPluginHost

This article needs a technical review. How you can help.

Please add a summary to this article.
Inherits from: nsISupports Last changed in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)

Method overview

nsIFile createTempFileToPost(in string aPostDataURL); Native code only!
void createTmpFileToPost(in string aPostDataURL, out string aTmpFileName); Native code only! Obsolete since Gecko 2.0
void deletePluginNativeWindow(in nsPluginNativeWindowPtr aPluginNativeWindow); Native code only!
void destroy(); Native code only!
void findProxyForURL(in string aURL, out string aResult); Native code only!
nsIPlugin getPlugin(in string aMimeType); Native code only!
void getPluginCount(out unsigned long aPluginCount); Obsolete since Gecko 1.8
nsIPlugin getPluginFactory(in string aMimeType); Native code only! Obsolete since Gecko 1.9.2
void getPluginName(in nsIPluginInstance aInstance, [shared] out string aPluginName); Native code only!
nsIPluginTag getPluginTagForInstance(in nsIPluginInstance aInstance); Native code only!
void getPluginTags([optional] out unsigned long aPluginCount, [retval, array, size_is(aPluginCount)] out nsIPluginTag aResults);
void handleBadPlugin(in PRLibraryPtr aLibrary, in nsIPluginInstance instance); Native code only!
void init(); Native code only!
void instantiateDummyJavaPlugin(in nsIPluginInstanceOwner aOwner); Native code only!
void instantiateEmbeddedPlugin(in string aMimeType, in nsIURI aURL, in nsIPluginInstanceOwner aOwner); Native code only!
void instantiateEmbededPlugin(in string aMimeType, in nsIURI aURL, in nsIPluginInstanceOwner aOwner); Obsolete since Gecko 1.8
void instantiateFullPagePlugin(in string aMimeType, in nsIURI aURI, in nsIPluginInstanceOwner aOwner, out nsIStreamListener aStreamListener); Native code only!
nsIStreamListener instantiatePluginForChannel(in nsIChannel aChannel, in nsIPluginInstanceOwner aOwner); Native code only!
void isPluginEnabledForExtension(in string aExtension, in constCharStarRef aMimeType); Native code only!
void isPluginEnabledForType(in string aMimeType); Native code only!
void loadPlugins(); Native code only!
void newPluginNativeWindow(out nsPluginNativeWindowPtr aPluginNativeWindow); Native code only!
void parsePostBufferToFixHeaders(in string aInPostData, in unsigned long aInPostDataLen, out string aOutPostData, out unsigned long aOutPostDataLen); Native code only!
void reloadPlugins(in boolean reloadPages);
void setIsScriptableInstance(in nsIPluginInstance aInstance, in boolean aScriptable); Native code only! Obsolete since Gecko 2.0
void setUpPluginInstance(in string aMimeType, in nsIURI aURL, in nsIPluginInstanceOwner aOwner); Native code only!
void stopPluginInstance(in nsIPluginInstance aInstance); Native code only!
void UserAgent(in nativeChar resultingAgentString); Native code only!

Attributes

Attribute Type Description
pluginCount unsigned long Read only. Native code only!

Methods

Native code only!

createTempFileToPost

To create temp file with Content len header in, it will use by http POST.

nsIFile createTempFileToPost(
  in string aPostDataURL
);
Parameters
aPostDataURL
 
Return value

 

Native code only!

createTmpFileToPost

Obsolete since Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

To create temp file with Content len header in, it will use by http POST.

void createTmpFileToPost(
  in string aPostDataURL,
  out string aTmpFileName
);
Parameters
aPostDataURL
 
aTmpFileName
 

Native code only!

deletePluginNativeWindow

Deletes plugin native window object created by NewPluginNativeWindow().

void deletePluginNativeWindow(
  in nsPluginNativeWindowPtr aPluginNativeWindow
);
Parameters
aPluginNativeWindow
 

Native code only!

destroy

void destroy();
Parameters

None.

Native code only!

findProxyForURL

Fetches a URL.

(Corresponds to NPN_GetURL and NPN_GetURLNotify.)

Posts to a URL with post data and/or post headers.

(Corresponds to NPN_PostURL and NPN_PostURLNotify.)

Returns the proxy info for a given URL. The caller is required to free the resulting memory with nsIMalloc.Free(). The result will be in the following format.

  1. "DIRECT" -- no proxy
  2. "PROXY xxx.xxx.xxx.xxx" -- use proxy
  3. "SOCKS xxx.xxx.xxx.xxx" -- use SOCKS
  4. Mixed. for example "PROXY 111.111.111.111;PROXY 112.112.112.112", "PROXY 111.111.111.111;SOCKS 112.112.112.112"....

Which proxy/SOCKS to use is determined by the plugin.

void findProxyForURL(
  in string aURL,
  out string aResult
);
Parameters
aURL
 
aResult
 

Native code only!

getPlugin

nsIPlugin getPlugin(
  in string aMimeType
);
Parameters
aMimeType
 
Return value

 

getPluginCount()

Obsolete since Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)

void getPluginCount(
  out unsigned long aPluginCount
);
Parameters
aPluginCount
 

Native code only!

getPluginFactory

Obsolete since Gecko 1.9.2 (Firefox 3.6 / Thunderbird 3.1 / Fennec 1.0)
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

nsIPlugin getPluginFactory(
  in string aMimeType
);
Parameters
aMimeType
 
Return value

 

Native code only!

getPluginName

Get the plugin name for the plugin instance.

void getPluginName(
  in nsIPluginInstance aInstance,
  [shared] out string aPluginName
);
Parameters
aInstance
The plugin instance object.
aPluginName
Returns a pointer to a shared read-only string value, it's only valid for the lifetime of the plugin instance - you must copy the string value if you need it longer than that.

Native code only!

getPluginTagForInstance

Get the plugin tag associated with a given plugin instance.

nsIPluginTag getPluginTagForInstance(
  in nsIPluginInstance aInstance
);
Parameters
aInstance
The plugin instance object.
Return value

Plugin tag object.

getPluginTags()

Requires Gecko 1.9 (Firefox 3)

void getPluginTags(
  out unsigned long aPluginCount, Optional
  [retval, array, size_is(aPluginCount)] out nsIPluginTag aResults
);
Parameters
aPluginCount Optional
 
aResults
 

Native code only!

handleBadPlugin

void handleBadPlugin(
  in PRLibraryPtr aLibrary,
  in nsIPluginInstance instance
);
Parameters
aLibrary
 
instance
 

Native code only!

init

void init();
Parameters

None.

Native code only!

instantiateDummyJavaPlugin

Instantiate a "dummy" java plugin if a java plugin that supports NPRuntime is installed. This plugin is used for exposing window.java and window.Packages. If the java plugin supports NPRuntime and instantiation was successful, aOwners instance will be non-null, if not, it will be null.

void instantiateDummyJavaPlugin(
  in nsIPluginInstanceOwner aOwner
);
Parameters
aOwner
 

Native code only!

instantiateEmbeddedPlugin

void instantiateEmbeddedPlugin(
  in string aMimeType,
  in nsIURI aURL,
  in nsIPluginInstanceOwner aOwner
);
Parameters
aMimeType
 
aURL
 
aOwner
 

instantiateEmbededPlugin()

Obsolete since Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)

void instantiateEmbededPlugin(
  in string aMimeType,
  in nsIURI aURL,
  in nsIPluginInstanceOwner aOwner
);
Parameters
aMimeType
 
aURL
 
aOwner
 

Native code only!

instantiateFullPagePlugin

void instantiateFullPagePlugin(
  in string aMimeType,
  in nsIURI aURI,
  in nsIPluginInstanceOwner aOwner,
  out nsIStreamListener aStreamListener
);
Parameters
aMimeType
 
aURI
 
aOwner
 
aStreamListener
 

Native code only!

instantiatePluginForChannel

Instantiate an embedded plugin for an existing channel. The caller is responsible for opening the channel. It may or may not be already opened when this function is called.

nsIStreamListener instantiatePluginForChannel(
  in nsIChannel aChannel,
  in nsIPluginInstanceOwner aOwner
);
Parameters
aChannel
 
aOwner
 
Return value

 

Native code only!

isPluginEnabledForExtension

void isPluginEnabledForExtension(
  in string aExtension,
  in constCharStarRef aMimeType
);
Parameters
aExtension
 
aMimeType
 

Native code only!

isPluginEnabledForType

void isPluginEnabledForType(
  in string aMimeType
);
Parameters
aMimeType
 

Native code only!

loadPlugins

void loadPlugins();
Parameters

None.

Native code only!

newPluginNativeWindow

Creates a new plugin native window object.

void newPluginNativeWindow(
  out nsPluginNativeWindowPtr aPluginNativeWindow
);
Parameters
aPluginNativeWindow
 

Native code only!

parsePostBufferToFixHeaders

This method parses post buffer to find out case insensitive "Content-length" string and CR or LF some where after that, then it assumes there is http headers in the input buffer and continue to search for end of headers (CRLFCRLF or LFLF). It will *always malloc()* output buffer (caller is responsible to free it) if input buffer starts with LF, which comes from 4.x spec https://developer.netscape.com/docs/manuals/communicator/plugin/pgfn2.htm#1007754 "If no custom headers are required, simply add a blank line ('\n') to the beginning of the file or buffer.", it skips that '\n' and considers rest of the input buffer as data. If "Content-length" string and end of headers is found it substitutes single LF with CRLF in the headers, so the end of headers always will be CRLFCRLF (single CR in headers, if any, remain untouched) else it puts "Content-length: "+size_of_data+CRLFCRLF at the beginning of the output buffer and memcpy data to the output buffer.

On failure outPostData and outPostDataLen will be set in 0.

void parsePostBufferToFixHeaders(
  in string aInPostData,
  in unsigned long aInPostDataLen,
  out string aOutPostData,
  out unsigned long aOutPostDataLen
);
Parameters
aInPostData
The post data.
aInPostDataLen
The length aInPostData.
aOutPostData
The buffer.
aOutPostDataLen
The length of aOutPostData.

reloadPlugins()

Requires Gecko 1.9.2 (Firefox 3.6 / Thunderbird 3.1 / Fennec 1.0)

Causes the plugins directory to be searched again for new plugin libraries.

void reloadPlugins(
  in boolean reloadPages
);
Parameters
reloadPages
Indicates whether currently visible pages should also be reloaded.

Native code only!

setIsScriptableInstance

Obsolete since Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

To notify the plugin manager that the plugin created a script object.

void setIsScriptableInstance(
  in nsIPluginInstance aInstance,
  in boolean aScriptable
);
Parameters
aInstance
 
aScriptable
 

Native code only!

setUpPluginInstance

void setUpPluginInstance(
  in string aMimeType,
  in nsIURI aURL,
  in nsIPluginInstanceOwner aOwner
);
Parameters
aMimeType
 
aURL
 
aOwner
 

Native code only!

stopPluginInstance

void stopPluginInstance(
  in nsIPluginInstance aInstance
);
Parameters
aInstance
 

Native code only!

UserAgent

void UserAgent(
  in nativeChar resultingAgentString
);
Parameters

Examples

List all plug-ins and associated mime types and get handler info

This example here logs to Browser Console all the installed plug-ins and the associated mime types. Then using nsIHandlerService it gets the handler info. A handler is, default application that should open or deal with this file.

let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
let handlerService = Cc['@mozilla.org/uriloader/handler-service;1'].getService(Ci.nsIHandlerService);
let mimeService = Cc['@mozilla.org/mime;1'].getService(Ci.nsIMIMEService);

let pluginTags = pluginHost.getPluginTags();

for (let i = 0; i < pluginTags.length; ++i) {
    let pluginTag = pluginTags[i];

    let mimeTypes = pluginTag.getMimeTypes();

    console.warn('pluginTag:', pluginTag.name, 'mimeTypes:', mimeTypes);

    // go through all the mime types and get the handler service
    for (let j = 0; j < mimeTypes.length; ++j) {
        let type = mimeTypes[j];

        let wrappedHandlerInfo = mimeService.getFromTypeAndExtension(type, null);
        console.log('handler info for type', type, wrappedHandlerInfo);
    }

}
resultingAgentString
 
 

Document Tags and Contributors

 Contributors to this page: tschneidereit, Noitidart, Sheppy, kscarfone, trevorh
 Last updated by: tschneidereit,