diff --git a/dom/apps/src/AppsService.js b/dom/apps/src/AppsService.js index 6ae20fcaea4..36d20a991f5 100644 --- a/dom/apps/src/AppsService.js +++ b/dom/apps/src/AppsService.js @@ -53,6 +53,26 @@ AppsService.prototype = { } }, + getAppByLocalId: function getAppByLocalId(aLocalId) { + debug("getAppByLocalId( " + aLocalId + " )"); + if (this.inParent) { + return DOMApplicationRegistry.getAppByLocalId(aLocalId); + } else { + return this.cpmm.sendSyncMessage("WebApps:GetAppByLocalId", + { id: aLocalId })[0]; + } + }, + + getManifestURLByLocalId: function getManifestURLByLocalId(aLocalId) { + debug("getManifestURLByLocalId( " + aLocalId + " )"); + if (this.inParent) { + return DOMApplicationRegistry.getManifestURLByLocalId(aLocalId); + } else { + return this.cpmm.sendSyncMessage("WebApps:GetManifestURLByLocalId", + { id: aLocalId })[0]; + } + }, + classID : APPS_SERVICE_CID, QueryInterface : XPCOMUtils.generateQI([Ci.nsIAppsService]) } diff --git a/dom/apps/src/Webapps.jsm b/dom/apps/src/Webapps.jsm index b19dd81de18..2b7045671c5 100644 --- a/dom/apps/src/Webapps.jsm +++ b/dom/apps/src/Webapps.jsm @@ -57,7 +57,8 @@ let DOMApplicationRegistry = { "Webapps:GetInstalled", "Webapps:GetNotInstalled", "Webapps:Launch", "Webapps:GetAll", "Webapps:InstallPackage", "Webapps:GetBasePath", - "WebApps:GetAppByManifestURL", "WebApps:GetAppLocalIdByManifestURL"]; + "WebApps:GetAppByManifestURL", "WebApps:GetAppLocalIdByManifestURL", + "WebApps:GetAppByLocalId", "Webapps:GetManifestURLByLocalId"]; this.messages.forEach((function(msgName) { ppmm.addMessageListener(msgName, this); @@ -249,6 +250,12 @@ let DOMApplicationRegistry = { case "WebApps:GetAppLocalIdByManifestURL": return { id: this.getAppLocalIdByManifestURL(msg.url) }; break; + case "WebApps:GetAppByLocalId": + return this.getAppByLocalId(msg.id); + break; + case "WebApps:GetManifestURLByLocalId": + return this.getManifestURLByLocalId(msg.id); + break; } }, @@ -698,6 +705,28 @@ let DOMApplicationRegistry = { return null; }, + getAppByLocalId: function(aLocalId) { + for (let id in this.webapps) { + let app = this.webapps[id]; + if (app.localId == aLocalId) { + return this._cloneAppObject(app); + } + } + + return null; + }, + + getManifestURLByLocalId: function(aLocalId) { + for (let id in this.webapps) { + let app = this.webapps[id]; + if (app.localId == aLocalId) { + return app.manifestURL; + } + } + + return null; + }, + getAppLocalIdByManifestURL: function(aManifestURL) { for (let id in this.webapps) { if (this.webapps[id].manifestURL == aManifestURL) { diff --git a/dom/interfaces/apps/nsIAppsService.idl b/dom/interfaces/apps/nsIAppsService.idl index 67471e7b6ef..e1559aa0e6b 100644 --- a/dom/interfaces/apps/nsIAppsService.idl +++ b/dom/interfaces/apps/nsIAppsService.idl @@ -15,7 +15,7 @@ interface mozIDOMApplication; * This service allows accessing some DOMApplicationRegistry methods from * non-javascript code. */ -[scriptable, uuid(1210a0f3-add3-4381-b892-9c102e3afc42)] +[scriptable, uuid(04e4ef3c-1a30-45bc-ab08-291820f13872)] interface nsIAppsService : nsISupports { mozIDOMApplication getAppByManifestURL(in DOMString manifestURL); @@ -27,4 +27,14 @@ interface nsIAppsService : nsISupports * installed manifest URL. */ unsigned long getAppLocalIdByManifestURL(in DOMString manifestURL); + + /** + * Returns the application associated to this localId. + */ + mozIDOMApplication getAppByLocalId(in unsigned long localId); + + /** + * Returns the manifest URL associated to this localId. + */ + DOMString getManifestURLByLocalId(in unsigned long localId); };