diff --git a/bootstrap.js b/bootstrap.js
index 93e552b..79ed82b 100644
--- a/bootstrap.js
+++ b/bootstrap.js
@@ -11,6 +11,7 @@ const CAA_URI = Services.io.newURI(CAA_URL, null, null);
const nsIURI = CC("@mozilla.org/network/simple-uri;1", "nsIURI");
const ff47plus = (Services.vc.compare(Services.appinfo.version, 47) > 0);
+const hint = '
';
const CAA_MODULES = [
"chrome://ca-archive/content/about.js",
@@ -336,6 +337,14 @@ let httpObserver = {
storageHost = redirect[1];
}
}
+ } else if (subject.URI.host == "addons.mozilla.org" && !Services.appinfo.browserTabsRemoteAutostart) {
+ let addon;
+ if (subject.responseStatus == "404" && (addon = /\/firefox\/addon\/(.*?)\//.exec(subject.URI.path)) !== null) {
+ subject.QueryInterface(Ci.nsITraceableChannel);
+ let newListener = new TracingListener();
+ newListener.addon = addon[1];
+ newListener.originalListener = subject.setNewListener(newListener);
+ }
}
}
},
@@ -358,6 +367,60 @@ let httpObserver = {
}
}
+function CCIN(cName, ifaceName) {
+ return Cc[cName].createInstance(Ci[ifaceName]);
+}
+
+function TracingListener() {
+ this.receivedData = [];
+}
+
+TracingListener.prototype = {
+ onDataAvailable: function(request, context, inputStream, offset, count) {
+ let binaryInputStream = CCIN("@mozilla.org/binaryinputstream;1","nsIBinaryInputStream");
+ binaryInputStream.setInputStream(inputStream);
+ let data = binaryInputStream.readBytes(count);
+ this.receivedData.push(data);
+ },
+ onStartRequest: function(request, context) {
+ try {
+ this.originalListener.onStartRequest(request, context);
+ } catch (err) {
+ request.cancel(err.result);
+ }
+ },
+ onStopRequest: function(request, context, statusCode) {
+ let data = this.receivedData.join("");
+ try {
+ data = data.replace(//, "$&" + hint.replace(/%ADDON%/g, this.addon));
+ data = data.replace(/