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 #ifndef mozilla_net_UrlClassifierFeatureFactory_h
8 #define mozilla_net_UrlClassifierFeatureFactory_h
14 class nsIUrlClassifierFeature
;
19 class UrlClassifierFeatureFactory final
{
21 static void Shutdown();
23 static void GetFeaturesFromChannel(
25 nsTArray
<nsCOMPtr
<nsIUrlClassifierFeature
>>& aFeatures
);
27 static void GetPhishingProtectionFeatures(
28 nsTArray
<RefPtr
<nsIUrlClassifierFeature
>>& aFeatures
);
30 static already_AddRefed
<nsIUrlClassifierFeature
> GetFeatureByName(
31 const nsACString
& aName
);
33 static void GetFeatureNames(nsTArray
<nsCString
>& aArray
);
35 static already_AddRefed
<nsIUrlClassifierFeature
> CreateFeatureWithTables(
36 const nsACString
& aName
, const nsTArray
<nsCString
>& aBlocklistTables
,
37 const nsTArray
<nsCString
>& aEntitylistTables
);
39 // Returns true if this error is known as one of the blocking error codes.
40 static bool IsClassifierBlockingErrorCode(nsresult aError
);
42 // Returns true if this event is a known blocking state from
43 // nsIWebProgressListener.
44 static bool IsClassifierBlockingEventCode(uint32_t aEventCode
);
46 static uint32_t GetClassifierBlockingEventCode(nsresult aErrorCode
);
48 // This can be called only if IsClassifierBlockingErrorCode(aError) returns
50 static const char* ClassifierBlockingErrorCodeToConsoleMessage(
51 nsresult aError
, nsACString
& aCategory
);
55 } // namespace mozilla
57 #endif // mozilla_net_UrlClassifierFeatureFactory_h