summaryrefslogtreecommitdiff
path: root/fxjs/ijs_runtime.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-04-18 22:48:22 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-18 22:48:22 +0000
commita1fe73272892b668bd5928a836ecc6303c81e2fd (patch)
tree959f9576d3cfe49ad48f7a765bec64d7a954d3ff /fxjs/ijs_runtime.cpp
parentfbecb9a5150d2c5391581933c8089e7249292171 (diff)
downloadpdfium-a1fe73272892b668bd5928a836ecc6303c81e2fd.tar.xz
Always build JS Runtime stubs even if V8 present.
Prerequisite for switching V8 off at run-time. Change-Id: I4b9f867185758350f5de3f57e771f63020df6e65 Reviewed-on: https://pdfium-review.googlesource.com/30994 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/ijs_runtime.cpp')
-rw-r--r--fxjs/ijs_runtime.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/fxjs/ijs_runtime.cpp b/fxjs/ijs_runtime.cpp
new file mode 100644
index 0000000000..03538cd7b5
--- /dev/null
+++ b/fxjs/ijs_runtime.cpp
@@ -0,0 +1,38 @@
+// Copyright 2018 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "fxjs/ijs_runtime.h"
+
+#include "fpdfsdk/cpdfsdk_helpers.h"
+#include "fxjs/cjs_runtimestub.h"
+#include "third_party/base/ptr_util.h"
+
+#ifdef PDF_ENABLE_V8
+#include "fxjs/cfxjs_engine.h"
+#include "fxjs/cjs_runtime.h"
+#endif
+
+// static
+void IJS_Runtime::Initialize(unsigned int slot, void* isolate) {
+#ifdef PDF_ENABLE_V8
+ FXJS_Initialize(slot, reinterpret_cast<v8::Isolate*>(isolate));
+#endif
+}
+
+// static
+void IJS_Runtime::Destroy() {
+#ifdef PDF_ENABLE_V8
+ FXJS_Release();
+#endif
+}
+
+// static
+std::unique_ptr<IJS_Runtime> IJS_Runtime::Create(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+#ifdef PDF_ENABLE_V8
+ return pdfium::MakeUnique<CJS_Runtime>(pFormFillEnv);
+#else
+ return pdfium::MakeUnique<CJS_RuntimeStub>(pFormFillEnv);
+#endif
+}