Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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.log('Failed to setup destination: ' + destination.id); | |
| 606 }) | |
|
xdai1
2016/12/30 00:38:13
indent off
skau
2017/01/04 18:57:06
Done.
| |
| 607 .then(function() { | |
| 608 this.removeChild(this.printerConfigurer_); | |
| 609 this.printerConfigurer_ = null; | |
| 610 }.bind(this)); | |
|
xdai1
2016/12/30 00:38:13
indent off
skau
2017/01/04 18:57:06
Done.
| |
| 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; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 }); |
| OLD | NEW |