10826e83eSopenharmony_ci/* 20826e83eSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 30826e83eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 40826e83eSopenharmony_ci * you may not use this file except in compliance with the License. 50826e83eSopenharmony_ci * You may obtain a copy of the License at 60826e83eSopenharmony_ci * 70826e83eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 80826e83eSopenharmony_ci * 90826e83eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 100826e83eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 110826e83eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 120826e83eSopenharmony_ci * See the License for the specific language governing permissions and 130826e83eSopenharmony_ci * limitations under the License. 140826e83eSopenharmony_ci */ 150826e83eSopenharmony_ci 160826e83eSopenharmony_ci/** 170826e83eSopenharmony_ci * @addtogroup Web 180826e83eSopenharmony_ci * @{ 190826e83eSopenharmony_ci * 200826e83eSopenharmony_ci * @brief Provides APIs to use javascript proxy and run javascirpt code. 210826e83eSopenharmony_ci * @since 11 220826e83eSopenharmony_ci */ 230826e83eSopenharmony_ci/** 240826e83eSopenharmony_ci * @file native_interface_arkweb.h 250826e83eSopenharmony_ci * 260826e83eSopenharmony_ci * @brief Declares the APIs to use javascript proxy and run javascirpt code. 270826e83eSopenharmony_ci * @library libohweb.so 280826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core 290826e83eSopenharmony_ci * @since 11 300826e83eSopenharmony_ci */ 310826e83eSopenharmony_ci#ifndef NATIVE_INTERFACE_ARKWEB_H 320826e83eSopenharmony_ci#define NATIVE_INTERFACE_ARKWEB_H 330826e83eSopenharmony_ci 340826e83eSopenharmony_ci#include <cstdint> 350826e83eSopenharmony_ci 360826e83eSopenharmony_ci#ifdef __cplusplus 370826e83eSopenharmony_ciextern "C" { 380826e83eSopenharmony_ci#endif 390826e83eSopenharmony_ci 400826e83eSopenharmony_ci/** 410826e83eSopenharmony_ci* @brief Defines the javascript callback of the web component. 420826e83eSopenharmony_ci* 430826e83eSopenharmony_ci* @since 11 440826e83eSopenharmony_ci*/ 450826e83eSopenharmony_citypedef void (*NativeArkWeb_OnJavaScriptCallback)(const char*); 460826e83eSopenharmony_ci 470826e83eSopenharmony_ci/** 480826e83eSopenharmony_ci* @brief Defines the javascript proxy callback of the web component. 490826e83eSopenharmony_ci* 500826e83eSopenharmony_ci* @since 11 510826e83eSopenharmony_ci*/ 520826e83eSopenharmony_citypedef char* (*NativeArkWeb_OnJavaScriptProxyCallback)(const char** argv, int32_t argc); 530826e83eSopenharmony_ci 540826e83eSopenharmony_ci/** 550826e83eSopenharmony_ci* @brief Defines the valid callback of the web component. 560826e83eSopenharmony_ci* 570826e83eSopenharmony_ci* @since 11 580826e83eSopenharmony_ci*/ 590826e83eSopenharmony_citypedef void (*NativeArkWeb_OnValidCallback)(const char*); 600826e83eSopenharmony_ci 610826e83eSopenharmony_ci/** 620826e83eSopenharmony_ci* @brief Defines the destroy callback of the web component. 630826e83eSopenharmony_ci* 640826e83eSopenharmony_ci* @since 11 650826e83eSopenharmony_ci*/ 660826e83eSopenharmony_citypedef void (*NativeArkWeb_OnDestroyCallback)(const char*); 670826e83eSopenharmony_ci 680826e83eSopenharmony_ci/* 690826e83eSopenharmony_ci * @brief Loads a piece of code and execute JS code in the context of the currently displayed page. 700826e83eSopenharmony_ci * 710826e83eSopenharmony_ci * @param webTag The name of the web component. 720826e83eSopenharmony_ci * @param jsCode a piece of javascript code. 730826e83eSopenharmony_ci * @param callback Callbacks execute JavaScript script results. 740826e83eSopenharmony_ci * 750826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core 760826e83eSopenharmony_ci * @since 11 770826e83eSopenharmony_ci */ 780826e83eSopenharmony_civoid OH_NativeArkWeb_RunJavaScript(const char* webTag, const char* jsCode, NativeArkWeb_OnJavaScriptCallback callback); 790826e83eSopenharmony_ci 800826e83eSopenharmony_ci/* 810826e83eSopenharmony_ci * @brief Registers the JavaScript object and method list. 820826e83eSopenharmony_ci * 830826e83eSopenharmony_ci * @param webTag The name of the web component. 840826e83eSopenharmony_ci * @param objName The name of the registered object. 850826e83eSopenharmony_ci * @param methodList The method of the application side JavaScript object participating in the registration. 860826e83eSopenharmony_ci * @param callback The callback function registered by developer is called back when HTML side uses. 870826e83eSopenharmony_ci * @param size The size of the callback. 880826e83eSopenharmony_ci * @param needRefresh if web need refresh. 890826e83eSopenharmony_ci * 900826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core 910826e83eSopenharmony_ci * @since 11 920826e83eSopenharmony_ci */ 930826e83eSopenharmony_civoid OH_NativeArkWeb_RegisterJavaScriptProxy(const char* webTag, const char* objName, const char** methodList, 940826e83eSopenharmony_ci NativeArkWeb_OnJavaScriptProxyCallback* callback, int32_t size, bool isNeedRefresh); 950826e83eSopenharmony_ci 960826e83eSopenharmony_ci/* 970826e83eSopenharmony_ci * @brief Deletes the registered object which th given name. 980826e83eSopenharmony_ci * 990826e83eSopenharmony_ci * @param webTag The name of the web component. 1000826e83eSopenharmony_ci * @param objName The name of the registered object. 1010826e83eSopenharmony_ci * 1020826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core 1030826e83eSopenharmony_ci * @since 11 1040826e83eSopenharmony_ci */ 1050826e83eSopenharmony_civoid OH_NativeArkWeb_UnregisterJavaScriptProxy(const char* webTag, const char* objName); 1060826e83eSopenharmony_ci 1070826e83eSopenharmony_ci/* 1080826e83eSopenharmony_ci * @brief Registers the valid callback. 1090826e83eSopenharmony_ci * 1100826e83eSopenharmony_ci * @param webTag The name of the web component. 1110826e83eSopenharmony_ci * @param callback The callback in which we can register object. 1120826e83eSopenharmony_ci * 1130826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core 1140826e83eSopenharmony_ci * @since 11 1150826e83eSopenharmony_ci */ 1160826e83eSopenharmony_civoid OH_NativeArkWeb_SetJavaScriptProxyValidCallback(const char* webTag, NativeArkWeb_OnValidCallback callback); 1170826e83eSopenharmony_ci 1180826e83eSopenharmony_ci/* 1190826e83eSopenharmony_ci * @brief Get the valid callback. 1200826e83eSopenharmony_ci * 1210826e83eSopenharmony_ci * @param webTag The name of the web component. 1220826e83eSopenharmony_ci * @return return the valid callback function registered. 1230826e83eSopenharmony_ci * 1240826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core 1250826e83eSopenharmony_ci * @since 11 1260826e83eSopenharmony_ci */ 1270826e83eSopenharmony_ciNativeArkWeb_OnValidCallback OH_NativeArkWeb_GetJavaScriptProxyValidCallback(const char* webTag); 1280826e83eSopenharmony_ci 1290826e83eSopenharmony_ci/* 1300826e83eSopenharmony_ci * @brief Registers the destroy callback. 1310826e83eSopenharmony_ci * 1320826e83eSopenharmony_ci * @param webTag The name of the web component. 1330826e83eSopenharmony_ci * @param callback the destroy callback. 1340826e83eSopenharmony_ci * 1350826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core 1360826e83eSopenharmony_ci * @since 11 1370826e83eSopenharmony_ci */ 1380826e83eSopenharmony_civoid OH_NativeArkWeb_SetDestroyCallback(const char* webTag, NativeArkWeb_OnDestroyCallback callback); 1390826e83eSopenharmony_ci 1400826e83eSopenharmony_ci/* 1410826e83eSopenharmony_ci * @brief Get the destroy callback. 1420826e83eSopenharmony_ci * 1430826e83eSopenharmony_ci * @param webTag The name of the web component. 1440826e83eSopenharmony_ci * @return return the destroy callback function registered. 1450826e83eSopenharmony_ci * 1460826e83eSopenharmony_ci * @syscap SystemCapability.Web.Webview.Core 1470826e83eSopenharmony_ci * @since 11 1480826e83eSopenharmony_ci */ 1490826e83eSopenharmony_ciNativeArkWeb_OnDestroyCallback OH_NativeArkWeb_GetDestroyCallback(const char* webTag); 1500826e83eSopenharmony_ci 1510826e83eSopenharmony_ci#ifdef __cplusplus 1520826e83eSopenharmony_ci}; 1530826e83eSopenharmony_ci#endif 1540826e83eSopenharmony_ci#endif // NATIVE_INTERFACE_ARKWEB_H