From 696a2d029fd2341d012038b9241594103339cdce Mon Sep 17 00:00:00 2001 From: Christoph Kerschbaumer Date: Fri, 18 Sep 2015 09:27:32 -0700 Subject: [PATCH] Bug 1204703 - Add AsyncOpen2 to channels in toolkit/ and b2g/ (r=sicking) --HG-- extra : source : deda472458fd5314c11461302008ce984dbd00a7 --- b2g/components/ActivityChannel.jsm | 8 +++++++- .../components/addoncompat/RemoteAddonsChild.jsm | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/b2g/components/ActivityChannel.jsm b/b2g/components/ActivityChannel.jsm index 5b33f5275165..9dfa13d67caa 100644 --- a/b2g/components/ActivityChannel.jsm +++ b/b2g/components/ActivityChannel.jsm @@ -12,6 +12,10 @@ XPCOMUtils.defineLazyServiceGetter(this, "cpmm", "@mozilla.org/childprocessmessagemanager;1", "nsIMessageSender"); +XPCOMUtils.defineLazyServiceGetter(this, "contentSecManager", + "@mozilla.org/contentsecuritymanager;1", + "nsIContentSecurityManager"); + this.EXPORTED_SYMBOLS = ["ActivityChannel"]; this.ActivityChannel = function(aURI, aLoadInfo, aName, aDetails) { @@ -51,7 +55,9 @@ this.ActivityChannel.prototype = { }, asyncOpen2: function(aListener) { - this.asyncOpen(aListener, null); + // throws an error if security checks fail + var outListener = contentSecManager.performSecurityCheck(this, aListener); + this.asyncOpen(outListener, null); }, QueryInterface2: XPCOMUtils.generateQI([Ci.nsIChannel]) diff --git a/toolkit/components/addoncompat/RemoteAddonsChild.jsm b/toolkit/components/addoncompat/RemoteAddonsChild.jsm index e3d721fbe7d9..c1ea329e26ee 100644 --- a/toolkit/components/addoncompat/RemoteAddonsChild.jsm +++ b/toolkit/components/addoncompat/RemoteAddonsChild.jsm @@ -20,6 +20,10 @@ XPCOMUtils.defineLazyModuleGetter(this, "Prefetcher", XPCOMUtils.defineLazyServiceGetter(this, "SystemPrincipal", "@mozilla.org/systemprincipal;1", "nsIPrincipal"); +XPCOMUtils.defineLazyServiceGetter(this, "contentSecManager", + "@mozilla.org/contentsecuritymanager;1", + "nsIContentSecurityManager"); + // Similar to Python. Returns dict[key] if it exists. Otherwise, // sets dict[key] to default_ and returns default_. function setDefault(dict, key, default_) @@ -274,10 +278,20 @@ AboutProtocolChannel.prototype = { Services.tm.currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL); }, + asyncOpen2: function(listener) { + // throws an error if security checks fail + var outListener = contentSecManager.performSecurityCheck(this, listener); + this.asyncOpen(outListener, null); + }, + open: function() { throw Cr.NS_ERROR_NOT_IMPLEMENTED; }, + open2: function() { + throw Cr.NS_ERROR_NOT_IMPLEMENTED; + }, + isPending: function() { return false; },