blob: 59cb220ceec3cb321e1778b8a29f8cc246a350f9 [file] [log] [blame]
Lei Zhang94293682016-01-27 18:27:56 -08001// 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
dsinclairbec76922016-09-29 16:52:30 -07007#ifndef FPDFSDK_FPDFXFA_FPDFXFA_APP_H_
8#define FPDFSDK_FPDFXFA_FPDFXFA_APP_H_
Lei Zhang94293682016-01-27 18:27:56 -08009
dsinclair5b493092016-09-29 20:20:24 -070010#include "xfa/fxfa/fxfa.h"
Lei Zhang94293682016-01-27 18:27:56 -080011
dsinclair79db6092016-09-14 07:27:21 -070012class CPDFSDK_Environment;
Lei Zhang94293682016-01-27 18:27:56 -080013class IFXJS_Runtime;
14
15class CPDFXFA_App : public IXFA_AppProvider {
16 public:
17 static CPDFXFA_App* GetInstance();
18 static void ReleaseInstance();
19
20 CPDFXFA_App();
21 ~CPDFXFA_App() override;
22
dsinclairec3da5b2016-05-25 16:42:05 -070023 FX_BOOL Initialize(v8::Isolate* pIsolate);
weili2d5b0202016-08-03 11:06:49 -070024 CXFA_FFApp* GetXFAApp() { return m_pXFAApp.get(); }
Lei Zhang94293682016-01-27 18:27:56 -080025
dsinclair79db6092016-09-14 07:27:21 -070026 FX_BOOL AddFormFillEnv(CPDFSDK_Environment* pEnv);
27 FX_BOOL RemoveFormFillEnv(CPDFSDK_Environment* pEnv);
Lei Zhang94293682016-01-27 18:27:56 -080028
29 FX_BOOL IsJavaScriptInitialized() const { return m_bJavaScriptInitialized; }
30 void SetJavaScriptInitialized(FX_BOOL bInitialized) {
31 m_bJavaScriptInitialized = bInitialized;
32 }
33
dsinclairec3da5b2016-05-25 16:42:05 -070034 v8::Isolate* GetJSERuntime() const { return m_pIsolate; }
Lei Zhang94293682016-01-27 18:27:56 -080035
36 // IFXA_AppProvider:
37 void GetAppType(CFX_WideString& wsAppType) override;
38 void SetAppType(const CFX_WideStringC& wsAppType) override;
39
40 void GetLanguage(CFX_WideString& wsLanguage) override;
41 void GetPlatform(CFX_WideString& wsPlatform) override;
42 void GetVariation(CFX_WideString& wsVariation) override;
43 void GetVersion(CFX_WideString& wsVersion) override;
Lei Zhang94293682016-01-27 18:27:56 -080044 void GetAppName(CFX_WideString& wsName) override;
Lei Zhang94293682016-01-27 18:27:56 -080045
tsepezc3255f52016-03-25 14:52:27 -070046 void Beep(uint32_t dwType) override;
tsepez3f80c862016-05-16 12:03:24 -070047 int32_t MsgBox(const CFX_WideString& wsMessage,
48 const CFX_WideString& wsTitle,
tsepezc3255f52016-03-25 14:52:27 -070049 uint32_t dwIconType,
50 uint32_t dwButtonType) override;
tsepez3f80c862016-05-16 12:03:24 -070051 CFX_WideString Response(const CFX_WideString& wsQuestion,
52 const CFX_WideString& wsTitle,
53 const CFX_WideString& wsDefaultAnswer,
54 FX_BOOL bMark) override;
Lei Zhang94293682016-01-27 18:27:56 -080055
tsepez3f80c862016-05-16 12:03:24 -070056 IFX_FileRead* DownloadURL(const CFX_WideString& wsURL) override;
57 FX_BOOL PostRequestURL(const CFX_WideString& wsURL,
58 const CFX_WideString& wsData,
59 const CFX_WideString& wsContentType,
60 const CFX_WideString& wsEncode,
61 const CFX_WideString& wsHeader,
Lei Zhang94293682016-01-27 18:27:56 -080062 CFX_WideString& wsResponse) override;
tsepez3f80c862016-05-16 12:03:24 -070063 FX_BOOL PutRequestURL(const CFX_WideString& wsURL,
64 const CFX_WideString& wsData,
65 const CFX_WideString& wsEncode) override;
Lei Zhang94293682016-01-27 18:27:56 -080066
67 void LoadString(int32_t iStringID, CFX_WideString& wsString) override;
Lei Zhang94293682016-01-27 18:27:56 -080068 IFWL_AdapterTimerMgr* GetTimerMgr() override;
69
dsinclair79db6092016-09-14 07:27:21 -070070 CFX_ArrayTemplate<CPDFSDK_Environment*> m_pEnvList;
Lei Zhang94293682016-01-27 18:27:56 -080071
72 protected:
Lei Zhang94293682016-01-27 18:27:56 -080073 FX_BOOL m_bJavaScriptInitialized;
weili2d5b0202016-08-03 11:06:49 -070074 std::unique_ptr<CXFA_FFApp> m_pXFAApp;
dsinclairec3da5b2016-05-25 16:42:05 -070075 v8::Isolate* m_pIsolate;
Lei Zhang94293682016-01-27 18:27:56 -080076 CFX_WideString m_csAppType;
77};
78
dsinclairbec76922016-09-29 16:52:30 -070079#endif // FPDFSDK_FPDFXFA_FPDFXFA_APP_H_