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