B2G/gecko/toolkit/mozapps/extensions/AddonManager.jsm
/**
   * Asynchronously gets an AddonInstall for an nsIFile.
   *
   * @param  aFile
   *         The nsIFile where the add-on is located
   * @param  aCallback
   *         A callback to pass the AddonInstall to
   * @param  aMimetype
   *         An optional mimetype hint for the add-on
   * @throws if the aFile or aCallback arguments are not specified
   */
Asynchronously gets an AddonInstall for an nsIFile.
@param  aFile
The nsIFile where the add-on is located
@param  aCallback
A callback to pass the AddonInstall to
@param  aMimetype
An optional mimetype hint for the add-on
@throws if the aFile or aCallback arguments are not specified
Asynchronously gets an AddonInstall for an nsIFile . @param aFile The nsIFile where the add - on is located @param aCallback A callback to pass the AddonInstall to @param aMimetype An optional mimetype hint for the add - on @throws if the aFile or aCallback arguments are not specified
function AMI_getInstallForFile(aFile, aCallback, aMimetype) {
    if (!gStarted)
      throw Components.Exception("AddonManager is not initialized",
                                 Cr.NS_ERROR_NOT_INITIALIZED);
    if (!(aFile instanceof Ci.nsIFile))
      throw Components.Exception("aFile must be a nsIFile",
                                 Cr.NS_ERROR_INVALID_ARG);
    if (typeof aCallback != "function")
      throw Components.Exception("aCallback must be a function",
                                 Cr.NS_ERROR_INVALID_ARG);
    if (aMimetype && typeof aMimetype != "string")
      throw Components.Exception("aMimetype must be a string or null",
                                 Cr.NS_ERROR_INVALID_ARG);
    new AsyncObjectCaller(this.providers, "getInstallForFile", {
      nextObject: function(aCaller, aProvider) {
        callProvider(aProvider, "getInstallForFile", null, aFile,
                     function(aInstall) {
          if (aInstall)
            safeCall(aCallback, aInstall);
          else
            aCaller.callNext();
        });
      },
      noMoreObjects: function(aCaller) {
        safeCall(aCallback, null);
      }
    });
  }
function AMI_getInstallForFile ( aFile , aCallback , aMimetype ) { if ( ! gStarted ) throw Components . Exception ( "AddonManager is not initialized" , Cr . NS_ERROR_NOT_INITIALIZED ) ; if ( ! ( aFile instanceof Ci . nsIFile ) ) throw Components . Exception ( "aFile must be a nsIFile" , Cr . NS_ERROR_INVALID_ARG ) ; if ( typeof aCallback != "function" ) throw Components . Exception ( "aCallback must be a function" , Cr . NS_ERROR_INVALID_ARG ) ; if ( aMimetype && typeof aMimetype != "string" ) throw Components . Exception ( "aMimetype must be a string or null" , Cr . NS_ERROR_INVALID_ARG ) ; new AsyncObjectCaller ( this . providers , "getInstallForFile" , { nextObject : function ( aCaller , aProvider ) { callProvider ( aProvider , "getInstallForFile" , null , aFile , function ( aInstall ) { if ( aInstall ) safeCall ( aCallback , aInstall ) ; else aCaller . callNext ( ) ; } ) ; } , noMoreObjects : function ( aCaller ) { safeCall ( aCallback , null ) ; } } ) ; }
Asynchronously gets an AddonInstall for an nsIFile.
Asynchronously gets an AddonInstall for an nsIFile .