Fix crashes with PrintToPDF (fixes issue #3373)

- Configure the DPI setting (see https://crrev.com/40e28bcba3)
- Call StopWorker on the UI thread (see https://crrev.com/564fa1d8a4)
This commit is contained in:
Marshall Greenblatt 2022-08-18 12:26:30 -04:00
parent 46ae630452
commit df482f6b12
1 changed files with 4 additions and 5 deletions

View File

@ -37,6 +37,7 @@
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "mojo/public/cpp/bindings/associated_remote.h" #include "mojo/public/cpp/bindings/associated_remote.h"
#include "printing/metafile_skia.h" #include "printing/metafile_skia.h"
#include "printing/units.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#if BUILDFLAG(IS_LINUX) #if BUILDFLAG(IS_LINUX)
@ -67,8 +68,8 @@ void FillInDictionaryFromPdfPrintSettings(
print_settings.Set(kSettingDeviceName, ""); print_settings.Set(kSettingDeviceName, "");
print_settings.Set(kSettingRasterizePdf, false); print_settings.Set(kSettingRasterizePdf, false);
print_settings.Set(kSettingPreviewModifiable, false); print_settings.Set(kSettingPreviewModifiable, false);
print_settings.Set(kSettingDpiHorizontal, 0); print_settings.Set(kSettingDpiHorizontal, printing::kDefaultPdfDpi);
print_settings.Set(kSettingDpiVertical, 0); print_settings.Set(kSettingDpiVertical, printing::kDefaultPdfDpi);
print_settings.Set(kSettingPagesPerSheet, 1); print_settings.Set(kSettingPagesPerSheet, 1);
// User defined settings. // User defined settings.
@ -137,9 +138,7 @@ void StopWorker(int document_cookie) {
std::unique_ptr<PrinterQuery> printer_query = std::unique_ptr<PrinterQuery> printer_query =
queue->PopPrinterQuery(document_cookie); queue->PopPrinterQuery(document_cookie);
if (printer_query.get()) { if (printer_query.get()) {
content::GetIOThreadTaskRunner({})->PostTask( printer_query->StopWorker();
FROM_HERE,
base::BindOnce(&PrinterQuery::StopWorker, std::move(printer_query)));
} }
} }