[PM-11312] Add "prevent screenshot" setting to windows and mac (#10707)
* Add screenshot protection to windows and mac * Update messaging of screencapture prevention feature * Set default state to false
This commit is contained in:
parent
18ef74930c
commit
1b7bb014d2
|
@ -419,6 +419,23 @@
|
|||
"enableHardwareAccelerationDesc" | i18n
|
||||
}}</small>
|
||||
</div>
|
||||
<div class="form-group" *ngIf="!isLinux">
|
||||
<div class="checkbox">
|
||||
<label for="allowScreenshots">
|
||||
<input
|
||||
id="allowScreenshots"
|
||||
type="checkbox"
|
||||
aria-describedby="allowScreenshotsHelp"
|
||||
formControlName="allowScreenshots"
|
||||
(change)="saveAllowScreenshots()"
|
||||
/>
|
||||
{{ "allowScreenshots" | i18n }}
|
||||
</label>
|
||||
</div>
|
||||
<small id="allowScreenshotsHelp" class="help-block">{{
|
||||
"allowScreenshotsDesc" | i18n
|
||||
}}</small>
|
||||
</div>
|
||||
<div class="form-group" *ngIf="showDuckDuckGoIntegrationOption">
|
||||
<div class="checkbox">
|
||||
<label for="enableDuckDuckGoBrowserIntegration">
|
||||
|
|
|
@ -109,6 +109,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
|||
disabled: true,
|
||||
}),
|
||||
enableHardwareAcceleration: true,
|
||||
allowScreenshots: false,
|
||||
enableDuckDuckGoBrowserIntegration: false,
|
||||
theme: [null as ThemeType | null],
|
||||
locale: [null as string | null],
|
||||
|
@ -277,6 +278,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
|||
enableHardwareAcceleration: await firstValueFrom(
|
||||
this.desktopSettingsService.hardwareAcceleration$,
|
||||
),
|
||||
allowScreenshots: await firstValueFrom(this.desktopSettingsService.allowScreenshots$),
|
||||
theme: await firstValueFrom(this.themeStateService.selectedTheme$),
|
||||
locale: await firstValueFrom(this.i18nService.userSetLocale$),
|
||||
};
|
||||
|
@ -727,6 +729,10 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
|||
);
|
||||
}
|
||||
|
||||
async saveAllowScreenshots() {
|
||||
await this.desktopSettingsService.setAllowScreenshots(this.form.value.allowScreenshots);
|
||||
}
|
||||
|
||||
private async generateVaultTimeoutOptions(): Promise<VaultTimeoutOption[]> {
|
||||
let vaultTimeoutOptions: VaultTimeoutOption[] = [
|
||||
{ name: this.i18nService.t("oneMinute"), value: 1 },
|
||||
|
|
|
@ -3077,6 +3077,12 @@
|
|||
"textSends": {
|
||||
"message": "Text Sends"
|
||||
},
|
||||
"allowScreenshots": {
|
||||
"message": "Allow screen capture"
|
||||
},
|
||||
"allowScreenshotsDesc": {
|
||||
"message": "Allow screen capture of the Bitwarden desktop application."
|
||||
},
|
||||
"ssoError": {
|
||||
"message": "No free ports could be found for the sso login."
|
||||
},
|
||||
|
|
|
@ -69,6 +69,13 @@ export class WindowMain {
|
|||
this.logService.info("Render process reloaded");
|
||||
});
|
||||
|
||||
this.desktopSettingsService.allowScreenshots$.subscribe((allowed) => {
|
||||
if (this.win == null) {
|
||||
return;
|
||||
}
|
||||
this.win.setContentProtection(!allowed);
|
||||
});
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
try {
|
||||
if (!isMacAppStore() && !isSnapStore()) {
|
||||
|
@ -270,6 +277,14 @@ export class WindowMain {
|
|||
});
|
||||
});
|
||||
|
||||
firstValueFrom(this.desktopSettingsService.allowScreenshots$)
|
||||
.then((allowScreenshots) => {
|
||||
this.win.setContentProtection(!allowScreenshots);
|
||||
})
|
||||
.catch((e) => {
|
||||
this.logService.error(e);
|
||||
});
|
||||
|
||||
if (this.createWindowCallback) {
|
||||
this.createWindowCallback(this.win);
|
||||
}
|
||||
|
|
|
@ -71,6 +71,10 @@ const MINIMIZE_ON_COPY = new UserKeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "
|
|||
clearOn: [], // User setting, no need to clear
|
||||
});
|
||||
|
||||
const ALLOW_SCREENSHOTS = new KeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "allowScreenshots", {
|
||||
deserializer: (b) => b,
|
||||
});
|
||||
|
||||
/**
|
||||
* Various settings for controlling application behavior specific to the desktop client.
|
||||
*/
|
||||
|
@ -139,6 +143,13 @@ export class DesktopSettingsService {
|
|||
browserIntegrationFingerprintEnabled$ =
|
||||
this.browserIntegrationFingerprintEnabledState.state$.pipe(map(Boolean));
|
||||
|
||||
private readonly allowScreenshotState = this.stateProvider.getGlobal(ALLOW_SCREENSHOTS);
|
||||
|
||||
/**
|
||||
* The application setting for whether or not to allow screenshots of the app.
|
||||
*/
|
||||
allowScreenshots$ = this.allowScreenshotState.state$.pipe(map(Boolean));
|
||||
|
||||
private readonly minimizeOnCopyState = this.stateProvider.getActive(MINIMIZE_ON_COPY);
|
||||
|
||||
/**
|
||||
|
@ -255,4 +266,12 @@ export class DesktopSettingsService {
|
|||
async setMinimizeOnCopy(value: boolean, userId: UserId) {
|
||||
await this.stateProvider.getUser(userId, MINIMIZE_ON_COPY).update(() => value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the setting for whether or not the screenshot protection is enabled.
|
||||
* @param value `true` if the screenshot protection is enabled, `false` if it is not.
|
||||
*/
|
||||
async setAllowScreenshots(value: boolean) {
|
||||
await this.allowScreenshotState.update(() => value);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue