Enables sandbox for all windows except main
This commit is contained in:
parent
abb839c24b
commit
e211837bcd
67 changed files with 1190 additions and 615 deletions
68
ts/util/os/shared.ts
Normal file
68
ts/util/os/shared.ts
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Copyright 2018 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import semver from 'semver';
|
||||
|
||||
function createIsPlatform(
|
||||
platform: typeof process.platform,
|
||||
osRelease: string
|
||||
): (minVersion?: string) => boolean {
|
||||
return minVersion => {
|
||||
if (process.platform !== platform) {
|
||||
return false;
|
||||
}
|
||||
if (minVersion === undefined) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return semver.gte(osRelease, minVersion);
|
||||
};
|
||||
}
|
||||
|
||||
export type OSType = {
|
||||
getClassName: () => string;
|
||||
getName: () => string;
|
||||
hasCustomTitleBar: () => boolean;
|
||||
isLinux: (minVersion?: string) => boolean;
|
||||
isMacOS: (minVersion?: string) => boolean;
|
||||
isWindows: (minVersion?: string) => boolean;
|
||||
};
|
||||
|
||||
export function getOSFunctions(osRelease: string): OSType {
|
||||
const isMacOS = createIsPlatform('darwin', osRelease);
|
||||
const isLinux = createIsPlatform('linux', osRelease);
|
||||
const isWindows = createIsPlatform('win32', osRelease);
|
||||
|
||||
// Windows 10 and above
|
||||
const hasCustomTitleBar = (): boolean =>
|
||||
isWindows('10.0.0') || Boolean(process.env.CUSTOM_TITLEBAR);
|
||||
|
||||
const getName = (): string => {
|
||||
if (isMacOS()) {
|
||||
return 'macOS';
|
||||
}
|
||||
if (isWindows()) {
|
||||
return 'Windows';
|
||||
}
|
||||
return 'Linux';
|
||||
};
|
||||
|
||||
const getClassName = (): string => {
|
||||
if (isMacOS()) {
|
||||
return 'os-macos';
|
||||
}
|
||||
if (isWindows()) {
|
||||
return 'os-windows';
|
||||
}
|
||||
return 'os-linux';
|
||||
};
|
||||
|
||||
return {
|
||||
getClassName,
|
||||
getName,
|
||||
hasCustomTitleBar,
|
||||
isLinux,
|
||||
isMacOS,
|
||||
isWindows,
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue