Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Side by Side Diff: fpdfsdk/include/javascript/JS_Object.h

Issue 883393007: Kill off some dodgy JS callbacks (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: remove more now-unreachable code. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/include/fsdk_mgr.h ('k') | fpdfsdk/include/javascript/app.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 _JS_OBJECT_H_ 7 #ifndef _JS_OBJECT_H_
8 #define _JS_OBJECT_H_ 8 #define _JS_OBJECT_H_
9 9
10 class CJS_Object; 10 class CJS_Object;
11 class CJS_Timer; 11 class CJS_Timer;
12 class CJS_Context; 12 class CJS_Context;
13 13
14 class CJS_EmbedObj : public CFX_Object 14 class CJS_EmbedObj : public CFX_Object
15 { 15 {
16 public: 16 public:
17 CJS_EmbedObj(CJS_Object* pJSObject); 17 CJS_EmbedObj(CJS_Object* pJSObject);
18 virtual ~CJS_EmbedObj(); 18 virtual ~CJS_EmbedObj();
19 19
20 virtual void TimerProc(CJS_Timer* pTimer){}; 20 virtual void TimerProc(CJS_Timer* pTimer){};
21 21
22 CJS_Timer* BeginTimer(CPDFDoc_Envir onment * pApp, FX_UINT nElapse); 22 CJS_Timer* BeginTimer(CPDFDoc_Envir onment * pApp, FX_UINT nElapse);
23 void EndTimer(CJS_Timer* pTim er); 23 void EndTimer(CJS_Timer* pTim er);
24 24
25 CJS_Object* GetJSObject(){return m_p JSObject;}; 25 CJS_Object* GetJSObject(){return m_p JSObject;};
26 operator CJS_Object* (){return m_ pJSObject;}; 26 operator CJS_Object* (){return m_ pJSObject;};
27 27
28 CPDFSDK_PageView * JSGetPageView(IFXJS_Context* cc) ; 28 CPDFSDK_PageView * JSGetPageView(IFXJS_Context* cc) ;
29 int MsgBox(CPDFDoc_E nvironment * pApp, CPDFSDK_PageView* pPageView, FX_LPCWSTR swMsg, FX_LPCWSTR swT itle = NULL, FX_UINT nType = 0, FX_UINT nIcon = 0); 29 int MsgBox(CPDFDoc_E nvironment * pApp, CPDFSDK_PageView* pPageView, FX_LPCWSTR swMsg, FX_LPCWSTR swT itle = NULL, FX_UINT nType = 0, FX_UINT nIcon = 0);
30 void Alert(CJS_Context* pCont ext, FX_LPCWSTR swMsg); 30 void Alert(CJS_Context* pCont ext, FX_LPCWSTR swMsg);
31 FX_BOOL IsSafeMode(IFXJS_Context * cc);
32 31
33 protected: 32 protected:
34
35 CJS_Object* m_pJSObject; 33 CJS_Object* m_pJSObject;
36 }; 34 };
37 35
38 class CJS_Object : public CFX_Object 36 class CJS_Object : public CFX_Object
39 { 37 {
40 public: 38 public:
41 CJS_Object(JSFXObject pObject); 39 CJS_Object(JSFXObject pObject);
42 virtual ~CJS_Object(void); 40 virtual ~CJS_Object(void);
43 » 41
44 void MakeWeak(); 42 void MakeWeak();
45 43
46 virtual FX_BOOL IsType(FX_LPCSTR sClassName){ret urn TRUE;}; 44 virtual FX_BOOL IsType(FX_LPCSTR sClassName){ret urn TRUE;};
47 virtual CFX_ByteString GetClassName(){return "";}; 45 virtual CFX_ByteString GetClassName(){return "";};
48 46
49 virtual FX_BOOL InitInstance(IFXJS_Context* cc){ return TRUE;}; 47 virtual FX_BOOL InitInstance(IFXJS_Context* cc){ return TRUE;};
50 virtual FX_BOOL ExitInstance(){return TRUE;}; 48 virtual FX_BOOL ExitInstance(){return TRUE;};
51 49
52 operator JSFXObject () {return v8 ::Local<v8::Object>::New(m_pIsolate, m_pObject);} 50 operator JSFXObject () {return v8 ::Local<v8::Object>::New(m_pIsolate, m_pObject);}
53 operator CJS_EmbedObj* (){return m_pEmbedObj;}; 51 operator CJS_EmbedObj* (){return m_pEmbedObj;};
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 { 132 {
135 delete m_Array.GetAt(i); 133 delete m_Array.GetAt(i);
136 m_Array.RemoveAt(i); 134 m_Array.RemoveAt(i);
137 } 135 }
138 //To prevent potential fake memory leak reported by vc6. 136 //To prevent potential fake memory leak reported by vc6.
139 if(m_Array.GetSize() == 0) 137 if(m_Array.GetSize() == 0)
140 m_Array.RemoveAll(); 138 m_Array.RemoveAll();
141 } 139 }
142 140
143 int Find(FX_UINT nIndex) 141 int Find(FX_UINT nIndex)
144 » {» » 142 » {
145 for (int i=0,sz=m_Array.GetSize(); i<sz; i++) 143 for (int i=0,sz=m_Array.GetSize(); i<sz; i++)
146 » » {» » » 144 » » {
147 if (JS_TIMER_MAP * pMap = m_Array.GetAt(i)) 145 if (JS_TIMER_MAP * pMap = m_Array.GetAt(i))
148 { 146 {
149 if (pMap->nID == nIndex) 147 if (pMap->nID == nIndex)
150 return i; 148 return i;
151 } 149 }
152 } 150 }
153 151
154 return -1; 152 return -1;
155 } 153 }
156 154
157 CTimerMapArray m_Array; 155 CTimerMapArray m_Array;
158 }; 156 };
159 157
160 JS_TIMER_MAPARRAY& GetTimeMap(); 158 JS_TIMER_MAPARRAY& GetTimeMap();
161 159
162 class CJS_Runtime; 160 class CJS_Runtime;
163 161
164 class CJS_Timer 162 class CJS_Timer
165 { 163 {
166 public: 164 public:
167 CJS_Timer(CJS_EmbedObj * pObj, CPDFDoc_Environment* pApp): 165 CJS_Timer(CJS_EmbedObj * pObj, CPDFDoc_Environment* pApp):
168 » » m_nTimerID(0), 166 » » m_nTimerID(0),
169 » » m_pEmbedObj(pObj), 167 » » m_pEmbedObj(pObj),
170 m_bProcessing(FALSE), 168 m_bProcessing(FALSE),
171 m_dwStartTime(0), 169 m_dwStartTime(0),
172 m_dwTimeOut(0), 170 m_dwTimeOut(0),
173 m_dwElapse(0), 171 m_dwElapse(0),
174 m_pRuntime(NULL), 172 m_pRuntime(NULL),
175 m_nType(0), 173 m_nType(0),
176 m_pApp(pApp) 174 m_pApp(pApp)
177 { 175 {
178 } 176 }
179 » 177
180 virtual ~CJS_Timer() 178 virtual ~CJS_Timer()
181 { 179 {
182 KillJSTimer(); 180 KillJSTimer();
183 } 181 }
184 182
185 public: 183 public:
186 FX_UINT SetJSTimer(FX_UINT nElapse) 184 FX_UINT SetJSTimer(FX_UINT nElapse)
187 » {» 185 » {
188 if (m_nTimerID)KillJSTimer(); 186 if (m_nTimerID)KillJSTimer();
189 IFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); 187 IFX_SystemHandler* pHandler = m_pApp->GetSysHandler();
190 m_nTimerID = pHandler->SetTimer(nElapse,TimerProc); 188 m_nTimerID = pHandler->SetTimer(nElapse,TimerProc);
191 GetTimeMap().SetAt(m_nTimerID,this); 189 GetTimeMap().SetAt(m_nTimerID,this);
192 m_dwElapse = nElapse; 190 m_dwElapse = nElapse;
193 return m_nTimerID; 191 return m_nTimerID;
194 }; 192 };
195 193
196 void KillJSTimer() 194 void KillJSTimer()
197 { 195 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 234
237 FX_DWORD GetTimeOut() const 235 FX_DWORD GetTimeOut() const
238 { 236 {
239 return m_dwTimeOut; 237 return m_dwTimeOut;
240 } 238 }
241 239
242 void SetRuntime(CJS_Runtime* pRuntime) 240 void SetRuntime(CJS_Runtime* pRuntime)
243 { 241 {
244 m_pRuntime = pRuntime; 242 m_pRuntime = pRuntime;
245 } 243 }
246 » 244
247 CJS_Runtime* GetRuntime() const 245 CJS_Runtime* GetRuntime() const
248 { 246 {
249 return m_pRuntime; 247 return m_pRuntime;
250 } 248 }
251 249
252 void SetJScript(const CFX_WideString& script) 250 void SetJScript(const CFX_WideString& script)
253 { 251 {
254 m_swJScript = script; 252 m_swJScript = script;
255 } 253 }
256 254
(...skipping 13 matching lines...) Expand all
270 pTimer->m_bProcessing = FALSE; 268 pTimer->m_bProcessing = FALSE;
271 } 269 }
272 else 270 else
273 { 271 {
274 // TRACE(L"BUSY!\n"); 272 // TRACE(L"BUSY!\n");
275 } 273 }
276 } 274 }
277 }; 275 };
278 276
279 private: 277 private:
280 » FX_UINT»» » » » » » m_nTimerID;» 278 » FX_UINT»» » » » » » m_nTimerID;
281 CJS_EmbedObj* m_pEmbedObj; 279 CJS_EmbedObj* m_pEmbedObj;
282 FX_BOOL m_bProcessing; 280 FX_BOOL m_bProcessing;
283 281
284 //data 282 //data
285 FX_DWORD m_dwStartTime; 283 FX_DWORD m_dwStartTime;
286 FX_DWORD m_dwTimeOut; 284 FX_DWORD m_dwTimeOut;
287 FX_DWORD m_dwElapse; 285 FX_DWORD m_dwElapse;
288 CJS_Runtime* m_pRuntime; 286 CJS_Runtime* m_pRuntime;
289 CFX_WideString m_swJScript; 287 CFX_WideString m_swJScript;
290 int m_nType; //0:Interval; 1:TimeOut 288 int m_nType; //0:Interval; 1:TimeOut
291 289
292 CPDFDoc_Environment* m_pApp; 290 CPDFDoc_Environment* m_pApp;
293 }; 291 };
294 #endif //_JS_OBJECT_H_ 292 #endif //_JS_OBJECT_H_
OLDNEW
« no previous file with comments | « fpdfsdk/include/fsdk_mgr.h ('k') | fpdfsdk/include/javascript/app.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698