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

Unified Diff: chrome/renderer/print_web_view_helper.cc

Issue 10083060: [Print Preview]: Added code to support pdf fit to page functionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years, 8 months 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: 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 b31cd851cfe5213c2219515b3dde4681cd01e5f7..7781fbcd11ec3abdaaebd7910dd28326a255e8bb 100644
--- a/chrome/renderer/print_web_view_helper.cc
+++ b/chrome/renderer/print_web_view_helper.cc
@@ -867,6 +867,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;
@@ -1310,23 +1320,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
Lei Zhang 2012/04/26 00:19:51 Is this change related to this CL?
kmadhusu 2012/04/26 22:18:51 Yes.
- // 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;
@@ -1381,9 +1375,24 @@ bool PrintWebViewHelper::UpdatePrintSettings(
settings.params.print_to_pdf = IsPrintToPdfRequested(*job_settings);
UpdateFrameMarginsCssInfo(*job_settings);
- // Fit to paper size.
- settings.params.fit_to_paper_size = source_is_html &&
- !IsPrintToPdfRequested(*job_settings);
+ // Fit to page
+ // TODO(kmadhusu): Update this code.
Lei Zhang 2012/04/26 00:19:51 I would move this into its own method with a clear
kmadhusu 2012/04/26 22:18:51 Done.
+ settings.params.fit_to_paper_size = true;
+ if (print_for_preview_ || settings.params.print_to_pdf) {
+ settings.params.fit_to_paper_size = false;
+ } else if (!source_is_html) {
+ bool fit_to_paper_size = false;
+ if (!job_settings->GetBoolean(printing::kSettingFitToPageEnabled,
+ &(fit_to_paper_size))) {
+ NOTREACHED();
+ }
+ if ((settings.params.is_first_request &&
+ frame->isPrintScalingDisabledForPlugin(
+ print_preview_context_.node())) ||
+ !fit_to_paper_size) {
+ settings.params.fit_to_paper_size = false;
+ }
+ }
// Header/Footer: Set |header_footer_info_|.
if (settings.params.display_header_footer) {

Powered by Google App Engine
This is Rietveld 408576698