Bug 1003312 - make PermissionSettings.js{,m} use Services.jsm more; r=fabrice

This commit is contained in:
Nathan Froyd 2014-04-29 13:27:51 -04:00
parent 84041459a1
commit 5340877d74
2 changed files with 9 additions and 29 deletions

View File

@ -28,16 +28,6 @@ function PermissionSettings()
debug("Constructor");
}
XPCOMUtils.defineLazyServiceGetter(this,
"permissionManager",
"@mozilla.org/permissionmanager;1",
"nsIPermissionManager");
XPCOMUtils.defineLazyServiceGetter(this,
"secMan",
"@mozilla.org/scriptsecuritymanager;1",
"nsIScriptSecurityManager");
XPCOMUtils.defineLazyServiceGetter(this,
"appsService",
"@mozilla.org/AppsService;1",
@ -48,8 +38,8 @@ PermissionSettings.prototype = {
debug("Get called with: " + aPermName + ", " + aManifestURL + ", " + aOrigin + ", " + aBrowserFlag);
let uri = Services.io.newURI(aOrigin, null, null);
let appID = appsService.getAppLocalIdByManifestURL(aManifestURL);
let principal = secMan.getAppCodebasePrincipal(uri, appID, aBrowserFlag);
let result = permissionManager.testExactPermanentPermission(principal, aPermName);
let principal = Services.scriptSecurityManager.getAppCodebasePrincipal(uri, appID, aBrowserFlag);
let result = Services.perms.testExactPermanentPermission(principal, aPermName);
switch (result)
{
@ -72,7 +62,7 @@ PermissionSettings.prototype = {
debug("isExplicit: " + aPermName + ", " + aManifestURL + ", " + aOrigin);
let uri = Services.io.newURI(aOrigin, null, null);
let appID = appsService.getAppLocalIdByManifestURL(aManifestURL);
let principal = secMan.getAppCodebasePrincipal(uri, appID, aBrowserFlag);
let principal = Services.scriptSecurityManager.getAppCodebasePrincipal(uri, appID, aBrowserFlag);
return isExplicitInPermissionsTable(aPermName, principal.appStatus);
},
@ -108,7 +98,7 @@ PermissionSettings.prototype = {
remove: function remove(aPermName, aManifestURL, aOrigin) {
let uri = Services.io.newURI(aOrigin, null, null);
let appID = appsService.getAppLocalIdByManifestURL(aManifestURL);
let principal = secMan.getAppCodebasePrincipal(uri, appID, true);
let principal = Services.scriptSecurityManager.getAppCodebasePrincipal(uri, appID, true);
if (principal.appStatus !== Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED) {
let errorMsg = "PermissionSettings.js: '" + aOrigin + "'" +

View File

@ -22,16 +22,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
"@mozilla.org/parentprocessmessagemanager;1",
"nsIMessageListenerManager");
XPCOMUtils.defineLazyServiceGetter(this,
"permissionManager",
"@mozilla.org/permissionmanager;1",
"nsIPermissionManager");
XPCOMUtils.defineLazyServiceGetter(this,
"secMan",
"@mozilla.org/scriptsecuritymanager;1",
"nsIScriptSecurityManager");
XPCOMUtils.defineLazyServiceGetter(this,
"appsService",
"@mozilla.org/AppsService;1",
@ -59,7 +49,7 @@ this.PermissionSettingsModule = {
// if the permission is actually explicit (and thus modifiable) or not
// on permissionManager also but we currently don't.
let perm =
permissionManager.testExactPermissionFromPrincipal(aPrincipal,aPermName);
Services.perms.testExactPermissionFromPrincipal(aPrincipal,aPermName);
let isExplicit = isExplicitInPermissionsTable(aPermName, aPrincipal.appStatus);
return (aAction === "unknown" &&
@ -79,7 +69,7 @@ this.PermissionSettingsModule = {
_internalAddPermission: function _internalAddPermission(aData, aAllowAllChanges, aCallbacks) {
let uri = Services.io.newURI(aData.origin, null, null);
let appID = appsService.getAppLocalIdByManifestURL(aData.manifestURL);
let principal = secMan.getAppCodebasePrincipal(uri, appID, aData.browserFlag);
let principal = Services.scriptSecurityManager.getAppCodebasePrincipal(uri, appID, aData.browserFlag);
let action;
switch (aData.value)
@ -104,7 +94,7 @@ this.PermissionSettingsModule = {
if (aAllowAllChanges ||
this._isChangeAllowed(principal, aData.type, aData.value)) {
debug("add: " + aData.origin + " " + appID + " " + action);
permissionManager.addFromPrincipal(principal, aData.type, action);
Services.perms.addFromPrincipal(principal, aData.type, action);
return true;
} else {
debug("add Failure: " + aData.origin + " " + appID + " " + action);
@ -116,8 +106,8 @@ this.PermissionSettingsModule = {
debug("getPermission: " + aPermName + ", " + aManifestURL + ", " + aOrigin);
let uri = Services.io.newURI(aOrigin, null, null);
let appID = appsService.getAppLocalIdByManifestURL(aManifestURL);
let principal = secMan.getAppCodebasePrincipal(uri, appID, aBrowserFlag);
let result = permissionManager.testExactPermissionFromPrincipal(principal, aPermName);
let principal = Services.scriptSecurityManager.getAppCodebasePrincipal(uri, appID, aBrowserFlag);
let result = Services.perms.testExactPermissionFromPrincipal(principal, aPermName);
switch (result)
{