Bug 786303 - Use the manifestURL in WebApps notifications instead of the origin. r=fabrice

This commit is contained in:
Marco Castelluccio 2013-07-24 09:03:25 -04:00
Родитель b4cc4e0631
Коммит ca9cda33f5
6 изменённых файлов: 19 добавлений и 45 удалений

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

@ -59,11 +59,6 @@ AppsService.prototype = {
return DOMApplicationRegistry.getManifestURLByLocalId(aLocalId);
},
getAppFromObserverMessage: function getAppFromObserverMessage(aMessage) {
debug("getAppFromObserverMessage( " + aMessage + " )");
return DOMApplicationRegistry.getAppFromObserverMessage(aMessage);
},
getCoreAppsBasePath: function getCoreAppsBasePath() {
debug("getCoreAppsBasePath()");
return DOMApplicationRegistry.getCoreAppsBasePath();

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

@ -104,11 +104,6 @@ this.DOMApplicationRegistry = {
return AppsUtils.getManifestURLByLocalId(this.webapps, aLocalId);
},
getAppFromObserverMessage: function getAppFromObserverMessage(aMessage) {
debug("getAppFromObserverMessage " + aMessage);
return AppsUtils.getAppFromObserverMessage(this.webapps. aMessage);
},
getCoreAppsBasePath: function getCoreAppsBasePath() {
debug("getCoreAppsBasePath() not yet supported on child!");
return null;

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

@ -176,21 +176,6 @@ this.AppsUtils = {
return "";
},
getAppFromObserverMessage: function(aApps, aMessage) {
let data = JSON.parse(aMessage);
for (let id in aApps) {
let app = aApps[id];
if (app.origin != data.origin) {
continue;
}
return this.cloneAsMozIApplication(app);
}
return null;
},
getCoreAppsBasePath: function getCoreAppsBasePath() {
debug("getCoreAppsBasePath()");
try {

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

@ -2980,10 +2980,6 @@ this.DOMApplicationRegistry = {
return AppsUtils.getAppLocalIdByManifestURL(this.webapps, aManifestURL);
},
getAppFromObserverMessage: function(aMessage) {
return AppsUtils.getAppFromObserverMessage(this.webapps, aMessage);
},
getCoreAppsBasePath: function() {
return AppsUtils.getCoreAppsBasePath();
},

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

@ -17,7 +17,7 @@ interface nsIURI;
* This service allows accessing some DOMApplicationRegistry methods from
* non-javascript code.
*/
[scriptable, uuid(27b995cf-bec8-47de-aa48-6117c950fce3)]
[scriptable, uuid(9b23d8f0-b2f3-46af-bff4-3df6c3cb69db)]
interface nsIAppsService : nsISupports
{
mozIDOMApplication getAppByManifestURL(in DOMString manifestURL);
@ -40,13 +40,6 @@ interface nsIAppsService : nsISupports
*/
DOMString getManifestURLByLocalId(in unsigned long localId);
/**
* Returns the app that is related to the message.
* This is a helper to not have to worry about what is the actual structure
* of the message when listening to one.
*/
mozIApplication getAppFromObserverMessage(in DOMString message);
/**
* Returns the CSP associated to this localId.
*/

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

@ -345,19 +345,29 @@ this.PushService = {
break;
case "webapps-uninstall":
debug("webapps-uninstall");
let appsService = Cc["@mozilla.org/AppsService;1"]
.getService(Ci.nsIAppsService);
var app = appsService.getAppFromObserverMessage(aData);
if (!app) {
debug("webapps-uninstall: No app found " + aData.origin);
let data;
try {
data = JSON.parse(aData);
} catch (ex) {
debug("webapps-uninstall: JSON parsing error: " + aData);
return;
}
this._db.getAllByManifestURL(app.manifestURL, function(records) {
let manifestURL = data.manifestURL;
let appsService = Cc["@mozilla.org/AppsService;1"]
.getService(Ci.nsIAppsService);
if (appsService.getAppLocalIdByManifestURL(manifestURL) ==
Ci.nsIScriptSecurityManager.NO_APP_ID) {
debug("webapps-uninstall: No app found " + manifestURL);
return;
}
this._db.getAllByManifestURL(manifestURL, function(records) {
debug("Got " + records.length);
for (var i = 0; i < records.length; i++) {
this._db.delete(records[i].channelID, null, function() {
debug("app uninstall: " + app.manifestURL +
debug("app uninstall: " + manifestURL +
" Could not delete entry " + records[i].channelID);
});
// courtesy, but don't establish a connection
@ -368,7 +378,7 @@ this.PushService = {
}
}
}.bind(this), function() {
debug("Error in getAllByManifestURL: url " + app.manifestURL);
debug("Error in getAllByManifestURL: url " + manifestURL);
});
break;