Bug 909573 - getManifestFor should accept a manifest url instead of an origin. r=fabrice

This commit is contained in:
Marco Castelluccio 2013-08-28 08:10:55 -04:00
parent bc3f221ede
commit bfa66ae5ef
4 changed files with 11 additions and 27 deletions

View File

@ -743,7 +743,7 @@ var AlertsHelper = {
this._listeners[uid] = listener;
let app = DOMApplicationRegistry.getAppByManifestURL(listener.manifestURL);
DOMApplicationRegistry.getManifestFor(app.origin, function(manifest) {
DOMApplicationRegistry.getManifestFor(app.manifestURL, function(manifest) {
let helper = new ManifestHelper(manifest, app.origin);
let getNotificationURLFor = function(messages) {
if (!messages)
@ -800,7 +800,7 @@ var AlertsHelper = {
// If we have a manifest URL, get the icon and title from the manifest
// to prevent spoofing.
let app = DOMApplicationRegistry.getAppByManifestURL(manifestUrl);
DOMApplicationRegistry.getManifestFor(app.origin, function(aManifest) {
DOMApplicationRegistry.getManifestFor(manifestUrl, function(aManifest) {
let helper = new ManifestHelper(aManifest, app.origin);
send(helper.name, helper.iconURLForSize(128));
});
@ -893,7 +893,7 @@ var WebappsHelper = {
switch(topic) {
case "webapps-launch":
DOMApplicationRegistry.getManifestFor(json.origin, function(aManifest) {
DOMApplicationRegistry.getManifestFor(json.manifestURL, function(aManifest) {
if (!aManifest)
return;

View File

@ -251,7 +251,7 @@ ContentPermissionPrompt.prototype = {
// When it's an app, get the manifest to add the l10n application name.
let app = DOMApplicationRegistry.getAppByLocalId(principal.appId);
DOMApplicationRegistry.getManifestFor(app.origin, function getManifest(aManifest) {
DOMApplicationRegistry.getManifestFor(app.manifestURL, function getManifest(aManifest) {
let helper = new ManifestHelper(aManifest, app.origin);
details.appName = helper.name;
browser.shell.sendChromeEvent(details);

View File

@ -1201,7 +1201,7 @@ this.DOMApplicationRegistry = {
}
// We need to get the old manifest to unregister web activities.
this.getManifestFor(app.origin, (function(aOldManifest) {
this.getManifestFor(aManifestURL, (function(aOldManifest) {
debug("Old manifest: " + JSON.stringify(aOldManifest));
// Move the application.zip and manifest.webapp files out of TmpD
let tmpDir = FileUtils.getDir("TmpD", ["webapps", id], true, true);
@ -1240,7 +1240,7 @@ this.DOMApplicationRegistry = {
Services.obs.notifyObservers(zipFile, "flush-cache-entry", null);
// Get the manifest, and set properties.
this.getManifestFor(app.origin, (function(aData) {
this.getManifestFor(aManifestURL, (function(aData) {
debug("New manifest: " + JSON.stringify(aData));
app.downloading = false;
app.downloadAvailable = false;
@ -1993,16 +1993,8 @@ this.DOMApplicationRegistry = {
let app = aData.app;
app.removable = true;
let origin = Services.io.newURI(app.origin, null, null);
let manifestURL = origin.resolve(app.manifestURL);
let id = this._appId(app.origin);
let localId = this.getAppLocalIdByManifestURL(manifestURL);
// For packaged apps, we need to get the id from the manifestURL.
if (localId && !id) {
id = this._appIdForManifestURL(manifestURL);
}
let id = this._appIdForManifestURL(app.manifestURL);
let localId = this.getAppLocalIdByManifestURL(app.manifestURL);
// Installing an application again is considered as an update.
if (id) {
@ -2137,14 +2129,6 @@ this.DOMApplicationRegistry = {
return id;
},
_appId: function(aURI) {
for (let id in this.webapps) {
if (this.webapps[id].origin == aURI)
return id;
}
return null;
},
_appIdForManifestURL: function(aURI) {
for (let id in this.webapps) {
if (this.webapps[id].manifestURL == aURI)
@ -2936,11 +2920,11 @@ this.DOMApplicationRegistry = {
}).bind(this));
},
getManifestFor: function(aOrigin, aCallback) {
getManifestFor: function(aManifestURL, aCallback) {
if (!aCallback)
return;
let id = this._appId(aOrigin);
let id = this._appIdForManifestURL(aManifestURL);
let app = this.webapps[id];
if (!id || (app.installState == "pending" && !app.retryingDownload)) {
aCallback(null);

View File

@ -6750,7 +6750,7 @@ var WebappsUI = {
break;
case "webapps-sync-install":
// Create a system notification allowing the user to launch the app
DOMApplicationRegistry.getManifestFor(data.origin, (function(aManifest) {
DOMApplicationRegistry.getManifestFor(data.manifestURL, (function(aManifest) {
if (!aManifest)
return;
let manifest = new ManifestHelper(aManifest, data.origin);