2019-01-05 11:10:45 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "UrlClassifierFeatureCustomTables.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(UrlClassifierFeatureCustomTables)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIUrlClassifierFeature)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIUrlClassifierFeature)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(UrlClassifierFeatureCustomTables)
|
|
|
|
NS_IMPL_RELEASE(UrlClassifierFeatureCustomTables)
|
|
|
|
|
|
|
|
UrlClassifierFeatureCustomTables::UrlClassifierFeatureCustomTables(
|
2020-07-07 19:17:11 +03:00
|
|
|
const nsACString& aName, const nsTArray<nsCString>& aBlocklistTables,
|
|
|
|
const nsTArray<nsCString>& aEntitylistTables)
|
2019-01-05 11:10:45 +03:00
|
|
|
: mName(aName),
|
2020-07-07 19:17:11 +03:00
|
|
|
mBlocklistTables(aBlocklistTables.Clone()),
|
|
|
|
mEntitylistTables(aEntitylistTables.Clone()) {}
|
2019-01-05 11:10:45 +03:00
|
|
|
|
|
|
|
UrlClassifierFeatureCustomTables::~UrlClassifierFeatureCustomTables() = default;
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
UrlClassifierFeatureCustomTables::GetName(nsACString& aName) {
|
|
|
|
aName = mName;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
UrlClassifierFeatureCustomTables::GetTables(
|
|
|
|
nsIUrlClassifierFeature::listType aListType, nsTArray<nsCString>& aTables) {
|
2020-07-07 19:17:11 +03:00
|
|
|
if (aListType == nsIUrlClassifierFeature::blocklist) {
|
|
|
|
aTables = mBlocklistTables.Clone();
|
2019-01-05 11:10:45 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2020-07-07 19:17:11 +03:00
|
|
|
if (aListType == nsIUrlClassifierFeature::entitylist) {
|
|
|
|
aTables = mEntitylistTables.Clone();
|
2019-01-05 11:10:45 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
UrlClassifierFeatureCustomTables::HasTable(
|
|
|
|
const nsACString& aTable, nsIUrlClassifierFeature::listType aListType,
|
|
|
|
bool* aResult) {
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
|
2020-07-07 19:17:11 +03:00
|
|
|
if (aListType == nsIUrlClassifierFeature::blocklist) {
|
|
|
|
*aResult = mBlocklistTables.Contains(aTable);
|
2019-01-05 11:10:45 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2020-07-07 19:17:11 +03:00
|
|
|
if (aListType == nsIUrlClassifierFeature::entitylist) {
|
|
|
|
*aResult = mEntitylistTables.Contains(aTable);
|
2019-01-05 11:10:45 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
UrlClassifierFeatureCustomTables::HasHostInPreferences(
|
|
|
|
const nsACString& aHost, nsIUrlClassifierFeature::listType aListType,
|
|
|
|
nsACString& aPrefTableName, bool* aResult) {
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
*aResult = false;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2020-07-07 19:17:11 +03:00
|
|
|
UrlClassifierFeatureCustomTables::GetExceptionHostList(nsACString& aList) {
|
2019-01-05 11:10:45 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-04-04 08:31:44 +03:00
|
|
|
UrlClassifierFeatureCustomTables::ProcessChannel(
|
|
|
|
nsIChannel* aChannel, const nsTArray<nsCString>& aList,
|
2019-04-26 16:02:35 +03:00
|
|
|
const nsTArray<nsCString>& aHashes, bool* aShouldContinue) {
|
2019-01-05 11:10:45 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aChannel);
|
|
|
|
NS_ENSURE_ARG_POINTER(aShouldContinue);
|
|
|
|
|
|
|
|
// This is not a blocking feature.
|
|
|
|
*aShouldContinue = true;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
UrlClassifierFeatureCustomTables::GetURIByListType(
|
|
|
|
nsIChannel* aChannel, nsIUrlClassifierFeature::listType aListType,
|
2019-09-27 16:22:18 +03:00
|
|
|
nsIUrlClassifierFeature::URIType* aURIType, nsIURI** aURI) {
|
2019-01-05 11:10:45 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mozilla
|