Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: chrome/browser/resources/print_preview/search/destination_search.js

Issue 1144983002: Introduce concept of provisional destinations to print preview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('print_preview', function() { 5 cr.define('print_preview', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Component used for searching for a print destination. 9 * Component used for searching for a print destination.
10 * This is a modal dialog that allows the user to search and select a 10 * This is a modal dialog that allows the user to search and select a
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 this.reflowLists_(); 146 this.reflowLists_();
147 this.metrics_.record( 147 this.metrics_.record(
148 print_preview.Metrics.DestinationSearchBucket.DESTINATION_SHOWN); 148 print_preview.Metrics.DestinationSearchBucket.DESTINATION_SHOWN);
149 149
150 this.destinationStore_.startLoadAllDestinations(); 150 this.destinationStore_.startLoadAllDestinations();
151 this.invitationStore_.startLoadingInvitations(); 151 this.invitationStore_.startLoadingInvitations();
152 } else { 152 } else {
153 // Collapse all destination lists 153 // Collapse all destination lists
154 this.localList_.setIsShowAll(false); 154 this.localList_.setIsShowAll(false);
155 this.cloudList_.setIsShowAll(false); 155 this.cloudList_.setIsShowAll(false);
156 if (this.resolver_)
157 this.resolver_.cancel();
156 this.resetSearch_(); 158 this.resetSearch_();
157 } 159 }
158 }, 160 },
159 161
160 /** @override */ 162 /** @override */
161 onCancelInternal: function() { 163 onCancelInternal: function() {
162 this.metrics_.record(print_preview.Metrics.DestinationSearchBucket. 164 this.metrics_.record(print_preview.Metrics.DestinationSearchBucket.
163 DESTINATION_CLOSED_UNCHANGED); 165 DESTINATION_CLOSED_UNCHANGED);
164 }, 166 },
165 167
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 print_preview.DestinationStore.EventType.DESTINATION_SELECT, 227 print_preview.DestinationStore.EventType.DESTINATION_SELECT,
226 this.onDestinationStoreSelect_.bind(this)); 228 this.onDestinationStoreSelect_.bind(this));
227 this.tracker.add( 229 this.tracker.add(
228 this.destinationStore_, 230 this.destinationStore_,
229 print_preview.DestinationStore.EventType.DESTINATION_SEARCH_STARTED, 231 print_preview.DestinationStore.EventType.DESTINATION_SEARCH_STARTED,
230 this.updateThrobbers_.bind(this)); 232 this.updateThrobbers_.bind(this));
231 this.tracker.add( 233 this.tracker.add(
232 this.destinationStore_, 234 this.destinationStore_,
233 print_preview.DestinationStore.EventType.DESTINATION_SEARCH_DONE, 235 print_preview.DestinationStore.EventType.DESTINATION_SEARCH_DONE,
234 this.onDestinationSearchDone_.bind(this)); 236 this.onDestinationSearchDone_.bind(this));
237 this.tracker.add(
238 this.destinationStore_,
239 print_preview.DestinationStore.EventType
240 .PROVISIONAL_DESTINATION_RESOLVED,
241 this.onDestinationsInserted_.bind(this));
235 242
236 this.tracker.add( 243 this.tracker.add(
237 this.invitationStore_, 244 this.invitationStore_,
238 print_preview.InvitationStore.EventType.INVITATION_SEARCH_DONE, 245 print_preview.InvitationStore.EventType.INVITATION_SEARCH_DONE,
239 this.updateInvitations_.bind(this)); 246 this.updateInvitations_.bind(this));
240 this.tracker.add( 247 this.tracker.add(
241 this.invitationStore_, 248 this.invitationStore_,
242 print_preview.InvitationStore.EventType.INVITATION_PROCESSED, 249 print_preview.InvitationStore.EventType.INVITATION_PROCESSED,
243 this.updateInvitations_.bind(this)); 250 this.updateInvitations_.bind(this));
244 251
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 * Called when a destination search should be executed. Filters the 544 * Called when a destination search should be executed. Filters the
538 * destination lists with the given query. 545 * destination lists with the given query.
539 * @param {Event} evt Contains the search query. 546 * @param {Event} evt Contains the search query.
540 * @private 547 * @private
541 */ 548 */
542 onSearch_: function(evt) { 549 onSearch_: function(evt) {
543 this.filterLists_(evt.queryRegExp); 550 this.filterLists_(evt.queryRegExp);
544 }, 551 },
545 552
546 /** 553 /**
554 * Handler for {@code print_preview.DestinationListItem.EventType.SELECT}
555 * event, which is called when a destinationi list item is selected.
556 * @param {Event} evt Contains the selected destination.
557 * @private
558 */
559 onDestinationSelect_: function(evt) {
560 this.handleOnDestinationSelect_(evt.destination);
561 },
562
563 /**
547 * Called when a destination is selected. Clears the search and hides the 564 * Called when a destination is selected. Clears the search and hides the
548 * widget. 565 * widget. If The destination is provisional, it runs provisional
549 * @param {Event} evt Contains the selected destination. 566 * destination resolver first.
567 * @param {!print_preview.Destination} destination The selected destination.
550 * @private 568 * @private
551 */ 569 */
552 onDestinationSelect_: function(evt) { 570 handleOnDestinationSelect_: function(destination) {
571 if (destination.isProvisional) {
572 assert(!this.resolver_,
573 'Provisional destination resolver already exists.');
574 this.resolver_ = print_preview.ProvisionalDestinationResolver.create(
575 this.destinationStore_, destination);
576 assert(!!this.resolver_,
577 'Unable to create provisional destination resolver');
578
579 this.addChild(this.resolver_);
580 this.resolver_.run(this.getElement())
581 .then(
582 /**
583 * @param {!print_preview.Destination} resolvedDestination
584 * Destination to which the provisional destination was
585 * resolved.
586 */
587 function(resolvedDestination) {
588 this.handleOnDestinationSelect_(resolvedDestination);
589 }.bind(this))
590 .catch(
591 function() {
592 console.log('Failed to resolve provisional destination: ' +
593 destination.id);
594 })
595 .then(
596 function() {
597 this.removeChild(this.resolver_);
598 this.resolver_ = null;
599 }.bind(this));
600 return;
601 }
602
553 this.setIsVisible(false); 603 this.setIsVisible(false);
554 this.destinationStore_.selectDestination(evt.destination); 604 this.destinationStore_.selectDestination(destination);
555 this.metrics_.record(print_preview.Metrics.DestinationSearchBucket. 605 this.metrics_.record(print_preview.Metrics.DestinationSearchBucket.
556 DESTINATION_CLOSED_CHANGED); 606 DESTINATION_CLOSED_CHANGED);
557 }, 607 },
558 608
559 /** 609 /**
560 * Called when a destination is selected. Selected destination are marked as 610 * Called when a destination is selected. Selected destination are marked as
561 * recent, so we have to update our recent destinations list. 611 * recent, so we have to update our recent destinations list.
562 * @private 612 * @private
563 */ 613 */
564 onDestinationStoreSelect_: function() { 614 onDestinationStoreSelect_: function() {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 onWindowResize_: function() { 738 onWindowResize_: function() {
689 this.reflowLists_(); 739 this.reflowLists_();
690 } 740 }
691 }; 741 };
692 742
693 // Export 743 // Export
694 return { 744 return {
695 DestinationSearch: DestinationSearch 745 DestinationSearch: DestinationSearch
696 }; 746 };
697 }); 747 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698