1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "UrlClassifierFeatureCustomTables.h"
11 NS_INTERFACE_MAP_BEGIN(UrlClassifierFeatureCustomTables
)
12 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports
, nsIUrlClassifierFeature
)
13 NS_INTERFACE_MAP_ENTRY(nsIUrlClassifierFeature
)
16 NS_IMPL_ADDREF(UrlClassifierFeatureCustomTables
)
17 NS_IMPL_RELEASE(UrlClassifierFeatureCustomTables
)
19 UrlClassifierFeatureCustomTables::UrlClassifierFeatureCustomTables(
20 const nsACString
& aName
, const nsTArray
<nsCString
>& aBlocklistTables
,
21 const nsTArray
<nsCString
>& aEntitylistTables
)
23 mBlocklistTables(aBlocklistTables
.Clone()),
24 mEntitylistTables(aEntitylistTables
.Clone()) {}
26 UrlClassifierFeatureCustomTables::~UrlClassifierFeatureCustomTables() = default;
29 UrlClassifierFeatureCustomTables::GetName(nsACString
& aName
) {
35 UrlClassifierFeatureCustomTables::GetTables(
36 nsIUrlClassifierFeature::listType aListType
, nsTArray
<nsCString
>& aTables
) {
37 if (aListType
== nsIUrlClassifierFeature::blocklist
) {
38 aTables
= mBlocklistTables
.Clone();
42 if (aListType
== nsIUrlClassifierFeature::entitylist
) {
43 aTables
= mEntitylistTables
.Clone();
47 return NS_ERROR_FAILURE
;
51 UrlClassifierFeatureCustomTables::HasTable(
52 const nsACString
& aTable
, nsIUrlClassifierFeature::listType aListType
,
54 NS_ENSURE_ARG_POINTER(aResult
);
56 if (aListType
== nsIUrlClassifierFeature::blocklist
) {
57 *aResult
= mBlocklistTables
.Contains(aTable
);
61 if (aListType
== nsIUrlClassifierFeature::entitylist
) {
62 *aResult
= mEntitylistTables
.Contains(aTable
);
66 return NS_ERROR_FAILURE
;
70 UrlClassifierFeatureCustomTables::HasHostInPreferences(
71 const nsACString
& aHost
, nsIUrlClassifierFeature::listType aListType
,
72 nsACString
& aPrefTableName
, bool* aResult
) {
73 NS_ENSURE_ARG_POINTER(aResult
);
79 UrlClassifierFeatureCustomTables::GetExceptionHostList(nsACString
& aList
) {
84 UrlClassifierFeatureCustomTables::ProcessChannel(
85 nsIChannel
* aChannel
, const nsTArray
<nsCString
>& aList
,
86 const nsTArray
<nsCString
>& aHashes
, bool* aShouldContinue
) {
87 NS_ENSURE_ARG_POINTER(aChannel
);
88 NS_ENSURE_ARG_POINTER(aShouldContinue
);
90 // This is not a blocking feature.
91 *aShouldContinue
= true;
97 UrlClassifierFeatureCustomTables::GetURIByListType(
98 nsIChannel
* aChannel
, nsIUrlClassifierFeature::listType aListType
,
99 nsIUrlClassifierFeature::URIType
* aURIType
, nsIURI
** aURI
) {
100 return NS_ERROR_NOT_IMPLEMENTED
;
103 } // namespace mozilla