Index: chrome/renderer/print_web_view_helper.cc |
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc |
index ae6fc69fdcbb0688d31e2932dcd353db78d26d32..9fb030a1ddc8a0ddafa6751af3849457a86329df 100644 |
--- a/chrome/renderer/print_web_view_helper.cc |
+++ b/chrome/renderer/print_web_view_helper.cc |
@@ -860,6 +860,16 @@ void PrintWebViewHelper::OnPrintPreview(const DictionaryValue& settings) { |
preview_params)); |
return; |
} |
+ |
+ // If we are previewing a pdf and the print scaling is disabled, send a |
+ // message to browser. |
+ if (!print_preview_context_.IsModifiable() && |
+ print_pages_params_->params.is_first_request && |
+ print_preview_context_.frame()->isPrintScalingDisabledForPlugin( |
+ print_preview_context_.node())) { |
+ Send(new PrintHostMsg_PrintPreviewScalingDisabled(routing_id())); |
+ } |
+ |
// Always clear |old_print_pages_params_| before rendering the pages. |
old_print_pages_params_.reset(); |
is_print_ready_metafile_sent_ = false; |
@@ -1309,23 +1319,7 @@ bool PrintWebViewHelper::UpdatePrintSettings( |
modified_job_settings.SetBoolean(printing::kSettingHeaderFooterEnabled, |
false); |
- // - On Windows, we don't add a margin until we turn it into an EMF when |
- // printing for print preview (We could add it in the plugin). |
- // - On Mac with Skia, we don't add a margin until we send it to the printer |
- // using the CG PDF class (We could add it in the plugin). |
- // - On Mac with CG, we can add a margin when generating the preview. |
- // - On Linux, we never add a margin (We Could add it in the plugin). |
-#if defined(OS_MACOSX) && !defined(USE_SKIA) |
- bool get_margins_from_pdf = !source_is_html && !print_for_preview_; |
-#elif defined(OS_WIN) || defined(OS_MACOSX) |
- bool get_margins_from_pdf = !source_is_html && print_for_preview_; |
-#else |
- bool get_margins_from_pdf = false; |
-#endif |
- |
printing::MarginType margin_type = printing::NO_MARGINS; |
- if (get_margins_from_pdf) |
- margin_type = GetMarginsForPdf(frame, node); |
modified_job_settings.SetInteger(printing::kSettingMarginsType, |
margin_type); |
job_settings = &modified_job_settings; |
@@ -1379,7 +1373,30 @@ bool PrintWebViewHelper::UpdatePrintSettings( |
settings.params.print_to_pdf = IsPrintToPdfRequested(*job_settings); |
UpdateFrameMarginsCssInfo(*job_settings); |
- fit_to_page_ = source_is_html && !IsPrintToPdfRequested(*job_settings); |
+ |
+ // Source is PDF (Fit to page) |
+ bool print_to_pdf_requested = IsPrintToPdfRequested(*job_settings); |
+ bool fit_pdf_page_to_paper_size = false; |
+ bool reset_fit_to_page_option = true; |
+ if (!print_for_preview_ && !source_is_html && !print_to_pdf_requested) { |
+ if (settings.params.is_first_request) { |
+ // If print scaling is disabled, do not fit to paper size. |
+ fit_pdf_page_to_paper_size = !print_preview_context_.frame()-> |
+ isPrintScalingDisabledForPlugin(print_preview_context_.node()); |
+ } else { |
+ reset_fit_to_page_option = false; |
+ } |
+ } |
+ |
+ if (reset_fit_to_page_option) { |
+ settings.params.fit_pdf_page_to_paper_size = fit_pdf_page_to_paper_size; |
+ } else if (!job_settings->GetBoolean(printing::kSettingFitToPageEnabled, |
+ &(settings.params.fit_pdf_page_to_paper_size))) { |
+ NOTREACHED(); |
+ } |
+ |
+ // Source is HTML (Fit to Page) |
+ fit_to_page_ = source_is_html && !print_to_pdf_requested; |
// Header/Footer: Set |header_footer_info_|. |
if (settings.params.display_header_footer) { |