Skip to content

Commit

Permalink
Migrate to OS_MAC and OS_APPLE in printing
Browse files Browse the repository at this point in the history
Bug: 1105907
Change-Id: I28cd4d958b4767b052c2821ec1032beb09579b6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2324899
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792755}
  • Loading branch information
Avi Drissman authored and Commit Bot committed Jul 29, 2020
1 parent d2b033e commit 578cd72
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions printing/backend/cups_printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bool CupsPrinter::ToPrinterInfo(PrinterBasicInfo* printer_info) const {
const std::string info = GetInfo();
const std::string make_and_model = GetMakeAndModel();

#if defined(OS_MACOSX)
#if defined(OS_MAC)
// On Mac, "printer-info" option specifies the human-readable printer name,
// while "printer-make-and-model" specifies the printer description.
printer_info->display_name = info;
Expand All @@ -96,7 +96,7 @@ bool CupsPrinter::ToPrinterInfo(PrinterBasicInfo* printer_info) const {
// On other platforms, "printer-info" specifies the printer description.
printer_info->display_name = printer->name;
printer_info->printer_description = info;
#endif // defined(OS_MACOSX)
#endif // defined(OS_MAC)

const char* state = cupsGetOption(kCUPSOptPrinterState, printer->num_options,
printer->options);
Expand Down
10 changes: 5 additions & 5 deletions printing/backend/print_backend_cups.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
#include "printing/backend/print_backend_consts.h"
#include "url/gurl.h"

#if defined(OS_MACOSX)
#if defined(OS_MAC)
#include "printing/backend/cups_connection.h"
#include "printing/backend/cups_ipp_utils.h"
#include "printing/backend/print_backend_cups_ipp.h"
#include "printing/printing_features.h"
#endif // defined(OS_MACOSX)
#endif // defined(OS_MAC)

namespace printing {

Expand Down Expand Up @@ -85,7 +85,7 @@ bool PrintBackendCUPS::PrinterBasicInfoFromCUPS(
printer.options[opt_index].value;
}

#if defined(OS_MACOSX)
#if defined(OS_MAC)
// On Mac, "printer-info" option specifies the printer name and
// "printer-make-and-model" specifies the printer description.
if (info)
Expand Down Expand Up @@ -223,13 +223,13 @@ scoped_refptr<PrintBackend> PrintBackend::CreateInstanceImpl(
const base::DictionaryValue* print_backend_settings,
const std::string& locale,
bool for_cloud_print) {
#if defined(OS_MACOSX)
#if defined(OS_MAC)
if (!for_cloud_print &&
base::FeatureList::IsEnabled(features::kCupsIppPrintingBackend)) {
return base::MakeRefCounted<PrintBackendCupsIpp>(
CreateConnection(print_backend_settings), locale);
}
#endif // defined(OS_MACOSX)
#endif // defined(OS_MAC)
std::string print_server_url_str, cups_blocking;
int encryption = HTTP_ENCRYPT_NEVER;
if (print_backend_settings) {
Expand Down
4 changes: 2 additions & 2 deletions printing/backend/print_backend_cups_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ TEST(PrintBackendCupsTest, PrinterBasicInfoFromCUPS) {

int num_options = 0;
cups_option_t* options = nullptr;
#if defined(OS_MACOSX)
#if defined(OS_MAC)
num_options =
cupsAddOption(kCUPSOptPrinterInfo, "info", num_options, &options);
num_options = cupsAddOption(kCUPSOptPrinterMakeAndModel, "description",
Expand All @@ -68,7 +68,7 @@ TEST(PrintBackendCupsTest, PrinterBasicInfoFromCUPS) {
cupsFreeDests(/*num_dests=*/1, printer);

EXPECT_EQ(kName, printer_info.printer_name);
#if defined(OS_MACOSX)
#if defined(OS_MAC)
EXPECT_EQ("info", printer_info.display_name);
#else
EXPECT_EQ(kName, printer_info.display_name);
Expand Down
4 changes: 2 additions & 2 deletions printing/metafile.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#if defined(OS_WIN)
#include <windows.h>
#elif defined(OS_MACOSX)
#elif defined(OS_MAC)
#include <ApplicationServices/ApplicationServices.h>
#include <CoreFoundation/CoreFoundation.h>
#include "base/mac/scoped_cftyperef.h"
Expand Down Expand Up @@ -48,7 +48,7 @@ class PRINTING_EXPORT MetafilePlayer {
// details.
virtual bool SafePlayback(printing::NativeDrawingContext hdc) const = 0;

#elif defined(OS_MACOSX)
#elif defined(OS_MAC)
// Renders the given page into |rect| in the given context.
// Pages use a 1-based index. |autorotate| determines whether the source PDF
// should be autorotated to fit on the destination page. |fit_to_page|
Expand Down
6 changes: 3 additions & 3 deletions printing/metafile_skia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "third_party/skia/src/utils/SkMultiPictureDocument.h"
#include "ui/gfx/skia_util.h"

#if defined(OS_MACOSX)
#if defined(OS_MAC)
#include "printing/pdf_metafile_cg_mac.h"
#endif

Expand Down Expand Up @@ -87,7 +87,7 @@ struct MetafileSkiaData {
SkSize size;
mojom::SkiaDocumentType type;

#if defined(OS_MACOSX)
#if defined(OS_MAC)
PdfMetafileCg pdf_cg;
#endif
};
Expand Down Expand Up @@ -294,7 +294,7 @@ bool MetafileSkia::SafePlayback(printing::NativeDrawingContext hdc) const {
return false;
}

#elif defined(OS_MACOSX)
#elif defined(OS_MAC)
/* TODO(caryclark): The set up of PluginInstance::PrintPDFOutput may result in
rasterized output. Even if that flow uses PdfMetafileCg::RenderPage,
the drawing of the PDF into the canvas may result in a rasterized output.
Expand Down
2 changes: 1 addition & 1 deletion printing/metafile_skia.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class PRINTING_EXPORT MetafileSkia : public Metafile {
bool Playback(printing::NativeDrawingContext hdc,
const RECT* rect) const override;
bool SafePlayback(printing::NativeDrawingContext hdc) const override;
#elif defined(OS_MACOSX)
#elif defined(OS_MAC)
bool RenderPage(unsigned int page_number,
printing::NativeDrawingContext context,
const CGRect& rect,
Expand Down
4 changes: 2 additions & 2 deletions printing/native_drawing_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

#if defined(OS_WIN)
#include <windows.h>
#elif defined(OS_MACOSX)
#elif defined(OS_MAC)
typedef struct CGContext* CGContextRef;
#endif

namespace printing {

#if defined(OS_WIN)
typedef HDC NativeDrawingContext;
#elif defined(OS_MACOSX)
#elif defined(OS_MAC)
typedef CGContextRef NativeDrawingContext;
#else
typedef void* NativeDrawingContext;
Expand Down
10 changes: 5 additions & 5 deletions printing/print_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "printing/print_job_constants.h"
#include "printing/units.h"

#if defined(USE_CUPS) && (defined(OS_MACOSX) || defined(OS_CHROMEOS))
#if defined(USE_CUPS) && (defined(OS_MAC) || defined(OS_CHROMEOS))
#include <cups/cups.h>
#endif

Expand Down Expand Up @@ -40,7 +40,7 @@ const std::string& GetAgent() {
void GetColorModelForMode(int color_mode,
std::string* color_setting_name,
std::string* color_value) {
#if defined(OS_MACOSX)
#if defined(OS_MAC)
constexpr char kCUPSColorMode[] = "ColorMode";
constexpr char kCUPSColorModel[] = "ColorModel";
constexpr char kCUPSPrintoutMode[] = "PrintoutMode";
Expand All @@ -60,7 +60,7 @@ void GetColorModelForMode(int color_mode,
constexpr char kCUPSEpsonInk[] = "cups-Ink";
constexpr char kCUPSSharpARCMode[] = "cups-ARCMode";
constexpr char kCUPSXeroxXRXColor[] = "cups-XRXColor";
#endif // defined(OS_MACOSX)
#endif // defined(OS_MAC)

*color_setting_name = kCUPSColorModel;

Expand Down Expand Up @@ -188,7 +188,7 @@ void GetColorModelForMode(int color_mode,
// all ColorModel values are determinantly handled.
}

#if defined(OS_MACOSX) || defined(OS_CHROMEOS)
#if defined(OS_MAC) || defined(OS_CHROMEOS)
std::string GetIppColorModelForMode(int color_mode) {
// Accept |UNKNOWN_COLOR_MODEL| for consistency with GetColorModelForMode().
if (color_mode == UNKNOWN_COLOR_MODEL)
Expand All @@ -203,7 +203,7 @@ std::string GetIppColorModelForMode(int color_mode) {
return is_color.value() ? CUPS_PRINT_COLOR_MODE_COLOR
: CUPS_PRINT_COLOR_MODE_MONOCHROME;
}
#endif // defined(OS_MACOSX) || defined(OS_CHROMEOS)
#endif // defined(OS_MAC) || defined(OS_CHROMEOS)
#endif // defined(USE_CUPS)

base::Optional<bool> IsColorModelSelected(int color_mode) {
Expand Down
8 changes: 4 additions & 4 deletions printing/print_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PRINTING_EXPORT void GetColorModelForMode(int color_mode,
std::string* color_setting_name,
std::string* color_value);

#if defined(OS_MACOSX) || defined(OS_CHROMEOS)
#if defined(OS_MAC) || defined(OS_CHROMEOS)
// Convert from |color_mode| to a print-color-mode value from PWG 5100.13.
PRINTING_EXPORT std::string GetIppColorModelForMode(int color_mode);
#endif
Expand Down Expand Up @@ -141,11 +141,11 @@ class PRINTING_EXPORT PrintSettings {
bool supports_alpha_blend() const { return supports_alpha_blend_; }

int device_units_per_inch() const {
#if defined(OS_MACOSX)
#if defined(OS_MAC)
return 72;
#else // defined(OS_MACOSX)
#else // defined(OS_MAC)
return dpi();
#endif // defined(OS_MACOSX)
#endif // defined(OS_MAC)
}

void set_ranges(const PageRanges& ranges) { ranges_ = ranges; }
Expand Down
4 changes: 2 additions & 2 deletions printing/print_settings_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ TEST(PrintSettingsDeathTest, GetColorModelForModeEdges) {
&color_setting_name, &color_value));
}

#if defined(OS_MACOSX) || defined(OS_CHROMEOS)
#if defined(OS_MAC) || defined(OS_CHROMEOS)
TEST(PrintSettingsTest, GetIppColorModelForMode) {
for (int model = UNKNOWN_COLOR_MODEL; model <= COLOR_MODEL_LAST; ++model)
EXPECT_FALSE(GetIppColorModelForMode(model).empty());
Expand All @@ -56,7 +56,7 @@ TEST(PrintSettingsDeathTest, GetIppColorModelForModeEdges) {
EXPECT_DCHECK_DEATH(GetIppColorModelForMode(UNKNOWN_COLOR_MODEL - 1));
EXPECT_DCHECK_DEATH(GetIppColorModelForMode(COLOR_MODEL_LAST + 1));
}
#endif // defined(OS_MACOSX) || defined(OS_CHROMEOS)
#endif // defined(OS_MAC) || defined(OS_CHROMEOS)
#endif // defined(USE_CUPS)

} // namespace printing
4 changes: 2 additions & 2 deletions printing/printing_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ const base::Feature kAdvancedPpdAttributes{"AdvancedPpdAttributes",
base::FEATURE_ENABLED_BY_DEFAULT};
#endif // defined(OS_CHROMEOS)

#if defined(OS_MACOSX)
#if defined(OS_MAC)
// 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};

const base::Feature kEnableCustomMacPaperSizes{
"EnableCustomMacPaperSizes", base::FEATURE_ENABLED_BY_DEFAULT};
#endif // defined(OS_MACOSX)
#endif // defined(OS_MAC)

#if defined(OS_WIN)
// When using GDI printing, avoid rasterization if possible.
Expand Down
4 changes: 2 additions & 2 deletions printing/printing_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ namespace features {
PRINTING_EXPORT extern const base::Feature kAdvancedPpdAttributes;
#endif // defined(OS_CHROMEOS)

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

#if defined(OS_WIN)
PRINTING_EXPORT extern const base::Feature kPrintWithReducedRasterization;
Expand Down

0 comments on commit 578cd72

Please sign in to comment.