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 NWEB_NAPI_WEB_ADSBLOCK_MANAGER_H
17 #define NWEB_NAPI_WEB_ADSBLOCK_MANAGER_H
18 
19 #include <cstddef>
20 #include <iosfwd>
21 #include <string>
22 #include <uv.h>
23 
24 #include "napi/native_api.h"
25 #include "napi/native_node_api.h"
26 #include "nweb_value_callback.h"
27 
28 namespace OHOS {
29 namespace NWeb {
30 const std::string WEB_ADSBLOCK_MANAGER_CLASS_NAME = "AdsBlockManager";
31 
32 class NapiWebAdsBlockManager {
33 public:
NapiWebAdsBlockManager()34     NapiWebAdsBlockManager() {}
35 
36     ~NapiWebAdsBlockManager() = default;
37 
38     static napi_value Init(napi_env env, napi_value exports);
39 
40 private:
41     static napi_value JsConstructor(napi_env env, napi_callback_info info);
42 
43     static napi_value JsSetAdsBlockRules(napi_env env, napi_callback_info info);
44 
45     static napi_value JsAddAdsBlockDisallowedList(napi_env env, napi_callback_info info);
46 
47     static napi_value JsRemoveAdsBlockDisallowedList(napi_env env, napi_callback_info info);
48 
49     static napi_value JsClearAdsBlockDisallowedList(napi_env env, napi_callback_info info);
50 
51     static napi_value JsAddAdsBlockAllowedList(napi_env env, napi_callback_info info);
52 
53     static napi_value JsRemoveAdsBlockAllowedList(napi_env env, napi_callback_info info);
54 
55     static napi_value JsClearAdsBlockAllowedList(napi_env env, napi_callback_info info);
56 };
57 
58 } // namespace NWeb
59 } // namespace OHOS
60 
61 #endif // NWEB_NAPI_WEB_ADSBLOCK_MANAGER_H