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

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

Issue 2606043004: Perform printer setup on Chrome OS before selecting printer. (Closed)
Patch Set: CustomEvent Created 3 years, 11 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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 }, 576 },
577 577
578 /** 578 /**
579 * Called when a destination is selected. Clears the search and hides the 579 * Called when a destination is selected. Clears the search and hides the
580 * widget. If The destination is provisional, it runs provisional 580 * widget. If The destination is provisional, it runs provisional
581 * destination resolver first. 581 * destination resolver first.
582 * @param {!print_preview.Destination} destination The selected destination. 582 * @param {!print_preview.Destination} destination The selected destination.
583 * @private 583 * @private
584 */ 584 */
585 handleOnDestinationSelect_: function(destination) { 585 handleOnDestinationSelect_: function(destination) {
586 if (destination.origin == print_preview.Destination.Origin.CROS &&
587 !destination.capabilities) {
588 // local printers on CrOS require setup.
589 assert(!this.printerConfigurer_);
590 this.printerConfigurer_ = new print_preview.CrosDestinationResolver(
591 this.destinationStore_, destination);
592 this.addChild(this.printerConfigurer_);
593 this.printerConfigurer_.run(this.getElement()).
594 then(
595 /**
596 * @param {Object} result
597 * An object containing the printerId and capabilities.
598 */
599 function(result) {
600 assert(result.printerId == destination.id);
601 destination.capabilities = result.capabilities;
602 this.handleOnDestinationSelect_(destination);
603 }.bind(this)).
604 catch(function() {
605 console.warn('Failed to setup destination: ' + destination.id);
606 }).
607 then(function() {
608 this.removeChild(this.printerConfigurer_);
609 this.printerConfigurer_ = null;
610 }.bind(this));
611 return;
612 }
613
586 if (destination.isProvisional) { 614 if (destination.isProvisional) {
587 assert(!this.provisionalDestinationResolver_, 615 assert(!this.provisionalDestinationResolver_,
588 'Provisional destination resolver already exists.'); 616 'Provisional destination resolver already exists.');
589 this.provisionalDestinationResolver_ = 617 this.provisionalDestinationResolver_ =
590 print_preview.ProvisionalDestinationResolver.create( 618 print_preview.ProvisionalDestinationResolver.create(
591 this.destinationStore_, destination); 619 this.destinationStore_, destination);
592 assert(!!this.provisionalDestinationResolver_, 620 assert(!!this.provisionalDestinationResolver_,
593 'Unable to create provisional destination resolver'); 621 'Unable to create provisional destination resolver');
594 622
595 var lastFocusedElement = document.activeElement; 623 var lastFocusedElement = document.activeElement;
596 this.addChild(this.provisionalDestinationResolver_); 624 this.addChild(this.provisionalDestinationResolver_);
597 this.provisionalDestinationResolver_.run(this.getElement()) 625 this.provisionalDestinationResolver_.run(this.getElement()).
598 .then( 626 then(
599 /** 627 /**
600 * @param {!print_preview.Destination} resolvedDestination 628 * @param {!print_preview.Destination} resolvedDestination
601 * Destination to which the provisional destination was 629 * Destination to which the provisional destination was
602 * resolved. 630 * resolved.
603 */ 631 */
604 function(resolvedDestination) { 632 function(resolvedDestination) {
605 this.handleOnDestinationSelect_(resolvedDestination); 633 this.handleOnDestinationSelect_(resolvedDestination);
606 }.bind(this)) 634 }.bind(this)).
607 .catch( 635 catch(
608 function() { 636 function() {
609 console.log('Failed to resolve provisional destination: ' + 637 console.log('Failed to resolve provisional destination: ' +
610 destination.id); 638 destination.id);
611 }) 639 }).
612 .then( 640 then(
613 function() { 641 function() {
614 this.removeChild(this.provisionalDestinationResolver_); 642 this.removeChild(this.provisionalDestinationResolver_);
615 this.provisionalDestinationResolver_ = null; 643 this.provisionalDestinationResolver_ = null;
616 644
617 // Restore focus to the previosly focused element if it's 645 // Restore focus to the previosly focused element if it's
618 // still shown in the search. 646 // still shown in the search.
619 if (lastFocusedElement && 647 if (lastFocusedElement &&
620 this.getIsVisible() && 648 this.getIsVisible() &&
621 getIsVisible(lastFocusedElement) && 649 getIsVisible(lastFocusedElement) &&
622 this.getElement().contains(lastFocusedElement)) { 650 this.getElement().contains(lastFocusedElement)) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 onWindowResize_: function() { 792 onWindowResize_: function() {
765 this.reflowLists_(); 793 this.reflowLists_();
766 } 794 }
767 }; 795 };
768 796
769 // Export 797 // Export
770 return { 798 return {
771 DestinationSearch: DestinationSearch 799 DestinationSearch: DestinationSearch
772 }; 800 };
773 }); 801 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698