Issue #1787 - Remove nsIAppsService, mozIApplication and mozapp data cleanup.

This commit is contained in:
Moonchild 2024-11-20 20:18:19 +01:00 committed by roytam1
commit ff89fee91d
43 changed files with 5 additions and 1032 deletions

View file

@ -19,14 +19,10 @@ XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "appsService",
"@mozilla.org/AppsService;1",
"nsIAppsService");
// Shared code for AppsServiceChild.jsm, Webapps.jsm and Webapps.js
// Shared code for Webapps.jsm and Webapps.js
this.EXPORTED_SYMBOLS =
["AppsUtils", "ManifestHelper", "isAbsoluteURI", "mozIApplication"];
["AppsUtils", "ManifestHelper", "isAbsoluteURI"];
function debug(s) {
//dump("-*- AppsUtils.jsm: " + s + "\n");
@ -39,46 +35,6 @@ this.isAbsoluteURI = function(aURI) {
Services.io.newURI(aURI, null, bar).prePath != bar.prePath;
}
this.mozIApplication = function(aApp) {
_setAppProperties(this, aApp);
}
mozIApplication.prototype = {
hasPermission: function(aPermission) {
// This helper checks an URI inside |aApp|'s origin and part of |aApp| has a
// specific permission. It is not checking if browsers inside |aApp| have such
// permission.
let perm = Services.perms.testExactPermissionFromPrincipal(this.principal,
aPermission);
return (perm === Ci.nsIPermissionManager.ALLOW_ACTION);
},
get principal() {
if (this._principal) {
return this._principal;
}
this._principal = null;
try {
this._principal = Services.scriptSecurityManager.createCodebasePrincipal(
Services.io.newURI(this.origin, null, null),
{appId: this.localId});
} catch(e) {
dump("Could not create app principal " + e + "\n");
}
return this._principal;
},
QueryInterface: function(aIID) {
if (aIID.equals(Ci.mozIApplication) ||
aIID.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
}
}
function _setAppProperties(aObj, aApp) {
aObj.name = aApp.name;
aObj.csp = aApp.csp;
@ -217,21 +173,6 @@ this.AppsUtils = {
return aPagePath.substr(pathPos, pathLen);
},
getAppByManifestURL: function getAppByManifestURL(aApps, aManifestURL) {
debug("getAppByManifestURL " + aManifestURL);
// This could be O(1) if |webapps| was a dictionary indexed on manifestURL
// which should be the unique app identifier.
// It's currently O(n).
for (let id in aApps) {
let app = aApps[id];
if (app.manifestURL == aManifestURL) {
return new mozIApplication(app);
}
}
return null;
},
getManifestFor: function getManifestFor(aManifestURL) {
debug("getManifestFor(" + aManifestURL + ")");
return DOMApplicationRegistry.getManifestFor(aManifestURL);
@ -259,18 +200,6 @@ this.AppsUtils = {
return Ci.nsIScriptSecurityManager.NO_APP_ID;
},
getAppByLocalId: function getAppByLocalId(aApps, aLocalId) {
debug("getAppByLocalId " + aLocalId);
for (let id in aApps) {
let app = aApps[id];
if (app.localId == aLocalId) {
return new mozIApplication(app);
}
}
return null;
},
getManifestURLByLocalId: function getManifestURLByLocalId(aApps, aLocalId) {
debug("getManifestURLByLocalId " + aLocalId);
for (let id in aApps) {
@ -697,14 +626,6 @@ this.AppsUtils = {
return this.computeHash(JSON.stringify(aObject));
},
getAppManifestURLFromWindow: function(aWindow) {
let appId = aWindow.document.nodePrincipal.appId;
if (appId === Ci.nsIScriptSecurityManager.NO_APP_ID) {
return null;
}
return appsService.getManifestURLByLocalId(appId);
},
}
/**