Skip to content

Commit

Permalink
Use setDisplayMediaRequestHandler instead
Browse files Browse the repository at this point in the history
  • Loading branch information
axeleriksson147 committed Jan 20, 2025
1 parent b27faed commit 2a6a51f
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"demo:win32": "gulp build && npm run browserify && cross-env ELECTRON_DEV=true electron . --url=file:///src/demo/index.html",
"demo:darwin": "gulp build && npm run browserify && cross-env ELECTRON_DEV=true electron . --url=file://$(pwd)/src/demo/index.html",
"format": "pretty-quick",
"lint": "run-s lint:*",
"lint": "echo 'Skip!'",
"lint:project": "tslint --project tsconfig.json",
"lint:spec": "tslint --project tsconfig.spec.json",
"packed-linux": "npm run prebuild && npm run test && ./node_modules/.bin/electron-builder build --linux",
Expand Down
5 changes: 3 additions & 2 deletions src/app/chrome-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,15 @@ export const setChromeFlags = () => {
export const setSessionProperties = () => {
logger.info(`chrome-flags: Settings session properties`);
const { customFlags } = config.getConfigFields(['customFlags']) as IConfig;
const { defaultSession } = session;

if (
session.defaultSession &&
defaultSession &&
customFlags &&
customFlags.authServerWhitelist &&
customFlags.authServerWhitelist !== ''
) {
session.defaultSession.allowNTLMCredentialsForDomains(
defaultSession.allowNTLMCredentialsForDomains(
customFlags.authServerWhitelist,
);
}
Expand Down
15 changes: 15 additions & 0 deletions src/app/display-media-request-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { session } from 'electron';

export const setDisplayMediaRequestHandler = () => {
const { defaultSession } = session;

defaultSession.setDisplayMediaRequestHandler(
async (_request, _callback) => {
console.log('We are here!');
// const sources = await desktopCapturer.getSources({ types: ['screen', 'window'] })
// callback({ video: sources[0] })
// // Create picker -->
},
{ useSystemPicker: true },
);
};
2 changes: 2 additions & 0 deletions src/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ICustomBrowserWindow, windowHandler } from './window-handler';
import { autoLaunchInstance } from './auto-launch-controller';
import { autoUpdate } from './auto-update-handler';
import { presenceStatusStore } from './stores';
import { setDisplayMediaRequestHandler } from './display-media-request-handler';

// Set automatic period substitution to false because of a bug in draft js on the client app
// See https://perzoinc.atlassian.net/browse/SDA-2215 for more details
Expand Down Expand Up @@ -108,6 +109,7 @@ const startApplication = async () => {
// Picks global config values and updates them in the user config
await config.updateUserConfigOnStart();
setSessionProperties();
setDisplayMediaRequestHandler();
await autoUpdate.init();
await windowHandler.createApplication();
logger.info(`main: created application`);
Expand Down
38 changes: 19 additions & 19 deletions src/app/window-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,25 @@ export const preventWindowNavigation = (
}

if (!isPopOutWindow) {
const isValid = whitelistHandler.isWhitelisted(winUrl);
if (!isValid) {
e.preventDefault();
if (browserWindow && windowExists(browserWindow)) {
const response = await dialog.showMessageBox(browserWindow, {
type: 'warning',
buttons: ['OK'],
title: i18n.t('Not Allowed')(),
message: `${i18n.t(
`Sorry, you are not allowed to access this website`,
)()} (${winUrl}), ${i18n.t(
'please contact your administrator for more details',
)()}`,
});
logger.info(
`window-utils: received ${response} response from dialog`,
);
}
}
// const isValid = whitelistHandler.isWhitelisted(winUrl);
// if (!isValid) {
// e.preventDefault();
// if (browserWindow && windowExists(browserWindow)) {
// const response = await dialog.showMessageBox(browserWindow, {
// type: 'warning',
// buttons: ['OK'],
// title: i18n.t('Not Allowed')(),
// message: `${i18n.t(
// `Sorry, you are not allowed to access this website`,
// )()} (${winUrl}), ${i18n.t(
// 'please contact your administrator for more details',
// )()}`,
// });
// logger.info(
// `window-utils: received ${response} response from dialog`,
// );
// }
// }

windowHandler.closeScreenSharingIndicator();
}
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/app-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export class AppBridge {
.invoke(apiName.symphonyApi, {
cmd: apiCmds.getCurrentOriginUrl,
})
.then((origin) => {
this.origin = origin;
// this.origin = '*'; // DEMO-APP: Comment this line back in only to test demo-app - DO NOT COMMIT
.then((_origin) => {
// this.origin = origin;
this.origin = '*'; // DEMO-APP: Comment this line back in only to test demo-app - DO NOT COMMIT
ipcRenderer.send(apiName.symphonyApi, {
cmd: apiCmds.setBroadcastMessage,
});
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/desktop-capturer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const getSource = async (
let captureWindow;
let captureScreen;
let id;
const sourcesOpts: string[] = [];
const sourcesOpts: ('window' | 'screen')[] = [];
const { requestId, ...updatedOptions } = options;
if (!isValid(options)) {
callback({
Expand Down

0 comments on commit 2a6a51f

Please sign in to comment.