B2G/gecko/toolkit/mozapps/extensions/XPIProvider.jsm
/**
     * Called when no change has been detected for an add-on's metadata. The
     * add-on may have become visible due to other add-ons being removed or
     * the add-on may need to be updated when the application version 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
     */
Called when no change has been detected for an add-on's metadata. The
add-on may have become visible due to other add-ons being removed or
the add-on may need to be updated when the application version 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
Called when no change has been detected for an add - on ' s metadata . The add - on may have become visible due to other add - ons being removed or the add - on may need to be updated when the application version 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 updateVisibilityAndCompatibility(aInstallLocation, aOldAddon,
                                              aAddonState) {
      let changed = false;
      if (!(aOldAddon.id in visibleAddons)) {
        visibleAddons[aOldAddon.id] = aOldAddon;
        if (!aOldAddon.visible) {
          AddonManagerPrivate.addStartupChange(AddonManager.STARTUP_CHANGE_CHANGED,
                                               aOldAddon.id);
          XPIDatabase.makeAddonVisible(aOldAddon);
          if (aOldAddon.bootstrap) {
            let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
            file.persistentDescriptor = aAddonState.descriptor;
            XPIProvider.callBootstrapMethod(aOldAddon.id, aOldAddon.version, aOldAddon.type, file,
                                            "install",
                                            BOOTSTRAP_REASONS.ADDON_INSTALL);
            if (!isAddonDisabled(aOldAddon)) {
              aOldAddon.active = true;
              XPIDatabase.updateAddonActive(aOldAddon);
            }
            else {
              XPIProvider.unloadBootstrapScope(newAddon.id);
            }
          }
          else {
            changed = true;
          }
        }
      }
      if (aUpdateCompatibility) {
        let newAddon = new AddonInternal();
        newAddon.id = aOldAddon.id;
        newAddon.syncGUID = aOldAddon.syncGUID;
        newAddon.version = aOldAddon.version;
        newAddon.type = aOldAddon.type;
        newAddon.appDisabled = !isUsableAddon(aOldAddon);
        if (aOldAddon.type == "theme")
          newAddon.userDisabled = aOldAddon.internalName != XPIProvider.selectedSkin;
        applyBlocklistChanges(aOldAddon, newAddon, aOldAppVersion,
                              aOldPlatformVersion);
        let wasDisabled = isAddonDisabled(aOldAddon);
        let isDisabled = isAddonDisabled(newAddon);
        if (newAddon.appDisabled != aOldAddon.appDisabled ||
            newAddon.userDisabled != aOldAddon.userDisabled ||
            newAddon.softDisabled != aOldAddon.softDisabled) {
          LOG("Add-on " + aOldAddon.id + " changed appDisabled state to " +
              newAddon.appDisabled + ", userDisabled state to " +
              newAddon.userDisabled + " and softDisabled state to " +
              newAddon.softDisabled);
          XPIDatabase.setAddonProperties(aOldAddon, {
            appDisabled: newAddon.appDisabled,
            userDisabled: newAddon.userDisabled,
            softDisabled: newAddon.softDisabled
          });
        }
        if (aOldAddon.visible && wasDisabled != isDisabled) {
          let change = isDisabled ? AddonManager.STARTUP_CHANGE_DISABLED
                                  : AddonManager.STARTUP_CHANGE_ENABLED;
          AddonManagerPrivate.addStartupChange(change, aOldAddon.id);
          if (aOldAddon.bootstrap) {
            aOldAddon.active = !isDisabled;
            XPIDatabase.updateAddonActive(aOldAddon);
          }
          else {
            changed = true;
          }
        }
      }
      if (aOldAddon.visible && aOldAddon.active && aOldAddon.bootstrap) {
        XPIProvider.bootstrappedAddons[aOldAddon.id] = {
          version: aOldAddon.version,
          type: aOldAddon.type,
          descriptor: aAddonState.descriptor
        };
      }
      return changed;
    }
