Bug 1084505 - Fix explicit permission lookup for trusted hosted apps r=fabrice

This commit is contained in:
Markus Nilsson
2015-01-31 11:10:50 -08:00
parent 6fce2236b0
commit f6db392407
3 changed files with 12 additions and 6 deletions

View File

@@ -668,7 +668,7 @@ this.AllPossiblePermissions = [];
AllPossiblePermissions.concat(["indexedDB", "offline-app", "pin-app"]); AllPossiblePermissions.concat(["indexedDB", "offline-app", "pin-app"]);
})(); })();
this.isExplicitInPermissionsTable = function(aPermName, aIntStatus) { this.isExplicitInPermissionsTable = function(aPermName, aIntStatus, aAppKind) {
// Check to see if the 'webapp' is app/privileged/certified. // Check to see if the 'webapp' is app/privileged/certified.
let appStatus; let appStatus;
@@ -680,7 +680,7 @@ this.isExplicitInPermissionsTable = function(aPermName, aIntStatus) {
appStatus = "privileged"; appStatus = "privileged";
break; break;
default: // If it isn't certified or privileged, it's app default: // If it isn't certified or privileged, it's app
appStatus = "app"; appStatus = aAppKind == "hosted-trusted" ? "trusted" : "app";
break; break;
} }

View File

@@ -11,7 +11,7 @@
* We expose Gecko-internal helpers related to "web apps" through this * We expose Gecko-internal helpers related to "web apps" through this
* sub-interface. * sub-interface.
*/ */
[scriptable, uuid(1d856b11-ac29-47d3-bd52-a86e3d45fcf4)] [scriptable, uuid(1d856b11-ac29-47d3-bd52-a86e3d45fcf5)]
interface mozIApplication: nsISupports interface mozIApplication: nsISupports
{ {
/* Return true if this app has |permission|. */ /* Return true if this app has |permission|. */
@@ -55,4 +55,7 @@ interface mozIApplication: nsISupports
/* role copied from the manifest */ /* role copied from the manifest */
readonly attribute DOMString role; readonly attribute DOMString role;
/* Returns the kind of the app. */
readonly attribute DOMString kind;
}; };

View File

@@ -61,10 +61,13 @@ PermissionSettings.prototype = {
aBrowserFlag) { aBrowserFlag) {
debug("isExplicit: " + aPermName + ", " + aManifestURL + ", " + aOrigin); debug("isExplicit: " + aPermName + ", " + aManifestURL + ", " + aOrigin);
let uri = Services.io.newURI(aOrigin, null, null); let uri = Services.io.newURI(aOrigin, null, null);
let appID = appsService.getAppLocalIdByManifestURL(aManifestURL); let app = appsService.getAppByManifestURL(aManifestURL);
let principal = Services.scriptSecurityManager.getAppCodebasePrincipal(uri, appID, aBrowserFlag); let principal = Services.scriptSecurityManager
.getAppCodebasePrincipal(uri, app.localId, aBrowserFlag);
return isExplicitInPermissionsTable(aPermName, principal.appStatus); return isExplicitInPermissionsTable(aPermName,
principal.appStatus,
app.kind);
}, },
set: function set(aPermName, aPermValue, aManifestURL, aOrigin, set: function set(aPermName, aPermValue, aManifestURL, aOrigin,