From ec4a733507c4a396510b35a37c309cf4115450f8 Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Wed, 1 Mar 2023 22:48:55 -0500 Subject: [PATCH] [MM-50527] Explicitly allow the Mattermost views access to write to the clipboard using Copy Link (#2565) * [MM-50527] Explicitly allow the Mattermost views access to write to the clipboard using Copy Link * Include calls widget window * Add calls popout to the list as well * Update src/main/app/initialize.ts Co-authored-by: Christopher Poile --------- Co-authored-by: Christopher Poile --- src/main/app/initialize.ts | 17 ++++++++++++++++- src/main/windows/callsWidgetWindow.ts | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/app/initialize.ts b/src/main/app/initialize.ts index 8a912c59..f1031a72 100644 --- a/src/main/app/initialize.ts +++ b/src/main/app/initialize.ts @@ -380,12 +380,15 @@ function initializeAfterAppReady() { 'notifications', 'fullscreen', 'openExternal', + 'clipboard-sanitized-write', ]; // handle permission requests // - approve if a supported permission type and the request comes from the renderer or one of the defined servers defaultSession.setPermissionRequestHandler((webContents, permission, callback) => { - // is the requested permission type supported? + log.debug('permission requested', webContents.getURL(), permission); + + // is the requested permission type supported? if (!supportedPermissionTypes.includes(permission)) { callback(false); return; @@ -398,6 +401,18 @@ function initializeAfterAppReady() { return; } + const callsWidgetWindow = WindowManager.callsWidgetWindow; + if (callsWidgetWindow) { + if (webContents.id === callsWidgetWindow.win.webContents.id) { + callback(true); + return; + } + if (callsWidgetWindow.popOut && webContents.id === callsWidgetWindow.popOut.webContents.id) { + callback(true); + return; + } + } + const requestingURL = webContents.getURL(); const serverURL = WindowManager.getServerURLFromWebContentsId(webContents.id); diff --git a/src/main/windows/callsWidgetWindow.ts b/src/main/windows/callsWidgetWindow.ts index 48492ad1..6da8e1ab 100644 --- a/src/main/windows/callsWidgetWindow.ts +++ b/src/main/windows/callsWidgetWindow.ts @@ -39,7 +39,7 @@ type LoadURLOpts = { export default class CallsWidgetWindow extends EventEmitter { public win: BrowserWindow; private main: BrowserWindow; - private popOut: BrowserWindow | null = null; + public popOut: BrowserWindow | null = null; private mainView: MattermostView; private config: CallsWidgetWindowConfig; private boundsErr: Rectangle = {