3rd/xulrunner-sdk/bin/components/amContentHandler.js
/**
   * Handles a new request for an application/x-xpinstall file.
   *
   * @param  aMimetype
   *         The mimetype of the file
   * @param  aContext
   *         The context passed to nsIChannel.asyncOpen
   * @param  aRequest
   *         The nsIRequest dealing with the content
   */
Handles a new request for an application/x-xpinstall file.
@param  aMimetype
The mimetype of the file
@param  aContext
The context passed to nsIChannel.asyncOpen
@param  aRequest
The nsIRequest dealing with the content
Handles a new request for an application / x - xpinstall file . @param aMimetype The mimetype of the file @param aContext The context passed to nsIChannel . asyncOpen @param aRequest The nsIRequest dealing with the content
function XCH_handleContent(aMimetype, aContext, aRequest) {
    if (aMimetype != XPI_CONTENT_TYPE)
      throw Cr.NS_ERROR_WONT_HANDLE_CONTENT;
    if (!(aRequest instanceof Ci.nsIChannel))
      throw Cr.NS_ERROR_WONT_HANDLE_CONTENT;
    let uri = aRequest.URI;
    let window = null;
    let callbacks = aRequest.notificationCallbacks ?
                    aRequest.notificationCallbacks :
                    aRequest.loadGroup.notificationCallbacks;
    if (callbacks)
      window = callbacks.getInterface(Ci.nsIDOMWindow);
    aRequest.cancel(Cr.NS_BINDING_ABORTED);
    let appinfo = Cc["@mozilla.org/xre/app-info;1"].
                  getService(Ci.nsIXULRuntime);
    if (appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT) {
      try {
        if (!window.InstallTrigger) 
          window = window.wrappedJSObject;
        if (window.InstallTrigger)
          window.InstallTrigger.startSoftwareUpdate(uri.spec);
        else
          this.log("Window does not have an InstallTrigger");
      } catch(ex) {
        this.log(ex);
      }
    }
    else {
      let referer = null;
      if (aRequest instanceof Ci.nsIPropertyBag2) {
        referer = aRequest.getPropertyAsInterface("docshell.internalReferrer",
                                                Ci.nsIURI);
      }
      let manager = Cc["@mozilla.org/addons/integration;1"].
                    getService(Ci.amIWebInstaller);
      manager.installAddonsFromWebpage(aMimetype, window, referer, [uri.spec],
                                       [null], [null], [null], null, 1);
    }
  }
function XCH_handleContent ( aMimetype , aContext , aRequest ) { if ( aMimetype != XPI_CONTENT_TYPE ) throw Cr . NS_ERROR_WONT_HANDLE_CONTENT ; if ( ! ( aRequest instanceof Ci . nsIChannel ) ) throw Cr . NS_ERROR_WONT_HANDLE_CONTENT ; let uri = aRequest . URI ; let window = null ; let callbacks = aRequest . notificationCallbacks ? aRequest . notificationCallbacks : aRequest . loadGroup . notificationCallbacks ; if ( callbacks ) window = callbacks . getInterface ( Ci . nsIDOMWindow ) ; aRequest . cancel ( Cr . NS_BINDING_ABORTED ) ; let appinfo = Cc [ "@mozilla.org/xre/app-info;1" ] . getService ( Ci . nsIXULRuntime ) ; if ( appinfo . processType == Ci . nsIXULRuntime . PROCESS_TYPE_CONTENT ) { try { if ( ! window . InstallTrigger ) window = window . wrappedJSObject ; if ( window . InstallTrigger ) window . InstallTrigger . startSoftwareUpdate ( uri . spec ) ; else this . log ( "Window does not have an InstallTrigger" ) ; } catch ( ex ) { this . log ( ex ) ; } } else { let referer = null ; if ( aRequest instanceof Ci . nsIPropertyBag2 ) { referer = aRequest . getPropertyAsInterface ( "docshell.internalReferrer" , Ci . nsIURI ) ; } let manager = Cc [ "@mozilla.org/addons/integration;1" ] . getService ( Ci . amIWebInstaller ) ; manager . installAddonsFromWebpage ( aMimetype , window , referer , [ uri . spec ] , [ null ] , [ null ] , [ null ] , null , 1 ) ; } }
Handles a new request for an application/x-xpinstall file.
Handles a new request for an application / x - xpinstall file .