blob: babc41842cf68ff0df1443c098357ca9108869ca [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
dsinclair735606d2016-10-05 15:47:02 -070017class CPDFSDK_FormFillEnvironment;
Tom Sepezd6ae2af2017-02-16 11:49:55 -080018class IJS_EventContext;
dsinclair64376be2016-03-31 20:03:24 -070019
20// Owns the FJXS objects needed to actually execute JS.
21class IJS_Runtime {
22 public:
23 static void Initialize(unsigned int slot, void* isolate);
thestig2d6dda12016-06-28 07:39:09 -070024 static void Destroy();
dsinclair82e17672016-10-11 12:38:01 -070025 static IJS_Runtime* Create(CPDFSDK_FormFillEnvironment* pFormFillEnv);
dsinclair64376be2016-03-31 20:03:24 -070026 virtual ~IJS_Runtime() {}
27
Tom Sepezd6ae2af2017-02-16 11:49:55 -080028 virtual IJS_EventContext* NewEventContext() = 0;
29 virtual void ReleaseEventContext(IJS_EventContext* pContext) = 0;
dsinclair82e17672016-10-11 12:38:01 -070030 virtual CPDFSDK_FormFillEnvironment* GetFormFillEnv() const = 0;
tsepezb4694242016-08-15 16:44:55 -070031 virtual int ExecuteScript(const CFX_WideString& script,
32 CFX_WideString* info) = 0;
dsinclair64376be2016-03-31 20:03:24 -070033
34#ifdef PDF_ENABLE_XFA
tsepez4cf55152016-11-02 14:37:54 -070035 virtual bool GetValueByName(const CFX_ByteStringC& utf8Name,
36 CFXJSE_Value* pValue) = 0;
37 virtual bool SetValueByName(const CFX_ByteStringC& utf8Name,
38 CFXJSE_Value* pValue) = 0;
dsinclair64376be2016-03-31 20:03:24 -070039#endif // PDF_ENABLE_XFA
40
41 protected:
42 IJS_Runtime() {}
43};
44
45#endif // FPDFSDK_JAVASCRIPT_IJS_RUNTIME_H_