Skip to content

Commit

Permalink
refactor: browser window options
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrykBuniX committed Apr 24, 2024
1 parent 031eb25 commit b5483b2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
13 changes: 13 additions & 0 deletions electron/src/calling/PictureInPictureCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,21 @@
*
*/

import {getNewWindowOptions} from '../window/WindowUtil';

const PICTURE_IN_PICTURE_CALL_FRAME_NAME = 'WIRE_PICTURE_IN_PICTURE_CALL';

export const isPictureInPictureCallWindow = (frameName: string): boolean => {
return frameName === PICTURE_IN_PICTURE_CALL_FRAME_NAME;
};

export const getPictureInPictureCallWindowOptions = (): Electron.BrowserWindowConstructorOptions => {
return getNewWindowOptions({
title: 'Calling UI',
width: 290,
height: 290,
resizable: true,
fullscreenable: true,
maximizable: true,
});
};
18 changes: 3 additions & 15 deletions electron/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {LogFactory} from '@wireapp/commons';
import {WebAppEvents} from '@wireapp/webapp-events';

import * as ProxyAuth from './auth/ProxyAuth';
import {isPictureInPictureCallWindow} from './calling/PictureInPictureCall';
import {getPictureInPictureCallWindowOptions, isPictureInPictureCallWindow} from './calling/PictureInPictureCall';
import {
attachTo as attachCertificateVerifyProcManagerTo,
setCertificateVerifyProc,
Expand Down Expand Up @@ -592,26 +592,14 @@ class ElectronWrapperInit {
if (SingleSignOn.isSingleSignOnLoginWindow(details.frameName)) {
return {
action: 'allow',
overrideBrowserWindowOptions: WindowUtil.getNewWindowOptions({
title: SingleSignOn.getWindowTitle(details.url),
parent: main,
width: 480,
height: 600,
}),
overrideBrowserWindowOptions: SingleSignOn.getSingleSignOnLoginWindowOptions(main, details.url),
};
}

if (isPictureInPictureCallWindow(details.frameName)) {
return {
action: 'allow',
overrideBrowserWindowOptions: WindowUtil.getNewWindowOptions({
title: 'Calling UI',
width: 290,
height: 290,
resizable: true,
fullscreenable: true,
maximizable: true,
}),
overrideBrowserWindowOptions: getPictureInPictureCallWindowOptions(),
};
}

Expand Down
11 changes: 11 additions & 0 deletions electron/src/sso/SingleSignOn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,17 @@ export class SingleSignOn {
// Ensure authenticity of the window from within the code
public static isSingleSignOnLoginWindow = (frameName: string) => SingleSignOn.SINGLE_SIGN_ON_FRAME_NAME === frameName;

public static getSingleSignOnLoginWindowOptions = (
parent: BrowserWindow,
origin: string,
): Electron.BrowserWindowConstructorOptions =>
WindowUtil.getNewWindowOptions({
title: SingleSignOn.getWindowTitle(origin),
parent,
width: 480,
height: 600,
});

// Returns an empty string if the origin is a Wire backend
public static getWindowTitle = (origin: string): string =>
SingleSignOn.ALLOWED_BACKEND_ORIGINS.includes(origin) ? '' : origin;
Expand Down

0 comments on commit b5483b2

Please sign in to comment.