| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "printing/print_settings.h" | 5 #include "printing/print_settings.h" |
| 6 | 6 |
| 7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "printing/print_job_constants.h" | 8 #include "printing/print_job_constants.h" |
| 9 #include "printing/units.h" | 9 #include "printing/units.h" |
| 10 | 10 |
| 11 namespace printing { | 11 namespace printing { |
| 12 | 12 |
| 13 #if defined (USE_CUPS) | |
| 14 void GetColorModelForMode( | |
| 15 int color_mode, std::string* color_setting_name, std::string* color_value) { | |
| 16 #if defined(OS_MACOSX) | |
| 17 const char kCUPSColorMode[] = "ColorMode"; | |
| 18 const char kCUPSColorModel[] = "ColorModel"; | |
| 19 const char kCUPSPrintoutMode[] = "PrintoutMode"; | |
| 20 const char kCUPSProcessColorModel[] = "ProcessColorModel"; | |
| 21 #else | |
| 22 const char kCUPSColorMode[] = "cups-ColorMode"; | |
| 23 const char kCUPSColorModel[] = "cups-ColorModel"; | |
| 24 const char kCUPSPrintoutMode[] = "cups-PrintoutMode"; | |
| 25 const char kCUPSProcessColorModel[] = "cups-ProcessColorModel"; | |
| 26 #endif | |
| 27 | |
| 28 color_setting_name->assign(kCUPSColorModel); | |
| 29 switch (color_mode) { | |
| 30 case printing::COLOR: | |
| 31 color_value->assign(printing::kColor); | |
| 32 break; | |
| 33 case printing::CMYK: | |
| 34 color_value->assign(printing::kCMYK); | |
| 35 break; | |
| 36 case printing::PRINTOUTMODE_NORMAL: | |
| 37 color_value->assign(printing::kNormal); | |
| 38 color_setting_name->assign(kCUPSPrintoutMode); | |
| 39 break; | |
| 40 case printing::PRINTOUTMODE_NORMAL_GRAY: | |
| 41 color_value->assign(printing::kNormalGray); | |
| 42 color_setting_name->assign(kCUPSPrintoutMode); | |
| 43 break; | |
| 44 case printing::RGB16: | |
| 45 color_value->assign(printing::kRGB16); | |
| 46 break; | |
| 47 case printing::RGBA: | |
| 48 color_value->assign(printing::kRGBA); | |
| 49 break; | |
| 50 case printing::RGB: | |
| 51 color_value->assign(printing::kRGB); | |
| 52 break; | |
| 53 case printing::CMY: | |
| 54 color_value->assign(printing::kCMY); | |
| 55 break; | |
| 56 case printing::CMY_K: | |
| 57 color_value->assign(printing::kCMY_K); | |
| 58 break; | |
| 59 case printing::BLACK: | |
| 60 color_value->assign(printing::kBlack); | |
| 61 break; | |
| 62 case printing::GRAY: | |
| 63 color_value->assign(printing::kGray); | |
| 64 break; | |
| 65 case printing::COLORMODE_COLOR: | |
| 66 color_setting_name->assign(kCUPSColorMode); | |
| 67 color_value->assign(printing::kColor); | |
| 68 break; | |
| 69 case printing::COLORMODE_MONOCHROME: | |
| 70 color_setting_name->assign(kCUPSColorMode); | |
| 71 color_value->assign(printing::kMonochrome); | |
| 72 break; | |
| 73 case printing::HP_COLOR_COLOR: | |
| 74 color_setting_name->assign(kColor); | |
| 75 color_value->assign(printing::kColor); | |
| 76 break; | |
| 77 case printing::HP_COLOR_BLACK: | |
| 78 color_setting_name->assign(kColor); | |
| 79 color_value->assign(printing::kBlack); | |
| 80 break; | |
| 81 case printing::PROCESSCOLORMODEL_CMYK: | |
| 82 color_setting_name->assign(kCUPSProcessColorModel); | |
| 83 color_value->assign(printing::kCMYK); | |
| 84 break; | |
| 85 case printing::PROCESSCOLORMODEL_GREYSCALE: | |
| 86 color_setting_name->assign(kCUPSProcessColorModel); | |
| 87 color_value->assign(printing::kGreyscale); | |
| 88 break; | |
| 89 case printing::PROCESSCOLORMODEL_RGB: | |
| 90 color_setting_name->assign(kCUPSProcessColorModel); | |
| 91 color_value->assign(printing::kRGB); | |
| 92 break; | |
| 93 default: | |
| 94 color_value->assign(printing::kGrayscale); | |
| 95 break; | |
| 96 } | |
| 97 } | |
| 98 #endif | |
| 99 | |
| 100 bool isColorModelSelected(int model) { | |
| 101 return (model != printing::GRAY && | |
| 102 model != printing::BLACK && | |
| 103 model != printing::PRINTOUTMODE_NORMAL_GRAY && | |
| 104 model != printing::COLORMODE_MONOCHROME && | |
| 105 model != printing::PROCESSCOLORMODEL_GREYSCALE && | |
| 106 model != printing::HP_COLOR_BLACK); | |
| 107 } | |
| 108 | |
| 109 // Global SequenceNumber used for generating unique cookie values. | 13 // Global SequenceNumber used for generating unique cookie values. |
| 110 static base::AtomicSequenceNumber cookie_seq(base::LINKER_INITIALIZED); | 14 static base::AtomicSequenceNumber cookie_seq(base::LINKER_INITIALIZED); |
| 111 | 15 |
| 112 PrintSettings::PrintSettings() | 16 PrintSettings::PrintSettings() |
| 113 : min_shrink(1.25), | 17 : min_shrink(1.25), |
| 114 max_shrink(2.0), | 18 max_shrink(2.0), |
| 115 desired_dpi(72), | 19 desired_dpi(72), |
| 116 selection_only(false), | 20 selection_only(false), |
| 117 use_overlays(true), | 21 use_overlays(true), |
| 118 display_header_footer(false), | 22 display_header_footer(false), |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 100 } |
| 197 | 101 |
| 198 void PrintSettings::SetOrientation(bool landscape) { | 102 void PrintSettings::SetOrientation(bool landscape) { |
| 199 if (landscape_ != landscape) { | 103 if (landscape_ != landscape) { |
| 200 landscape_ = landscape; | 104 landscape_ = landscape; |
| 201 page_setup_device_units_.FlipOrientation(); | 105 page_setup_device_units_.FlipOrientation(); |
| 202 } | 106 } |
| 203 } | 107 } |
| 204 | 108 |
| 205 } // namespace printing | 109 } // namespace printing |
| OLD | NEW |