• 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 #include "webview_adsblock_ffi.h"
17 
18 #include "webview_utils.h"
19 #include "nweb_helper.h"
20 #include "nweb_init_params.h"
21 #include "web_errors.h"
22 #include "webview_log.h"
23 #include "parameters.h"
24 #include "webview_adsblock_manager.h"
25 
26 using namespace OHOS::FFI;
27 using namespace OHOS::NWeb;
28 
29 namespace OHOS {
30 namespace Webview {
31 extern "C" {
32     // AdsBlockManager
FfiAdsBlockManagerSetAdsBlockRules(const char * rulesFile,bool replace)33     int32_t FfiAdsBlockManagerSetAdsBlockRules(const char *rulesFile, bool replace)
34     {
35         return AdsBlockManagerImpl::SetAdsBlockRules(rulesFile, replace);
36     }
37 
FfiAdsBlockManagerAddAdsBlockDisallowedList(CArrString domainSuffixes)38     int32_t FfiAdsBlockManagerAddAdsBlockDisallowedList(CArrString domainSuffixes)
39     {
40         return AdsBlockManagerImpl::AddAdsBlockDisallowedList(domainSuffixes);
41     }
42 
FfiAdsBlockManagerRemoveAdsBlockDisallowedList(CArrString domainSuffixes)43     int32_t FfiAdsBlockManagerRemoveAdsBlockDisallowedList(CArrString domainSuffixes)
44     {
45         return AdsBlockManagerImpl::RemoveAdsBlockDisallowedList(domainSuffixes);
46     }
47 
FfiAdsBlockManagerAddAdsBlockAllowedList(CArrString domainSuffixes)48     int32_t FfiAdsBlockManagerAddAdsBlockAllowedList(CArrString domainSuffixes)
49     {
50         return AdsBlockManagerImpl::AddAdsBlockAllowedList(domainSuffixes);
51     }
52 
FfiAdsBlockManagerRemoveAdsBlockAllowedList(CArrString domainSuffixes)53     int32_t FfiAdsBlockManagerRemoveAdsBlockAllowedList(CArrString domainSuffixes)
54     {
55         return AdsBlockManagerImpl::RemoveAdsBlockAllowedList(domainSuffixes);
56     }
57 
FfiAdsBlockManagerClearAdsBlockAllowedList()58     void FfiAdsBlockManagerClearAdsBlockAllowedList()
59     {
60         AdsBlockManagerImpl::ClearAdsBlockAllowedList();
61     }
62 
FfiAdsBlockManagerClearAdsBlockDisallowedList()63     void FfiAdsBlockManagerClearAdsBlockDisallowedList()
64     {
65         AdsBlockManagerImpl::ClearAdsBlockDisallowedList();
66     }
67 }
68 }
69 }