mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Bug 1039012: Only cancel third party channels with NS_ERROR_TRACKING_URI (r=gcp,briansmith)
This commit is contained in:
parent
8d085107d6
commit
3a14448afa
@ -30,7 +30,7 @@ interface nsIURIClassifierCallback : nsISupports
|
||||
* The URI classifier service checks a URI against lists of phishing
|
||||
* and malware sites.
|
||||
*/
|
||||
[scriptable, uuid(617f1002-ec55-42c4-a7b0-ebb221ba9fa2)]
|
||||
[scriptable, uuid(de4f03cd-1a28-4f51-906b-c54b47a533c5)]
|
||||
interface nsIURIClassifier : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -38,6 +38,10 @@ interface nsIURIClassifier : nsISupports
|
||||
*
|
||||
* @param aPrincipal
|
||||
* The principal that should be checked by the URI classifier.
|
||||
* @param aTrackingProtectionEnabled
|
||||
* Whether or not to classify the given URI against tracking
|
||||
* protection lists
|
||||
*
|
||||
* @param aCallback
|
||||
* The URI classifier will call this callback when the URI has been
|
||||
* classified.
|
||||
@ -48,5 +52,6 @@ interface nsIURIClassifier : nsISupports
|
||||
* callback will be called.
|
||||
*/
|
||||
boolean classify(in nsIPrincipal aPrincipal,
|
||||
in boolean aTrackingProtectionEnabled,
|
||||
in nsIURIClassifierCallback aCallback);
|
||||
};
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "nsICacheEntryDescriptor.h"
|
||||
#include "prlog.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "mozIThirdPartyUtil.h"
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
//
|
||||
@ -32,6 +33,24 @@ nsChannelClassifier::nsChannelClassifier()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
nsChannelClassifier::ShouldEnableTrackingProtection(nsIChannel* aChannel)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
|
||||
do_GetService(THIRDPARTYUTIL_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Third party checks don't work for chrome:// URIs in mochitests, so just
|
||||
// default to isThirdParty = true
|
||||
bool isThirdParty = true;
|
||||
(void)thirdPartyUtil->IsThirdPartyChannel(aChannel, nullptr, &isThirdParty);
|
||||
return isThirdParty;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsChannelClassifier::Start(nsIChannel *aChannel)
|
||||
{
|
||||
@ -97,7 +116,9 @@ nsChannelClassifier::Start(nsIChannel *aChannel)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool expectCallback;
|
||||
rv = uriClassifier->Classify(principal, this, &expectCallback);
|
||||
bool trackingProtectionEnabled = ShouldEnableTrackingProtection(aChannel);
|
||||
rv = uriClassifier->Classify(principal, trackingProtectionEnabled, this,
|
||||
&expectCallback);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (expectCallback) {
|
||||
|
@ -28,6 +28,8 @@ private:
|
||||
~nsChannelClassifier() {}
|
||||
void MarkEntryClassified(nsresult status);
|
||||
bool HasBeenClassified(nsIChannel *aChannel);
|
||||
// Whether or not tracking protection should be enabled on this channel.
|
||||
bool ShouldEnableTrackingProtection(nsIChannel* aChannel);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1215,6 +1215,7 @@ nsUrlClassifierDBService::Init()
|
||||
// nsChannelClassifier is the only consumer of this interface.
|
||||
NS_IMETHODIMP
|
||||
nsUrlClassifierDBService::Classify(nsIPrincipal* aPrincipal,
|
||||
bool aTrackingProtectionEnabled,
|
||||
nsIURIClassifierCallback* c,
|
||||
bool* result)
|
||||
{
|
||||
@ -1246,8 +1247,8 @@ nsUrlClassifierDBService::Classify(nsIPrincipal* aPrincipal,
|
||||
}
|
||||
nsAutoCString tracking;
|
||||
Preferences::GetCString(TRACKING_TABLE_PREF, &tracking);
|
||||
if (!tracking.IsEmpty()) {
|
||||
LOG(("Looking up in tracking table, [cb=%p]", callback.get()));
|
||||
if (aTrackingProtectionEnabled && !tracking.IsEmpty()) {
|
||||
LOG(("Looking up third party in tracking table, [cb=%p]", callback.get()));
|
||||
tables.Append(',');
|
||||
tables.Append(tracking);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user