OLD | NEW |
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 #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 <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/shared_memory.h" | 12 #include "base/shared_memory.h" |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "content/public/renderer/render_view_observer.h" | 14 #include "content/public/renderer/render_view_observer.h" |
15 #include "content/public/renderer/render_view_observer_tracker.h" | 15 #include "content/public/renderer/render_view_observer_tracker.h" |
16 #include "printing/metafile.h" | 16 #include "printing/metafile.h" |
17 #include "printing/metafile_impl.h" | 17 #include "printing/metafile_impl.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPrintScalingOption
.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" |
22 #include "ui/gfx/size.h" | 23 #include "ui/gfx/size.h" |
23 | 24 |
24 struct PrintMsg_Print_Params; | 25 struct PrintMsg_Print_Params; |
25 struct PrintMsg_PrintPage_Params; | 26 struct PrintMsg_PrintPage_Params; |
26 struct PrintMsg_PrintPages_Params; | 27 struct PrintMsg_PrintPages_Params; |
27 | 28 |
28 namespace base { | 29 namespace base { |
29 class DictionaryValue; | 30 class DictionaryValue; |
30 } | 31 } |
(...skipping 24 matching lines...) Expand all Loading... |
55 return use_browser_overlays_; | 56 return use_browser_overlays_; |
56 } | 57 } |
57 | 58 |
58 const gfx::Size& GetPrintCanvasSize() const { | 59 const gfx::Size& GetPrintCanvasSize() const { |
59 return print_canvas_size_; | 60 return print_canvas_size_; |
60 } | 61 } |
61 | 62 |
62 void FinishPrinting(); | 63 void FinishPrinting(); |
63 | 64 |
64 private: | 65 private: |
65 void StartPrinting(const gfx::Size& print_params); | 66 void StartPrinting(const gfx::Size& canvas_size, |
| 67 const gfx::Rect& printable_area, |
| 68 const gfx::Size& paper_size); |
66 | 69 |
67 WebKit::WebFrame* frame_; | 70 WebKit::WebFrame* frame_; |
68 WebKit::WebNode node_to_print_; | 71 WebKit::WebNode node_to_print_; |
69 WebKit::WebView* web_view_; | 72 WebKit::WebView* web_view_; |
70 gfx::Size print_canvas_size_; | 73 gfx::Size print_canvas_size_; |
| 74 gfx::Rect printable_area_; |
| 75 gfx::Size paper_size_; |
71 gfx::Size prev_view_size_; | 76 gfx::Size prev_view_size_; |
72 gfx::Size prev_scroll_offset_; | 77 gfx::Size prev_scroll_offset_; |
73 int dpi_; | 78 int dpi_; |
74 int expected_pages_count_; | 79 int expected_pages_count_; |
75 bool use_browser_overlays_; | 80 bool use_browser_overlays_; |
| 81 WebKit::WebPrintScalingOption print_scaling_option_; |
76 bool finished_; | 82 bool finished_; |
77 | 83 |
78 DISALLOW_COPY_AND_ASSIGN(PrepareFrameAndViewForPrint); | 84 DISALLOW_COPY_AND_ASSIGN(PrepareFrameAndViewForPrint); |
79 }; | 85 }; |
80 | 86 |
81 // PrintWebViewHelper handles most of the printing grunt work for RenderView. | 87 // PrintWebViewHelper handles most of the printing grunt work for RenderView. |
82 // We plan on making print asynchronous and that will require copying the DOM | 88 // We plan on making print asynchronous and that will require copying the DOM |
83 // of the document and creating a new WebView with the contents. | 89 // of the document and creating a new WebView with the contents. |
84 class PrintWebViewHelper | 90 class PrintWebViewHelper |
85 : public content::RenderViewObserver, | 91 : public content::RenderViewObserver, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 199 |
194 void Print(WebKit::WebFrame* frame, const WebKit::WebNode& node); | 200 void Print(WebKit::WebFrame* frame, const WebKit::WebNode& node); |
195 | 201 |
196 // Notification when printing is done - signal tear-down/free resources. | 202 // Notification when printing is done - signal tear-down/free resources. |
197 void DidFinishPrinting(PrintingResult result); | 203 void DidFinishPrinting(PrintingResult result); |
198 | 204 |
199 // Print Settings ----------------------------------------------------------- | 205 // Print Settings ----------------------------------------------------------- |
200 | 206 |
201 // Initialize print page settings with default settings. | 207 // Initialize print page settings with default settings. |
202 // Used only for native printing workflow. | 208 // Used only for native printing workflow. |
203 bool InitPrintSettings(); | 209 bool InitPrintSettings(bool fit_to_paper_size); |
204 | 210 |
205 // Initialize print page settings with default settings and prepare the frame | 211 // Initialize print page settings with default settings and prepare the frame |
206 // for print. A new PrepareFrameAndViewForPrint is created to fulfill the | 212 // for print. A new PrepareFrameAndViewForPrint is created to fulfill the |
207 // request and is filled into the |prepare| argument. | 213 // request and is filled into the |prepare| argument. |
208 // Used only for native printing workflow. | 214 // Used only for native printing workflow. |
209 bool InitPrintSettingsAndPrepareFrame( | 215 bool InitPrintSettingsAndPrepareFrame( |
210 WebKit::WebFrame* frame, | 216 WebKit::WebFrame* frame, |
211 const WebKit::WebNode& node, | 217 const WebKit::WebNode& node, |
212 scoped_ptr<PrepareFrameAndViewForPrint>* prepare); | 218 scoped_ptr<PrepareFrameAndViewForPrint>* prepare); |
213 | 219 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 enum PrintPreviewErrorBuckets error_; | 473 enum PrintPreviewErrorBuckets error_; |
468 | 474 |
469 State state_; | 475 State state_; |
470 }; | 476 }; |
471 | 477 |
472 PrintPreviewContext print_preview_context_; | 478 PrintPreviewContext print_preview_context_; |
473 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 479 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
474 }; | 480 }; |
475 | 481 |
476 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 482 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |