summaryrefslogtreecommitdiff
path: root/chromium/printing
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-24 12:15:48 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-28 13:30:04 +0000
commitb014812705fc80bff0a5c120dfcef88f349816dc (patch)
tree25a2e2d9fa285f1add86aa333389a839f81a39ae /chromium/printing
parent9f4560b1027ae06fdb497023cdcaf91b8511fa74 (diff)
downloadqtwebengine-chromium-b014812705fc80bff0a5c120dfcef88f349816dc.tar.gz
BASELINE: Update Chromium to 68.0.3440.125
Change-Id: I23f19369e01f688e496f5bf179abb521ad73874f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/printing')
-rw-r--r--chromium/printing/BUILD.gn3
-rw-r--r--chromium/printing/OWNERS2
-rw-r--r--chromium/printing/android/OWNERS2
-rw-r--r--chromium/printing/backend/cups_helper.cc2
-rw-r--r--chromium/printing/backend/cups_jobs.cc2
-rw-r--r--chromium/printing/buildflags/BUILD.gn6
-rw-r--r--chromium/printing/buildflags/buildflags.gni6
-rw-r--r--chromium/printing/common/pdf_metafile_utils.cc1
-rw-r--r--chromium/printing/emf_win_unittest.cc2
-rw-r--r--chromium/printing/nup_parameters.cc75
-rw-r--r--chromium/printing/nup_parameters.h44
-rw-r--r--chromium/printing/nup_parameters_unittest.cc103
-rw-r--r--chromium/printing/print_dialog_gtk_interface.h4
-rw-r--r--chromium/printing/print_job_constants.cc8
-rw-r--r--chromium/printing/print_job_constants.h4
-rw-r--r--chromium/printing/print_settings.cc1
-rw-r--r--chromium/printing/print_settings.h8
-rw-r--r--chromium/printing/print_settings_conversion.cc7
-rw-r--r--chromium/printing/printed_document.cc12
-rw-r--r--chromium/printing/printed_document.h6
-rw-r--r--chromium/printing/printing_context.cc3
-rw-r--r--chromium/printing/printing_context_linux.cc23
-rw-r--r--chromium/printing/printing_context_system_dialog_win.cc5
-rw-r--r--chromium/printing/printing_context_win.cc11
24 files changed, 285 insertions, 55 deletions
diff --git a/chromium/printing/BUILD.gn b/chromium/printing/BUILD.gn
index 8f75d8f4c79..e4ed98b0dff 100644
--- a/chromium/printing/BUILD.gn
+++ b/chromium/printing/BUILD.gn
@@ -38,6 +38,8 @@ component("printing") {
"metafile_skia_wrapper.cc",
"metafile_skia_wrapper.h",
"native_drawing_context.h",
+ "nup_parameters.cc",
+ "nup_parameters.h",
"page_number.cc",
"page_number.h",
"page_range.cc",
@@ -261,6 +263,7 @@ static_library("test_support") {
test("printing_unittests") {
sources = [
"emf_win_unittest.cc",
+ "nup_parameters_unittest.cc",
"page_number_unittest.cc",
"page_range_unittest.cc",
"page_setup_unittest.cc",
diff --git a/chromium/printing/OWNERS b/chromium/printing/OWNERS
index 47b44bca93c..d15a3243246 100644
--- a/chromium/printing/OWNERS
+++ b/chromium/printing/OWNERS
@@ -3,6 +3,6 @@ rbpotter@chromium.org
thestig@chromium.org
weili@chromium.org
-per-file printing_context_android*=dgn@chromium.org
+per-file printing_context_android*=ctzsm@chromium.org
# COMPONENT: Internals>Printing
diff --git a/chromium/printing/android/OWNERS b/chromium/printing/android/OWNERS
index d3c907e2e97..395fd997f0f 100644
--- a/chromium/printing/android/OWNERS
+++ b/chromium/printing/android/OWNERS
@@ -1 +1 @@
-dgn@chromium.org
+ctzsm@chromium.org
diff --git a/chromium/printing/backend/cups_helper.cc b/chromium/printing/backend/cups_helper.cc
index d352ccf8c1d..20b1c853b5c 100644
--- a/chromium/printing/backend/cups_helper.cc
+++ b/chromium/printing/backend/cups_helper.cc
@@ -119,7 +119,7 @@ void MarkLpOptions(base::StringPiece printer_name, ppd_file_t** ppd) {
std::vector<base::FilePath> file_locations;
file_locations.push_back(base::FilePath(kSystemLpOptionPath));
base::FilePath homedir;
- PathService::Get(base::DIR_HOME, &homedir);
+ base::PathService::Get(base::DIR_HOME, &homedir);
file_locations.push_back(base::FilePath(homedir.Append(kUserLpOptionPath)));
for (const base::FilePath& location : file_locations) {
diff --git a/chromium/printing/backend/cups_jobs.cc b/chromium/printing/backend/cups_jobs.cc
index 3461e00c126..aa8f83b3b3d 100644
--- a/chromium/printing/backend/cups_jobs.cc
+++ b/chromium/printing/backend/cups_jobs.cc
@@ -443,7 +443,7 @@ bool GetPrinterInfo(const std::string& address,
ScopedHttpPtr http = ScopedHttpPtr(httpConnect2(
address.c_str(), port, nullptr, AF_INET,
- encrypted ? HTTP_ENCRYPTION_REQUIRED : HTTP_ENCRYPTION_IF_REQUESTED, 0,
+ encrypted ? HTTP_ENCRYPTION_ALWAYS : HTTP_ENCRYPTION_IF_REQUESTED, 0,
kHttpConnectTimeoutMs, nullptr));
if (!http) {
LOG(WARNING) << "Could not connect to host";
diff --git a/chromium/printing/buildflags/BUILD.gn b/chromium/printing/buildflags/BUILD.gn
index ceba2ef9552..770117aec00 100644
--- a/chromium/printing/buildflags/BUILD.gn
+++ b/chromium/printing/buildflags/BUILD.gn
@@ -12,12 +12,8 @@ import("//printing/buildflags/buildflags.gni")
buildflag_header("buildflags") {
header = "buildflags.h"
- # Convenience define for ENABLE_BASIC_PRINTING || ENABLE_PRINT_PREVIEW.
- enable_printing = enable_basic_printing || enable_print_preview
-
flags = [
- "ENABLE_PRINTING=$enable_printing",
- "ENABLE_BASIC_PRINTING=$enable_basic_printing",
+ "ENABLE_PRINTING=$enable_basic_printing",
"ENABLE_PRINT_PREVIEW=$enable_print_preview",
]
}
diff --git a/chromium/printing/buildflags/buildflags.gni b/chromium/printing/buildflags/buildflags.gni
index b3d69670210..c2edd93db7d 100644
--- a/chromium/printing/buildflags/buildflags.gni
+++ b/chromium/printing/buildflags/buildflags.gni
@@ -9,8 +9,10 @@ declare_args() {
# Enable basic printing support and UI.
enable_basic_printing = !is_chromecast && !is_ios && !is_fuchsia
- # Enable printing with print preview. It does not imply
- # enable_basic_printing. It's possible to build Chrome with preview only.
+ # Enable printing with print preview. It implies enable_basic_printing.
+ # Note: It would be convenient to not repeat many of the same conditions in
+ # enable_basic_printing below. However, GN does not allow the use of
+ # enable_basic_printing within the same declare_args() block.
enable_print_preview = !is_android && !is_chromecast && !is_ios && !is_fuchsia
use_cups = (is_desktop_linux || is_mac) && !is_chromecast && !is_fuchsia
diff --git a/chromium/printing/common/pdf_metafile_utils.cc b/chromium/printing/common/pdf_metafile_utils.cc
index c3c073e8750..fe3fd49e2af 100644
--- a/chromium/printing/common/pdf_metafile_utils.cc
+++ b/chromium/printing/common/pdf_metafile_utils.cc
@@ -51,6 +51,7 @@ sk_sp<SkDocument> MakePdfDocument(const std::string& creator,
metadata.fCreator = creator.empty()
? SkString("Chromium")
: SkString(creator.c_str(), creator.size());
+ metadata.fRasterDPI = 300.0f;
return SkDocument::MakePDF(stream, metadata);
}
diff --git a/chromium/printing/emf_win_unittest.cc b/chromium/printing/emf_win_unittest.cc
index e98b628a079..9372af13d27 100644
--- a/chromium/printing/emf_win_unittest.cc
+++ b/chromium/printing/emf_win_unittest.cc
@@ -92,7 +92,7 @@ TEST_F(EmfPrintingTest, Enumerate) {
EXPECT_EQ(PrintingContext::OK, context.InitWithSettingsForTest(settings));
base::FilePath emf_file;
- EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &emf_file));
+ EXPECT_TRUE(base::PathService::Get(base::DIR_SOURCE_ROOT, &emf_file));
emf_file = emf_file.Append(FILE_PATH_LITERAL("printing"))
.Append(FILE_PATH_LITERAL("test"))
.Append(FILE_PATH_LITERAL("data"))
diff --git a/chromium/printing/nup_parameters.cc b/chromium/printing/nup_parameters.cc
new file mode 100644
index 00000000000..1e5a959422d
--- /dev/null
+++ b/chromium/printing/nup_parameters.cc
@@ -0,0 +1,75 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "printing/nup_parameters.h"
+
+#include <algorithm>
+#include <cmath>
+
+#include "base/logging.h"
+
+namespace printing {
+
+NupParameters::NupParameters() {
+ Clear();
+}
+
+void NupParameters::Clear() {
+ landscape_ = false;
+ num_pages_on_x_axis_ = 1;
+ num_pages_on_y_axis_ = 1;
+}
+
+// static
+bool NupParameters::IsSupported(int num_pages_per_sheet) {
+ // Supports N-up: 1 2 4 6 9 16
+
+ return num_pages_per_sheet == 1 || num_pages_per_sheet == 2 ||
+ num_pages_per_sheet == 4 || num_pages_per_sheet == 6 ||
+ num_pages_per_sheet == 9 || num_pages_per_sheet == 16;
+}
+
+void NupParameters::SetParameters(int num_pages_per_sheet,
+ bool is_source_landscape) {
+ DCHECK(IsSupported(num_pages_per_sheet));
+
+ switch (num_pages_per_sheet) {
+ case 1:
+ num_pages_on_x_axis_ = 1;
+ num_pages_on_y_axis_ = 1;
+ break;
+ case 2:
+ if (!is_source_landscape) {
+ num_pages_on_x_axis_ = 2;
+ num_pages_on_y_axis_ = 1;
+ landscape_ = true;
+ } else {
+ num_pages_on_x_axis_ = 1;
+ num_pages_on_y_axis_ = 2;
+ }
+ break;
+ case 6:
+ if (!is_source_landscape) {
+ num_pages_on_x_axis_ = 3;
+ num_pages_on_y_axis_ = 2;
+ landscape_ = true;
+ } else {
+ num_pages_on_x_axis_ = 2;
+ num_pages_on_y_axis_ = 3;
+ }
+ break;
+ case 4:
+ case 9:
+ case 16:
+ num_pages_on_x_axis_ = std::sqrt(num_pages_per_sheet);
+ num_pages_on_y_axis_ = std::sqrt(num_pages_per_sheet);
+ if (is_source_landscape)
+ landscape_ = true;
+ break;
+ default:
+ NOTREACHED();
+ }
+}
+
+} // namespace printing
diff --git a/chromium/printing/nup_parameters.h b/chromium/printing/nup_parameters.h
new file mode 100644
index 00000000000..466ac3c3af0
--- /dev/null
+++ b/chromium/printing/nup_parameters.h
@@ -0,0 +1,44 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PRINTING_NUP_PARAMETERS_H_
+#define PRINTING_NUP_PARAMETERS_H_
+
+#include "printing/printing_export.h"
+
+namespace printing {
+
+class PRINTING_EXPORT NupParameters {
+ public:
+ NupParameters();
+
+ // Whether or not the input |num_pages_per_sheet| is a supported N-up value.
+ // Supported values are: 1 2 4 6 9 16
+ static bool IsSupported(int num_pages_per_sheet);
+
+ // Orientation of the to-be-generated N-up PDF document.
+ bool landscape() const { return landscape_; };
+ int num_pages_on_x_axis() const { return num_pages_on_x_axis_; };
+ int num_pages_on_y_axis() const { return num_pages_on_y_axis_; };
+
+ // Calculates the |num_pages_on_x_axis_|, |num_pages_on_y_axis_| and
+ // |landscape_| based on the input. |is_source_landscape| is true if the
+ // source document orientation is landscape.
+ // Callers should check |num_pages_per_sheet| values with IsSupported() first,
+ // and only pass in supported values.
+ void SetParameters(int num_pages_per_sheet, bool is_source_landscape);
+
+ // Turns off N-up mode by resetting |num_pages_on_x_axis| = 1,
+ // |num_pages_on_y_axis| = 1, and |landscape_| = false
+ void Clear();
+
+ private:
+ int num_pages_on_x_axis_;
+ int num_pages_on_y_axis_;
+ bool landscape_;
+};
+
+} // namespace printing
+
+#endif // PRINTING_NUP_PARAMETERS_H_
diff --git a/chromium/printing/nup_parameters_unittest.cc b/chromium/printing/nup_parameters_unittest.cc
new file mode 100644
index 00000000000..70c12a029e8
--- /dev/null
+++ b/chromium/printing/nup_parameters_unittest.cc
@@ -0,0 +1,103 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "printing/nup_parameters.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace printing {
+
+TEST(NupParametersTest, SetNupParams) {
+ // Test default constructor.
+ printing::NupParameters nup_params;
+ EXPECT_FALSE(nup_params.landscape());
+ EXPECT_EQ(1, nup_params.num_pages_on_x_axis());
+ EXPECT_EQ(1, nup_params.num_pages_on_y_axis());
+ nup_params.Clear();
+
+ // Set N-up parameters for 1-up, and source doc is portrait.
+ nup_params.SetParameters(1, false);
+ EXPECT_FALSE(nup_params.landscape());
+ EXPECT_EQ(1, nup_params.num_pages_on_x_axis());
+ EXPECT_EQ(1, nup_params.num_pages_on_y_axis());
+ nup_params.Clear();
+
+ // Set N-up parameters for 1-up, and source doc is landscape.
+ nup_params.SetParameters(1, true);
+ EXPECT_FALSE(nup_params.landscape());
+ EXPECT_EQ(1, nup_params.num_pages_on_x_axis());
+ EXPECT_EQ(1, nup_params.num_pages_on_y_axis());
+ nup_params.Clear();
+
+ // Set N-up parameters for 2-up, and source doc is portrait.
+ nup_params.SetParameters(2, false);
+ EXPECT_TRUE(nup_params.landscape());
+ EXPECT_EQ(2, nup_params.num_pages_on_x_axis());
+ EXPECT_EQ(1, nup_params.num_pages_on_y_axis());
+ nup_params.Clear();
+
+ // Set N-up parameters for 2-up, and source doc is landscape.
+ nup_params.SetParameters(2, true);
+ EXPECT_FALSE(nup_params.landscape());
+ EXPECT_EQ(1, nup_params.num_pages_on_x_axis());
+ EXPECT_EQ(2, nup_params.num_pages_on_y_axis());
+ nup_params.Clear();
+
+ // Set N-up parameters for 4-up, and source doc is portrait.
+ nup_params.SetParameters(4, false);
+ EXPECT_FALSE(nup_params.landscape());
+ EXPECT_EQ(2, nup_params.num_pages_on_x_axis());
+ EXPECT_EQ(2, nup_params.num_pages_on_y_axis());
+ nup_params.Clear();
+
+ // Set N-up parameters for 4-up, and source doc is landscape.
+ nup_params.SetParameters(4, true);
+ EXPECT_TRUE(nup_params.landscape());
+ EXPECT_EQ(2, nup_params.num_pages_on_x_axis());
+ EXPECT_EQ(2, nup_params.num_pages_on_y_axis());
+ nup_params.Clear();
+
+ // Set N-up parameters for 6-up, and source doc is portrait.
+ nup_params.SetParameters(6, false);
+ EXPECT_TRUE(nup_params.landscape());
+ EXPECT_EQ(3, nup_params.num_pages_on_x_axis());
+ EXPECT_EQ(2, nup_params.num_pages_on_y_axis());
+ nup_params.Clear();
+
+ // Set N-up parameters for 6-up, and source doc is landscape.
+ nup_params.SetParameters(6, true);
+ EXPECT_FALSE(nup_params.landscape());
+ EXPECT_EQ(2, nup_params.num_pages_on_x_axis());
+ EXPECT_EQ(3, nup_params.num_pages_on_y_axis());
+ nup_params.Clear();
+
+ // Set N-up parameters for 9-up, and source doc is portrait.
+ nup_params.SetParameters(9, false);
+ EXPECT_FALSE(nup_params.landscape());
+ EXPECT_EQ(3, nup_params.num_pages_on_x_axis());
+ EXPECT_EQ(3, nup_params.num_pages_on_y_axis());
+ nup_params.Clear();
+
+ // Set N-up parameters for 9-up, and source doc is landscape.
+ nup_params.SetParameters(9, true);
+ EXPECT_TRUE(nup_params.landscape());
+ EXPECT_EQ(3, nup_params.num_pages_on_x_axis());
+ EXPECT_EQ(3, nup_params.num_pages_on_y_axis());
+ nup_params.Clear();
+
+ // Set N-up parameters for 16-up, and source doc is portrait.
+ nup_params.SetParameters(16, false);
+ EXPECT_FALSE(nup_params.landscape());
+ EXPECT_EQ(4, nup_params.num_pages_on_x_axis());
+ EXPECT_EQ(4, nup_params.num_pages_on_y_axis());
+ nup_params.Clear();
+
+ // Set N-up parameters for 16-up, and source doc is landscape.
+ nup_params.SetParameters(16, true);
+ EXPECT_TRUE(nup_params.landscape());
+ EXPECT_EQ(4, nup_params.num_pages_on_x_axis());
+ EXPECT_EQ(4, nup_params.num_pages_on_y_axis());
+ nup_params.Clear();
+}
+
+} // namespace printing
diff --git a/chromium/printing/print_dialog_gtk_interface.h b/chromium/printing/print_dialog_gtk_interface.h
index 695a5e3b3bd..374acc46639 100644
--- a/chromium/printing/print_dialog_gtk_interface.h
+++ b/chromium/printing/print_dialog_gtk_interface.h
@@ -23,8 +23,8 @@ class PrintDialogGtkInterface {
virtual void UseDefaultSettings() = 0;
// Updates the dialog to use |settings|. Only used when printing without the
- // system print dialog. E.g. for Print Preview. Returns false on error.
- virtual bool UpdateSettings(PrintSettings* settings) = 0;
+ // system print dialog. E.g. for Print Preview.
+ virtual void UpdateSettings(PrintSettings* settings) = 0;
// Shows the dialog and handles the response with |callback|. Only used when
// printing with the native print dialog.
diff --git a/chromium/printing/print_job_constants.cc b/chromium/printing/print_job_constants.cc
index d6f8f43e844..838813a75fc 100644
--- a/chromium/printing/print_job_constants.cc
+++ b/chromium/printing/print_job_constants.cc
@@ -66,9 +66,6 @@ const char kSettingDuplexMode[] = "duplex";
// selected else false.
const char kSettingFitToPageEnabled[] = "fitToPageEnabled";
-// True, when a new set of draft preview data is required.
-const char kSettingGenerateDraftData[] = "generateDraftData";
-
// Option to print headers and Footers: true if selected, false if not.
const char kSettingHeaderFooterEnabled[] = "headerFooterEnabled";
@@ -172,6 +169,9 @@ const char kSettingPrintWithExtension[] = "printWithExtension";
// Scaling factor
const char kSettingScaleFactor[] = "scaleFactor";
+// Number of pages per sheet.
+const char kSettingPagesPerSheet[] = "pagesPerSheet";
+
// Whether to rasterize the PDF for printing.
const char kSettingRasterizePdf[] = "rasterizePDF";
@@ -184,10 +184,8 @@ const char kSettingShouldPrintBackgrounds[] = "shouldPrintBackgrounds";
// Whether to print selection only.
const char kSettingShouldPrintSelectionOnly[] = "shouldPrintSelectionOnly";
-#if BUILDFLAG(ENABLE_BASIC_PRINTING)
// Whether to print using the system dialog.
const char kSettingShowSystemDialog[] = "showSystemDialog";
-#endif
// Indices used to represent first preview page and complete preview document.
const int FIRST_PAGE_INDEX = 0;
diff --git a/chromium/printing/print_job_constants.h b/chromium/printing/print_job_constants.h
index b543c7b9f8a..36e7b83b554 100644
--- a/chromium/printing/print_job_constants.h
+++ b/chromium/printing/print_job_constants.h
@@ -30,7 +30,6 @@ PRINTING_EXPORT extern const char kSettingDpiVertical[];
PRINTING_EXPORT extern const char kSettingDuplexMode[];
PRINTING_EXPORT extern const char kSettingFitToPageEnabled[];
PRINTING_EXPORT extern const char kSettingFitToPageScaling[];
-PRINTING_EXPORT extern const char kSettingGenerateDraftData[];
PRINTING_EXPORT extern const char kSettingHeaderFooterEnabled[];
PRINTING_EXPORT extern const float kSettingHeaderFooterInterstice;
PRINTING_EXPORT extern const char kSettingHeaderFooterDate[];
@@ -54,6 +53,7 @@ PRINTING_EXPORT extern const char kSettingPageRangeFrom[];
PRINTING_EXPORT extern const char kSettingPageRangeTo[];
PRINTING_EXPORT extern const char kSettingPageWidth[];
PRINTING_EXPORT extern const char kSettingPageHeight[];
+PRINTING_EXPORT extern const char kSettingPagesPerSheet[];
PRINTING_EXPORT extern const char kSettingPreviewModifiable[];
PRINTING_EXPORT extern const char kSettingPrintToPDF[];
PRINTING_EXPORT extern const char kSettingPrintWithPrivet[];
@@ -70,9 +70,7 @@ PRINTING_EXPORT extern const char kSettingScaleFactor[];
PRINTING_EXPORT extern const char kSettingTicket[];
PRINTING_EXPORT extern const char kSettingShouldPrintBackgrounds[];
PRINTING_EXPORT extern const char kSettingShouldPrintSelectionOnly[];
-#if BUILDFLAG(ENABLE_BASIC_PRINTING)
PRINTING_EXPORT extern const char kSettingShowSystemDialog[];
-#endif
PRINTING_EXPORT extern const int FIRST_PAGE_INDEX;
PRINTING_EXPORT extern const int COMPLETE_PREVIEW_DOCUMENT_INDEX;
diff --git a/chromium/printing/print_settings.cc b/chromium/printing/print_settings.cc
index b95ba271197..ae8ad92658a 100644
--- a/chromium/printing/print_settings.cc
+++ b/chromium/printing/print_settings.cc
@@ -181,6 +181,7 @@ void PrintSettings::Clear() {
printer_type_ = PrintSettings::PrinterType::TYPE_NONE;
#endif
is_modifiable_ = true;
+ num_pages_per_sheet_ = 1;
}
void PrintSettings::SetPrinterPrintableArea(
diff --git a/chromium/printing/print_settings.h b/chromium/printing/print_settings.h
index 569955b6fe5..e6ecec7fa46 100644
--- a/chromium/printing/print_settings.h
+++ b/chromium/printing/print_settings.h
@@ -187,6 +187,11 @@ class PRINTING_EXPORT PrintSettings {
void set_is_modifiable(bool is_modifiable) { is_modifiable_ = is_modifiable; }
bool is_modifiable() const { return is_modifiable_; }
+ int num_pages_per_sheet() const { return num_pages_per_sheet_; }
+ void set_num_pages_per_sheet(int num_pages_per_sheet) {
+ num_pages_per_sheet_ = num_pages_per_sheet;
+ }
+
// Cookie generator. It is used to initialize PrintedDocument with its
// associated PrintSettings, to be sure that each generated PrintedPage is
// correctly associated with its corresponding PrintedDocument.
@@ -262,6 +267,9 @@ class PRINTING_EXPORT PrintSettings {
// If margin type is custom, this is what was requested.
PageMargins requested_custom_margins_in_points_;
+
+ // Number of pages per sheet.
+ int num_pages_per_sheet_;
};
} // namespace printing
diff --git a/chromium/printing/print_settings_conversion.cc b/chromium/printing/print_settings_conversion.cc
index 98caf9c15b7..f7ca6844b81 100644
--- a/chromium/printing/print_settings_conversion.cc
+++ b/chromium/printing/print_settings_conversion.cc
@@ -179,6 +179,7 @@ bool PrintSettingsFromJobSettings(const base::DictionaryValue& job_settings,
int copies = 1;
int scale_factor = 100;
bool rasterize_pdf = false;
+ int num_pages_per_sheet = 1;
if (!job_settings.GetBoolean(kSettingCollate, &collate) ||
!job_settings.GetInteger(kSettingCopies, &copies) ||
@@ -216,6 +217,10 @@ bool PrintSettingsFromJobSettings(const base::DictionaryValue& job_settings,
#endif
}
+ // TODO(crbug.com/842000): |kSettingPagesPerSheet| should be required.
+ job_settings.GetInteger(kSettingPagesPerSheet, &num_pages_per_sheet);
+ settings->set_num_pages_per_sheet(num_pages_per_sheet);
+
return true;
}
@@ -247,6 +252,8 @@ void PrintSettingsToJobSettingsDebug(const PrintSettings& settings,
job_settings->SetInteger(kSettingDuplexMode, settings.duplex_mode());
job_settings->SetBoolean(kSettingLandscape, settings.landscape());
job_settings->SetString(kSettingDeviceName, settings.device_name());
+ job_settings->SetInteger(kSettingPagesPerSheet,
+ settings.num_pages_per_sheet());
// Following values are not read form JSON by InitSettings, so do not have
// common public constants. So just serialize in "debug" section.
diff --git a/chromium/printing/printed_document.cc b/chromium/printing/printed_document.cc
index bc5aeccb466..61716a80fed 100644
--- a/chromium/printing/printed_document.cc
+++ b/chromium/printing/printed_document.cc
@@ -18,7 +18,6 @@
#include "base/json/json_writer.h"
#include "base/lazy_instance.h"
#include "base/memory/ref_counted_memory.h"
-#include "base/message_loop/message_loop.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@@ -115,14 +114,9 @@ PrintedDocument::PrintedDocument(const PrintSettings& settings,
const base::string16& name,
int cookie)
: immutable_(settings, name, cookie) {
- // Records the expected page count if a range is setup.
- if (!settings.ranges().empty()) {
- // If there is a range, set the number of page
- for (unsigned i = 0; i < settings.ranges().size(); ++i) {
- const PageRange& range = settings.ranges()[i];
- mutable_.expected_page_count_ += range.to - range.from + 1;
- }
- }
+ // If there is a range, set the number of page
+ for (const PageRange& range : settings.ranges())
+ mutable_.expected_page_count_ += range.to - range.from + 1;
if (HasDebugDumpPath())
DebugDumpSettings(name, settings);
diff --git a/chromium/printing/printed_document.h b/chromium/printing/printed_document.h
index 08d9946fa22..aaf249588e4 100644
--- a/chromium/printing/printed_document.h
+++ b/chromium/printing/printed_document.h
@@ -91,7 +91,7 @@ class PRINTING_EXPORT PrintedDocument
// Note: locks for a short amount of time.
void set_page_count(int max_page);
- // Number of pages in the document. Used for headers/footers.
+ // Number of pages in the document.
// Note: locks for a short amount of time.
int page_count() const;
@@ -136,10 +136,10 @@ class PRINTING_EXPORT PrintedDocument
private:
friend class base::RefCountedThreadSafe<PrintedDocument>;
- virtual ~PrintedDocument();
+ ~PrintedDocument();
// Array of data for each print previewed page.
- typedef std::map<int, scoped_refptr<PrintedPage> > PrintedPages;
+ using PrintedPages = std::map<int, scoped_refptr<PrintedPage>>;
// Contains all the mutable stuff. All this stuff MUST be accessed with the
// lock held.
diff --git a/chromium/printing/printing_context.cc b/chromium/printing/printing_context.cc
index b2a6dcf0342..ebf841c4766 100644
--- a/chromium/printing/printing_context.cc
+++ b/chromium/printing/printing_context.cc
@@ -76,6 +76,7 @@ PrintingContext::Result PrintingContext::UsePdfSettings() {
pdf_settings->SetBoolean(kSettingPrintWithExtension, false);
pdf_settings->SetInteger(kSettingScaleFactor, 100);
pdf_settings->SetBoolean(kSettingRasterizePdf, false);
+ pdf_settings->SetInteger(kSettingPagesPerSheet, 1);
return UpdatePrintSettings(*pdf_settings);
}
@@ -130,9 +131,7 @@ PrintingContext::Result PrintingContext::UpdatePrintSettings(
}
bool show_system_dialog = false;
-#if BUILDFLAG(ENABLE_BASIC_PRINTING)
job_settings.GetBoolean(kSettingShowSystemDialog, &show_system_dialog);
-#endif
int page_count = 0;
job_settings.GetInteger(kSettingPreviewPageCount, &page_count);
diff --git a/chromium/printing/printing_context_linux.cc b/chromium/printing/printing_context_linux.cc
index 1338529cd75..5adcfd39b5b 100644
--- a/chromium/printing/printing_context_linux.cc
+++ b/chromium/printing/printing_context_linux.cc
@@ -4,6 +4,9 @@
#include "printing/printing_context_linux.h"
+#include <memory>
+#include <utility>
+
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/values.h"
@@ -12,29 +15,27 @@
#include "printing/print_job_constants.h"
#include "printing/units.h"
+namespace printing {
+
namespace {
// Function pointer for creating print dialogs. |callback| is only used when
// |show_dialog| is true.
-printing::PrintDialogGtkInterface* (*create_dialog_func_)(
- printing::PrintingContextLinux* context) = NULL;
+PrintDialogGtkInterface* (*create_dialog_func_)(PrintingContextLinux* context) =
+ nullptr;
// Function pointer for determining paper size.
-gfx::Size (*get_pdf_paper_size_)(
- printing::PrintingContextLinux* context) = NULL;
+gfx::Size (*get_pdf_paper_size_)(PrintingContextLinux* context) = nullptr;
} // namespace
-namespace printing {
-
// static
std::unique_ptr<PrintingContext> PrintingContext::Create(Delegate* delegate) {
return base::WrapUnique(new PrintingContextLinux(delegate));
}
PrintingContextLinux::PrintingContextLinux(Delegate* delegate)
- : PrintingContext(delegate), print_dialog_(NULL) {
-}
+ : PrintingContext(delegate), print_dialog_(nullptr) {}
PrintingContextLinux::~PrintingContextLinux() {
ReleaseContext();
@@ -121,9 +122,7 @@ PrintingContext::Result PrintingContextLinux::UpdatePrinterSettings(
print_dialog_->AddRefToDialog();
}
- if (!print_dialog_->UpdateSettings(&settings_))
- return OnError();
-
+ print_dialog_->UpdateSettings(&settings_);
return OK;
}
@@ -183,7 +182,7 @@ void PrintingContextLinux::ReleaseContext() {
printing::NativeDrawingContext PrintingContextLinux::context() const {
// Intentional No-op.
- return NULL;
+ return nullptr;
}
} // namespace printing
diff --git a/chromium/printing/printing_context_system_dialog_win.cc b/chromium/printing/printing_context_system_dialog_win.cc
index 045ce3ee634..deba200346d 100644
--- a/chromium/printing/printing_context_system_dialog_win.cc
+++ b/chromium/printing/printing_context_system_dialog_win.cc
@@ -6,7 +6,7 @@
#include "base/auto_reset.h"
#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_current.h"
#include "printing/backend/win_helper.h"
#include "printing/print_settings_initializer_win.h"
#include "skia/ext/skia_utils_win.h"
@@ -88,8 +88,7 @@ HRESULT PrintingContextSystemDialogWin::ShowPrintDialog(PRINTDLGEX* options) {
// browser frame (but still being modal) so neither the browser frame nor
// the print dialog will get any input. See http://crbug.com/342697
// http://crbug.com/180997 for details.
- base::MessageLoop::ScopedNestableTaskAllower allow(
- base::MessageLoop::current());
+ base::MessageLoopCurrent::ScopedNestableTaskAllower allow;
return PrintDlgEx(options);
}
diff --git a/chromium/printing/printing_context_win.cc b/chromium/printing/printing_context_win.cc
index 6beedaa43ce..43e7e3531a5 100644
--- a/chromium/printing/printing_context_win.cc
+++ b/chromium/printing/printing_context_win.cc
@@ -10,7 +10,7 @@
#include "base/bind.h"
#include "base/memory/free_deleter.h"
#include "base/memory/ptr_util.h"
-#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_current.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "printing/backend/print_backend.h"
@@ -37,9 +37,12 @@ void AssignResult(PrintingContext::Result* out, PrintingContext::Result in) {
// static
std::unique_ptr<PrintingContext> PrintingContext::Create(Delegate* delegate) {
-#if BUILDFLAG(ENABLE_BASIC_PRINTING)
+#if BUILDFLAG(ENABLE_PRINTING)
return base::WrapUnique(new PrintingContextSystemDialogWin(delegate));
#else
+ // The code in printing/ is still built when the GN |enable_basic_printing|
+ // variable is set to false. Just return PrintingContextWin as a dummy
+ // context.
return base::WrapUnique(new PrintingContextWin(delegate));
#endif
}
@@ -270,8 +273,8 @@ PrintingContext::Result PrintingContextWin::NewDocument(
}
// No message loop running in unit tests.
- DCHECK(!base::MessageLoop::current() ||
- !base::MessageLoop::current()->NestableTasksAllowed());
+ DCHECK(!base::MessageLoopCurrent::Get() ||
+ !base::MessageLoopCurrent::Get()->NestableTasksAllowed());
// Begin a print job by calling the StartDoc function.
// NOTE: StartDoc() starts a message loop. That causes a lot of problems with