|
@@ -126,7 +126,7 @@ index 2824b97e715a493082734d40f62860c8cafa5f34..584d4ef2b73a0f89458224eb134a8d8a
|
|
|
}
|
|
|
|
|
|
diff --git a/chrome/browser/printing/print_view_manager_base.cc b/chrome/browser/printing/print_view_manager_base.cc
|
|
|
-index 867227684ddba1b1032d7aa4935cbfdca8518309..fbcb81b7dedcf5d9bad949dbf721c0a34a7c8f2b 100644
|
|
|
+index e345c611cac05d7e802b1f910031e8d799196e31..562800bf194e1f07f58b912b54a740b7c7dcabb6 100644
|
|
|
--- a/chrome/browser/printing/print_view_manager_base.cc
|
|
|
+++ b/chrome/browser/printing/print_view_manager_base.cc
|
|
|
@@ -28,10 +28,10 @@
|
|
@@ -202,10 +202,10 @@ index 867227684ddba1b1032d7aa4935cbfdca8518309..fbcb81b7dedcf5d9bad949dbf721c0a3
|
|
|
+ bool silent,
|
|
|
+ base::Value settings,
|
|
|
+ CompletionCallback callback) {
|
|
|
+ auto weak_this = weak_ptr_factory_.GetWeakPtr();
|
|
|
DisconnectFromCurrentPrintJob();
|
|
|
-
|
|
|
- // Don't print / print preview crashed tabs.
|
|
|
-@@ -364,7 +375,14 @@ bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh) {
|
|
|
+ if (!weak_this)
|
|
|
+@@ -367,7 +378,14 @@ bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh) {
|
|
|
// go in `ReleasePrintJob()`.
|
|
|
|
|
|
SetPrintingRFH(rfh);
|
|
@@ -221,7 +221,7 @@ index 867227684ddba1b1032d7aa4935cbfdca8518309..fbcb81b7dedcf5d9bad949dbf721c0a3
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-@@ -519,9 +537,9 @@ void PrintViewManagerBase::ScriptedPrintReply(
|
|
|
+@@ -522,9 +540,9 @@ void PrintViewManagerBase::ScriptedPrintReply(
|
|
|
void PrintViewManagerBase::UpdatePrintingEnabled() {
|
|
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
// The Unretained() is safe because ForEachFrame() is synchronous.
|
|
@@ -234,7 +234,7 @@ index 867227684ddba1b1032d7aa4935cbfdca8518309..fbcb81b7dedcf5d9bad949dbf721c0a3
|
|
|
}
|
|
|
|
|
|
void PrintViewManagerBase::NavigationStopped() {
|
|
|
-@@ -635,12 +653,13 @@ void PrintViewManagerBase::DidPrintDocument(
|
|
|
+@@ -638,12 +656,13 @@ void PrintViewManagerBase::DidPrintDocument(
|
|
|
void PrintViewManagerBase::GetDefaultPrintSettings(
|
|
|
GetDefaultPrintSettingsCallback callback) {
|
|
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
@@ -249,7 +249,7 @@ index 867227684ddba1b1032d7aa4935cbfdca8518309..fbcb81b7dedcf5d9bad949dbf721c0a3
|
|
|
content::RenderFrameHost* render_frame_host = GetCurrentTargetFrame();
|
|
|
auto callback_wrapper =
|
|
|
base::BindOnce(&PrintViewManagerBase::GetDefaultPrintSettingsReply,
|
|
|
-@@ -658,12 +677,13 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
|
+@@ -661,12 +680,13 @@ void PrintViewManagerBase::UpdatePrintSettings(
|
|
|
base::Value job_settings,
|
|
|
UpdatePrintSettingsCallback callback) {
|
|
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
@@ -264,7 +264,7 @@ index 867227684ddba1b1032d7aa4935cbfdca8518309..fbcb81b7dedcf5d9bad949dbf721c0a3
|
|
|
if (!job_settings.FindIntKey(kSettingPrinterType)) {
|
|
|
UpdatePrintSettingsReply(std::move(callback),
|
|
|
CreateEmptyPrintPagesParamsPtr(), false);
|
|
|
-@@ -708,13 +728,18 @@ void PrintViewManagerBase::PrintingFailed(int32_t cookie) {
|
|
|
+@@ -711,13 +731,18 @@ void PrintViewManagerBase::PrintingFailed(int32_t cookie) {
|
|
|
PrintManager::PrintingFailed(cookie);
|
|
|
|
|
|
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
@@ -284,7 +284,7 @@ index 867227684ddba1b1032d7aa4935cbfdca8518309..fbcb81b7dedcf5d9bad949dbf721c0a3
|
|
|
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
|
|
FROM_HERE, base::BindOnce(&ShowWarningMessageBox,
|
|
|
l10n_util::GetStringUTF16(
|
|
|
-@@ -794,6 +819,11 @@ void PrintViewManagerBase::OnNotifyPrintJobEvent(
|
|
|
+@@ -797,6 +822,11 @@ void PrintViewManagerBase::OnNotifyPrintJobEvent(
|
|
|
#endif
|
|
|
break;
|
|
|
}
|
|
@@ -296,20 +296,21 @@ index 867227684ddba1b1032d7aa4935cbfdca8518309..fbcb81b7dedcf5d9bad949dbf721c0a3
|
|
|
case JobEventDetails::JOB_DONE:
|
|
|
// Printing is done, we don't need it anymore.
|
|
|
// print_job_->is_job_pending() may still be true, depending on the order
|
|
|
-@@ -859,8 +889,10 @@ bool PrintViewManagerBase::CreateNewPrintJob(
|
|
|
+@@ -864,9 +894,11 @@ bool PrintViewManagerBase::CreateNewPrintJob(
|
|
|
DCHECK(!quit_inner_loop_);
|
|
|
DCHECK(query);
|
|
|
|
|
|
- // Disconnect the current |print_job_|.
|
|
|
+ auto weak_this = weak_ptr_factory_.GetWeakPtr();
|
|
|
- DisconnectFromCurrentPrintJob();
|
|
|
+ if (callback_.is_null()) {
|
|
|
+ // Disconnect the current |print_job_| only when calling window.print()
|
|
|
+ DisconnectFromCurrentPrintJob();
|
|
|
+ }
|
|
|
+ if (!weak_this)
|
|
|
+ return false;
|
|
|
|
|
|
- // We can't print if there is no renderer.
|
|
|
- if (!web_contents()->GetMainFrame()->GetRenderViewHost() ||
|
|
|
-@@ -881,8 +913,6 @@ bool PrintViewManagerBase::CreateNewPrintJob(
|
|
|
+@@ -889,8 +921,6 @@ bool PrintViewManagerBase::CreateNewPrintJob(
|
|
|
/*source_id=*/"");
|
|
|
#endif
|
|
|
|
|
@@ -318,7 +319,7 @@ index 867227684ddba1b1032d7aa4935cbfdca8518309..fbcb81b7dedcf5d9bad949dbf721c0a3
|
|
|
printing_succeeded_ = false;
|
|
|
return true;
|
|
|
}
|
|
|
-@@ -931,14 +961,22 @@ void PrintViewManagerBase::ReleasePrintJob() {
|
|
|
+@@ -942,14 +972,22 @@ void PrintViewManagerBase::ReleasePrintJob() {
|
|
|
content::RenderFrameHost* rfh = printing_rfh_;
|
|
|
printing_rfh_ = nullptr;
|
|
|
|
|
@@ -343,7 +344,7 @@ index 867227684ddba1b1032d7aa4935cbfdca8518309..fbcb81b7dedcf5d9bad949dbf721c0a3
|
|
|
// Don't close the worker thread.
|
|
|
print_job_ = nullptr;
|
|
|
}
|
|
|
-@@ -974,7 +1012,7 @@ bool PrintViewManagerBase::RunInnerMessageLoop() {
|
|
|
+@@ -988,7 +1026,7 @@ bool PrintViewManagerBase::RunInnerMessageLoop() {
|
|
|
}
|
|
|
|
|
|
bool PrintViewManagerBase::OpportunisticallyCreatePrintJob(int cookie) {
|
|
@@ -353,7 +354,7 @@ index 867227684ddba1b1032d7aa4935cbfdca8518309..fbcb81b7dedcf5d9bad949dbf721c0a3
|
|
|
|
|
|
if (!cookie) {
|
|
|
diff --git a/chrome/browser/printing/print_view_manager_base.h b/chrome/browser/printing/print_view_manager_base.h
|
|
|
-index 48e2baa05cdf61ac18d9d5a357833abd07b373b0..21ed887db41c979470f2a72b7a1c1832ad0e7961 100644
|
|
|
+index eaa0e162a339ba68d42c920fdd30869d259b4f27..8381f5171970aa89fc5c406d57d2665e16c6678b 100644
|
|
|
--- a/chrome/browser/printing/print_view_manager_base.h
|
|
|
+++ b/chrome/browser/printing/print_view_manager_base.h
|
|
|
@@ -38,6 +38,8 @@ class PrintJob;
|
|
@@ -377,7 +378,7 @@ index 48e2baa05cdf61ac18d9d5a357833abd07b373b0..21ed887db41c979470f2a72b7a1c1832
|
|
|
|
|
|
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
// Prints the document in |print_data| with settings specified in
|
|
|
-@@ -230,9 +235,15 @@ class PrintViewManagerBase : public content::NotificationObserver,
|
|
|
+@@ -234,9 +239,15 @@ class PrintViewManagerBase : public content::NotificationObserver,
|
|
|
// The current RFH that is printing with a system printing dialog.
|
|
|
content::RenderFrameHost* printing_rfh_ = nullptr;
|
|
|
|