1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsChannelClassifier_h__
6 #define nsChannelClassifier_h__
8 #include "nsIObserver.h"
9 #include "nsIURIClassifier.h"
11 #include "mozilla/Attributes.h"
20 class nsChannelClassifier final
: public nsIURIClassifierCallback
,
23 explicit nsChannelClassifier(nsIChannel
* aChannel
);
26 NS_DECL_NSIURICLASSIFIERCALLBACK
29 // Calls nsIURIClassifier.Classify with the principal of the given channel,
30 // and cancels the channel on a bad verdict.
34 // True if the channel is on the allow list.
36 // True if the channel has been suspended.
37 bool mSuspendedChannel
;
38 nsCOMPtr
<nsIChannel
> mChannel
;
40 ~nsChannelClassifier();
41 // Caches good classifications for the channel principal.
42 void MarkEntryClassified(nsresult status
);
43 bool HasBeenClassified(nsIChannel
* aChannel
);
44 // Helper function so that we ensure we call ContinueBeginConnect once
45 // Start is called. Returns NS_OK if and only if we will get a callback
46 // from the classifier service.
47 nsresult
StartInternal();
48 // Helper function to check a URI against the hostname entitylist
49 bool IsHostnameEntitylisted(nsIURI
* aUri
, const nsACString
& aEntitylisted
);
51 void AddShutdownObserver();
52 void RemoveShutdownObserver();
53 static nsresult
SendThreatHitReport(nsIChannel
* aChannel
,
54 const nsACString
& aProvider
,
55 const nsACString
& aList
,
56 const nsACString
& aFullHash
);
59 // If we are blocking content, update the corresponding flag in the respective
60 // docshell and call nsDocLoader::OnSecurityChange.
61 static nsresult
SetBlockedContent(nsIChannel
* channel
, nsresult aErrorCode
,
62 const nsACString
& aList
,
63 const nsACString
& aProvider
,
64 const nsACString
& aFullHash
);
68 } // namespace mozilla