function updateVisibilityAndCompatibility ( aInstallLocation , aOldAddon , aAddonState ) { let changed = false ; if ( ! ( aOldAddon . id in visibleAddons ) ) { visibleAddons [ aOldAddon . id ] = aOldAddon ; if ( ! aOldAddon . visible ) { AddonManagerPrivate . addStartupChange ( AddonManager . STARTUP_CHANGE_CHANGED , aOldAddon . id ) ; XPIDatabase . makeAddonVisible ( aOldAddon ) ; if ( aOldAddon . bootstrap ) { let file = Cc [ "@mozilla.org/file/local;1" ] . createInstance ( Ci . nsIFile ) ; file . persistentDescriptor = aAddonState . descriptor ; XPIProvider . callBootstrapMethod ( aOldAddon . id , aOldAddon . version , aOldAddon . type , file , "install" , BOOTSTRAP_REASONS . ADDON_INSTALL ) ; if ( ! isAddonDisabled ( aOldAddon ) ) { aOldAddon . active = true ; XPIDatabase . updateAddonActive ( aOldAddon ) ; } else { XPIProvider . unloadBootstrapScope ( newAddon . id ) ; } } else { changed = true ; } } } if ( aUpdateCompatibility ) { let newAddon = new AddonInternal ( ) ; newAddon . id = aOldAddon . id ; newAddon . syncGUID = aOldAddon . syncGUID ; newAddon . version = aOldAddon . version ; newAddon . type = aOldAddon . type ; newAddon . appDisabled = ! isUsableAddon ( aOldAddon ) ; if ( aOldAddon . type == "theme" ) newAddon . userDisabled = aOldAddon . internalName != XPIProvider . selectedSkin ; applyBlocklistChanges ( aOldAddon , newAddon , aOldAppVersion , aOldPlatformVersion ) ; let wasDisabled = isAddonDisabled ( aOldAddon ) ; let isDisabled = isAddonDisabled ( newAddon ) ; if ( newAddon . appDisabled != aOldAddon . appDisabled || newAddon . userDisabled != aOldAddon . userDisabled || newAddon . softDisabled != aOldAddon . softDisabled ) { LOG ( "Add-on " + aOldAddon . id + " changed appDisabled state to " + newAddon . appDisabled + ", userDisabled state to " + newAddon . userDisabled + " and softDisabled state to " + newAddon . softDisabled ) ; XPIDatabase . setAddonProperties ( aOldAddon , { appDisabled : newAddon . appDisabled , userDisabled : newAddon . userDisabled , softDisabled : newAddon . softDisabled } ) ; } if ( aOldAddon . visible && wasDisabled != isDisabled ) { let change = isDisabled ? AddonManager . STARTUP_CHANGE_DISABLED : AddonManager . STARTUP_CHANGE_ENABLED ; AddonManagerPrivate . addStartupChange ( change , aOldAddon . id ) ; if ( aOldAddon . bootstrap ) { aOldAddon . active = ! isDisabled ; XPIDatabase . updateAddonActive ( aOldAddon ) ; } else { changed = true ; } } } if ( aOldAddon . visible && aOldAddon . active && aOldAddon . bootstrap ) { XPIProvider . bootstrappedAddons [ aOldAddon . id ] = { version : aOldAddon . version , type : aOldAddon . type , descriptor : aAddonState . descriptor } ; } return changed ; }
Called when no change has been detected for an add-on's metadata.
Called when no change has been detected for an add - on ' s metadata .
// This add-ons metadata has not changed but it may have become visible // Remember add-ons that were changed during startup. // The add-on is bootstrappable so call its install script // If it should be active then mark it as active otherwise unload // its scope // Otherwise a restart is necessary // App version changed, we may need to update the appDisabled property. // Create a basic add-on object for the new state to save reproducing // the applyBlocklistChanges code // Sync the userDisabled flag to the selectedSkin // If either property has changed update the database. // If this is a visible add-on and it has changed disabled state then we // may need a restart or to update the bootstrap list. // Remember add-ons that became disabled or enabled by the application // change // Update the add-ons active state