Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | bfd04a6 | 2009-02-01 18:16:56 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ |
6 | #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 8 | #include "base/memory/raw_ptr.h" |
Yuta Hijikata | fd3ad1d | 2025-03-07 02:01:24 | [diff] [blame] | 9 | #include "build/build_config.h" |
[email protected] | 1e54c1c | 2013-08-12 17:16:05 | [diff] [blame] | 10 | #include "chrome/browser/printing/print_view_manager_base.h" |
Gyuyoung Kim | f9d551d | 2020-02-20 00:50:21 | [diff] [blame] | 11 | #include "components/printing/common/print.mojom-forward.h" |
[email protected] | 46b3c98 | 2012-10-09 18:38:30 | [diff] [blame] | 12 | #include "content/public/browser/web_contents_user_data.h" |
Julie Jeongeun Kim | 52b2da7 | 2019-11-20 00:02:35 | [diff] [blame] | 13 | #include "mojo/public/cpp/bindings/pending_associated_remote.h" |
Scott Violet | 318a55f | 2018-03-30 19:08:19 | [diff] [blame] | 14 | #include "printing/buildflags/buildflags.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 15 | |
[email protected] | a9c3683 | 2011-11-23 08:55:24 | [diff] [blame] | 16 | namespace content { |
thestig | cb959ce | 2016-11-17 05:56:32 | [diff] [blame] | 17 | class RenderFrameHost; |
[email protected] | a9c3683 | 2011-11-23 08:55:24 | [diff] [blame] | 18 | class RenderProcessHost; |
Lei Zhang | 60a3b18 | 2022-02-25 22:29:03 | [diff] [blame] | 19 | struct GlobalRenderFrameHostId; |
[email protected] | a9c3683 | 2011-11-23 08:55:24 | [diff] [blame] | 20 | } |
21 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 22 | namespace printing { |
23 | |||||
[email protected] | e3a7e6f | 2012-09-18 22:44:31 | [diff] [blame] | 24 | // Manages the print commands for a WebContents. |
[email protected] | 1e54c1c | 2013-08-12 17:16:05 | [diff] [blame] | 25 | class PrintViewManager : public PrintViewManagerBase, |
[email protected] | 46b3c98 | 2012-10-09 18:38:30 | [diff] [blame] | 26 | public content::WebContentsUserData<PrintViewManager> { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 27 | public: |
Peter Boström | 53c6c595 | 2021-09-17 09:41:26 | [diff] [blame] | 28 | PrintViewManager(const PrintViewManager&) = delete; |
29 | PrintViewManager& operator=(const PrintViewManager&) = delete; | ||||
30 | |||||
dcheng | df7e44a7 | 2014-10-21 23:50:19 | [diff] [blame] | 31 | ~PrintViewManager() override; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 32 | |
Robert Sesek | 926bda6 | 2021-08-10 20:59:46 | [diff] [blame] | 33 | static void BindPrintManagerHost( |
34 | mojo::PendingAssociatedReceiver<mojom::PrintManagerHost> receiver, | ||||
35 | content::RenderFrameHost* rfh); | ||||
36 | |||||
[email protected] | 3121c76b | 2011-07-22 02:34:32 | [diff] [blame] | 37 | // Same as PrintNow(), but for the case where a user prints with the system |
38 | // dialog from print preview. | ||||
Cuc Doan | 8c41923 | 2022-01-22 01:32:51 | [diff] [blame] | 39 | // `dialog_shown_callback` is called when the print dialog is shown. |
Lei Zhang | 3398fa5 | 2018-10-31 18:27:11 | [diff] [blame] | 40 | bool PrintForSystemDialogNow(base::OnceClosure dialog_shown_callback); |
[email protected] | 3121c76b | 2011-07-22 02:34:32 | [diff] [blame] | 41 | |
[email protected] | 0996e9b | 2011-08-26 17:59:01 | [diff] [blame] | 42 | // Same as PrintNow(), but for the case where a user press "ctrl+shift+p" to |
[email protected] | e6c97f6d | 2013-08-02 00:47:05 | [diff] [blame] | 43 | // show the native system dialog. This can happen from both initiator and |
[email protected] | c248f555 | 2013-01-26 01:58:49 | [diff] [blame] | 44 | // preview dialog. |
thestig | cb959ce | 2016-11-17 05:56:32 | [diff] [blame] | 45 | bool BasicPrint(content::RenderFrameHost* rfh); |
[email protected] | 0996e9b | 2011-08-26 17:59:01 | [diff] [blame] | 46 | |
Jesse Schettler | fd3df7e8 | 2019-09-16 23:23:18 | [diff] [blame] | 47 | // Initiate print preview of the current document and specify whether a |
48 | // selection or the entire frame is being printed. | ||||
thestig | cb959ce | 2016-11-17 05:56:32 | [diff] [blame] | 49 | bool PrintPreviewNow(content::RenderFrameHost* rfh, bool has_selection); |
[email protected] | 8980e0d | 2011-05-27 19:16:23 | [diff] [blame] | 50 | |
Yuta Hijikata | fd3ad1d | 2025-03-07 02:01:24 | [diff] [blame] | 51 | #if BUILDFLAG(IS_CHROMEOS) |
Jesse Schettler | fd3df7e8 | 2019-09-16 23:23:18 | [diff] [blame] | 52 | // 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 Kim | 52b2da7 | 2019-11-20 00:02:35 | [diff] [blame] | 57 | mojo::PendingAssociatedRemote<mojom::PrintRenderer> print_renderer); |
Lei Zhang | be4236bc | 2023-04-27 18:54:08 | [diff] [blame] | 58 | #endif |
Jesse Schettler | fd3df7e8 | 2019-09-16 23:23:18 | [diff] [blame] | 59 | |
Lei Zhang | 862c6f57a | 2023-06-16 21:44:28 | [diff] [blame] | 60 | // Initiate print preview for the node under the context menu. |
61 | void PrintPreviewForNodeUnderContextMenu(content::RenderFrameHost* rfh); | ||||
[email protected] | 9a26bb2 | 2012-01-24 23:50:25 | [diff] [blame] | 62 | |
Lei Zhang | 218f742d0 | 2019-03-05 05:18:40 | [diff] [blame] | 63 | // 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] | a9c3683 | 2011-11-23 08:55:24 | [diff] [blame] | 69 | void PrintPreviewDone(); |
70 | |||||
Julie Jeongeun Kim | a75e43f | 2020-08-25 07:21:32 | [diff] [blame] | 71 | // mojom::PrintManagerHost: |
72 | void DidShowPrintDialog() override; | ||||
Julie Jeongeun Kim | ac7fed6 | 2021-01-22 08:01:21 | [diff] [blame] | 73 | void SetupScriptedPrintPreview( |
74 | SetupScriptedPrintPreviewCallback callback) override; | ||||
Julie Jeongeun Kim | ec9f86b | 2020-12-08 03:32:35 | [diff] [blame] | 75 | void ShowScriptedPrintPreview(bool source_is_modifiable) override; |
Julie Jeongeun Kim | 514a77b | 2021-01-07 06:05:03 | [diff] [blame] | 76 | void RequestPrintPreview(mojom::RequestPrintPreviewParamsPtr params) override; |
Julie Jeongeun Kim | be7f4124 | 2021-01-21 14:48:36 | [diff] [blame] | 77 | void CheckForCancel(int32_t preview_ui_id, |
78 | int32_t request_id, | ||||
79 | CheckForCancelCallback callback) override; | ||||
Julie Jeongeun Kim | a75e43f | 2020-08-25 07:21:32 | [diff] [blame] | 80 | |
[email protected] | 08ad957 | 2012-07-26 21:03:39 | [diff] [blame] | 81 | // content::WebContentsObserver implementation. |
thestig | cb959ce | 2016-11-17 05:56:32 | [diff] [blame] | 82 | void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; |
sgurun | 356feed5 | 2016-11-16 16:13:06 | [diff] [blame] | 83 | |
thestig | cb959ce | 2016-11-17 05:56:32 | [diff] [blame] | 84 | content::RenderFrameHost* print_preview_rfh() { return print_preview_rfh_; } |
[email protected] | 2e3f457 | 2011-03-25 19:24:47 | [diff] [blame] | 85 | |
Robert Sesek | 926bda6 | 2021-08-10 20:59:46 | [diff] [blame] | 86 | // Sets the target object for BindPrintManagerHost() for tests. |
87 | static void SetReceiverImplForTesting(PrintManager* impl); | ||||
88 | |||||
rbpotter | fdff067 | 2018-04-12 20:46:58 | [diff] [blame] | 89 | protected: |
[email protected] | e3a7e6f | 2012-09-18 22:44:31 | [diff] [blame] | 90 | explicit PrintViewManager(content::WebContents* web_contents); |
rbpotter | fdff067 | 2018-04-12 20:46:58 | [diff] [blame] | 91 | |
92 | private: | ||||