mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-02 20:42:49 +00:00
Bug 1003312 - make PermissionSettings.js{,m} use Services.jsm more; r=fabrice
This commit is contained in:
parent
84041459a1
commit
5340877d74
@ -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 + "'" +
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user