Chromium Code Reviews| 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_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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "content/browser/tab_contents/tab_contents_observer.h" | 9 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 10 | 10 |
| 11 class TabContentsWrapper; | |
| 11 struct PrintHostMsg_DidGetPreviewPageCount_Params; | 12 struct PrintHostMsg_DidGetPreviewPageCount_Params; |
| 12 struct PrintHostMsg_DidPreviewDocument_Params; | 13 struct PrintHostMsg_DidPreviewDocument_Params; |
| 13 struct PrintHostMsg_DidPreviewPage_Params; | 14 struct PrintHostMsg_DidPreviewPage_Params; |
| 14 | 15 |
| 15 namespace printing { | 16 namespace printing { |
| 16 | 17 |
| 17 struct PageSizeMargins; | 18 struct PageSizeMargins; |
| 18 | 19 |
| 19 // TabContents offloads print preview message handling to | 20 // TabContents offloads print preview message handling to |
| 20 // PrintPreviewMessageHandler. This object has the same life time as the | 21 // PrintPreviewMessageHandler. This object has the same life time as the |
| 21 // TabContents that owns it. | 22 // TabContents that owns it. |
| 22 class PrintPreviewMessageHandler : public TabContentsObserver { | 23 class PrintPreviewMessageHandler : public TabContentsObserver { |
| 23 public: | 24 public: |
| 24 explicit PrintPreviewMessageHandler(TabContents* tab_contents); | 25 explicit PrintPreviewMessageHandler(TabContents* tab_contents); |
| 25 virtual ~PrintPreviewMessageHandler(); | 26 virtual ~PrintPreviewMessageHandler(); |
| 26 | 27 |
| 27 // TabContentsObserver implementation. | 28 // TabContentsObserver implementation. |
| 28 virtual bool OnMessageReceived(const IPC::Message& message); | 29 virtual bool OnMessageReceived(const IPC::Message& message); |
| 29 virtual void DidStartLoading(); | 30 virtual void DidStartLoading(); |
| 30 | 31 |
| 31 private: | 32 private: |
| 32 // Gets the print preview tab associated with the TabContents being observed. | 33 // Gets the print preview tab associated with the TabContents being observed. |
| 33 TabContents* GetPrintPreviewTab(); | 34 TabContentsWrapper* GetPrintPreviewTab(); |
| 35 // Helper function to return the TabContentsWrapper for tab_contents(). | |
|
kmadhusu
2011/08/30 21:00:01
nit: Add a blank line before this.
| |
| 36 TabContentsWrapper* tab_contents_wrapper(); | |
| 34 | 37 |
| 35 // Message handlers. | 38 // Message handlers. |
| 36 void OnRequestPrintPreview(); | 39 void OnRequestPrintPreview(); |
| 37 void OnDidGetDefaultPageLayout( | 40 void OnDidGetDefaultPageLayout( |
| 38 const printing::PageSizeMargins& page_layout_in_points); | 41 const printing::PageSizeMargins& page_layout_in_points); |
| 39 void OnDidGetPreviewPageCount( | 42 void OnDidGetPreviewPageCount( |
| 40 const PrintHostMsg_DidGetPreviewPageCount_Params& params); | 43 const PrintHostMsg_DidGetPreviewPageCount_Params& params); |
| 41 void OnDidPreviewPage(const PrintHostMsg_DidPreviewPage_Params& params); | 44 void OnDidPreviewPage(const PrintHostMsg_DidPreviewPage_Params& params); |
| 42 void OnPagesReadyForPreview( | 45 void OnPagesReadyForPreview( |
| 43 const PrintHostMsg_DidPreviewDocument_Params& params); | 46 const PrintHostMsg_DidPreviewDocument_Params& params); |
| 44 void OnPrintPreviewFailed(int document_cookie); | 47 void OnPrintPreviewFailed(int document_cookie); |
| 45 void OnPrintPreviewCancelled(int document_cookie); | 48 void OnPrintPreviewCancelled(int document_cookie); |
| 46 | 49 |
| 47 DISALLOW_COPY_AND_ASSIGN(PrintPreviewMessageHandler); | 50 DISALLOW_COPY_AND_ASSIGN(PrintPreviewMessageHandler); |
| 48 }; | 51 }; |
| 49 | 52 |
| 50 } // namespace printing | 53 } // namespace printing |
| 51 | 54 |
| 52 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_ | 55 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_ |
| OLD | NEW |