[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 <cpoile@gmail.com>

---------

Co-authored-by: Christopher Poile <cpoile@gmail.com>
This commit is contained in:
Devin Binnie
2023-03-01 22:48:55 -05:00
committed by GitHub
parent cd051fe679
commit ec4a733507
2 changed files with 17 additions and 2 deletions

View File

@@ -380,12 +380,15 @@ function initializeAfterAppReady() {
'notifications', 'notifications',
'fullscreen', 'fullscreen',
'openExternal', 'openExternal',
'clipboard-sanitized-write',
]; ];
// handle permission requests // handle permission requests
// - approve if a supported permission type and the request comes from the renderer or one of the defined servers // - approve if a supported permission type and the request comes from the renderer or one of the defined servers
defaultSession.setPermissionRequestHandler((webContents, permission, callback) => { 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)) { if (!supportedPermissionTypes.includes(permission)) {
callback(false); callback(false);
return; return;
@@ -398,6 +401,18 @@ function initializeAfterAppReady() {
return; 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 requestingURL = webContents.getURL();
const serverURL = WindowManager.getServerURLFromWebContentsId(webContents.id); const serverURL = WindowManager.getServerURLFromWebContentsId(webContents.id);

View File

@@ -39,7 +39,7 @@ type LoadURLOpts = {
export default class CallsWidgetWindow extends EventEmitter { export default class CallsWidgetWindow extends EventEmitter {
public win: BrowserWindow; public win: BrowserWindow;
private main: BrowserWindow; private main: BrowserWindow;
private popOut: BrowserWindow | null = null; public popOut: BrowserWindow | null = null;
private mainView: MattermostView; private mainView: MattermostView;
private config: CallsWidgetWindowConfig; private config: CallsWidgetWindowConfig;
private boundsErr: Rectangle = { private boundsErr: Rectangle = {