From ca9cda33f57085cbe7553bbbaf000bc92bfbd187 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Wed, 24 Jul 2013 09:03:25 -0400 Subject: [PATCH] Bug 786303 - Use the manifestURL in WebApps notifications instead of the origin. r=fabrice --- dom/apps/src/AppsService.js | 5 ----- dom/apps/src/AppsServiceChild.jsm | 5 ----- dom/apps/src/AppsUtils.jsm | 15 --------------- dom/apps/src/Webapps.jsm | 4 ---- dom/interfaces/apps/nsIAppsService.idl | 9 +-------- dom/push/src/PushService.jsm | 26 ++++++++++++++++++-------- 6 files changed, 19 insertions(+), 45 deletions(-) diff --git a/dom/apps/src/AppsService.js b/dom/apps/src/AppsService.js index fe364235b07d..bf6e32a01ede 100644 --- a/dom/apps/src/AppsService.js +++ b/dom/apps/src/AppsService.js @@ -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(); diff --git a/dom/apps/src/AppsServiceChild.jsm b/dom/apps/src/AppsServiceChild.jsm index eaff04b9ac77..fb27f060d752 100644 --- a/dom/apps/src/AppsServiceChild.jsm +++ b/dom/apps/src/AppsServiceChild.jsm @@ -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; diff --git a/dom/apps/src/AppsUtils.jsm b/dom/apps/src/AppsUtils.jsm index 6c9ea2d82df1..d4089a530a1a 100644 --- a/dom/apps/src/AppsUtils.jsm +++ b/dom/apps/src/AppsUtils.jsm @@ -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 { diff --git a/dom/apps/src/Webapps.jsm b/dom/apps/src/Webapps.jsm index 51f5f8d3cac1..6901563a02db 100644 --- a/dom/apps/src/Webapps.jsm +++ b/dom/apps/src/Webapps.jsm @@ -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(); }, diff --git a/dom/interfaces/apps/nsIAppsService.idl b/dom/interfaces/apps/nsIAppsService.idl index 63287ff3c9e7..19302eb950b7 100644 --- a/dom/interfaces/apps/nsIAppsService.idl +++ b/dom/interfaces/apps/nsIAppsService.idl @@ -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. */ diff --git a/dom/push/src/PushService.jsm b/dom/push/src/PushService.jsm index 267a1cb91fd4..2e0574434d50 100644 --- a/dom/push/src/PushService.jsm +++ b/dom/push/src/PushService.jsm @@ -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;