mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 23:35:34 +00:00
Bug 1599043 - Part 10: Make GeckoView to listen OnContentBlockingEvent on the parent process. r=geckoview-reviewers,agi
The GeckoView is listening OnContentBlockingEvent in the content process. As we move the event into the parent process, we have to change it to listen the event in the parent process. This patch also adds a workaround in the test ContentBlockingControllerTest#getLog(). This workaround adds a 500ms delays before we check the ContentBlockingLog. This is needed because there is a delay between the notification of OnContentBlockingEven in the parent process and the actual recording of the log in the content process. This workaround will be no longer needed once we move the log entirely to the parent process (Bug 1599046). Differential Revision: https://phabricator.services.mozilla.com/D56749 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
e3647eeee3
commit
d67a32d3cf
@ -11,16 +11,6 @@ class GeckoViewContentBlockingChild extends GeckoViewChildModule {
|
||||
onEnable() {
|
||||
debug`onEnable`;
|
||||
|
||||
const flags = Ci.nsIWebProgress.NOTIFY_CONTENT_BLOCKING;
|
||||
this.progressFilter = Cc[
|
||||
"@mozilla.org/appshell/component/browser-status-filter;1"
|
||||
].createInstance(Ci.nsIWebProgress);
|
||||
this.progressFilter.addProgressListener(this, flags);
|
||||
const webProgress = docShell
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebProgress);
|
||||
webProgress.addProgressListener(this.progressFilter, flags);
|
||||
|
||||
this.messageManager.addMessageListener("ContentBlocking:RequestLog", this);
|
||||
}
|
||||
|
||||
@ -46,37 +36,6 @@ class GeckoViewContentBlockingChild extends GeckoViewChildModule {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onContentBlockingEvent(aWebProgress, aRequest, aEvent) {
|
||||
debug`onContentBlockingEvent ${aEvent.toString(16)}`;
|
||||
|
||||
if (!aRequest || !(aRequest instanceof Ci.nsIClassifiedChannel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const channel = aRequest.QueryInterface(Ci.nsIChannel);
|
||||
const uri = channel.URI && channel.URI.spec;
|
||||
const classChannel = aRequest.QueryInterface(Ci.nsIClassifiedChannel);
|
||||
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
debug`onContentBlockingEvent matchedList: ${classChannel.matchedList}`;
|
||||
debug`onContentBlockingEvent matchedTrackingLists: ${
|
||||
classChannel.matchedTrackingLists
|
||||
}`;
|
||||
|
||||
const message = {
|
||||
type: "GeckoView:ContentBlockingEvent",
|
||||
uri: uri,
|
||||
category: aEvent,
|
||||
blockedList: classChannel.matchedList || null,
|
||||
loadedLists: classChannel.matchedTrackingLists,
|
||||
};
|
||||
|
||||
this.eventDispatcher.sendRequest(message);
|
||||
}
|
||||
}
|
||||
|
||||
const { debug, warn } = GeckoViewContentBlockingChild.initLogging(
|
||||
|
@ -158,6 +158,10 @@ class ContentBlockingControllerTest : BaseSessionTest() {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onContentBlocked(session: GeckoSession,
|
||||
event: ContentBlocking.BlockEvent) {
|
||||
// A workaround for waiting until the log is actually recorded
|
||||
// in the content process.
|
||||
// TODO: This should be removed after Bug 1599046.
|
||||
Thread.sleep(500);
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -12,12 +12,25 @@ const { GeckoViewModule } = ChromeUtils.import(
|
||||
|
||||
class GeckoViewContentBlocking extends GeckoViewModule {
|
||||
onEnable() {
|
||||
const flags = Ci.nsIWebProgress.NOTIFY_CONTENT_BLOCKING;
|
||||
this.progressFilter = Cc[
|
||||
"@mozilla.org/appshell/component/browser-status-filter;1"
|
||||
].createInstance(Ci.nsIWebProgress);
|
||||
this.progressFilter.addProgressListener(this, flags);
|
||||
this.browser.addProgressListener(this.progressFilter, flags);
|
||||
|
||||
this.registerListener(["ContentBlocking:RequestLog"]);
|
||||
|
||||
this.messageManager.addMessageListener("ContentBlocking:ExportLog", this);
|
||||
}
|
||||
|
||||
onDisable() {
|
||||
if (this.progressFilter) {
|
||||
this.progressFilter.removeProgressListener(this);
|
||||
this.browser.removeProgressListener(this.progressFilter);
|
||||
delete this.progressFilter;
|
||||
}
|
||||
|
||||
this.unregisterListener(["ContentBlocking:RequestLog"]);
|
||||
|
||||
this.messageManager.removeMessageListener(
|
||||
@ -90,6 +103,37 @@ class GeckoViewContentBlocking extends GeckoViewModule {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onContentBlockingEvent(aWebProgress, aRequest, aEvent) {
|
||||
debug`onContentBlockingEvent ${aEvent.toString(16)}`;
|
||||
|
||||
if (aRequest instanceof Ci.nsIClassifiedChannel) {
|
||||
return;
|
||||
}
|
||||
|
||||
const channel = aRequest.QueryInterface(Ci.nsIChannel);
|
||||
const uri = channel.URI && channel.URI.spec;
|
||||
const classChannel = aRequest.QueryInterface(Ci.nsIClassifiedChannel);
|
||||
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
debug`onContentBlockingEvent matchedList: ${classChannel.matchedList}`;
|
||||
debug`onContentBlockingEvent matchedTrackingLists: ${
|
||||
classChannel.matchedTrackingLists
|
||||
}`;
|
||||
|
||||
const message = {
|
||||
type: "GeckoView:ContentBlockingEvent",
|
||||
uri: uri,
|
||||
category: aEvent,
|
||||
blockedList: classChannel.matchedList || null,
|
||||
loadedLists: classChannel.matchedTrackingLists,
|
||||
};
|
||||
|
||||
this.eventDispatcher.sendRequest(message);
|
||||
}
|
||||
}
|
||||
|
||||
const { debug, warn } = GeckoViewContentBlocking.initLogging(
|
||||
|
Loading…
Reference in New Issue
Block a user