diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /netwerk/base/nsChannelClassifier.h | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'netwerk/base/nsChannelClassifier.h')
-rw-r--r-- | netwerk/base/nsChannelClassifier.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/netwerk/base/nsChannelClassifier.h b/netwerk/base/nsChannelClassifier.h new file mode 100644 index 000000000..20575f3c1 --- /dev/null +++ b/netwerk/base/nsChannelClassifier.h @@ -0,0 +1,65 @@ +/* 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/. */ + +#ifndef nsChannelClassifier_h__ +#define nsChannelClassifier_h__ + +#include "nsIURIClassifier.h" +#include "nsCOMPtr.h" +#include "mozilla/Attributes.h" + +class nsIChannel; +class nsIHttpChannelInternal; +class nsIDocument; + +namespace mozilla { +namespace net { + +class nsChannelClassifier final : public nsIURIClassifierCallback +{ +public: + nsChannelClassifier(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIURICLASSIFIERCALLBACK + + // Calls nsIURIClassifier.Classify with the principal of the given channel, + // and cancels the channel on a bad verdict. + void Start(nsIChannel *aChannel); + // Whether or not tracking protection should be enabled on this channel. + nsresult ShouldEnableTrackingProtection(nsIChannel *aChannel, bool *result); + +private: + // True if the channel is on the allow list. + bool mIsAllowListed; + // True if the channel has been suspended. + bool mSuspendedChannel; + nsCOMPtr<nsIChannel> mChannel; + + ~nsChannelClassifier() {} + // Caches good classifications for the channel principal. + void MarkEntryClassified(nsresult status); + bool HasBeenClassified(nsIChannel *aChannel); + // Helper function so that we ensure we call ContinueBeginConnect once + // Start is called. Returns NS_OK if and only if we will get a callback + // from the classifier service. + nsresult StartInternal(); + // Helper function to check a tracking URI against the whitelist + nsresult IsTrackerWhitelisted(); + // Helper function to check a URI against the hostname whitelist + bool IsHostnameWhitelisted(nsIURI *aUri, const nsACString &aWhitelisted); + // Checks that the channel was loaded by the URI currently loaded in aDoc + static bool SameLoadingURI(nsIDocument *aDoc, nsIChannel *aChannel); + +public: + // If we are blocking tracking content, update the corresponding flag in + // the respective docshell and call nsISecurityEventSink::onSecurityChange. + static nsresult SetBlockedTrackingContent(nsIChannel *channel); + static nsresult NotifyTrackingProtectionDisabled(nsIChannel *aChannel); +}; + +} // namespace net +} // namespace mozilla + +#endif |