Bug 960601 - Fixed installation of priviledged app with origin. r=fabrice

This commit is contained in:
Carmen Jimenez 2014-01-22 15:42:56 +01:00
Родитель 23be98ba63
Коммит 1de28836a9
1 изменённых файлов: 9 добавлений и 7 удалений

Просмотреть файл

@ -2693,7 +2693,7 @@ onInstallSuccessAck: function onInstallSuccessAck(aManifestURL,
AppDownloadManager.remove(aNewApp.manifestURL);
return [id, newManifest];
return [oldApp.id, newManifest];
}).bind(this)).then(
aOnSuccess,
@ -3150,7 +3150,8 @@ onInstallSuccessAck: function onInstallSuccessAck(aManifestURL,
aOldApp.appStatus = AppsUtils.getAppManifestStatus(newManifest);
this._saveEtag(aIsUpdate, aOldApp, aRequestChannel, aHash, newManifest);
this._checkOrigin(aIsSigned, aOldApp, newManifest, aIsUpdate);
this._checkOrigin(aIsSigned || aIsLocalFileInstall, aOldApp, newManifest,
aIsUpdate);
this._getIds(aIsSigned, aZipReader, converter, aNewApp, aOldApp, aIsUpdate);
return newManifest;
@ -3231,7 +3232,7 @@ onInstallSuccessAck: function onInstallSuccessAck(aManifestURL,
if (aIsUpdate) {
// Changing the origin during an update is not allowed.
if (uri.prePath != app.origin) {
if (uri.prePath != aOldApp.origin) {
throw "INVALID_ORIGIN_CHANGE";
}
// Nothing else to do for an update... since the
@ -3239,24 +3240,25 @@ onInstallSuccessAck: function onInstallSuccessAck(aManifestURL,
// app nor can we have a duplicated origin
} else {
debug("Setting origin to " + uri.prePath +
" for " + app.manifestURL);
" for " + aOldApp.manifestURL);
let newId = uri.prePath.substring(6); // "app://".length
if (newId in this.webapps) {
throw "DUPLICATE_ORIGIN";
}
aOldApp.origin = uri.prePath;
// Update the registry.
let oldId = aOldApp.id;
aOldApp.id = newId;
this.webapps[newId] = aOldApp;
delete this.webapps[aId];
delete this.webapps[oldId];
// Rename the directories where the files are installed.
[DIRECTORY_NAME, "TmpD"].forEach(function(aDir) {
let parent = FileUtils.getDir(aDir, ["webapps"], true, true);
let dir = FileUtils.getDir(aDir, ["webapps", aId], true, true);
let dir = FileUtils.getDir(aDir, ["webapps", oldId], true, true);
dir.moveTo(parent, newId);
});
// Signals that we need to swap the old id with the new app.
this.broadcastMessage("Webapps:RemoveApp", { id: aId });
this.broadcastMessage("Webapps:RemoveApp", { id: oldId });
this.broadcastMessage("Webapps:AddApp", { id: newId,
app: aOldApp });
}