From b5483b246ef51e3cc4fbb513d7456df9c02e9eed Mon Sep 17 00:00:00 2001 From: PatrykBuniX Date: Mon, 22 Apr 2024 14:42:48 +0200 Subject: [PATCH] refactor: browser window options --- electron/src/calling/PictureInPictureCall.ts | 13 +++++++++++++ electron/src/main.ts | 18 +++--------------- electron/src/sso/SingleSignOn.ts | 11 +++++++++++ 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/electron/src/calling/PictureInPictureCall.ts b/electron/src/calling/PictureInPictureCall.ts index 70f8b82646a..c5940228c2e 100644 --- a/electron/src/calling/PictureInPictureCall.ts +++ b/electron/src/calling/PictureInPictureCall.ts @@ -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, + }); +}; diff --git a/electron/src/main.ts b/electron/src/main.ts index 6d4e200e299..7909920cf0e 100644 --- a/electron/src/main.ts +++ b/electron/src/main.ts @@ -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, @@ -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(), }; } diff --git a/electron/src/sso/SingleSignOn.ts b/electron/src/sso/SingleSignOn.ts index 06aaeff0f27..9c9415efc81 100644 --- a/electron/src/sso/SingleSignOn.ts +++ b/electron/src/sso/SingleSignOn.ts @@ -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;