2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2007-09-01 03:18:46 +04:00
|
|
|
|
2010-05-22 01:03:02 +04:00
|
|
|
#ifndef nsChannelClassifier_h__
|
|
|
|
#define nsChannelClassifier_h__
|
2007-09-01 03:18:46 +04:00
|
|
|
|
2010-05-22 01:03:02 +04:00
|
|
|
#include "nsIURIClassifier.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2012-06-06 07:18:25 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-09-01 03:18:46 +04:00
|
|
|
|
2010-05-22 01:03:02 +04:00
|
|
|
class nsIChannel;
|
2015-01-21 22:33:07 +03:00
|
|
|
class nsIHttpChannelInternal;
|
2015-08-13 12:14:36 +03:00
|
|
|
class nsIDocument;
|
2010-05-22 01:03:02 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsChannelClassifier final : public nsIURIClassifierCallback
|
2007-09-01 03:18:46 +04:00
|
|
|
{
|
2010-05-22 01:03:02 +04:00
|
|
|
public:
|
|
|
|
nsChannelClassifier();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIURICLASSIFIERCALLBACK
|
|
|
|
|
2015-01-10 00:25:13 +03:00
|
|
|
// Calls nsIURIClassifier.Classify with the principal of the given channel,
|
2015-06-18 17:57:00 +03:00
|
|
|
// and cancels the channel on a bad verdict.
|
|
|
|
void Start(nsIChannel *aChannel);
|
2015-01-10 00:25:13 +03:00
|
|
|
// Whether or not tracking protection should be enabled on this channel.
|
|
|
|
nsresult ShouldEnableTrackingProtection(nsIChannel *aChannel, bool *result);
|
2010-05-22 01:03:02 +04:00
|
|
|
|
|
|
|
private:
|
2015-01-10 00:25:13 +03:00
|
|
|
// True if the channel is on the allow list.
|
2014-08-23 02:17:32 +04:00
|
|
|
bool mIsAllowListed;
|
2015-01-10 00:25:13 +03:00
|
|
|
// True if the channel has been suspended.
|
|
|
|
bool mSuspendedChannel;
|
|
|
|
nsCOMPtr<nsIChannel> mChannel;
|
2010-05-22 01:03:02 +04:00
|
|
|
|
|
|
|
~nsChannelClassifier() {}
|
2015-01-10 00:25:13 +03:00
|
|
|
// Caches good classifications for the channel principal.
|
2010-05-22 01:03:02 +04:00
|
|
|
void MarkEntryClassified(nsresult status);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasBeenClassified(nsIChannel *aChannel);
|
2015-01-10 00:25:13 +03:00
|
|
|
// 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.
|
2015-01-21 22:33:07 +03:00
|
|
|
nsresult StartInternal();
|
2015-08-07 23:08:22 +03:00
|
|
|
// Helper function to check a tracking URI against the whitelist
|
|
|
|
nsresult IsTrackerWhitelisted();
|
2015-08-13 12:14:36 +03:00
|
|
|
// Checks that the channel was loaded by the URI currently loaded in aDoc
|
|
|
|
static bool SameLoadingURI(nsIDocument *aDoc, nsIChannel *aChannel);
|
2014-11-12 02:05:55 +03:00
|
|
|
|
|
|
|
public:
|
2014-08-13 00:53:15 +04:00
|
|
|
// If we are blocking tracking content, update the corresponding flag in
|
|
|
|
// the respective docshell and call nsISecurityEventSink::onSecurityChange.
|
2014-11-12 02:05:55 +03:00
|
|
|
static nsresult SetBlockedTrackingContent(nsIChannel *channel);
|
|
|
|
static nsresult NotifyTrackingProtectionDisabled(nsIChannel *aChannel);
|
2007-09-01 03:18:46 +04:00
|
|
|
};
|
2010-05-22 01:03:02 +04:00
|
|
|
|
|
|
|
#endif
|