Chromium Code Reviews| Index: chrome/renderer/print_web_view_helper.h |
| diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h |
| index 81d40e3cd716dba45740ed2e1fe8e0e7274b2c63..ce78ed5d850dbe44efaadd7ca55489d4fa36f04e 100644 |
| --- a/chrome/renderer/print_web_view_helper.h |
| +++ b/chrome/renderer/print_web_view_helper.h |
| @@ -11,9 +11,13 @@ |
| #include "base/memory/scoped_ptr.h" |
| #include "base/shared_memory.h" |
| #include "base/time.h" |
| +#include "base/values.h" |
| #include "content/renderer/render_view_observer.h" |
| #include "content/renderer/render_view_observer_tracker.h" |
| #include "printing/metafile.h" |
| +#include "skia/ext/vector_canvas.h" |
|
vandebo (ex-Chrome)
2011/07/22 22:58:33
Don't include heads for things you only use as poi
Aayush Kumar
2011/07/24 02:09:02
Done.
|
| +#include "skia/ext/vector_platform_device_skia.h" |
| +#include "third_party/skia/include/core/SkRefCnt.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" |
| #include "ui/gfx/size.h" |
| @@ -66,6 +70,25 @@ class PrepareFrameAndViewForPrint { |
| DISALLOW_COPY_AND_ASSIGN(PrepareFrameAndViewForPrint); |
| }; |
| +// Struct that holds margin and content area information of a page. |
| +typedef struct PageSizeMargins { |
| + double content_width; |
| + double content_height; |
| + double margin_top; |
| + double margin_right; |
| + double margin_bottom; |
| + double margin_left; |
| +} PageSizeMargins; |
| + |
| +// Given the |device| and |canvas| to draw on, prints the appropriate headers |
| +// and footers using strings from |header_footer_info| on to the canvas. |
| +void PrintHeaderAndFooter(skia::VectorPlatformDeviceSkia* device, |
| + const SkRefPtr<skia::VectorCanvas>& canvas, |
| + int page_number, int total_pages, |
| + float webkit_scale_factor, |
| + PageSizeMargins& page_size_margins, |
| + const DictionaryValue* header_footer_info); |
| + |
| // PrintWebViewHelper handles most of the printing grunt work for RenderView. |
| // We plan on making print asynchronous and that will require copying the DOM |
| // of the document and creating a new WebView with the contents. |
| @@ -110,7 +133,11 @@ class PrintWebViewHelper : public RenderViewObserver, |
| void OnInitiatePrintPreview(); |
| // Start the process of generating a print preview using |settings|. |
| - void OnPrintPreview(const base::DictionaryValue& settings); |
| + // |header_footer_info| contains the necessary strings generated by the |
| + // browser process to be printed as headers and footers if requested by the |
| + // user. |
| + void OnPrintPreview(const base::DictionaryValue& settings, |
| + const DictionaryValue& header_footer_info); |
| // Initialize the print preview document. |
| bool CreatePreviewDocument(); |
| @@ -188,7 +215,8 @@ class PrintWebViewHelper : public RenderViewObserver, |
| void PrintPageInternal(const PrintMsg_PrintPage_Params& params, |
| const gfx::Size& canvas_size, |
| WebKit::WebFrame* frame, |
| - printing::Metafile* metafile); |
| + printing::Metafile* metafile, |
| + bool is_preview); |
| #else |
| void PrintPageInternal(const PrintMsg_PrintPage_Params& params, |
| const gfx::Size& canvas_size, |
| @@ -206,7 +234,8 @@ class PrintWebViewHelper : public RenderViewObserver, |
| #elif defined(OS_MACOSX) |
| void RenderPage(const gfx::Size& page_size, const gfx::Rect& content_area, |
| const float& scale_factor, int page_number, |
| - WebKit::WebFrame* frame, printing::Metafile* metafile); |
| + WebKit::WebFrame* frame, printing::Metafile* metafile, |
| + bool is_preview, bool display_header_footer); |
| #elif defined(OS_POSIX) |
| bool RenderPages(const PrintMsg_PrintPages_Params& params, |
| WebKit::WebFrame* frame, WebKit::WebNode* node, |
| @@ -220,16 +249,10 @@ class PrintWebViewHelper : public RenderViewObserver, |
| bool CopyMetafileDataToSharedMem(printing::Metafile* metafile, |
| base::SharedMemoryHandle* shared_mem_handle); |
| - void GetPageSizeAndMarginsInPoints( |
| + PageSizeMargins GetPageSizeAndMarginsInPoints( |
| WebKit::WebFrame* frame, |
| int page_index, |
| - const PrintMsg_Print_Params& default_params, |
| - double* content_width_in_points, |
| - double* content_height_in_points, |
| - double* margin_top_in_points, |
| - double* margin_right_in_points, |
| - double* margin_bottom_in_points, |
| - double* margin_left_in_points); |
| + const PrintMsg_Print_Params& default_params); |
| void UpdatePrintableSizeInPrintParameters(WebKit::WebFrame* frame, |
| WebKit::WebNode* node, |
| @@ -277,6 +300,10 @@ class PrintWebViewHelper : public RenderViewObserver, |
| scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_; |
| + // Contains strings generated by the browser process to be printed as headers |
| + // and footers if requested by the user. |
| + const DictionaryValue* header_footer_info_; |
| + |
| // Keeps track of the state of print preview between messages. |
| class PrintPreviewContext { |
| public: |