| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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_JS_OBJECT_H_ | 7 #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_JS_OBJECT_H_ |
| 8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_OBJECT_H_ | 8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_OBJECT_H_ |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "../../../third_party/base/nonstd_unique_ptr.h" | 12 #include "../../../third_party/base/nonstd_unique_ptr.h" |
| 13 | 13 |
| 14 #include "../fsdk_define.h" // For FX_UINT | 14 #include "../fsdk_define.h" // For FX_UINT |
| 15 #include "../fsdk_mgr.h" // For CPDFDoc_Environment | 15 #include "../fsdk_mgr.h" // For CPDFDoc_Environment |
| 16 #include "../fx_systemhandler.h" // For IFX_SystemHandler | 16 #include "../fx_systemhandler.h" // For IFX_SystemHandler |
| 17 #include "../jsapi/fxjs_v8.h" | 17 #include "../jsapi/fxjs_v8.h" |
| 18 #include "JS_Runtime.h" | 18 #include "JS_Runtime.h" |
| 19 | 19 |
| 20 class CPDFSDK_PageView; | |
| 21 class CJS_Context; | 20 class CJS_Context; |
| 22 class CJS_Object; | 21 class CJS_Object; |
| 23 class CJS_Timer; | 22 class CJS_Timer; |
| 24 | 23 |
| 25 class CJS_EmbedObj { | 24 class CJS_EmbedObj { |
| 26 public: | 25 public: |
| 27 explicit CJS_EmbedObj(CJS_Object* pJSObject); | 26 explicit CJS_EmbedObj(CJS_Object* pJSObject); |
| 28 virtual ~CJS_EmbedObj(); | 27 virtual ~CJS_EmbedObj(); |
| 29 | 28 |
| 30 virtual void TimerProc(CJS_Timer* pTimer) {} | 29 virtual void TimerProc(CJS_Timer* pTimer) {} |
| 31 | 30 |
| 32 CJS_Object* GetJSObject() const { return m_pJSObject; } | 31 CJS_Object* GetJSObject() const { return m_pJSObject; } |
| 33 | 32 |
| 34 CPDFSDK_PageView* JSGetPageView(IFXJS_Context* cc); | |
| 35 int MsgBox(CPDFDoc_Environment* pApp, | 33 int MsgBox(CPDFDoc_Environment* pApp, |
| 36 CPDFSDK_PageView* pPageView, | |
| 37 const FX_WCHAR* swMsg, | 34 const FX_WCHAR* swMsg, |
| 38 const FX_WCHAR* swTitle = NULL, | 35 const FX_WCHAR* swTitle, |
| 39 FX_UINT nType = 0, | 36 FX_UINT nType, |
| 40 FX_UINT nIcon = 0); | 37 FX_UINT nIcon); |
| 41 void Alert(CJS_Context* pContext, const FX_WCHAR* swMsg); | 38 void Alert(CJS_Context* pContext, const FX_WCHAR* swMsg); |
| 42 | 39 |
| 43 protected: | 40 protected: |
| 44 CJS_Object* m_pJSObject; | 41 CJS_Object* m_pJSObject; |
| 45 }; | 42 }; |
| 46 | 43 |
| 47 class CJS_Object { | 44 class CJS_Object { |
| 48 public: | 45 public: |
| 49 explicit CJS_Object(v8::Local<v8::Object> pObject); | 46 explicit CJS_Object(v8::Local<v8::Object> pObject); |
| 50 virtual ~CJS_Object(); | 47 virtual ~CJS_Object(); |
| 51 | 48 |
| 52 void MakeWeak(); | 49 void MakeWeak(); |
| 53 void Dispose(); | 50 void Dispose(); |
| 54 | 51 |
| 55 virtual FX_BOOL IsType(const FX_CHAR* sClassName) { return TRUE; } | 52 virtual FX_BOOL IsType(const FX_CHAR* sClassName) { return TRUE; } |
| 56 virtual CFX_ByteString GetClassName() { return ""; } | 53 virtual CFX_ByteString GetClassName() { return ""; } |
| 57 | 54 |
| 58 virtual FX_BOOL InitInstance(IFXJS_Context* cc) { return TRUE; } | 55 virtual FX_BOOL InitInstance(IFXJS_Context* cc) { return TRUE; } |
| 59 virtual FX_BOOL ExitInstance() { return TRUE; } | 56 virtual FX_BOOL ExitInstance() { return TRUE; } |
| 60 | 57 |
| 61 v8::Local<v8::Object> ToV8Object() { return m_pV8Object.Get(m_pIsolate); } | 58 v8::Local<v8::Object> ToV8Object() { return m_pV8Object.Get(m_pIsolate); } |
| 62 | 59 |
| 63 // Takes ownership of |pObj|. | 60 // Takes ownership of |pObj|. |
| 64 void SetEmbedObject(CJS_EmbedObj* pObj) { m_pEmbedObj.reset(pObj); } | 61 void SetEmbedObject(CJS_EmbedObj* pObj) { m_pEmbedObj.reset(pObj); } |
| 65 CJS_EmbedObj* GetEmbedObject() const { return m_pEmbedObj.get(); } | 62 CJS_EmbedObj* GetEmbedObject() const { return m_pEmbedObj.get(); } |
| 66 | 63 |
| 67 static CPDFSDK_PageView* JSGetPageView(IFXJS_Context* cc); | |
| 68 static int MsgBox(CPDFDoc_Environment* pApp, | 64 static int MsgBox(CPDFDoc_Environment* pApp, |
| 69 CPDFSDK_PageView* pPageView, | |
| 70 const FX_WCHAR* swMsg, | 65 const FX_WCHAR* swMsg, |
| 71 const FX_WCHAR* swTitle = NULL, | 66 const FX_WCHAR* swTitle, |
| 72 FX_UINT nType = 0, | 67 FX_UINT nType, |
| 73 FX_UINT nIcon = 0); | 68 FX_UINT nIcon); |
| 74 static void Alert(CJS_Context* pContext, const FX_WCHAR* swMsg); | 69 static void Alert(CJS_Context* pContext, const FX_WCHAR* swMsg); |
| 75 | 70 |
| 76 v8::Isolate* GetIsolate() { return m_pIsolate; } | 71 v8::Isolate* GetIsolate() { return m_pIsolate; } |
| 77 | 72 |
| 78 protected: | 73 protected: |
| 79 nonstd::unique_ptr<CJS_EmbedObj> m_pEmbedObj; | 74 nonstd::unique_ptr<CJS_EmbedObj> m_pEmbedObj; |
| 80 v8::Global<v8::Object> m_pV8Object; | 75 v8::Global<v8::Object> m_pV8Object; |
| 81 v8::Isolate* m_pIsolate; | 76 v8::Isolate* m_pIsolate; |
| 82 }; | 77 }; |
| 83 | 78 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 110 |
| 116 // data | 111 // data |
| 117 const int m_nType; // 0:Interval; 1:TimeOut | 112 const int m_nType; // 0:Interval; 1:TimeOut |
| 118 const FX_DWORD m_dwTimeOut; | 113 const FX_DWORD m_dwTimeOut; |
| 119 const CFX_WideString m_swJScript; | 114 const CFX_WideString m_swJScript; |
| 120 CJS_Runtime* const m_pRuntime; | 115 CJS_Runtime* const m_pRuntime; |
| 121 CPDFDoc_Environment* const m_pApp; | 116 CPDFDoc_Environment* const m_pApp; |
| 122 }; | 117 }; |
| 123 | 118 |
| 124 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_OBJECT_H_ | 119 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_OBJECT_H_ |
| OLD | NEW |