B2G/gecko/toolkit/mozapps/extensions/AddonManager.jsm
/**
   * Starts installation of an array of AddonInstalls notifying the registered
   * web install listener of blocked or started installs.
   *
   * @param  aMimetype
   *         The mimetype of add-ons being installed
   * @param  aSource
   *         The optional nsIDOMWindow that started the installs
   * @param  aURI
   *         The optional nsIURI that started the installs
   * @param  aInstalls
   *         The array of AddonInstalls to be installed
   */
Starts installation of an array of AddonInstalls notifying the registered
web install listener of blocked or started installs.

@param  aMimetype
The mimetype of add-ons being installed
@param  aSource
The optional nsIDOMWindow that started the installs
@param  aURI
The optional nsIURI that started the installs
@param  aInstalls
The array of AddonInstalls to be installed
Starts installation of an array of AddonInstalls notifying the registered web install listener of blocked or started installs . @param aMimetype The mimetype of add - ons being installed @param aSource The optional nsIDOMWindow that started the installs @param aURI The optional nsIURI that started the installs @param aInstalls The array of AddonInstalls to be installed
function AMI_installAddonsFromWebpage(aMimetype,
                                                                  aSource,
                                                                  aURI,
                                                                  aInstalls) {
    if (!gStarted)
      throw Components.Exception("AddonManager is not initialized",
                                 Cr.NS_ERROR_NOT_INITIALIZED);
    if (!aMimetype || typeof aMimetype != "string")
      throw Components.Exception("aMimetype must be a non-empty string",
                                 Cr.NS_ERROR_INVALID_ARG);
    if (aSource && !(aSource instanceof Ci.nsIDOMWindow))
      throw Components.Exception("aSource must be a nsIDOMWindow or null",
                                 Cr.NS_ERROR_INVALID_ARG);
    if (aURI && !(aURI instanceof Ci.nsIURI))
      throw Components.Exception("aURI must be a nsIURI or null",
                                 Cr.NS_ERROR_INVALID_ARG);
    if (!Array.isArray(aInstalls))
      throw Components.Exception("aInstalls must be an array",
                                 Cr.NS_ERROR_INVALID_ARG);
    if (!("@mozilla.org/addons/web-install-listener;1" in Cc)) {
      WARN("No web installer available, cancelling all installs");
      aInstalls.forEach(function(aInstall) {
        aInstall.cancel();
      });
      return;
    }
    try {
      let weblistener = Cc["@mozilla.org/addons/web-install-listener;1"].
                        getService(Ci.amIWebInstallListener);
      if (!this.isInstallEnabled(aMimetype, aURI)) {
        weblistener.onWebInstallDisabled(aSource, aURI, aInstalls,
                                         aInstalls.length);
      }
      else if (!this.isInstallAllowed(aMimetype, aURI)) {
        if (weblistener.onWebInstallBlocked(aSource, aURI, aInstalls,
                                            aInstalls.length)) {
          aInstalls.forEach(function(aInstall) {
            aInstall.install();
          });
        }
      }
      else if (weblistener.onWebInstallRequested(aSource, aURI, aInstalls,
                                                   aInstalls.length)) {
        aInstalls.forEach(function(aInstall) {
          aInstall.install();
        });
      }
    }
    catch (e) {
      WARN("Failure calling web installer", e);
      aInstalls.forEach(function(aInstall) {
        aInstall.cancel();
      });
    }
  }
function AMI_installAddonsFromWebpage ( aMimetype , aSource , aURI , aInstalls ) { if ( ! gStarted ) throw Components . Exception ( "AddonManager is not initialized" , Cr . NS_ERROR_NOT_INITIALIZED ) ; if ( ! aMimetype || typeof aMimetype != "string" ) throw Components . Exception ( "aMimetype must be a non-empty string" , Cr . NS_ERROR_INVALID_ARG ) ; if ( aSource && ! ( aSource instanceof Ci . nsIDOMWindow ) ) throw Components . Exception ( "aSource must be a nsIDOMWindow or null" , Cr . NS_ERROR_INVALID_ARG ) ; if ( aURI && ! ( aURI instanceof Ci . nsIURI ) ) throw Components . Exception ( "aURI must be a nsIURI or null" , Cr . NS_ERROR_INVALID_ARG ) ; if ( ! Array . isArray ( aInstalls ) ) throw Components . Exception ( "aInstalls must be an array" , Cr . NS_ERROR_INVALID_ARG ) ; if ( ! ( "@mozilla.org/addons/web-install-listener;1" in Cc ) ) { WARN ( "No web installer available, cancelling all installs" ) ; aInstalls . forEach ( function ( aInstall ) { aInstall . cancel ( ) ; } ) ; return ; } try { let weblistener = Cc [ "@mozilla.org/addons/web-install-listener;1" ] . getService ( Ci . amIWebInstallListener ) ; if ( ! this . isInstallEnabled ( aMimetype , aURI ) ) { weblistener . onWebInstallDisabled ( aSource , aURI , aInstalls , aInstalls . length ) ; } else if ( ! this . isInstallAllowed ( aMimetype , aURI ) ) { if ( weblistener . onWebInstallBlocked ( aSource , aURI , aInstalls , aInstalls . length ) ) { aInstalls . forEach ( function ( aInstall ) { aInstall . install ( ) ; } ) ; } } else if ( weblistener . onWebInstallRequested ( aSource , aURI , aInstalls , aInstalls . length ) ) { aInstalls . forEach ( function ( aInstall ) { aInstall . install ( ) ; } ) ; } } catch ( e ) { WARN ( "Failure calling web installer" , e ) ; aInstalls . forEach ( function ( aInstall ) { aInstall . cancel ( ) ; } ) ; } }
Starts installation of an array of AddonInstalls notifying the registered
 web install listener of blocked or started installs.
Starts installation of an array of AddonInstalls notifying the registered web install listener of blocked or started installs .
// In the event that the weblistener throws during instatiation or when // calling onWebInstallBlocked or onWebInstallRequested all of the // installs should get cancelled.