Skip to content

Commit

Permalink
Add a feature flag to use the CUPS IPP printing backend on macOS
Browse files Browse the repository at this point in the history
Add |printing::features::kCupsIppPrintingBackend| and the corresponding
UI in chrome://flags for switching printing backends on macOS.

The existing CUPS backend calls the deprecated PPD API. In a future CL,
the switch will allow use of the CUPS IPP backend, which uses an
up-to-date API for fetching printer attributes and managing printers.

The flag does not do anything yet.

Bug: 226176
Change-Id: Ifbacfbd1872eb7c47b3130694de920a94f42fc15
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2063220
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Sean Kau <skau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750018}
  • Loading branch information
Daniel Hosseinian authored and Commit Bot committed Mar 13, 2020
1 parent a6a3bfc commit 159cb3d
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 5 deletions.
7 changes: 7 additions & 0 deletions chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3372,6 +3372,13 @@ const FeatureEntry kFeatureEntries[] = {
#endif // BUILDFLAG(ENABLE_PDF)

#if BUILDFLAG(ENABLE_PRINTING)
#if defined(OS_MACOSX)
{"cups-ipp-printing-backend",
flag_descriptions::kCupsIppPrintingBackendName,
flag_descriptions::kCupsIppPrintingBackendDescription, kOsMac,
FEATURE_VALUE_TYPE(printing::features::kCupsIppPrintingBackend)},
#endif // defined(OS_MACOSX)

#if defined(OS_WIN)
{"use-xps-for-printing", flag_descriptions::kUseXpsForPrintingName,
flag_descriptions::kUseXpsForPrintingDescription, kOsWin,
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/flag-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,11 @@
"owners": [ "khorimoto", "nohle" ],
"expiry_milestone": 86
},
{
"name": "cups-ipp-printing-backend",
"owners": [ "dhoss", "chrome-print@google.com" ],
"expiry_milestone": 89
},
{
"name": "d3d11-video-decoder",
"owners": [ "liberato", "tmathmeyer", "videostack-eng" ],
Expand Down
9 changes: 9 additions & 0 deletions chrome/browser/flag_descriptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2845,6 +2845,7 @@ const char kUseWinrtMidiApiDescription[] =
"Use Windows Runtime MIDI API for WebMIDI (effective only on Windows 10 or "
"later).";

#if BUILDFLAG(ENABLE_PRINTING)
const char kUseXpsForPrintingName[] = "Use XPS for printing";
const char kUseXpsForPrintingDescription[] =
"When enabled, use XPS printing API instead of the GDI print API.";
Expand All @@ -2853,6 +2854,7 @@ const char kUseXpsForPrintingFromPdfName[] = "Use XPS for printing from PDF";
const char kUseXpsForPrintingFromPdfDescription[] =
"When enabled, use XPS printing API instead of the GDI print API when "
"printing PDF documents.";
#endif // BUILDFLAG(ENABLE_PRINTING)

#if BUILDFLAG(ENABLE_SPELLCHECK)
const char kWinUseBrowserSpellCheckerName[] =
Expand Down Expand Up @@ -2880,6 +2882,13 @@ const char kWinUseHybridSpellCheckerDescription[] =

#if defined(OS_MACOSX)

#if BUILDFLAG(ENABLE_PRINTING)
const char kCupsIppPrintingBackendName[] = "CUPS IPP Printing Backend";
const char kCupsIppPrintingBackendDescription[] =
"Use the CUPS IPP printing backend instead of the original CUPS backend "
"that calls the PPD API.";
#endif // BUILDFLAG(ENABLE_PRINTING)

const char kImmersiveFullscreenName[] = "Immersive Fullscreen Toolbar";
const char kImmersiveFullscreenDescription[] =
"Automatically hide and show the toolbar in fullscreen.";
Expand Down
8 changes: 8 additions & 0 deletions chrome/browser/flag_descriptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "device/vr/buildflags/buildflags.h"
#include "media/media_buildflags.h"
#include "ppapi/buildflags/buildflags.h"
#include "printing/buildflags/buildflags.h"

#if defined(OS_LINUX)
#include "base/allocator/buildflags.h"
Expand Down Expand Up @@ -1629,11 +1630,13 @@ extern const char kUseAngleD3D11on12[];
extern const char kUseWinrtMidiApiName[];
extern const char kUseWinrtMidiApiDescription[];

#if BUILDFLAG(ENABLE_PRINTING)
extern const char kUseXpsForPrintingName[];
extern const char kUseXpsForPrintingDescription[];

extern const char kUseXpsForPrintingFromPdfName[];
extern const char kUseXpsForPrintingFromPdfDescription[];
#endif // BUILDFLAG(ENABLE_PRINTING)

#if BUILDFLAG(ENABLE_SPELLCHECK)
extern const char kWinUseBrowserSpellCheckerName[];
Expand All @@ -1652,6 +1655,11 @@ extern const char kWinUseHybridSpellCheckerDescription[];

#if defined(OS_MACOSX)

#if BUILDFLAG(ENABLE_PRINTING)
extern const char kCupsIppPrintingBackendName[];
extern const char kCupsIppPrintingBackendDescription[];
#endif // BUILDFLAG(ENABLE_PRINTING)

extern const char kImmersiveFullscreenName[];
extern const char kImmersiveFullscreenDescription[];

Expand Down
9 changes: 8 additions & 1 deletion printing/printing_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ const base::Feature kAdvancedPpdAttributes{"AdvancedPpdAttributes",
base::FEATURE_ENABLED_BY_DEFAULT};
#endif // defined(OS_CHROMEOS)

#if defined(OS_MACOSX)
// Use the CUPS IPP printing backend instead of the original CUPS backend that
// calls the deprecated PPD API.
const base::Feature kCupsIppPrintingBackend{"CupsIppPrintingBackend",
base::FEATURE_DISABLED_BY_DEFAULT};
#endif // defined(OS_MACOSX)

#if defined(OS_WIN)
// Use XPS for printing instead of GDI.
const base::Feature kUseXpsForPrinting{"UseXpsForPrinting",
base::FEATURE_DISABLED_BY_DEFAULT};

// Use XPS for printing instead of GDI for printing PDF documents. This is
// Use XPS for printing instead of GDI for printing PDF documents. This is
// independent of |kUseXpsForPrinting|; can use XPS for PDFs even if still using
// GDI for modifiable content.
const base::Feature kUseXpsForPrintingFromPdf{
Expand Down
13 changes: 9 additions & 4 deletions printing/printing_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
namespace printing {
namespace features {

// The following features are declared alphabetically. The features should be
// documented with descriptions of their behaviors in the .cc file.

#if defined(OS_CHROMEOS)
// All features in alphabetical order. The features should be documented
// alongside the definition of their values in the .cc file.
PRINTING_EXPORT extern const base::Feature kAdvancedPpdAttributes;
#endif
#endif // defined(OS_CHROMEOS)

#if defined(OS_MACOSX)
PRINTING_EXPORT extern const base::Feature kCupsIppPrintingBackend;
#endif // defined(OS_MACOSX)

#if defined(OS_WIN)
PRINTING_EXPORT extern const base::Feature kUseXpsForPrinting;
Expand All @@ -29,7 +34,7 @@ PRINTING_EXPORT bool IsXpsPrintCapabilityRequired();
// Helper function to determine if printing of a document from a particular
// source should be done using XPS printing API instead of with GDI.
PRINTING_EXPORT bool ShouldPrintUsingXps(bool source_is_pdf);
#endif
#endif // defined(OS_WIN)

PRINTING_EXPORT extern const base::Feature kUseFrameAssociatedLoaderFactory;

Expand Down
2 changes: 2 additions & 0 deletions tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38330,6 +38330,7 @@ from previous Chrome versions.
<int value="-920204598" label="ScrollAnchorSerialization:enabled"/>
<int value="-918900957" label="AutofillCreditCardAssist:disabled"/>
<int value="-918618075" label="enable-service-worker"/>
<int value="-915328316" label="CupsIppPrintingBackend:disabled"/>
<int value="-915035507" label="ArcPrintSpoolerExperiment:enabled"/>
<int value="-914210146" label="enable-web-based-signin"/>
<int value="-914097698" label="EnableDbusAndX11StatusIcons:disabled"/>
Expand Down Expand Up @@ -40404,6 +40405,7 @@ from previous Chrome versions.
<int value="1603578716" label="CaptionSettings:disabled"/>
<int value="1605398303" label="MacSystemMediaPermissionsInfoUI:enabled"/>
<int value="1605611615" label="enable-webrtc-srtp-aes-gcm"/>
<int value="1609059016" label="CupsIppPrintingBackend:enabled"/>
<int value="1611522475" label="AutofillPrimaryInfoStyleExperiment:disabled"/>
<int value="1612206633" label="CCTModuleCustomHeader:enabled"/>
<int value="1612446645" label="enable-weak-memorycache"/>
Expand Down

0 comments on commit 159cb3d

Please sign in to comment.