OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_ | 7 #ifndef FPDFSDK_JAVASCRIPT_IJS_CONTEXT_H_ |
8 #define FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_ | 8 #define FPDFSDK_JAVASCRIPT_IJS_CONTEXT_H_ |
9 | 9 |
10 #include "core/fxcrt/include/fx_string.h" | 10 #include "core/fxcrt/include/fx_string.h" |
11 #include "core/fxcrt/include/fx_system.h" | 11 #include "core/fxcrt/include/fx_system.h" |
12 | 12 |
13 #ifdef PDF_ENABLE_XFA | 13 class CPDF_Bookmark; |
14 #include "xfa/fxjse/include/fxjse.h" | 14 class CPDF_FormField; |
15 #endif // PDF_ENABLE_XFA | |
16 | |
17 class CPDFDoc_Environment; | |
18 class CPDFSDK_Annot; | 15 class CPDFSDK_Annot; |
19 class CPDFSDK_Document; | 16 class CPDFSDK_Document; |
20 class CPDF_Bookmark; | |
21 class CPDF_FormField; | |
22 | 17 |
23 // Records the details of an event and triggers JS execution for it. | 18 // Records the details of an event and triggers JS execution for it. |
24 class IJS_Context { | 19 class IJS_Context { |
25 public: | 20 public: |
26 virtual FX_BOOL RunScript(const CFX_WideString& script, | 21 virtual FX_BOOL RunScript(const CFX_WideString& script, |
27 CFX_WideString* info) = 0; | 22 CFX_WideString* info) = 0; |
28 | 23 |
29 virtual void OnApp_Init() = 0; | 24 virtual void OnApp_Init() = 0; |
30 | 25 |
31 virtual void OnDoc_Open(CPDFSDK_Document* pDoc, | 26 virtual void OnDoc_Open(CPDFSDK_Document* pDoc, |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 virtual void OnBatchExec(CPDFSDK_Document* pTarget) = 0; | 124 virtual void OnBatchExec(CPDFSDK_Document* pTarget) = 0; |
130 virtual void OnConsole_Exec() = 0; | 125 virtual void OnConsole_Exec() = 0; |
131 virtual void OnExternal_Exec() = 0; | 126 virtual void OnExternal_Exec() = 0; |
132 | 127 |
133 virtual void EnableMessageBox(FX_BOOL bEnable) = 0; | 128 virtual void EnableMessageBox(FX_BOOL bEnable) = 0; |
134 | 129 |
135 protected: | 130 protected: |
136 virtual ~IJS_Context() {} | 131 virtual ~IJS_Context() {} |
137 }; | 132 }; |
138 | 133 |
139 // Owns the FJXS objects needed to actually execute JS. | 134 #endif // FPDFSDK_JAVASCRIPT_IJS_CONTEXT_H_ |
140 class IJS_Runtime { | |
141 public: | |
142 static void Initialize(unsigned int slot, void* isolate); | |
143 static IJS_Runtime* Create(CPDFDoc_Environment* pEnv); | |
144 virtual ~IJS_Runtime() {} | |
145 | |
146 virtual IJS_Context* NewContext() = 0; | |
147 virtual void ReleaseContext(IJS_Context* pContext) = 0; | |
148 virtual IJS_Context* GetCurrentContext() = 0; | |
149 virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0; | |
150 virtual CPDFSDK_Document* GetReaderDocument() = 0; | |
151 virtual int Execute(IJS_Context* cc, | |
152 const wchar_t* script, | |
153 CFX_WideString* info) = 0; | |
154 | |
155 #ifdef PDF_ENABLE_XFA | |
156 virtual FX_BOOL GetHValueByName(const CFX_ByteStringC& utf8Name, | |
157 FXJSE_HVALUE hValue) = 0; | |
158 virtual FX_BOOL SetHValueByName(const CFX_ByteStringC& utf8Name, | |
159 FXJSE_HVALUE hValue) = 0; | |
160 #endif // PDF_ENABLE_XFA | |
161 | |
162 protected: | |
163 IJS_Runtime() {} | |
164 }; | |
165 | |
166 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_ | |
OLD | NEW |