Skip to content

Commit

Permalink
Use setDisplayMediaRequestHandler instead (#2266)
Browse files Browse the repository at this point in the history
  • Loading branch information
axeleriksson147 authored Jan 22, 2025
1 parent 5606a3e commit 1b83b36
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
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
20 changes: 20 additions & 0 deletions src/app/display-media-request-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { session } from 'electron';

/**
* This is currently supported only on macOS 15+.
* setDisplayMediaRequestHandler injects into navigator.mediaDevices.getDisplayMedia().
* With the macOS-only option { useSystemPicker: true },
* everyting is handled natively by the OS.
*
* For all other OSes and versions, the regular screen share flow will be used.
*/
export const setDisplayMediaRequestHandler = () => {
const { defaultSession } = session;

defaultSession.setDisplayMediaRequestHandler(
async (_request, _callback) => {
// TODO - Add support for Windows.
},
{ useSystemPicker: true },
);
};
2 changes: 2 additions & 0 deletions src/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { cleanUpAppCache, createAppCacheFile } from './app-cache-handler';
import { setChromeFlags, setSessionProperties } from './chrome-flags';
import { config } from './config-handler';
import './dialog-handler';
import { setDisplayMediaRequestHandler } from './display-media-request-handler';
import './main-api-handler';
import { handlePerformanceSettings } from './perf-handler';
import { protocolHandler } from './protocol-handler';
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

0 comments on commit 1b83b36

Please sign in to comment.