1 /* 2 * Copyright (c) 2023 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_SAVE_REQUEST_CALLBACK_H 17 #define OHOS_ABILITY_RUNTIME_JS_SAVE_REQUEST_CALLBACK_H 18 19 #include "js_auto_fill_extension_util.h" 20 #include "js_runtime_utils.h" 21 #include "session_info.h" 22 #include "view_data.h" 23 #include "want.h" 24 #include "window.h" 25 26 namespace OHOS { 27 namespace AbilityRuntime { 28 class JsSaveRequestCallback { 29 public: 30 JsSaveRequestCallback(const sptr<AAFwk::SessionInfo> &sessionInfo, const sptr<Rosen::Window> &uiWindow); 31 virtual ~JsSaveRequestCallback() = default; 32 33 static napi_value CreateJsSaveRequestCallback(napi_env env, 34 const sptr<AAFwk::SessionInfo> &sessionInfo, const sptr<Rosen::Window> &uiWindow); 35 static void Finalizer(napi_env env, void *data, void *hint); 36 static napi_value SaveRequestSuccess(napi_env env, napi_callback_info info); 37 static napi_value SaveRequestFailed(napi_env env, napi_callback_info info); 38 39 private: 40 napi_value OnSaveRequestSuccess(napi_env env, NapiCallbackInfo &info); 41 napi_value OnSaveRequestFailed(napi_env env, NapiCallbackInfo &info); 42 void SendResultCodeAndViewData(const JsAutoFillExtensionUtil::AutoFillResultCode &resultCode); 43 44 sptr<AAFwk::SessionInfo> sessionInfo_; 45 sptr<Rosen::Window> uiWindow_; 46 }; 47 } // namespace AbilityRuntime 48 } // namespace OHOS 49 #endif // OHOS_ABILITY_RUNTIME_JS_SAVE_REQUEST_CALLBACK_H 50