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_SCHEME_FFI_H 17 #define WEBVIEW_SCHEME_FFI_H 18 19 #include "ffi_remote_data.h" 20 #include "webview_utils.h" 21 #include "cj_common_ffi.h" 22 23 extern "C" { 24 // WebHttpBodyStream 25 FFI_EXPORT int64_t FfiWebHttpBodyStreamConstructor(); 26 FFI_EXPORT void FfiWebHttpBodyStreaminitialize(int64_t id, int32_t *errCode); 27 FFI_EXPORT int32_t FfiWebHttpBodyStreamRead(int32_t bufLen, int64_t id); 28 FFI_EXPORT bool FfiWebHttpBodyStreamIsChunked(int64_t id, int32_t *errCode); 29 FFI_EXPORT bool FfiWebHttpBodyStreamIsEof(int64_t id, int32_t *errCode); 30 FFI_EXPORT bool FfiWebHttpBodyStreamIsInMemory(int64_t id, int32_t *errCode); 31 FFI_EXPORT uint64_t FfiWebHttpBodyStreamGetPostion(int64_t id, int32_t *errCode); 32 FFI_EXPORT uint64_t FfiWebHttpBodyStreamGetSize(int64_t id, int32_t *errCode); 33 34 // WebSchemeHandlerRequest 35 FFI_EXPORT int64_t FfiWebSchemeHandlerRequestConstructor(); 36 FFI_EXPORT int32_t FfiWebSchemeHandlerRequestGetRequestResourceType(int64_t id, int32_t *errCode); 37 FFI_EXPORT bool FfiWebSchemeHandlerRequestHasGesture(int64_t id, int32_t *errCode); 38 FFI_EXPORT bool FfiWebSchemeHandlerRequestIsMainFrame(int64_t id, int32_t *errCode); 39 FFI_EXPORT bool FfiWebSchemeHandlerRequestIsRedirect(int64_t id, int32_t *errCode); 40 FFI_EXPORT RetDataCString FfiWebSchemeHandlerRequestGetRequestUrl(int64_t id); 41 FFI_EXPORT RetDataCString FfiWebSchemeHandlerRequestGetMethod(int64_t id); 42 FFI_EXPORT RetDataCString FfiWebSchemeHandlerRequestGetReferrer(int64_t id); 43 FFI_EXPORT RetDataCString FfiWebSchemeHandlerRequestGetFrameUrl(int64_t id); 44 FFI_EXPORT OHOS::Webview::ArrWebHeader FfiWebSchemeHandlerRequestGetHeader(int64_t id, int32_t *errCode); 45 FFI_EXPORT int64_t FfiWebSchemeHandlerRequestGetHttpBodyStream(int64_t id, int32_t *errCode); 46 47 // WebResourceHandler 48 FFI_EXPORT int64_t FfiWebResourceHandlerConstructor(); 49 FFI_EXPORT void FfiWebResourceHandlerDidReceiveResponse(int64_t id, int32_t *errCode, int64_t responceid); 50 FFI_EXPORT void FfiWebResourceHandlerDidReceiveResponseBody( 51 int64_t id, int32_t *errCode, CArrUI8 buffer, int64_t buflen); 52 FFI_EXPORT void FfiWebResourceHandlerDidFinish(int64_t id, int32_t *errCode); 53 FFI_EXPORT void FfiWebResourceHandlerDidFail(int64_t id, int32_t *errCode, int32_t errorcode); 54 55 // WebSchemeHandler 56 FFI_EXPORT int64_t FfiWebSchemeHandlerConstructor(); 57 FFI_EXPORT void FfiWebSchemeHandlerOnRequestStart(int64_t id, bool (*callback)(int64_t, int64_t)); 58 FFI_EXPORT void FfiWebSchemeHandlerOnRequestStop(int64_t id, void (*callback)(int64_t)); 59 } 60 61 #endif // WEBVIEW_SCHEME_FFI_H