Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1815)

Unified Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 2524143003: Print Preview: Add option to rasterize PDFs and add JPEG compression. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/pepper/pepper_plugin_instance_impl.cc
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc
index c80fe6bd5639e7f1ad68d5478054d3717d3e748e..e56975d2ac41ee8b397f24a6e851f460515bbf3e 100644
--- a/content/renderer/pepper/pepper_plugin_instance_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc
@@ -1747,23 +1747,30 @@ void PepperPluginInstanceImpl::ReportGeometry() {
}
bool PepperPluginInstanceImpl::GetPreferredPrintOutputFormat(
- PP_PrintOutputFormat_Dev* format) {
+ PP_PrintOutputFormat_Dev* format, const WebPrintParams& print_params) {
// Keep a reference on the stack. See NOTE above.
scoped_refptr<PepperPluginInstanceImpl> ref(this);
if (!LoadPrintInterface())
return false;
uint32_t supported_formats =
plugin_print_interface_->QuerySupportedFormats(pp_instance());
- if (supported_formats & PP_PRINTOUTPUTFORMAT_PDF) {
+ if ((supported_formats & PP_PRINTOUTPUTFORMAT_PDF) &&
+ !print_params.rasterizePDF) {
*format = PP_PRINTOUTPUTFORMAT_PDF;
return true;
}
+ if (supported_formats & PP_PRINTOUTPUTFORMAT_RASTER) {
+ *format = PP_PRINTOUTPUTFORMAT_RASTER;
+ return true;
+ }
return false;
}
bool PepperPluginInstanceImpl::SupportsPrintInterface() {
PP_PrintOutputFormat_Dev format;
- return GetPreferredPrintOutputFormat(&format);
+ WebPrintParams params;
+ params.rasterizePDF = false;
+ return GetPreferredPrintOutputFormat(&format, params);
}
bool PepperPluginInstanceImpl::IsPrintScalingDisabled() {
@@ -1777,7 +1784,7 @@ int PepperPluginInstanceImpl::PrintBegin(const WebPrintParams& print_params) {
// Keep a reference on the stack. See NOTE above.
scoped_refptr<PepperPluginInstanceImpl> ref(this);
PP_PrintOutputFormat_Dev format;
- if (!GetPreferredPrintOutputFormat(&format)) {
+ if (!GetPreferredPrintOutputFormat(&format, print_params)) {
// PrintBegin should not have been called since SupportsPrintInterface
// would have returned false;
NOTREACHED();
@@ -1839,7 +1846,8 @@ void PepperPluginInstanceImpl::PrintPageHelper(
if (!print_output)
return;
- if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF)
+ if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF ||
+ current_print_settings_.format == PP_PRINTOUTPUTFORMAT_RASTER)
PrintPDFOutput(print_output, metafile);
// Now we need to release the print output resource.

Powered by Google App Engine
This is Rietveld 408576698