B2G/gecko/toolkit/mozapps/extensions/AddonManager.jsm
/**
   * Registers a new AddonProvider.
   *
   * @param  aProvider
   *         The provider to register
   * @param  aTypes
   *         An optional array of add-on types
   */
Registers a new AddonProvider.
@param  aProvider
The provider to register
@param  aTypes
An optional array of add-on types
Registers a new AddonProvider . @param aProvider The provider to register @param aTypes An optional array of add - on types
function AMI_registerProvider(aProvider, aTypes) {
    if (!aProvider || typeof aProvider != "object")
      throw Components.Exception("aProvider must be specified",
                                 Cr.NS_ERROR_INVALID_ARG);
    if (aTypes && !Array.isArray(aTypes))
      throw Components.Exception("aTypes must be an array or null",
                                 Cr.NS_ERROR_INVALID_ARG);
    this.providers.push(aProvider);
    if (aTypes) {
      aTypes.forEach(function(aType) {
        if (!(aType.id in this.types)) {
          if (!VALID_TYPES_REGEXP.test(aType.id)) {
            WARN("Ignoring invalid type " + aType.id);
            return;
          }
          this.types[aType.id] = {
            type: aType,
            providers: [aProvider]
          };
          let typeListeners = this.typeListeners.slice(0);
          for (let listener of typeListeners) {
            safeCall(function() {
              listener.onTypeAdded(aType);
            });
          }
        }
        else {
          this.types[aType.id].providers.push(aProvider);
        }
      }, this);
    }
    if (gStarted)
      callProvider(aProvider, "startup");
  }
function AMI_registerProvider ( aProvider , aTypes ) { if ( ! aProvider || typeof aProvider != "object" ) throw Components . Exception ( "aProvider must be specified" , Cr . NS_ERROR_INVALID_ARG ) ; if ( aTypes && ! Array . isArray ( aTypes ) ) throw Components . Exception ( "aTypes must be an array or null" , Cr . NS_ERROR_INVALID_ARG ) ; this . providers . push ( aProvider ) ; if ( aTypes ) { aTypes . forEach ( function ( aType ) { if ( ! ( aType . id in this . types ) ) { if ( ! VALID_TYPES_REGEXP . test ( aType . id ) ) { WARN ( "Ignoring invalid type " + aType . id ) ; return ; } this . types [ aType . id ] = { type : aType , providers : [ aProvider ] } ; let typeListeners = this . typeListeners . slice ( 0 ) ; for ( let listener of typeListeners ) { safeCall ( function ( ) { listener . onTypeAdded ( aType ) ; } ) ; } } else { this . types [ aType . id ] . providers . push ( aProvider ) ; } } , this ) ; } if ( gStarted ) callProvider ( aProvider , "startup" ) ; }
Registers a new AddonProvider.
Registers a new AddonProvider .
// If we're registering after startup call this provider's startup.