Bug 1312954 - Part 11: Updating speculativeConnect to speculativeConnect2 for Fennec. r?sebastian
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -4635,17 +4635,19 @@ var BrowserEventHandler = {
this._inCluster = aEvent.hitCluster;
if (this._inCluster) {
return; // No highlight for a cluster of links
}
let uri = this._getLinkURI(target);
if (uri) {
try {
- Services.io.QueryInterface(Ci.nsISpeculativeConnect).speculativeConnect(uri, null);
+ Services.io.QueryInterface(Ci.nsISpeculativeConnect).speculativeConnect2(uri,
+ target.ownerDocument.nodePrincipal,
+ null);
} catch (e) {}
}
this._doTapHighlight(target);
},
_getLinkURI: function(aElement) {
if (aElement.nodeType == Ci.nsIDOMNode.ELEMENT_NODE &&
((aElement instanceof Ci.nsIDOMHTMLAnchorElement && aElement.href) ||
@@ -6862,17 +6864,21 @@ var Tabs = {
this.expireLruTab();
}
break;
case "Session:Prefetch":
if (aData) {
try {
let uri = Services.io.newURI(aData);
if (uri && !this._domains.has(uri.host)) {
- Services.io.QueryInterface(Ci.nsISpeculativeConnect).speculativeConnect(uri, null);
+ Services.io.QueryInterface(Ci.nsISpeculativeConnect).speculativeConnect2(uri,
+ BrowserApp.selectedBrowser
+ .contentDocument
+ .nodePrincipal,
+ null);
this._domains.add(uri.host);
}
} catch (e) {}
}
break;
case "network:link-status-changed":
if (["down", "unknown", "up"].indexOf(aData) == -1) {
return;
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -130,17 +130,20 @@ public:
if (!specConn) {
return;
}
nsCOMPtr<nsIURI> uri = nsAppShell::ResolveURI(aUriStr->ToCString());
if (!uri) {
return;
}
- specConn->SpeculativeConnect(uri, nullptr);
+
+ OriginAttributes attrs;
+ nsCOMPtr<nsIPrincipal> principal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
+ specConn->SpeculativeConnect2(uri, principal, nullptr);
}
static void WaitOnGecko()
{
struct NoOpEvent : nsAppShell::Event {
void Run() override {}
};
nsAppShell::SyncRunEvent(NoOpEvent());