replace OVERRIDE and FINAL with override and final in ash/
[chromium-blink-merge.git] / chrome / browser / printing / print_view_manager.h
blobd07299b7a2b0097fa9ba94869c9adfc18f42ab20
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.
5 #ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
6 #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
8 #include "chrome/browser/printing/print_view_manager_base.h"
9 #include "content/public/browser/web_contents_user_data.h"
11 namespace content {
12 class RenderProcessHost;
15 namespace printing {
17 class PrintViewManagerObserver;
19 // Manages the print commands for a WebContents.
20 class PrintViewManager : public PrintViewManagerBase,
21 public content::WebContentsUserData<PrintViewManager> {
22 public:
23 virtual ~PrintViewManager();
25 #if !defined(DISABLE_BASIC_PRINTING)
26 // Same as PrintNow(), but for the case where a user prints with the system
27 // dialog from print preview.
28 bool PrintForSystemDialogNow();
30 // Same as PrintNow(), but for the case where a user press "ctrl+shift+p" to
31 // show the native system dialog. This can happen from both initiator and
32 // preview dialog.
33 bool BasicPrint();
34 #endif // !DISABLE_BASIC_PRINTING
36 // Initiate print preview of the current document by first notifying the
37 // renderer. Since this happens asynchronous, the print preview dialog
38 // creation will not be completed on the return of this function. Returns
39 // false if print preview is impossible at the moment.
40 bool PrintPreviewNow(bool selection_only);
42 // Notify PrintViewManager that print preview is starting in the renderer for
43 // a particular WebNode.
44 void PrintPreviewForWebNode();
46 // Notify PrintViewManager that print preview has finished. Unfreeze the
47 // renderer in the case of scripted print preview.
48 void PrintPreviewDone();
50 // Sets |observer| as the current PrintViewManagerObserver. Pass in NULL to
51 // remove the current observer. |observer| may always be NULL, but |observer_|
52 // must be NULL if |observer| is non-NULL.
53 void set_observer(PrintViewManagerObserver* observer);
55 // content::WebContentsObserver implementation.
56 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
58 // content::WebContentsObserver implementation.
59 // Terminates or cancels the print job if one was pending.
60 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
62 private:
63 explicit PrintViewManager(content::WebContents* web_contents);
64 friend class content::WebContentsUserData<PrintViewManager>;
66 enum PrintPreviewState {
67 NOT_PREVIEWING,
68 USER_INITIATED_PREVIEW,
69 SCRIPTED_PREVIEW,
72 // IPC Message handlers.
73 void OnDidShowPrintDialog();
74 void OnSetupScriptedPrintPreview(IPC::Message* reply_msg);
75 void OnShowScriptedPrintPreview(bool source_is_modifiable);
76 void OnScriptedPrintPreviewReply(IPC::Message* reply_msg);
78 // Weak pointer to an observer that is notified when the print dialog is
79 // shown.
80 PrintViewManagerObserver* observer_;
82 // Current state of print preview for this view.
83 PrintPreviewState print_preview_state_;
85 // Keeps track of the pending callback during scripted print preview.
86 content::RenderProcessHost* scripted_print_preview_rph_;
88 DISALLOW_COPY_AND_ASSIGN(PrintViewManager);
91 } // namespace printing
93 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_