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

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

Issue 7817013: PrintPreview: Added code to identify the printer default duplex value. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/print_preview.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/print_preview/copies_settings.js
diff --git a/chrome/browser/resources/print_preview/copies_settings.js b/chrome/browser/resources/print_preview/copies_settings.js
index 3c48e45e271cd50787056e8a05a498e00e9954e9..899673a4382267d012f50a733fa70baf30f2b707 100644
--- a/chrome/browser/resources/print_preview/copies_settings.js
+++ b/chrome/browser/resources/print_preview/copies_settings.js
@@ -22,6 +22,15 @@ cr.define('print_preview', function() {
this.collateCheckbox_ = $('collate');
this.hint_ = $('copies-hint');
this.twoSidedCheckbox_ = $('two-sided');
+
+ // Constant values matches printing::DuplexMode enum. Not using const
+ // keyword because it is not allowed by JS strict mode.
+ this.SIMPLEX = 0;
+ this.LONG_EDGE = 1;
+ this.SHORT_EDGE = 2;
+ this.UNKNOWN = -1;
+ // Store the default duplex setting value which we got from the printer.
+ this.printerDefaultDuplexValue_ = this.UNKNOWN;
}
cr.addSingletonGetter(CopiesSettings);
@@ -56,15 +65,19 @@ cr.define('print_preview', function() {
},
/**
- * Gets the duplex mode for printing.
+ * Gets the duplex mode information for printing.
* @return {number} duplex mode.
*/
- get duplexMode() {
- // Constant values matches printing::DuplexMode enum. Not using const
- // keyword because it is not allowed by JS strict mode.
- var SIMPLEX = 0;
- var LONG_EDGE = 1;
- return !this.twoSidedCheckbox_.checked ? SIMPLEX : LONG_EDGE;
+ get duplexMode() {
+ // On Windows, some printer doesn't specify their duplex values in the
+ // printer schema. If the printer duplex value is UNKNOWN, it is better
+ // to assign either "0" or "1" in DEVMODE structure according to user
+ // selected duplex value.
+ // Ref bug: http://code.google.com/p/chromium/issues/detail?id=89204
vandebo (ex-Chrome) 2011/09/03 00:58:26 http://crbug.com/89204
kmadhusu 2011/09/03 02:44:53 Done.
+ return !this.twoSidedCheckbox_.checked ?
vandebo (ex-Chrome) 2011/09/03 00:58:27 Double trinary is pretty ugly... how about if, els
kmadhusu 2011/09/03 02:44:53 Done.
+ this.SIMPLEX :
+ (this.printerDefaultDuplexValue == this.UNKNOWN ?
+ this.SHORT_EDGE : this.LONG_EDGE);
vandebo (ex-Chrome) 2011/09/03 00:58:27 I wonder if it would be clearer to define this.DUP
kmadhusu 2011/09/03 02:44:53 Yeah it will be consistent with the comment. Done.
},
/**
@@ -158,7 +171,10 @@ cr.define('print_preview', function() {
fadeInElement(this.copiesOption_);
$('hr-before-copies').classList.add('invisible');
}
- this.twoSidedCheckbox_.checked = e.printerCapabilities.setDuplexAsDefault;
+ this.printerDefaultDuplexValue =
+ e.printerCapabilities.printerDefaultDuplexValue;
+ if (this.printerDefaultDuplexValue >= 0)
vandebo (ex-Chrome) 2011/09/03 00:58:27 != UNKNOWN ?
kmadhusu 2011/09/03 02:44:53 Done.
+ this.twoSidedCheckbox_.checked = this.printerDefaultDuplexValue;
},
/**
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/print_preview.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698