From 3df0a425de0ab35e4e869025f643f5dd9589682b Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 9 Dec 2020 11:35:31 +1100 Subject: [PATCH] remove permissions popup window and related stuff --- js/permissions_popup_start.js | 21 ------------- main.js | 59 ----------------------------------- package.json | 2 -- permissions_popup.html | 26 --------------- permissions_popup_preload.js | 52 ------------------------------ preload.js | 2 -- ts/util/lint/exceptions.json | 27 ---------------- 7 files changed, 189 deletions(-) delete mode 100644 js/permissions_popup_start.js delete mode 100644 permissions_popup.html delete mode 100644 permissions_popup_preload.js diff --git a/js/permissions_popup_start.js b/js/permissions_popup_start.js deleted file mode 100644 index 69fe851d7..000000000 --- a/js/permissions_popup_start.js +++ /dev/null @@ -1,21 +0,0 @@ -/* global $, i18n */ - -$(document).on('keyup', e => { - 'use strict'; - - if (e.keyCode === 27) { - window.closePermissionsPopup(); - } -}); - -window.confirmationDialog({ - title: i18n('audioPermissionNeeded'), - okText: i18n('allowAccess'), - resolve: () => { - 'use strict'; - - window.setMediaPermissions(true); - window.closePermissionsPopup(); - }, - onClose: window.closePermissionsPopup, -}); diff --git a/main.js b/main.js index 25a7495d4..fabcd9b09 100644 --- a/main.js +++ b/main.js @@ -669,56 +669,6 @@ async function showDebugLogWindow() { }); } -let permissionsPopupWindow; -async function showPermissionsPopupWindow() { - if (permissionsPopupWindow) { - permissionsPopupWindow.show(); - return; - } - if (!mainWindow) { - return; - } - - const theme = await getThemeFromMainWindow(); - const size = mainWindow.getSize(); - const options = { - width: Math.min(400, size[0]), - height: Math.min(150, size[1]), - resizable: false, - title: locale.messages.permissions.message, - autoHideMenuBar: true, - backgroundColor: '#FFFFFF', - show: false, - modal: true, - webPreferences: { - nodeIntegration: false, - nodeIntegrationInWorker: false, - contextIsolation: false, - preload: path.join(__dirname, 'permissions_popup_preload.js'), - nativeWindowOpen: true, - }, - parent: mainWindow, - }; - - permissionsPopupWindow = new BrowserWindow(options); - - captureClicks(permissionsPopupWindow); - - permissionsPopupWindow.loadURL( - prepareURL([__dirname, 'permissions_popup.html'], { theme }) - ); - - permissionsPopupWindow.on('closed', () => { - removeDarkOverlay(); - permissionsPopupWindow = null; - }); - - permissionsPopupWindow.once('ready-to-show', () => { - addDarkOverlay(); - permissionsPopupWindow.show(); - }); -} - // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. @@ -1079,15 +1029,6 @@ ipc.on('close-debug-log', () => { } }); -// Permissions Popup-related IPC calls - -ipc.on('show-permissions-popup', showPermissionsPopupWindow); -ipc.on('close-permissions-popup', () => { - if (permissionsPopupWindow) { - permissionsPopupWindow.close(); - } -}); - // Settings-related IPC calls function addDarkOverlay() { diff --git a/package.json b/package.json index fc2b8c9a6..cc29a6750 100644 --- a/package.json +++ b/package.json @@ -280,7 +280,6 @@ "background.html", "about.html", "password.html", - "permissions_popup.html", "debug_log.html", "_locales/**", "libloki/modules/*.js", @@ -296,7 +295,6 @@ "preload.js", "about_preload.js", "settings_preload.js", - "permissions_popup_preload.js", "debug_log_preload.js", "password_preload.js", "main.js", diff --git a/permissions_popup.html b/permissions_popup.html deleted file mode 100644 index f1fe49dfa..000000000 --- a/permissions_popup.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - diff --git a/permissions_popup_preload.js b/permissions_popup_preload.js deleted file mode 100644 index c591700bf..000000000 --- a/permissions_popup_preload.js +++ /dev/null @@ -1,52 +0,0 @@ -/* global window */ - -const { ipcRenderer } = require('electron'); -const url = require('url'); -const i18n = require('./js/modules/i18n'); - -const config = url.parse(window.location.toString(), true).query; -const { locale } = config; -const localeMessages = ipcRenderer.sendSync('locale-data'); - -global.dcodeIO = global.dcodeIO || {}; -global.dcodeIO.ByteBuffer = require('bytebuffer'); - -window.getVersion = () => config.version; -window.theme = config.theme; -window.i18n = i18n.setup(locale, localeMessages); - -require('./js/logging'); - -window.closePermissionsPopup = () => - ipcRenderer.send('close-permissions-popup'); - -window.getMediaPermissions = makeGetter('media-permissions'); -window.setMediaPermissions = makeSetter('media-permissions'); - -function makeGetter(name) { - return () => - new Promise((resolve, reject) => { - ipcRenderer.once(`get-success-${name}`, (event, error, value) => { - if (error) { - return reject(error); - } - - return resolve(value); - }); - ipcRenderer.send(`get-${name}`); - }); -} - -function makeSetter(name) { - return value => - new Promise((resolve, reject) => { - ipcRenderer.once(`set-success-${name}`, (event, error) => { - if (error) { - return reject(error); - } - - return resolve(); - }); - ipcRenderer.send(`set-${name}`, value); - }); -} diff --git a/preload.js b/preload.js index 28d3c780d..88e348166 100644 --- a/preload.js +++ b/preload.js @@ -250,8 +250,6 @@ ipc.on('get-theme-setting', () => { // Settings-related events -window.showPermissionsPopup = () => ipc.send('show-permissions-popup'); - ipc.on('add-dark-overlay', () => { const { addDarkOverlay } = window.Events; if (addDarkOverlay) { diff --git a/ts/util/lint/exceptions.json b/ts/util/lint/exceptions.json index 757063adc..714ecfee7 100644 --- a/ts/util/lint/exceptions.json +++ b/ts/util/lint/exceptions.json @@ -267,33 +267,6 @@ "reasonCategory": "falseMatch", "updated": "2018-09-19T18:13:29.628Z" }, - { - "rule": "jQuery-$(", - "path": "js/permissions_popup_start.js", - "line": "$(document).on('keyup', e => {", - "lineNumber": 3, - "reasonCategory": "usageTrusted", - "updated": "2018-09-19T21:59:32.770Z", - "reasonDetail": "Protected from arbitrary input" - }, - { - "rule": "jQuery-$(", - "path": "js/permissions_popup_start.js", - "line": "const $body = $(document.body);", - "lineNumber": 11, - "reasonCategory": "usageTrusted", - "updated": "2018-09-19T21:59:32.770Z", - "reasonDetail": "Protected from arbitrary input" - }, - { - "rule": "jQuery-appendTo(", - "path": "js/permissions_popup_start.js", - "line": "window.view.$el.appendTo($body);", - "lineNumber": 26, - "reasonCategory": "usageTrusted", - "updated": "2018-09-19T18:13:29.628Z", - "reasonDetail": "Interacting with already-existing DOM nodes" - }, { "rule": "jQuery-$(", "path": "js/settings_start.js",