| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/printing/renderer/print_web_view_helper.h" | 5 #include "components/printing/renderer/print_web_view_helper.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 if (printed_pages.empty()) | 22 if (printed_pages.empty()) |
| 23 return false; | 23 return false; |
| 24 | 24 |
| 25 std::vector<gfx::Size> page_size_in_dpi(printed_pages.size()); | 25 std::vector<gfx::Size> page_size_in_dpi(printed_pages.size()); |
| 26 std::vector<gfx::Rect> content_area_in_dpi(printed_pages.size()); | 26 std::vector<gfx::Rect> content_area_in_dpi(printed_pages.size()); |
| 27 std::vector<gfx::Rect> printable_area_in_dpi(printed_pages.size()); | 27 std::vector<gfx::Rect> printable_area_in_dpi(printed_pages.size()); |
| 28 | 28 |
| 29 PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE); | 29 PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE); |
| 30 CHECK(metafile.Init()); | 30 CHECK(metafile.Init()); |
| 31 | 31 |
| 32 PrintMsg_PrintPage_Params page_params; | |
| 33 page_params.params = params.params; | |
| 34 for (size_t i = 0; i < printed_pages.size(); ++i) { | 32 for (size_t i = 0; i < printed_pages.size(); ++i) { |
| 35 page_params.page_number = printed_pages[i]; | 33 PrintPageInternal(params.params, printed_pages[i], frame, &metafile, |
| 36 PrintPageInternal(page_params, frame, &metafile, &page_size_in_dpi[i], | 34 &page_size_in_dpi[i], &content_area_in_dpi[i], |
| 37 &content_area_in_dpi[i], &printable_area_in_dpi[i]); | 35 &printable_area_in_dpi[i]); |
| 38 } | 36 } |
| 39 | 37 |
| 40 // blink::printEnd() for PDF should be called before metafile is closed. | 38 // blink::printEnd() for PDF should be called before metafile is closed. |
| 41 FinishFramePrinting(); | 39 FinishFramePrinting(); |
| 42 | 40 |
| 43 metafile.FinishDocument(); | 41 metafile.FinishDocument(); |
| 44 | 42 |
| 45 PrintHostMsg_DidPrintPage_Params printed_page_params; | 43 PrintHostMsg_DidPrintPage_Params printed_page_params; |
| 46 if (!CopyMetafileDataToSharedMem( | 44 if (!CopyMetafileDataToSharedMem( |
| 47 metafile, &printed_page_params.metafile_data_handle)) { | 45 metafile, &printed_page_params.metafile_data_handle)) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 63 // Send the rest of the pages with an invalid metafile handle. | 61 // Send the rest of the pages with an invalid metafile handle. |
| 64 // TODO(erikchen): Fix semantics. See https://crbug.com/640840 | 62 // TODO(erikchen): Fix semantics. See https://crbug.com/640840 |
| 65 if (printed_page_params.metafile_data_handle.IsValid()) | 63 if (printed_page_params.metafile_data_handle.IsValid()) |
| 66 printed_page_params.metafile_data_handle = base::SharedMemoryHandle(); | 64 printed_page_params.metafile_data_handle = base::SharedMemoryHandle(); |
| 67 } | 65 } |
| 68 return true; | 66 return true; |
| 69 } | 67 } |
| 70 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) | 68 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 71 | 69 |
| 72 } // namespace printing | 70 } // namespace printing |
| OLD | NEW |