Bug 1091601 - Settings closes down when changing permissions for THA applications r=fabrice a=bajaj
authorFredrik Lanker <fredrik.lanker@sonymobile.com>
Thu, 30 Oct 2014 15:02:51 -0700
changeset 221299 95fbd763515294473708c0328686a82c75948426
parent 221298 45849b862a7fe7fe5b87cf403308294ce0100008
child 221300 d7b12401107c2b2528fda20d2294dd2f85dcad00
push id190
push userkwierso@gmail.com
push dateTue, 18 Nov 2014 04:12:03 +0000
treeherdermozilla-b2g34_v2_1@95fbd7635152 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice, bajaj
bugs1091601
milestone34.0
Bug 1091601 - Settings closes down when changing permissions for THA applications r=fabrice a=bajaj Application kind is used in isExplicitInPermissionsTable for checking the permissions in the permission table. When calling the function from PermissionSettings, the app kind wasn't passed so the permission check failed. This lead to Settings closing down when trying to change the permissions in "App permissions", due to the assert in receiveMessage (dom/permission/PermissionSettings.jsm). --- dom/permission/PermissionSettings.jsm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
dom/permission/PermissionSettings.jsm
--- a/dom/permission/PermissionSettings.jsm
+++ b/dom/permission/PermissionSettings.jsm
@@ -30,32 +30,32 @@ XPCOMUtils.defineLazyServiceGetter(this,
 this.PermissionSettingsModule = {
   init: function init() {
     debug("Init");
     ppmm.addMessageListener("PermissionSettings:AddPermission", this);
     Services.obs.addObserver(this, "profile-before-change", false);
   },
 
 
-  _isChangeAllowed: function(aPrincipal, aPermName, aAction) {
+  _isChangeAllowed: function(aPrincipal, aPermName, aAction, aAppKind) {
     // Bug 812289:
     // Change is allowed from a child process when all of the following
     // conditions stand true:
     //   * the action isn't "unknown" (so the change isn't a delete) if the app
     //     is installed
     //   * the permission already exists on the database
     //   * the permission is marked as explicit on the permissions table
     // Note that we *have* to check the first two conditions here because
     // permissionManager doesn't know if it's being called as a result of
     // a parent process or child process request. We could check
     // if the permission is actually explicit (and thus modifiable) or not
     // on permissionManager also but we currently don't.
     let perm =
       Services.perms.testExactPermissionFromPrincipal(aPrincipal,aPermName);
-    let isExplicit = isExplicitInPermissionsTable(aPermName, aPrincipal.appStatus);
+    let isExplicit = isExplicitInPermissionsTable(aPermName, aPrincipal.appStatus, aAppKind);
 
     return (aAction === "unknown" &&
             aPrincipal.appStatus === Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED) ||
            (aAction !== "unknown" &&
             (perm !== Ci.nsIPermissionManager.UNKNOWN_ACTION) &&
             isExplicit);
   },
 
@@ -63,18 +63,18 @@ this.PermissionSettingsModule = {
 
     this._internalAddPermission(aData, true, aCallbacks);
 
   },
 
 
   _internalAddPermission: function _internalAddPermission(aData, aAllowAllChanges, aCallbacks) {
     let uri = Services.io.newURI(aData.origin, null, null);
-    let appID = appsService.getAppLocalIdByManifestURL(aData.manifestURL);
-    let principal = Services.scriptSecurityManager.getAppCodebasePrincipal(uri, appID, aData.browserFlag);
+    let app = appsService.getAppByManifestURL(aData.manifestURL);
+    let principal = Services.scriptSecurityManager.getAppCodebasePrincipal(uri, app.localId, aData.browserFlag);
 
     let action;
     switch (aData.value)
     {
       case "unknown":
         action = Ci.nsIPermissionManager.UNKNOWN_ACTION;
         break;
       case "allow":
@@ -87,22 +87,22 @@ this.PermissionSettingsModule = {
         action = Ci.nsIPermissionManager.PROMPT_ACTION;
         break;
       default:
         dump("Unsupported PermisionSettings Action: " + aData.value +"\n");
         action = Ci.nsIPermissionManager.UNKNOWN_ACTION;
     }
 
     if (aAllowAllChanges ||
-        this._isChangeAllowed(principal, aData.type, aData.value)) {
-      debug("add: " + aData.origin + " " + appID + " " + action);
+        this._isChangeAllowed(principal, aData.type, aData.value, app.kind)) {
+      debug("add: " + aData.origin + " " + app.localId + " " + action);
       Services.perms.addFromPrincipal(principal, aData.type, action);
       return true;
     } else {
-      debug("add Failure: " + aData.origin + " " + appID + " " + action);
+      debug("add Failure: " + aData.origin + " " + app.localId + " " + action);
       return false; // This isn't currently used, see comment on setPermission
     }
   },
 
   getPermission: function getPermission(aPermName, aManifestURL, aOrigin, aBrowserFlag) {
     debug("getPermission: " + aPermName + ", " + aManifestURL + ", " + aOrigin);
     let uri = Services.io.newURI(aOrigin, null, null);
     let appID = appsService.getAppLocalIdByManifestURL(aManifestURL);