selectDestination(destination) {
      this.autoSelectMatchingDestination_ = null;
      // When auto select expires, DESTINATION_SELECT event has to be dispatched
      // anyway (see isAutoSelectDestinationInProgress() logic).
      if (this.autoSelectTimeout_) {
        clearTimeout(this.autoSelectTimeout_);
        this.autoSelectTimeout_ = null;
      } else if (destination == this.selectedDestination_) {
        return;
      }
      if (destination == null) {
        this.selectedDestination_ = null;
        cr.dispatchSimpleEvent(
            this, DestinationStore.EventType.DESTINATION_SELECT);
        return;
      }

      assert(
          !destination.isProvisional,
          'Unable to select provisonal destinations');

      // Update and persist selected destination.
      this.selectedDestination_ = destination;
      this.selectedDestination_.isRecent = true;
      // Adjust metrics.
      if (destination.cloudID &&
          this.destinations_.some(function(otherDestination) {
            return otherDestination.cloudID == destination.cloudID &&
                otherDestination != destination;
          })) {
        this.metrics_.record(
            destination.isPrivet ? print_preview.Metrics.DestinationSearchBucket
                                       .PRIVET_DUPLICATE_SELECTED :
                                   print_preview.Metrics.DestinationSearchBucket
                                       .CLOUD_DUPLICATE_SELECTED);
      }
      // Notify about selected destination change.
      cr.dispatchSimpleEvent(
          this, DestinationStore.EventType.DESTINATION_SELECT);
      // Request destination capabilities from backend, since they are not
      // known yet.
      if (destination.capabilities == null) {
        const type = print_preview.originToType(destination.origin);
        if (type !== null) {
          this.nativeLayer_.getPrinterCapabilities(destination.id, type)
              .then(
                  (caps) => this.onCapabilitiesSet_(
                      destination.origin, destination.id, caps),
                  () => this.onGetCapabilitiesFail_(
                      destination.origin, destination.id));
        } else {
          assert(
              this.cloudPrintInterface_ != null,
              'Cloud destination selected, but GCP is not enabled');
          this.cloudPrintInterface_.printer(
              destination.id, destination.origin, destination.account);
        }
      } else {
        this.sendSelectedDestinationUpdateEvent_();
      }
    }
/**
     * @param {print_preview.Destination} destination Destination to select.
     */
@param {print_preview.Destination} destination Destination to select.
@param { print_preview . Destination } destination Destination to select .
selectDestination(destination) {
      this.autoSelectMatchingDestination_ = null;
      if (this.autoSelectTimeout_) {
        clearTimeout(this.autoSelectTimeout_);
        this.autoSelectTimeout_ = null;
      } else if (destination == this.selectedDestination_) {
        return;
      }
      if (destination == null) {
        this.selectedDestination_ = null;
        cr.dispatchSimpleEvent(
            this, DestinationStore.EventType.DESTINATION_SELECT);
        return;
      }
      assert(
          !destination.isProvisional,
          'Unable to select provisonal destinations');
      this.selectedDestination_ = destination;
      this.selectedDestination_.isRecent = true;
      if (destination.cloudID &&
          this.destinations_.some(function(otherDestination) {
            return otherDestination.cloudID == destination.cloudID &&
                otherDestination != destination;
          })) {
        this.metrics_.record(
            destination.isPrivet ? print_preview.Metrics.DestinationSearchBucket
                                       .PRIVET_DUPLICATE_SELECTED :
                                   print_preview.Metrics.DestinationSearchBucket
                                       .CLOUD_DUPLICATE_SELECTED);
      }
      cr.dispatchSimpleEvent(
          this, DestinationStore.EventType.DESTINATION_SELECT);
      if (destination.capabilities == null) {
        const type = print_preview.originToType(destination.origin);
        if (type !== null) {
          this.nativeLayer_.getPrinterCapabilities(destination.id, type)
              .then(
                  (caps) => this.onCapabilitiesSet_(
                      destination.origin, destination.id, caps),
                  () => this.onGetCapabilitiesFail_(
                      destination.origin, destination.id));
        } else {
          assert(
              this.cloudPrintInterface_ != null,
              'Cloud destination selected, but GCP is not enabled');
          this.cloudPrintInterface_.printer(
              destination.id, destination.origin, destination.account);
        }
      } else {
        this.sendSelectedDestinationUpdateEvent_();
      }
    }
selectDestination ( destination ) { this . autoSelectMatchingDestination_ = null ; if ( this . autoSelectTimeout_ ) { clearTimeout ( this . autoSelectTimeout_ ) ; this . autoSelectTimeout_ = null ; } else if ( destination == this . selectedDestination_ ) { return ; } if ( destination == null ) { this . selectedDestination_ = null ; cr . dispatchSimpleEvent ( this , DestinationStore . EventType . DESTINATION_SELECT ) ; return ; } assert ( ! destination . isProvisional , 'Unable to select provisonal destinations' ) ; this . selectedDestination_ = destination ; this . selectedDestination_ . isRecent = true ; if ( destination . cloudID && this . destinations_ . some ( function ( otherDestination ) { return otherDestination . cloudID == destination . cloudID && otherDestination != destination ; } ) ) { this . metrics_ . record ( destination . isPrivet ? print_preview . Metrics . DestinationSearchBucket . PRIVET_DUPLICATE_SELECTED : print_preview . Metrics . DestinationSearchBucket . CLOUD_DUPLICATE_SELECTED ) ; } cr . dispatchSimpleEvent ( this , DestinationStore . EventType . DESTINATION_SELECT ) ; if ( destination . capabilities == null ) { const type = print_preview . originToType ( destination . origin ) ; if ( type !== null ) { this . nativeLayer_ . getPrinterCapabilities ( destination . id , type ) . then ( ( caps ) => this . onCapabilitiesSet_ ( destination . origin , destination . id , caps ) , ( ) => this . onGetCapabilitiesFail_ ( destination . origin , destination . id ) ) ; } else { assert ( this . cloudPrintInterface_ != null , 'Cloud destination selected, but GCP is not enabled' ) ; this . cloudPrintInterface_ . printer ( destination . id , destination . origin , destination . account ) ; } } else { this . sendSelectedDestinationUpdateEvent_ ( ) ; } }
@param {print_preview.Destination} destination Destination to select.
@param { print_preview . Destination } destination Destination to select .
// When auto select expires, DESTINATION_SELECT event has to be dispatched // anyway (see isAutoSelectDestinationInProgress() logic). // Update and persist selected destination. // Adjust metrics. // Notify about selected destination change. // Request destination capabilities from backend, since they are not // known yet.