xref: /aosp_15_r20/external/pdfium/fxjs/xfa/cfxjse_class.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2014 The PDFium Authors
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 FXJS_XFA_CFXJSE_CLASS_H_
8 #define FXJS_XFA_CFXJSE_CLASS_H_
9 
10 #include "core/fxcrt/unowned_ptr.h"
11 #include "fxjs/xfa/fxjse.h"
12 #include "v8/include/v8-forward.h"
13 #include "v8/include/v8-persistent-handle.h"
14 
15 class CFXJSE_Context;
16 struct FXJSE_CLASS_DESCRIPTOR;
17 
18 class CFXJSE_Class {
19  public:
20   static CFXJSE_Class* Create(CFXJSE_Context* pContext,
21                               const FXJSE_CLASS_DESCRIPTOR* pClassDescriptor,
22                               bool bIsJSGlobal);
23 
24   explicit CFXJSE_Class(const CFXJSE_Context* pContext);
25   ~CFXJSE_Class();
26 
IsName(ByteStringView name)27   bool IsName(ByteStringView name) const { return name == m_szClassName; }
GetContext()28   const CFXJSE_Context* GetContext() const { return m_pContext; }
29   v8::Local<v8::FunctionTemplate> GetTemplate(v8::Isolate* pIsolate);
30 
31  protected:
32   ByteString m_szClassName;
33   UnownedPtr<const FXJSE_CLASS_DESCRIPTOR> m_pClassDescriptor;
34   UnownedPtr<const CFXJSE_Context> const m_pContext;
35   v8::Global<v8::FunctionTemplate> m_hTemplate;
36 };
37 
38 #endif  // FXJS_XFA_CFXJSE_CLASS_H_
39