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

Side by Side Diff: chrome/renderer/print_web_view_helper_win.cc

Issue 11367033: "Using" cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « chrome/renderer/print_web_view_helper_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/print_web_view_helper.h" 5 #include "chrome/renderer/print_web_view_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 page_params.content_area = content_area_in_dpi; 76 page_params.content_area = content_area_in_dpi;
77 77
78 if (!CopyMetafileDataToSharedMem(metafile.get(), 78 if (!CopyMetafileDataToSharedMem(metafile.get(),
79 &(page_params.metafile_data_handle))) { 79 &(page_params.metafile_data_handle))) {
80 page_params.data_size = 0; 80 page_params.data_size = 0;
81 } 81 }
82 82
83 Send(new PrintHostMsg_DidPrintPage(routing_id(), page_params)); 83 Send(new PrintHostMsg_DidPrintPage(routing_id(), page_params));
84 } 84 }
85 85
86 bool PrintWebViewHelper::RenderPreviewPage(int page_number) { 86 bool PrintWebViewHelper::RenderPreviewPage(
87 PrintMsg_Print_Params print_params = print_preview_context_.print_params(); 87 int page_number,
88 const PrintMsg_Print_Params& print_params) {
88 // Calculate the dpi adjustment. 89 // Calculate the dpi adjustment.
89 double actual_shrink = static_cast<float>(print_params.desired_dpi / 90 double actual_shrink = static_cast<float>(print_params.desired_dpi /
90 print_params.dpi); 91 print_params.dpi);
91 scoped_ptr<Metafile> draft_metafile; 92 scoped_ptr<Metafile> draft_metafile;
92 printing::Metafile* initial_render_metafile = 93 printing::Metafile* initial_render_metafile =
93 print_preview_context_.metafile(); 94 print_preview_context_.metafile();
94 95
95 if (print_preview_context_.IsModifiable() && is_print_ready_metafile_sent_) { 96 if (print_preview_context_.IsModifiable() && is_print_ready_metafile_sent_) {
96 draft_metafile.reset(new printing::PreviewMetafile); 97 draft_metafile.reset(new printing::PreviewMetafile);
97 initial_render_metafile = draft_metafile.get(); 98 initial_render_metafile = draft_metafile.get();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 skia::SetIsPreviewMetafile(*canvas, is_preview); 175 skia::SetIsPreviewMetafile(*canvas, is_preview);
175 } 176 }
176 177
177 float webkit_scale_factor = frame->printPage(page_number, canvas.get()); 178 float webkit_scale_factor = frame->printPage(page_number, canvas.get());
178 179
179 if (params.display_header_footer) { 180 if (params.display_header_footer) {
180 // |page_number| is 0-based, so 1 is added. 181 // |page_number| is 0-based, so 1 is added.
181 PrintHeaderAndFooter(canvas.get(), page_number + 1, 182 PrintHeaderAndFooter(canvas.get(), page_number + 1,
182 print_preview_context_.total_page_count(), 183 print_preview_context_.total_page_count(),
183 css_scale_factor * webkit_page_shrink_factor, 184 css_scale_factor * webkit_page_shrink_factor,
184 page_layout_in_points, 185 page_layout_in_points, *header_footer_info_, params);
185 *header_footer_info_);
186 } 186 }
187 187
188 if (*actual_shrink <= 0 || webkit_scale_factor <= 0) { 188 if (*actual_shrink <= 0 || webkit_scale_factor <= 0) {
189 NOTREACHED() << "Printing page " << page_number << " failed."; 189 NOTREACHED() << "Printing page " << page_number << " failed.";
190 } else { 190 } else {
191 // While rendering certain plugins (PDF) to metafile, we might need to 191 // While rendering certain plugins (PDF) to metafile, we might need to
192 // set custom scale factor. Update |actual_shrink| with custom scale 192 // set custom scale factor. Update |actual_shrink| with custom scale
193 // if it is set on canvas. 193 // if it is set on canvas.
194 // TODO(gene): We should revisit this solution for the next versions. 194 // TODO(gene): We should revisit this solution for the next versions.
195 // Consider creating metafile of the right size (or resizable) 195 // Consider creating metafile of the right size (or resizable)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 shared_buf.Unmap(); 227 shared_buf.Unmap();
228 return false; 228 return false;
229 } 229 }
230 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); 230 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle);
231 shared_buf.Unmap(); 231 shared_buf.Unmap();
232 232
233 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle, 233 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle,
234 shared_mem_handle)); 234 shared_mem_handle));
235 return true; 235 return true;
236 } 236 }
OLDNEW
« no previous file with comments | « chrome/renderer/print_web_view_helper_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698