From 25048d2d010fcab408f980c79b9424b494b3b240 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Mon, 29 Oct 2018 14:47:55 +0000 Subject: [PATCH] Bug 1497014 - Part 1: Pass in a URI hint for all content blocking state notifications r=baku Differential Revision: https://phabricator.services.mozilla.com/D9984 --HG-- extra : moz-landing-system : lando --- dom/base/nsGlobalWindowOuter.cpp | 8 ++++---- dom/base/nsPIDOMWindow.h | 4 ++-- netwerk/base/nsChannelClassifier.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index f246fd66a882..af18e766f3e5 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -5297,6 +5297,8 @@ nsGlobalWindowOuter::NotifyContentBlockingState(unsigned aState, bool aBlocked, nsIURI* aURIHint) { + MOZ_ASSERT(aURIHint); + nsCOMPtr docShell = GetDocShell(); if (!docShell) { return; @@ -5326,10 +5328,8 @@ nsGlobalWindowOuter::NotifyContentBlockingState(unsigned aState, } securityUI->GetState(&state); nsAutoString origin; - origin.SetIsVoid(true); - if (aURIHint) { - nsContentUtils::GetUTFOrigin(aURIHint, origin); - } + nsContentUtils::GetUTFOrigin(aURIHint, origin); + bool unblocked = false; if (aState == nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT) { doc->SetHasTrackingContentBlocked(aBlocked, origin); diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index 49ced89c6663..6f3e4c0a5be5 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -1094,8 +1094,8 @@ public: virtual void NotifyContentBlockingState(unsigned aState, nsIChannel* aChannel, - bool aBlocked = true, - nsIURI* aURIHint = nullptr) = 0; + bool aBlocked, + nsIURI* aURIHint) = 0; // WebIDL-ish APIs void MarkUncollectableForCCGeneration(uint32_t aGeneration) diff --git a/netwerk/base/nsChannelClassifier.cpp b/netwerk/base/nsChannelClassifier.cpp index 976ee8647eb0..eb3fab0c4a14 100644 --- a/netwerk/base/nsChannelClassifier.cpp +++ b/netwerk/base/nsChannelClassifier.cpp @@ -923,17 +923,17 @@ nsChannelClassifier::SetBlockedContent(nsIChannel *channel, nsCOMPtr doc = docShell->GetDocument(); NS_ENSURE_TRUE(doc, NS_OK); + nsCOMPtr uri; + channel->GetURI(getter_AddRefs(uri)); unsigned state; if (aErrorCode == NS_ERROR_TRACKING_URI) { state = nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT; } else { state = nsIWebProgressListener::STATE_BLOCKED_UNSAFE_CONTENT; } - pwin->NotifyContentBlockingState(state, channel); + pwin->NotifyContentBlockingState(state, channel, true, uri); // Log a warning to the web console. - nsCOMPtr uri; - channel->GetURI(getter_AddRefs(uri)); NS_ConvertUTF8toUTF16 spec(uri->GetSpecOrDefault()); const char16_t* params[] = { spec.get() }; const char* message = (aErrorCode == NS_ERROR_TRACKING_URI) ?