From d80ee5153a9b6a774bfb26f4032296fff9ba1b0f Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Tue, 31 Jul 2018 16:15:53 -0700 Subject: [PATCH] printing compiles on windows, but is explosively wrong --- .../chrome/browser/printing/pdf_to_emf_converter.cc | 12 ++++++++++-- chromium_src/chrome/browser/printing/print_job.cc | 2 ++ chromium_src/chrome/utility/printing_handler_win.cc | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc b/chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc index cd5fef18c1f..f91bc94a12f 100644 --- a/chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc +++ b/chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc @@ -26,8 +26,8 @@ #include "chrome/common/chrome_utility_printing_messages.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/child_process_data.h" -#include "content/public/browser/utility_process_host.h" -#include "content/public/browser/utility_process_host_client.h" +#include "content/browser/utility_process_host.h" +#include "content/browser/utility_process_host_client.h" #include "printing/emf_win.h" #include "printing/pdf_render_settings.h" #include "ui/base/l10n/l10n_util.h" @@ -421,6 +421,7 @@ PdfConverterUtilityProcessHostClient::~PdfConverterUtilityProcessHostClient() {} void PdfConverterUtilityProcessHostClient::Start( const scoped_refptr& data, const PdfConverter::StartCallback& start_callback) { + CHECK(false) << "Printing doesn't work yet."; if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, @@ -435,9 +436,12 @@ void PdfConverterUtilityProcessHostClient::Start( // NOTE: This process _must_ be sandboxed, otherwise the pdf dll will load // gdiplus.dll, change how rendering happens, and not be able to correctly // generate when sent to a metafile DC. + /* utility_process_host_ = content::UtilityProcessHost::Create( this, base::ThreadTaskRunnerHandle::Get()) ->AsWeakPtr(); + */ + utility_process_host_ = nullptr; utility_process_host_->SetName(GetName()); base::PostTaskAndReplyWithResult( @@ -546,7 +550,11 @@ void PdfConverterUtilityProcessHostClient::OnProcessLaunchFailed( bool PdfConverterUtilityProcessHostClient::Send(IPC::Message* msg) { if (utility_process_host_) +#if 1 + CHECK(false) << "Printing is broken."; +#else return utility_process_host_->Send(msg); +#endif delete msg; return false; } diff --git a/chromium_src/chrome/browser/printing/print_job.cc b/chromium_src/chrome/browser/printing/print_job.cc index 80d9cc3c21a..54010e6a9d5 100644 --- a/chromium_src/chrome/browser/printing/print_job.cc +++ b/chromium_src/chrome/browser/printing/print_job.cc @@ -265,6 +265,7 @@ void PrintJob::StartPdfToEmfConversion( const int kPrinterDpi = settings().dpi(); PdfRenderSettings settings( content_area, gfx::Point(0, 0), gfx::Size(kPrinterDpi, kPrinterDpi), /*autorotate=*/true, + settings_.color() == COLOR, print_text_with_gdi ? PdfRenderSettings::Mode::GDI_TEXT : PdfRenderSettings::Mode::NORMAL); pdf_conversion_state_->Start( @@ -313,6 +314,7 @@ void PrintJob::StartPdfToPostScriptConversion( const int kPrinterDpi = settings().dpi(); PdfRenderSettings settings( content_area, physical_offsets, gfx::Size(kPrinterDpi, kPrinterDpi), true /* autorotate? */, + settings_.color() == COLOR, ps_level2 ? PdfRenderSettings::Mode::POSTSCRIPT_LEVEL2 : PdfRenderSettings::Mode::POSTSCRIPT_LEVEL3); pdf_conversion_state_->Start( diff --git a/chromium_src/chrome/utility/printing_handler_win.cc b/chromium_src/chrome/utility/printing_handler_win.cc index 585259919fb..796dccc5d3a 100644 --- a/chromium_src/chrome/utility/printing_handler_win.cc +++ b/chromium_src/chrome/utility/printing_handler_win.cc @@ -161,6 +161,7 @@ bool PrintingHandlerWin::RenderPdfPageToMetafile(int page_number, pdf_rendering_settings_.area.y() - offset_y, pdf_rendering_settings_.area.width(), pdf_rendering_settings_.area.height(), true, false, true, true, + pdf_rendering_settings_.use_color, pdf_rendering_settings_.autorotate)) { return false; }