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

Unified Diff: chrome/browser/resources/print_preview/native_layer.js

Issue 318293002: Revert of Revert of Generalize printer color model handling, get rid of CUPS specific case. Enable supported paper szes… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/native_layer.js
diff --git a/chrome/browser/resources/print_preview/native_layer.js b/chrome/browser/resources/print_preview/native_layer.js
index efdd55b36073695ca5a34c475a299e408e7ea0a9..0111ccd3b778b70283e398e87278bba04bd2e35d 100644
--- a/chrome/browser/resources/print_preview/native_layer.js
+++ b/chrome/browser/resources/print_preview/native_layer.js
@@ -168,6 +168,23 @@
},
/**
+ * @param {!print_preview.Destination} destination Destination to print to.
+ * @param {!print_preview.ticket_items.Color} color Color ticket item.
+ * @return {number} Native layer color model.
+ * @private
+ */
+ getNativeColorModel_: function(destination, color) {
+ // For non-local printers native color model is ignored anyway.
+ var option = destination.isLocal ? color.getSelectedOption() : null;
+ var nativeColorModel = parseInt(option ? option.vendor_id : null);
+ if (isNaN(nativeColorModel)) {
+ return color.getValue() ?
+ NativeLayer.ColorMode_.COLOR : NativeLayer.ColorMode_.GRAY;
+ }
+ return nativeColorModel;
+ },
+
+ /**
* Requests that a preview be generated. The following events may be
* dispatched in response:
* - PAGE_COUNT_READY
@@ -190,8 +207,7 @@
'pageRange': printTicketStore.pageRange.getDocumentPageRanges(),
'mediaSize': printTicketStore.mediaSize.getValue(),
'landscape': printTicketStore.landscape.getValue(),
- 'color': printTicketStore.color.getValue() ?
- NativeLayer.ColorMode_.COLOR : NativeLayer.ColorMode_.GRAY,
+ 'color': this.getNativeColorModel_(destination, printTicketStore.color),
'headerFooterEnabled': printTicketStore.headerFooter.getValue(),
'marginsType': printTicketStore.marginsType.getValue(),
'isFirstRequest': requestId == 0,
@@ -263,8 +279,7 @@
'pageRange': printTicketStore.pageRange.getDocumentPageRanges(),
'pageCount': printTicketStore.pageRange.getPageNumberSet().size,
'landscape': printTicketStore.landscape.getValue(),
- 'color': printTicketStore.color.getValue() ?
- NativeLayer.ColorMode_.COLOR : NativeLayer.ColorMode_.GRAY,
+ 'color': this.getNativeColorModel_(destination, printTicketStore.color),
'headerFooterEnabled': printTicketStore.headerFooter.getValue(),
'marginsType': printTicketStore.marginsType.getValue(),
'generateDraftData': true, // TODO(rltoscano): What should this be?

Powered by Google App Engine
This is Rietveld 408576698