| 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_BROWSER_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_ |
| 6 #define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_ | 6 #define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
| 11 #include "content/public/browser/web_contents_user_data.h" | 11 #include "content/public/browser/web_contents_user_data.h" |
| 12 #include "mojo/public/cpp/system/buffer.h" |
| 12 | 13 |
| 13 class PrintPreviewUI; | 14 class PrintPreviewUI; |
| 14 struct PrintHostMsg_DidGetPreviewPageCount_Params; | 15 struct PrintHostMsg_DidGetPreviewPageCount_Params; |
| 15 struct PrintHostMsg_DidPreviewDocument_Params; | 16 struct PrintHostMsg_DidPreviewDocument_Params; |
| 16 struct PrintHostMsg_DidPreviewPage_Params; | 17 struct PrintHostMsg_DidPreviewPage_Params; |
| 17 struct PrintHostMsg_RequestPrintPreview_Params; | 18 struct PrintHostMsg_RequestPrintPreview_Params; |
| 18 struct PrintHostMsg_SetOptionsFromDocument_Params; | 19 struct PrintHostMsg_SetOptionsFromDocument_Params; |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 class RenderFrameHost; | 22 class RenderFrameHost; |
| 22 class WebContents; | 23 class WebContents; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace gfx { | 26 namespace gfx { |
| 26 class Rect; | 27 class Rect; |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace printing { | 30 namespace printing { |
| 30 | 31 |
| 32 class PrintCompositeClient; |
| 31 struct PageSizeMargins; | 33 struct PageSizeMargins; |
| 32 | 34 |
| 33 // Manages the print preview handling for a WebContents. | 35 // Manages the print preview handling for a WebContents. |
| 34 class PrintPreviewMessageHandler | 36 class PrintPreviewMessageHandler |
| 35 : public content::WebContentsObserver, | 37 : public content::WebContentsObserver, |
| 36 public content::WebContentsUserData<PrintPreviewMessageHandler> { | 38 public content::WebContentsUserData<PrintPreviewMessageHandler> { |
| 37 public: | 39 public: |
| 38 ~PrintPreviewMessageHandler() override; | 40 ~PrintPreviewMessageHandler() override; |
| 39 | 41 |
| 40 // content::WebContentsObserver implementation. | 42 // content::WebContentsObserver implementation. |
| 41 bool OnMessageReceived(const IPC::Message& message, | 43 bool OnMessageReceived(const IPC::Message& message, |
| 42 content::RenderFrameHost* render_frame_host) override; | 44 content::RenderFrameHost* render_frame_host) override; |
| 43 | 45 |
| 46 void OnCompositePdfPageDone(int page_number, |
| 47 int request_id, |
| 48 mojo::ScopedSharedBufferHandle handle); |
| 49 |
| 50 void OnCompositePdfDocumentDone(int page_count, |
| 51 int request_id, |
| 52 mojo::ScopedSharedBufferHandle handle); |
| 53 |
| 44 private: | 54 private: |
| 45 explicit PrintPreviewMessageHandler(content::WebContents* web_contents); | 55 explicit PrintPreviewMessageHandler(content::WebContents* web_contents); |
| 46 friend class content::WebContentsUserData<PrintPreviewMessageHandler>; | 56 friend class content::WebContentsUserData<PrintPreviewMessageHandler>; |
| 47 | 57 |
| 48 // Gets the print preview dialog associated with the WebContents being | 58 // Gets the print preview dialog associated with the WebContents being |
| 49 // observed. | 59 // observed. |
| 50 content::WebContents* GetPrintPreviewDialog(); | 60 content::WebContents* GetPrintPreviewDialog(); |
| 51 | 61 |
| 52 // Gets the PrintPreviewUI associated with the WebContents being observed. | 62 // Gets the PrintPreviewUI associated with the WebContents being observed. |
| 53 PrintPreviewUI* GetPrintPreviewUI(); | 63 PrintPreviewUI* GetPrintPreviewUI(); |
| 54 | 64 |
| 55 // Message handlers. | 65 // Message handlers. |
| 56 void OnRequestPrintPreview( | 66 void OnRequestPrintPreview( |
| 57 content::RenderFrameHost* render_frame_host, | 67 content::RenderFrameHost* render_frame_host, |
| 58 const PrintHostMsg_RequestPrintPreview_Params& params); | 68 const PrintHostMsg_RequestPrintPreview_Params& params); |
| 59 void OnDidGetDefaultPageLayout(const PageSizeMargins& page_layout_in_points, | 69 void OnDidGetDefaultPageLayout(const PageSizeMargins& page_layout_in_points, |
| 60 const gfx::Rect& printable_area_in_points, | 70 const gfx::Rect& printable_area_in_points, |
| 61 bool has_custom_page_size_style); | 71 bool has_custom_page_size_style); |
| 62 void OnDidGetPreviewPageCount( | 72 void OnDidGetPreviewPageCount( |
| 63 const PrintHostMsg_DidGetPreviewPageCount_Params& params); | 73 const PrintHostMsg_DidGetPreviewPageCount_Params& params); |
| 64 void OnDidPreviewPage(const PrintHostMsg_DidPreviewPage_Params& params); | 74 void OnDidPreviewPage(content::RenderFrameHost* render_frame_host, |
| 75 const PrintHostMsg_DidPreviewPage_Params& params); |
| 65 void OnMetafileReadyForPrinting( | 76 void OnMetafileReadyForPrinting( |
| 77 content::RenderFrameHost* render_frame_host, |
| 66 const PrintHostMsg_DidPreviewDocument_Params& params); | 78 const PrintHostMsg_DidPreviewDocument_Params& params); |
| 67 void OnPrintPreviewFailed(int document_cookie); | 79 void OnPrintPreviewFailed(int document_cookie); |
| 68 void OnPrintPreviewCancelled(int document_cookie); | 80 void OnPrintPreviewCancelled(int document_cookie); |
| 69 void OnInvalidPrinterSettings(int document_cookie); | 81 void OnInvalidPrinterSettings(int document_cookie); |
| 70 void OnSetOptionsFromDocument( | 82 void OnSetOptionsFromDocument( |
| 71 const PrintHostMsg_SetOptionsFromDocument_Params& params); | 83 const PrintHostMsg_SetOptionsFromDocument_Params& params); |
| 72 | 84 |
| 85 PrintCompositeClient* composite_client_; |
| 86 |
| 73 DISALLOW_COPY_AND_ASSIGN(PrintPreviewMessageHandler); | 87 DISALLOW_COPY_AND_ASSIGN(PrintPreviewMessageHandler); |
| 74 }; | 88 }; |
| 75 | 89 |
| 76 } // namespace printing | 90 } // namespace printing |
| 77 | 91 |
| 78 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_ | 92 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_ |
| OLD | NEW |