зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1189871 - Add event to add/remove permissions for Graphene. r=fabrice
This commit is contained in:
Родитель
7bf8055bf0
Коммит
942c3455f7
|
@ -738,6 +738,14 @@ Services.obs.addObserver(function(subject, topic, data) {
|
|||
shell.sendCustomEvent('mozmemorypressure');
|
||||
}, 'memory-pressure', false);
|
||||
|
||||
let permissionMap = new Map([
|
||||
['unknown', Services.perms.UNKNOWN_ACTION],
|
||||
['allow', Services.perms.ALLOW_ACTION],
|
||||
['deny', Services.perms.DENY_ACTION],
|
||||
['prompt', Services.perms.PROMPT_ACTION],
|
||||
]);
|
||||
let permissionMapRev = new Map(Array.from(permissionMap.entries()).reverse());
|
||||
|
||||
var CustomEventManager = {
|
||||
init: function custevt_init() {
|
||||
window.addEventListener("ContentStart", (function(evt) {
|
||||
|
@ -783,6 +791,22 @@ var CustomEventManager = {
|
|||
Services.obs.notifyObservers({ wrappedJSObject: shell.contentBrowser },
|
||||
'ask-children-to-execute-copypaste-command', detail.cmd);
|
||||
break;
|
||||
case 'add-permission':
|
||||
Services.perms.add(Services.io.newURI(detail.uri, null, null),
|
||||
detail.permissionType, permissionMap.get(detail.permission));
|
||||
break;
|
||||
case 'remove-permission':
|
||||
Services.perms.remove(Services.io.newURI(detail.uri, null, null),
|
||||
detail.permissionType);
|
||||
break;
|
||||
case 'test-permission':
|
||||
let result = Services.perms.testExactPermission(
|
||||
Services.io.newURI(detail.uri, null, null), detail.permissionType);
|
||||
// Not equal check here because we want to prevent default only if it's not set
|
||||
if (result !== permissionMapRev.get(detail.permission)) {
|
||||
evt.preventDefault();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче