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
android_webview / browser / aw_pdf_exporter.h [blame]
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ANDROID_WEBVIEW_BROWSER_AW_PDF_EXPORTER_H_
#define ANDROID_WEBVIEW_BROWSER_AW_PDF_EXPORTER_H_
#include "base/android/jni_weak_ref.h"
#include "base/android/scoped_java_ref.h"
#include "base/memory/raw_ptr.h"
#include "printing/page_range.h"
namespace content {
class WebContents;
}
namespace printing {
class PrintSettings;
}
namespace android_webview {
// Native companion to Java AwPdfExporter.
// Owned by native AwContents, which lazy-instantiates this object when
// instructed to by the Java side.
//
// The Java AwPdfExporter holds a pointer to this native component but is not
// responsible for its lifetime.
// The Java AwPdfExporter is similarly owned by the Java AwContents.
//
// Lifetime: WebView
class AwPdfExporter {
public:
AwPdfExporter(JNIEnv* env,
const base::android::JavaRef<jobject>& obj,
content::WebContents* web_contents);
AwPdfExporter(const AwPdfExporter&) = delete;
AwPdfExporter& operator=(const AwPdfExporter&) = delete;
~AwPdfExporter();
void ExportToPdf(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
int fd,
const base::android::JavaParamRef<jintArray>& pages,
const base::android::JavaParamRef<jobject>& cancel_signal);
private:
std::unique_ptr<printing::PrintSettings> CreatePdfSettings(
JNIEnv* env,
const base::android::JavaRef<jobject>& obj,
const printing::PageRanges& page_ranges);
void DidExportPdf(int page_count);
JavaObjectWeakGlobalRef java_ref_;
raw_ptr<content::WebContents> web_contents_;
};
} // namespace android_webview
#endif // ANDROID_WEBVIEW_BROWSER_AW_PDF_EXPORTER_H_