Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / printing / print_preview_message_handler.h
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 struct PrintHostMsg_SetOptionsFromDocument_Params;
18
19 namespace content {
20 class WebContents;
21 }
22
23 namespace gfx {
24 class Rect;
25 }
26
27 namespace printing {
28
29 struct PageSizeMargins;
30
31 // Manages the print preview handling for a WebContents.
32 class PrintPreviewMessageHandler
33     : public content::WebContentsObserver,
34       public content::WebContentsUserData<PrintPreviewMessageHandler> {
35  public:
36   ~PrintPreviewMessageHandler() override;
37
38   // content::WebContentsObserver implementation.
39   bool OnMessageReceived(const IPC::Message& message) override;
40
41  private:
42   explicit PrintPreviewMessageHandler(content::WebContents* web_contents);
43   friend class content::WebContentsUserData<PrintPreviewMessageHandler>;
44
45   // Gets the print preview dialog associated with the WebContents being
46   // observed.
47   content::WebContents* GetPrintPreviewDialog();
48
49   // Gets the PrintPreviewUI associated with the WebContents being observed.
50   PrintPreviewUI* GetPrintPreviewUI();
51
52   // Message handlers.
53   void OnRequestPrintPreview(
54       const PrintHostMsg_RequestPrintPreview_Params& params);
55   void OnDidGetDefaultPageLayout(
56       const printing::PageSizeMargins& page_layout_in_points,
57       const gfx::Rect& printable_area_in_points,
58       bool has_custom_page_size_style);
59   void OnDidGetPreviewPageCount(
60       const PrintHostMsg_DidGetPreviewPageCount_Params& params);
61   void OnDidPreviewPage(const PrintHostMsg_DidPreviewPage_Params& params);
62   void OnMetafileReadyForPrinting(
63       const PrintHostMsg_DidPreviewDocument_Params& params);
64   void OnPrintPreviewFailed(int document_cookie);
65   void OnPrintPreviewCancelled(int document_cookie);
66   void OnInvalidPrinterSettings(int document_cookie);
67   void OnSetOptionsFromDocument(
68       const PrintHostMsg_SetOptionsFromDocument_Params& params);
69
70   DISALLOW_COPY_AND_ASSIGN(PrintPreviewMessageHandler);
71 };
72
73 }  // namespace printing
74
75 #endif  // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_