зеркало из https://github.com/mozilla/gecko-dev.git
Bug 796198 - Use the right cookie jar when downloading package and minimanifest for packaged apps - Part 2 : use cookie jars. r=sicking, a=blocking-basecamp
This commit is contained in:
Родитель
772f350b8a
Коммит
0c64961581
|
@ -47,7 +47,9 @@ this.AppsUtils = {
|
||||||
downloadSize: aApp.downloadSize || 0,
|
downloadSize: aApp.downloadSize || 0,
|
||||||
lastUpdateCheck: aApp.lastUpdateCheck,
|
lastUpdateCheck: aApp.lastUpdateCheck,
|
||||||
updateTime: aApp.updateTime,
|
updateTime: aApp.updateTime,
|
||||||
etag: aApp.etag
|
etag: aApp.etag,
|
||||||
|
installerAppId: aApp.installerAppId || Ci.nsIScriptSecurityManager.NO_APP_ID,
|
||||||
|
installerIsBrowser: !!aApp.installerIsBrowser
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,7 @@ WebappsRegistry.prototype = {
|
||||||
Array.isArray(aParams.categories)) ? aParams.categories
|
Array.isArray(aParams.categories)) ? aParams.categories
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
let principal = this._window.document.nodePrincipal;
|
||||||
cpmm.sendAsyncMessage("Webapps:Install",
|
cpmm.sendAsyncMessage("Webapps:Install",
|
||||||
{ app: {
|
{ app: {
|
||||||
installOrigin: this._getOrigin(installURL),
|
installOrigin: this._getOrigin(installURL),
|
||||||
|
@ -107,7 +108,9 @@ WebappsRegistry.prototype = {
|
||||||
},
|
},
|
||||||
from: installURL,
|
from: installURL,
|
||||||
oid: this._id,
|
oid: this._id,
|
||||||
requestID: requestID
|
requestID: requestID,
|
||||||
|
appId: principal.appId,
|
||||||
|
isBrowser: principal.isInBrowserElement
|
||||||
});
|
});
|
||||||
return request;
|
return request;
|
||||||
},
|
},
|
||||||
|
@ -168,6 +171,7 @@ WebappsRegistry.prototype = {
|
||||||
Array.isArray(aParams.categories)) ? aParams.categories
|
Array.isArray(aParams.categories)) ? aParams.categories
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
let principal = this._window.document.nodePrincipal;
|
||||||
cpmm.sendAsyncMessage("Webapps:InstallPackage",
|
cpmm.sendAsyncMessage("Webapps:InstallPackage",
|
||||||
{ app: {
|
{ app: {
|
||||||
installOrigin: this._getOrigin(installURL),
|
installOrigin: this._getOrigin(installURL),
|
||||||
|
@ -179,7 +183,9 @@ WebappsRegistry.prototype = {
|
||||||
from: installURL,
|
from: installURL,
|
||||||
oid: this._id,
|
oid: this._id,
|
||||||
requestID: requestID,
|
requestID: requestID,
|
||||||
isPackage: true
|
isPackage: true,
|
||||||
|
appId: principal.appId,
|
||||||
|
isBrowser: principal.isInBrowserElement
|
||||||
});
|
});
|
||||||
return request;
|
return request;
|
||||||
},
|
},
|
||||||
|
|
|
@ -123,6 +123,14 @@ this.DOMApplicationRegistry = {
|
||||||
if (this.webapps[id].appStatus === undefined) {
|
if (this.webapps[id].appStatus === undefined) {
|
||||||
this.webapps[id].appStatus = Ci.nsIPrincipal.APP_STATUS_INSTALLED;
|
this.webapps[id].appStatus = Ci.nsIPrincipal.APP_STATUS_INSTALLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default to NO_APP_ID and not in browser.
|
||||||
|
if (this.webapps[id].installerAppId === undefined) {
|
||||||
|
this.webapps[id].installerAppId = Ci.nsIScriptSecurityManager.NO_APP_ID;
|
||||||
|
}
|
||||||
|
if (this.webapps[id].installerIsBrowser === undefined) {
|
||||||
|
this.webapps[id].installerIsBrowser = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
aNext();
|
aNext();
|
||||||
|
@ -1162,6 +1170,8 @@ this.DOMApplicationRegistry = {
|
||||||
if (app.etag) {
|
if (app.etag) {
|
||||||
xhr.setRequestHeader("If-None-Match", app.etag);
|
xhr.setRequestHeader("If-None-Match", app.etag);
|
||||||
}
|
}
|
||||||
|
xhr.channel.notificationCallbacks =
|
||||||
|
this.createLoadContext(app.installerAppId, app.installerIsBrowser);
|
||||||
|
|
||||||
xhr.addEventListener("load", (function() {
|
xhr.addEventListener("load", (function() {
|
||||||
if (xhr.status == 200) {
|
if (xhr.status == 200) {
|
||||||
|
@ -1205,6 +1215,31 @@ this.DOMApplicationRegistry = {
|
||||||
xhr.send(null);
|
xhr.send(null);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Creates a nsILoadContext object with a given appId and isBrowser flag.
|
||||||
|
createLoadContext: function createLoadContext(aAppId, aIsBrowser) {
|
||||||
|
return {
|
||||||
|
associatedWindow: null,
|
||||||
|
topWindow : null,
|
||||||
|
appId: aAppId,
|
||||||
|
isInBrowserElement: aIsBrowser,
|
||||||
|
usePrivateBrowsing: false,
|
||||||
|
isContent: false,
|
||||||
|
|
||||||
|
isAppOfType: function(appType) {
|
||||||
|
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
},
|
||||||
|
|
||||||
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsILoadContext,
|
||||||
|
Ci.nsIInterfaceRequestor,
|
||||||
|
Ci.nsISupports]),
|
||||||
|
getInterface: function(iid) {
|
||||||
|
if (iid.equals(Ci.nsILoadContext))
|
||||||
|
return this;
|
||||||
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// Downloads the manifest and run checks, then eventually triggers the
|
// Downloads the manifest and run checks, then eventually triggers the
|
||||||
// installation UI.
|
// installation UI.
|
||||||
doInstall: function doInstall(aData, aMm) {
|
doInstall: function doInstall(aData, aMm) {
|
||||||
|
@ -1229,7 +1264,10 @@ this.DOMApplicationRegistry = {
|
||||||
.createInstance(Ci.nsIXMLHttpRequest);
|
.createInstance(Ci.nsIXMLHttpRequest);
|
||||||
xhr.open("GET", app.manifestURL, true);
|
xhr.open("GET", app.manifestURL, true);
|
||||||
xhr.channel.loadFlags |= Ci.nsIRequest.VALIDATE_ALWAYS;
|
xhr.channel.loadFlags |= Ci.nsIRequest.VALIDATE_ALWAYS;
|
||||||
|
xhr.channel.notificationCallbacks = this.createLoadContext(aData.appId,
|
||||||
|
aData.isBrowser);
|
||||||
xhr.responseType = "json";
|
xhr.responseType = "json";
|
||||||
|
|
||||||
xhr.addEventListener("load", (function() {
|
xhr.addEventListener("load", (function() {
|
||||||
if (xhr.status == 200) {
|
if (xhr.status == 200) {
|
||||||
if (!AppsUtils.checkManifestContentType(app.installOrigin, app.origin,
|
if (!AppsUtils.checkManifestContentType(app.installOrigin, app.origin,
|
||||||
|
@ -1281,6 +1319,8 @@ this.DOMApplicationRegistry = {
|
||||||
.createInstance(Ci.nsIXMLHttpRequest);
|
.createInstance(Ci.nsIXMLHttpRequest);
|
||||||
xhr.open("GET", app.manifestURL, true);
|
xhr.open("GET", app.manifestURL, true);
|
||||||
xhr.channel.loadFlags |= Ci.nsIRequest.VALIDATE_ALWAYS;
|
xhr.channel.loadFlags |= Ci.nsIRequest.VALIDATE_ALWAYS;
|
||||||
|
xhr.channel.notificationCallbacks = this.createLoadContext(aData.appId,
|
||||||
|
aData.isBrowser);
|
||||||
xhr.responseType = "json";
|
xhr.responseType = "json";
|
||||||
|
|
||||||
xhr.addEventListener("load", (function() {
|
xhr.addEventListener("load", (function() {
|
||||||
|
@ -1413,6 +1453,9 @@ this.DOMApplicationRegistry = {
|
||||||
appObject.name = manifest.name;
|
appObject.name = manifest.name;
|
||||||
appObject.csp = manifest.csp || "";
|
appObject.csp = manifest.csp || "";
|
||||||
|
|
||||||
|
appObject.installerAppId = aData.appId;
|
||||||
|
appObject.installerIsBrowser = aData.isBrowser;
|
||||||
|
|
||||||
this.webapps[id] = appObject;
|
this.webapps[id] = appObject;
|
||||||
|
|
||||||
// For package apps, the permissions are not in the mini-manifest, so
|
// For package apps, the permissions are not in the mini-manifest, so
|
||||||
|
@ -1649,7 +1692,8 @@ this.DOMApplicationRegistry = {
|
||||||
requestChannel.notificationCallbacks = {
|
requestChannel.notificationCallbacks = {
|
||||||
QueryInterface: function notifQI(aIID) {
|
QueryInterface: function notifQI(aIID) {
|
||||||
if (aIID.equals(Ci.nsISupports) ||
|
if (aIID.equals(Ci.nsISupports) ||
|
||||||
aIID.equals(Ci.nsIProgressEventSink))
|
aIID.equals(Ci.nsIProgressEventSink) ||
|
||||||
|
aIID.equals(Ci.nsILoadContext))
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||||
|
@ -1667,7 +1711,18 @@ this.DOMApplicationRegistry = {
|
||||||
progress: aProgress,
|
progress: aProgress,
|
||||||
app: app });
|
app: app });
|
||||||
},
|
},
|
||||||
onStatus: function notifStatus(aRequest, aContext, aStatus, aStatusArg) { }
|
onStatus: function notifStatus(aRequest, aContext, aStatus, aStatusArg) { },
|
||||||
|
|
||||||
|
// nsILoadContext
|
||||||
|
appId: app.installerAppId,
|
||||||
|
isInBrowserElement: app.installerIsBrowser,
|
||||||
|
usePrivateBrowsing: false,
|
||||||
|
isContent: false,
|
||||||
|
associatedWindow: null,
|
||||||
|
topWindow : null,
|
||||||
|
isAppOfType: function(appType) {
|
||||||
|
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We set the 'downloading' flag to true right before starting the fetch.
|
// We set the 'downloading' flag to true right before starting the fetch.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче