--- a/browser/modules/ContentLinkHandler.jsm
+++ b/browser/modules/ContentLinkHandler.jsm
@@ -8,23 +8,24 @@ const EXPORTED_SYMBOLS = ["ContentLinkHa
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGlobalGetters(this, ["Blob", "FileReader"]);
ChromeUtils.defineModuleGetter(this, "Feeds",
"resource:///modules/Feeds.jsm");
-ChromeUtils.defineModuleGetter(this, "NetUtil",
- "resource://gre/modules/NetUtil.jsm");
ChromeUtils.defineModuleGetter(this, "DeferredTask",
"resource://gre/modules/DeferredTask.jsm");
ChromeUtils.defineModuleGetter(this, "PromiseUtils",
"resource://gre/modules/PromiseUtils.jsm");
+const BinaryInputStream = Components.Constructor("@mozilla.org/binaryinputstream;1",
+ "nsIBinaryInputStream", "setInputStream");
+
const SIZES_TELEMETRY_ENUM = {
NO_SIZES: 0,
ANY: 1,
DIMENSION: 2,
INVALID: 3,
};
const FAVICON_PARSING_TIMEOUT = 100;
@@ -64,26 +65,25 @@ function promiseBlobAsOctets(blob) {
});
}
class FaviconLoad {
constructor(iconInfo) {
this.buffers = [];
this.icon = iconInfo;
- this.channel = NetUtil.newChannel({
- uri: iconInfo.iconUri,
- loadingNode: iconInfo.node,
- loadingPrincipal: iconInfo.node.nodePrincipal,
- triggeringPrincipal: iconInfo.node.nodePrincipal,
- contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE_FAVICON,
- securityFlags: Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS |
- Ci.nsILoadInfo.SEC_ALLOW_CHROME |
- Ci.nsILoadInfo.SEC_DISALLOW_SCRIPT,
- });
+ this.channel = Services.io.newChannelFromURI2(
+ iconInfo.iconUri,
+ iconInfo.node,
+ iconInfo.node.nodePrincipal,
+ iconInfo.node.nodePrincipal,
+ (Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS |
+ Ci.nsILoadInfo.SEC_ALLOW_CHROME |
+ Ci.nsILoadInfo.SEC_DISALLOW_SCRIPT),
+ Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE_FAVICON);
this.channel.loadFlags |= Ci.nsIRequest.LOAD_BACKGROUND;
// Sometimes node is a document and sometimes it is an element. This is
// the easiest single way to get to the load group in both those cases.
this.channel.loadGroup = iconInfo.node.ownerGlobal.document.documentLoadGroup;
this.channel.notificationCallbacks = this;
if (Services.prefs.getBoolPref("network.http.tailing.enabled", true) &&
@@ -116,18 +116,20 @@ class FaviconLoad {
this.channel.cancel(Cr.NS_BINDING_ABORTED);
}
onStartRequest(request, context) {
}
onDataAvailable(request, context, inputStream, offset, count) {
- let data = NetUtil.readInputStreamToString(inputStream, count);
- this.buffers.push(Uint8Array.from(data, c => c.charCodeAt(0)));
+ let stream = new BinaryInputStream(inputStream);
+ let buffer = new ArrayBuffer(count);
+ stream.readArrayBuffer(buffer.byteLength, buffer);
+ this.buffers.push(new Uint8Array(buffer));
}
asyncOnChannelRedirect(oldChannel, newChannel, flags, callback) {
if (oldChannel == this.channel) {
this.channel = newChannel;
}
callback.onRedirectVerifyCallback(Cr.NS_OK);