B2G/gecko/toolkit/mozapps/extensions/XPIProvider.jsm
/**
   * Called when AddonUpdateChecker completes the update check
   *
   * @param  updates
   *         The list of update details for the add-on
   */
Called when AddonUpdateChecker completes the update check
@param  updates
The list of update details for the add-on
Called when AddonUpdateChecker completes the update check @param updates The list of update details for the add - on
function UC_onUpdateCheckComplete(aUpdates) {
    let AUC = AddonUpdateChecker;
    let ignoreMaxVersion = false;
    let ignoreStrictCompat = false;
    if (!AddonManager.checkCompatibility) {
      ignoreMaxVersion = true;
      ignoreStrictCompat = true;
    } else if (this.addon.type in COMPATIBLE_BY_DEFAULT_TYPES &&
               !AddonManager.strictCompatibility &&
               !this.addon.strictCompatibility &&
               !this.addon.hasBinaryComponents) {
      ignoreMaxVersion = true;
    }
    let compatUpdate = AUC.getCompatibilityUpdate(aUpdates, this.addon.version,
                                                  this.syncCompatibility,
                                                  null, null,
                                                  ignoreMaxVersion,
                                                  ignoreStrictCompat);
    if (compatUpdate)
      this.addon.applyCompatibilityUpdate(compatUpdate, this.syncCompatibility);
    if ((this.appVersion &&
         Services.vc.compare(this.appVersion, Services.appinfo.version) != 0) ||
        (this.platformVersion &&
         Services.vc.compare(this.platformVersion, Services.appinfo.platformVersion) != 0)) {
      compatUpdate = AUC.getCompatibilityUpdate(aUpdates, this.addon.version,
                                                false, this.appVersion,
                                                this.platformVersion,
                                                ignoreMaxVersion,
                                                ignoreStrictCompat);
    }
    if (compatUpdate)
      this.callListener("onCompatibilityUpdateAvailable", createWrapper(this.addon));
    else
      this.callListener("onNoCompatibilityUpdateAvailable", createWrapper(this.addon));
    function sendUpdateAvailableMessages(aSelf, aInstall) {
      if (aInstall) {
        aSelf.callListener("onUpdateAvailable", createWrapper(aSelf.addon),
                           aInstall.wrapper);
      }
      else {
        aSelf.callListener("onNoUpdateAvailable", createWrapper(aSelf.addon));
      }
      aSelf.callListener("onUpdateFinished", createWrapper(aSelf.addon),
                         AddonManager.UPDATE_STATUS_NO_ERROR);
    }
    let compatOverrides = AddonManager.strictCompatibility ?
                            null :
                            this.addon.compatibilityOverrides;
    let update = AUC.getNewestCompatibleUpdate(aUpdates,
                                               this.appVersion,
                                               this.platformVersion,
                                               ignoreMaxVersion,
                                               ignoreStrictCompat,
                                               compatOverrides);
    if (update && Services.vc.compare(this.addon.version, update.version) < 0) {
      for (let currentInstall of XPIProvider.installs) {
        if (currentInstall.existingAddon != this.addon ||
            currentInstall.version != update.version)
          continue;
        if (currentInstall.state == AddonManager.STATE_AVAILABLE)
          sendUpdateAvailableMessages(this, currentInstall);
        else
          sendUpdateAvailableMessages(this, null);
        return;
      }
      let self = this;
      AddonInstall.createUpdate(function onUpdateCheckComplete_createUpdate(aInstall) {
        sendUpdateAvailableMessages(self, aInstall);
      }, this.addon, update);
    }
    else {
      sendUpdateAvailableMessages(this, null);
    }
  }
function UC_onUpdateCheckComplete ( aUpdates ) { let AUC = AddonUpdateChecker ; let ignoreMaxVersion = false ; let ignoreStrictCompat = false ; if ( ! AddonManager . checkCompatibility ) { ignoreMaxVersion = true ; ignoreStrictCompat = true ; } else if ( this . addon . type in COMPATIBLE_BY_DEFAULT_TYPES && ! AddonManager . strictCompatibility && ! this . addon . strictCompatibility && ! this . addon . hasBinaryComponents ) { ignoreMaxVersion = true ; } let compatUpdate = AUC . getCompatibilityUpdate ( aUpdates , this . addon . version , this . syncCompatibility , null , null , ignoreMaxVersion , ignoreStrictCompat ) ; if ( compatUpdate ) this . addon . applyCompatibilityUpdate ( compatUpdate , this . syncCompatibility ) ; if ( ( this . appVersion && Services . vc . compare ( this . appVersion , Services . appinfo . version ) != 0 ) || ( this . platformVersion && Services . vc . compare ( this . platformVersion , Services . appinfo . platformVersion ) != 0 ) ) { compatUpdate = AUC . getCompatibilityUpdate ( aUpdates , this . addon . version , false , this . appVersion , this . platformVersion , ignoreMaxVersion , ignoreStrictCompat ) ; } if ( compatUpdate ) this . callListener ( "onCompatibilityUpdateAvailable" , createWrapper ( this . addon ) ) ; else this . callListener ( "onNoCompatibilityUpdateAvailable" , createWrapper ( this . addon ) ) ; function sendUpdateAvailableMessages ( aSelf , aInstall ) { if ( aInstall ) { aSelf . callListener ( "onUpdateAvailable" , createWrapper ( aSelf . addon ) , aInstall . wrapper ) ; } else { aSelf . callListener ( "onNoUpdateAvailable" , createWrapper ( aSelf . addon ) ) ; } aSelf . callListener ( "onUpdateFinished" , createWrapper ( aSelf . addon ) , AddonManager . UPDATE_STATUS_NO_ERROR ) ; } let compatOverrides = AddonManager . strictCompatibility ? null : this . addon . compatibilityOverrides ; let update = AUC . getNewestCompatibleUpdate ( aUpdates , this . appVersion , this . platformVersion , ignoreMaxVersion , ignoreStrictCompat , compatOverrides ) ; if ( update && Services . vc . compare ( this . addon . version , update . version ) < 0 ) { for ( let currentInstall of XPIProvider . installs ) { if ( currentInstall . existingAddon != this . addon || currentInstall . version != update . version ) continue ; if ( currentInstall . state == AddonManager . STATE_AVAILABLE ) sendUpdateAvailableMessages ( this , currentInstall ) ; else sendUpdateAvailableMessages ( this , null ) ; return ; } let self = this ; AddonInstall . createUpdate ( function onUpdateCheckComplete_createUpdate ( aInstall ) { sendUpdateAvailableMessages ( self , aInstall ) ; } , this . addon , update ) ; } else { sendUpdateAvailableMessages ( this , null ) ; } }
Called when AddonUpdateChecker completes the update check
 @param  updates
         The list of update details for the add-on
Called when AddonUpdateChecker completes the update check @param updates The list of update details for the add - on
// Always apply any compatibility update for the current version // Apply the compatibility update to the database // If the request is for an application or platform version that is // different to the current application or platform version then look for a // compatibility update for those versions. // Skip installs that don't match the available update // If the existing install has not yet started downloading then send an // available update notification. If it is already downloading then // don't send any available update notification