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

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

Issue 7348010: Added Header and Footer support using Skia (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Remove header_footer_info from settings Dictionary. Changes as per Steve and Kausalya's comments. Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_descriptor_posix.h" 7 #include "base/file_descriptor_posix.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 print_params.document_cookie, 152 print_params.document_cookie,
153 *page_count)); 153 *page_count));
154 #endif 154 #endif
155 155
156 base::TimeTicks begin_time = base::TimeTicks::Now(); 156 base::TimeTicks begin_time = base::TimeTicks::Now();
157 base::TimeTicks page_begin_time = begin_time; 157 base::TimeTicks page_begin_time = begin_time;
158 158
159 PrintMsg_PrintPage_Params page_params; 159 PrintMsg_PrintPage_Params page_params;
160 page_params.params = print_params; 160 page_params.params = print_params;
161 const gfx::Size& canvas_size = prepare->GetPrintCanvasSize(); 161 const gfx::Size& canvas_size = prepare->GetPrintCanvasSize();
162 page_params.params.display_header_footer = false;
162 if (params.pages.empty()) { 163 if (params.pages.empty()) {
163 for (int i = 0; i < *page_count; ++i) { 164 for (int i = 0; i < *page_count; ++i) {
164 page_params.page_number = i; 165 page_params.page_number = i;
165 page_params.page_slot = i; 166 page_params.page_slot = i;
166 PrintPageInternal(page_params, canvas_size, frame, metafile); 167 PrintPageInternal(page_params, canvas_size, frame, metafile);
167 } 168 }
168 } else { 169 } else {
169 for (size_t i = 0; i < params.pages.size(); ++i) { 170 for (size_t i = 0; i < params.pages.size(); ++i) {
170 page_params.page_number = params.pages[i]; 171 page_params.page_number = params.pages[i];
171 page_params.page_slot = i; 172 page_params.page_slot = i;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 if (!device) 207 if (!device)
207 return; 208 return;
208 209
209 // The printPage method take a reference to the canvas we pass down, so it 210 // The printPage method take a reference to the canvas we pass down, so it
210 // can't be a stack object. 211 // can't be a stack object.
211 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device); 212 SkRefPtr<skia::VectorCanvas> canvas = new skia::VectorCanvas(device);
212 canvas->unref(); // SkRefPtr and new both took a reference. 213 canvas->unref(); // SkRefPtr and new both took a reference.
213 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile); 214 printing::MetafileSkiaWrapper::SetMetafileOnCanvas(canvas.get(), metafile);
214 frame->printPage(params.page_number, canvas.get()); 215 frame->printPage(params.page_number, canvas.get());
215 216
216 // TODO(myhuang): We should render the header and the footer. 217 if (params.params.display_header_footer) {
218 // |page_number| is 0-based, so 1 is added.
219 // The scale factor on Linux is 1.
220 PrintHeaderAndFooter(device, canvas.get(), params.page_number + 1,
221 print_preview_context_.total_page_count(), 1,
222 page_layout_in_points, *header_footer_info_);
223 }
217 224
218 // Done printing. Close the device context to retrieve the compiled metafile. 225 // Done printing. Close the device context to retrieve the compiled metafile.
219 if (!metafile->FinishPage()) 226 if (!metafile->FinishPage())
220 NOTREACHED() << "metafile failed"; 227 NOTREACHED() << "metafile failed";
221 } 228 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698