Skip to content

Commit

Permalink
SDA-4018 Enabling copy/paste in clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
sbenmoussati committed Dec 28, 2022
1 parent b4d5f6d commit 397aa91
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/app/window-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ enum Permissions {
const PERMISSIONS_NAMESPACE = 'Permissions';

const saveWindowSettings = async (): Promise<void> => {
const browserWindow = BrowserWindow.getFocusedWindow() as ICustomBrowserWindow;
const browserWindow =
BrowserWindow.getFocusedWindow() as ICustomBrowserWindow;
const mainWebContents = windowHandler.getMainWebContents();

if (browserWindow && windowExists(browserWindow)) {
Expand Down Expand Up @@ -86,7 +87,8 @@ const saveWindowSettings = async (): Promise<void> => {
};

const windowMaximized = async (): Promise<void> => {
const browserWindow = BrowserWindow.getFocusedWindow() as ICustomBrowserWindow;
const browserWindow =
BrowserWindow.getFocusedWindow() as ICustomBrowserWindow;
if (browserWindow && windowExists(browserWindow)) {
const isMaximized = browserWindow.isMaximized();
const isFullScreen = browserWindow.isFullScreen();
Expand Down Expand Up @@ -216,7 +218,8 @@ export const updateAlwaysOnTop = async (
logger.info(
`window-actions: Should we set always on top? ${shouldSetAlwaysOnTop}!`,
);
const browserWins: ICustomBrowserWindow[] = BrowserWindow.getAllWindows() as ICustomBrowserWindow[];
const browserWins: ICustomBrowserWindow[] =
BrowserWindow.getAllWindows() as ICustomBrowserWindow[];
if (shouldUpdateUserConfig) {
await config.updateUserConfig({
alwaysOnTop: shouldSetAlwaysOnTop
Expand Down Expand Up @@ -264,7 +267,8 @@ export const handleKeyPress = (key: number): void => {
if (isMac || isLinux) {
return;
}
const browserWin = BrowserWindow.getFocusedWindow() as ICustomBrowserWindow;
const browserWin =
BrowserWindow.getFocusedWindow() as ICustomBrowserWindow;
if (
browserWin &&
windowExists(browserWin) &&
Expand Down Expand Up @@ -476,6 +480,11 @@ export const handlePermissionRequests = (webContents: WebContents): void => {
return;
}

const allowedPermissions = new Set([
'clipboard-read',
'clipboard-sanitized-write',
]);

session.setPermissionRequestHandler(
(_webContents, permission, callback, details) => {
switch (permission) {
Expand Down Expand Up @@ -550,7 +559,7 @@ export const handlePermissionRequests = (webContents: WebContents): void => {
callback,
);
default:
return callback(false);
return callback(allowedPermissions.has(permission));
}
},
);
Expand Down

0 comments on commit 397aa91

Please sign in to comment.