blob: dd7be26e833012a8c113937aa482a113704ec175 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
// 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"
#include "libcef/browser/browser_host_base.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/task/sequenced_task_runner_helpers.h"
#include "content/public/browser/browser_thread.h"
#include "printing/print_dialog_linux_interface.h"
#include "ui/linux/linux_ui.h"
namespace printing {
class MetafilePlayer;
class PrintSettings;
} // namespace printing
using printing::PrintingContextLinux;
class CefPrintingContextLinuxDelegate
: public ui::PrintingContextLinuxDelegate {
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;
void SetDefaultDelegate(ui::PrintingContextLinuxDelegate* delegate);
private:
ui::PrintingContextLinuxDelegate* default_delegate_ = nullptr;
};
// Needs to be freed on the UI thread to clean up its member variables.
class CefPrintDialogLinux : public printing::PrintDialogLinuxInterface,
public base::RefCountedThreadSafe<
CefPrintDialogLinux,
content::BrowserThread::DeleteOnUIThread> {
public:
CefPrintDialogLinux(const CefPrintDialogLinux&) = delete;
CefPrintDialogLinux& operator=(const CefPrintDialogLinux&) = delete;
// PrintDialogLinuxInterface implementation.
void UseDefaultSettings() override;
void UpdateSettings(
std::unique_ptr<printing::PrintSettings> settings) override;
void ShowDialog(
gfx::NativeView parent_view,
bool has_selection,
PrintingContextLinux::PrintSettingsCallback callback) override;
void PrintDocument(const printing::MetafilePlayer& metafile,
const std::u16string& document_name) override;
void ReleaseDialog() override;
private:
friend class base::DeleteHelper<CefPrintDialogLinux>;
friend class base::RefCountedThreadSafe<
CefPrintDialogLinux,
content::BrowserThread::DeleteOnUIThread>;
friend struct content::BrowserThread::DeleteOnThread<
content::BrowserThread::UI>;
friend class CefPrintDialogCallbackImpl;
friend class CefPrintJobCallbackImpl;
friend class CefPrintingContextLinuxDelegate;
CefPrintDialogLinux(PrintingContextLinux* context,
CefRefPtr<CefBrowserHostBase> browser,
CefRefPtr<CefPrintHandler> handler);
~CefPrintDialogLinux() override;
bool UpdateSettings(std::unique_ptr<printing::PrintSettings> settings,
bool get_defaults);
// Prints document named |document_name|.
void SendDocumentToPrinter(const std::u16string& document_name);
// Handles print dialog response.
void OnPrintContinue(CefRefPtr<CefPrintSettings> settings);
void OnPrintCancel();
// Handles print job response.
void OnJobCompleted();
// Printing dialog callback.
PrintingContextLinux::PrintSettingsCallback callback_;
PrintingContextLinux* context_;
CefRefPtr<CefBrowserHostBase> browser_;
CefRefPtr<CefPrintHandler> handler_;
base::FilePath path_to_pdf_;
};
#endif // LIBCEF_BROWSER_PRINTING_PRINT_DIALOG_LINUX_H_
|