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