mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 776649, part 1: Add mozIApplication in order to expose a hasPermission() method through it. r=fabrice
This commit is contained in:
parent
0cded142db
commit
4c1b0c618d
@ -698,7 +698,25 @@ let DOMApplicationRegistry = {
|
||||
for (let id in this.webapps) {
|
||||
let app = this.webapps[id];
|
||||
if (app.manifestURL == aManifestURL) {
|
||||
return this._cloneAppObject(app);
|
||||
let res = this._cloneAppObject(app);
|
||||
res.hasPermission = function(permission) {
|
||||
let localId = DOMApplicationRegistry.getAppLocalIdByManifestURL(
|
||||
this.manifestURL);
|
||||
let uri = Services.io.newURI(this.manifestURL, null, null);
|
||||
let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(Ci.nsIScriptSecurityManager);
|
||||
// XXX for the purposes of permissions checking, this helper
|
||||
// should always be called on !isBrowser frames, so we
|
||||
// assume false here.
|
||||
let principal = secMan.getAppCodebasePrincipal(uri, localId,
|
||||
/*mozbrowser*/false);
|
||||
let perm = Services.perms.testExactPermissionFromPrincipal(principal,
|
||||
permission);
|
||||
return (perm === Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
};
|
||||
res.QueryInterface = XPCOMUtils.generateQI([Ci.mozIDOMApplication,
|
||||
Ci.mozIApplication]);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ XPIDL_MODULE = dom_apps
|
||||
GRE_MODULE = 1
|
||||
|
||||
XPIDLSRCS = \
|
||||
mozIApplication.idl \
|
||||
nsIDOMApplicationRegistry.idl \
|
||||
nsIAppsService.idl \
|
||||
nsIDOMMozApplicationEvent.idl \
|
||||
|
19
dom/interfaces/apps/mozIApplication.idl
Normal file
19
dom/interfaces/apps/mozIApplication.idl
Normal file
@ -0,0 +1,19 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=8 et :
|
||||
*/
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsIDOMApplicationRegistry.idl"
|
||||
|
||||
/**
|
||||
* We expose Gecko-internal helpers related to "web apps" through this
|
||||
* sub-interface.
|
||||
*/
|
||||
[scriptable, uuid(8de25e36-b4cb-4e89-9310-a199dce4e5f4)]
|
||||
interface mozIApplication: mozIDOMApplication
|
||||
{
|
||||
/* Return true if this app has |permission|. */
|
||||
boolean hasPermission(in string permission);
|
||||
};
|
Loading…
Reference in New Issue
Block a user