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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 374 |
375 // Frame to be use to render preview. May be the same as source_frame(), or | 375 // Frame to be use to render preview. May be the same as source_frame(), or |
376 // generated from it, e.g. copy of selected block. | 376 // generated from it, e.g. copy of selected block. |
377 blink::WebLocalFrame* prepared_frame(); | 377 blink::WebLocalFrame* prepared_frame(); |
378 // Node to be use to render preview. May be the same as source_node(), or | 378 // Node to be use to render preview. May be the same as source_node(), or |
379 // generated from it, e.g. copy of selected block. | 379 // generated from it, e.g. copy of selected block. |
380 const blink::WebNode& prepared_node() const; | 380 const blink::WebNode& prepared_node() const; |
381 | 381 |
382 int total_page_count() const; | 382 int total_page_count() const; |
383 bool generate_draft_pages() const; | 383 bool generate_draft_pages() const; |
384 PreviewMetafile* metafile(); | 384 PdfMetafileSkia* metafile(); |
385 gfx::Size GetPrintCanvasSize() const; | 385 gfx::Size GetPrintCanvasSize() const; |
386 int last_error() const; | 386 int last_error() const; |
387 | 387 |
388 private: | 388 private: |
389 enum State { | 389 enum State { |
390 UNINITIALIZED, // Not ready to render. | 390 UNINITIALIZED, // Not ready to render. |
391 INITIALIZED, // Ready to render. | 391 INITIALIZED, // Ready to render. |
392 RENDERING, // Rendering. | 392 RENDERING, // Rendering. |
393 DONE // Finished rendering. | 393 DONE // Finished rendering. |
394 }; | 394 }; |
395 | 395 |
396 // Reset some of the internal rendering context. | 396 // Reset some of the internal rendering context. |
397 void ClearContext(); | 397 void ClearContext(); |
398 | 398 |
399 // Specifies what to render for print preview. | 399 // Specifies what to render for print preview. |
400 FrameReference source_frame_; | 400 FrameReference source_frame_; |
401 blink::WebNode source_node_; | 401 blink::WebNode source_node_; |
402 | 402 |
403 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; | 403 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; |
404 scoped_ptr<PreviewMetafile> metafile_; | 404 scoped_ptr<PdfMetafileSkia> metafile_; |
405 | 405 |
406 // Total page count in the renderer. | 406 // Total page count in the renderer. |
407 int total_page_count_; | 407 int total_page_count_; |
408 | 408 |
409 // The current page to render. | 409 // The current page to render. |
410 int current_page_index_; | 410 int current_page_index_; |
411 | 411 |
412 // List of page indices that need to be rendered. | 412 // List of page indices that need to be rendered. |
413 std::vector<int> pages_to_render_; | 413 std::vector<int> pages_to_render_; |
414 | 414 |
(...skipping 21 matching lines...) Expand all Loading... |
436 // hangs because RequestPrintPreview is called before DidStopLoading() is | 436 // hangs because RequestPrintPreview is called before DidStopLoading() is |
437 // called. This is a store for the RequestPrintPreview() call and its | 437 // called. This is a store for the RequestPrintPreview() call and its |
438 // parameters so that it can be invoked after DidStopLoading. | 438 // parameters so that it can be invoked after DidStopLoading. |
439 base::Closure on_stop_loading_closure_; | 439 base::Closure on_stop_loading_closure_; |
440 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 440 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
441 }; | 441 }; |
442 | 442 |
443 } // namespace printing | 443 } // namespace printing |
444 | 444 |
445 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ | 445 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |