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 | |
| 10 | #include "core/fxcrt/include/fx_string.h" |
| 11 | #include "core/fxcrt/include/fx_system.h" |
| 12 | |
| 13 | #ifdef PDF_ENABLE_XFA |
dsinclair | 8bd9ce0 | 2016-06-09 13:24:34 -0700 | [diff] [blame] | 14 | #include "fxjse/include/fxjse.h" |
dsinclair | 64376be | 2016-03-31 20:03:24 -0700 | [diff] [blame] | 15 | #endif // PDF_ENABLE_XFA |
| 16 | |
| 17 | class CPDFDoc_Environment; |
| 18 | class CPDFSDK_Document; |
| 19 | class IJS_Context; |
| 20 | |
| 21 | // Owns the FJXS objects needed to actually execute JS. |
| 22 | class IJS_Runtime { |
| 23 | public: |
| 24 | static void Initialize(unsigned int slot, void* isolate); |
thestig | 2d6dda1 | 2016-06-28 07:39:09 -0700 | [diff] [blame^] | 25 | static void Destroy(); |
dsinclair | 64376be | 2016-03-31 20:03:24 -0700 | [diff] [blame] | 26 | static IJS_Runtime* Create(CPDFDoc_Environment* pEnv); |
| 27 | 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; |
dsinclair | 884b4f9 | 2016-06-06 09:49:32 -0700 | [diff] [blame] | 34 | virtual int Execute(const CFX_WideString& script, CFX_WideString* info) = 0; |
dsinclair | 64376be | 2016-03-31 20:03:24 -0700 | [diff] [blame] | 35 | |
| 36 | #ifdef PDF_ENABLE_XFA |
dsinclair | 12a6b0c | 2016-05-26 11:14:08 -0700 | [diff] [blame] | 37 | virtual FX_BOOL GetValueByName(const CFX_ByteStringC& utf8Name, |
| 38 | CFXJSE_Value* pValue) = 0; |
| 39 | virtual FX_BOOL SetValueByName(const CFX_ByteStringC& utf8Name, |
| 40 | CFXJSE_Value* pValue) = 0; |
dsinclair | 64376be | 2016-03-31 20:03:24 -0700 | [diff] [blame] | 41 | #endif // PDF_ENABLE_XFA |
| 42 | |
| 43 | protected: |
| 44 | IJS_Runtime() {} |
| 45 | }; |
| 46 | |
| 47 | #endif // FPDFSDK_JAVASCRIPT_IJS_RUNTIME_H_ |