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_WRAPPER_H_ 17 #define ARK_WEB_JS_RESULT_CALLBACK_WRAPPER_H_ 18 #pragma once 19 20 #include "include/nweb_javascript_result_callback.h" 21 #include "ohos_nweb/include/ark_web_js_result_callback.h" 22 23 namespace OHOS::ArkWeb { 24 25 class ArkWebJsResultCallbackWrapper : public OHOS::NWeb::NWebJavaScriptResultCallBack { 26 public: 27 ArkWebJsResultCallbackWrapper(ArkWebRefPtr<ArkWebJsResultCallback> ark_web_js_result_callback); 28 ~ArkWebJsResultCallbackWrapper() = default; 29 30 std::shared_ptr<OHOS::NWeb::NWebValue> GetJavaScriptResult(std::vector<std::shared_ptr<OHOS::NWeb::NWebValue>> args, 31 const std::string& method, const std::string& object_name, int32_t routing_id, int32_t object_id) override; 32 33 std::shared_ptr<OHOS::NWeb::NWebValue> GetJavaScriptResultFlowbuf( 34 std::vector<std::shared_ptr<OHOS::NWeb::NWebValue>> args, const std::string& method, 35 const std::string& object_name, int fd, int32_t routing_id, int32_t object_id) override; 36 37 /** 38 * @brief GetJavaScriptObjectMethods 39 * 40 * @param object_id: means the JavaScript object id 41 * @param object_id: means the method name 42 */ 43 bool HasJavaScriptObjectMethods(int32_t object_id, const std::string& method_name) override; 44 45 /** 46 * @brief GetJavaScriptObjectMethods 47 * 48 * @param object_id: means the JavaScript object id 49 */ 50 std::shared_ptr<OHOS::NWeb::NWebValue> GetJavaScriptObjectMethods(int32_t object_id) override; 51 52 /** 53 * @brief RemoveJavaScriptObjectHolder 54 * 55 * @param holder: means the JavaScript object is holded by 56 * it(routing_id) 57 * @param object_id: means the JavaScript object id 58 */ 59 void RemoveJavaScriptObjectHolder(int32_t holder, int32_t object_id) override; 60 61 /** 62 * @brief Remove Transient JavaScript Object 63 */ 64 void RemoveTransientJavaScriptObject() override; 65 66 private: 67 ArkWebRefPtr<ArkWebJsResultCallback> ark_web_js_result_callback_; 68 }; 69 70 } // namespace OHOS::ArkWeb 71 72 #endif // ARK_WEB_JS_RESULT_CALLBACK_WRAPPER_H_ 73