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" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "content/public/renderer/render_view_observer.h" | 16 #include "content/public/renderer/render_view_observer.h" |
17 #include "content/public/renderer/render_view_observer_tracker.h" | 17 #include "content/public/renderer/render_view_observer_tracker.h" |
18 #include "printing/metafile_impl.h" | 18 #include "printing/pdf_metafile_skia.h" |
19 #include "third_party/WebKit/public/platform/WebCanvas.h" | 19 #include "third_party/WebKit/public/platform/WebCanvas.h" |
20 #include "third_party/WebKit/public/web/WebNode.h" | 20 #include "third_party/WebKit/public/web/WebNode.h" |
21 #include "third_party/WebKit/public/web/WebPrintParams.h" | 21 #include "third_party/WebKit/public/web/WebPrintParams.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 struct PrintHostMsg_SetOptionsFromDocument_Params; | 27 struct PrintHostMsg_SetOptionsFromDocument_Params; |
28 | 28 |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 388 |
389 // Frame to be use to render preview. May be the same as source_frame(), or | 389 // Frame to be use to render preview. May be the same as source_frame(), or |
390 // generated from it, e.g. copy of selected block. | 390 // generated from it, e.g. copy of selected block. |
391 blink::WebLocalFrame* prepared_frame(); | 391 blink::WebLocalFrame* prepared_frame(); |
392 // Node to be use to render preview. May be the same as source_node(), or | 392 // Node to be use to render preview. May be the same as source_node(), or |
393 // generated from it, e.g. copy of selected block. | 393 // generated from it, e.g. copy of selected block. |
394 const blink::WebNode& prepared_node() const; | 394 const blink::WebNode& prepared_node() const; |
395 | 395 |
396 int total_page_count() const; | 396 int total_page_count() const; |
397 bool generate_draft_pages() const; | 397 bool generate_draft_pages() const; |
398 PreviewMetafile* metafile(); | 398 PdfMetafileSkia* metafile(); |
399 gfx::Size GetPrintCanvasSize() const; | 399 gfx::Size GetPrintCanvasSize() const; |
400 int last_error() const; | 400 int last_error() const; |
401 | 401 |
402 private: | 402 private: |
403 enum State { | 403 enum State { |
404 UNINITIALIZED, // Not ready to render. | 404 UNINITIALIZED, // Not ready to render. |
405 INITIALIZED, // Ready to render. | 405 INITIALIZED, // Ready to render. |
406 RENDERING, // Rendering. | 406 RENDERING, // Rendering. |
407 DONE // Finished rendering. | 407 DONE // Finished rendering. |
408 }; | 408 }; |
409 | 409 |
410 // Reset some of the internal rendering context. | 410 // Reset some of the internal rendering context. |
411 void ClearContext(); | 411 void ClearContext(); |
412 | 412 |
413 // Specifies what to render for print preview. | 413 // Specifies what to render for print preview. |
414 FrameReference source_frame_; | 414 FrameReference source_frame_; |
415 blink::WebNode source_node_; | 415 blink::WebNode source_node_; |
416 | 416 |
417 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; | 417 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; |
418 scoped_ptr<PreviewMetafile> metafile_; | 418 scoped_ptr<PdfMetafileSkia> metafile_; |
419 | 419 |
420 // Total page count in the renderer. | 420 // Total page count in the renderer. |
421 int total_page_count_; | 421 int total_page_count_; |
422 | 422 |
423 // The current page to render. | 423 // The current page to render. |
424 int current_page_index_; | 424 int current_page_index_; |
425 | 425 |
426 // List of page indices that need to be rendered. | 426 // List of page indices that need to be rendered. |
427 std::vector<int> pages_to_render_; | 427 std::vector<int> pages_to_render_; |
428 | 428 |
(...skipping 21 matching lines...) Expand all Loading... |
450 // hangs because RequestPrintPreview is called before DidStopLoading() is | 450 // hangs because RequestPrintPreview is called before DidStopLoading() is |
451 // called. This is a store for the RequestPrintPreview() call and its | 451 // called. This is a store for the RequestPrintPreview() call and its |
452 // parameters so that it can be invoked after DidStopLoading. | 452 // parameters so that it can be invoked after DidStopLoading. |
453 base::Closure on_stop_loading_closure_; | 453 base::Closure on_stop_loading_closure_; |
454 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 454 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
455 }; | 455 }; |
456 | 456 |
457 } // namespace printing | 457 } // namespace printing |
458 | 458 |
459 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 459 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |