| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_DELEGATE_H_ | 5 #ifndef CHROME_RENDERER_PRINT_WEB_VIEW_DELEGATE_H_ |
| 6 #define CHROME_RENDERER_PRINT_WEB_VIEW_DELEGATE_H_ | 6 #define CHROME_RENDERER_PRINT_WEB_VIEW_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/gfx/size.h" | 10 #include "base/gfx/size.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 struct ViewMsg_PrintPages_Params; | 27 struct ViewMsg_PrintPages_Params; |
| 28 | 28 |
| 29 | 29 |
| 30 // Class that calls the Begin and End print functions on the frame and changes | 30 // Class that calls the Begin and End print functions on the frame and changes |
| 31 // the size of the view temporarily to support full page printing.. | 31 // the size of the view temporarily to support full page printing.. |
| 32 // Do not serve any events in the time between construction and destruction of | 32 // Do not serve any events in the time between construction and destruction of |
| 33 // this class because it will cause flicker. | 33 // this class because it will cause flicker. |
| 34 class PrepareFrameAndViewForPrint { | 34 class PrepareFrameAndViewForPrint { |
| 35 public: | 35 public: |
| 36 PrepareFrameAndViewForPrint(const ViewMsg_Print_Params& print_params, | 36 PrepareFrameAndViewForPrint(const ViewMsg_Print_Params& print_params, |
| 37 WebFrame* frame, | 37 WebKit::WebFrame* frame, |
| 38 WebView* web_view); | 38 WebView* web_view); |
| 39 ~PrepareFrameAndViewForPrint(); | 39 ~PrepareFrameAndViewForPrint(); |
| 40 | 40 |
| 41 int GetExpectedPageCount() const { | 41 int GetExpectedPageCount() const { |
| 42 return expected_pages_count_; | 42 return expected_pages_count_; |
| 43 } | 43 } |
| 44 | 44 |
| 45 const gfx::Size& GetPrintCanvasSize() const { | 45 const gfx::Size& GetPrintCanvasSize() const { |
| 46 return print_canvas_size_; | 46 return print_canvas_size_; |
| 47 } | 47 } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 WebFrame* frame_; | 50 WebKit::WebFrame* frame_; |
| 51 WebView* web_view_; | 51 WebView* web_view_; |
| 52 gfx::Size print_canvas_size_; | 52 gfx::Size print_canvas_size_; |
| 53 gfx::Size prev_view_size_; | 53 gfx::Size prev_view_size_; |
| 54 int expected_pages_count_; | 54 int expected_pages_count_; |
| 55 | 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(PrepareFrameAndViewForPrint); | 56 DISALLOW_COPY_AND_ASSIGN(PrepareFrameAndViewForPrint); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 | 59 |
| 60 // PrintWebViewHelper handles most of the printing grunt work for RenderView. | 60 // PrintWebViewHelper handles most of the printing grunt work for RenderView. |
| 61 // We plan on making print asynchronous and that will require copying the DOM | 61 // We plan on making print asynchronous and that will require copying the DOM |
| 62 // of the document and creating a new WebView with the contents. | 62 // of the document and creating a new WebView with the contents. |
| 63 class PrintWebViewHelper : public WebViewDelegate { | 63 class PrintWebViewHelper : public WebViewDelegate { |
| 64 public: | 64 public: |
| 65 explicit PrintWebViewHelper(RenderView* render_view); | 65 explicit PrintWebViewHelper(RenderView* render_view); |
| 66 virtual ~PrintWebViewHelper(); | 66 virtual ~PrintWebViewHelper(); |
| 67 | 67 |
| 68 void Print(WebFrame* frame, bool script_initiated); | 68 void Print(WebKit::WebFrame* frame, bool script_initiated); |
| 69 | 69 |
| 70 // Is there a background print in progress? | 70 // Is there a background print in progress? |
| 71 bool IsPrinting() { | 71 bool IsPrinting() { |
| 72 return print_web_view_.get() != NULL; | 72 return print_web_view_.get() != NULL; |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Notification when printing is done - signal teardown | 75 // Notification when printing is done - signal teardown |
| 76 void DidFinishPrinting(bool success); | 76 void DidFinishPrinting(bool success); |
| 77 | 77 |
| 78 protected: | 78 protected: |
| 79 bool CopyAndPrint(const ViewMsg_PrintPages_Params& params, | 79 bool CopyAndPrint(const ViewMsg_PrintPages_Params& params, |
| 80 WebFrame* web_frame); | 80 WebKit::WebFrame* web_frame); |
| 81 | 81 |
| 82 // Prints the page listed in |params|. | 82 // Prints the page listed in |params|. |
| 83 void PrintPage(const ViewMsg_PrintPage_Params& params, | 83 void PrintPage(const ViewMsg_PrintPage_Params& params, |
| 84 const gfx::Size& canvas_size, | 84 const gfx::Size& canvas_size, |
| 85 WebFrame* frame); | 85 WebKit::WebFrame* frame); |
| 86 | 86 |
| 87 // Prints all the pages listed in |params|. | 87 // Prints all the pages listed in |params|. |
| 88 // It will implicitly revert the document to display CSS media type. | 88 // It will implicitly revert the document to display CSS media type. |
| 89 void PrintPages(const ViewMsg_PrintPages_Params& params, WebFrame* frame); | 89 void PrintPages(const ViewMsg_PrintPages_Params& params, |
| 90 WebKit::WebFrame* frame); |
| 90 | 91 |
| 91 // IPC::Message::Sender | 92 // IPC::Message::Sender |
| 92 bool Send(IPC::Message* msg); | 93 bool Send(IPC::Message* msg); |
| 93 | 94 |
| 94 int32 routing_id(); | 95 int32 routing_id(); |
| 95 | 96 |
| 96 // WebViewDeletegate | 97 // WebViewDeletegate |
| 97 virtual void didInvalidateRect(const WebKit::WebRect&) {} | 98 virtual void didInvalidateRect(const WebKit::WebRect&) {} |
| 98 virtual void didScrollRect(int dx, int dy, const WebKit::WebRect& clipRect) {} | 99 virtual void didScrollRect(int dx, int dy, const WebKit::WebRect& clipRect) {} |
| 99 virtual void didFocus() {} | 100 virtual void didFocus() {} |
| (...skipping 14 matching lines...) Expand all Loading... |
| 114 scoped_ptr<WebView> print_web_view_; | 115 scoped_ptr<WebView> print_web_view_; |
| 115 scoped_ptr<ViewMsg_PrintPages_Params> print_pages_params_; | 116 scoped_ptr<ViewMsg_PrintPages_Params> print_pages_params_; |
| 116 base::Time last_cancelled_script_print_; | 117 base::Time last_cancelled_script_print_; |
| 117 int user_cancelled_scripted_print_count_; | 118 int user_cancelled_scripted_print_count_; |
| 118 | 119 |
| 119 private: | 120 private: |
| 120 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 121 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
| 121 }; | 122 }; |
| 122 | 123 |
| 123 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_DELEGATE_H_ | 124 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_DELEGATE_H_ |
| OLD | NEW |