summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/printing/print_dialog_gtk.cc36
-rw-r--r--chrome/browser/resources/print_preview.js2
-rw-r--r--printing/print_job_constants.h7
-rw-r--r--printing/printing_context.h7
-rw-r--r--printing/printing_context_mac.h1
-rw-r--r--printing/printing_context_mac.mm1
6 files changed, 43 insertions, 11 deletions
diff --git a/chrome/browser/printing/print_dialog_gtk.cc b/chrome/browser/printing/print_dialog_gtk.cc
index 5edab34..596ec9d 100644
--- a/chrome/browser/printing/print_dialog_gtk.cc
+++ b/chrome/browser/printing/print_dialog_gtk.cc
@@ -29,6 +29,17 @@ using printing::PrintSettings;
namespace {
+// CUPS ColorModel attribute and values.
+const char kCUPSColorModel[] = "cups-ColorModel";
+const char kColor[] = "Color";
+const char kGrayscale[] = "Grayscale";
+
+// CUPS Duplex attribute and values.
+const char kCUPSDuplex[] = "cups-Duplex";
+const char kDuplexNone[] = "None";
+const char kDuplexTumble[] = "DuplexTumble";
+const char kDuplexNoTumble[] = "DuplexNoTumble";
+
// Helper class to track GTK printers.
class GtkPrinterList {
public:
@@ -179,8 +190,29 @@ bool PrintDialogGtk::UpdateSettings(const DictionaryValue& settings,
return false;
gtk_print_settings_set_collate(gtk_settings_, collate);
- // TODO(thestig) Color: gtk_print_settings_set_color() does not work.
- // TODO(thestig) Duplex: gtk_print_settings_set_duplex() does not work.
+ bool is_color;
+ if (!settings.GetBoolean(printing::kSettingColor, &is_color))
+ return false;
+
+ gtk_print_settings_set(gtk_settings_, kCUPSColorModel,
+ is_color ? kColor : kGrayscale);
+ int mode;
+ if (!settings.GetInteger(printing::kSettingDuplexMode, &mode))
+ return false;
+
+ const char* cups_duplex_mode;
+ switch (mode) {
+ case printing::LONG_EDGE:
+ cups_duplex_mode = kDuplexNoTumble;
+ break;
+ case printing::SHORT_EDGE:
+ cups_duplex_mode = kDuplexTumble;
+ break;
+ default:
+ cups_duplex_mode = kDuplexNone;
+ break;
+ }
+ gtk_print_settings_set(gtk_settings_, kCUPSDuplex, cups_duplex_mode);
InitPrintSettings(ranges);
return true;
diff --git a/chrome/browser/resources/print_preview.js b/chrome/browser/resources/print_preview.js
index 79b33dc..b281892b 100644
--- a/chrome/browser/resources/print_preview.js
+++ b/chrome/browser/resources/print_preview.js
@@ -268,7 +268,7 @@ function isTwoSided() {
* @return {number} duplex mode.
*/
function getDuplexMode() {
- // Constants values matches printing::PrintingContext::DuplexMode enum.
+ // Constants values matches printing::DuplexMode enum.
const SIMPLEX = 0;
const LONG_EDGE = 1;
const SHORT_EDGE = 2;
diff --git a/printing/print_job_constants.h b/printing/print_job_constants.h
index 1005ca3..5fe4bc6 100644
--- a/printing/print_job_constants.h
+++ b/printing/print_job_constants.h
@@ -18,6 +18,13 @@ extern const char kSettingPageRangeTo[];
extern const char kSettingPrinterName[];
extern const char kSettingPrintToPDF[];
+// Print job duplex mode values.
+enum DuplexMode {
+ SIMPLEX,
+ LONG_EDGE,
+ SHORT_EDGE,
+};
+
} // namespace printing
#endif // PRINTING_PRINT_JOB_CONSTANTS_H_
diff --git a/printing/printing_context.h b/printing/printing_context.h
index 77ac844..c4e2094 100644
--- a/printing/printing_context.h
+++ b/printing/printing_context.h
@@ -99,13 +99,6 @@ class PrintingContext {
}
protected:
- // Print job duplex mode values.
- enum DuplexMode {
- SIMPLEX,
- LONG_EDGE,
- SHORT_EDGE,
- };
-
explicit PrintingContext(const std::string& app_locale);
// Reinitializes the settings for object reuse.
diff --git a/printing/printing_context_mac.h b/printing/printing_context_mac.h
index 3005602..ef7e75c 100644
--- a/printing/printing_context_mac.h
+++ b/printing/printing_context_mac.h
@@ -9,6 +9,7 @@
#include "base/memory/scoped_nsobject.h"
#include "printing/printing_context.h"
+#include "printing/print_job_constants.h"
#ifdef __OBJC__
@class NSPrintInfo;
diff --git a/printing/printing_context_mac.mm b/printing/printing_context_mac.mm
index 755069a..cb60f9f 100644
--- a/printing/printing_context_mac.mm
+++ b/printing/printing_context_mac.mm
@@ -11,7 +11,6 @@
#include "base/mac/scoped_cftyperef.h"
#include "base/sys_string_conversions.h"
#include "base/values.h"
-#include "printing/print_job_constants.h"
#include "printing/print_settings_initializer_mac.h"
static const CFStringRef kColorModel = CFSTR("ColorModel");