blob: a21ce809ac37613d54417dba667a7a5f27e34a93 [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;
Ryan Harrison275e2602017-09-18 14:23:18 -040031 virtual int ExecuteScript(const WideString& script, WideString* info) = 0;
dsinclair64376be2016-03-31 20:03:24 -070032
33#ifdef PDF_ENABLE_XFA
Ryan Harrison275e2602017-09-18 14:23:18 -040034 virtual bool GetValueByName(const ByteStringView& utf8Name,
tsepez4cf55152016-11-02 14:37:54 -070035 CFXJSE_Value* pValue) = 0;
Ryan Harrison275e2602017-09-18 14:23:18 -040036 virtual bool SetValueByName(const ByteStringView& utf8Name,
tsepez4cf55152016-11-02 14:37:54 -070037 CFXJSE_Value* pValue) = 0;
dsinclair64376be2016-03-31 20:03:24 -070038#endif // PDF_ENABLE_XFA
39
40 protected:
41 IJS_Runtime() {}
42};
43
44#endif // FPDFSDK_JAVASCRIPT_IJS_RUNTIME_H_