forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1567268 - [1.0] Report all ETP-related blocking and non-blocking.…
… r=geckoview-reviewers,snorp,rbarker Differential Revision: https://phabricator.services.mozilla.com/D40694
- Loading branch information
Dylan Roeh
committed
Aug 9, 2019
1 parent
9ca10cd
commit a7f5f26
Showing
9 changed files
with
490 additions
and
322 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
mobile/android/chrome/geckoview/GeckoViewContentBlockingChild.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const { GeckoViewChildModule } = ChromeUtils.import( | ||
"resource://gre/modules/GeckoViewChildModule.jsm" | ||
); | ||
|
||
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); | ||
} | ||
|
||
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( | ||
"GeckoViewContentBlocking" | ||
); // eslint-disable-line no-unused-vars | ||
const module = GeckoViewContentBlockingChild.create(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.