Bug 804623 - Permission Prompt Helper needs more access context to enable/disable permissions. r=sicking
authorGregor Wagner <anygregor@gmail.com>
Thu, 04 Apr 2013 17:47:46 -0700
changeset 139516 2418deea4b19e48fb1f5f5ef5402563c3d428501
parent 139515 03a6b2be2d610ff22b75194d0abe335507b716f2
child 139517 8161280e740e290a8082a9e2a6c6766b23460a05
push id350
push userbbajaj@mozilla.com
push dateMon, 29 Jul 2013 23:00:49 +0000
treeherdermozilla-release@064965b37dbd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs804623
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 804623 - Permission Prompt Helper needs more access context to enable/disable permissions. r=sicking
dom/permission/PermissionPromptHelper.jsm
--- a/dom/permission/PermissionPromptHelper.jsm
+++ b/dom/permission/PermissionPromptHelper.jsm
@@ -54,68 +54,53 @@ this.PermissionPromptHelper = {
     debug("Init");
     ppmm.addMessageListener("PermissionPromptHelper:AskPermission", this);
     Services.obs.addObserver(this, "profile-before-change", false);
   },
 
   askPermission: function askPermission(aMessage, aCallbacks) {
     let msg = aMessage.json;
 
-    let access;
-    if (PermissionsTable[msg.type].access) {
-      access = "readwrite"; // XXXddahl: Not sure if this should be set to READWRITE
+    let access = msg.type;
+    if (msg.access) {
+      access = access + "-" + msg.access;
     }
-    // Expand permission names.
-    let expandedPermNames = expandPermissions(msg.type, access);
-    let installedPermValues = [];
+
     let uri = Services.io.newURI(msg.origin, null, null);
     let principal =
       secMan.getAppCodebasePrincipal(uri, msg.appID, msg.browserFlag);
 
-    for (let idx in expandedPermNames) {
-      let access = msg.access ? expandedPermNames[idx] : msg.type;
-      let permValue =
-        permissionManager.testExactPermissionFromPrincipal(principal, access);
-      installedPermValues.push(permValue);
-    }
+    let permValue =
+      permissionManager.testExactPermissionFromPrincipal(principal, access);
 
-    // TODO: see bug 804623, We are preventing "read" operations
-    // even if just "write" has been set to DENY_ACTION
-    for (let idx in installedPermValues) {
-      // if any of the installedPermValues are deny, run aCallbacks.cancel
-      if (installedPermValues[idx] == Ci.nsIPermissionManager.DENY_ACTION ||
-          installedPermValues[idx] == Ci.nsIPermissionManager.UNKNOWN_ACTION) {
-        aCallbacks.cancel();
-        return;
-      }
+    if (permValue == Ci.nsIPermissionManager.DENY_ACTION ||
+        permValue == Ci.nsIPermissionManager.UNKNOWN_ACTION) {
+      aCallbacks.cancel();
+      return;
     }
 
-    for (let idx in installedPermValues) {
-      if (installedPermValues[idx] == Ci.nsIPermissionManager.PROMPT_ACTION) {
-        // create a nsIContentPermissionRequest
-        let request = {
-          type: msg.type,
-          access: msg.access ? msg.access : "unused",
-          principal: principal,
-          QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionRequest]),
-          allow: aCallbacks.allow,
-          cancel: aCallbacks.cancel,
-          window: Services.wm.getMostRecentWindow("navigator:browser")
-        };
+    if (permValue == Ci.nsIPermissionManager.PROMPT_ACTION) {
+      // create a nsIContentPermissionRequest
+      let request = {
+        type: msg.type,
+        access: msg.access ? msg.access : "unused",
+        principal: principal,
+        QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionRequest]),
+        allow: aCallbacks.allow,
+        cancel: aCallbacks.cancel,
+        window: Services.wm.getMostRecentWindow("navigator:browser")
+      };
 
-        permissionPromptService.getPermission(request);
-        return;
-      }
+      permissionPromptService.getPermission(request);
+      return;
     }
 
-    for (let idx in installedPermValues) {
-      if (installedPermValues[idx] == Ci.nsIPermissionManager.ALLOW_ACTION) {
-        aCallbacks.allow();
-        return;
-      }
+    if (permValue == Ci.nsIPermissionManager.ALLOW_ACTION) {
+      aCallbacks.allow();
+      return;
     }
   },
 
   observe: function observe(aSubject, aTopic, aData) {
     ppmm.removeMessageListener("PermissionPromptHelper:AskPermission", this);
     Services.obs.removeObserver(this, "profile-before-change");
     ppmm = null;
   },