forked from bblanchon/pdfium-binaries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv8_init.patch
71 lines (70 loc) · 1.81 KB
/
v8_init.patch
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
diff --git a/fpdfsdk/BUILD.gn b/fpdfsdk/BUILD.gn
index dc8012ad3..12f82268c 100644
--- a/fpdfsdk/BUILD.gn
+++ b/fpdfsdk/BUILD.gn
@@ -70,6 +70,7 @@ source_set("fpdfsdk") {
"fpdf_transformpage.cpp",
"fpdf_view.cpp",
"ipdfsdk_annothandler.h",
+ "fpdf_libs.cpp",
]
configs += [ "../:pdfium_strict_config" ]
diff --git a/fpdfsdk/fpdf_libs.cpp b/fpdfsdk/fpdf_libs.cpp
new file mode 100644
index 000000000..18fb89dd2
--- /dev/null
+++ b/fpdfsdk/fpdf_libs.cpp
@@ -0,0 +1,22 @@
+#include "public/fpdfview.h"
+
+#include "v8.h"
+
+extern "C"
+{
+
+FPDF_EXPORT void FPDF_CALLCONV FPDF_InitEmbeddedLibraries(const char* resourcePath)
+{
+ v8::V8::InitializeICU();
+
+ v8::V8::InitializeExternalStartupData(resourcePath);
+
+ v8::V8::Initialize();
+
+ // By enabling predictable mode, V8 won't post any background tasks.
+ const char predictable_flag[] = "--predictable";
+ v8::V8::SetFlagsFromString(predictable_flag,
+ static_cast<int>(strlen(predictable_flag)));
+}
+
+} // extern "C"
diff --git a/public/fpdf_libs.h b/public/fpdf_libs.h
new file mode 100644
index 000000000..aa58f9ede
--- /dev/null
+++ b/public/fpdf_libs.h
@@ -0,0 +1,25 @@
+#ifndef FPDF_LIBS_H_
+#define FPDF_LIBS_H_
+
+#include "fpdfview.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Function: FPDF_InitEmbeddedLibraries
+// Initialize embedded libraries (v8, iuctl) included in pdfium
+// Parameters:
+// resourcePath - a path to v8 resources (snapshot_blob.bin, icudtl.dat, ...)
+// Return value:
+// None.
+// Comments:
+// This function must be called before calling FPDF_InitLibrary()
+// if v8 suppport is enabled
+FPDF_EXPORT void FPDF_CALLCONV FPDF_InitEmbeddedLibraries(const char* resourcePath);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // FPDF_LIBS_H_