B2G/gecko/toolkit/mozapps/extensions/XPIProvider.jsm
/**
     * Updates an add-on's metadata and determines if a restart of the
     * application is necessary. This is called when either the add-on's
     * install directory path or last modified time has changed.
     *
     * @param  aInstallLocation
     *         The install location containing the add-on
     * @param  aOldAddon
     *         The AddonInternal as it appeared the last time the application
     *         ran
     * @param  aAddonState
     *         The new state of the add-on
     * @return a boolean indicating if flushing caches is required to complete
     *         changing this add-on
     */
Updates an add-on's metadata and determines if a restart of the
application is necessary. This is called when either the add-on's
install directory path or last modified time has changed.

@param  aInstallLocation
The install location containing the add-on
@param  aOldAddon
The AddonInternal as it appeared the last time the application
ran
@param  aAddonState
The new state of the add-on
@return a boolean indicating if flushing caches is required to complete
changing this add-on
Updates an add - on ' s metadata and determines if a restart of the application is necessary . This is called when either the add - on ' s install directory path or last modified time has changed . @param aInstallLocation The install location containing the add - on @param aOldAddon The AddonInternal as it appeared the last time the application ran @param aAddonState The new state of the add - on @return a boolean indicating if flushing caches is required to complete changing this add - on
function updateMetadata(aInstallLocation, aOldAddon, aAddonState) {
      LOG("Add-on " + aOldAddon.id + " modified in " + aInstallLocation.name);
      let newAddon = aManifests[aInstallLocation.name][aOldAddon.id];
      try {
        if (!newAddon) {
          let file = aInstallLocation.getLocationForID(aOldAddon.id);
          newAddon = loadManifestFromFile(file);
          applyBlocklistChanges(aOldAddon, newAddon);
          newAddon.pendingUninstall = aOldAddon.pendingUninstall;
        }
        if (newAddon.id != aOldAddon.id)
          throw new Error("Incorrect id in install manifest");
      }
      catch (e) {
        WARN("Add-on is invalid", e);
        XPIDatabase.removeAddonMetadata(aOldAddon);
        if (!aInstallLocation.locked)
          aInstallLocation.uninstallAddon(aOldAddon.id);
        else
          WARN("Could not uninstall invalid item from locked install location");
        if (aOldAddon.active)
          return true;
        return false;
      }
      newAddon._installLocation = aInstallLocation;
      newAddon.updateDate = aAddonState.mtime;
      newAddon.visible = !(newAddon.id in visibleAddons);
      XPIDatabase.updateAddonMetadata(aOldAddon, newAddon, aAddonState.descriptor);
      if (newAddon.visible) {
        visibleAddons[newAddon.id] = newAddon;
        AddonManagerPrivate.addStartupChange(AddonManager.STARTUP_CHANGE_CHANGED,
                                             newAddon.id);
        if (aOldAddon.active && isAddonDisabled(newAddon))
          XPIProvider.enableDefaultTheme();
        if (newAddon.active && newAddon.bootstrap) {
          flushStartupCache();
          let installReason = Services.vc.compare(aOldAddon.version, newAddon.version) < 0 ?
                              BOOTSTRAP_REASONS.ADDON_UPGRADE :
                              BOOTSTRAP_REASONS.ADDON_DOWNGRADE;
          let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
          file.persistentDescriptor = aAddonState.descriptor;
          XPIProvider.callBootstrapMethod(newAddon.id, newAddon.version, newAddon.type, file,
                                          "install", installReason);
          return false;
        }
        return true;
      }
      return false;
    }
function updateMetadata ( aInstallLocation , aOldAddon , aAddonState ) { LOG ( "Add-on " + aOldAddon . id + " modified in " + aInstallLocation . name ) ; let newAddon = aManifests [ aInstallLocation . name ] [ aOldAddon . id ] ; try { if ( ! newAddon ) { let file = aInstallLocation . getLocationForID ( aOldAddon . id ) ; newAddon = loadManifestFromFile ( file ) ; applyBlocklistChanges ( aOldAddon , newAddon ) ; newAddon . pendingUninstall = aOldAddon . pendingUninstall ; } if ( newAddon . id != aOldAddon . id ) throw new Error ( "Incorrect id in install manifest" ) ; } catch ( e ) { WARN ( "Add-on is invalid" , e ) ; XPIDatabase . removeAddonMetadata ( aOldAddon ) ; if ( ! aInstallLocation . locked ) aInstallLocation . uninstallAddon ( aOldAddon . id ) ; else WARN ( "Could not uninstall invalid item from locked install location" ) ; if ( aOldAddon . active ) return true ; return false ; } newAddon . _installLocation = aInstallLocation ; newAddon . updateDate = aAddonState . mtime ; newAddon . visible = ! ( newAddon . id in visibleAddons ) ; XPIDatabase . updateAddonMetadata ( aOldAddon , newAddon , aAddonState . descriptor ) ; if ( newAddon . visible ) { visibleAddons [ newAddon . id ] = newAddon ; AddonManagerPrivate . addStartupChange ( AddonManager . STARTUP_CHANGE_CHANGED , newAddon . id ) ; if ( aOldAddon . active && isAddonDisabled ( newAddon ) ) XPIProvider . enableDefaultTheme ( ) ; if ( newAddon . active && newAddon . bootstrap ) { flushStartupCache ( ) ; let installReason = Services . vc . compare ( aOldAddon . version , newAddon . version ) < 0 ? BOOTSTRAP_REASONS . ADDON_UPGRADE : BOOTSTRAP_REASONS . ADDON_DOWNGRADE ; let file = Cc [ "@mozilla.org/file/local;1" ] . createInstance ( Ci . nsIFile ) ; file . persistentDescriptor = aAddonState . descriptor ; XPIProvider . callBootstrapMethod ( newAddon . id , newAddon . version , newAddon . type , file , "install" , installReason ) ; return false ; } return true ; } return false ; }
Updates an add-on's metadata and determines if a restart of the
 application is necessary.
Updates an add - on ' s metadata and determines if a restart of the application is necessary .
// Check if there is an updated install manifest for this add-on // If not load it // Carry over any pendingUninstall state to add-ons modified directly // in the profile. This is impoprtant when the attempt to remove the // add-on in processPendingFileChanges failed and caused an mtime // change to the add-ons files. // The ID in the manifest that was loaded must match the ID of the old // add-on. // If this was an active add-on then we must force a restart // Set the additional properties on the new AddonInternal // Update the database // Remember add-ons that were changed during startup // If this was the active theme and it is now disabled then enable the // default theme // If the new add-on is bootstrapped and active then call its install method // Startup cache must be flushed before calling the bootstrap script