• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_
6 #define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_
7 
8 #include "base/compiler_specific.h"
9 #include "content/public/browser/web_contents_observer.h"
10 #include "content/public/browser/web_contents_user_data.h"
11 
12 class PrintPreviewUI;
13 struct PrintHostMsg_DidGetPreviewPageCount_Params;
14 struct PrintHostMsg_DidPreviewDocument_Params;
15 struct PrintHostMsg_DidPreviewPage_Params;
16 struct PrintHostMsg_RequestPrintPreview_Params;
17 
18 namespace content {
19 class WebContents;
20 }
21 
22 namespace gfx {
23 class Rect;
24 }
25 
26 namespace printing {
27 
28 struct PageSizeMargins;
29 
30 // Manages the print preview handling for a WebContents.
31 class PrintPreviewMessageHandler
32     : public content::WebContentsObserver,
33       public content::WebContentsUserData<PrintPreviewMessageHandler> {
34  public:
35   virtual ~PrintPreviewMessageHandler();
36 
37   // content::WebContentsObserver implementation.
38   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
39 
40  private:
41   explicit PrintPreviewMessageHandler(content::WebContents* web_contents);
42   friend class content::WebContentsUserData<PrintPreviewMessageHandler>;
43 
44   // Gets the print preview dialog associated with the WebContents being
45   // observed.
46   content::WebContents* GetPrintPreviewDialog();
47 
48   // Gets the PrintPreviewUI associated with the WebContents being observed.
49   PrintPreviewUI* GetPrintPreviewUI();
50 
51   // Message handlers.
52   void OnRequestPrintPreview(
53       const PrintHostMsg_RequestPrintPreview_Params& params);
54   void OnDidGetDefaultPageLayout(
55       const printing::PageSizeMargins& page_layout_in_points,
56       const gfx::Rect& printable_area_in_points,
57       bool has_custom_page_size_style);
58   void OnDidGetPreviewPageCount(
59       const PrintHostMsg_DidGetPreviewPageCount_Params& params);
60   void OnDidPreviewPage(const PrintHostMsg_DidPreviewPage_Params& params);
61   void OnMetafileReadyForPrinting(
62       const PrintHostMsg_DidPreviewDocument_Params& params);
63   void OnPrintPreviewFailed(int document_cookie);
64   void OnPrintPreviewCancelled(int document_cookie);
65   void OnInvalidPrinterSettings(int document_cookie);
66   void OnPrintPreviewScalingDisabled();
67 
68   DISALLOW_COPY_AND_ASSIGN(PrintPreviewMessageHandler);
69 };
70 
71 }  // namespace printing
72 
73 #endif  // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_
74