Bug 1180323 - Only look at TP table before cancelling speculative connections. r=gcp
This commit is contained in:
@@ -30,7 +30,7 @@ interface nsIURIClassifierCallback : nsISupports
|
||||
* The URI classifier service checks a URI against lists of phishing
|
||||
* and malware sites.
|
||||
*/
|
||||
[scriptable, uuid(750c4313-f689-4a4c-87c2-a04710a2395b)]
|
||||
[scriptable, uuid(9168a330-7fba-40e8-9c47-4ce8f15a57fd)]
|
||||
interface nsIURIClassifier : nsISupports
|
||||
{
|
||||
/**
|
||||
@@ -55,14 +55,6 @@ interface nsIURIClassifier : nsISupports
|
||||
in boolean aTrackingProtectionEnabled,
|
||||
in nsIURIClassifierCallback aCallback);
|
||||
|
||||
/**
|
||||
* Synchronously classify a Principal locally using its URI. This does not
|
||||
* make network requests. The result is an error code with which the channel
|
||||
* should be cancelled, or NS_OK if no result was found.
|
||||
*/
|
||||
nsresult classifyLocal(in nsIPrincipal aPrincipal,
|
||||
in boolean aTrackingProtectionEnabled);
|
||||
|
||||
/**
|
||||
* Synchronously classify a Principal locally using its URI with a
|
||||
* comma-separated string containing the given tables. This does not make
|
||||
|
||||
@@ -5037,23 +5037,27 @@ nsHttpChannel::BeginConnect()
|
||||
if (mLoadFlags & LOAD_CLASSIFY_URI) {
|
||||
nsCOMPtr<nsIURIClassifier> classifier = do_GetService(NS_URICLASSIFIERSERVICE_CONTRACTID);
|
||||
if (classifier) {
|
||||
bool tp = false;
|
||||
channelClassifier->ShouldEnableTrackingProtection(this, &tp);
|
||||
bool tpEnabled = false;
|
||||
channelClassifier->ShouldEnableTrackingProtection(this, &tpEnabled);
|
||||
// We skip speculative connections by setting mLocalBlocklist only
|
||||
// when tracking protection is enabled. Though we could do this for
|
||||
// both phishing and malware, it is not necessary for correctness,
|
||||
// since no network events will be received while the
|
||||
// nsChannelClassifier is in progress. See bug 1122691.
|
||||
if (tp) {
|
||||
if (tpEnabled) {
|
||||
nsCOMPtr<nsIPrincipal> principal = GetURIPrincipal();
|
||||
nsresult response = NS_OK;
|
||||
classifier->ClassifyLocal(principal, tp, &response);
|
||||
if (NS_FAILED(response)) {
|
||||
LOG(("nsHttpChannel::ClassifyLocal found principal on local "
|
||||
"blocklist [this=%p]", this));
|
||||
nsAutoCString tables;
|
||||
Preferences::GetCString("urlclassifier.trackingTable", &tables);
|
||||
nsAutoCString results;
|
||||
rv = classifier->ClassifyLocalWithTables(principal, tables, results);
|
||||
if (NS_SUCCEEDED(rv) && !results.IsEmpty()) {
|
||||
LOG(("nsHttpChannel::ClassifyLocalWithTables found "
|
||||
"principal on local tracking blocklist [this=%p]",
|
||||
this));
|
||||
mLocalBlocklist = true;
|
||||
} else {
|
||||
LOG(("nsHttpChannel::ClassifyLocal no result found [this=%p]", this));
|
||||
LOG(("nsHttpChannel::ClassifyLocalWithTables no result "
|
||||
"found [this=%p]", this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1228,22 +1228,6 @@ nsUrlClassifierDBService::Classify(nsIPrincipal* aPrincipal,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUrlClassifierDBService::ClassifyLocal(nsIPrincipal* aPrincipal,
|
||||
bool aTrackingProtectionEnabled,
|
||||
nsresult* aResponse)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "ClassifyLocal must be on main thread");
|
||||
*aResponse = NS_OK;
|
||||
nsAutoCString tables;
|
||||
BuildTables(aTrackingProtectionEnabled, tables);
|
||||
nsAutoCString results;
|
||||
nsresult rv = ClassifyLocalWithTables(aPrincipal, tables, results);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*aResponse = TablesToResponse(results);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUrlClassifierDBService::ClassifyLocalWithTables(nsIPrincipal *aPrincipal,
|
||||
const nsACString & aTables,
|
||||
|
||||
Reference in New Issue
Block a user