function installAddonFromSearchResult(addon, options, cb) {
    this._log.info("Trying to install add-on from search result: " + addon.id);

    if (options.requireSecureURI === undefined) {
      options.requireSecureURI = true;
    }

    this.getInstallFromSearchResult(addon, function onResult(error, install) {
      if (error) {
        cb(error, null);
        return;
      }

      if (!install) {
        cb(new Error("AddonInstall not available: " + addon.id), null);
        return;
      }

      try {
        this._log.info("Installing " + addon.id);
        let log = this._log;

        let listener = {
          onInstallStarted: function onInstallStarted(install) {
            if (!options) {
              return;
            }

            if (options.syncGUID) {
              log.info("Setting syncGUID of " + install.name  +": " +
                       options.syncGUID);
              install.addon.syncGUID = options.syncGUID;
            }

            // We only need to change userDisabled if it is disabled because
            // enabled is the default.
            if ("enabled" in options && !options.enabled) {
              log.info("Marking add-on as disabled for install: " +
                       install.name);
              install.addon.userDisabled = true;
            }
          },
          onInstallEnded: function(install, addon) {
            install.removeListener(listener);

            cb(null, {id: addon.id, install: install, addon: addon});
          },
          onInstallFailed: function(install) {
            install.removeListener(listener);

            cb(new Error("Install failed: " + install.error), null);
          },
          onDownloadFailed: function(install) {
            install.removeListener(listener);

            cb(new Error("Download failed: " + install.error), null);
          }
        };
        install.addListener(listener);
        install.install();
      }
      catch (ex) {
        this._log.error("Error installing add-on: " + Utils.exceptionstr(ex));
        cb(ex, null);
      }
    }.bind(this), options.requireSecureURI);
  }
/**
   * Installs an add-on from an AddonSearchResult instance.
   *
   * The options argument defines extra options to control the install.
   * Recognized keys in this map are:
   *
   *   syncGUID - Sync GUID to use for the new add-on.
   *   enabled - Boolean indicating whether the add-on should be enabled upon
   *             install.
   *   requireSecureURI - Boolean indicating whether to require a secure
   *     URI to install from. This defaults to true.
   *
   * When complete it calls a callback with 2 arguments, error and result.
   *
   * If error is falsy, result is an object. If error is truthy, result is
   * null.
   *
   * The result object has the following keys:
   *
   *   id      ID of add-on that was installed.
   *   install AddonInstall that was installed.
   *   addon   Addon that was installed.
   *
   * @param addon
   *        AddonSearchResult to install add-on from.
   * @param options
   *        Object with additional metadata describing how to install add-on.
   * @param cb
   *        Function to be invoked with result of operation.
   */
Installs an add-on from an AddonSearchResult instance.
The options argument defines extra options to control the install.
Recognized keys in this map are.

Sync GUID to use for the new add-on.
enabled - Boolean indicating whether the add-on should be enabled upon
install.
requireSecureURI - Boolean indicating whether to require a secure
URI to install from. This defaults to true.

When complete it calls a callback with 2 arguments, error and result.

If error is falsy, result is an object. If error is truthy, result is
null.

The result object has the following keys.

id      ID of add-on that was installed.
install AddonInstall that was installed.
addon   Addon that was installed.

@param addon
AddonSearchResult to install add-on from.
@param options
Object with additional metadata describing how to install add-on.
@param cb
Function to be invoked with result of operation.
Installs an add - on from an AddonSearchResult instance . The options argument defines extra options to control the install . Recognized keys in this map are . Sync GUID to use for the new add - on . enabled - Boolean indicating whether the add - on should be enabled upon install . requireSecureURI - Boolean indicating whether to require a secure URI to install from . This defaults to true . When complete it calls a callback with 2 arguments error and result . If error is falsy result is an object . If error is truthy result is null . The result object has the following keys . id ID of add - on that was installed . install AddonInstall that was installed . addon Addon that was installed . @param addon AddonSearchResult to install add - on from . @param options Object with additional metadata describing how to install add - on . @param cb Function to be invoked with result of operation .
function installAddonFromSearchResult(addon, options, cb) {
    this._log.info("Trying to install add-on from search result: " + addon.id);
    if (options.requireSecureURI === undefined) {
      options.requireSecureURI = true;
    }
    this.getInstallFromSearchResult(addon, function onResult(error, install) {
      if (error) {
        cb(error, null);
        return;
      }
      if (!install) {
        cb(new Error("AddonInstall not available: " + addon.id), null);
        return;
      }
      try {
        this._log.info("Installing " + addon.id);
        let log = this._log;
        let listener = {
          onInstallStarted: function onInstallStarted(install) {
            if (!options) {
              return;
            }
            if (options.syncGUID) {
              log.info("Setting syncGUID of " + install.name  +": " +
                       options.syncGUID);
              install.addon.syncGUID = options.syncGUID;
            }
            if ("enabled" in options && !options.enabled) {
              log.info("Marking add-on as disabled for install: " +
                       install.name);
              install.addon.userDisabled = true;
            }
          },
          onInstallEnded: function(install, addon) {
            install.removeListener(listener);
            cb(null, {id: addon.id, install: install, addon: addon});
          },
          onInstallFailed: function(install) {
            install.removeListener(listener);
            cb(new Error("Install failed: " + install.error), null);
          },
          onDownloadFailed: function(install) {
            install.removeListener(listener);
            cb(new Error("Download failed: " + install.error), null);
          }
        };
        install.addListener(listener);
        install.install();
      }
      catch (ex) {
        this._log.error("Error installing add-on: " + Utils.exceptionstr(ex));
        cb(ex, null);
      }
    }.bind(this), options.requireSecureURI);
  }
function installAddonFromSearchResult ( addon , options , cb ) { this . _log . info ( "Trying to install add-on from search result: " + addon . id ) ; if ( options . requireSecureURI === undefined ) { options . requireSecureURI = true ; } this . getInstallFromSearchResult ( addon , function onResult ( error , install ) { if ( error ) { cb ( error , null ) ; return ; } if ( ! install ) { cb ( new Error ( "AddonInstall not available: " + addon . id ) , null ) ; return ; } try { this . _log . info ( "Installing " + addon . id ) ; let log = this . _log ; let listener = { onInstallStarted : function onInstallStarted ( install ) { if ( ! options ) { return ; } if ( options . syncGUID ) { log . info ( "Setting syncGUID of " + install . name + ": " + options . syncGUID ) ; install . addon . syncGUID = options . syncGUID ; } if ( "enabled" in options && ! options . enabled ) { log . info ( "Marking add-on as disabled for install: " + install . name ) ; install . addon . userDisabled = true ; } } , onInstallEnded : function ( install , addon ) { install . removeListener ( listener ) ; cb ( null , { id : addon . id , install : install , addon : addon } ) ; } , onInstallFailed : function ( install ) { install . removeListener ( listener ) ; cb ( new Error ( "Install failed: " + install . error ) , null ) ; } , onDownloadFailed : function ( install ) { install . removeListener ( listener ) ; cb ( new Error ( "Download failed: " + install . error ) , null ) ; } } ; install . addListener ( listener ) ; install . install ( ) ; } catch ( ex ) { this . _log . error ( "Error installing add-on: " + Utils . exceptionstr ( ex ) ) ; cb ( ex , null ) ; } } . bind ( this ) , options . requireSecureURI ) ; }
Installs an add-on from an AddonSearchResult instance.
Installs an add - on from an AddonSearchResult instance .
// We only need to change userDisabled if it is disabled because // enabled is the default.