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
This commit is contained in:
Ehsan Akhgari 2018-10-29 14:47:55 +00:00
Родитель 7d9df9b0ec
Коммит 25048d2d01
3 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -5297,6 +5297,8 @@ nsGlobalWindowOuter::NotifyContentBlockingState(unsigned aState,
bool aBlocked,
nsIURI* aURIHint)
{
MOZ_ASSERT(aURIHint);
nsCOMPtr<nsIDocShell> 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);

Просмотреть файл

@ -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)

Просмотреть файл

@ -923,17 +923,17 @@ nsChannelClassifier::SetBlockedContent(nsIChannel *channel,
nsCOMPtr<nsIDocument> doc = docShell->GetDocument();
NS_ENSURE_TRUE(doc, NS_OK);
nsCOMPtr<nsIURI> 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<nsIURI> 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) ?