| Index: chrome/browser/resources/print_preview/search/destination_search.js
|
| diff --git a/chrome/browser/resources/print_preview/search/destination_search.js b/chrome/browser/resources/print_preview/search/destination_search.js
|
| index 601022408dffeaa331b6b3118fda27e490c768a7..5558c2308bd9a7186be8ca1081736d92e38d514f 100644
|
| --- a/chrome/browser/resources/print_preview/search/destination_search.js
|
| +++ b/chrome/browser/resources/print_preview/search/destination_search.js
|
| @@ -153,6 +153,8 @@ cr.define('print_preview', function() {
|
| // Collapse all destination lists
|
| this.localList_.setIsShowAll(false);
|
| this.cloudList_.setIsShowAll(false);
|
| + if (this.resolver_)
|
| + this.resolver_.cancel();
|
| this.resetSearch_();
|
| }
|
| },
|
| @@ -232,6 +234,11 @@ cr.define('print_preview', function() {
|
| this.destinationStore_,
|
| print_preview.DestinationStore.EventType.DESTINATION_SEARCH_DONE,
|
| this.onDestinationSearchDone_.bind(this));
|
| + this.tracker.add(
|
| + this.destinationStore_,
|
| + print_preview.DestinationStore.EventType
|
| + .PROVISIONAL_DESTINATION_RESOLVED,
|
| + this.onDestinationsInserted_.bind(this));
|
|
|
| this.tracker.add(
|
| this.invitationStore_,
|
| @@ -544,14 +551,57 @@ cr.define('print_preview', function() {
|
| },
|
|
|
| /**
|
| - * Called when a destination is selected. Clears the search and hides the
|
| - * widget.
|
| + * Handler for {@code print_preview.DestinationListItem.EventType.SELECT}
|
| + * event, which is called when a destinationi list item is selected.
|
| * @param {Event} evt Contains the selected destination.
|
| * @private
|
| */
|
| onDestinationSelect_: function(evt) {
|
| + this.handleOnDestinationSelect_(evt.destination);
|
| + },
|
| +
|
| + /**
|
| + * Called when a destination is selected. Clears the search and hides the
|
| + * widget. If The destination is provisional, it runs provisional
|
| + * destination resolver first.
|
| + * @param {!print_preview.Destination} destination The selected destination.
|
| + * @private
|
| + */
|
| + handleOnDestinationSelect_: function(destination) {
|
| + if (destination.isProvisional) {
|
| + assert(!this.resolver_,
|
| + 'Provisional destination resolver already exists.');
|
| + this.resolver_ = print_preview.ProvisionalDestinationResolver.create(
|
| + this.destinationStore_, destination);
|
| + assert(!!this.resolver_,
|
| + 'Unable to create provisional destination resolver');
|
| +
|
| + this.addChild(this.resolver_);
|
| + this.resolver_.run(this.getElement())
|
| + .then(
|
| + /**
|
| + * @param {!print_preview.Destination} resolvedDestination
|
| + * Destination to which the provisional destination was
|
| + * resolved.
|
| + */
|
| + function(resolvedDestination) {
|
| + this.handleOnDestinationSelect_(resolvedDestination);
|
| + }.bind(this))
|
| + .catch(
|
| + function() {
|
| + console.log('Failed to resolve provisional destination: ' +
|
| + destination.id);
|
| + })
|
| + .then(
|
| + function() {
|
| + this.removeChild(this.resolver_);
|
| + this.resolver_ = null;
|
| + }.bind(this));
|
| + return;
|
| + }
|
| +
|
| this.setIsVisible(false);
|
| - this.destinationStore_.selectDestination(evt.destination);
|
| + this.destinationStore_.selectDestination(destination);
|
| this.metrics_.record(print_preview.Metrics.DestinationSearchBucket.
|
| DESTINATION_CLOSED_CHANGED);
|
| },
|
|
|