function rectifyStateFromAddon(addon) {
    this._log.debug("Rectifying state for addon: " + addon.id);
    this._ensureStateLoaded();

    let id = addon.id;
    let enabled = !addon.userDisabled;
    let guid = addon.syncGUID;
    let now = new Date();

    if (!(id in this._addons)) {
      let record = {
        id: id,
        guid: guid,
        enabled: enabled,
        installed: true,
        modified: now,
        type: addon.type,
        scope: addon.scope,
        foreignInstall: addon.foreignInstall
      };
      this._addons[id] = record;
      this._log.debug("Adding change because add-on not present locally: " +
                      id);
      this._addChange(now, CHANGE_INSTALLED, record);
      return;
    }

    let record = this._addons[id];

    if (!record.installed) {
      // It is possible the record is marked as uninstalled because an
      // uninstall is pending.
      if (!(addon.pendingOperations & AddonManager.PENDING_UNINSTALL)) {
        record.installed = true;
        record.modified = now;
      }
    }

    if (record.enabled != enabled) {
      record.enabled = enabled;
      record.modified = now;
      let change = enabled ? CHANGE_ENABLED : CHANGE_DISABLED;
      this._log.debug("Adding change because enabled state changed: " + id);
      this._addChange(new Date(), change, record);
    }

    if (record.guid != guid) {
      record.guid = guid;
      // We don't record a change because the Sync engine rectifies this on its
      // own. This is tightly coupled with Sync. If this code is ever lifted
      // outside of Sync, this exception should likely be removed.
    }
  }
/**
   * Rectifies the state of an add-on from an Addon instance.
   *
   * This basically says "given an Addon instance, assume it is truth and
   * apply changes to the local state to reflect it."
   *
   * This function could result in change listeners being called if the local
   * state differs from the passed add-on's state.
   *
   * @param addon
   *        Addon instance being updated.
   */
Rectifies the state of an add-on from an Addon instance.
This basically says "given an Addon instance, assume it is truth and
apply changes to the local state to reflect it."

This function could result in change listeners being called if the local
state differs from the passed add-on's state.

@param addon
Addon instance being updated.
Rectifies the state of an add - on from an Addon instance . This basically says " given an Addon instance assume it is truth and apply changes to the local state to reflect it . " This function could result in change listeners being called if the local state differs from the passed add - on ' s state . @param addon Addon instance being updated .
function rectifyStateFromAddon(addon) {
    this._log.debug("Rectifying state for addon: " + addon.id);
    this._ensureStateLoaded();
    let id = addon.id;
    let enabled = !addon.userDisabled;
    let guid = addon.syncGUID;
    let now = new Date();
    if (!(id in this._addons)) {
      let record = {
        id: id,
        guid: guid,
        enabled: enabled,
        installed: true,
        modified: now,
        type: addon.type,
        scope: addon.scope,
        foreignInstall: addon.foreignInstall
      };
      this._addons[id] = record;
      this._log.debug("Adding change because add-on not present locally: " +
                      id);
      this._addChange(now, CHANGE_INSTALLED, record);
      return;
    }
    let record = this._addons[id];
    if (!record.installed) {
      if (!(addon.pendingOperations & AddonManager.PENDING_UNINSTALL)) {
        record.installed = true;
        record.modified = now;
      }
    }
    if (record.enabled != enabled) {
      record.enabled = enabled;
      record.modified = now;
      let change = enabled ? CHANGE_ENABLED : CHANGE_DISABLED;
      this._log.debug("Adding change because enabled state changed: " + id);
      this._addChange(new Date(), change, record);
    }
    if (record.guid != guid) {
      record.guid = guid;
    }
  }
function rectifyStateFromAddon ( addon ) { this . _log . debug ( "Rectifying state for addon: " + addon . id ) ; this . _ensureStateLoaded ( ) ; let id = addon . id ; let enabled = ! addon . userDisabled ; let guid = addon . syncGUID ; let now = new Date ( ) ; if ( ! ( id in this . _addons ) ) { let record = { id : id , guid : guid , enabled : enabled , installed : true , modified : now , type : addon . type , scope : addon . scope , foreignInstall : addon . foreignInstall } ; this . _addons [ id ] = record ; this . _log . debug ( "Adding change because add-on not present locally: " + id ) ; this . _addChange ( now , CHANGE_INSTALLED , record ) ; return ; } let record = this . _addons [ id ] ; if ( ! record . installed ) { if ( ! ( addon . pendingOperations & AddonManager . PENDING_UNINSTALL ) ) { record . installed = true ; record . modified = now ; } } if ( record . enabled != enabled ) { record . enabled = enabled ; record . modified = now ; let change = enabled ? CHANGE_ENABLED : CHANGE_DISABLED ; this . _log . debug ( "Adding change because enabled state changed: " + id ) ; this . _addChange ( new Date ( ) , change , record ) ; } if ( record . guid != guid ) { record . guid = guid ; } }
Rectifies the state of an add-on from an Addon instance.
Rectifies the state of an add - on from an Addon instance .
// It is possible the record is marked as uninstalled because an // uninstall is pending. // We don't record a change because the Sync engine rectifies this on its // own. This is tightly coupled with Sync. If this code is ever lifted // outside of Sync, this exception should likely be removed.