Skip to content

Commit

Permalink
Bug 1804264 - Refactor PermissionUI to use JS class r=pbz
Browse files Browse the repository at this point in the history
Also, esmify.

Differential Revision: https://phabricator.services.mozilla.com/D167074
  • Loading branch information
gregorypappas committed Jan 23, 2023
1 parent a3d0c20 commit e823139
Show file tree
Hide file tree
Showing 8 changed files with 347 additions and 347 deletions.
18 changes: 15 additions & 3 deletions browser/base/content/browser-fullScreenAndPointerLock.js
Original file line number Diff line number Diff line change
Expand Up @@ -901,12 +901,24 @@ var FullScreen = {
};

XPCOMUtils.defineLazyGetter(FullScreen, "_permissionNotificationIDs", () => {
let { PermissionUI } = ChromeUtils.import(
"resource:///modules/PermissionUI.jsm"
let { PermissionUI } = ChromeUtils.importESModule(
"resource:///modules/PermissionUI.sys.mjs"
);
return (
Object.values(PermissionUI)
.filter(value => value.prototype && value.prototype.notificationID)
.filter(value => {
let returnValue;
try {
returnValue = value.prototype.notificationID;
} catch (err) {
if (err.message === "Not implemented.") {
returnValue = false;
} else {
throw err;
}
}
return returnValue;
})
.map(value => value.prototype.notificationID)
// Additionally include webRTC permission prompt which does not use PermissionUI
.concat(["webRTC-shareDevices"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

requestLongerTimeout(2);

const { PermissionUI } = ChromeUtils.import(
"resource:///modules/PermissionUI.jsm"
const { PermissionUI } = ChromeUtils.importESModule(
"resource:///modules/PermissionUI.sys.mjs"
);
const { SitePermissions } = ChromeUtils.import(
"resource:///modules/SitePermissions.jsm"
Expand Down
6 changes: 3 additions & 3 deletions browser/components/BrowserGlue.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
NewTabUtils: "resource://gre/modules/NewTabUtils.sys.mjs",
OsEnvironment: "resource://gre/modules/OsEnvironment.sys.mjs",
PageDataService: "resource:///modules/pagedata/PageDataService.sys.mjs",
PermissionUI: "resource:///modules/PermissionUI.sys.mjs",
PlacesBackups: "resource://gre/modules/PlacesBackups.sys.mjs",
PlacesDBUtils: "resource://gre/modules/PlacesDBUtils.sys.mjs",
PlacesUIUtils: "resource:///modules/PlacesUIUtils.sys.mjs",
Expand Down Expand Up @@ -75,7 +76,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
PageActions: "resource:///modules/PageActions.jsm",
PageThumbs: "resource://gre/modules/PageThumbs.jsm",
PdfJs: "resource://pdf.js/PdfJs.jsm",
PermissionUI: "resource:///modules/PermissionUI.jsm",
PluralForm: "resource://gre/modules/PluralForm.jsm",
ProcessHangMonitor: "resource:///modules/ProcessHangMonitor.jsm",
PublicSuffixList: "resource://gre/modules/netwerk-dns/PublicSuffixList.jsm",
Expand Down Expand Up @@ -5210,7 +5210,7 @@ var ContentBlockingCategoriesPrefs = {
* can also be overridden by system add-ons or tests to provide new ones.
*
* This override ability is provided by Integration.sys.mjs. See
* PermissionUI.jsm for an example of how to provide a new prompt
* PermissionUI.sys.mjs for an example of how to provide a new prompt
* from an add-on.
*/
const ContentPermissionIntegration = {
Expand All @@ -5228,7 +5228,7 @@ const ContentPermissionIntegration = {
* Example: "geolocation"
* @param {nsIContentPermissionRequest} request
* The request for a permission from content.
* @return {PermissionPrompt} (see PermissionUI.jsm),
* @return {PermissionPrompt} (see PermissionUI.sys.mjs),
* or undefined if the type cannot be handled.
*/
createPermissionPrompt(type, request) {
Expand Down
Loading

0 comments on commit e823139

Please sign in to comment.