• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef WEBVIEW_FFI_H
17 #define WEBVIEW_FFI_H
18 
19 #include <cstdint>
20 
21 #include "cj_common_ffi.h"
22 #include "ffi_remote_data.h"
23 #include "webview_utils.h"
24 
25 extern "C" {
26 FFI_EXPORT int32_t FfiOHOSWebviewOnce(char* type, void (*callbackRef)(void));
27 
28     // WebMessagePortImpl
29 FFI_EXPORT int64_t FfiOHOSWebviewCtlConstructor();
30 FFI_EXPORT int64_t FfiOHOSWebviewCtlConstructorWithWebTag(char* webTag);
31 FFI_EXPORT void FfiOHOSWebviewCtlInitializeWebEngine();
32 FFI_EXPORT void FfiOHOSWebviewCtlSetHttpDns(int32_t secureDnsMode, char* secureDnsConfig);
33 FFI_EXPORT void FfiOHOSWebviewCtlSetWebDebuggingAccess(bool webDebuggingAccess);
34 FFI_EXPORT int32_t FfiOHOSWebviewCtlLoadUrl(int64_t id, char* url);
35 FFI_EXPORT int32_t FfiOHOSWebviewCtlLoadUrlWithHeaders(int64_t id, char* url, OHOS::Webview::ArrWebHeader headers);
36 FFI_EXPORT int32_t FfiOHOSWebviewCtlLoadData(int64_t id, OHOS::Webview::LoadDatas loadDatas);
37 FFI_EXPORT int32_t FfiOHOSWebviewCtlRefresh(int64_t id);
38 FFI_EXPORT int32_t FFiOHOSWebviewCtlPreFetchPage(int64_t id, char* url);
39 FFI_EXPORT int32_t FFiOHOSWebviewCtlPreFetchPageWithHeaders(
40     int64_t id, char* url, OHOS::Webview::ArrWebHeader headers);
41 FFI_EXPORT int32_t FfiOHOSWebviewCtlSetAudioMuted(int64_t id, bool mute);
42 FFI_EXPORT char* FfiOHOSWebviewCtlGetUserAgent(int64_t id, int32_t* errCode);
43 FFI_EXPORT int32_t FfiOHOSWebviewCtlSetConnectionTimeout(int32_t timeout);
44 FFI_EXPORT int32_t FfiOHOSWebviewCtlGetWebId(int64_t id, int32_t* errCode);
45 FFI_EXPORT bool FfiOHOSWebviewCtlAccessForward(int64_t id, int32_t* errCode);
46 FFI_EXPORT bool FfiOHOSWebviewCtlAccessBackward(int64_t id, int32_t* errCode);
47 FFI_EXPORT int32_t FfiOHOSWebviewCtlSetCustomUserAgent(int64_t id, char* cUserAgent);
48 FFI_EXPORT RetDataCString FfiOHOSWebviewCtlGetCustomUserAgent(int64_t id);
49 FFI_EXPORT int32_t FfiOHOSWebviewCtlRunJavaScript(
50     int64_t id, char* cScript, void (*callbackRef)(RetDataCString infoRef));
51 FFI_EXPORT int32_t FfiOHOSWebviewCtlRunJavaScriptExt(int64_t id, char* cScript, void (*callbackRef)(RetDataI64));
52 FFI_EXPORT int32_t FfiOHOSWebviewCtlRunJavaScriptExtArr(
53     int64_t id, CArrUI8 cScript, void (*callbackRef)(RetDataI64));
54 FFI_EXPORT int32_t FfiOHOSWebviewCtlRegisterJavaScriptProxy(
55     int64_t id, CArrI64 cFuncIds, const char* cName, CArrString cMethodList);
56 FFI_EXPORT int32_t FfiOHOSWebviewCtlRegisterJavaScriptProxyEx(
57     int64_t id, CArrI64 cFuncIds, const char* cName, CArrString cMethodList, char* cPermission);
58 FFI_EXPORT RetDataCString FfiOHOSWebviewCtlGetUrl(int64_t id);
59 FFI_EXPORT RetDataCString FfiOHOSWebviewCtlGetOriginalUrl(int64_t id);
60 FFI_EXPORT int32_t FfiOHOSWebviewCtlPageUp(int64_t id, bool top);
61 FFI_EXPORT int32_t FfiOHOSWebviewCtlPageDown(int64_t id, bool bottom);
62 FFI_EXPORT int32_t FfiOHOSWebviewCtlScrollTo(int64_t id, float x, float y);
63 FFI_EXPORT int32_t FfiOHOSWebviewCtlScrollBy(int64_t id, float deltaX, float deltaY);
64 FFI_EXPORT int32_t FfiOHOSWebviewCtlScrollToWithAnime(int64_t id, float x, float y, int32_t duration);
65 FFI_EXPORT int32_t FfiOHOSWebviewCtlScrollByWithAnime(int64_t id, float deltaX, float deltaY, int32_t duration);
66 FFI_EXPORT int32_t FfiOHOSWebviewCtlForward(int64_t id);
67 FFI_EXPORT int32_t FfiOHOSWebviewCtlBackward(int64_t id);
68 FFI_EXPORT int32_t FfiOHOSWebviewCtlBackOrForward(int64_t id, int32_t step);
69 FFI_EXPORT int32_t FfiOHOSWebviewCtlGetProgress(int64_t id, int32_t* errCode);
70 FFI_EXPORT int32_t FfiOHOSWebviewCtlGetPageHeight(int64_t id, int32_t* errCode);
71 FFI_EXPORT RetDataCString FfiOHOSWebviewCtlGetTitle(int64_t id);
72 FFI_EXPORT int32_t FfiOHOSWebviewCtlZoom(int64_t id, float factor);
73 FFI_EXPORT int32_t FfiOHOSWebviewCtlZoomIn(int64_t id);
74 FFI_EXPORT int32_t FfiOHOSWebviewCtlZoomOut(int64_t id);
75 FFI_EXPORT int32_t FfiOHOSWebviewCtlRequestFocus(int64_t id);
76 FFI_EXPORT int32_t FfiOHOSWebviewCtlClearHistory(int64_t id);
77 FFI_EXPORT bool FfiOHOSWebviewCtlAccessStep(int64_t id, int32_t* errCode, int32_t step);
78 FFI_EXPORT int32_t FfiOHOSWebviewCtlOnActive(int64_t id);
79 FFI_EXPORT int32_t FfiOHOSWebviewCtlOnInactive(int64_t id);
80 FFI_EXPORT int32_t FfiOHOSWebviewCtlGetHitTest(int64_t id, int32_t* errCode);
81 FFI_EXPORT RetDataCString FfiOHOSWebviewCtlGetHitTestValue(int64_t id, int32_t* errCode);
82 FFI_EXPORT int32_t FfiOHOSWebviewCtlStoreWebArchive(
83     int64_t id, const char* cBaseName, bool autoName, void (*callbackRef)(RetDataCString infoRef));
84 FFI_EXPORT int32_t FfiOHOSWebviewCtlEnableSafeBrowsing(int64_t id, bool enable);
85 FFI_EXPORT bool FfiOHOSWebviewCtlIsSafeBrowsingEnabled(int64_t id, int32_t* errCode);
86 FFI_EXPORT int32_t FfiOHOSWebviewCtlGetSecurityLevel(int64_t id, int32_t* errCode);
87 FFI_EXPORT bool FfiOHOSWebviewCtlIsIncognitoMode(int64_t id, int32_t* errCode);
88 FFI_EXPORT int32_t FfiOHOSWebviewCtlRemoveCache(int64_t id, bool clearRom);
89 FFI_EXPORT int64_t FfiOHOSWebviewCtlGetBackForwardEntries(int64_t id, int32_t* errCode);
90 FFI_EXPORT int32_t FfiOHOSWebviewCtlStop(int64_t id);
91 FFI_EXPORT int64_t FfiOHOSWebviewCtlGetFavicon(int64_t id, int32_t* errCode);
92 FFI_EXPORT int32_t FfiOHOSWebviewCtlPrepareForPageLoad(char* url, bool preconnectable, int32_t numSockets);
93 FFI_EXPORT int32_t FfiOHOSWebviewCtlSlideScroll(int64_t id, float vx, float vy);
94 FFI_EXPORT int32_t FfiOHOSWebviewCtlSetNetworkAvailable(int64_t id, bool enable);
95 FFI_EXPORT int32_t FfiOHOSWebviewCtlClearClientAuthenticationCache(int64_t id);
96 FFI_EXPORT int32_t FfiOHOSWebviewCtlClearSslChache(int64_t id);
97 FFI_EXPORT int32_t FfiOHOSWebviewCtlSearchNext(int64_t id, bool forward);
98 FFI_EXPORT int32_t FfiOHOSWebviewCtlClearMatches(int64_t id);
99 FFI_EXPORT int32_t FfiOHOSWebviewCtlSearchAllAsync(int64_t id, char* searchString);
100 FFI_EXPORT int32_t FfiOHOSWebviewCtlDeleteJavaScriptRegister(int64_t id, char* name);
101 FFI_EXPORT int32_t FfiOHOSWebviewCtlPostUrl(int64_t id, char* url, CArrUI8 buffer);
102 FFI_EXPORT int32_t FfiOHOSWebviewCtlSetDownloadDelegate(int64_t id, int64_t delegateId);
103 FFI_EXPORT int32_t FfiOHOSWebviewCtlStartDownload(int64_t id, char* url);
104 FFI_EXPORT CArrI64 FfiOHOSWebviewCtlCreateWebMessagePorts(int64_t id, bool isExtentionType, int32_t* errCode);
105 FFI_EXPORT int32_t FfiOHOSWebviewCtlPostMessage(int64_t id, char* name, CArrI64 ports, char* uri);
106 FFI_EXPORT CArrUI8 FfiOHOSWebviewCtlSerializeWebState(int64_t id, int32_t* errCode);
107 FFI_EXPORT int32_t FfiOHOSWebviewCtlRestoreWebState(int64_t id, CArrUI8 cState);
108 FFI_EXPORT CArrString FfiOHOSWebviewCtlGetCertificate(int64_t id, int32_t* errCode);
109 FFI_EXPORT OHOS::Webview::CCertByteData FfiOHOSWebviewCtlGetCertificateByte(int64_t id, int32_t* errCode);
110 FFI_EXPORT int32_t FfiOHOSWebviewCtlHasImage(int64_t id, void (*callbackRef)(RetDataBool));
111 FFI_EXPORT int32_t FfiWebviewCtlCustomizeSchemes(OHOS::Webview::CArrScheme schemes);
112 FFI_EXPORT bool FfiOHOSWebviewCtlTerminateRenderProcess(int64_t id, int32_t* errCode);
113 FFI_EXPORT int32_t FfiOHOSWebviewCtlCloseAllMediaPresentations(int64_t id);
114 FFI_EXPORT int32_t FfiOHOSWebviewCtlPauseAllMedia(int64_t id);
115 FFI_EXPORT int32_t FfiOHOSWebviewCtlResumeAllMedia(int64_t id);
116 FFI_EXPORT int32_t FfiOHOSWebviewCtlStopAllMedia(int64_t id);
117 FFI_EXPORT void FfiOHOSWebviewCtlResumeAllTimers();
118 FFI_EXPORT void FfiOHOSWebviewCtlPauseAllTimers();
119 FFI_EXPORT int32_t FfiOHOSWebviewCtlSetPrintBackground(int64_t id, bool enable);
120 FFI_EXPORT bool FfiOHOSWebviewCtlGetPrintBackground(int64_t id, int32_t* errCode);
121 FFI_EXPORT int32_t FfiOHOSWebviewCtlSetScrollable(int64_t id, bool enable);
122 FFI_EXPORT bool FfiOHOSWebviewCtlGetScrollable(int64_t id, int32_t* errCode);
123 FFI_EXPORT void FfiOHOSWebviewCtlEnableAdsBlock(int64_t id, bool enable);
124 FFI_EXPORT bool FfiOHOSWebviewCtlIsAdsBlockEnabled(int64_t id);
125 FFI_EXPORT bool FfiOHOSWebviewCtlIsAdsBlockEnabledForCurPage(int64_t id);
126 FFI_EXPORT bool FfiOHOSWebviewCtlIsIntelligentTrackingPreventionEnabled(int64_t id, int32_t* errorCode);
127 FFI_EXPORT int32_t FfiOHOSWebviewCtlEnableIntelligentTrackingPrevention(int64_t id, bool enable);
128 FFI_EXPORT int32_t FfiOHOSWebviewCtlGetMediaPlaybackState(int64_t id, int32_t* errorCode);
129 FFI_EXPORT int32_t FfiOHOSWebviewCtlGetRenderProcessMode();
130 FFI_EXPORT void FfiOHOSWebviewCtlSetRenderProcessMode(int32_t mode);
131 FFI_EXPORT int32_t FfiOHOSWebviewCtlWarmupServiceWorker(char* url);
132 FFI_EXPORT int32_t FfiOHOSWebviewCtlSetHostIP(char* hostname, char* address, int32_t aliveTime);
133 FFI_EXPORT int32_t FfiOHOSWebviewCtlClearHostIP(char* hostname);
134 FFI_EXPORT RetDataCString FfiOHOSWebviewCtlGetLastJavascriptProxyCallingFrameUrl(int64_t id);
135 FFI_EXPORT int32_t FfiOHOSWebviewCtlEnableWholeWebPageDrawing();
136 FFI_EXPORT int32_t FfiOHOSWebviewCtlClearPrefetchedResource(CArrString cacheKeyList);
137 FFI_EXPORT int32_t FfiOHOSWebviewCtlStartCamera(int64_t id);
138 FFI_EXPORT int32_t FfiOHOSWebviewCtlStopCamera(int64_t id);
139 FFI_EXPORT int32_t FfiOHOSWebviewCtlCloseCamera(int64_t id);
140 FFI_EXPORT int32_t FfiOHOSWebviewCtlAvoidVisibleViewportBottom(int64_t id, int32_t avoidHeight);
141 
142 FFI_EXPORT int32_t FfiOHOSWebviewCtlAddIntelligentTrackingPreventionBypassingList(CArrString hostList);
143 FFI_EXPORT void FfiOHOSWebviewCtlClearIntelligentTrackingPreventionBypassingList();
144 FFI_EXPORT void FfiOHOSWebviewCtlEnableBackForwardCache(bool nativeEmbed, bool mediaTakeOver);
145 FFI_EXPORT RetDataCString FfiOHOSWebviewCtlGetSurfaceId(int64_t id);
146 FFI_EXPORT int32_t FfiOHOSWebviewCtlInjectOfflineResources(int64_t id, OHOS::Webview::CArrOfflineResourceMap maps);
147 FFI_EXPORT void FfiOHOSWebviewCtlRemoveIntelligentTrackingPreventionBypassingList(CArrString hostList);
148 FFI_EXPORT int32_t FfiOHOSWebviewCtlSetBackForwardCacheOptions(int64_t id, int32_t size, int32_t timeToLive);
149 FFI_EXPORT int32_t FfiOHOSWebviewCtlSetPathAllowingUniversalAccess(int64_t id, CArrString pathList);
150 FFI_EXPORT int32_t FfiOHOSWebviewCtlSetUrlTrustList(int64_t id, char* cUrl);
151 FFI_EXPORT int32_t FfiOHOSWebviewCtlPrefetchResource(OHOS::Webview::CRequestInfo request,
152     OHOS::Webview::ArrWebHeader additionalHttpHeaders, char* cKey, int32_t cacheValidTime);
153 FFI_EXPORT void FfiOHOSWebviewCtlSetWebSchemeHandler(int64_t id, char* cScheme, int64_t classId, int32_t *errCode);
154 FFI_EXPORT int32_t FfiOHOSWebviewCtlClearWebSchemeHandler(int64_t id);
155 FFI_EXPORT int32_t FfiOHOSWebviewCtlSetServiceWorkerWebSchemeHandler(char* cScheme, int64_t classId);
156 FFI_EXPORT int32_t FfiOHOSWebviewCtlClearServiceWorkerWebSchemeHandler();
157 FFI_EXPORT void FfiOHOSWebviewCtlOnCreateNativeMediaPlayer(int64_t id,
158     int64_t (* callback)(int64_t, OHOS::Webview::CMediaInfo));
159 FFI_EXPORT int32_t FfiOHOSWebviewCtlPrecompileJavaScript(int64_t id,
160     char* url, char* script, OHOS::Webview::CacheOptions cacheOptions);
161 FFI_EXPORT int32_t FfiOHOSWebviewCtlWebPageSnapshot(int64_t id, OHOS::Webview::CSnapshotInfo snapshot,
162     void (*callbackRef)(OHOS::Webview::RetDataCSnapshotResult infoRef));
163 FFI_EXPORT OHOS::Webview::CScrollOffset FfiOHOSWebviewCtlgetScrollOffset(int64_t id, int32_t* errorCode);
164 FFI_EXPORT int32_t FfiOHOSWebviewCtlSetScrollableEx(int64_t id, bool enable, int32_t scrollType);
165 FFI_EXPORT bool FfiOHOSWebviewCtlScrollByWithResult(int64_t id, float deltaX, float deltaY, int32_t* errorCode);
166 
167     // BackForwardList
168 FFI_EXPORT int32_t FfiOHOSBackForwardListCurrentIndex(int64_t id, int32_t* errCode);
169 FFI_EXPORT int32_t FfiOHOSBackForwardListSize(int64_t id, int32_t* errCode);
170 FFI_EXPORT OHOS::Webview::CHistoryItem FfiOHOSGetItemAtIndex(int64_t id, int32_t index, int32_t* errCode);
171 FFI_EXPORT RetDataCString FfiOHOSWebviewCtlGetLastHitTest(int64_t id, int32_t* errCode);
172 }
173 
174 #endif // WEBVIEW_FFI_H