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 * A data store that stores destinations and dispatches events when the data | 9 * A data store that stores destinations and dispatches events when the data |
| 10 * store changes. | 10 * store changes. |
| (...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1536 /** | 1536 /** |
| 1537 * Called when the native layer retrieves the capabilities for the selected | 1537 * Called when the native layer retrieves the capabilities for the selected |
| 1538 * local destination. Updates the destination with new capabilities if the | 1538 * local destination. Updates the destination with new capabilities if the |
| 1539 * destination already exists, otherwise it creates a new destination and | 1539 * destination already exists, otherwise it creates a new destination and |
| 1540 * then updates its capabilities. | 1540 * then updates its capabilities. |
| 1541 * @param {Event} event Contains the capabilities of the local print | 1541 * @param {Event} event Contains the capabilities of the local print |
| 1542 * destination. | 1542 * destination. |
| 1543 * @private | 1543 * @private |
| 1544 */ | 1544 */ |
| 1545 onLocalDestinationCapabilitiesSet_: function(event) { | 1545 onLocalDestinationCapabilitiesSet_: function(event) { |
| 1546 var rawCapabilities = event.settingsInfo.capabilities; | |
| 1547 assert(rawCapabilities != null, | |
|
dpapad
2017/05/01 17:39:28
assert(rawCapabilities);
The comment does not add
skau
2017/05/01 22:51:26
Done.
| |
| 1548 'Capabilities should never be null'); | |
| 1549 | |
| 1546 var destinationId = event.settingsInfo['printerId']; | 1550 var destinationId = event.settingsInfo['printerId']; |
| 1547 var printerName = event.settingsInfo['printerName']; | 1551 var printerName = event.settingsInfo['printerName']; |
| 1548 var printerDescription = event.settingsInfo['printerDescription']; | 1552 var printerDescription = event.settingsInfo['printerDescription']; |
| 1549 // PDF is special since we don't need to query the device for | 1553 // PDF is special since we don't need to query the device for |
| 1550 // capabilities. | 1554 // capabilities. |
| 1551 var origin = destinationId == | 1555 var origin = destinationId == |
| 1552 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ? | 1556 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ? |
| 1553 print_preview.Destination.Origin.LOCAL : this.platformOrigin_; | 1557 print_preview.Destination.Origin.LOCAL : this.platformOrigin_; |
| 1554 var key = this.getDestinationKey_( | 1558 var key = this.getDestinationKey_( |
| 1555 origin, | 1559 origin, |
| 1556 destinationId, | 1560 destinationId, |
| 1557 ''); | 1561 ''); |
| 1558 var destination = this.destinationMap_[key]; | 1562 var destination = this.destinationMap_[key]; |
| 1559 var capabilities = DestinationStore.localizeCapabilities_( | 1563 var capabilities = DestinationStore.localizeCapabilities_( |
| 1560 event.settingsInfo.capabilities); | 1564 rawCapabilities); |
| 1561 // Special case for PDF printer (until local printers capabilities are | 1565 // Special case for PDF printer (until local printers capabilities are |
| 1562 // reported in CDD format too). | 1566 // reported in CDD format too). |
| 1563 if (destinationId == | 1567 if (destinationId == |
| 1564 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) { | 1568 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) { |
| 1565 if (destination) { | 1569 if (destination) { |
| 1566 destination.capabilities = capabilities; | 1570 destination.capabilities = capabilities; |
| 1567 } | 1571 } |
| 1568 } else { | 1572 } else { |
| 1569 if (destination) { | 1573 if (destination) { |
| 1570 // In case there were multiple capabilities request for this local | 1574 // In case there were multiple capabilities request for this local |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1774 return this.getDestinationKey_( | 1778 return this.getDestinationKey_( |
| 1775 destination.origin, destination.id, destination.account); | 1779 destination.origin, destination.id, destination.account); |
| 1776 } | 1780 } |
| 1777 }; | 1781 }; |
| 1778 | 1782 |
| 1779 // Export | 1783 // Export |
| 1780 return { | 1784 return { |
| 1781 DestinationStore: DestinationStore | 1785 DestinationStore: DestinationStore |
| 1782 }; | 1786 }; |
| 1783 }); | 1787 }); |
| OLD | NEW |