blob: 529692c27f466105465c923e32189f118691f6a4 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2012 The Chromium Authors
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
Keishi Hattori0e45c022021-11-27 09:25:528#include "base/memory/raw_ptr.h"
Yuta Hijikatafd3ad1d2025-03-07 02:01:249#include "build/build_config.h"
[email protected]1e54c1c2013-08-12 17:16:0510#include "chrome/browser/printing/print_view_manager_base.h"
Gyuyoung Kimf9d551d2020-02-20 00:50:2111#include "components/printing/common/print.mojom-forward.h"
[email protected]46b3c982012-10-09 18:38:3012#include "content/public/browser/web_contents_user_data.h"
Julie Jeongeun Kim52b2da72019-11-20 00:02:3513#include "mojo/public/cpp/bindings/pending_associated_remote.h"
Scott Violet318a55f2018-03-30 19:08:1914#include "printing/buildflags/buildflags.h"
initial.commit09911bf2008-07-26 23:55:2915
[email protected]a9c36832011-11-23 08:55:2416namespace content {
thestigcb959ce2016-11-17 05:56:3217class RenderFrameHost;
[email protected]a9c36832011-11-23 08:55:2418class RenderProcessHost;
Lei Zhang60a3b182022-02-25 22:29:0319struct GlobalRenderFrameHostId;
[email protected]a9c36832011-11-23 08:55:2420}
21
initial.commit09911bf2008-07-26 23:55:2922namespace printing {
23
[email protected]e3a7e6f2012-09-18 22:44:3124// Manages the print commands for a WebContents.
[email protected]1e54c1c2013-08-12 17:16:0525class PrintViewManager : public PrintViewManagerBase,
[email protected]46b3c982012-10-09 18:38:3026 public content::WebContentsUserData<PrintViewManager> {
initial.commit09911bf2008-07-26 23:55:2927 public:
Peter Boström53c6c5952021-09-17 09:41:2628 PrintViewManager(const PrintViewManager&) = delete;
29 PrintViewManager& operator=(const PrintViewManager&) = delete;
30
dchengdf7e44a72014-10-21 23:50:1931 ~PrintViewManager() override;
initial.commit09911bf2008-07-26 23:55:2932
Robert Sesek926bda62021-08-10 20:59:4633 static void BindPrintManagerHost(
34 mojo::PendingAssociatedReceiver<mojom::PrintManagerHost> receiver,
35 content::RenderFrameHost* rfh);
36
[email protected]3121c76b2011-07-22 02:34:3237 // Same as PrintNow(), but for the case where a user prints with the system
38 // dialog from print preview.
Cuc Doan8c419232022-01-22 01:32:5139 // `dialog_shown_callback` is called when the print dialog is shown.
Lei Zhang3398fa52018-10-31 18:27:1140 bool PrintForSystemDialogNow(base::OnceClosure dialog_shown_callback);
[email protected]3121c76b2011-07-22 02:34:3241
[email protected]0996e9b2011-08-26 17:59:0142 // Same as PrintNow(), but for the case where a user press "ctrl+shift+p" to
[email protected]e6c97f6d2013-08-02 00:47:0543 // show the native system dialog. This can happen from both initiator and
[email protected]c248f5552013-01-26 01:58:4944 // preview dialog.
thestigcb959ce2016-11-17 05:56:3245 bool BasicPrint(content::RenderFrameHost* rfh);
[email protected]0996e9b2011-08-26 17:59:0146
Jesse Schettlerfd3df7e82019-09-16 23:23:1847 // Initiate print preview of the current document and specify whether a
48 // selection or the entire frame is being printed.
thestigcb959ce2016-11-17 05:56:3249 bool PrintPreviewNow(content::RenderFrameHost* rfh, bool has_selection);
[email protected]8980e0d2011-05-27 19:16:2350
Yuta Hijikatafd3ad1d2025-03-07 02:01:2451#if BUILDFLAG(IS_CHROMEOS)
Jesse Schettlerfd3df7e82019-09-16 23:23:1852 // Initiate print preview of the current document and provide the renderer
53 // a printing::mojom::PrintRenderer to perform the actual rendering of
54 // the print document.
55 bool PrintPreviewWithPrintRenderer(
56 content::RenderFrameHost* rfh,
Julie Jeongeun Kim52b2da72019-11-20 00:02:3557 mojo::PendingAssociatedRemote<mojom::PrintRenderer> print_renderer);
Lei Zhangbe4236bc2023-04-27 18:54:0858#endif
Jesse Schettlerfd3df7e82019-09-16 23:23:1859
Lei Zhang862c6f57a2023-06-16 21:44:2860 // Initiate print preview for the node under the context menu.
61 void PrintPreviewForNodeUnderContextMenu(content::RenderFrameHost* rfh);
[email protected]9a26bb22012-01-24 23:50:2562
Lei Zhang218f742d02019-03-05 05:18:4063 // Notify PrintViewManager that print preview is about to finish. Unblock the
64 // renderer in the case of scripted print preview if needed.
65 void PrintPreviewAlmostDone();
66
67 // Notify PrintViewManager that print preview has finished. Unblock the
68 // renderer in the case of scripted print preview if needed.
[email protected]a9c36832011-11-23 08:55:2469 void PrintPreviewDone();
70
Julie Jeongeun Kima75e43f2020-08-25 07:21:3271 // mojom::PrintManagerHost:
72 void DidShowPrintDialog() override;
Julie Jeongeun Kimac7fed62021-01-22 08:01:2173 void SetupScriptedPrintPreview(
74 SetupScriptedPrintPreviewCallback callback) override;
Julie Jeongeun Kimec9f86b2020-12-08 03:32:3575 void ShowScriptedPrintPreview(bool source_is_modifiable) override;
Julie Jeongeun Kim514a77b2021-01-07 06:05:0376 void RequestPrintPreview(mojom::RequestPrintPreviewParamsPtr params) override;
Julie Jeongeun Kimbe7f41242021-01-21 14:48:3677 void CheckForCancel(int32_t preview_ui_id,
78 int32_t request_id,
79 CheckForCancelCallback callback) override;
Julie Jeongeun Kima75e43f2020-08-25 07:21:3280
[email protected]08ad9572012-07-26 21:03:3981 // content::WebContentsObserver implementation.
thestigcb959ce2016-11-17 05:56:3282 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
sgurun356feed52016-11-16 16:13:0683
thestigcb959ce2016-11-17 05:56:3284 content::RenderFrameHost* print_preview_rfh() { return print_preview_rfh_; }
[email protected]2e3f4572011-03-25 19:24:4785
Robert Sesek926bda62021-08-10 20:59:4686 // Sets the target object for BindPrintManagerHost() for tests.
87 static void SetReceiverImplForTesting(PrintManager* impl);
88
rbpotterfdff0672018-04-12 20:46:5889 protected:
[email protected]e3a7e6f2012-09-18 22:44:3190 explicit PrintViewManager(content::WebContents* web_contents);
rbpotterfdff0672018-04-12 20:46:5891
92 private: