Home | History | Annotate | Download | only in javascript
      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/fx_string.h"
     11 #include "core/fxcrt/fx_system.h"
     12 
     13 #ifdef PDF_ENABLE_XFA
     14 #include "fxjs/fxjse.h"
     15 #endif  // PDF_ENABLE_XFA
     16 
     17 class CPDFSDK_FormFillEnvironment;
     18 class IJS_EventContext;
     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);
     24   static void Destroy();
     25   static IJS_Runtime* Create(CPDFSDK_FormFillEnvironment* pFormFillEnv);
     26   virtual ~IJS_Runtime() {}
     27 
     28   virtual IJS_EventContext* NewEventContext() = 0;
     29   virtual void ReleaseEventContext(IJS_EventContext* pContext) = 0;
     30   virtual CPDFSDK_FormFillEnvironment* GetFormFillEnv() const = 0;
     31   virtual int ExecuteScript(const CFX_WideString& script,
     32                             CFX_WideString* info) = 0;
     33 
     34 #ifdef PDF_ENABLE_XFA
     35   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;
     39 #endif  // PDF_ENABLE_XFA
     40 
     41  protected:
     42   IJS_Runtime() {}
     43 };
     44 
     45 #endif  // FPDFSDK_JAVASCRIPT_IJS_RUNTIME_H_
     46