|
@@ -11,10 +11,10 @@ majority of changes originally come from these PRs:
|
|
|
This patch also fixes callback for manual user cancellation and success.
|
|
|
|
|
|
diff --git a/BUILD.gn b/BUILD.gn
|
|
|
-index 69e759c3b34692beac06ceeddf4b3f1637fb7788..42d0da7f936626aa8bb90057723deeaafce8744d 100644
|
|
|
+index 357f7117f8737ea75a14565d67807ee8a2e2c3cd..eb0794dd15481b52c135e55b9ff3ca6dadca57e2 100644
|
|
|
--- a/BUILD.gn
|
|
|
+++ b/BUILD.gn
|
|
|
-@@ -973,7 +973,6 @@ if (is_win) {
|
|
|
+@@ -969,7 +969,6 @@ if (is_win) {
|
|
|
"//media:media_unittests",
|
|
|
"//media/midi:midi_unittests",
|
|
|
"//net:net_unittests",
|
|
@@ -22,7 +22,7 @@ index 69e759c3b34692beac06ceeddf4b3f1637fb7788..42d0da7f936626aa8bb90057723deeaa
|
|
|
"//sql:sql_unittests",
|
|
|
"//third_party/breakpad:symupload($host_toolchain)",
|
|
|
"//ui/base:ui_base_unittests",
|
|
|
-@@ -982,6 +981,10 @@ if (is_win) {
|
|
|
+@@ -978,6 +977,10 @@ if (is_win) {
|
|
|
"//ui/views:views_unittests",
|
|
|
"//url:url_unittests",
|
|
|
]
|
|
@@ -91,20 +91,20 @@ index 0d8a53178e8d509a573ffdaadf2c4cec670522ac..8e7f9b92beb317888a5a3acb3bc2fa29
|
|
|
: PdfRenderSettings::Mode::POSTSCRIPT_LEVEL3;
|
|
|
}
|
|
|
diff --git a/chrome/browser/printing/print_view_manager_base.cc b/chrome/browser/printing/print_view_manager_base.cc
|
|
|
-index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09b1e78450 100644
|
|
|
+index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec593554a1 100644
|
|
|
--- a/chrome/browser/printing/print_view_manager_base.cc
|
|
|
+++ b/chrome/browser/printing/print_view_manager_base.cc
|
|
|
-@@ -23,7 +23,9 @@
|
|
|
- #include "build/chromeos_buildflags.h"
|
|
|
+@@ -25,7 +25,9 @@
|
|
|
#include "chrome/browser/bad_message.h"
|
|
|
#include "chrome/browser/browser_process.h"
|
|
|
+ #include "chrome/browser/printing/print_compositor_util.h"
|
|
|
+#if 0 // Electron does not use Chrome error dialogs
|
|
|
#include "chrome/browser/printing/print_error_dialog.h"
|
|
|
+#endif
|
|
|
#include "chrome/browser/printing/print_job.h"
|
|
|
#include "chrome/browser/printing/print_job_manager.h"
|
|
|
#include "chrome/browser/printing/print_view_manager_common.h"
|
|
|
-@@ -81,6 +83,20 @@ namespace printing {
|
|
|
+@@ -86,6 +88,20 @@ namespace printing {
|
|
|
|
|
|
namespace {
|
|
|
|
|
@@ -125,7 +125,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
void OnDidGetDefaultPrintSettings(
|
|
|
scoped_refptr<PrintQueriesQueue> queue,
|
|
|
bool want_pdf_settings,
|
|
|
-@@ -89,9 +105,11 @@ void OnDidGetDefaultPrintSettings(
|
|
|
+@@ -94,9 +110,11 @@ void OnDidGetDefaultPrintSettings(
|
|
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
|
|
|
if (printer_query->last_status() != mojom::ResultCode::kSuccess) {
|
|
@@ -137,7 +137,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
std::move(callback).Run(nullptr);
|
|
|
return;
|
|
|
}
|
|
|
-@@ -101,9 +119,11 @@ void OnDidGetDefaultPrintSettings(
|
|
|
+@@ -106,9 +124,11 @@ void OnDidGetDefaultPrintSettings(
|
|
|
params->document_cookie = printer_query->cookie();
|
|
|
|
|
|
if (!PrintMsgPrintParamsIsValid(*params)) {
|
|
@@ -149,7 +149,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
std::move(callback).Run(nullptr);
|
|
|
return;
|
|
|
}
|
|
|
-@@ -115,11 +135,15 @@ void OnDidGetDefaultPrintSettings(
|
|
|
+@@ -120,11 +140,15 @@ void OnDidGetDefaultPrintSettings(
|
|
|
void OnDidScriptedPrint(
|
|
|
scoped_refptr<PrintQueriesQueue> queue,
|
|
|
std::unique_ptr<PrinterQuery> printer_query,
|
|
@@ -166,7 +166,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
std::move(callback).Run(nullptr);
|
|
|
return;
|
|
|
}
|
|
|
-@@ -176,9 +200,11 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents)
|
|
|
+@@ -181,9 +205,11 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents)
|
|
|
: PrintManager(web_contents),
|
|
|
queue_(g_browser_process->print_job_manager()->queue()) {
|
|
|
DCHECK(queue_);
|
|
@@ -179,7 +179,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
}
|
|
|
|
|
|
PrintViewManagerBase::~PrintViewManagerBase() {
|
|
|
-@@ -202,12 +228,17 @@ void PrintViewManagerBase::DisableThirdPartyBlocking() {
|
|
|
+@@ -207,12 +233,17 @@ void PrintViewManagerBase::DisableThirdPartyBlocking() {
|
|
|
}
|
|
|
#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
|
|
|
|
@@ -199,7 +199,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
|
|
|
for (auto& observer : GetTestObservers()) {
|
|
|
observer.OnPrintNow(rfh);
|
|
|
-@@ -336,12 +367,13 @@ void PrintViewManagerBase::OnDidUpdatePrintableArea(
|
|
|
+@@ -341,12 +372,13 @@ void PrintViewManagerBase::OnDidUpdatePrintableArea(
|
|
|
}
|
|
|
PRINTER_LOG(EVENT) << "Paper printable area updated for vendor id "
|
|
|
<< print_settings->requested_media().vendor_id;
|
|
@@ -214,7 +214,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
base::Value::Dict job_settings,
|
|
|
std::unique_ptr<PrintSettings> print_settings,
|
|
|
UpdatePrintSettingsCallback callback) {
|
|
|
-@@ -349,7 +381,8 @@ void PrintViewManagerBase::CompleteUpdatePrintSettings(
|
|
|
+@@ -354,7 +386,8 @@ void PrintViewManagerBase::CompleteUpdatePrintSettings(
|
|
|
settings->pages = GetPageRangesFromJobSettings(job_settings);
|
|
|
settings->params = mojom::PrintParams::New();
|
|
|
RenderParamsFromPrintSettings(*print_settings, settings->params.get());
|
|
@@ -224,7 +224,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
if (!PrintMsgPrintParamsIsValid(*settings->params)) {
|
|
|
mojom::PrinterType printer_type = static_cast<mojom::PrinterType>(
|
|
|
*job_settings.FindInt(kSettingPrinterType));
|
|
|
-@@ -361,6 +394,10 @@ void PrintViewManagerBase::CompleteUpdatePrintSettings(
|
|
|
+@@ -366,6 +399,10 @@ void PrintViewManagerBase::CompleteUpdatePrintSettings(
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -235,34 +235,33 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
set_cookie(settings->params->document_cookie);
|
|
|
std::move(callback).Run(std::move(settings));
|
|
|
}
|
|
|
-@@ -647,11 +684,12 @@ void PrintViewManagerBase::DidPrintDocument(
|
|
|
+@@ -652,10 +689,12 @@ void PrintViewManagerBase::DidPrintDocument(
|
|
|
void PrintViewManagerBase::GetDefaultPrintSettings(
|
|
|
GetDefaultPrintSettingsCallback callback) {
|
|
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
+#if 0 // Printing is always enabled.
|
|
|
- if (!printing_enabled_.GetValue()) {
|
|
|
+ if (!GetPrintingEnabledBooleanPref()) {
|
|
|
GetDefaultPrintSettingsReply(std::move(callback), nullptr);
|
|
|
return;
|
|
|
}
|
|
|
--
|
|
|
+#endif
|
|
|
+
|
|
|
content::RenderFrameHost* render_frame_host = GetCurrentTargetFrame();
|
|
|
if (base::FeatureList::IsEnabled(kCheckPrintRfhIsActive) &&
|
|
|
- !render_frame_host->IsActive()) {
|
|
|
-@@ -710,10 +748,12 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
|
+@@ -715,10 +754,12 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
|
base::Value::Dict job_settings,
|
|
|
UpdatePrintSettingsCallback callback) {
|
|
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
+#if 0 // Printing is always enabled.
|
|
|
- if (!printing_enabled_.GetValue()) {
|
|
|
+ if (!GetPrintingEnabledBooleanPref()) {
|
|
|
std::move(callback).Run(nullptr);
|
|
|
return;
|
|
|
}
|
|
|
-+#endif // Printing is always enabled.
|
|
|
++#endif
|
|
|
|
|
|
std::optional<int> printer_type_value =
|
|
|
job_settings.FindInt(kSettingPrinterType);
|
|
|
-@@ -724,6 +764,7 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
|
+@@ -729,6 +770,7 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
|
|
|
|
mojom::PrinterType printer_type =
|
|
|
static_cast<mojom::PrinterType>(*printer_type_value);
|
|
@@ -270,7 +269,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
if (printer_type != mojom::PrinterType::kExtension &&
|
|
|
printer_type != mojom::PrinterType::kPdf &&
|
|
|
printer_type != mojom::PrinterType::kLocal) {
|
|
|
-@@ -743,6 +784,7 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
|
+@@ -748,6 +790,7 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
|
if (value > 0)
|
|
|
job_settings.Set(kSettingRasterizePdfDpi, value);
|
|
|
}
|
|
@@ -278,7 +277,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
|
|
|
std::unique_ptr<PrintSettings> print_settings =
|
|
|
PrintSettingsFromJobSettings(job_settings);
|
|
|
-@@ -762,7 +804,21 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
|
+@@ -767,7 +810,21 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -301,7 +300,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
// TODO(crbug.com/1424368): Remove this if the printable areas can be made
|
|
|
// fully available from `PrintBackend::GetPrinterSemanticCapsAndDefaults()`
|
|
|
// for in-browser queries.
|
|
|
-@@ -784,8 +840,6 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
|
+@@ -789,8 +846,6 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
|
}
|
|
|
#endif
|
|
|
|
|
@@ -310,16 +309,16 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
}
|
|
|
|
|
|
void PrintViewManagerBase::SetAccessibilityTree(
|
|
|
-@@ -801,7 +855,7 @@ void PrintViewManagerBase::SetAccessibilityTree(
|
|
|
+@@ -806,7 +861,7 @@ void PrintViewManagerBase::SetAccessibilityTree(
|
|
|
void PrintViewManagerBase::IsPrintingEnabled(
|
|
|
IsPrintingEnabledCallback callback) {
|
|
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
-- std::move(callback).Run(printing_enabled_.GetValue());
|
|
|
+- std::move(callback).Run(GetPrintingEnabledBooleanPref());
|
|
|
+ std::move(callback).Run(true);
|
|
|
}
|
|
|
|
|
|
void PrintViewManagerBase::ScriptedPrint(mojom::ScriptedPrintParamsPtr params,
|
|
|
-@@ -852,6 +906,7 @@ void PrintViewManagerBase::PrintingFailed(int32_t cookie,
|
|
|
+@@ -857,6 +912,7 @@ void PrintViewManagerBase::PrintingFailed(int32_t cookie,
|
|
|
|
|
|
PrintManager::PrintingFailed(cookie, reason);
|
|
|
|
|
@@ -327,7 +326,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
// `PrintingFailed()` can occur because asynchronous compositing results
|
|
|
// don't complete until after a print job has already failed and been
|
|
|
// destroyed. In such cases the error notification to the user will
|
|
|
-@@ -861,7 +916,7 @@ void PrintViewManagerBase::PrintingFailed(int32_t cookie,
|
|
|
+@@ -866,7 +922,7 @@ void PrintViewManagerBase::PrintingFailed(int32_t cookie,
|
|
|
print_job_->document()->cookie() == cookie) {
|
|
|
ShowPrintErrorDialogForGenericError();
|
|
|
}
|
|
@@ -336,7 +335,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
ReleasePrinterQuery();
|
|
|
}
|
|
|
|
|
|
-@@ -873,15 +928,24 @@ void PrintViewManagerBase::RemoveTestObserver(TestObserver& observer) {
|
|
|
+@@ -878,15 +934,24 @@ void PrintViewManagerBase::RemoveTestObserver(TestObserver& observer) {
|
|
|
test_observers_.RemoveObserver(&observer);
|
|
|
}
|
|
|
|
|
@@ -361,7 +360,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
}
|
|
|
|
|
|
void PrintViewManagerBase::RenderFrameDeleted(
|
|
|
-@@ -933,7 +997,12 @@ void PrintViewManagerBase::OnJobDone() {
|
|
|
+@@ -942,7 +1007,12 @@ void PrintViewManagerBase::OnJobDone() {
|
|
|
// Printing is done, we don't need it anymore.
|
|
|
// print_job_->is_job_pending() may still be true, depending on the order
|
|
|
// of object registration.
|
|
@@ -375,7 +374,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
ReleasePrintJob();
|
|
|
}
|
|
|
|
|
|
-@@ -942,9 +1011,10 @@ void PrintViewManagerBase::OnCanceling() {
|
|
|
+@@ -951,9 +1021,10 @@ void PrintViewManagerBase::OnCanceling() {
|
|
|
}
|
|
|
|
|
|
void PrintViewManagerBase::OnFailed() {
|
|
@@ -387,7 +386,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
TerminatePrintJob(true);
|
|
|
}
|
|
|
|
|
|
-@@ -954,7 +1024,7 @@ bool PrintViewManagerBase::RenderAllMissingPagesNow() {
|
|
|
+@@ -963,7 +1034,7 @@ bool PrintViewManagerBase::RenderAllMissingPagesNow() {
|
|
|
|
|
|
// Is the document already complete?
|
|
|
if (print_job_->document() && print_job_->document()->IsComplete()) {
|
|
@@ -396,7 +395,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-@@ -1007,7 +1077,10 @@ bool PrintViewManagerBase::SetupNewPrintJob(
|
|
|
+@@ -1016,7 +1087,10 @@ bool PrintViewManagerBase::SetupNewPrintJob(
|
|
|
|
|
|
// Disconnect the current `print_job_`.
|
|
|
auto weak_this = weak_ptr_factory_.GetWeakPtr();
|
|
@@ -408,7 +407,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
if (!weak_this)
|
|
|
return false;
|
|
|
|
|
|
-@@ -1027,7 +1100,7 @@ bool PrintViewManagerBase::SetupNewPrintJob(
|
|
|
+@@ -1036,7 +1110,7 @@ bool PrintViewManagerBase::SetupNewPrintJob(
|
|
|
#endif
|
|
|
print_job_->AddObserver(*this);
|
|
|
|
|
@@ -417,7 +416,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-@@ -1095,6 +1168,11 @@ void PrintViewManagerBase::ReleasePrintJob() {
|
|
|
+@@ -1104,6 +1178,11 @@ void PrintViewManagerBase::ReleasePrintJob() {
|
|
|
}
|
|
|
#endif
|
|
|
|
|
@@ -429,7 +428,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
if (!print_job_)
|
|
|
return;
|
|
|
|
|
|
-@@ -1102,7 +1180,7 @@ void PrintViewManagerBase::ReleasePrintJob() {
|
|
|
+@@ -1111,7 +1190,7 @@ void PrintViewManagerBase::ReleasePrintJob() {
|
|
|
// printing_rfh_ should only ever point to a RenderFrameHost with a live
|
|
|
// RenderFrame.
|
|
|
DCHECK(rfh->IsRenderFrameLive());
|
|
@@ -438,7 +437,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
}
|
|
|
|
|
|
print_job_->RemoveObserver(*this);
|
|
|
-@@ -1144,7 +1222,7 @@ bool PrintViewManagerBase::RunInnerMessageLoop() {
|
|
|
+@@ -1153,7 +1232,7 @@ bool PrintViewManagerBase::RunInnerMessageLoop() {
|
|
|
}
|
|
|
|
|
|
bool PrintViewManagerBase::OpportunisticallyCreatePrintJob(int cookie) {
|
|
@@ -447,7 +446,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
return true;
|
|
|
|
|
|
if (!cookie) {
|
|
|
-@@ -1298,6 +1376,8 @@ void PrintViewManagerBase::CompleteScriptedPrint(
|
|
|
+@@ -1307,6 +1386,8 @@ void PrintViewManagerBase::CompleteScriptedPrint(
|
|
|
auto callback_wrapper = base::BindOnce(
|
|
|
&PrintViewManagerBase::ScriptedPrintReply, weak_ptr_factory_.GetWeakPtr(),
|
|
|
std::move(callback), render_process_host->GetID());
|
|
@@ -456,7 +455,7 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
|
|
DisableThirdPartyBlocking();
|
|
|
#endif
|
|
|
-@@ -1312,7 +1392,7 @@ void PrintViewManagerBase::CompleteScriptedPrint(
|
|
|
+@@ -1321,7 +1402,7 @@ void PrintViewManagerBase::CompleteScriptedPrint(
|
|
|
params->expected_pages_count, params->has_selection, params->margin_type,
|
|
|
params->is_scripted, !render_process_host->IsPdf(),
|
|
|
base::BindOnce(&OnDidScriptedPrint, queue_, std::move(printer_query),
|
|
@@ -466,10 +465,10 @@ index 301a4a47fb4dfb6007c2214b04ffdff744cc3043..427a045c310109475b83a229637f4d09
|
|
|
|
|
|
#if BUILDFLAG(ENABLE_PRINT_CONTENT_ANALYSIS)
|
|
|
diff --git a/chrome/browser/printing/print_view_manager_base.h b/chrome/browser/printing/print_view_manager_base.h
|
|
|
-index 24a2bc8b26462e6cafbcd5eb89e838b73266ec70..402aab3b14e6987bde0e22e6c82ac438d465330a 100644
|
|
|
+index 43e353663b9b6be478a9418752dc189118b7fa58..c52ba4328c2f41c8d4233eecb96b864e0a1b7979 100644
|
|
|
--- a/chrome/browser/printing/print_view_manager_base.h
|
|
|
+++ b/chrome/browser/printing/print_view_manager_base.h
|
|
|
-@@ -49,6 +49,8 @@ class PrinterQuery;
|
|
|
+@@ -51,6 +51,8 @@ class PrinterQuery;
|
|
|
// rollout.
|
|
|
BASE_DECLARE_FEATURE(kCheckPrintRfhIsActive);
|
|
|
|
|
@@ -478,7 +477,7 @@ index 24a2bc8b26462e6cafbcd5eb89e838b73266ec70..402aab3b14e6987bde0e22e6c82ac438
|
|
|
// Base class for managing the print commands for a WebContents.
|
|
|
class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
|
|
public:
|
|
|
-@@ -82,7 +84,10 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
|
|
+@@ -84,7 +86,10 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
|
|
// Prints the current document immediately. Since the rendering is
|
|
|
// asynchronous, the actual printing will not be completed on the return of
|
|
|
// this function. Returns false if printing is impossible at the moment.
|
|
@@ -490,7 +489,7 @@ index 24a2bc8b26462e6cafbcd5eb89e838b73266ec70..402aab3b14e6987bde0e22e6c82ac438
|
|
|
|
|
|
// Like PrintNow(), but for the node under the context menu, instead of the
|
|
|
// entire frame.
|
|
|
-@@ -136,8 +141,10 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
|
|
+@@ -138,8 +143,10 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
|
|
void IsPrintingEnabled(IsPrintingEnabledCallback callback) override;
|
|
|
void ScriptedPrint(mojom::ScriptedPrintParamsPtr params,
|
|
|
ScriptedPrintCallback callback) override;
|
|
@@ -501,7 +500,7 @@ index 24a2bc8b26462e6cafbcd5eb89e838b73266ec70..402aab3b14e6987bde0e22e6c82ac438
|
|
|
|
|
|
// Adds and removes observers for `PrintViewManagerBase` events. The order in
|
|
|
// which notifications are sent to observers is undefined. Observers must be
|
|
|
-@@ -145,6 +152,14 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
|
|
+@@ -147,6 +154,14 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
|
|
void AddTestObserver(TestObserver& observer);
|
|
|
void RemoveTestObserver(TestObserver& observer);
|
|
|
|
|
@@ -514,9 +513,9 @@ index 24a2bc8b26462e6cafbcd5eb89e838b73266ec70..402aab3b14e6987bde0e22e6c82ac438
|
|
|
+ };
|
|
|
+
|
|
|
protected:
|
|
|
- explicit PrintViewManagerBase(content::WebContents* web_contents);
|
|
|
-
|
|
|
-@@ -268,6 +283,7 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
|
|
+ #if BUILDFLAG(ENABLE_PRINT_CONTENT_ANALYSIS)
|
|
|
+ using PrintDocumentCallback =
|
|
|
+@@ -290,6 +305,7 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
|
|
bool success);
|
|
|
#endif
|
|
|
void CompleteUpdatePrintSettings(
|
|
@@ -524,7 +523,7 @@ index 24a2bc8b26462e6cafbcd5eb89e838b73266ec70..402aab3b14e6987bde0e22e6c82ac438
|
|
|
base::Value::Dict job_settings,
|
|
|
std::unique_ptr<PrintSettings> print_settings,
|
|
|
UpdatePrintSettingsCallback callback);
|
|
|
-@@ -362,8 +378,11 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
|
|
+@@ -384,8 +400,11 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
|
|
// The current RFH that is printing with a system printing dialog.
|
|
|
raw_ptr<content::RenderFrameHost> printing_rfh_ = nullptr;
|
|
|
|
|
@@ -538,7 +537,7 @@ index 24a2bc8b26462e6cafbcd5eb89e838b73266ec70..402aab3b14e6987bde0e22e6c82ac438
|
|
|
// Indication that the job is getting canceled.
|
|
|
bool canceling_job_ = false;
|
|
|
diff --git a/chrome/browser/printing/printer_query.cc b/chrome/browser/printing/printer_query.cc
|
|
|
-index 418f53b0db3a2b2624298fca5628aacdd2a99c94..4a110fda692e16ec887cb90c6a2fa611c67b8d6f 100644
|
|
|
+index 0e48a7582d86c85a826de08af655b29a3ef74fd2..2e67a73611ca2c55ffc002341b0878de7191c932 100644
|
|
|
--- a/chrome/browser/printing/printer_query.cc
|
|
|
+++ b/chrome/browser/printing/printer_query.cc
|
|
|
@@ -355,17 +355,19 @@ void PrinterQuery::UpdatePrintSettings(base::Value::Dict new_settings,
|
|
@@ -640,7 +639,7 @@ index 4ecdb28904fac480cf102fffdff24ae008ac88cf..e8150c95fafd83d7e2fe1f472a35acec
|
|
|
PrintingFailed(int32 cookie, PrintFailureReason reason);
|
|
|
|
|
|
diff --git a/components/printing/renderer/print_render_frame_helper.cc b/components/printing/renderer/print_render_frame_helper.cc
|
|
|
-index a0ec654b13f82d9c5ff4eb838585485a59c45924..e24f2e209e547685daf18570c0a8a95306c72e2d 100644
|
|
|
+index 5df31ec780ae5388b431e6fd63cee5de705a177a..ed520b130544a3854c4dcf98b04ada0cc2a14587 100644
|
|
|
--- a/components/printing/renderer/print_render_frame_helper.cc
|
|
|
+++ b/components/printing/renderer/print_render_frame_helper.cc
|
|
|
@@ -47,6 +47,7 @@
|
|
@@ -651,7 +650,7 @@ index a0ec654b13f82d9c5ff4eb838585485a59c45924..e24f2e209e547685daf18570c0a8a953
|
|
|
#include "printing/units.h"
|
|
|
#include "services/metrics/public/cpp/ukm_source_id.h"
|
|
|
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
|
|
|
-@@ -1229,14 +1230,14 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) {
|
|
|
+@@ -1231,14 +1232,14 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) {
|
|
|
}
|
|
|
|
|
|
print_in_progress_ = true;
|
|
@@ -668,7 +667,7 @@ index a0ec654b13f82d9c5ff4eb838585485a59c45924..e24f2e209e547685daf18570c0a8a953
|
|
|
if (!weak_this) {
|
|
|
return;
|
|
|
}
|
|
|
-@@ -1267,7 +1268,7 @@ void PrintRenderFrameHelper::BindPrintRenderFrameReceiver(
|
|
|
+@@ -1269,7 +1270,7 @@ void PrintRenderFrameHelper::BindPrintRenderFrameReceiver(
|
|
|
receivers_.Add(this, std::move(receiver));
|
|
|
}
|
|
|
|
|
@@ -677,7 +676,7 @@ index a0ec654b13f82d9c5ff4eb838585485a59c45924..e24f2e209e547685daf18570c0a8a953
|
|
|
ScopedIPC scoped_ipc(weak_ptr_factory_.GetWeakPtr());
|
|
|
if (ipc_nesting_level_ > kAllowedIpcDepthForPrint)
|
|
|
return;
|
|
|
-@@ -1282,7 +1283,7 @@ void PrintRenderFrameHelper::PrintRequestedPages() {
|
|
|
+@@ -1284,7 +1285,7 @@ void PrintRenderFrameHelper::PrintRequestedPages() {
|
|
|
// plugin node and print that instead.
|
|
|
auto plugin = delegate_->GetPdfElement(frame);
|
|
|
|
|
@@ -686,7 +685,7 @@ index a0ec654b13f82d9c5ff4eb838585485a59c45924..e24f2e209e547685daf18570c0a8a953
|
|
|
|
|
|
if (render_frame_gone_) {
|
|
|
return;
|
|
|
-@@ -1371,7 +1372,8 @@ void PrintRenderFrameHelper::PrintForSystemDialog() {
|
|
|
+@@ -1373,7 +1374,8 @@ void PrintRenderFrameHelper::PrintForSystemDialog() {
|
|
|
}
|
|
|
|
|
|
Print(frame, print_preview_context_.source_node(),
|
|
@@ -696,7 +695,7 @@ index a0ec654b13f82d9c5ff4eb838585485a59c45924..e24f2e209e547685daf18570c0a8a953
|
|
|
if (render_frame_gone_) {
|
|
|
return;
|
|
|
}
|
|
|
-@@ -1434,6 +1436,8 @@ void PrintRenderFrameHelper::PrintPreview(base::Value::Dict settings) {
|
|
|
+@@ -1436,6 +1438,8 @@ void PrintRenderFrameHelper::PrintPreview(base::Value::Dict settings) {
|
|
|
if (ipc_nesting_level_ > kAllowedIpcDepthForPrint)
|
|
|
return;
|
|
|
|
|
@@ -705,7 +704,7 @@ index a0ec654b13f82d9c5ff4eb838585485a59c45924..e24f2e209e547685daf18570c0a8a953
|
|
|
print_preview_context_.OnPrintPreview();
|
|
|
|
|
|
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
|
|
-@@ -2011,7 +2015,8 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
|
|
+@@ -2013,7 +2017,8 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
|
|
}
|
|
|
|
|
|
Print(duplicate_node.GetDocument().GetFrame(), duplicate_node,
|
|
@@ -715,7 +714,7 @@ index a0ec654b13f82d9c5ff4eb838585485a59c45924..e24f2e209e547685daf18570c0a8a953
|
|
|
// Check if `this` is still valid.
|
|
|
if (!weak_this) {
|
|
|
return;
|
|
|
-@@ -2027,17 +2032,19 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
|
|
+@@ -2029,17 +2034,19 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
|
|
|
|
|
void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
|
|
const blink::WebNode& node,
|
|
@@ -738,7 +737,7 @@ index a0ec654b13f82d9c5ff4eb838585485a59c45924..e24f2e209e547685daf18570c0a8a953
|
|
|
DidFinishPrinting(PrintingResult::kFailPrintInit);
|
|
|
return;
|
|
|
}
|
|
|
-@@ -2058,8 +2065,15 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
|
|
+@@ -2060,8 +2067,15 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
|
|
print_pages_params_->params->print_scaling_option;
|
|
|
|
|
|
auto self = weak_ptr_factory_.GetWeakPtr();
|
|
@@ -755,7 +754,7 @@ index a0ec654b13f82d9c5ff4eb838585485a59c45924..e24f2e209e547685daf18570c0a8a953
|
|
|
// Check if `this` is still valid.
|
|
|
if (!self)
|
|
|
return;
|
|
|
-@@ -2317,25 +2331,33 @@ void PrintRenderFrameHelper::IPCProcessed() {
|
|
|
+@@ -2319,25 +2333,33 @@ void PrintRenderFrameHelper::IPCProcessed() {
|
|
|
}
|
|
|
|
|
|
bool PrintRenderFrameHelper::InitPrintSettings(blink::WebLocalFrame* frame,
|
|
@@ -785,11 +784,11 @@ index a0ec654b13f82d9c5ff4eb838585485a59c45924..e24f2e209e547685daf18570c0a8a953
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- bool fit_to_paper_size = !IsPrintingPdfFrame(frame, node);
|
|
|
+ bool center_on_paper = !IsPrintingPdfFrame(frame, node);
|
|
|
- settings.params->print_scaling_option =
|
|
|
+ settings->params->print_scaling_option =
|
|
|
- fit_to_paper_size ? mojom::PrintScalingOption::kFitToPrintableArea
|
|
|
- : mojom::PrintScalingOption::kSourceSize;
|
|
|
+ center_on_paper ? mojom::PrintScalingOption::kCenterShrinkToFitPaper
|
|
|
+ : mojom::PrintScalingOption::kSourceSize;
|
|
|
- SetPrintPagesParams(settings);
|
|
|
+ SetPrintPagesParams(*settings);
|
|
|
return true;
|
|
@@ -830,10 +829,10 @@ index b0ac94751454bd16b4e9bfdc071e2623813133ec..271bd9949a802a370b3619340f3364df
|
|
|
// Calculate number of pages in source document.
|
|
|
uint32_t CalculateNumberOfPages(blink::WebLocalFrame* frame,
|
|
|
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
|
|
|
-index f6b7ba2f3512dcd2528323bb6853452cc9eab1a6..288d9219efa0ea8683fe86c5b339bbf9b829d712 100644
|
|
|
+index 873d36935fcce58584e10bf26e483ba89533d6c6..48808e9c491d095473092d5bff9ba67621e0613e 100644
|
|
|
--- a/content/browser/BUILD.gn
|
|
|
+++ b/content/browser/BUILD.gn
|
|
|
-@@ -2933,8 +2933,9 @@ source_set("browser") {
|
|
|
+@@ -2935,8 +2935,9 @@ source_set("browser") {
|
|
|
"//ppapi/shared_impl",
|
|
|
]
|
|
|
|