Bug 805646 - Allow access fields in manifest files. r=ddahl
authorGregor Wagner <anygregor@gmail.com>
Fri, 26 Oct 2012 12:34:48 -0700
changeset 111688 55e06361e08ef413bd17c0c1957fa1ca38d4f8b3
parent 111687 1d857107b77883abebf8122b7d3c8b11806071d7
child 111689 d1ec228e2ff507cade5cdb89a68017a39259af48
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersddahl
bugs805646
milestone19.0a1
Bug 805646 - Allow access fields in manifest files. r=ddahl
dom/apps/src/PermissionsInstaller.jsm
--- a/dom/apps/src/PermissionsInstaller.jsm
+++ b/dom/apps/src/PermissionsInstaller.jsm
@@ -77,37 +77,41 @@ const PermissionsTable = { "resource-loc
                            "network-events": {
                              app: DENY_ACTION,
                              privileged: DENY_ACTION,
                              certified: ALLOW_ACTION
                            },
                            contacts: {
                              app: DENY_ACTION,
                              privileged: PROMPT_ACTION,
-                             certified: ALLOW_ACTION
+                             certified: ALLOW_ACTION,
+                             access: ["read", "write", "create"]
                            },
                            "device-storage:apps": {
                              app: DENY_ACTION,
                              privileged: ALLOW_ACTION,
                              certified: ALLOW_ACTION
                            },
                            "device-storage:pictures": {
                              app: DENY_ACTION,
                              privileged: ALLOW_ACTION,
-                             certified: ALLOW_ACTION
+                             certified: ALLOW_ACTION,
+                             access: ["read", "write", "create"]
                            },
                            "device-storage:videos": {
                              app: DENY_ACTION,
                              privileged: ALLOW_ACTION,
-                             certified: ALLOW_ACTION
+                             certified: ALLOW_ACTION,
+                             access: ["read", "write", "create"]
                            },
                            "device-storage:music": {
                              app: DENY_ACTION,
                              privileged: ALLOW_ACTION,
-                             certified: ALLOW_ACTION
+                             certified: ALLOW_ACTION,
+                             access: ["read", "write", "create"]
                            },
                            sms: {
                              app: DENY_ACTION,
                              privileged: DENY_ACTION,
                              certified: ALLOW_ACTION
                            },
                            telephony: {
                              app: DENY_ACTION,
@@ -147,17 +151,18 @@ const PermissionsTable = { "resource-loc
                            push: {
                              app: DENY_ACTION,
                              privileged: DENY_ACTION,
                              certified: ALLOW_ACTION
                            },
                            settings: {
                              app: DENY_ACTION,
                              privileged: DENY_ACTION,
-                             certified: ALLOW_ACTION
+                             certified: ALLOW_ACTION,
+                             access: ["read", "write"]
                            },
                            permissions: {
                              app: DENY_ACTION,
                              privileged: DENY_ACTION,
                              certified: ALLOW_ACTION
                            },
                            fmradio: {
                              app: ALLOW_ACTION,     // Matrix indicates '?'
@@ -262,23 +267,28 @@ for (let permName in PermissionsTable) {
  * @param string aAccess
  * @returns Array
  **/
 function expandPermissions(aPermName, aAccess) {
   if (!PermissionsTable[aPermName]) {
     Cu.reportError("PermissionsTable.jsm: expandPermissions: Unknown Permission: " + aPermName);
     throw new Error("PermissionsTable.jsm: expandPermissions: Unknown Permission: " + aPermName);
   }
+
+/* 
+Temporarily disabled in order to add access fields to gaia: See Bug 805646
   if (!aAccess && PermissionsTable[aPermName].access ||
       aAccess && !PermissionsTable[aPermName].access) {
     Cu.reportError("PermissionsTable.jsm: expandPermissions: Invalid Manifest : " +
                    aPermName + " " + aAccess + "\n");
     throw new Error("PermissionsTable.jsm: expandPermissions: Invalid Manifest");
   }
-  if (!PermissionsTable[aPermName].access) {
+*/
+
+  if (!PermissionsTable[aPermName].access || !aAccess) {
     return [aPermName];
   }
 
   let requestedSuffixes = [];
   switch(aAccess) {
   case READONLY:
     requestedSuffixes.push("read");
     break;
@@ -292,17 +302,17 @@ function expandPermissions(aPermName, aA
     requestedSuffixes.push("read", "create", "write");
     break;
   default:
     return [];
   }
 
   let permArr = mapSuffixes(aPermName, requestedSuffixes);
 
-  let expandedPerms = [];
+  let expandedPerms = [aPermName];
   for (let idx in permArr) {
     if (PermissionsTable[aPermName].access.indexOf(requestedSuffixes[idx]) != -1) {
       expandedPerms.push(permArr[idx]);
     }
   }
   return expandedPerms;
 }