blob: f3572c43e6b31ad0cdc8ccae8ab171b60bc32672 [file] [log] [blame]
[email protected]9a26bb22012-01-24 23:50:251// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]bfd04a62009-02-01 18:16:565#ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
6#define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
initial.commit09911bf2008-07-26 23:55:297
avib896c712015-12-26 02:10:438#include "base/macros.h"
[email protected]1e54c1c2013-08-12 17:16:059#include "chrome/browser/printing/print_view_manager_base.h"
[email protected]46b3c982012-10-09 18:38:3010#include "content/public/browser/web_contents_user_data.h"
Brett Wilson65f951c2016-11-03 22:06:1211#include "printing/features/features.h"
initial.commit09911bf2008-07-26 23:55:2912
[email protected]a9c36832011-11-23 08:55:2413namespace content {
thestigcb959ce2016-11-17 05:56:3214class RenderFrameHost;
[email protected]a9c36832011-11-23 08:55:2415class RenderProcessHost;
16}
17
initial.commit09911bf2008-07-26 23:55:2918namespace printing {
19
[email protected]e3a7e6f2012-09-18 22:44:3120// Manages the print commands for a WebContents.
[email protected]1e54c1c2013-08-12 17:16:0521class PrintViewManager : public PrintViewManagerBase,
[email protected]46b3c982012-10-09 18:38:3022 public content::WebContentsUserData<PrintViewManager> {
initial.commit09911bf2008-07-26 23:55:2923 public:
dchengdf7e44a72014-10-21 23:50:1924 ~PrintViewManager() override;
initial.commit09911bf2008-07-26 23:55:2925
Brett Wilson65f951c2016-11-03 22:06:1226#if BUILDFLAG(ENABLE_BASIC_PRINTING)
[email protected]3121c76b2011-07-22 02:34:3227 // Same as PrintNow(), but for the case where a user prints with the system
28 // dialog from print preview.
thestigf8117202016-02-26 19:05:1429 // |dialog_shown_callback| is called when the print dialog is shown.
30 bool PrintForSystemDialogNow(const base::Closure& dialog_shown_callback);
[email protected]3121c76b2011-07-22 02:34:3231
[email protected]0996e9b2011-08-26 17:59:0132 // Same as PrintNow(), but for the case where a user press "ctrl+shift+p" to
[email protected]e6c97f6d2013-08-02 00:47:0533 // show the native system dialog. This can happen from both initiator and
[email protected]c248f5552013-01-26 01:58:4934 // preview dialog.
thestigcb959ce2016-11-17 05:56:3235 bool BasicPrint(content::RenderFrameHost* rfh);
vitalybukae29991c2014-11-05 21:15:1236#endif // ENABLE_BASIC_PRINTING
[email protected]0996e9b2011-08-26 17:59:0137
[email protected]8980e0d2011-05-27 19:16:2338 // Initiate print preview of the current document by first notifying the
[email protected]c248f5552013-01-26 01:58:4939 // renderer. Since this happens asynchronous, the print preview dialog
40 // creation will not be completed on the return of this function. Returns
41 // false if print preview is impossible at the moment.
thestigcb959ce2016-11-17 05:56:3242 bool PrintPreviewNow(content::RenderFrameHost* rfh, bool has_selection);
[email protected]8980e0d2011-05-27 19:16:2343
[email protected]9a26bb22012-01-24 23:50:2544 // Notify PrintViewManager that print preview is starting in the renderer for
45 // a particular WebNode.
thestig46657562016-11-21 21:35:2246 void PrintPreviewForWebNode(content::RenderFrameHost* rfh);
[email protected]9a26bb22012-01-24 23:50:2547
[email protected]a9c36832011-11-23 08:55:2448 // Notify PrintViewManager that print preview has finished. Unfreeze the
49 // renderer in the case of scripted print preview.
50 void PrintPreviewDone();
51
[email protected]08ad9572012-07-26 21:03:3952 // content::WebContentsObserver implementation.
sgurun356feed52016-11-16 16:13:0653 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
thestigcb959ce2016-11-17 05:56:3254 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
55 bool OnMessageReceived(const IPC::Message& message,
56 content::RenderFrameHost* render_frame_host) override;
sgurun356feed52016-11-16 16:13:0657
thestigcb959ce2016-11-17 05:56:3258 content::RenderFrameHost* print_preview_rfh() { return print_preview_rfh_; }
[email protected]2e3f4572011-03-25 19:24:4759
initial.commit09911bf2008-07-26 23:55:2960 private:
[email protected]e3a7e6f2012-09-18 22:44:3161 explicit PrintViewManager(content::WebContents* web_contents);
[email protected]46b3c982012-10-09 18:38:3062 friend class content::WebContentsUserData<PrintViewManager>;
[email protected]e3a7e6f2012-09-18 22:44:3163
[email protected]a9c36832011-11-23 08:55:2464 enum PrintPreviewState {
65 NOT_PREVIEWING,
66 USER_INITIATED_PREVIEW,
67 SCRIPTED_PREVIEW,
68 };
69
[email protected]b3ee0b522011-05-06 04:06:4070 // IPC Message handlers.
thestigcb959ce2016-11-17 05:56:3271 void OnDidShowPrintDialog(content::RenderFrameHost* rfh);
72 void OnSetupScriptedPrintPreview(content::RenderFrameHost* rfh,
73 IPC::Message* reply_msg);
74 void OnShowScriptedPrintPreview(content::RenderFrameHost* rfh,
75 bool source_is_modifiable);
[email protected]a9c36832011-11-23 08:55:2476 void OnScriptedPrintPreviewReply(IPC::Message* reply_msg);
77
thestigf8117202016-02-26 19:05:1478 base::Closure on_print_dialog_shown_callback_;
[email protected]0b481bf2011-06-29 20:33:0079
[email protected]a9c36832011-11-23 08:55:2480 // Current state of print preview for this view.
81 PrintPreviewState print_preview_state_;
82
thestigcb959ce2016-11-17 05:56:3283 // The current RFH that is print previewing. It should be a nullptr when
84 // |print_preview_state_| is NOT_PREVIEWING.
85 content::RenderFrameHost* print_preview_rfh_;
86
[email protected]a9c36832011-11-23 08:55:2487 // Keeps track of the pending callback during scripted print preview.
88 content::RenderProcessHost* scripted_print_preview_rph_;
89
[email protected]bfd04a62009-02-01 18:16:5690 DISALLOW_COPY_AND_ASSIGN(PrintViewManager);
initial.commit09911bf2008-07-26 23:55:2991};
92
93} // namespace printing
94
[email protected]bfd04a62009-02-01 18:16:5695#endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_