[email protected] | d53002f4 | 2014-01-14 16:08:56 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | d53002f4 | 2014-01-14 16:08:56 | [diff] [blame] | 5 | #ifndef PRINTING_PRINTING_CONTEXT_LINUX_H_ |
6 | #define PRINTING_PRINTING_CONTEXT_LINUX_H_ | ||||
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 7 | |
Vladislav Kuzkokov | 1999822 | 2019-08-12 14:26:09 | [diff] [blame] | 8 | #include <memory> |
[email protected] | ee5f36e4 | 2010-12-03 22:40:37 | [diff] [blame] | 9 | #include <string> |
10 | |||||
Keishi Hattori | f28f4f8 | 2022-06-21 11:32:15 | [diff] [blame] | 11 | #include "base/memory/raw_ptr.h" |
Alan Screen | 202e49a | 2021-09-21 06:34:28 | [diff] [blame] | 12 | #include "printing/mojom/print.mojom.h" |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 13 | #include "printing/printing_context.h" |
14 | |||||
15 | namespace printing { | ||||
16 | |||||
vitalybuka | 5d129058 | 2014-09-12 09:19:59 | [diff] [blame] | 17 | class MetafilePlayer; |
[email protected] | eaa389e | 2011-04-11 04:58:20 | [diff] [blame] | 18 | class PrintDialogGtkInterface; |
19 | |||||
[email protected] | d53002f4 | 2014-01-14 16:08:56 | [diff] [blame] | 20 | // PrintingContext with optional native UI for print dialog and pdf_paper_size. |
Alan Screen | 9347cae | 2021-04-27 18:11:24 | [diff] [blame] | 21 | class COMPONENT_EXPORT(PRINTING) PrintingContextLinux : public PrintingContext { |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 22 | public: |
Vitaly Buka | bd7c981 | 2014-08-26 08:57:54 | [diff] [blame] | 23 | explicit PrintingContextLinux(Delegate* delegate); |
Lei Zhang | dd3e9b0 | 2020-08-19 23:04:42 | [diff] [blame] | 24 | PrintingContextLinux(const PrintingContextLinux&) = delete; |
25 | PrintingContextLinux& operator=(const PrintingContextLinux&) = delete; | ||||
dcheng | 0f9f1d7 | 2014-12-22 23:35:16 | [diff] [blame] | 26 | ~PrintingContextLinux() override; |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 27 | |
[email protected] | eaa389e | 2011-04-11 04:58:20 | [diff] [blame] | 28 | // Sets the function that creates the print dialog. |
Lei Zhang | 01a1d3c0 | 2019-05-21 04:59:10 | [diff] [blame] | 29 | static void SetCreatePrintDialogFunction(PrintDialogGtkInterface* ( |
30 | *create_dialog_func)(PrintingContextLinux* context)); | ||||
[email protected] | d53002f4 | 2014-01-14 16:08:56 | [diff] [blame] | 31 | |
32 | // Sets the function that returns pdf paper size through the native API. | ||||
33 | static void SetPdfPaperSizeFunction( | ||||
34 | gfx::Size (*get_pdf_paper_size)(PrintingContextLinux* context)); | ||||
[email protected] | 5cc4c42 | 2011-02-19 00:09:22 | [diff] [blame] | 35 | |
thestig | 5f68391 | 2016-09-30 22:42:16 | [diff] [blame] | 36 | // Initializes with predefined settings. |
Vladislav Kuzkokov | 1999822 | 2019-08-12 14:26:09 | [diff] [blame] | 37 | void InitWithSettings(std::unique_ptr<PrintSettings> settings); |
thestig | 5f68391 | 2016-09-30 22:42:16 | [diff] [blame] | 38 | |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 39 | // PrintingContext implementation. |
dcheng | 0f9f1d7 | 2014-12-22 23:35:16 | [diff] [blame] | 40 | void AskUserForSettings(int max_pages, |
41 | bool has_selection, | ||||
42 | bool is_scripted, | ||||
Vladislav Kuzkokov | 48ceab2 | 2018-02-14 16:29:28 | [diff] [blame] | 43 | PrintSettingsCallback callback) override; |
dcheng | 0f9f1d7 | 2014-12-22 23:35:16 | [diff] [blame] | 44 | gfx::Size GetPdfPaperSizeDeviceUnits() override; |
Alan Screen | 202e49a | 2021-09-21 06:34:28 | [diff] [blame] | 45 | mojom::ResultCode UseDefaultSettings() override; |
Lei Zhang | a3fdad44 | 2021-11-15 23:55:33 | [diff] [blame] | 46 | mojom::ResultCode UpdatePrinterSettings( |
47 | const PrinterSettings& printer_settings) override; | ||||
Alan Screen | 202e49a | 2021-09-21 06:34:28 | [diff] [blame] | 48 | mojom::ResultCode NewDocument(const std::u16string& document_name) override; |
Alan Screen | 4e284e9cb | 2021-12-04 00:38:29 | [diff] [blame] | 49 | mojom::ResultCode PrintDocument(const MetafilePlayer& metafile, |
50 | const PrintSettings& settings, | ||||
51 | uint32_t num_pages) override; | ||||
Alan Screen | 202e49a | 2021-09-21 06:34:28 | [diff] [blame] | 52 | mojom::ResultCode DocumentDone() override; |
dcheng | 0f9f1d7 | 2014-12-22 23:35:16 | [diff] [blame] | 53 | void Cancel() override; |
54 | void ReleaseContext() override; | ||||
Nico Weber | 8e55956 | 2017-10-03 01:25:26 | [diff] [blame] | 55 | printing::NativeDrawingContext context() const override; |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 56 | |
57 | private: | ||||
Jan Wilken Dörrie | 739ccc21 | 2021-03-11 18:13:05 | [diff] [blame] | 58 | std::u16string document_name_; |
Keishi Hattori | f28f4f8 | 2022-06-21 11:32:15 | [diff] [blame] | 59 | raw_ptr<PrintDialogGtkInterface> print_dialog_; |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 60 | }; |
61 | |||||
62 | } // namespace printing | ||||
63 | |||||
[email protected] | d53002f4 | 2014-01-14 16:08:56 | [diff] [blame] | 64 | #endif // PRINTING_PRINTING_CONTEXT_LINUX_H_ |