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

Unified Diff: components/printing/renderer/print_web_view_helper_mac.mm

Issue 2829973002: add customized printing setting for headless (Closed)
Patch Set: add skia as public_deps instead Created 3 years, 7 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: components/printing/renderer/print_web_view_helper_mac.mm
diff --git a/components/printing/renderer/print_web_view_helper_mac.mm b/components/printing/renderer/print_web_view_helper_mac.mm
index 4c1c5b9a73ec45da4bf946e042c1d78429261610..a00cfa0a95f16e18757bd32b899d7a2eda700993 100644
--- a/components/printing/renderer/print_web_view_helper_mac.mm
+++ b/components/printing/renderer/print_web_view_helper_mac.mm
@@ -29,12 +29,13 @@ bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
return false;
if (delegate_->UseSingleMetafile()) {
- PrintPagesInternal(print_params, printed_pages, frame);
+ PrintPagesInternal(print_params, printed_pages, page_count, frame);
return true;
}
for (int page_number : printed_pages)
- PrintPagesInternal(print_params, std::vector<int>{page_number}, frame);
+ PrintPagesInternal(print_params, std::vector<int>{page_number}, page_count,
+ frame);
return true;
}
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
@@ -42,6 +43,7 @@ bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
void PrintWebViewHelper::PrintPagesInternal(
const PrintMsg_Print_Params& params,
const std::vector<int>& printed_pages,
+ int page_count,
blink::WebLocalFrame* frame) {
PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE);
CHECK(metafile.Init());
@@ -49,8 +51,8 @@ void PrintWebViewHelper::PrintPagesInternal(
gfx::Size page_size_in_dpi;
gfx::Rect content_area_in_dpi;
for (int page_number : printed_pages) {
- RenderPage(params, page_number, frame, false, &metafile, &page_size_in_dpi,
- &content_area_in_dpi);
+ RenderPage(params, page_number, page_count, frame, false, &metafile,
+ &page_size_in_dpi, &content_area_in_dpi);
}
metafile.FinishDocument();
@@ -93,8 +95,10 @@ bool PrintWebViewHelper::RenderPreviewPage(
base::TimeTicks begin_time = base::TimeTicks::Now();
gfx::Size page_size;
- RenderPage(printParams, page_number, print_preview_context_.prepared_frame(),
- true, initial_render_metafile, &page_size, NULL);
+ RenderPage(printParams, page_number,
+ print_preview_context_.total_page_count(),
+ print_preview_context_.prepared_frame(), true,
+ initial_render_metafile, &page_size, NULL);
print_preview_context_.RenderedPreviewPage(
base::TimeTicks::Now() - begin_time);
@@ -115,6 +119,7 @@ bool PrintWebViewHelper::RenderPreviewPage(
void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params,
int page_number,
+ int page_count,
blink::WebLocalFrame* frame,
bool is_preview,
PdfMetafileSkia* metafile,
@@ -147,14 +152,11 @@ void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params,
MetafileSkiaWrapper::SetMetafileOnCanvas(canvas, metafile);
cc::SetIsPreviewMetafile(canvas, is_preview);
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (params.display_header_footer) {
PrintHeaderAndFooter(static_cast<blink::WebCanvas*>(canvas),
- page_number + 1,
- print_preview_context_.total_page_count(), *frame,
- scale_factor, page_layout_in_points, params);
+ page_number + 1, page_count, *frame, scale_factor,
+ page_layout_in_points, params);
}
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
RenderPageContent(frame, page_number, canvas_area, content_area,
scale_factor, static_cast<blink::WebCanvas*>(canvas));
}

Powered by Google App Engine
This is Rietveld 408576698