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 ARK_WEB_JS_RESULT_CALLBACK_H_ 17 #define ARK_WEB_JS_RESULT_CALLBACK_H_ 18 #pragma once 19 20 #include "ohos_nweb/include/ark_web_hap_value.h" 21 #include "ohos_nweb/include/ark_web_value.h" 22 #include "ohos_nweb/include/ark_web_value_vector.h" 23 24 #include "base/include/ark_web_base_ref_counted.h" 25 #include "base/include/ark_web_types.h" 26 27 namespace OHOS::ArkWeb { 28 29 /*--ark web(source=webview)--*/ 30 class ArkWebJsResultCallback : public virtual ArkWebBaseRefCounted { 31 public: 32 /*--ark web()--*/ 33 virtual ArkWebValue GetJavaScriptResult(ArkWebValueVector args, const ArkWebString& method, 34 const ArkWebString& object_name, int32_t routing_id, int32_t object_id) = 0; 35 36 /** 37 * @brief GetJavaScriptObjectMethods 38 * 39 * @param object_id: means the JavaScript object id 40 * @param object_id: means the method name 41 */ 42 /*--ark web()--*/ 43 virtual bool HasJavaScriptObjectMethods(int32_t object_id, const ArkWebString& method_name) = 0; 44 45 /** 46 * @brief GetJavaScriptObjectMethods 47 * 48 * @param object_id: means the JavaScript object id 49 */ 50 /*--ark web()--*/ 51 virtual ArkWebValue GetJavaScriptObjectMethods(int32_t object_id) = 0; 52 53 /** 54 * @brief RemoveJavaScriptObjectHolder 55 * 56 * @param holder: means the JavaScript object is holded by 57 * it(routing_id) 58 * @param object_id: means the JavaScript object id 59 */ 60 /*--ark web()--*/ 61 virtual void RemoveJavaScriptObjectHolder(int32_t holder, int32_t object_id) = 0; 62 63 /** 64 * @brief Remove Transient JavaScript Object 65 */ 66 /*--ark web()--*/ 67 virtual void RemoveTransientJavaScriptObject() = 0; 68 69 /*--ark web()--*/ 70 virtual ArkWebValue GetJavaScriptResultFlowbuf(ArkWebValueVector args, const ArkWebString& method, 71 const ArkWebString& object_name, int fd, int32_t routing_id, int32_t object_id) = 0; 72 73 /*--ark web()--*/ 74 virtual void GetJavaScriptResultV2(const ArkWebHapValueVector& args, const ArkWebString& method, 75 const ArkWebString& object_name, int32_t routing_id, int32_t object_id, 76 ArkWebRefPtr<ArkWebHapValue> result) = 0; 77 78 /*--ark web()--*/ 79 virtual void GetJavaScriptResultFlowbufV2(const ArkWebHapValueVector& args, const ArkWebString& method, 80 const ArkWebString& object_name, int fd, int32_t routing_id, int32_t object_id, 81 ArkWebRefPtr<ArkWebHapValue> result) = 0; 82 83 /*--ark web()--*/ 84 virtual void GetJavaScriptObjectMethodsV2(int32_t object_id, ArkWebRefPtr<ArkWebHapValue> result) = 0; 85 }; 86 87 } // namespace OHOS::ArkWeb 88 89 #endif // ARK_WEB_JS_RESULT_CALLBACK_H_ 90