K. Moon | 832a694 | 2022-10-31 20:11:31 +0000 | [diff] [blame] | 1 | // Copyright 2014 The PDFium Authors |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 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 | |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 7 | #ifndef XFA_FXFA_CXFA_FFAPP_H_ |
| 8 | #define XFA_FXFA_CXFA_FFAPP_H_ |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 9 | |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 10 | #include "core/fxcrt/unowned_ptr.h" |
Tom Sepez | 1e151c6 | 2021-11-22 23:46:09 +0000 | [diff] [blame] | 11 | #include "core/fxcrt/widestring.h" |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 12 | #include "fxjs/gc/heap.h" |
| 13 | #include "v8/include/cppgc/garbage-collected.h" |
| 14 | #include "v8/include/cppgc/member.h" |
dsinclair | 447b1f3 | 2016-12-08 10:06:32 -0800 | [diff] [blame] | 15 | #include "xfa/fwl/cfwl_app.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 16 | |
Lei Zhang | 6e59fb5 | 2018-01-18 19:03:58 +0000 | [diff] [blame] | 17 | class CFWL_WidgetMgr; |
Tom Sepez | ba61796 | 2021-06-08 23:21:19 +0000 | [diff] [blame] | 18 | class CXFA_FFDoc; |
Lei Zhang | 6e59fb5 | 2018-01-18 19:03:58 +0000 | [diff] [blame] | 19 | class CXFA_FWLAdapterWidgetMgr; |
| 20 | class CXFA_FWLTheme; |
Tom Sepez | ba61796 | 2021-06-08 23:21:19 +0000 | [diff] [blame] | 21 | class CXFA_FontMgr; |
| 22 | class IFX_SeekableReadStream; |
| 23 | |
Tom Sepez | 327a070 | 2021-10-15 19:38:55 +0000 | [diff] [blame] | 24 | class CXFA_FFApp final : public cppgc::GarbageCollected<CXFA_FFApp>, |
| 25 | public CFWL_App::AdapterIface { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 26 | public: |
Tom Sepez | dc3718f | 2021-06-09 01:01:29 +0000 | [diff] [blame] | 27 | class CallbackIface { |
| 28 | public: |
| 29 | virtual ~CallbackIface() = default; |
| 30 | |
| 31 | /** |
| 32 | * Returns the language of the running host application. Such as zh_CN |
| 33 | */ |
| 34 | virtual WideString GetLanguage() = 0; |
| 35 | |
| 36 | /** |
| 37 | * Returns the platform of the machine running the script. Such as WIN |
| 38 | */ |
| 39 | virtual WideString GetPlatform() = 0; |
| 40 | |
| 41 | /** |
| 42 | * Get application name, such as Phantom. |
| 43 | */ |
| 44 | virtual WideString GetAppName() = 0; |
| 45 | |
| 46 | /** |
| 47 | * Get application message box title. |
| 48 | */ |
| 49 | virtual WideString GetAppTitle() const = 0; |
| 50 | |
| 51 | /** |
| 52 | * Causes the system to play a sound. |
| 53 | * @param[in] dwType The system code for the appropriate sound.0 (Error)1 |
| 54 | * (Warning)2 (Question)3 (Status)4 (Default) |
| 55 | */ |
| 56 | virtual void Beep(uint32_t dwType) = 0; |
| 57 | |
| 58 | /** |
| 59 | * Displays a message box. |
| 60 | * @param[in] wsMessage - Message string to display in box. |
| 61 | * @param[in] wsTitle - Title string for box. |
| 62 | * @param[in] dwIconType - Icon type, refer to XFA_MBICON. |
| 63 | * @param[in] dwButtonType - Button type, refer to XFA_MESSAGEBUTTON. |
| 64 | * @return A valid integer representing the value of the button pressed by |
| 65 | * the user, refer to XFA_ID. |
| 66 | */ |
| 67 | virtual int32_t MsgBox(const WideString& wsMessage, |
| 68 | const WideString& wsTitle, |
| 69 | uint32_t dwIconType, |
| 70 | uint32_t dwButtonType) = 0; |
| 71 | |
| 72 | /** |
| 73 | * Get a response from the user. |
| 74 | * @param[in] wsQuestion - Message string to display in box. |
| 75 | * @param[in] wsTitle - Title string for box. |
| 76 | * @param[in] wsDefaultAnswer - Initial contents for answer. |
| 77 | * @param[in] bMask - Mask the user input with asterisks when |
| 78 | * true, |
| 79 | * @return A string containing the user's response. |
| 80 | */ |
| 81 | virtual WideString Response(const WideString& wsQuestion, |
| 82 | const WideString& wsTitle, |
| 83 | const WideString& wsDefaultAnswer, |
| 84 | bool bMask) = 0; |
| 85 | |
| 86 | /** |
| 87 | * Download something from somewhere. |
| 88 | * @param[in] wsURL - http, ftp, such as |
| 89 | * "http://www.w3.org/TR/REC-xml-names/". |
| 90 | */ |
| 91 | virtual RetainPtr<IFX_SeekableReadStream> DownloadURL( |
| 92 | const WideString& wsURL) = 0; |
| 93 | |
| 94 | /** |
| 95 | * POST data to the given url. |
| 96 | * @param[in] wsURL the URL being uploaded. |
| 97 | * @param[in] wsData the data being uploaded. |
| 98 | * @param[in] wsContentType the content type of data including text/html, |
| 99 | * text/xml, text/plain, multipart/form-data, |
| 100 | * application/x-www-form-urlencoded, |
| 101 | * application/octet-stream, any valid MIME type. |
| 102 | * @param[in] wsEncode the encode of data including UTF-8, UTF-16, |
| 103 | * ISO8859-1, any recognized [IANA]character encoding |
| 104 | * @param[in] wsHeader any additional HTTP headers to be included in |
| 105 | * the post. |
| 106 | * @param[out] wsResponse decoded response from server. |
| 107 | * @return true Server permitted the post request, false otherwise. |
| 108 | */ |
| 109 | virtual bool PostRequestURL(const WideString& wsURL, |
| 110 | const WideString& wsData, |
| 111 | const WideString& wsContentType, |
| 112 | const WideString& wsEncode, |
| 113 | const WideString& wsHeader, |
| 114 | WideString& wsResponse) = 0; |
| 115 | |
| 116 | /** |
| 117 | * PUT data to the given url. |
| 118 | * @param[in] wsURL the URL being uploaded. |
| 119 | * @param[in] wsData the data being uploaded. |
| 120 | * @param[in] wsEncode the encode of data including UTF-8, UTF-16, |
| 121 | * ISO8859-1, any recognized [IANA]character encoding |
| 122 | * @return true Server permitted the post request, false otherwise. |
| 123 | */ |
| 124 | virtual bool PutRequestURL(const WideString& wsURL, |
| 125 | const WideString& wsData, |
| 126 | const WideString& wsEncode) = 0; |
| 127 | |
| 128 | virtual CFX_Timer::HandlerIface* GetTimerHandler() const = 0; |
| 129 | virtual cppgc::Heap* GetGCHeap() const = 0; |
| 130 | }; |
| 131 | |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 132 | CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED; |
Tom Sepez | 1289953 | 2019-05-30 00:06:33 +0000 | [diff] [blame] | 133 | ~CXFA_FFApp() override; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 134 | |
Tom Sepez | 1289953 | 2019-05-30 00:06:33 +0000 | [diff] [blame] | 135 | // CFWL_App::AdapterIface: |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 136 | void Trace(cppgc::Visitor* visitor) const override; |
Tom Sepez | 1289953 | 2019-05-30 00:06:33 +0000 | [diff] [blame] | 137 | CFWL_WidgetMgr::AdapterIface* GetWidgetMgrAdapter() override; |
Tom Sepez | 8a5699d | 2020-10-13 21:23:53 +0000 | [diff] [blame] | 138 | CFX_Timer::HandlerIface* GetTimerHandler() override; |
Tom Sepez | a911672 | 2020-08-13 22:18:18 +0000 | [diff] [blame] | 139 | IFWL_ThemeProvider* GetThemeProvider() override; |
Tom Sepez | 6602876 | 2020-08-18 20:35:37 +0000 | [diff] [blame] | 140 | cppgc::Heap* GetHeap() override; |
Tom Sepez | 1289953 | 2019-05-30 00:06:33 +0000 | [diff] [blame] | 141 | |
Tom Sepez | a911672 | 2020-08-13 22:18:18 +0000 | [diff] [blame] | 142 | bool LoadFWLTheme(CXFA_FFDoc* doc); |
Dan Sinclair | a5eb9f0 | 2017-09-21 15:43:56 -0400 | [diff] [blame] | 143 | CFWL_WidgetMgr* GetFWLWidgetMgr() const { return m_pFWLApp->GetWidgetMgr(); } |
Tom Sepez | 0c3768e | 2022-10-27 23:41:46 +0000 | [diff] [blame] | 144 | CallbackIface* GetAppProvider() const { return m_pProvider; } |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 145 | CFWL_App* GetFWLApp() const { return m_pFWLApp; } |
Tom Sepez | a7edf06 | 2020-09-09 22:48:17 +0000 | [diff] [blame] | 146 | CXFA_FontMgr* GetXFAFontMgr() const { return m_pXFAFontMgr; } |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 147 | |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 148 | private: |
Tom Sepez | dc3718f | 2021-06-09 01:01:29 +0000 | [diff] [blame] | 149 | explicit CXFA_FFApp(CallbackIface* pProvider); |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 150 | |
Tom Sepez | dc3718f | 2021-06-09 01:01:29 +0000 | [diff] [blame] | 151 | UnownedPtr<CallbackIface> const m_pProvider; |
Tom Sepez | a7edf06 | 2020-09-09 22:48:17 +0000 | [diff] [blame] | 152 | cppgc::Member<CXFA_FontMgr> m_pXFAFontMgr; |
Tom Sepez | 0a9d974 | 2020-09-01 21:40:52 +0000 | [diff] [blame] | 153 | cppgc::Member<CXFA_FWLAdapterWidgetMgr> m_pAdapterWidgetMgr; |
| 154 | cppgc::Member<CXFA_FWLTheme> m_pFWLTheme; |
| 155 | cppgc::Member<CFWL_App> m_pFWLApp; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 156 | }; |
| 157 | |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 158 | #endif // XFA_FXFA_CXFA_FFAPP_H_ |