Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / netwerk / url-classifier / UrlClassifierFeatureFactory.h
blobf8a7537561734a8fed0872fad656198ead1079b3
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
10 #include "nsCOMPtr.h"
11 #include "nsTArray.h"
13 class nsIChannel;
14 class nsIUrlClassifierFeature;
16 namespace mozilla {
17 namespace net {
19 class UrlClassifierFeatureFactory final {
20 public:
21 static void Shutdown();
23 static void GetFeaturesFromChannel(
24 nsIChannel* aChannel,
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
49 // true.
50 static const char* ClassifierBlockingErrorCodeToConsoleMessage(
51 nsresult aError, nsACString& aCategory);
54 } // namespace net
55 } // namespace mozilla
57 #endif // mozilla_net_UrlClassifierFeatureFactory_h