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

Side by Side Diff: chrome/renderer/printing/print_web_view_helper.cc

Issue 255543006: Printing on Windows via PDF (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tidy Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/printing/print_web_view_helper.h" 5 #include "chrome/renderer/printing/print_web_view_helper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 prep_frame_view_->GetPrintCanvasSize())) { 1361 prep_frame_view_->GetPrintCanvasSize())) {
1362 LOG(ERROR) << "Printing failed."; 1362 LOG(ERROR) << "Printing failed.";
1363 return DidFinishPrinting(FAIL_PRINT); 1363 return DidFinishPrinting(FAIL_PRINT);
1364 } 1364 }
1365 } 1365 }
1366 1366
1367 void PrintWebViewHelper::FinishFramePrinting() { 1367 void PrintWebViewHelper::FinishFramePrinting() {
1368 prep_frame_view_.reset(); 1368 prep_frame_view_.reset();
1369 } 1369 }
1370 1370
1371 #if defined(OS_MACOSX) || defined(OS_WIN) 1371 #if defined(OS_MACOSX) || !defined(PRINTING_WIN_USES_PDF_AS_METAFILE)
1372 bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame, 1372 bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
1373 int page_count, 1373 int page_count,
1374 const gfx::Size& canvas_size) { 1374 const gfx::Size& canvas_size) {
1375 const PrintMsg_PrintPages_Params& params = *print_pages_params_; 1375 const PrintMsg_PrintPages_Params& params = *print_pages_params_;
1376 const PrintMsg_Print_Params& print_params = params.params; 1376 const PrintMsg_Print_Params& print_params = params.params;
1377 1377
1378 PrintMsg_PrintPage_Params page_params; 1378 PrintMsg_PrintPage_Params page_params;
1379 page_params.params = print_params; 1379 page_params.params = print_params;
1380 if (params.pages.empty()) { 1380 if (params.pages.empty()) {
1381 for (int i = 0; i < page_count; ++i) { 1381 for (int i = 0; i < page_count; ++i) {
1382 page_params.page_number = i; 1382 page_params.page_number = i;
1383 PrintPageInternal(page_params, canvas_size, frame); 1383 PrintPageInternal(page_params, canvas_size, frame);
1384 } 1384 }
1385 } else { 1385 } else {
1386 for (size_t i = 0; i < params.pages.size(); ++i) { 1386 for (size_t i = 0; i < params.pages.size(); ++i) {
1387 if (params.pages[i] >= page_count) 1387 if (params.pages[i] >= page_count)
1388 break; 1388 break;
1389 page_params.page_number = params.pages[i]; 1389 page_params.page_number = params.pages[i];
1390 PrintPageInternal(page_params, canvas_size, frame); 1390 PrintPageInternal(page_params, canvas_size, frame);
1391 } 1391 }
1392 } 1392 }
1393 return true; 1393 return true;
1394 } 1394 }
1395 1395
1396 #endif // OS_MACOSX || OS_WIN 1396 #endif // OS_MACOSX || !PRINTING_WIN_USES_PDF_AS_METAFILE
1397 1397
1398 // static - Not anonymous so that platform implementations can use it. 1398 // static - Not anonymous so that platform implementations can use it.
1399 void PrintWebViewHelper::ComputePageLayoutInPointsForCss( 1399 void PrintWebViewHelper::ComputePageLayoutInPointsForCss(
1400 blink::WebFrame* frame, 1400 blink::WebFrame* frame,
1401 int page_index, 1401 int page_index,
1402 const PrintMsg_Print_Params& page_params, 1402 const PrintMsg_Print_Params& page_params,
1403 bool ignore_css_margins, 1403 bool ignore_css_margins,
1404 double* scale_factor, 1404 double* scale_factor,
1405 PageSizeMargins* page_layout_in_points) { 1405 PageSizeMargins* page_layout_in_points) {
1406 PrintMsg_Print_Params params = CalculatePrintParamsForCss( 1406 PrintMsg_Print_Params params = CalculatePrintParamsForCss(
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
2024 } 2024 }
2025 2025
2026 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { 2026 void PrintWebViewHelper::PrintPreviewContext::ClearContext() {
2027 prep_frame_view_.reset(); 2027 prep_frame_view_.reset();
2028 metafile_.reset(); 2028 metafile_.reset();
2029 pages_to_render_.clear(); 2029 pages_to_render_.clear();
2030 error_ = PREVIEW_ERROR_NONE; 2030 error_ = PREVIEW_ERROR_NONE;
2031 } 2031 }
2032 2032
2033 } // namespace printing 2033 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698