2014-07-10 17:41:30 +02:00
|
|
|
// Copyright (c) 2014 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef LIBCEF_BROWSER_PRINTING_PRINT_DIALOG_LINUX_H_
|
|
|
|
#define LIBCEF_BROWSER_PRINTING_PRINT_DIALOG_LINUX_H_
|
|
|
|
|
|
|
|
#include "include/cef_print_handler.h"
|
2020-09-18 00:24:08 +02:00
|
|
|
#include "libcef/browser/browser_host_base.h"
|
2014-07-10 17:41:30 +02:00
|
|
|
|
|
|
|
#include "base/files/file_path.h"
|
|
|
|
#include "base/memory/ref_counted.h"
|
2021-11-10 22:57:31 +01:00
|
|
|
#include "base/task/sequenced_task_runner_helpers.h"
|
2014-07-10 17:41:30 +02:00
|
|
|
#include "content/public/browser/browser_thread.h"
|
2022-07-21 19:26:10 +02:00
|
|
|
#include "printing/print_dialog_linux_interface.h"
|
2023-01-12 17:49:21 +01:00
|
|
|
#include "ui/linux/linux_ui.h"
|
2014-07-10 17:41:30 +02:00
|
|
|
|
|
|
|
namespace printing {
|
2014-09-27 01:48:19 +02:00
|
|
|
class MetafilePlayer;
|
2014-07-10 17:41:30 +02:00
|
|
|
class PrintSettings;
|
2018-01-02 22:51:02 +01:00
|
|
|
} // namespace printing
|
2014-07-10 17:41:30 +02:00
|
|
|
|
|
|
|
using printing::PrintingContextLinux;
|
|
|
|
|
2022-07-21 19:26:10 +02:00
|
|
|
class CefPrintingContextLinuxDelegate
|
2023-01-12 17:49:21 +01:00
|
|
|
: public ui::PrintingContextLinuxDelegate {
|
2022-07-21 19:26:10 +02:00
|
|
|
public:
|
|
|
|
CefPrintingContextLinuxDelegate();
|
|
|
|
|
|
|
|
CefPrintingContextLinuxDelegate(const CefPrintingContextLinuxDelegate&) =
|
|
|
|
delete;
|
|
|
|
CefPrintingContextLinuxDelegate& operator=(
|
|
|
|
const CefPrintingContextLinuxDelegate&) = delete;
|
|
|
|
|
|
|
|
printing::PrintDialogLinuxInterface* CreatePrintDialog(
|
|
|
|
printing::PrintingContextLinux* context) override;
|
|
|
|
gfx::Size GetPdfPaperSize(printing::PrintingContextLinux* context) override;
|
|
|
|
|
2023-01-12 17:49:21 +01:00
|
|
|
void SetDefaultDelegate(ui::PrintingContextLinuxDelegate* delegate);
|
2022-07-21 19:26:10 +02:00
|
|
|
|
|
|
|
private:
|
2023-01-12 17:49:21 +01:00
|
|
|
ui::PrintingContextLinuxDelegate* default_delegate_ = nullptr;
|
2022-07-21 19:26:10 +02:00
|
|
|
};
|
|
|
|
|
2014-07-10 17:41:30 +02:00
|
|
|
// Needs to be freed on the UI thread to clean up its member variables.
|
2022-07-21 19:26:10 +02:00
|
|
|
class CefPrintDialogLinux : public printing::PrintDialogLinuxInterface,
|
2017-05-17 11:29:28 +02:00
|
|
|
public base::RefCountedThreadSafe<
|
|
|
|
CefPrintDialogLinux,
|
|
|
|
content::BrowserThread::DeleteOnUIThread> {
|
2014-07-10 17:41:30 +02:00
|
|
|
public:
|
2021-12-06 21:40:25 +01:00
|
|
|
CefPrintDialogLinux(const CefPrintDialogLinux&) = delete;
|
|
|
|
CefPrintDialogLinux& operator=(const CefPrintDialogLinux&) = delete;
|
|
|
|
|
2022-07-21 19:26:10 +02:00
|
|
|
// PrintDialogLinuxInterface implementation.
|
2014-11-12 20:25:15 +01:00
|
|
|
void UseDefaultSettings() override;
|
2019-10-01 15:55:16 +02:00
|
|
|
void UpdateSettings(
|
|
|
|
std::unique_ptr<printing::PrintSettings> settings) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
void ShowDialog(
|
2014-07-10 17:41:30 +02:00
|
|
|
gfx::NativeView parent_view,
|
|
|
|
bool has_selection,
|
2018-03-20 21:15:08 +01:00
|
|
|
PrintingContextLinux::PrintSettingsCallback callback) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
void PrintDocument(const printing::MetafilePlayer& metafile,
|
2021-04-21 00:52:34 +02:00
|
|
|
const std::u16string& document_name) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
void ReleaseDialog() override;
|
2014-07-10 17:41:30 +02:00
|
|
|
|
|
|
|
private:
|
2014-11-12 20:25:15 +01:00
|
|
|
friend class base::DeleteHelper<CefPrintDialogLinux>;
|
|
|
|
friend class base::RefCountedThreadSafe<
|
2017-05-17 11:29:28 +02:00
|
|
|
CefPrintDialogLinux,
|
|
|
|
content::BrowserThread::DeleteOnUIThread>;
|
2014-07-10 17:41:30 +02:00
|
|
|
friend struct content::BrowserThread::DeleteOnThread<
|
|
|
|
content::BrowserThread::UI>;
|
|
|
|
friend class CefPrintDialogCallbackImpl;
|
|
|
|
friend class CefPrintJobCallbackImpl;
|
2022-07-21 19:26:10 +02:00
|
|
|
friend class CefPrintingContextLinuxDelegate;
|
2014-07-10 17:41:30 +02:00
|
|
|
|
2022-04-15 21:55:23 +02:00
|
|
|
CefPrintDialogLinux(PrintingContextLinux* context,
|
|
|
|
CefRefPtr<CefBrowserHostBase> browser,
|
|
|
|
CefRefPtr<CefPrintHandler> handler);
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefPrintDialogLinux() override;
|
2014-07-10 17:41:30 +02:00
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
bool UpdateSettings(std::unique_ptr<printing::PrintSettings> settings,
|
|
|
|
bool get_defaults);
|
2014-07-10 17:41:30 +02:00
|
|
|
|
|
|
|
// Prints document named |document_name|.
|
2021-04-21 00:52:34 +02:00
|
|
|
void SendDocumentToPrinter(const std::u16string& document_name);
|
2014-07-10 17:41:30 +02:00
|
|
|
|
|
|
|
// Handles print dialog response.
|
|
|
|
void OnPrintContinue(CefRefPtr<CefPrintSettings> settings);
|
|
|
|
void OnPrintCancel();
|
|
|
|
|
|
|
|
// Handles print job response.
|
|
|
|
void OnJobCompleted();
|
|
|
|
|
|
|
|
// Printing dialog callback.
|
|
|
|
PrintingContextLinux::PrintSettingsCallback callback_;
|
2022-04-15 21:55:23 +02:00
|
|
|
|
2014-07-10 17:41:30 +02:00
|
|
|
PrintingContextLinux* context_;
|
2020-09-18 00:24:08 +02:00
|
|
|
CefRefPtr<CefBrowserHostBase> browser_;
|
2022-04-15 21:55:23 +02:00
|
|
|
CefRefPtr<CefPrintHandler> handler_;
|
2014-07-10 17:41:30 +02:00
|
|
|
|
|
|
|
base::FilePath path_to_pdf_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LIBCEF_BROWSER_PRINTING_PRINT_DIALOG_LINUX_H_
|