blob: cbd73e417f37a04de11e3ff950aa3957d1df8a6e [file] [log] [blame]
[email protected]d53002f42014-01-14 16:08:561// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]51e8d9352010-10-06 22:21:172// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]d53002f42014-01-14 16:08:565#ifndef PRINTING_PRINTING_CONTEXT_LINUX_H_
6#define PRINTING_PRINTING_CONTEXT_LINUX_H_
[email protected]51e8d9352010-10-06 22:21:177
Vladislav Kuzkokov19998222019-08-12 14:26:098#include <memory>
[email protected]ee5f36e42010-12-03 22:40:379#include <string>
10
Keishi Hattorif28f4f82022-06-21 11:32:1511#include "base/memory/raw_ptr.h"
Alan Screen202e49a2021-09-21 06:34:2812#include "printing/mojom/print.mojom.h"
[email protected]51e8d9352010-10-06 22:21:1713#include "printing/printing_context.h"
14
15namespace printing {
16
vitalybuka5d1290582014-09-12 09:19:5917class MetafilePlayer;
[email protected]eaa389e2011-04-11 04:58:2018class PrintDialogGtkInterface;
19
[email protected]d53002f42014-01-14 16:08:5620// PrintingContext with optional native UI for print dialog and pdf_paper_size.
Alan Screen9347cae2021-04-27 18:11:2421class COMPONENT_EXPORT(PRINTING) PrintingContextLinux : public PrintingContext {
[email protected]51e8d9352010-10-06 22:21:1722 public:
Vitaly Bukabd7c9812014-08-26 08:57:5423 explicit PrintingContextLinux(Delegate* delegate);
Lei Zhangdd3e9b02020-08-19 23:04:4224 PrintingContextLinux(const PrintingContextLinux&) = delete;
25 PrintingContextLinux& operator=(const PrintingContextLinux&) = delete;
dcheng0f9f1d72014-12-22 23:35:1626 ~PrintingContextLinux() override;
[email protected]51e8d9352010-10-06 22:21:1727
[email protected]eaa389e2011-04-11 04:58:2028 // Sets the function that creates the print dialog.
Lei Zhang01a1d3c02019-05-21 04:59:1029 static void SetCreatePrintDialogFunction(PrintDialogGtkInterface* (
30 *create_dialog_func)(PrintingContextLinux* context));
[email protected]d53002f42014-01-14 16:08:5631
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]5cc4c422011-02-19 00:09:2235
thestig5f683912016-09-30 22:42:1636 // Initializes with predefined settings.
Vladislav Kuzkokov19998222019-08-12 14:26:0937 void InitWithSettings(std::unique_ptr<PrintSettings> settings);
thestig5f683912016-09-30 22:42:1638
[email protected]51e8d9352010-10-06 22:21:1739 // PrintingContext implementation.
dcheng0f9f1d72014-12-22 23:35:1640 void AskUserForSettings(int max_pages,
41 bool has_selection,
42 bool is_scripted,
Vladislav Kuzkokov48ceab22018-02-14 16:29:2843 PrintSettingsCallback callback) override;
dcheng0f9f1d72014-12-22 23:35:1644 gfx::Size GetPdfPaperSizeDeviceUnits() override;
Alan Screen202e49a2021-09-21 06:34:2845 mojom::ResultCode UseDefaultSettings() override;
Lei Zhanga3fdad442021-11-15 23:55:3346 mojom::ResultCode UpdatePrinterSettings(
47 const PrinterSettings& printer_settings) override;
Alan Screen202e49a2021-09-21 06:34:2848 mojom::ResultCode NewDocument(const std::u16string& document_name) override;
Alan Screen4e284e9cb2021-12-04 00:38:2949 mojom::ResultCode PrintDocument(const MetafilePlayer& metafile,
50 const PrintSettings& settings,
51 uint32_t num_pages) override;
Alan Screen202e49a2021-09-21 06:34:2852 mojom::ResultCode DocumentDone() override;
dcheng0f9f1d72014-12-22 23:35:1653 void Cancel() override;
54 void ReleaseContext() override;
Nico Weber8e559562017-10-03 01:25:2655 printing::NativeDrawingContext context() const override;
[email protected]51e8d9352010-10-06 22:21:1756
57 private:
Jan Wilken Dörrie739ccc212021-03-11 18:13:0558 std::u16string document_name_;
Keishi Hattorif28f4f82022-06-21 11:32:1559 raw_ptr<PrintDialogGtkInterface> print_dialog_;
[email protected]51e8d9352010-10-06 22:21:1760};
61
62} // namespace printing
63
[email protected]d53002f42014-01-14 16:08:5664#endif // PRINTING_PRINTING_CONTEXT_LINUX_H_