| Index: printing/backend/cups_helper.cc
|
| diff --git a/printing/backend/cups_helper.cc b/printing/backend/cups_helper.cc
|
| index 4eaad46be617d0687254d3cc336f72e0c60aeb2f..aaf3f86825e55bddfd0ad9b2aedc6c0f30a45df9 100644
|
| --- a/printing/backend/cups_helper.cc
|
| +++ b/printing/backend/cups_helper.cc
|
| @@ -36,9 +36,17 @@ const char kPrintoutMode[] = "PrintoutMode";
|
| const char kDraftGray[] = "Draft.Gray";
|
| const char kHighGray[] = "High.Gray";
|
|
|
| -const char kDuplex[] = "Duplex";
|
| -const char kDuplexNone[] = "None";
|
| -const char kPageSize[] = "PageSize";
|
| +constexpr char kDuplex[] = "Duplex";
|
| +constexpr char kDuplexNone[] = "None";
|
| +constexpr char kDuplexTumble[] = "DuplexTumble";
|
| +constexpr char kPageSize[] = "PageSize";
|
| +
|
| +// Brother printer specific options.
|
| +constexpr char kBrotherDuplex[] = "BRDuplex";
|
| +constexpr char kBrotherMonoColor[] = "BRMonoColor";
|
| +constexpr char kBrotherPrintQuality[] = "BRPrintQuality";
|
| +constexpr char kFullColor[] = "FullColor";
|
| +constexpr char kMono[] = "Mono";
|
|
|
| const double kMicronsPerPoint = 10.0f * kHundrethsMMPerInch / kPointsPerInch;
|
|
|
| @@ -121,6 +129,34 @@ void MarkLpOptions(base::StringPiece printer_name, ppd_file_t** ppd) {
|
| }
|
| }
|
|
|
| +void GetDuplexSettings(ppd_file_t* ppd,
|
| + bool* duplex_capable,
|
| + DuplexMode* duplex_default) {
|
| + ppd_choice_t* duplex_choice = ppdFindMarkedChoice(ppd, kDuplex);
|
| + if (!duplex_choice) {
|
| + ppd_option_t* option = ppdFindOption(ppd, kDuplex);
|
| + if (!option)
|
| + option = ppdFindOption(ppd, kBrotherDuplex);
|
| + if (!option)
|
| + return;
|
| +
|
| + duplex_choice = ppdFindChoice(option, option->defchoice);
|
| + }
|
| +
|
| + if (!duplex_choice)
|
| + return;
|
| +
|
| + *duplex_capable = true;
|
| + const char* choice = duplex_choice->choice;
|
| + if (base::EqualsCaseInsensitiveASCII(choice, kDuplexNone)) {
|
| + *duplex_default = SIMPLEX;
|
| + } else if (base::EqualsCaseInsensitiveASCII(choice, kDuplexTumble)) {
|
| + *duplex_default = SHORT_EDGE;
|
| + } else {
|
| + *duplex_default = LONG_EDGE;
|
| + }
|
| +}
|
| +
|
| bool GetBasicColorModelSettings(ppd_file_t* ppd,
|
| ColorModel* color_model_for_black,
|
| ColorModel* color_model_for_color,
|
| @@ -209,7 +245,7 @@ bool GetColorModeSettings(ppd_file_t* ppd,
|
| ColorModel* color_model_for_black,
|
| ColorModel* color_model_for_color,
|
| bool* color_is_default) {
|
| - // Samsung printers use "ColorMode" attribute in their ppds.
|
| + // Samsung printers use "ColorMode" attribute in their PPDs.
|
| ppd_option_t* color_mode_option = ppdFindOption(ppd, kColorMode);
|
| if (!color_mode_option)
|
| return false;
|
| @@ -233,11 +269,45 @@ bool GetColorModeSettings(ppd_file_t* ppd,
|
| return true;
|
| }
|
|
|
| +bool GetBrotherColorSettings(ppd_file_t* ppd,
|
| + ColorModel* color_model_for_black,
|
| + ColorModel* color_model_for_color,
|
| + bool* color_is_default) {
|
| + // Some Brother printers use "BRMonoColor" attribute in their PPDs.
|
| + // Some Brother printers use "BRPrintQuality" attribute in their PPDs.
|
| + ppd_option_t* color_mode_option = ppdFindOption(ppd, kBrotherMonoColor);
|
| + if (!color_mode_option)
|
| + color_mode_option = ppdFindOption(ppd, kBrotherPrintQuality);
|
| + if (!color_mode_option)
|
| + return false;
|
| +
|
| + if (ppdFindChoice(color_mode_option, kFullColor) ||
|
| + ppdFindChoice(color_mode_option, kColor)) {
|
| + *color_model_for_color = BROTHER_COLOR_COLOR;
|
| + }
|
| + if (ppdFindChoice(color_mode_option, kBlack) ||
|
| + ppdFindChoice(color_mode_option, kMono)) {
|
| + *color_model_for_black = BROTHER_COLOR_BLACK;
|
| + }
|
| +
|
| + ppd_choice_t* marked_choice = ppdFindMarkedChoice(ppd, kColorMode);
|
| + if (!marked_choice) {
|
| + marked_choice =
|
| + ppdFindChoice(color_mode_option, color_mode_option->defchoice);
|
| + }
|
| + if (marked_choice) {
|
| + *color_is_default =
|
| + !base::EqualsCaseInsensitiveASCII(marked_choice->choice, kBlack) &&
|
| + !base::EqualsCaseInsensitiveASCII(marked_choice->choice, kMono);
|
| + }
|
| + return true;
|
| +}
|
| +
|
| bool GetHPColorSettings(ppd_file_t* ppd,
|
| ColorModel* color_model_for_black,
|
| ColorModel* color_model_for_color,
|
| bool* color_is_default) {
|
| - // HP printers use "Color/Color Model" attribute in their ppds.
|
| + // HP printers use "Color/Color Model" attribute in their PPDs.
|
| ppd_option_t* color_mode_option = ppdFindOption(ppd, kColor);
|
| if (!color_mode_option)
|
| return false;
|
| @@ -263,7 +333,7 @@ bool GetProcessColorModelSettings(ppd_file_t* ppd,
|
| ColorModel* color_model_for_black,
|
| ColorModel* color_model_for_color,
|
| bool* color_is_default) {
|
| - // Canon printers use "ProcessColorModel" attribute in their ppds.
|
| + // Canon printers use "ProcessColorModel" attribute in their PPDs.
|
| ppd_option_t* color_mode_option = ppdFindOption(ppd, kProcessColorModel);
|
| if (!color_mode_option)
|
| return false;
|
| @@ -301,10 +371,11 @@ bool GetColorModelSettings(ppd_file_t* ppd,
|
| *is_color = is_color_device;
|
| return (is_color_device &&
|
| GetBasicColorModelSettings(ppd, cm_black, cm_color, is_color)) ||
|
| - GetPrintOutModeColorSettings(ppd, cm_black, cm_color, is_color) ||
|
| - GetColorModeSettings(ppd, cm_black, cm_color, is_color) ||
|
| - GetHPColorSettings(ppd, cm_black, cm_color, is_color) ||
|
| - GetProcessColorModelSettings(ppd, cm_black, cm_color, is_color);
|
| + GetPrintOutModeColorSettings(ppd, cm_black, cm_color, is_color) ||
|
| + GetColorModeSettings(ppd, cm_black, cm_color, is_color) ||
|
| + GetHPColorSettings(ppd, cm_black, cm_color, is_color) ||
|
| + GetBrotherColorSettings(ppd, cm_black, cm_color, is_color) ||
|
| + GetProcessColorModelSettings(ppd, cm_black, cm_color, is_color);
|
| }
|
|
|
| // Default port for IPP print servers.
|
| @@ -377,20 +448,7 @@ bool ParsePpdCapabilities(base::StringPiece printer_name,
|
| caps.collate_default = true;
|
| caps.copies_capable = true;
|
|
|
| - ppd_choice_t* duplex_choice = ppdFindMarkedChoice(ppd, kDuplex);
|
| - if (!duplex_choice) {
|
| - ppd_option_t* option = ppdFindOption(ppd, kDuplex);
|
| - if (option)
|
| - duplex_choice = ppdFindChoice(option, option->defchoice);
|
| - }
|
| -
|
| - if (duplex_choice) {
|
| - caps.duplex_capable = true;
|
| - if (!base::EqualsCaseInsensitiveASCII(duplex_choice->choice, kDuplexNone))
|
| - caps.duplex_default = LONG_EDGE;
|
| - else
|
| - caps.duplex_default = SIMPLEX;
|
| - }
|
| + GetDuplexSettings(ppd, &caps.duplex_capable, &caps.duplex_default);
|
|
|
| bool is_color = false;
|
| ColorModel cm_color = UNKNOWN_COLOR_MODEL, cm_black = UNKNOWN_COLOR_MODEL;
|
|
|