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

Side by Side Diff: chrome/browser/resources/print_preview/data/destination_store.js

Issue 2848093002: Process null capabilities as a capability fetch failure. (Closed)
Patch Set: refine assertions Created 3 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 * 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
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);
1548
1546 var destinationId = event.settingsInfo['printerId']; 1549 var destinationId = event.settingsInfo['printerId'];
1547 var printerName = event.settingsInfo['printerName']; 1550 var printerName = event.settingsInfo['printerName'];
1548 var printerDescription = event.settingsInfo['printerDescription']; 1551 var printerDescription = event.settingsInfo['printerDescription'];
1549 // PDF is special since we don't need to query the device for 1552 // PDF is special since we don't need to query the device for
1550 // capabilities. 1553 // capabilities.
1551 var origin = destinationId == 1554 var origin = destinationId ==
1552 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ? 1555 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ?
1553 print_preview.Destination.Origin.LOCAL : this.platformOrigin_; 1556 print_preview.Destination.Origin.LOCAL : this.platformOrigin_;
1554 var key = this.getDestinationKey_( 1557 var key = this.getDestinationKey_(
1555 origin, 1558 origin,
1556 destinationId, 1559 destinationId,
1557 ''); 1560 '');
1558 var destination = this.destinationMap_[key]; 1561 var destination = this.destinationMap_[key];
1559 var capabilities = DestinationStore.localizeCapabilities_( 1562 var capabilities = DestinationStore.localizeCapabilities_(
1560 event.settingsInfo.capabilities); 1563 rawCapabilities);
dpapad 2017/05/02 00:07:41 If we already assert in native_layer.js before tri
skau 2017/05/02 01:52:47 Done.
1561 // Special case for PDF printer (until local printers capabilities are 1564 // Special case for PDF printer (until local printers capabilities are
1562 // reported in CDD format too). 1565 // reported in CDD format too).
1563 if (destinationId == 1566 if (destinationId ==
1564 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) { 1567 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) {
1565 if (destination) { 1568 if (destination) {
1566 destination.capabilities = capabilities; 1569 destination.capabilities = capabilities;
1567 } 1570 }
1568 } else { 1571 } else {
1569 if (destination) { 1572 if (destination) {
1570 // In case there were multiple capabilities request for this local 1573 // In case there were multiple capabilities request for this local
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 return this.getDestinationKey_( 1777 return this.getDestinationKey_(
1775 destination.origin, destination.id, destination.account); 1778 destination.origin, destination.id, destination.account);
1776 } 1779 }
1777 }; 1780 };
1778 1781
1779 // Export 1782 // Export
1780 return { 1783 return {
1781 DestinationStore: DestinationStore 1784 DestinationStore: DestinationStore
1782 }; 1785 };
1783 }); 1786 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698