blob: 0c2bd042c6e9e9a3bcf97586407932775368290c [file] [log] [blame]
dsinclair64376be2016-03-31 20:03:24 -07001// Copyright 2016 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef FPDFSDK_JAVASCRIPT_IJS_RUNTIME_H_
8#define FPDFSDK_JAVASCRIPT_IJS_RUNTIME_H_
9
dsinclaira52ab742016-09-29 13:59:29 -070010#include "core/fxcrt/fx_string.h"
11#include "core/fxcrt/fx_system.h"
dsinclair64376be2016-03-31 20:03:24 -070012
13#ifdef PDF_ENABLE_XFA
dsinclair43554682016-09-29 17:29:48 -070014#include "fxjs/fxjse.h"
dsinclair64376be2016-03-31 20:03:24 -070015#endif // PDF_ENABLE_XFA
16
dsinclair79db6092016-09-14 07:27:21 -070017class CPDFSDK_Environment;
dsinclair64376be2016-03-31 20:03:24 -070018class CPDFSDK_Document;
19class IJS_Context;
20
21// Owns the FJXS objects needed to actually execute JS.
22class IJS_Runtime {
23 public:
24 static void Initialize(unsigned int slot, void* isolate);
thestig2d6dda12016-06-28 07:39:09 -070025 static void Destroy();
dsinclair79db6092016-09-14 07:27:21 -070026 static IJS_Runtime* Create(CPDFSDK_Environment* pEnv);
dsinclair64376be2016-03-31 20:03:24 -070027 virtual ~IJS_Runtime() {}
28
29 virtual IJS_Context* NewContext() = 0;
30 virtual void ReleaseContext(IJS_Context* pContext) = 0;
31 virtual IJS_Context* GetCurrentContext() = 0;
32 virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0;
33 virtual CPDFSDK_Document* GetReaderDocument() = 0;
tsepezb4694242016-08-15 16:44:55 -070034 virtual int ExecuteScript(const CFX_WideString& script,
35 CFX_WideString* info) = 0;
dsinclair64376be2016-03-31 20:03:24 -070036
37#ifdef PDF_ENABLE_XFA
dsinclair12a6b0c2016-05-26 11:14:08 -070038 virtual FX_BOOL GetValueByName(const CFX_ByteStringC& utf8Name,
39 CFXJSE_Value* pValue) = 0;
40 virtual FX_BOOL SetValueByName(const CFX_ByteStringC& utf8Name,
41 CFXJSE_Value* pValue) = 0;
dsinclair64376be2016-03-31 20:03:24 -070042#endif // PDF_ENABLE_XFA
43
44 protected:
45 IJS_Runtime() {}
46};
47
48#endif // FPDFSDK_JAVASCRIPT_IJS_RUNTIME_H_