• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 ARK_WEB_ADSBLOCK_MANAGER_WRAPPER_H_
17 #define ARK_WEB_ADSBLOCK_MANAGER_WRAPPER_H_
18 #pragma once
19 
20 #include "include/nweb_adsblock_manager.h"
21 #include "ohos_nweb/include/ark_web_adsblock_manager.h"
22 
23 namespace OHOS::ArkWeb {
24 
25 class ArkWebAdsBlockManagerWrapper : public OHOS::NWeb::NWebAdsBlockManager {
26 public:
27   ArkWebAdsBlockManagerWrapper(
28       ArkWebRefPtr<ArkWebAdsBlockManager> ark_web_adsblock_manager);
29   ~ArkWebAdsBlockManagerWrapper() = default;
30 
31   /**
32    * @brief Set Ads Block ruleset file, containing easylist rules.
33    *
34    * @param rulesFile absolute easylist file path contains app customized ads block rules.
35    * @param replace replace internal rules or not;
36    */
37   void SetAdsBlockRules(const std::string &rulesFile, bool replace) override;
38 
39   /**
40    * @brief Add items to Ads Block Disallowed list.
41    *
42    * @param domainSuffix list of domains suffix. if web page url matches someone in the list,
43    * Ads Block will be disallowed for the web page.
44    */
45   void AddAdsBlockDisallowedList(const std::vector<std::string> &domainSuffixes) override;
46 
47   /**
48    * @brief Remove items from Ads Block disallowed list.
49    *
50    * @param domainSuffix : list of domains suffix needed be removed from disallow list
51    */
52   void RemoveAdsBlockDisallowedList(const std::vector<std::string> &domainSuffixes) override;
53 
54   /**
55    * @brief Clear Ads Block disallowed list.
56    *
57    */
58   void ClearAdsBlockDisallowedList() override;
59 
60   /**
61    * @brief Add items to Ads Block Allowed list.
62    * By default, ads block is allowed for all pages unless they are added to the
63    * disallow list. The priority of allowlist is higher than the disallowlist. It is
64    * used to re-enable ads block on the page that matches disallow list.
65    *
66    * @param domainSuffix list of domains suffix, if web page url matches someone in the list,
67    * Ads Block will be allowed for the web page.
68    */
69   void AddAdsBlockAllowedList(const std::vector<std::string> &domainSuffixes) override;
70 
71   /**
72    * @brief Remove items from Ads Block allowed list.
73    *
74    * @param domainSuffix : list of domains suffix needed be removed from allow list
75    */
76   void RemoveAdsBlockAllowedList(const std::vector<std::string> &domainSuffixes) override;
77 
78   /**
79    * @brief Clear Ads Block allow list.
80    *
81    */
82   void ClearAdsBlockAllowedList() override;
83 
84 private:
85   ArkWebRefPtr<ArkWebAdsBlockManager> ark_web_adsblock_manager_;
86 };
87 
88 } // namespace OHOS::ArkWeb
89 
90 #endif // ARK_WEB_ADSBLOCK_MANAGER_WRAPPER_H_
91