OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/print_web_view_helper.h" | 5 #include "chrome/renderer/print_web_view_helper.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 page_params.data_size = metafile.GetDataSize(); | 65 page_params.data_size = metafile.GetDataSize(); |
66 Send(new ViewHostMsg_DidPrintPage(routing_id(), page_params)); | 66 Send(new ViewHostMsg_DidPrintPage(routing_id(), page_params)); |
67 } | 67 } |
68 | 68 |
69 void PrintWebViewHelper::CreatePreviewDocument( | 69 void PrintWebViewHelper::CreatePreviewDocument( |
70 const ViewMsg_PrintPages_Params& params, | 70 const ViewMsg_PrintPages_Params& params, |
71 WebFrame* frame, | 71 WebFrame* frame, |
72 ViewHostMsg_DidPreviewDocument_Params* print_params) { | 72 ViewHostMsg_DidPreviewDocument_Params* print_params) { |
73 ViewMsg_Print_Params printParams = params.params; | 73 ViewMsg_Print_Params printParams = params.params; |
74 UpdatePrintableSizeInPrintParameters(frame, &printParams); | 74 UpdatePrintableSizeInPrintParameters(frame, NULL, &printParams); |
75 | 75 |
76 PrepareFrameAndViewForPrint prep_frame_view(printParams, | 76 PrepareFrameAndViewForPrint prep_frame_view(printParams, |
77 frame, frame->view()); | 77 frame, NULL, frame->view()); |
78 int page_count = prep_frame_view.GetExpectedPageCount(); | 78 int page_count = prep_frame_view.GetExpectedPageCount(); |
79 | 79 |
80 if (!page_count) | 80 if (!page_count) |
81 return; | 81 return; |
82 | 82 |
83 float scale_factor = frame->getPrintPageShrink(0); | 83 float scale_factor = frame->getPrintPageShrink(0); |
84 double originX = printParams.margin_left; | 84 double originX = printParams.margin_left; |
85 double originY = printParams.margin_top; | 85 double originY = printParams.margin_top; |
86 | 86 |
87 printing::NativeMetafile metafile; | 87 printing::NativeMetafile metafile; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // printPage can create autoreleased references to |context|. PDF contexts | 125 // printPage can create autoreleased references to |context|. PDF contexts |
126 // don't write all their data until they are destroyed, so we need to make | 126 // don't write all their data until they are destroyed, so we need to make |
127 // certain that there are no lingering references. | 127 // certain that there are no lingering references. |
128 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; | 128 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; |
129 frame->printPage(page_number, context); | 129 frame->printPage(page_number, context); |
130 [pool release]; | 130 [pool release]; |
131 | 131 |
132 // Done printing. Close the device context to retrieve the compiled metafile. | 132 // Done printing. Close the device context to retrieve the compiled metafile. |
133 metafile->FinishPage(); | 133 metafile->FinishPage(); |
134 } | 134 } |
OLD | NEW |