Bug 1601310 - Add GetContentBlockingEvents IPC method for the child to retrive content blocking event in the parent. r=timhuang,twisniewski,Ehsan
This patch does the following: 1. Add a WindowGlobalChild IPC method - GetContentBlockingEvents. Documents can use the method retrieve content blocking events stored in the parent process. 2. Update nsIDocShell::GetHasTrackingContentBlocked to return a promise. 3. Replace API in report-site-issue to use the promise-based GetHasTrackingContentBlocked API Differential Revision: https://phabricator.services.mozilla.com/D56204
This commit is contained in:
@@ -1402,9 +1402,37 @@ nsDocShell::GetHasMixedDisplayContentBlocked(
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetHasTrackingContentBlocked(bool* aHasTrackingContentBlocked) {
|
||||
nsDocShell::GetHasTrackingContentBlocked(Promise** aPromise) {
|
||||
MOZ_ASSERT(aPromise);
|
||||
|
||||
ErrorResult rv;
|
||||
RefPtr<Document> doc(GetDocument());
|
||||
*aHasTrackingContentBlocked = doc && doc->GetHasTrackingContentBlocked();
|
||||
RefPtr<Promise> retPromise = Promise::Create(doc->GetOwnerGlobal(), rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
// Retrieve the document's content blocking events from the parent process.
|
||||
RefPtr<Document::GetContentBlockingEventsPromise> promise =
|
||||
doc->GetContentBlockingEvents();
|
||||
if (promise) {
|
||||
promise->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[retPromise](const Document::GetContentBlockingEventsPromise::
|
||||
ResolveOrRejectValue& aValue) {
|
||||
if (aValue.IsResolve()) {
|
||||
bool has = aValue.ResolveValue() &
|
||||
nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT;
|
||||
retPromise->MaybeResolve(has);
|
||||
} else {
|
||||
retPromise->MaybeResolve(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
retPromise->MaybeResolve(false);
|
||||
}
|
||||
|
||||
retPromise.forget(aPromise);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user