Skip to content

Commit

Permalink
[unseasoned-pdf] Remove PDFEngine::QuerySupportedPrintOutputFormats()
Browse files Browse the repository at this point in the history
Its implementation is only appropriate for a Pepper plugin, and the
bitmask it returns is not very compatible to Blink's printing API. The
implementation also contains Pepper enums, so bubble it up to
OutOfProcessInstance and remove it from PDFEngine's interface.

Of the four print output formats exposed through PPAPI, only
PP_PRINTOUTPUTFORMAT_PDF and PP_PRINTOUTPUTFORMAT_RASTER are supported
by the PDF plugin.

Bug: 1200000
Change-Id: I7c3db1eea92453c71167c7389512efa4c9ab8f2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2947894
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#890903}
  • Loading branch information
Daniel Hosseinian authored and Chromium LUCI CQ committed Jun 9, 2021
1 parent 6d09480 commit 1fb29ed
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
8 changes: 6 additions & 2 deletions pdf/out_of_process_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ int32_t OutOfProcessInstance::PdfPrintBegin(
if (!ret)
return 0;

uint32_t supported_formats = engine()->QuerySupportedPrintOutputFormats();
uint32_t supported_formats = QuerySupportedPrintOutputFormats();
if ((print_settings->format & supported_formats) == 0)
return 0;

Expand All @@ -742,7 +742,11 @@ int32_t OutOfProcessInstance::PdfPrintBegin(
}

uint32_t OutOfProcessInstance::QuerySupportedPrintOutputFormats() {
return engine()->QuerySupportedPrintOutputFormats();
if (engine()->HasPermission(PDFEngine::PERMISSION_PRINT_HIGH_QUALITY))
return PP_PRINTOUTPUTFORMAT_PDF | PP_PRINTOUTPUTFORMAT_RASTER;
if (engine()->HasPermission(PDFEngine::PERMISSION_PRINT_LOW_QUALITY))
return PP_PRINTOUTPUTFORMAT_RASTER;
return 0;
}

int32_t OutOfProcessInstance::PrintBegin(
Expand Down
1 change: 0 additions & 1 deletion pdf/pdf_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ class PDFEngine {
virtual void PostPaint() = 0;
virtual bool HandleDocumentLoad(std::unique_ptr<UrlLoader> loader) = 0;
virtual bool HandleInputEvent(const blink::WebInputEvent& event) = 0;
virtual uint32_t QuerySupportedPrintOutputFormats() = 0;
virtual void PrintBegin() = 0;
virtual pp::Resource PrintPages(
const PP_PrintPageNumberRange_Dev* page_ranges,
Expand Down
8 changes: 0 additions & 8 deletions pdf/pdfium/pdfium_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -965,14 +965,6 @@ bool PDFiumEngine::HandleInputEvent(const blink::WebInputEvent& event) {
return rv;
}

uint32_t PDFiumEngine::QuerySupportedPrintOutputFormats() {
if (HasPermission(PERMISSION_PRINT_HIGH_QUALITY))
return PP_PRINTOUTPUTFORMAT_PDF | PP_PRINTOUTPUTFORMAT_RASTER;
if (HasPermission(PERMISSION_PRINT_LOW_QUALITY))
return PP_PRINTOUTPUTFORMAT_RASTER;
return 0;
}

void PDFiumEngine::PrintBegin() {
FORM_DoDocumentAAction(form(), FPDFDOC_AACTION_WP);
}
Expand Down
1 change: 0 additions & 1 deletion pdf/pdfium/pdfium_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class PDFiumEngine : public PDFEngine,
void PostPaint() override;
bool HandleDocumentLoad(std::unique_ptr<UrlLoader> loader) override;
bool HandleInputEvent(const blink::WebInputEvent& event) override;
uint32_t QuerySupportedPrintOutputFormats() override;
void PrintBegin() override;
pp::Resource PrintPages(
const PP_PrintPageNumberRange_Dev* page_ranges,
Expand Down

0 comments on commit 1fb29ed

Please sign in to comment.