GeckoViewPermission.sys.mjs (1146B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 import { GeckoViewUtils } from "resource://gre/modules/GeckoViewUtils.sys.mjs"; 6 7 export class GeckoViewPermission { 8 constructor() { 9 this.wrappedJSObject = this; 10 } 11 12 async prompt(aRequest) { 13 const window = aRequest.window 14 ? aRequest.window 15 : aRequest.element.ownerGlobal; 16 17 const actor = window.windowGlobalChild.getActor("GeckoViewPermission"); 18 const result = await actor.promptPermission(aRequest); 19 if (!result.allow) { 20 aRequest.cancel(); 21 } else { 22 // Note: permission could be undefined, that's what aRequest expects. 23 const { permission } = result; 24 aRequest.allow(permission); 25 } 26 } 27 } 28 29 GeckoViewPermission.prototype.classID = Components.ID( 30 "{42f3c238-e8e8-4015-9ca2-148723a8afcf}" 31 ); 32 GeckoViewPermission.prototype.QueryInterface = ChromeUtils.generateQI([ 33 "nsIContentPermissionPrompt", 34 ]); 35 36 const { debug, warn } = GeckoViewUtils.initLogging("GeckoViewPermission");