• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FILL_REQUEST_CALLBACK_H
17 #define OHOS_ABILITY_RUNTIME_JS_FILL_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 /**
29  * @brief Basic auto fill extension components.
30  */
31 class JsFillRequestCallback {
32 public:
33     JsFillRequestCallback(const sptr<AAFwk::SessionInfo> &sessionInfo, const sptr<Rosen::Window> &uiWindow);
34     virtual ~JsFillRequestCallback() = default;
35 
36     static napi_value CreateJsFillRequestCallback(napi_env env,
37         const sptr<AAFwk::SessionInfo> &sessionInfo, const sptr<Rosen::Window> &uiWindow);
38     static void Finalizer(napi_env env, void *data, void *hint);
39     static napi_value FillRequestSuccess(napi_env env, napi_callback_info info);
40     static napi_value FillRequestFailed(napi_env env, napi_callback_info info);
41     static napi_value FillRequestCanceled(napi_env env, napi_callback_info info);
42     static napi_value FillRequestAutoFillPopupConfig(napi_env env, napi_callback_info info);
43 
44 private:
45     napi_value OnFillRequestSuccess(napi_env env, NapiCallbackInfo &info);
46     napi_value OnFillRequestFailed(napi_env env, NapiCallbackInfo &info);
47     napi_value OnFillRequestCanceled(napi_env env, NapiCallbackInfo &info);
48     napi_value OnFillRequestAutoFillPopupConfig(napi_env env, NapiCallbackInfo &info);
49     bool SetPopupConfigToWantParams(napi_env env, NapiCallbackInfo& info, AAFwk::WantParams& wantParams);
50     void SendResultCodeAndViewData(
51         const JsAutoFillExtensionUtil::AutoFillResultCode &resultCode, const std::string &jsString);
52 
53     sptr<AAFwk::SessionInfo> sessionInfo_;
54     sptr<Rosen::Window> uiWindow_;
55 };
56 } // namespace AbilityRuntime
57 } // namespace OHOS
58 #endif // OHOS_ABILITY_RUNTIME_JS_FILL_REQUEST_CALLBACK_H
59