Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / printing / print_view_manager.h
blob333fb6a29c364b4a745062108ba89f61aad6ec3b
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 // Same as PrintNow(), but for the case where a user prints with the system
26 // dialog from print preview.
27 bool PrintForSystemDialogNow();
29 // Same as PrintNow(), but for the case where a user press "ctrl+shift+p" to
30 // show the native system dialog. This can happen from both initiator and
31 // preview dialog.
32 bool AdvancedPrintNow();
34 // Same as PrintNow(), but for the case where we want to send the result to
35 // another destination.
36 // TODO(mad) Add an argument so we can pass the destination interface.
37 bool PrintToDestination();
39 // Initiate print preview of the current document by first notifying the
40 // renderer. Since this happens asynchronous, the print preview dialog
41 // creation will not be completed on the return of this function. Returns
42 // false if print preview is impossible at the moment.
43 bool PrintPreviewNow(bool selection_only);
45 // Notify PrintViewManager that print preview is starting in the renderer for
46 // a particular WebNode.
47 void PrintPreviewForWebNode();
49 // Notify PrintViewManager that print preview has finished. Unfreeze the
50 // renderer in the case of scripted print preview.
51 void PrintPreviewDone();
53 // Sets |observer| as the current PrintViewManagerObserver. Pass in NULL to
54 // remove the current observer. |observer| may always be NULL, but |observer_|
55 // must be NULL if |observer| is non-NULL.
56 void set_observer(PrintViewManagerObserver* observer);
58 // content::WebContentsObserver implementation.
59 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
61 // content::WebContentsObserver implementation.
62 // Terminates or cancels the print job if one was pending.
63 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
65 private:
66 explicit PrintViewManager(content::WebContents* web_contents);
67 friend class content::WebContentsUserData<PrintViewManager>;
69 enum PrintPreviewState {
70 NOT_PREVIEWING,
71 USER_INITIATED_PREVIEW,
72 SCRIPTED_PREVIEW,
75 // IPC Message handlers.
76 void OnDidShowPrintDialog();
77 void OnSetupScriptedPrintPreview(IPC::Message* reply_msg);
78 void OnShowScriptedPrintPreview(bool source_is_modifiable);
79 void OnScriptedPrintPreviewReply(IPC::Message* reply_msg);
81 // Weak pointer to an observer that is notified when the print dialog is
82 // shown.
83 PrintViewManagerObserver* observer_;
85 // Current state of print preview for this view.
86 PrintPreviewState print_preview_state_;
88 // Keeps track of the pending callback during scripted print preview.
89 content::RenderProcessHost* scripted_print_preview_rph_;
91 DISALLOW_COPY_AND_ASSIGN(PrintViewManager);
94 } // namespace printing
96 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_