Commit 85663d61 authored by Daniel Hosseinian's avatar Daniel Hosseinian Committed by Commit Bot

Set color model differently for CUPS IPP on macOS

Unlike other printer settings, color does not have its own function in
the Core Printing API [1]. Therefore, color needs to be set using the
generic PMPrintSettingsSetValue() function. When printing using CUPS
IPP, the passed key-value pair must be IPP constants.

All other printer settings work fine with CUPS IPP because they are
handled with their own Core Printing functions.

[1] https://developer.apple.com/documentation/applicationservices/core_printing

Bug: 1106437
Change-Id: I7ad153fc97f9e5797b263a6ec2ac10726deb27b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2303992
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789726}
parent 843f6a0d
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
#import <QuartzCore/QuartzCore.h> #import <QuartzCore/QuartzCore.h>
#include <cups/cups.h>
#import <iomanip> #import <iomanip>
#import <numeric> #import <numeric>
...@@ -16,6 +17,7 @@ ...@@ -16,6 +17,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "printing/print_settings_initializer_mac.h" #include "printing/print_settings_initializer_mac.h"
#include "printing/printing_features.h"
#include "printing/units.h" #include "printing/units.h"
namespace printing { namespace printing {
...@@ -389,7 +391,12 @@ bool PrintingContextMac::SetOutputColor(int color_mode) { ...@@ -389,7 +391,12 @@ bool PrintingContextMac::SetOutputColor(int color_mode) {
static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]); static_cast<PMPrintSettings>([print_info_.get() PMPrintSettings]);
std::string color_setting_name; std::string color_setting_name;
std::string color_value; std::string color_value;
GetColorModelForMode(color_mode, &color_setting_name, &color_value); if (base::FeatureList::IsEnabled(features::kCupsIppPrintingBackend)) {
color_setting_name = CUPS_PRINT_COLOR_MODE;
color_value = GetIppColorModelForMode(color_mode);
} else {
GetColorModelForMode(color_mode, &color_setting_name, &color_value);
}
base::ScopedCFTypeRef<CFStringRef> color_setting( base::ScopedCFTypeRef<CFStringRef> color_setting(
base::SysUTF8ToCFStringRef(color_setting_name)); base::SysUTF8ToCFStringRef(color_setting_name));
base::ScopedCFTypeRef<CFStringRef> output_color( base::ScopedCFTypeRef<CFStringRef> output_color(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment