I am currently building an extension which is required to capture only HTTP request being made by the TOP frame browser (Not capture every HTTP request being initiated) before they are being sent out and the response received. Is that possible to handle in a Firefox extension?
I currently managed to capture all HTTP requests being made via the following code snippet:
var httpRequestObserver =
{
observe: function(aSubject, aTopic, aData)
{
var browser = this.getBrowserFromChannel(subject);
if (topic == "http-on-modify-request") {
var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
}
},
get observerService() {
return Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
},
register: function()
{
this.observerService.addObserver(this, "http-on-opening-request", false);
},
unregister: function()
{
this.observerService.removeObserver(this, "http-on-opening-request");
}
};
httpRequestObserver.register();
var {Cc, Ci} = require("chrome");
My question is, how can I update my code snippet to have it capture only HTTP requests being made by the top level browser (In other words, navigation requests made by a tab within the browser).
Thanks a bunch in advance!