dsinclair | 64376be | 2016-03-31 20:03:24 -0700 | [diff] [blame] | 1 | // 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 | |
dsinclair | a52ab74 | 2016-09-29 13:59:29 -0700 | [diff] [blame] | 10 | #include "core/fxcrt/fx_string.h" |
| 11 | #include "core/fxcrt/fx_system.h" |
dsinclair | 64376be | 2016-03-31 20:03:24 -0700 | [diff] [blame] | 12 | |
| 13 | #ifdef PDF_ENABLE_XFA |
dsinclair | 4355468 | 2016-09-29 17:29:48 -0700 | [diff] [blame] | 14 | #include "fxjs/fxjse.h" |
dsinclair | 64376be | 2016-03-31 20:03:24 -0700 | [diff] [blame] | 15 | #endif // PDF_ENABLE_XFA |
| 16 | |
dsinclair | 735606d | 2016-10-05 15:47:02 -0700 | [diff] [blame] | 17 | class CPDFSDK_FormFillEnvironment; |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 18 | class IJS_EventContext; |
dsinclair | 64376be | 2016-03-31 20:03:24 -0700 | [diff] [blame] | 19 | |
| 20 | // Owns the FJXS objects needed to actually execute JS. |
| 21 | class IJS_Runtime { |
| 22 | public: |
| 23 | static void Initialize(unsigned int slot, void* isolate); |
thestig | 2d6dda1 | 2016-06-28 07:39:09 -0700 | [diff] [blame] | 24 | static void Destroy(); |
dsinclair | 82e1767 | 2016-10-11 12:38:01 -0700 | [diff] [blame] | 25 | static IJS_Runtime* Create(CPDFSDK_FormFillEnvironment* pFormFillEnv); |
dsinclair | 64376be | 2016-03-31 20:03:24 -0700 | [diff] [blame] | 26 | virtual ~IJS_Runtime() {} |
| 27 | |
Tom Sepez | d6ae2af | 2017-02-16 11:49:55 -0800 | [diff] [blame] | 28 | virtual IJS_EventContext* NewEventContext() = 0; |
| 29 | virtual void ReleaseEventContext(IJS_EventContext* pContext) = 0; |
dsinclair | 82e1767 | 2016-10-11 12:38:01 -0700 | [diff] [blame] | 30 | virtual CPDFSDK_FormFillEnvironment* GetFormFillEnv() const = 0; |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame^] | 31 | virtual int ExecuteScript(const WideString& script, WideString* info) = 0; |
dsinclair | 64376be | 2016-03-31 20:03:24 -0700 | [diff] [blame] | 32 | |
| 33 | #ifdef PDF_ENABLE_XFA |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame^] | 34 | virtual bool GetValueByName(const ByteStringView& utf8Name, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 35 | CFXJSE_Value* pValue) = 0; |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame^] | 36 | virtual bool SetValueByName(const ByteStringView& utf8Name, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 37 | CFXJSE_Value* pValue) = 0; |
dsinclair | 64376be | 2016-03-31 20:03:24 -0700 | [diff] [blame] | 38 | #endif // PDF_ENABLE_XFA |
| 39 | |
| 40 | protected: |
| 41 | IJS_Runtime() {} |
| 42 | }; |
| 43 | |
| 44 | #endif // FPDFSDK_JAVASCRIPT_IJS_RUNTIME_H_ |