onSearchDone_(isRecent, request) {
      let lastRequestForThisOrigin = true;
      this.outstandingCloudSearchRequests_ =
          this.outstandingCloudSearchRequests_.filter(function(item) {
            if (item != request && item.origin == request.origin) {
              lastRequestForThisOrigin = false;
            }
            return item != request;
          });
      let activeUser = '';
      if (request.origin == print_preview.DestinationOrigin.COOKIES) {
        activeUser = request.result && request.result['request'] &&
            request.result['request']['user'];
      }
      let event = null;
      if (request.xhr.status == 200 && request.result['success']) {
        // Extract printers.
        const printerListJson = request.result['printers'] || [];
        const printerList = [];
        printerListJson.forEach(function(printerJson) {
          try {
            printerList.push(cloudprint.parseCloudDestination(
                printerJson, request.origin, activeUser));
          } catch (err) {
            console.error('Unable to parse cloud print destination: ' + err);
          }
        });
        // Extract and store users.
        this.setUsers_(request);
        // Dispatch SEARCH_DONE event.
        event = new Event(CloudPrintInterfaceEventType.SEARCH_DONE);
        event.origin = request.origin;
        event.printers = printerList;
        event.isRecent = isRecent;
      } else {
        event = this.createErrorEvent_(
            CloudPrintInterfaceEventType.SEARCH_FAILED, request);
      }
      event.user = activeUser;
      event.searchDone = lastRequestForThisOrigin;
      this.dispatchEvent(event);
    }
/**
     * Called when the search request completes.
     * @param {boolean} isRecent Whether the search request was for recent
     *     destinations.
     * @param {!cloudprint.CloudPrintRequest} request Request that has been
     *     completed.
     * @private
     */
Called when the search request completes.
@param {boolean} isRecent Whether the search request was for recent
destinations.
@param {!cloudprint.CloudPrintRequest} request Request that has been
completed.
@private
Called when the search request completes . @param { boolean } isRecent Whether the search request was for recent destinations . @param { !cloudprint . CloudPrintRequest } request Request that has been completed . @private
onSearchDone_(isRecent, request) {
      let lastRequestForThisOrigin = true;
      this.outstandingCloudSearchRequests_ =
          this.outstandingCloudSearchRequests_.filter(function(item) {
            if (item != request && item.origin == request.origin) {
              lastRequestForThisOrigin = false;
            }
            return item != request;
          });
      let activeUser = '';
      if (request.origin == print_preview.DestinationOrigin.COOKIES) {
        activeUser = request.result && request.result['request'] &&
            request.result['request']['user'];
      }
      let event = null;
      if (request.xhr.status == 200 && request.result['success']) {
        const printerListJson = request.result['printers'] || [];
        const printerList = [];
        printerListJson.forEach(function(printerJson) {
          try {
            printerList.push(cloudprint.parseCloudDestination(
                printerJson, request.origin, activeUser));
          } catch (err) {
            console.error('Unable to parse cloud print destination: ' + err);
          }
        });
        this.setUsers_(request);
        event = new Event(CloudPrintInterfaceEventType.SEARCH_DONE);
        event.origin = request.origin;
        event.printers = printerList;
        event.isRecent = isRecent;
      } else {
        event = this.createErrorEvent_(
            CloudPrintInterfaceEventType.SEARCH_FAILED, request);
      }
      event.user = activeUser;
      event.searchDone = lastRequestForThisOrigin;
      this.dispatchEvent(event);
    }
onSearchDone_ ( isRecent , request ) { let lastRequestForThisOrigin = true ; this . outstandingCloudSearchRequests_ = this . outstandingCloudSearchRequests_ . filter ( function ( item ) { if ( item != request && item . origin == request . origin ) { lastRequestForThisOrigin = false ; } return item != request ; } ) ; let activeUser = '' ; if ( request . origin == print_preview . DestinationOrigin . COOKIES ) { activeUser = request . result && request . result [ 'request' ] && request . result [ 'request' ] [ 'user' ] ; } let event = null ; if ( request . xhr . status == 200 && request . result [ 'success' ] ) { const printerListJson = request . result [ 'printers' ] || [ ] ; const printerList = [ ] ; printerListJson . forEach ( function ( printerJson ) { try { printerList . push ( cloudprint . parseCloudDestination ( printerJson , request . origin , activeUser ) ) ; } catch ( err ) { console . error ( 'Unable to parse cloud print destination: ' + err ) ; } } ) ; this . setUsers_ ( request ) ; event = new Event ( CloudPrintInterfaceEventType . SEARCH_DONE ) ; event . origin = request . origin ; event . printers = printerList ; event . isRecent = isRecent ; } else { event = this . createErrorEvent_ ( CloudPrintInterfaceEventType . SEARCH_FAILED , request ) ; } event . user = activeUser ; event . searchDone = lastRequestForThisOrigin ; this . dispatchEvent ( event ) ; }
Called when the search request completes.
Called when the search request completes .
// Extract printers. // Extract and store users. // Dispatch SEARCH_DONE event.