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