refactor: fold silent print into settings (#41873)
* refactor: fold silent print into settings * chore: feedback
This commit is contained in:
parent
cdafe09ffb
commit
b118c70f77
3 changed files with 87 additions and 172 deletions
|
@ -91,20 +91,10 @@ index 0d8a53178e8d509a573ffdaadf2c4cec670522ac..8e7f9b92beb317888a5a3acb3bc2fa29
|
||||||
: PdfRenderSettings::Mode::POSTSCRIPT_LEVEL3;
|
: PdfRenderSettings::Mode::POSTSCRIPT_LEVEL3;
|
||||||
}
|
}
|
||||||
diff --git a/chrome/browser/printing/print_view_manager_base.cc b/chrome/browser/printing/print_view_manager_base.cc
|
diff --git a/chrome/browser/printing/print_view_manager_base.cc b/chrome/browser/printing/print_view_manager_base.cc
|
||||||
index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec593554a1 100644
|
index 261742ba789809e4dc65530fff25554d10c59b75..12bc3f84b0279c9eb2f1fc5cfe5ea1546ba174ca 100644
|
||||||
--- a/chrome/browser/printing/print_view_manager_base.cc
|
--- a/chrome/browser/printing/print_view_manager_base.cc
|
||||||
+++ b/chrome/browser/printing/print_view_manager_base.cc
|
+++ b/chrome/browser/printing/print_view_manager_base.cc
|
||||||
@@ -25,7 +25,9 @@
|
@@ -86,6 +86,20 @@ namespace printing {
|
||||||
#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"
|
|
||||||
@@ -86,6 +88,20 @@ namespace printing {
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -125,31 +115,31 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
void OnDidGetDefaultPrintSettings(
|
void OnDidGetDefaultPrintSettings(
|
||||||
scoped_refptr<PrintQueriesQueue> queue,
|
scoped_refptr<PrintQueriesQueue> queue,
|
||||||
bool want_pdf_settings,
|
bool want_pdf_settings,
|
||||||
@@ -94,9 +110,11 @@ void OnDidGetDefaultPrintSettings(
|
@@ -94,9 +108,9 @@ void OnDidGetDefaultPrintSettings(
|
||||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||||
|
|
||||||
if (printer_query->last_status() != mojom::ResultCode::kSuccess) {
|
if (printer_query->last_status() != mojom::ResultCode::kSuccess) {
|
||||||
+#if 0 // Electron does not use Chrome error dialogs
|
- if (!want_pdf_settings) {
|
||||||
if (!want_pdf_settings) {
|
+#if 0 // Electron does not use Chromium error dialogs
|
||||||
ShowPrintErrorDialogForInvalidPrinterError();
|
ShowPrintErrorDialogForInvalidPrinterError();
|
||||||
}
|
- }
|
||||||
+#endif
|
+#endif
|
||||||
std::move(callback).Run(nullptr);
|
std::move(callback).Run(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -106,9 +124,11 @@ void OnDidGetDefaultPrintSettings(
|
@@ -106,9 +120,9 @@ void OnDidGetDefaultPrintSettings(
|
||||||
params->document_cookie = printer_query->cookie();
|
params->document_cookie = printer_query->cookie();
|
||||||
|
|
||||||
if (!PrintMsgPrintParamsIsValid(*params)) {
|
if (!PrintMsgPrintParamsIsValid(*params)) {
|
||||||
+#if 0 // Electron does not use Chrome error dialogs
|
- if (!want_pdf_settings) {
|
||||||
if (!want_pdf_settings) {
|
+#if 0 // Electron does not use Chromium error dialogs
|
||||||
ShowPrintErrorDialogForInvalidPrinterError();
|
ShowPrintErrorDialogForInvalidPrinterError();
|
||||||
}
|
- }
|
||||||
+#endif
|
+#endif
|
||||||
std::move(callback).Run(nullptr);
|
std::move(callback).Run(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -120,11 +140,15 @@ void OnDidGetDefaultPrintSettings(
|
@@ -120,11 +134,15 @@ void OnDidGetDefaultPrintSettings(
|
||||||
void OnDidScriptedPrint(
|
void OnDidScriptedPrint(
|
||||||
scoped_refptr<PrintQueriesQueue> queue,
|
scoped_refptr<PrintQueriesQueue> queue,
|
||||||
std::unique_ptr<PrinterQuery> printer_query,
|
std::unique_ptr<PrinterQuery> printer_query,
|
||||||
|
@ -166,26 +156,24 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
std::move(callback).Run(nullptr);
|
std::move(callback).Run(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -181,9 +205,11 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents)
|
@@ -181,9 +199,11 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents)
|
||||||
: PrintManager(web_contents),
|
: PrintManager(web_contents),
|
||||||
queue_(g_browser_process->print_job_manager()->queue()) {
|
queue_(g_browser_process->print_job_manager()->queue()) {
|
||||||
DCHECK(queue_);
|
DCHECK(queue_);
|
||||||
+#if 0 // Printing is always enabled.
|
+#if 0
|
||||||
Profile* profile =
|
Profile* profile =
|
||||||
Profile::FromBrowserContext(web_contents->GetBrowserContext());
|
Profile::FromBrowserContext(web_contents->GetBrowserContext());
|
||||||
- printing_enabled_.Init(prefs::kPrintingEnabled, profile->GetPrefs());
|
printing_enabled_.Init(prefs::kPrintingEnabled, profile->GetPrefs());
|
||||||
+ printing_enabled_.Init(prefs::kPrintingEnabled, profile->GetPrefs());
|
|
||||||
+#endif
|
+#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintViewManagerBase::~PrintViewManagerBase() {
|
PrintViewManagerBase::~PrintViewManagerBase() {
|
||||||
@@ -207,12 +233,17 @@ void PrintViewManagerBase::DisableThirdPartyBlocking() {
|
@@ -207,12 +227,16 @@ void PrintViewManagerBase::DisableThirdPartyBlocking() {
|
||||||
}
|
}
|
||||||
#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
||||||
|
|
||||||
-bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh) {
|
-bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh) {
|
||||||
+bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh,
|
+bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh,
|
||||||
+ bool silent,
|
|
||||||
+ base::Value::Dict settings,
|
+ base::Value::Dict settings,
|
||||||
+ CompletionCallback callback) {
|
+ CompletionCallback callback) {
|
||||||
if (!StartPrintCommon(rfh)) {
|
if (!StartPrintCommon(rfh)) {
|
||||||
|
@ -195,11 +183,11 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
- GetPrintRenderFrame(rfh)->PrintRequestedPages();
|
- GetPrintRenderFrame(rfh)->PrintRequestedPages();
|
||||||
+ callback_ = std::move(callback);
|
+ callback_ = std::move(callback);
|
||||||
+
|
+
|
||||||
+ GetPrintRenderFrame(rfh)->PrintRequestedPages(silent, std::move(settings));
|
+ GetPrintRenderFrame(rfh)->PrintRequestedPages(std::move(settings));
|
||||||
|
|
||||||
for (auto& observer : GetTestObservers()) {
|
for (auto& observer : GetTestObservers()) {
|
||||||
observer.OnPrintNow(rfh);
|
observer.OnPrintNow(rfh);
|
||||||
@@ -341,12 +372,13 @@ void PrintViewManagerBase::OnDidUpdatePrintableArea(
|
@@ -341,12 +365,13 @@ void PrintViewManagerBase::OnDidUpdatePrintableArea(
|
||||||
}
|
}
|
||||||
PRINTER_LOG(EVENT) << "Paper printable area updated for vendor id "
|
PRINTER_LOG(EVENT) << "Paper printable area updated for vendor id "
|
||||||
<< print_settings->requested_media().vendor_id;
|
<< print_settings->requested_media().vendor_id;
|
||||||
|
@ -214,7 +202,7 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
base::Value::Dict job_settings,
|
base::Value::Dict job_settings,
|
||||||
std::unique_ptr<PrintSettings> print_settings,
|
std::unique_ptr<PrintSettings> print_settings,
|
||||||
UpdatePrintSettingsCallback callback) {
|
UpdatePrintSettingsCallback callback) {
|
||||||
@@ -354,7 +386,8 @@ void PrintViewManagerBase::CompleteUpdatePrintSettings(
|
@@ -354,7 +379,8 @@ void PrintViewManagerBase::CompleteUpdatePrintSettings(
|
||||||
settings->pages = GetPageRangesFromJobSettings(job_settings);
|
settings->pages = GetPageRangesFromJobSettings(job_settings);
|
||||||
settings->params = mojom::PrintParams::New();
|
settings->params = mojom::PrintParams::New();
|
||||||
RenderParamsFromPrintSettings(*print_settings, settings->params.get());
|
RenderParamsFromPrintSettings(*print_settings, settings->params.get());
|
||||||
|
@ -224,7 +212,7 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
if (!PrintMsgPrintParamsIsValid(*settings->params)) {
|
if (!PrintMsgPrintParamsIsValid(*settings->params)) {
|
||||||
mojom::PrinterType printer_type = static_cast<mojom::PrinterType>(
|
mojom::PrinterType printer_type = static_cast<mojom::PrinterType>(
|
||||||
*job_settings.FindInt(kSettingPrinterType));
|
*job_settings.FindInt(kSettingPrinterType));
|
||||||
@@ -366,6 +399,10 @@ void PrintViewManagerBase::CompleteUpdatePrintSettings(
|
@@ -366,6 +392,10 @@ void PrintViewManagerBase::CompleteUpdatePrintSettings(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,49 +223,19 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
set_cookie(settings->params->document_cookie);
|
set_cookie(settings->params->document_cookie);
|
||||||
std::move(callback).Run(std::move(settings));
|
std::move(callback).Run(std::move(settings));
|
||||||
}
|
}
|
||||||
@@ -652,10 +689,12 @@ void PrintViewManagerBase::DidPrintDocument(
|
@@ -739,10 +769,7 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
||||||
void PrintViewManagerBase::GetDefaultPrintSettings(
|
// `job_settings` does not yet contain the rasterized PDF dpi, so if the user
|
||||||
GetDefaultPrintSettingsCallback callback) {
|
// has the print preference set, fetch it for use in
|
||||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
// `PrintSettingsFromJobSettings()`.
|
||||||
+#if 0 // Printing is always enabled.
|
- content::BrowserContext* context =
|
||||||
if (!GetPrintingEnabledBooleanPref()) {
|
- web_contents() ? web_contents()->GetBrowserContext() : nullptr;
|
||||||
GetDefaultPrintSettingsReply(std::move(callback), nullptr);
|
- PrefService* prefs =
|
||||||
return;
|
- context ? Profile::FromBrowserContext(context)->GetPrefs() : nullptr;
|
||||||
}
|
+ PrefService* prefs = nullptr;
|
||||||
+#endif
|
if (prefs && prefs->HasPrefPath(prefs::kPrintRasterizePdfDpi)) {
|
||||||
|
int value = prefs->GetInteger(prefs::kPrintRasterizePdfDpi);
|
||||||
content::RenderFrameHost* render_frame_host = GetCurrentTargetFrame();
|
|
||||||
if (base::FeatureList::IsEnabled(kCheckPrintRfhIsActive) &&
|
|
||||||
@@ -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 (!GetPrintingEnabledBooleanPref()) {
|
|
||||||
std::move(callback).Run(nullptr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
+#endif
|
|
||||||
|
|
||||||
std::optional<int> printer_type_value =
|
|
||||||
job_settings.FindInt(kSettingPrinterType);
|
|
||||||
@@ -729,6 +770,7 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
||||||
|
|
||||||
mojom::PrinterType printer_type =
|
|
||||||
static_cast<mojom::PrinterType>(*printer_type_value);
|
|
||||||
+#if 0 // Printing is always enabled.
|
|
||||||
if (printer_type != mojom::PrinterType::kExtension &&
|
|
||||||
printer_type != mojom::PrinterType::kPdf &&
|
|
||||||
printer_type != mojom::PrinterType::kLocal) {
|
|
||||||
@@ -748,6 +790,7 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
||||||
if (value > 0)
|
if (value > 0)
|
||||||
job_settings.Set(kSettingRasterizePdfDpi, value);
|
@@ -767,7 +794,21 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
||||||
}
|
|
||||||
+#endif // Printing is always enabled.
|
|
||||||
|
|
||||||
std::unique_ptr<PrintSettings> print_settings =
|
|
||||||
PrintSettingsFromJobSettings(job_settings);
|
|
||||||
@@ -767,7 +810,21 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +258,7 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
// TODO(crbug.com/1424368): Remove this if the printable areas can be made
|
// TODO(crbug.com/1424368): Remove this if the printable areas can be made
|
||||||
// fully available from `PrintBackend::GetPrinterSemanticCapsAndDefaults()`
|
// fully available from `PrintBackend::GetPrinterSemanticCapsAndDefaults()`
|
||||||
// for in-browser queries.
|
// for in-browser queries.
|
||||||
@@ -789,8 +846,6 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
@@ -789,8 +830,6 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -309,7 +267,7 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintViewManagerBase::SetAccessibilityTree(
|
void PrintViewManagerBase::SetAccessibilityTree(
|
||||||
@@ -806,7 +861,7 @@ void PrintViewManagerBase::SetAccessibilityTree(
|
@@ -806,7 +845,7 @@ void PrintViewManagerBase::SetAccessibilityTree(
|
||||||
void PrintViewManagerBase::IsPrintingEnabled(
|
void PrintViewManagerBase::IsPrintingEnabled(
|
||||||
IsPrintingEnabledCallback callback) {
|
IsPrintingEnabledCallback callback) {
|
||||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||||
|
@ -318,24 +276,21 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintViewManagerBase::ScriptedPrint(mojom::ScriptedPrintParamsPtr params,
|
void PrintViewManagerBase::ScriptedPrint(mojom::ScriptedPrintParamsPtr params,
|
||||||
@@ -857,6 +912,7 @@ void PrintViewManagerBase::PrintingFailed(int32_t cookie,
|
@@ -862,11 +901,9 @@ void PrintViewManagerBase::PrintingFailed(int32_t cookie,
|
||||||
|
|
||||||
PrintManager::PrintingFailed(cookie, reason);
|
|
||||||
|
|
||||||
+#if 0 // Electron does not use Chromium error dialogs
|
|
||||||
// `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
|
// destroyed. In such cases the error notification to the user will
|
||||||
@@ -866,7 +922,7 @@ void PrintViewManagerBase::PrintingFailed(int32_t cookie,
|
// have already been displayed, and a second message should not be
|
||||||
print_job_->document()->cookie() == cookie) {
|
// shown.
|
||||||
|
- if (print_job_ && print_job_->document() &&
|
||||||
|
- print_job_->document()->cookie() == cookie) {
|
||||||
|
+#if 0 // Electron does not use Chromium error dialogs
|
||||||
ShowPrintErrorDialogForGenericError();
|
ShowPrintErrorDialogForGenericError();
|
||||||
}
|
- }
|
||||||
-
|
-
|
||||||
+#endif
|
+#endif
|
||||||
ReleasePrinterQuery();
|
ReleasePrinterQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -878,15 +934,24 @@ void PrintViewManagerBase::RemoveTestObserver(TestObserver& observer) {
|
@@ -878,15 +915,24 @@ void PrintViewManagerBase::RemoveTestObserver(TestObserver& observer) {
|
||||||
test_observers_.RemoveObserver(&observer);
|
test_observers_.RemoveObserver(&observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,7 +315,16 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintViewManagerBase::RenderFrameDeleted(
|
void PrintViewManagerBase::RenderFrameDeleted(
|
||||||
@@ -942,7 +1007,12 @@ void PrintViewManagerBase::OnJobDone() {
|
@@ -925,7 +971,7 @@ void PrintViewManagerBase::SystemDialogCancelled() {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool PrintViewManagerBase::GetPrintingEnabledBooleanPref() const {
|
||||||
|
- return printing_enabled_.GetValue();
|
||||||
|
+ return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintViewManagerBase::OnDocDone(int job_id, PrintedDocument* document) {
|
||||||
|
@@ -942,7 +988,12 @@ void PrintViewManagerBase::OnJobDone() {
|
||||||
// Printing is done, we don't need it anymore.
|
// Printing is done, we don't need it anymore.
|
||||||
// print_job_->is_job_pending() may still be true, depending on the order
|
// print_job_->is_job_pending() may still be true, depending on the order
|
||||||
// of object registration.
|
// of object registration.
|
||||||
|
@ -374,19 +338,19 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
ReleasePrintJob();
|
ReleasePrintJob();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -951,9 +1021,10 @@ void PrintViewManagerBase::OnCanceling() {
|
@@ -951,9 +1002,9 @@ void PrintViewManagerBase::OnCanceling() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintViewManagerBase::OnFailed() {
|
void PrintViewManagerBase::OnFailed() {
|
||||||
|
- if (!canceling_job_)
|
||||||
+#if 0 // Electron does not use Chromium error dialogs
|
+#if 0 // Electron does not use Chromium error dialogs
|
||||||
if (!canceling_job_)
|
|
||||||
ShowPrintErrorDialogForGenericError();
|
ShowPrintErrorDialogForGenericError();
|
||||||
-
|
-
|
||||||
+#endif
|
+#endif
|
||||||
TerminatePrintJob(true);
|
TerminatePrintJob(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -963,7 +1034,7 @@ bool PrintViewManagerBase::RenderAllMissingPagesNow() {
|
@@ -963,7 +1014,7 @@ bool PrintViewManagerBase::RenderAllMissingPagesNow() {
|
||||||
|
|
||||||
// Is the document already complete?
|
// Is the document already complete?
|
||||||
if (print_job_->document() && print_job_->document()->IsComplete()) {
|
if (print_job_->document() && print_job_->document()->IsComplete()) {
|
||||||
|
@ -395,7 +359,7 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1016,7 +1087,10 @@ bool PrintViewManagerBase::SetupNewPrintJob(
|
@@ -1016,7 +1067,10 @@ bool PrintViewManagerBase::SetupNewPrintJob(
|
||||||
|
|
||||||
// Disconnect the current `print_job_`.
|
// Disconnect the current `print_job_`.
|
||||||
auto weak_this = weak_ptr_factory_.GetWeakPtr();
|
auto weak_this = weak_ptr_factory_.GetWeakPtr();
|
||||||
|
@ -407,7 +371,7 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
if (!weak_this)
|
if (!weak_this)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -1036,7 +1110,7 @@ bool PrintViewManagerBase::SetupNewPrintJob(
|
@@ -1036,7 +1090,7 @@ bool PrintViewManagerBase::SetupNewPrintJob(
|
||||||
#endif
|
#endif
|
||||||
print_job_->AddObserver(*this);
|
print_job_->AddObserver(*this);
|
||||||
|
|
||||||
|
@ -416,7 +380,7 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1104,6 +1178,11 @@ void PrintViewManagerBase::ReleasePrintJob() {
|
@@ -1104,6 +1158,11 @@ void PrintViewManagerBase::ReleasePrintJob() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -428,7 +392,7 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
if (!print_job_)
|
if (!print_job_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1111,7 +1190,7 @@ void PrintViewManagerBase::ReleasePrintJob() {
|
@@ -1111,7 +1170,7 @@ void PrintViewManagerBase::ReleasePrintJob() {
|
||||||
// printing_rfh_ should only ever point to a RenderFrameHost with a live
|
// printing_rfh_ should only ever point to a RenderFrameHost with a live
|
||||||
// RenderFrame.
|
// RenderFrame.
|
||||||
DCHECK(rfh->IsRenderFrameLive());
|
DCHECK(rfh->IsRenderFrameLive());
|
||||||
|
@ -437,7 +401,7 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
}
|
}
|
||||||
|
|
||||||
print_job_->RemoveObserver(*this);
|
print_job_->RemoveObserver(*this);
|
||||||
@@ -1153,7 +1232,7 @@ bool PrintViewManagerBase::RunInnerMessageLoop() {
|
@@ -1153,7 +1212,7 @@ bool PrintViewManagerBase::RunInnerMessageLoop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrintViewManagerBase::OpportunisticallyCreatePrintJob(int cookie) {
|
bool PrintViewManagerBase::OpportunisticallyCreatePrintJob(int cookie) {
|
||||||
|
@ -446,7 +410,7 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!cookie) {
|
if (!cookie) {
|
||||||
@@ -1307,6 +1386,8 @@ void PrintViewManagerBase::CompleteScriptedPrint(
|
@@ -1307,6 +1366,8 @@ void PrintViewManagerBase::CompleteScriptedPrint(
|
||||||
auto callback_wrapper = base::BindOnce(
|
auto callback_wrapper = base::BindOnce(
|
||||||
&PrintViewManagerBase::ScriptedPrintReply, weak_ptr_factory_.GetWeakPtr(),
|
&PrintViewManagerBase::ScriptedPrintReply, weak_ptr_factory_.GetWeakPtr(),
|
||||||
std::move(callback), render_process_host->GetID());
|
std::move(callback), render_process_host->GetID());
|
||||||
|
@ -455,7 +419,7 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
||||||
DisableThirdPartyBlocking();
|
DisableThirdPartyBlocking();
|
||||||
#endif
|
#endif
|
||||||
@@ -1321,7 +1402,7 @@ void PrintViewManagerBase::CompleteScriptedPrint(
|
@@ -1321,7 +1382,7 @@ void PrintViewManagerBase::CompleteScriptedPrint(
|
||||||
params->expected_pages_count, params->has_selection, params->margin_type,
|
params->expected_pages_count, params->has_selection, params->margin_type,
|
||||||
params->is_scripted, !render_process_host->IsPdf(),
|
params->is_scripted, !render_process_host->IsPdf(),
|
||||||
base::BindOnce(&OnDidScriptedPrint, queue_, std::move(printer_query),
|
base::BindOnce(&OnDidScriptedPrint, queue_, std::move(printer_query),
|
||||||
|
@ -465,7 +429,7 @@ index 261742ba789809e4dc65530fff25554d10c59b75..40a7529c7b069a3b705705354bdb41ec
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_PRINT_CONTENT_ANALYSIS)
|
#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
|
diff --git a/chrome/browser/printing/print_view_manager_base.h b/chrome/browser/printing/print_view_manager_base.h
|
||||||
index 43e353663b9b6be478a9418752dc189118b7fa58..c52ba4328c2f41c8d4233eecb96b864e0a1b7979 100644
|
index 43e353663b9b6be478a9418752dc189118b7fa58..a751bdfeac3a7072114420cb5d93b2732a79696f 100644
|
||||||
--- a/chrome/browser/printing/print_view_manager_base.h
|
--- a/chrome/browser/printing/print_view_manager_base.h
|
||||||
+++ b/chrome/browser/printing/print_view_manager_base.h
|
+++ b/chrome/browser/printing/print_view_manager_base.h
|
||||||
@@ -51,6 +51,8 @@ class PrinterQuery;
|
@@ -51,6 +51,8 @@ class PrinterQuery;
|
||||||
|
@ -477,19 +441,18 @@ index 43e353663b9b6be478a9418752dc189118b7fa58..c52ba4328c2f41c8d4233eecb96b864e
|
||||||
// Base class for managing the print commands for a WebContents.
|
// Base class for managing the print commands for a WebContents.
|
||||||
class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
||||||
public:
|
public:
|
||||||
@@ -84,7 +86,10 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
@@ -84,7 +86,9 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
||||||
// Prints the current document immediately. Since the rendering is
|
// Prints the current document immediately. Since the rendering is
|
||||||
// asynchronous, the actual printing will not be completed on the return of
|
// asynchronous, the actual printing will not be completed on the return of
|
||||||
// this function. Returns false if printing is impossible at the moment.
|
// this function. Returns false if printing is impossible at the moment.
|
||||||
- virtual bool PrintNow(content::RenderFrameHost* rfh);
|
- virtual bool PrintNow(content::RenderFrameHost* rfh);
|
||||||
+ virtual bool PrintNow(content::RenderFrameHost* rfh,
|
+ virtual bool PrintNow(content::RenderFrameHost* rfh,
|
||||||
+ bool silent = true,
|
|
||||||
+ base::Value::Dict settings = {},
|
+ base::Value::Dict settings = {},
|
||||||
+ CompletionCallback callback = {});
|
+ CompletionCallback callback = {});
|
||||||
|
|
||||||
// Like PrintNow(), but for the node under the context menu, instead of the
|
// Like PrintNow(), but for the node under the context menu, instead of the
|
||||||
// entire frame.
|
// entire frame.
|
||||||
@@ -138,8 +143,10 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
@@ -138,8 +142,10 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
||||||
void IsPrintingEnabled(IsPrintingEnabledCallback callback) override;
|
void IsPrintingEnabled(IsPrintingEnabledCallback callback) override;
|
||||||
void ScriptedPrint(mojom::ScriptedPrintParamsPtr params,
|
void ScriptedPrint(mojom::ScriptedPrintParamsPtr params,
|
||||||
ScriptedPrintCallback callback) override;
|
ScriptedPrintCallback callback) override;
|
||||||
|
@ -500,7 +463,7 @@ index 43e353663b9b6be478a9418752dc189118b7fa58..c52ba4328c2f41c8d4233eecb96b864e
|
||||||
|
|
||||||
// Adds and removes observers for `PrintViewManagerBase` events. The order in
|
// Adds and removes observers for `PrintViewManagerBase` events. The order in
|
||||||
// which notifications are sent to observers is undefined. Observers must be
|
// which notifications are sent to observers is undefined. Observers must be
|
||||||
@@ -147,6 +154,14 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
@@ -147,6 +153,14 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
||||||
void AddTestObserver(TestObserver& observer);
|
void AddTestObserver(TestObserver& observer);
|
||||||
void RemoveTestObserver(TestObserver& observer);
|
void RemoveTestObserver(TestObserver& observer);
|
||||||
|
|
||||||
|
@ -515,7 +478,7 @@ index 43e353663b9b6be478a9418752dc189118b7fa58..c52ba4328c2f41c8d4233eecb96b864e
|
||||||
protected:
|
protected:
|
||||||
#if BUILDFLAG(ENABLE_PRINT_CONTENT_ANALYSIS)
|
#if BUILDFLAG(ENABLE_PRINT_CONTENT_ANALYSIS)
|
||||||
using PrintDocumentCallback =
|
using PrintDocumentCallback =
|
||||||
@@ -290,6 +305,7 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
@@ -290,6 +304,7 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
||||||
bool success);
|
bool success);
|
||||||
#endif
|
#endif
|
||||||
void CompleteUpdatePrintSettings(
|
void CompleteUpdatePrintSettings(
|
||||||
|
@ -523,7 +486,7 @@ index 43e353663b9b6be478a9418752dc189118b7fa58..c52ba4328c2f41c8d4233eecb96b864e
|
||||||
base::Value::Dict job_settings,
|
base::Value::Dict job_settings,
|
||||||
std::unique_ptr<PrintSettings> print_settings,
|
std::unique_ptr<PrintSettings> print_settings,
|
||||||
UpdatePrintSettingsCallback callback);
|
UpdatePrintSettingsCallback callback);
|
||||||
@@ -384,8 +400,11 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
@@ -384,8 +399,11 @@ class PrintViewManagerBase : public PrintManager, public PrintJob::Observer {
|
||||||
// The current RFH that is printing with a system printing dialog.
|
// The current RFH that is printing with a system printing dialog.
|
||||||
raw_ptr<content::RenderFrameHost> printing_rfh_ = nullptr;
|
raw_ptr<content::RenderFrameHost> printing_rfh_ = nullptr;
|
||||||
|
|
||||||
|
@ -564,32 +527,6 @@ index 0e48a7582d86c85a826de08af655b29a3ef74fd2..2e67a73611ca2c55ffc002341b0878de
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(IS_CHROMEOS)
|
#if BUILDFLAG(IS_CHROMEOS)
|
||||||
diff --git a/chrome/browser/ui/webui/print_preview/fake_print_render_frame.cc b/chrome/browser/ui/webui/print_preview/fake_print_render_frame.cc
|
|
||||||
index ac54519f611f719470c4b7a139a58f489884ede2..89055b6df74389560b6c5884a511897a36425b7b 100644
|
|
||||||
--- a/chrome/browser/ui/webui/print_preview/fake_print_render_frame.cc
|
|
||||||
+++ b/chrome/browser/ui/webui/print_preview/fake_print_render_frame.cc
|
|
||||||
@@ -21,7 +21,7 @@ FakePrintRenderFrame::FakePrintRenderFrame(
|
|
||||||
|
|
||||||
FakePrintRenderFrame::~FakePrintRenderFrame() = default;
|
|
||||||
|
|
||||||
-void FakePrintRenderFrame::PrintRequestedPages() {}
|
|
||||||
+void FakePrintRenderFrame::PrintRequestedPages(bool /*silent*/, ::base::Value::Dict /*settings*/) {}
|
|
||||||
|
|
||||||
void FakePrintRenderFrame::PrintWithParams(mojom::PrintPagesParamsPtr params,
|
|
||||||
PrintWithParamsCallback callback) {
|
|
||||||
diff --git a/chrome/browser/ui/webui/print_preview/fake_print_render_frame.h b/chrome/browser/ui/webui/print_preview/fake_print_render_frame.h
|
|
||||||
index 1e8f7bedaf679ee19788bf181b33e5d574d1f863..8be77b57580621bf659a6a2a63a2be94a2301c70 100644
|
|
||||||
--- a/chrome/browser/ui/webui/print_preview/fake_print_render_frame.h
|
|
||||||
+++ b/chrome/browser/ui/webui/print_preview/fake_print_render_frame.h
|
|
||||||
@@ -25,7 +25,7 @@ class FakePrintRenderFrame : public mojom::PrintRenderFrame {
|
|
||||||
|
|
||||||
private:
|
|
||||||
// printing::mojom::PrintRenderFrame:
|
|
||||||
- void PrintRequestedPages() override;
|
|
||||||
+ void PrintRequestedPages(bool silent, ::base::Value::Dict settings) override;
|
|
||||||
void PrintWithParams(mojom::PrintPagesParamsPtr params,
|
|
||||||
PrintWithParamsCallback callback) override;
|
|
||||||
void PrintForSystemDialog() override;
|
|
||||||
diff --git a/components/printing/browser/print_manager.cc b/components/printing/browser/print_manager.cc
|
diff --git a/components/printing/browser/print_manager.cc b/components/printing/browser/print_manager.cc
|
||||||
index 21c81377d32ae8d4185598a7eba88ed1d2063ef0..0767f4e9369e926b1cea99178c1a1975941f1765 100644
|
index 21c81377d32ae8d4185598a7eba88ed1d2063ef0..0767f4e9369e926b1cea99178c1a1975941f1765 100644
|
||||||
--- a/components/printing/browser/print_manager.cc
|
--- a/components/printing/browser/print_manager.cc
|
||||||
|
@ -616,7 +553,7 @@ index ca71560874a0189068dd11fbc039f5673bf6bd96..a8551d95e64da2afbc1685b2df8f1fc3
|
||||||
mojom::PrintFailureReason reason) override;
|
mojom::PrintFailureReason reason) override;
|
||||||
|
|
||||||
diff --git a/components/printing/common/print.mojom b/components/printing/common/print.mojom
|
diff --git a/components/printing/common/print.mojom b/components/printing/common/print.mojom
|
||||||
index 4ecdb28904fac480cf102fffdff24ae008ac88cf..e8150c95fafd83d7e2fe1f472a35acec3ca6e391 100644
|
index 4ecdb28904fac480cf102fffdff24ae008ac88cf..0d7d20c1a7920b1961585b345d30d9969411ca9e 100644
|
||||||
--- a/components/printing/common/print.mojom
|
--- a/components/printing/common/print.mojom
|
||||||
+++ b/components/printing/common/print.mojom
|
+++ b/components/printing/common/print.mojom
|
||||||
@@ -302,7 +302,7 @@ union PrintWithParamsResult {
|
@@ -302,7 +302,7 @@ union PrintWithParamsResult {
|
||||||
|
@ -624,7 +561,7 @@ index 4ecdb28904fac480cf102fffdff24ae008ac88cf..e8150c95fafd83d7e2fe1f472a35acec
|
||||||
// Tells the RenderFrame to switch the CSS to print media type, render every
|
// Tells the RenderFrame to switch the CSS to print media type, render every
|
||||||
// requested page, and then switch back the CSS to display media type.
|
// requested page, and then switch back the CSS to display media type.
|
||||||
- PrintRequestedPages();
|
- PrintRequestedPages();
|
||||||
+ PrintRequestedPages(bool silent, mojo_base.mojom.DictionaryValue settings);
|
+ PrintRequestedPages(mojo_base.mojom.DictionaryValue settings);
|
||||||
|
|
||||||
// Requests the frame to be printed with specified parameters. This is used
|
// Requests the frame to be printed with specified parameters. This is used
|
||||||
// to programmatically produce PDF by request from the browser (e.g. over
|
// to programmatically produce PDF by request from the browser (e.g. over
|
||||||
|
@ -639,7 +576,7 @@ index 4ecdb28904fac480cf102fffdff24ae008ac88cf..e8150c95fafd83d7e2fe1f472a35acec
|
||||||
PrintingFailed(int32 cookie, PrintFailureReason reason);
|
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
|
diff --git a/components/printing/renderer/print_render_frame_helper.cc b/components/printing/renderer/print_render_frame_helper.cc
|
||||||
index 5df31ec780ae5388b431e6fd63cee5de705a177a..ed520b130544a3854c4dcf98b04ada0cc2a14587 100644
|
index 5df31ec780ae5388b431e6fd63cee5de705a177a..9a7d340b38124b2557b43efb12f1d110c230de8f 100644
|
||||||
--- a/components/printing/renderer/print_render_frame_helper.cc
|
--- a/components/printing/renderer/print_render_frame_helper.cc
|
||||||
+++ b/components/printing/renderer/print_render_frame_helper.cc
|
+++ b/components/printing/renderer/print_render_frame_helper.cc
|
||||||
@@ -47,6 +47,7 @@
|
@@ -47,6 +47,7 @@
|
||||||
|
@ -663,7 +600,7 @@ index 5df31ec780ae5388b431e6fd63cee5de705a177a..ed520b130544a3854c4dcf98b04ada0c
|
||||||
|
|
||||||
- Print(web_frame, blink::WebNode(), PrintRequestType::kScripted);
|
- Print(web_frame, blink::WebNode(), PrintRequestType::kScripted);
|
||||||
+ Print(web_frame, blink::WebNode(), PrintRequestType::kScripted,
|
+ Print(web_frame, blink::WebNode(), PrintRequestType::kScripted,
|
||||||
+ false /* silent */, base::Value::Dict() /* new_settings */);
|
+ base::Value::Dict());
|
||||||
if (!weak_this) {
|
if (!weak_this) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -672,7 +609,7 @@ index 5df31ec780ae5388b431e6fd63cee5de705a177a..ed520b130544a3854c4dcf98b04ada0c
|
||||||
}
|
}
|
||||||
|
|
||||||
-void PrintRenderFrameHelper::PrintRequestedPages() {
|
-void PrintRenderFrameHelper::PrintRequestedPages() {
|
||||||
+void PrintRenderFrameHelper::PrintRequestedPages(bool silent, base::Value::Dict settings) {
|
+void PrintRenderFrameHelper::PrintRequestedPages(base::Value::Dict settings) {
|
||||||
ScopedIPC scoped_ipc(weak_ptr_factory_.GetWeakPtr());
|
ScopedIPC scoped_ipc(weak_ptr_factory_.GetWeakPtr());
|
||||||
if (ipc_nesting_level_ > kAllowedIpcDepthForPrint)
|
if (ipc_nesting_level_ > kAllowedIpcDepthForPrint)
|
||||||
return;
|
return;
|
||||||
|
@ -681,21 +618,11 @@ index 5df31ec780ae5388b431e6fd63cee5de705a177a..ed520b130544a3854c4dcf98b04ada0c
|
||||||
auto plugin = delegate_->GetPdfElement(frame);
|
auto plugin = delegate_->GetPdfElement(frame);
|
||||||
|
|
||||||
- Print(frame, plugin, PrintRequestType::kRegular);
|
- Print(frame, plugin, PrintRequestType::kRegular);
|
||||||
+ Print(frame, plugin, PrintRequestType::kRegular, silent, std::move(settings));
|
+ Print(frame, plugin, PrintRequestType::kRegular, std::move(settings));
|
||||||
|
|
||||||
if (render_frame_gone_) {
|
if (render_frame_gone_) {
|
||||||
return;
|
return;
|
||||||
@@ -1373,7 +1374,8 @@ void PrintRenderFrameHelper::PrintForSystemDialog() {
|
@@ -1436,6 +1437,8 @@ void PrintRenderFrameHelper::PrintPreview(base::Value::Dict settings) {
|
||||||
}
|
|
||||||
|
|
||||||
Print(frame, print_preview_context_.source_node(),
|
|
||||||
- PrintRequestType::kRegular);
|
|
||||||
+ PrintRequestType::kRegular, false,
|
|
||||||
+ base::Value::Dict());
|
|
||||||
if (render_frame_gone_) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
@@ -1436,6 +1438,8 @@ void PrintRenderFrameHelper::PrintPreview(base::Value::Dict settings) {
|
|
||||||
if (ipc_nesting_level_ > kAllowedIpcDepthForPrint)
|
if (ipc_nesting_level_ > kAllowedIpcDepthForPrint)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -704,28 +631,18 @@ index 5df31ec780ae5388b431e6fd63cee5de705a177a..ed520b130544a3854c4dcf98b04ada0c
|
||||||
print_preview_context_.OnPrintPreview();
|
print_preview_context_.OnPrintPreview();
|
||||||
|
|
||||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||||
@@ -2013,7 +2017,8 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
@@ -2029,17 +2032,19 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
||||||
}
|
|
||||||
|
|
||||||
Print(duplicate_node.GetDocument().GetFrame(), duplicate_node,
|
|
||||||
- PrintRequestType::kRegular);
|
|
||||||
+ PrintRequestType::kRegular, false /* silent */,
|
|
||||||
+ base::Value::Dict() /* new_settings */);
|
|
||||||
// Check if `this` is still valid.
|
|
||||||
if (!weak_this) {
|
|
||||||
return;
|
|
||||||
@@ -2029,17 +2034,19 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
|
||||||
|
|
||||||
void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||||
const blink::WebNode& node,
|
const blink::WebNode& node,
|
||||||
- PrintRequestType print_request_type) {
|
- PrintRequestType print_request_type) {
|
||||||
+ PrintRequestType print_request_type,
|
+ PrintRequestType print_request_type,
|
||||||
+ bool silent,
|
|
||||||
+ base::Value::Dict settings) {
|
+ base::Value::Dict settings) {
|
||||||
// If still not finished with earlier print request simply ignore.
|
// If still not finished with earlier print request simply ignore.
|
||||||
if (prep_frame_view_)
|
if (prep_frame_view_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
+ bool silent = settings.FindBool("silent").value_or(false);
|
||||||
FrameReference frame_ref(frame);
|
FrameReference frame_ref(frame);
|
||||||
|
|
||||||
- if (!InitPrintSettings(frame, node)) {
|
- if (!InitPrintSettings(frame, node)) {
|
||||||
|
@ -737,7 +654,7 @@ index 5df31ec780ae5388b431e6fd63cee5de705a177a..ed520b130544a3854c4dcf98b04ada0c
|
||||||
DidFinishPrinting(PrintingResult::kFailPrintInit);
|
DidFinishPrinting(PrintingResult::kFailPrintInit);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2060,8 +2067,15 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
@@ -2060,8 +2065,15 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||||
print_pages_params_->params->print_scaling_option;
|
print_pages_params_->params->print_scaling_option;
|
||||||
|
|
||||||
auto self = weak_ptr_factory_.GetWeakPtr();
|
auto self = weak_ptr_factory_.GetWeakPtr();
|
||||||
|
@ -754,7 +671,7 @@ index 5df31ec780ae5388b431e6fd63cee5de705a177a..ed520b130544a3854c4dcf98b04ada0c
|
||||||
// Check if `this` is still valid.
|
// Check if `this` is still valid.
|
||||||
if (!self)
|
if (!self)
|
||||||
return;
|
return;
|
||||||
@@ -2319,25 +2333,33 @@ void PrintRenderFrameHelper::IPCProcessed() {
|
@@ -2319,25 +2331,33 @@ void PrintRenderFrameHelper::IPCProcessed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrintRenderFrameHelper::InitPrintSettings(blink::WebLocalFrame* frame,
|
bool PrintRenderFrameHelper::InitPrintSettings(blink::WebLocalFrame* frame,
|
||||||
|
@ -795,7 +712,7 @@ index 5df31ec780ae5388b431e6fd63cee5de705a177a..ed520b130544a3854c4dcf98b04ada0c
|
||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/components/printing/renderer/print_render_frame_helper.h b/components/printing/renderer/print_render_frame_helper.h
|
diff --git a/components/printing/renderer/print_render_frame_helper.h b/components/printing/renderer/print_render_frame_helper.h
|
||||||
index b0ac94751454bd16b4e9bfdc071e2623813133ec..271bd9949a802a370b3619340f3364df14c7fe4a 100644
|
index b0ac94751454bd16b4e9bfdc071e2623813133ec..2631e9019e4c6617e2a8a90d30a21ca5552f1d67 100644
|
||||||
--- a/components/printing/renderer/print_render_frame_helper.h
|
--- a/components/printing/renderer/print_render_frame_helper.h
|
||||||
+++ b/components/printing/renderer/print_render_frame_helper.h
|
+++ b/components/printing/renderer/print_render_frame_helper.h
|
||||||
@@ -245,7 +245,7 @@ class PrintRenderFrameHelper
|
@@ -245,7 +245,7 @@ class PrintRenderFrameHelper
|
||||||
|
@ -803,22 +720,21 @@ index b0ac94751454bd16b4e9bfdc071e2623813133ec..271bd9949a802a370b3619340f3364df
|
||||||
|
|
||||||
// printing::mojom::PrintRenderFrame:
|
// printing::mojom::PrintRenderFrame:
|
||||||
- void PrintRequestedPages() override;
|
- void PrintRequestedPages() override;
|
||||||
+ void PrintRequestedPages(bool silent, base::Value::Dict settings) override;
|
+ void PrintRequestedPages(base::Value::Dict settings) override;
|
||||||
void PrintWithParams(mojom::PrintPagesParamsPtr params,
|
void PrintWithParams(mojom::PrintPagesParamsPtr params,
|
||||||
PrintWithParamsCallback callback) override;
|
PrintWithParamsCallback callback) override;
|
||||||
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||||
@@ -312,7 +312,9 @@ class PrintRenderFrameHelper
|
@@ -312,7 +312,8 @@ class PrintRenderFrameHelper
|
||||||
// WARNING: |this| may be gone after this method returns.
|
// WARNING: |this| may be gone after this method returns.
|
||||||
void Print(blink::WebLocalFrame* frame,
|
void Print(blink::WebLocalFrame* frame,
|
||||||
const blink::WebNode& node,
|
const blink::WebNode& node,
|
||||||
- PrintRequestType print_request_type);
|
- PrintRequestType print_request_type);
|
||||||
+ PrintRequestType print_request_type,
|
+ PrintRequestType print_request_type,
|
||||||
+ bool silent,
|
+ base::Value::Dict settings = {});
|
||||||
+ base::Value::Dict settings);
|
|
||||||
|
|
||||||
// Notification when printing is done - signal tear-down/free resources.
|
// Notification when printing is done - signal tear-down/free resources.
|
||||||
void DidFinishPrinting(PrintingResult result);
|
void DidFinishPrinting(PrintingResult result);
|
||||||
@@ -322,7 +324,8 @@ class PrintRenderFrameHelper
|
@@ -322,7 +323,8 @@ class PrintRenderFrameHelper
|
||||||
// Initialize print page settings with default settings.
|
// Initialize print page settings with default settings.
|
||||||
// Used only for native printing workflow.
|
// Used only for native printing workflow.
|
||||||
bool InitPrintSettings(blink::WebLocalFrame* frame,
|
bool InitPrintSettings(blink::WebLocalFrame* frame,
|
||||||
|
|
|
@ -2865,7 +2865,6 @@ bool WebContents::IsCurrentlyAudible() {
|
||||||
void WebContents::OnGetDeviceNameToUse(
|
void WebContents::OnGetDeviceNameToUse(
|
||||||
base::Value::Dict print_settings,
|
base::Value::Dict print_settings,
|
||||||
printing::CompletionCallback print_callback,
|
printing::CompletionCallback print_callback,
|
||||||
bool silent,
|
|
||||||
// <error, device_name>
|
// <error, device_name>
|
||||||
std::pair<std::string, std::u16string> info) {
|
std::pair<std::string, std::u16string> info) {
|
||||||
// The content::WebContents might be already deleted at this point, and the
|
// The content::WebContents might be already deleted at this point, and the
|
||||||
|
@ -2901,7 +2900,7 @@ void WebContents::OnGetDeviceNameToUse(
|
||||||
? focused_frame
|
? focused_frame
|
||||||
: web_contents()->GetPrimaryMainFrame();
|
: web_contents()->GetPrimaryMainFrame();
|
||||||
|
|
||||||
print_view_manager->PrintNow(rfh, silent, std::move(print_settings),
|
print_view_manager->PrintNow(rfh, std::move(print_settings),
|
||||||
std::move(print_callback));
|
std::move(print_callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2922,9 +2921,10 @@ void WebContents::Print(gin::Arguments* args) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set optional silent printing
|
// Set optional silent printing.
|
||||||
bool silent = false;
|
bool silent = false;
|
||||||
options.Get("silent", &silent);
|
options.Get("silent", &silent);
|
||||||
|
settings.Set("silent", silent);
|
||||||
|
|
||||||
bool print_background = false;
|
bool print_background = false;
|
||||||
options.Get("printBackground", &print_background);
|
options.Get("printBackground", &print_background);
|
||||||
|
@ -3065,7 +3065,7 @@ void WebContents::Print(gin::Arguments* args) {
|
||||||
FROM_HERE, base::BindOnce(&GetDeviceNameToUse, device_name),
|
FROM_HERE, base::BindOnce(&GetDeviceNameToUse, device_name),
|
||||||
base::BindOnce(&WebContents::OnGetDeviceNameToUse,
|
base::BindOnce(&WebContents::OnGetDeviceNameToUse,
|
||||||
weak_factory_.GetWeakPtr(), std::move(settings),
|
weak_factory_.GetWeakPtr(), std::move(settings),
|
||||||
std::move(callback), silent));
|
std::move(callback)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Partially duplicated and modified from
|
// Partially duplicated and modified from
|
||||||
|
|
|
@ -237,7 +237,6 @@ class WebContents : public ExclusiveAccessContext,
|
||||||
#if BUILDFLAG(ENABLE_PRINTING)
|
#if BUILDFLAG(ENABLE_PRINTING)
|
||||||
void OnGetDeviceNameToUse(base::Value::Dict print_settings,
|
void OnGetDeviceNameToUse(base::Value::Dict print_settings,
|
||||||
printing::CompletionCallback print_callback,
|
printing::CompletionCallback print_callback,
|
||||||
bool silent,
|
|
||||||
// <error, device_name>
|
// <error, device_name>
|
||||||
std::pair<std::string, std::u16string> info);
|
std::pair<std::string, std::u16string> info);
|
||||||
void Print(gin::Arguments* args);
|
void Print(gin::Arguments* args);
|
||||||
|
|
Loading…
Reference in a new issue