OLD | NEW |
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 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 prep_frame_view_->GetPrintCanvasSize())) { | 1344 prep_frame_view_->GetPrintCanvasSize())) { |
1345 LOG(ERROR) << "Printing failed."; | 1345 LOG(ERROR) << "Printing failed."; |
1346 return DidFinishPrinting(FAIL_PRINT); | 1346 return DidFinishPrinting(FAIL_PRINT); |
1347 } | 1347 } |
1348 } | 1348 } |
1349 | 1349 |
1350 void PrintWebViewHelper::FinishFramePrinting() { | 1350 void PrintWebViewHelper::FinishFramePrinting() { |
1351 prep_frame_view_.reset(); | 1351 prep_frame_view_.reset(); |
1352 } | 1352 } |
1353 | 1353 |
1354 #if defined(OS_MACOSX) || defined(OS_WIN) | 1354 #if defined(OS_MACOSX) || !defined(PRINTING_WIN_USES_PDF_AS_METAFILE) |
1355 bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame, | 1355 bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame, |
1356 int page_count, | 1356 int page_count, |
1357 const gfx::Size& canvas_size) { | 1357 const gfx::Size& canvas_size) { |
1358 const PrintMsg_PrintPages_Params& params = *print_pages_params_; | 1358 const PrintMsg_PrintPages_Params& params = *print_pages_params_; |
1359 const PrintMsg_Print_Params& print_params = params.params; | 1359 const PrintMsg_Print_Params& print_params = params.params; |
1360 | 1360 |
1361 PrintMsg_PrintPage_Params page_params; | 1361 PrintMsg_PrintPage_Params page_params; |
1362 page_params.params = print_params; | 1362 page_params.params = print_params; |
1363 if (params.pages.empty()) { | 1363 if (params.pages.empty()) { |
1364 for (int i = 0; i < page_count; ++i) { | 1364 for (int i = 0; i < page_count; ++i) { |
1365 page_params.page_number = i; | 1365 page_params.page_number = i; |
1366 PrintPageInternal(page_params, canvas_size, frame); | 1366 PrintPageInternal(page_params, canvas_size, frame); |
1367 } | 1367 } |
1368 } else { | 1368 } else { |
1369 for (size_t i = 0; i < params.pages.size(); ++i) { | 1369 for (size_t i = 0; i < params.pages.size(); ++i) { |
1370 if (params.pages[i] >= page_count) | 1370 if (params.pages[i] >= page_count) |
1371 break; | 1371 break; |
1372 page_params.page_number = params.pages[i]; | 1372 page_params.page_number = params.pages[i]; |
1373 PrintPageInternal(page_params, canvas_size, frame); | 1373 PrintPageInternal(page_params, canvas_size, frame); |
1374 } | 1374 } |
1375 } | 1375 } |
1376 return true; | 1376 return true; |
1377 } | 1377 } |
1378 | 1378 |
1379 #endif // OS_MACOSX || OS_WIN | 1379 #endif // OS_MACOSX || !PRINTING_WIN_USES_PDF_AS_METAFILE |
1380 | 1380 |
1381 // static - Not anonymous so that platform implementations can use it. | 1381 // static - Not anonymous so that platform implementations can use it. |
1382 void PrintWebViewHelper::ComputePageLayoutInPointsForCss( | 1382 void PrintWebViewHelper::ComputePageLayoutInPointsForCss( |
1383 blink::WebFrame* frame, | 1383 blink::WebFrame* frame, |
1384 int page_index, | 1384 int page_index, |
1385 const PrintMsg_Print_Params& page_params, | 1385 const PrintMsg_Print_Params& page_params, |
1386 bool ignore_css_margins, | 1386 bool ignore_css_margins, |
1387 double* scale_factor, | 1387 double* scale_factor, |
1388 PageSizeMargins* page_layout_in_points) { | 1388 PageSizeMargins* page_layout_in_points) { |
1389 PrintMsg_Print_Params params = CalculatePrintParamsForCss( | 1389 PrintMsg_Print_Params params = CalculatePrintParamsForCss( |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2007 } | 2007 } |
2008 | 2008 |
2009 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 2009 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
2010 prep_frame_view_.reset(); | 2010 prep_frame_view_.reset(); |
2011 metafile_.reset(); | 2011 metafile_.reset(); |
2012 pages_to_render_.clear(); | 2012 pages_to_render_.clear(); |
2013 error_ = PREVIEW_ERROR_NONE; | 2013 error_ = PREVIEW_ERROR_NONE; |
2014 } | 2014 } |
2015 | 2015 |
2016 } // namespace printing | 2016 } // namespace printing |
OLD | NEW |