Skip to content

Commit

Permalink
Bug 769621 - Checking Contacts, Settings, Wifi and WebApps permission…
Browse files Browse the repository at this point in the history
… should use principal instead of URI. r=sicking
  • Loading branch information
mounirlamouri committed Jul 16, 2012
1 parent 99507ad commit 7f510a6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
6 changes: 3 additions & 3 deletions dom/apps/src/Webapps.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ function WebappsApplicationMgmt(aWindow) {
let principal = aWindow.document.nodePrincipal;
let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);

let perm = principal == secMan.getSystemPrincipal() ?
Ci.nsIPermissionManager.ALLOW_ACTION :
Services.perms.testExactPermission(principal.URI, "webapps-manage");
let perm = principal == secMan.getSystemPrincipal()
? Ci.nsIPermissionManager.ALLOW_ACTION
: Services.perms.testExactPermissionFromPrincipal(principal, "webapps-manage");

//only pages with perm set can use some functions
this.hasPrivileges = perm == Ci.nsIPermissionManager.ALLOW_ACTION;
Expand Down
6 changes: 3 additions & 3 deletions dom/contacts/ContactManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,9 @@ ContactManager.prototype = {
let principal = aWindow.document.nodePrincipal;
let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);

let perm = principal == secMan.getSystemPrincipal() ?
Ci.nsIPermissionManager.ALLOW_ACTION :
Services.perms.testExactPermission(principal.URI, "webcontacts-manage");
let perm = principal == secMan.getSystemPrincipal()
? Ci.nsIPermissionManager.ALLOW_ACTION
: Services.perms.testExactPermissionFromPrincipal(principal, "webcontacts-manage");

//only pages with perm set can use the contacts
this.hasPrivileges = perm == Ci.nsIPermissionManager.ALLOW_ACTION;
Expand Down
8 changes: 6 additions & 2 deletions dom/settings/SettingsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,12 @@ SettingsManager.prototype = {

let principal = aWindow.document.nodePrincipal;
let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
let readPerm = principal == secMan.getSystemPrincipal() ? Ci.nsIPermissionManager.ALLOW_ACTION : Services.perms.testExactPermission(principal.URI, "websettings-read");
let readwritePerm = principal == secMan.getSystemPrincipal() ? Ci.nsIPermissionManager.ALLOW_ACTION : Services.perms.testExactPermission(principal.URI, "websettings-readwrite");
let readPerm = principal == secMan.getSystemPrincipal()
? Ci.nsIPermissionManager.ALLOW_ACTION
: Services.perms.testExactPermissionFromPrincipal(principal, "websettings-read");
let readwritePerm = principal == secMan.getSystemPrincipal()
? Ci.nsIPermissionManager.ALLOW_ACTION
: Services.perms.testExactPermissionFromPrincipal(principal, "websettings-readwrite");
this.hasReadPrivileges = readPerm == Ci.nsIPermissionManager.ALLOW_ACTION;
this.hasReadWritePrivileges = readwritePerm == Ci.nsIPermissionManager.ALLOW_ACTION;
debug("has read privileges :" + this.hasReadPrivileges + ", has read-write privileges: " + this.hasReadWritePrivileges);
Expand Down
6 changes: 3 additions & 3 deletions dom/wifi/DOMWifiManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ DOMWifiManager.prototype = {
let principal = aWindow.document.nodePrincipal;
let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);

let perm = (principal == secMan.getSystemPrincipal()) ?
Ci.nsIPermissionManager.ALLOW_ACTION :
Services.perms.testExactPermission(principal.URI, "wifi-manage");
let perm = principal == secMan.getSystemPrincipal()
? Ci.nsIPermissionManager.ALLOW_ACTION
: Services.perms.testExactPermissionFromPrincipal(principal, "wifi-manage");

// Only pages with perm set can use the wifi manager.
this._hasPrivileges = perm == Ci.nsIPermissionManager.ALLOW_ACTION;
Expand Down

0 comments on commit 7f510a6

Please sign in to comment.