From 5cfc7ef5a935cc57243b50c4ec629a900c38d70a Mon Sep 17 00:00:00 2001 From: Christoph Kerschbaumer Date: Fri, 18 Mar 2016 10:58:58 -0700 Subject: [PATCH] Bug 1242857 - Use channel.asyncOpen2() within toolkit/components/places. r=sicking, r=mak --HG-- extra : rebase_source : 164a43d5195027d37df49d6e105ebf29cde50a83 --- toolkit/components/places/BookmarkJSONUtils.jsm | 7 +++---- toolkit/components/places/nsLivemarkService.js | 9 +++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/toolkit/components/places/BookmarkJSONUtils.jsm b/toolkit/components/places/BookmarkJSONUtils.jsm index f99708c151c2..4a68e26c0b28 100644 --- a/toolkit/components/places/BookmarkJSONUtils.jsm +++ b/toolkit/components/places/BookmarkJSONUtils.jsm @@ -208,14 +208,13 @@ BookmarkImporter.prototype = { let uri = NetUtil.newURI(spec); let channel = NetUtil.newChannel({ - uri, - loadingPrincipal: Services.scriptSecurityManager.createCodebasePrincipal(uri, {}), - contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST + uri: uri, + loadUsingSystemPrincipal: true }); let streamLoader = Cc["@mozilla.org/network/stream-loader;1"] .createInstance(Ci.nsIStreamLoader); streamLoader.init(streamObserver); - channel.asyncOpen(streamLoader, channel); + channel.asyncOpen2(streamLoader); }); }, diff --git a/toolkit/components/places/nsLivemarkService.js b/toolkit/components/places/nsLivemarkService.js index 32fd46e82dc6..3f67e5c604da 100644 --- a/toolkit/components/places/nsLivemarkService.js +++ b/toolkit/components/places/nsLivemarkService.js @@ -528,9 +528,14 @@ Livemark.prototype = { // cancel the channel. let loadgroup = Cc["@mozilla.org/network/load-group;1"]. createInstance(Ci.nsILoadGroup); + // Creating a CodeBasePrincipal and using it as the loadingPrincipal + // is *not* desired and is only tolerated within this file. + // TODO: Find the right OriginAttributes and pass something other + // than {} to .createCodeBasePrincipal(). let channel = NetUtil.newChannel({ - uri: this.feedURI.spec, + uri: this.feedURI, loadingPrincipal: Services.scriptSecurityManager.createCodebasePrincipal(this.feedURI, {}), + securityFlags: Ci.nsILoadInfo.SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED, contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_XMLHTTPREQUEST }).QueryInterface(Ci.nsIHttpChannel); channel.loadGroup = loadgroup; @@ -542,7 +547,7 @@ Livemark.prototype = { // Stream the result to the feed parser with this listener let listener = new LivemarkLoadListener(this); channel.notificationCallbacks = listener; - channel.asyncOpen(listener, null); + channel.asyncOpen2(listener); this.loadGroup = loadgroup; }