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_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 5 #ifndef CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
6 #define CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 6 #define CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // Get final print settings from the user. | 200 // Get final print settings from the user. |
201 // Return false if the user cancels or on error. | 201 // Return false if the user cancels or on error. |
202 bool GetPrintSettingsFromUser(blink::WebFrame* frame, | 202 bool GetPrintSettingsFromUser(blink::WebFrame* frame, |
203 const blink::WebNode& node, | 203 const blink::WebNode& node, |
204 int expected_pages_count); | 204 int expected_pages_count); |
205 | 205 |
206 // Page Printing / Rendering ------------------------------------------------ | 206 // Page Printing / Rendering ------------------------------------------------ |
207 | 207 |
208 void OnFramePreparedForPrintPages(); | 208 void OnFramePreparedForPrintPages(); |
209 void PrintPages(); | 209 void PrintPages(); |
210 bool PrintPagesNative(blink::WebFrame* frame, | 210 bool PrintPagesNative(blink::WebFrame* frame, int page_count); |
211 int page_count, | |
212 const gfx::Size& canvas_size); | |
213 void FinishFramePrinting(); | 211 void FinishFramePrinting(); |
214 | 212 |
215 // Prints the page listed in |params|. | 213 // Prints the page listed in |params|. |
216 #if defined(OS_LINUX) || defined(OS_ANDROID) | 214 #if defined(OS_LINUX) || defined(OS_ANDROID) |
217 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, | 215 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, |
218 const gfx::Size& canvas_size, | |
219 blink::WebFrame* frame, | 216 blink::WebFrame* frame, |
220 PdfMetafileSkia* metafile); | 217 PdfMetafileSkia* metafile); |
221 #elif defined(OS_WIN) | 218 #elif defined(OS_WIN) |
222 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, | 219 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, |
223 const gfx::Size& canvas_size, | |
224 blink::WebFrame* frame, | 220 blink::WebFrame* frame, |
225 PdfMetafileSkia* metafile, | 221 PdfMetafileSkia* metafile, |
226 gfx::Size* page_size_in_dpi, | 222 gfx::Size* page_size_in_dpi, |
227 gfx::Rect* content_area_in_dpi); | 223 gfx::Rect* content_area_in_dpi); |
228 #else | 224 #else |
229 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, | 225 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, |
230 const gfx::Size& canvas_size, | |
231 blink::WebFrame* frame); | 226 blink::WebFrame* frame); |
232 #endif | 227 #endif |
233 | 228 |
234 // Render the frame for printing. | 229 // Render the frame for printing. |
235 bool RenderPagesForPrint(blink::WebLocalFrame* frame, | 230 bool RenderPagesForPrint(blink::WebLocalFrame* frame, |
236 const blink::WebNode& node); | 231 const blink::WebNode& node); |
237 | 232 |
238 // Platform specific helper function for rendering page(s) to |metafile|. | 233 // Platform specific helper function for rendering page(s) to |metafile|. |
239 #if defined(OS_MACOSX) | 234 #if defined(OS_MACOSX) |
240 void RenderPage(const PrintMsg_Print_Params& params, | 235 void RenderPage(const PrintMsg_Print_Params& params, |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 // Frame to be use to render preview. May be the same as source_frame(), or | 380 // Frame to be use to render preview. May be the same as source_frame(), or |
386 // generated from it, e.g. copy of selected block. | 381 // generated from it, e.g. copy of selected block. |
387 blink::WebLocalFrame* prepared_frame(); | 382 blink::WebLocalFrame* prepared_frame(); |
388 // Node to be use to render preview. May be the same as source_node(), or | 383 // Node to be use to render preview. May be the same as source_node(), or |
389 // generated from it, e.g. copy of selected block. | 384 // generated from it, e.g. copy of selected block. |
390 const blink::WebNode& prepared_node() const; | 385 const blink::WebNode& prepared_node() const; |
391 | 386 |
392 int total_page_count() const; | 387 int total_page_count() const; |
393 bool generate_draft_pages() const; | 388 bool generate_draft_pages() const; |
394 PdfMetafileSkia* metafile(); | 389 PdfMetafileSkia* metafile(); |
395 gfx::Size GetPrintCanvasSize() const; | |
396 int last_error() const; | 390 int last_error() const; |
397 | 391 |
398 private: | 392 private: |
399 enum State { | 393 enum State { |
400 UNINITIALIZED, // Not ready to render. | 394 UNINITIALIZED, // Not ready to render. |
401 INITIALIZED, // Ready to render. | 395 INITIALIZED, // Ready to render. |
402 RENDERING, // Rendering. | 396 RENDERING, // Rendering. |
403 DONE // Finished rendering. | 397 DONE // Finished rendering. |
404 }; | 398 }; |
405 | 399 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 base::Closure on_stop_loading_closure_; | 461 base::Closure on_stop_loading_closure_; |
468 | 462 |
469 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; | 463 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; |
470 | 464 |
471 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 465 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
472 }; | 466 }; |
473 | 467 |
474 } // namespace printing | 468 } // namespace printing |
475 | 469 |
476 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 470 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |