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 ba0d9e51e314794fb2587b3502c0aae76441a744..012c7587a1fb802a6a1047888130e7b1f98f21f5 100644 |
--- a/chrome/renderer/print_web_view_helper.h |
+++ b/chrome/renderer/print_web_view_helper.h |
@@ -9,9 +9,15 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/shared_memory.h" |
#include "base/time.h" |
+#include "base/utf_string_conversions.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" |
+#include "third_party/skia/include/core/SkPaint.h" |
+#include "third_party/skia/include/core/SkRefCnt.h" |
+#include "third_party/skia/include/core/SkScalar.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" |
@@ -107,7 +113,11 @@ class PrintWebViewHelper : public RenderViewObserver, |
void OnInitiatePrintPreview(); |
// Generate a print preview using |settings|. |
- void OnPrintPreview(const 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 DictionaryValue& settings, |
+ const DictionaryValue& header_footer_info); |
kmadhusu
2011/07/13 18:47:53
nit: Fix indentation.
Aayush Kumar
2011/07/13 21:52:16
Done.
|
// Print / preview the node under the context menu. |
void OnPrintNodeUnderContextMenu(); |
@@ -165,7 +175,9 @@ 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, |
+ int total_pages); |
#else |
void PrintPageInternal(const PrintMsg_PrintPage_Params& params, |
const gfx::Size& canvas_size, |
@@ -283,6 +295,61 @@ class PrintWebViewHelper : public RenderViewObserver, |
int preview_page_count_; |
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_; |
+ |
+ // Specifies the horizontal alignment of the Headers and Footers. |
+ enum HorizontalHeaderFooterPosition { |
kmadhusu
2011/07/13 18:47:53
Move these enums to print_job_constants.h &.cc and
|
+ LEFT, |
+ CENTER, |
+ RIGHT |
+ }; |
+ |
+ // Specifies the vertical alignment of the Headers and Footers. |
+ enum VerticalHeaderFooterPosition { |
+ TOP, |
+ BOTTOM |
+ }; |
+ |
+ // Gets the x-coordinate from where we want to start printing the current text |
+ // depending on the alignment (LEFT, RIGHT, CENTER). |
+ SkScalar GetHorizontalCoordinate( |
+ string16 text, |
+ SkPaint paint, |
+ HorizontalHeaderFooterPosition pos, |
+ SkScalar margin_left_in_points, |
+ SkScalar margin_right_in_points, |
+ SkScalar content_width_in_points); |
+ |
+ // Gets the y-coordinate from where we want to start printing based on if we |
+ // are printing the Header or the Footer (TOP or BOTTOM). |
+ SkScalar GetVerticalCoordinate( |
+ SkPaint paint, |
+ VerticalHeaderFooterPosition pos, |
+ SkScalar margin_left_in_points, |
+ SkScalar margin_right_in_points, |
+ SkScalar content_height_in_points); |
+ |
+ // Interstice or gap between different Header and Footer components. |
+ // Hardcoded to 0.25cm = 1/10" = 7.2 points |
+ const SkScalar header_footer_interstice; |
+ |
+ // Given a text, the positions and the paint object, this method calculates |
+ // the coordinates and prints the text at those co-ordinates. |
+ void PrintHeaderFooterText( |
+ string16 text, |
+ SkPaint paint, |
+ const SkRefPtr<skia::VectorCanvas>& canvas, |
+ SkScalar margin_left_in_points, |
Lei Zhang
2011/07/12 22:04:50
Consider using some additional data structures. Wh
Aayush Kumar
2011/07/13 21:52:16
Now private variables in PrintWebViewHelper class
|
+ SkScalar margin_right_in_points, |
+ SkScalar content_width_in_points, |
+ SkScalar margin_top_in_points, |
+ SkScalar margin_bottom_in_points, |
+ SkScalar content_height_in_points, |
+ HorizontalHeaderFooterPosition hor_pos, |
+ VerticalHeaderFooterPosition ver_pos); |
+ |
DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
}; |