1 /* 2 * Copyright (c) 2023-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 OHOS_ABILITY_RUNTIME_JS_AUTO_FILL_MANAGER_H 17 #define OHOS_ABILITY_RUNTIME_JS_AUTO_FILL_MANAGER_H 18 19 #include <map> 20 21 #include "js_auto_fill_manager.h" 22 #include "js_auto_save_request_callback.h" 23 #include "js_runtime.h" 24 #include "js_runtime_utils.h" 25 #include "native_engine/native_value.h" 26 27 namespace OHOS { 28 namespace AbilityRuntime { 29 class JsAutoFillManager { 30 public: 31 JsAutoFillManager() = default; 32 ~JsAutoFillManager() = default; 33 static void Finalizer(napi_env env, void *data, void *hint); 34 static napi_value RequestAutoSave(napi_env env, napi_callback_info info); 35 36 private: 37 napi_value OnRequestAutoSave(napi_env env, NapiCallbackInfo &info); 38 void OnRequestAutoSaveInner(napi_env env, int32_t instanceId, 39 const std::shared_ptr<JsAutoSaveRequestCallback> &saveRequestCallback); 40 std::shared_ptr<JsAutoSaveRequestCallback> GetCallbackByInstanceId(int32_t instanceId); 41 void OnRequestAutoSaveDone(int32_t instanceId); 42 43 std::mutex mutexLock_; 44 std::map<int32_t, std::weak_ptr<JsAutoSaveRequestCallback>> saveRequestObject_; 45 }; 46 napi_value JsAutoFillManagerInit(napi_env env, napi_value exportObj); 47 } // namespace AbilityRuntime 48 } // namespace OHOS 49 #endif // OHOS_ABILITY_RUNTIME_JS_AUTO_FILL_MANAGER_H