17777dab0Sopenharmony_ci/*
27777dab0Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License.
57777dab0Sopenharmony_ci * You may obtain a copy of the License at
67777dab0Sopenharmony_ci *
77777dab0Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
87777dab0Sopenharmony_ci *
97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and
137777dab0Sopenharmony_ci * limitations under the License.
147777dab0Sopenharmony_ci */
157777dab0Sopenharmony_ci
167777dab0Sopenharmony_ci/**
177777dab0Sopenharmony_ci * @addtogroup Web
187777dab0Sopenharmony_ci * @{
197777dab0Sopenharmony_ci *
207777dab0Sopenharmony_ci * @brief Provides APIs to use javascript proxy and run javascirpt code.
217777dab0Sopenharmony_ci * @since 11
227777dab0Sopenharmony_ci */
237777dab0Sopenharmony_ci/**
247777dab0Sopenharmony_ci * @file native_interface_arkweb.h
257777dab0Sopenharmony_ci *
267777dab0Sopenharmony_ci * @brief Declares the APIs to use javascript proxy and run javascirpt code.
277777dab0Sopenharmony_ci * @kit ArkWeb
287777dab0Sopenharmony_ci * @library libohweb.so
297777dab0Sopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
307777dab0Sopenharmony_ci * @since 11
317777dab0Sopenharmony_ci */
327777dab0Sopenharmony_ci#ifndef NATIVE_INTERFACE_ARKWEB_H
337777dab0Sopenharmony_ci#define NATIVE_INTERFACE_ARKWEB_H
347777dab0Sopenharmony_ci
357777dab0Sopenharmony_ci#include <stdbool.h>
367777dab0Sopenharmony_ci#include <stdint.h>
377777dab0Sopenharmony_ci
387777dab0Sopenharmony_ci#ifdef __cplusplus
397777dab0Sopenharmony_ciextern "C" {
407777dab0Sopenharmony_ci#endif
417777dab0Sopenharmony_ci
427777dab0Sopenharmony_ci/**
437777dab0Sopenharmony_ci* @brief Defines the javascript callback of the web component.
447777dab0Sopenharmony_ci*
457777dab0Sopenharmony_ci* @since 11
467777dab0Sopenharmony_ci*/
477777dab0Sopenharmony_citypedef void (*NativeArkWeb_OnJavaScriptCallback)(const char*);
487777dab0Sopenharmony_ci
497777dab0Sopenharmony_ci/**
507777dab0Sopenharmony_ci* @brief Defines the javascript proxy callback of the web component.
517777dab0Sopenharmony_ci*
527777dab0Sopenharmony_ci* @since 11
537777dab0Sopenharmony_ci*/
547777dab0Sopenharmony_citypedef char* (*NativeArkWeb_OnJavaScriptProxyCallback)(const char** argv, int32_t argc);
557777dab0Sopenharmony_ci
567777dab0Sopenharmony_ci/**
577777dab0Sopenharmony_ci* @brief Defines the valid callback of the web component.
587777dab0Sopenharmony_ci*
597777dab0Sopenharmony_ci* @since 11
607777dab0Sopenharmony_ci*/
617777dab0Sopenharmony_citypedef void (*NativeArkWeb_OnValidCallback)(const char*);
627777dab0Sopenharmony_ci
637777dab0Sopenharmony_ci/**
647777dab0Sopenharmony_ci* @brief Defines the destroy callback of the web component.
657777dab0Sopenharmony_ci*
667777dab0Sopenharmony_ci* @since 11
677777dab0Sopenharmony_ci*/
687777dab0Sopenharmony_citypedef void (*NativeArkWeb_OnDestroyCallback)(const char*);
697777dab0Sopenharmony_ci
707777dab0Sopenharmony_ci/*
717777dab0Sopenharmony_ci * @brief Loads a piece of code and execute JS code in the context of the currently displayed page.
727777dab0Sopenharmony_ci *
737777dab0Sopenharmony_ci * @param webTag The name of the web component.
747777dab0Sopenharmony_ci * @param jsCode a piece of javascript code.
757777dab0Sopenharmony_ci * @param callback Callbacks execute JavaScript script results.
767777dab0Sopenharmony_ci *
777777dab0Sopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
787777dab0Sopenharmony_ci * @since 11
797777dab0Sopenharmony_ci */
807777dab0Sopenharmony_civoid OH_NativeArkWeb_RunJavaScript(const char* webTag, const char* jsCode, NativeArkWeb_OnJavaScriptCallback callback);
817777dab0Sopenharmony_ci
827777dab0Sopenharmony_ci/*
837777dab0Sopenharmony_ci * @brief Registers the JavaScript object and method list.
847777dab0Sopenharmony_ci *
857777dab0Sopenharmony_ci * @param webTag The name of the web component.
867777dab0Sopenharmony_ci * @param objName The name of the registered object.
877777dab0Sopenharmony_ci * @param methodList The method of the application side JavaScript object participating in the registration.
887777dab0Sopenharmony_ci * @param callback The callback function registered by developer is called back when HTML side uses.
897777dab0Sopenharmony_ci * @param size The size of the callback.
907777dab0Sopenharmony_ci * @param needRefresh if web need refresh.
917777dab0Sopenharmony_ci *
927777dab0Sopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
937777dab0Sopenharmony_ci * @since 11
947777dab0Sopenharmony_ci */
957777dab0Sopenharmony_civoid OH_NativeArkWeb_RegisterJavaScriptProxy(const char* webTag, const char* objName, const char** methodList,
967777dab0Sopenharmony_ci    NativeArkWeb_OnJavaScriptProxyCallback* callback, int32_t size, bool needRefresh);
977777dab0Sopenharmony_ci
987777dab0Sopenharmony_ci/*
997777dab0Sopenharmony_ci * @brief Deletes the registered object which th given name.
1007777dab0Sopenharmony_ci *
1017777dab0Sopenharmony_ci * @param webTag The name of the web component.
1027777dab0Sopenharmony_ci * @param objName The name of the registered object.
1037777dab0Sopenharmony_ci *
1047777dab0Sopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
1057777dab0Sopenharmony_ci * @since 11
1067777dab0Sopenharmony_ci */
1077777dab0Sopenharmony_civoid OH_NativeArkWeb_UnregisterJavaScriptProxy(const char* webTag, const char* objName);
1087777dab0Sopenharmony_ci
1097777dab0Sopenharmony_ci/*
1107777dab0Sopenharmony_ci * @brief Registers the valid callback.
1117777dab0Sopenharmony_ci *
1127777dab0Sopenharmony_ci * @param webTag The name of the web component.
1137777dab0Sopenharmony_ci * @param callback The callback in which we can register object.
1147777dab0Sopenharmony_ci *
1157777dab0Sopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
1167777dab0Sopenharmony_ci * @since 11
1177777dab0Sopenharmony_ci */
1187777dab0Sopenharmony_civoid OH_NativeArkWeb_SetJavaScriptProxyValidCallback(const char* webTag, NativeArkWeb_OnValidCallback callback);
1197777dab0Sopenharmony_ci
1207777dab0Sopenharmony_ci/*
1217777dab0Sopenharmony_ci * @brief Get the valid callback.
1227777dab0Sopenharmony_ci *
1237777dab0Sopenharmony_ci * @param webTag The name of the web component.
1247777dab0Sopenharmony_ci * @return Return the valid callback function registered. If the valid callback function
1257777dab0Sopenharmony_ci *         specified by the parameter webTag is not set, a null pointer is returned.
1267777dab0Sopenharmony_ci *
1277777dab0Sopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
1287777dab0Sopenharmony_ci * @since 11
1297777dab0Sopenharmony_ci */
1307777dab0Sopenharmony_ciNativeArkWeb_OnValidCallback OH_NativeArkWeb_GetJavaScriptProxyValidCallback(const char* webTag);
1317777dab0Sopenharmony_ci
1327777dab0Sopenharmony_ci/*
1337777dab0Sopenharmony_ci * @brief Registers the destroy callback.
1347777dab0Sopenharmony_ci *
1357777dab0Sopenharmony_ci * @param webTag The name of the web component.
1367777dab0Sopenharmony_ci * @param callback the destroy callback.
1377777dab0Sopenharmony_ci *
1387777dab0Sopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
1397777dab0Sopenharmony_ci * @since 11
1407777dab0Sopenharmony_ci */
1417777dab0Sopenharmony_civoid OH_NativeArkWeb_SetDestroyCallback(const char* webTag, NativeArkWeb_OnDestroyCallback callback);
1427777dab0Sopenharmony_ci
1437777dab0Sopenharmony_ci/*
1447777dab0Sopenharmony_ci * @brief Get the destroy callback.
1457777dab0Sopenharmony_ci *
1467777dab0Sopenharmony_ci * @param webTag The name of the web component.
1477777dab0Sopenharmony_ci * @return Return the destroy callback function registered. If the destroy callback
1487777dab0Sopenharmony_ci *         function specified by the parameter webTag is not set,
1497777dab0Sopenharmony_ci *         a null pointer is returned.
1507777dab0Sopenharmony_ci *
1517777dab0Sopenharmony_ci * @syscap SystemCapability.Web.Webview.Core
1527777dab0Sopenharmony_ci * @since 11
1537777dab0Sopenharmony_ci */
1547777dab0Sopenharmony_ciNativeArkWeb_OnDestroyCallback OH_NativeArkWeb_GetDestroyCallback(const char* webTag);
1557777dab0Sopenharmony_ci
1567777dab0Sopenharmony_ci#ifdef __cplusplus
1577777dab0Sopenharmony_ci};
1587777dab0Sopenharmony_ci#endif
1597777dab0Sopenharmony_ci#endif // NATIVE_INTERFACE_ARKWEB_H