UrlClassifierFeatureFactory.h (1919B)
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/. */ 6 7 #ifndef mozilla_net_UrlClassifierFeatureFactory_h 8 #define mozilla_net_UrlClassifierFeatureFactory_h 9 10 #include "nsCOMPtr.h" 11 #include "nsTArray.h" 12 13 class nsIChannel; 14 class nsIUrlClassifierFeature; 15 16 namespace mozilla { 17 namespace net { 18 19 class UrlClassifierFeatureFactory final { 20 public: 21 static void Shutdown(); 22 23 static void GetFeaturesFromChannel( 24 nsIChannel* aChannel, 25 nsTArray<nsCOMPtr<nsIUrlClassifierFeature>>& aFeatures); 26 27 static void GetPhishingProtectionFeatures( 28 nsTArray<RefPtr<nsIUrlClassifierFeature>>& aFeatures); 29 30 static already_AddRefed<nsIUrlClassifierFeature> GetFeatureByName( 31 const nsACString& aName); 32 33 static void GetFeatureNames(nsTArray<nsCString>& aArray); 34 35 static already_AddRefed<nsIUrlClassifierFeature> CreateFeatureWithTables( 36 const nsACString& aName, const nsTArray<nsCString>& aBlocklistTables, 37 const nsTArray<nsCString>& aEntitylistTables); 38 39 // Returns true if this error is known as one of the blocking error codes. 40 static bool IsClassifierBlockingErrorCode(nsresult aError); 41 42 // Returns true if this event is a known blocking state from 43 // nsIWebProgressListener. 44 static bool IsClassifierBlockingEventCode(uint32_t aEventCode); 45 46 static uint32_t GetClassifierBlockingEventCode(nsresult aErrorCode); 47 48 // This can be called only if IsClassifierBlockingErrorCode(aError) returns 49 // true. 50 static const char* ClassifierBlockingErrorCodeToConsoleMessage( 51 nsresult aError, nsACString& aCategory); 52 }; 53 54 } // namespace net 55 } // namespace mozilla 56 57 #endif // mozilla_net_UrlClassifierFeatureFactory_h