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

Side by Side Diff: chrome/renderer/print_web_view_helper.h

Issue 7348010: Added Header and Footer support using Skia (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Added SK_API to vector platform device skia 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 #ifndef CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 5 #ifndef CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
6 #define CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 6 #define CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 10 matching lines...) Expand all
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h"
22 #include "ui/gfx/size.h" 22 #include "ui/gfx/size.h"
23 23
24 struct PrintMsg_Print_Params; 24 struct PrintMsg_Print_Params;
25 struct PrintMsg_PrintPage_Params; 25 struct PrintMsg_PrintPage_Params;
26 struct PrintMsg_PrintPages_Params; 26 struct PrintMsg_PrintPages_Params;
27 27
28 namespace base { 28 namespace base {
29 class DictionaryValue; 29 class DictionaryValue;
30 } 30 }
31 #if defined(USE_SKIA)
32 namespace skia {
33 class VectorCanvas;
34 }
35 #endif
31 36
32 // Class that calls the Begin and End print functions on the frame and changes 37 // Class that calls the Begin and End print functions on the frame and changes
33 // the size of the view temporarily to support full page printing.. 38 // the size of the view temporarily to support full page printing..
34 // Do not serve any events in the time between construction and destruction of 39 // Do not serve any events in the time between construction and destruction of
35 // this class because it will cause flicker. 40 // this class because it will cause flicker.
36 class PrepareFrameAndViewForPrint { 41 class PrepareFrameAndViewForPrint {
37 public: 42 public:
38 // Prints |frame|. If |node| is not NULL, then only that node will be 43 // Prints |frame|. If |node| is not NULL, then only that node will be
39 // printed. 44 // printed.
40 PrepareFrameAndViewForPrint(const PrintMsg_Print_Params& print_params, 45 PrepareFrameAndViewForPrint(const PrintMsg_Print_Params& print_params,
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 int page_index, 264 int page_index,
260 const PrintMsg_Print_Params& default_params, 265 const PrintMsg_Print_Params& default_params,
261 PageSizeMargins* page_layout_in_points); 266 PageSizeMargins* page_layout_in_points);
262 267
263 static void UpdatePrintableSizeInPrintParameters( 268 static void UpdatePrintableSizeInPrintParameters(
264 WebKit::WebFrame* frame, 269 WebKit::WebFrame* frame,
265 WebKit::WebNode* node, 270 WebKit::WebNode* node,
266 PrepareFrameAndViewForPrint* prepare, 271 PrepareFrameAndViewForPrint* prepare,
267 PrintMsg_Print_Params* params); 272 PrintMsg_Print_Params* params);
268 273
274 #if defined(USE_SKIA)
275 // Given the |device| and |canvas| to draw on, prints the appropriate headers
276 // and footers using strings from |header_footer_info| on to the canvas.
277 static void PrintHeaderAndFooter(
278 SkDevice* device,
279 skia::VectorCanvas* canvas,
280 int page_number,
281 int total_pages,
282 float webkit_scale_factor,
283 const PageSizeMargins& page_layout_in_points,
284 const base::DictionaryValue& header_footer_info);
285 #endif // defined(USE_SKIA)
286
269 bool GetPrintFrame(WebKit::WebFrame** frame); 287 bool GetPrintFrame(WebKit::WebFrame** frame);
270 288
271 // This reports the current time - |start_time| as the time to render a page. 289 // This reports the current time - |start_time| as the time to render a page.
272 void ReportPreviewPageRenderTime(base::TimeTicks start_time); 290 void ReportPreviewPageRenderTime(base::TimeTicks start_time);
273 291
274 // Script Initiated Printing ------------------------------------------------ 292 // Script Initiated Printing ------------------------------------------------
275 293
276 // Returns true if script initiated printing occurs too often. 294 // Returns true if script initiated printing occurs too often.
277 bool IsScriptInitiatedPrintTooFrequent(WebKit::WebFrame* frame); 295 bool IsScriptInitiatedPrintTooFrequent(WebKit::WebFrame* frame);
278 296
(...skipping 23 matching lines...) Expand all
302 // Used for scripted initiated printing blocking. 320 // Used for scripted initiated printing blocking.
303 base::Time last_cancelled_script_print_; 321 base::Time last_cancelled_script_print_;
304 int user_cancelled_scripted_print_count_; 322 int user_cancelled_scripted_print_count_;
305 323
306 // Let the browser process know of a printing failure. Only set to false when 324 // Let the browser process know of a printing failure. Only set to false when
307 // the failure came from the browser in the first place. 325 // the failure came from the browser in the first place.
308 bool notify_browser_of_print_failure_; 326 bool notify_browser_of_print_failure_;
309 327
310 scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_; 328 scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_;
311 329
330 // Strings generated by the browser process to be printed as headers and
331 // footers if requested by the user.
332 scoped_ptr<base::DictionaryValue> header_footer_info_;
333
312 // Keeps track of the state of print preview between messages. 334 // Keeps track of the state of print preview between messages.
313 class PrintPreviewContext { 335 class PrintPreviewContext {
314 public: 336 public:
315 PrintPreviewContext(); 337 PrintPreviewContext();
316 ~PrintPreviewContext(); 338 ~PrintPreviewContext();
317 339
318 // Initializes the print preview context. Need to be called to set 340 // Initializes the print preview context. Need to be called to set
319 // the |web_frame| / |web_node| to generate the print preview for. 341 // the |web_frame| / |web_node| to generate the print preview for.
320 void InitWithFrame(WebKit::WebFrame* web_frame); 342 void InitWithFrame(WebKit::WebFrame* web_frame);
321 void InitWithNode(const WebKit::WebNode& web_node); 343 void InitWithNode(const WebKit::WebNode& web_node);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 417
396 State state_; 418 State state_;
397 }; 419 };
398 420
399 PrintPreviewContext print_preview_context_; 421 PrintPreviewContext print_preview_context_;
400 422
401 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); 423 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper);
402 }; 424 };
403 425
404 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 426 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698