• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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 FXJS_CJS_APP_H_
8 #define FXJS_CJS_APP_H_
9 
10 #include <memory>
11 #include <set>
12 #include <vector>
13 
14 #include "fxjs/cjs_object.h"
15 #include "fxjs/js_define.h"
16 
17 class CJS_Runtime;
18 class GlobalTimer;
19 
20 class CJS_App final : public CJS_Object {
21  public:
22   static int GetObjDefnID();
23   static void DefineJSObjects(CFXJS_Engine* pEngine);
24 
25   CJS_App(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
26   ~CJS_App() override;
27 
28   void TimerProc(GlobalTimer* pTimer);
29   void CancelProc(GlobalTimer* pTimer);
30 
31   static WideString SysPathToPDFPath(const WideString& sOldPath);
32 
33   JS_STATIC_PROP(activeDocs, active_docs, CJS_App)
34   JS_STATIC_PROP(calculate, calculate, CJS_App)
35   JS_STATIC_PROP(formsVersion, forms_version, CJS_App)
36   JS_STATIC_PROP(fs, fs, CJS_App)
37   JS_STATIC_PROP(fullscreen, fullscreen, CJS_App)
38   JS_STATIC_PROP(language, language, CJS_App)
39   JS_STATIC_PROP(media, media, CJS_App)
40   JS_STATIC_PROP(platform, platform, CJS_App)
41   JS_STATIC_PROP(runtimeHighlight, runtime_highlight, CJS_App)
42   JS_STATIC_PROP(viewerType, viewer_type, CJS_App)
43   JS_STATIC_PROP(viewerVariation, viewer_variation, CJS_App)
44   JS_STATIC_PROP(viewerVersion, viewer_version, CJS_App)
45 
46   JS_STATIC_METHOD(alert, CJS_App)
47   JS_STATIC_METHOD(beep, CJS_App)
48   JS_STATIC_METHOD(browseForDoc, CJS_App)
49   JS_STATIC_METHOD(clearInterval, CJS_App)
50   JS_STATIC_METHOD(clearTimeOut, CJS_App)
51   JS_STATIC_METHOD(execDialog, CJS_App)
52   JS_STATIC_METHOD(execMenuItem, CJS_App)
53   JS_STATIC_METHOD(findComponent, CJS_App)
54   JS_STATIC_METHOD(goBack, CJS_App)
55   JS_STATIC_METHOD(goForward, CJS_App)
56   JS_STATIC_METHOD(launchURL, CJS_App)
57   JS_STATIC_METHOD(mailMsg, CJS_App)
58   JS_STATIC_METHOD(newFDF, CJS_App)
59   JS_STATIC_METHOD(newDoc, CJS_App)
60   JS_STATIC_METHOD(openDoc, CJS_App)
61   JS_STATIC_METHOD(openFDF, CJS_App)
62   JS_STATIC_METHOD(popUpMenuEx, CJS_App)
63   JS_STATIC_METHOD(popUpMenu, CJS_App)
64   JS_STATIC_METHOD(response, CJS_App)
65   JS_STATIC_METHOD(setInterval, CJS_App)
66   JS_STATIC_METHOD(setTimeOut, CJS_App)
67 
68  private:
69   static int ObjDefnID;
70   static const char kName[];
71   static const JSPropertySpec PropertySpecs[];
72   static const JSMethodSpec MethodSpecs[];
73 
74   CJS_Result get_active_docs(CJS_Runtime* pRuntime);
75   CJS_Result set_active_docs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
76 
77   CJS_Result get_calculate(CJS_Runtime* pRuntime);
78   CJS_Result set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
79 
80   CJS_Result get_forms_version(CJS_Runtime* pRuntime);
81   CJS_Result set_forms_version(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
82 
83   CJS_Result get_fs(CJS_Runtime* pRuntime);
84   CJS_Result set_fs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
85 
86   CJS_Result get_fullscreen(CJS_Runtime* pRuntime);
87   CJS_Result set_fullscreen(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
88 
89   CJS_Result get_language(CJS_Runtime* pRuntime);
90   CJS_Result set_language(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
91 
92   CJS_Result get_media(CJS_Runtime* pRuntime);
93   CJS_Result set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
94 
95   CJS_Result get_platform(CJS_Runtime* pRuntime);
96   CJS_Result set_platform(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
97 
98   CJS_Result get_runtime_highlight(CJS_Runtime* pRuntime);
99   CJS_Result set_runtime_highlight(CJS_Runtime* pRuntime,
100                                    v8::Local<v8::Value> vp);
101 
102   CJS_Result get_viewer_type(CJS_Runtime* pRuntime);
103   CJS_Result set_viewer_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
104 
105   CJS_Result get_viewer_variation(CJS_Runtime* pRuntime);
106   CJS_Result set_viewer_variation(CJS_Runtime* pRuntime,
107                                   v8::Local<v8::Value> vp);
108 
109   CJS_Result get_viewer_version(CJS_Runtime* pRuntime);
110   CJS_Result set_viewer_version(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
111 
112   CJS_Result alert(CJS_Runtime* pRuntime,
113                    const std::vector<v8::Local<v8::Value>>& params);
114   CJS_Result beep(CJS_Runtime* pRuntime,
115                   const std::vector<v8::Local<v8::Value>>& params);
116   CJS_Result browseForDoc(CJS_Runtime* pRuntime,
117                           const std::vector<v8::Local<v8::Value>>& params);
118   CJS_Result clearInterval(CJS_Runtime* pRuntime,
119                            const std::vector<v8::Local<v8::Value>>& params);
120   CJS_Result clearTimeOut(CJS_Runtime* pRuntime,
121                           const std::vector<v8::Local<v8::Value>>& params);
122   CJS_Result execDialog(CJS_Runtime* pRuntime,
123                         const std::vector<v8::Local<v8::Value>>& params);
124   CJS_Result execMenuItem(CJS_Runtime* pRuntime,
125                           const std::vector<v8::Local<v8::Value>>& params);
126   CJS_Result findComponent(CJS_Runtime* pRuntime,
127                            const std::vector<v8::Local<v8::Value>>& params);
128   CJS_Result goBack(CJS_Runtime* pRuntime,
129                     const std::vector<v8::Local<v8::Value>>& params);
130   CJS_Result goForward(CJS_Runtime* pRuntime,
131                        const std::vector<v8::Local<v8::Value>>& params);
132   CJS_Result launchURL(CJS_Runtime* pRuntime,
133                        const std::vector<v8::Local<v8::Value>>& params);
134   CJS_Result mailMsg(CJS_Runtime* pRuntime,
135                      const std::vector<v8::Local<v8::Value>>& params);
136   CJS_Result newFDF(CJS_Runtime* pRuntime,
137                     const std::vector<v8::Local<v8::Value>>& params);
138   CJS_Result newDoc(CJS_Runtime* pRuntime,
139                     const std::vector<v8::Local<v8::Value>>& params);
140   CJS_Result openDoc(CJS_Runtime* pRuntime,
141                      const std::vector<v8::Local<v8::Value>>& params);
142   CJS_Result openFDF(CJS_Runtime* pRuntime,
143                      const std::vector<v8::Local<v8::Value>>& params);
144   CJS_Result popUpMenuEx(CJS_Runtime* pRuntime,
145                          const std::vector<v8::Local<v8::Value>>& params);
146   CJS_Result popUpMenu(CJS_Runtime* pRuntime,
147                        const std::vector<v8::Local<v8::Value>>& params);
148   CJS_Result response(CJS_Runtime* pRuntime,
149                       const std::vector<v8::Local<v8::Value>>& params);
150   CJS_Result setInterval(CJS_Runtime* pRuntime,
151                          const std::vector<v8::Local<v8::Value>>& params);
152   CJS_Result setTimeOut(CJS_Runtime* pRuntime,
153                         const std::vector<v8::Local<v8::Value>>& params);
154 
155   void RunJsScript(CJS_Runtime* pRuntime, const WideString& wsScript);
156   void ClearTimerCommon(CJS_Runtime* pRuntime, v8::Local<v8::Value> param);
157 
158   bool m_bCalculate = true;
159   bool m_bRuntimeHighLight = false;
160   std::set<std::unique_ptr<GlobalTimer>> m_Timers;
161 };
162 
163 #endif  // FXJS_CJS_APP_H_
164