From 0a37ca91fbb729de54735240ad8a11237866e362 Mon Sep 17 00:00:00 2001 From: pengx17 Date: Tue, 1 Apr 2025 01:48:07 +0000 Subject: [PATCH] feat(electron): add allow list for recording apps (#11321) --- .../electron/src/main/recording/allow-list.ts | 43 +++++++++++++++++++ .../electron/src/main/recording/feature.ts | 4 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 packages/frontend/apps/electron/src/main/recording/allow-list.ts diff --git a/packages/frontend/apps/electron/src/main/recording/allow-list.ts b/packages/frontend/apps/electron/src/main/recording/allow-list.ts new file mode 100644 index 0000000000..8d8778f4ca --- /dev/null +++ b/packages/frontend/apps/electron/src/main/recording/allow-list.ts @@ -0,0 +1,43 @@ +// the following apps are sorted by the name in alphabetical order +const appNameKeywords = new Set([ + 'arc', + 'boardmix', + 'brave', + 'chrome', + 'chromium', + 'classin', + 'dia', + 'dingtalk', + 'discord', + 'edge', + 'facetime', + 'feishu', + 'figma', + 'firefox', + 'lark', + 'meet', + 'messenger', + 'opera', + 'qq', + 'safari', + 'skype', + 'slack', + 'telegram', + 'tim', + 'vivaldi', + 'webex', + 'wechat', + 'whatsapp', + 'wire', + 'zen', + 'zoom', +]); + +export function isAppNameAllowed(name: string) { + for (const keyword of appNameKeywords) { + if (name.toLowerCase().includes(keyword.toLowerCase())) { + return true; + } + } + return false; +} diff --git a/packages/frontend/apps/electron/src/main/recording/feature.ts b/packages/frontend/apps/electron/src/main/recording/feature.ts index 810c502c1a..fe06b4b49e 100644 --- a/packages/frontend/apps/electron/src/main/recording/feature.ts +++ b/packages/frontend/apps/electron/src/main/recording/feature.ts @@ -28,6 +28,7 @@ import { import { globalStateStorage } from '../shared-storage/storage'; import { getMainWindow } from '../windows-manager'; import { popupManager } from '../windows-manager/popup'; +import { isAppNameAllowed } from './allow-list'; import { recordingStateMachine } from './state-machine'; import type { AppGroupInfo, @@ -390,7 +391,8 @@ function getAllApps(): TappableAppInfo[] { v !== null && !v.bundleIdentifier.startsWith('com.apple') && !v.bundleIdentifier.startsWith('pro.affine') && - v.processId !== process.pid + v.processId !== process.pid && + isAppNameAllowed(v.name) ); return filteredApps; }