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 USER_AUTH_WIDGET_MGR_V10
17 #define USER_AUTH_WIDGET_MGR_V10
18 
19 #include <mutex>
20 
21 #include "nocopyable.h"
22 
23 #include "auth_common.h"
24 #include "user_auth_napi_helper.h"
25 #include "user_auth_client.h"
26 #include "iam_common_defines.h"
27 #include "user_auth_common_defines.h"
28 #include "user_auth_widget_callback_v10.h"
29 
30 namespace OHOS {
31 namespace UserIam {
32 namespace UserAuth {
33 class UserAuthWidgetMgr : public NoCopyable {
34 public:
35     explicit UserAuthWidgetMgr(napi_env env);
36     ~UserAuthWidgetMgr() override = default;
37 
38     UserAuthResultCode Init(napi_env env, napi_callback_info info);
39     UserAuthResultCode On(napi_env env, napi_callback_info info);
40     UserAuthResultCode Off(napi_env env, napi_callback_info info);
41 
42 private:
43     std::shared_ptr<JsRefHolder> GetCallback(napi_env env, napi_value value);
44 
45     int32_t version_ = 1;
46     std::mutex mutex_;
47     std::shared_ptr<UserAuthWidgetCallback> callback_ = nullptr;
48 };
49 } // namespace UserAuth
50 } // namespace UserIam
51 } // namespace OHOS
52 #endif // USER_AUTH_WIDGET_MGR_V10
53