| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/shared_memory.h" | 13 #include "base/shared_memory.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "content/renderer/render_view_observer.h" | 15 #include "content/renderer/render_view_observer.h" |
| 16 #include "content/renderer/render_view_observer_tracker.h" | 16 #include "content/renderer/render_view_observer_tracker.h" |
| 17 #include "printing/metafile.h" | 17 #include "printing/metafile.h" |
| 18 #include "printing/metafile_impl.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" |
| 21 #include "ui/gfx/size.h" | 22 #include "ui/gfx/size.h" |
| 22 | 23 |
| 23 struct PrintMsg_Print_Params; | 24 struct PrintMsg_Print_Params; |
| 24 struct PrintMsg_PrintPage_Params; | 25 struct PrintMsg_PrintPage_Params; |
| 25 struct PrintMsg_PrintPages_Params; | 26 struct PrintMsg_PrintPages_Params; |
| 26 | 27 |
| 27 namespace base { | 28 namespace base { |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // Helper functions | 341 // Helper functions |
| 341 int GetNextPageNumber(); | 342 int GetNextPageNumber(); |
| 342 bool IsReadyToRender() const; | 343 bool IsReadyToRender() const; |
| 343 bool IsBusy() const; | 344 bool IsBusy() const; |
| 344 bool IsModifiable() const; | 345 bool IsModifiable() const; |
| 345 | 346 |
| 346 // Getters | 347 // Getters |
| 347 WebKit::WebFrame* frame() const; | 348 WebKit::WebFrame* frame() const; |
| 348 WebKit::WebNode* node() const; | 349 WebKit::WebNode* node() const; |
| 349 int total_page_count() const; | 350 int total_page_count() const; |
| 350 printing::Metafile* metafile() const; | 351 printing::PreviewMetafile* metafile() const; |
| 351 const PrintMsg_Print_Params& print_params() const; | 352 const PrintMsg_Print_Params& print_params() const; |
| 352 const gfx::Size& GetPrintCanvasSize() const; | 353 const gfx::Size& GetPrintCanvasSize() const; |
| 353 | 354 |
| 354 private: | 355 private: |
| 355 enum State { | 356 enum State { |
| 356 UNINITIALIZED, // Not ready to render. | 357 UNINITIALIZED, // Not ready to render. |
| 357 INITIALIZED, // Ready to render. | 358 INITIALIZED, // Ready to render. |
| 358 RENDERING, // Rendering. | 359 RENDERING, // Rendering. |
| 359 DONE // Finished rendering. | 360 DONE // Finished rendering. |
| 360 }; | 361 }; |
| 361 | 362 |
| 362 // Reset some of the internal rendering context. | 363 // Reset some of the internal rendering context. |
| 363 void ClearContext(); | 364 void ClearContext(); |
| 364 | 365 |
| 365 // Specifies what to render for print preview. | 366 // Specifies what to render for print preview. |
| 366 WebKit::WebFrame* frame_; | 367 WebKit::WebFrame* frame_; |
| 367 scoped_ptr<WebKit::WebNode> node_; | 368 scoped_ptr<WebKit::WebNode> node_; |
| 368 | 369 |
| 369 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; | 370 scoped_ptr<PrepareFrameAndViewForPrint> prep_frame_view_; |
| 370 scoped_ptr<printing::Metafile> metafile_; | 371 scoped_ptr<printing::PreviewMetafile> metafile_; |
| 371 scoped_ptr<PrintMsg_Print_Params> print_params_; | 372 scoped_ptr<PrintMsg_Print_Params> print_params_; |
| 372 | 373 |
| 373 // Total page count in the renderer. | 374 // Total page count in the renderer. |
| 374 int total_page_count_; | 375 int total_page_count_; |
| 375 | 376 |
| 376 // Number of pages to render. | 377 // Number of pages to render. |
| 377 int actual_page_count_; | 378 int actual_page_count_; |
| 378 | 379 |
| 379 // The current page to render. | 380 // The current page to render. |
| 380 int current_page_number_; | 381 int current_page_number_; |
| 381 | 382 |
| 382 // |rendered_pages_| tracks which pages need to be printed as well as | 383 // |rendered_pages_| tracks which pages need to be printed as well as |
| 383 // the page slot it should be printed in. See GetPageSlotForPage. | 384 // the page slot it should be printed in. See GetPageSlotForPage. |
| 384 typedef std::pair<bool, int> PreviewPageInfo; | 385 typedef std::pair<bool, int> PreviewPageInfo; |
| 385 std::vector<PreviewPageInfo> rendered_pages_; | 386 std::vector<PreviewPageInfo> rendered_pages_; |
| 386 | 387 |
| 387 base::TimeDelta document_render_time_; | 388 base::TimeDelta document_render_time_; |
| 388 base::TimeTicks begin_time_; | 389 base::TimeTicks begin_time_; |
| 389 | 390 |
| 390 State state_; | 391 State state_; |
| 391 }; | 392 }; |
| 392 | 393 |
| 393 PrintPreviewContext print_preview_context_; | 394 PrintPreviewContext print_preview_context_; |
| 394 | 395 |
| 395 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 396 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
| 396 }; | 397 }; |
| 397 | 398 |
| 398 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 399 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
| OLD | NEW |