mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 10:43:35 +00:00
[PM-14006] Prevent screenshot setting V2 (#12570)
* Add screenshot protection to windows and mac * Update messaging of screencapture prevention feature * Rename settings key * Default allow screenshots * Update screenshot setting description * Fix typo * Add confirm visible prompt
This commit is contained in:
@@ -3,7 +3,16 @@
|
||||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
||||
import { FormBuilder } from "@angular/forms";
|
||||
import { BehaviorSubject, Observable, Subject, firstValueFrom } from "rxjs";
|
||||
import { concatMap, debounceTime, filter, map, switchMap, takeUntil, tap } from "rxjs/operators";
|
||||
import {
|
||||
concatMap,
|
||||
debounceTime,
|
||||
filter,
|
||||
map,
|
||||
switchMap,
|
||||
takeUntil,
|
||||
tap,
|
||||
timeout,
|
||||
} from "rxjs/operators";
|
||||
|
||||
import { PinServiceAbstraction } from "@bitwarden/auth/common";
|
||||
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
||||
@@ -116,6 +125,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
||||
}),
|
||||
enableHardwareAcceleration: true,
|
||||
enableSshAgent: false,
|
||||
allowScreenshots: false,
|
||||
enableDuckDuckGoBrowserIntegration: false,
|
||||
theme: [null as ThemeType | null],
|
||||
locale: [null as string | null],
|
||||
@@ -287,6 +297,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
||||
this.desktopSettingsService.hardwareAcceleration$,
|
||||
),
|
||||
enableSshAgent: await firstValueFrom(this.desktopSettingsService.sshAgentEnabled$),
|
||||
allowScreenshots: !(await firstValueFrom(this.desktopSettingsService.preventScreenshots$)),
|
||||
theme: await firstValueFrom(this.themeStateService.selectedTheme$),
|
||||
locale: await firstValueFrom(this.i18nService.userSetLocale$),
|
||||
};
|
||||
@@ -769,6 +780,33 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
||||
await this.desktopSettingsService.setSshAgentEnabled(this.form.value.enableSshAgent);
|
||||
}
|
||||
|
||||
async savePreventScreenshots() {
|
||||
await this.desktopSettingsService.setPreventScreenshots(!this.form.value.allowScreenshots);
|
||||
|
||||
if (!this.form.value.allowScreenshots) {
|
||||
const dialogRef = this.dialogService.openSimpleDialogRef({
|
||||
title: { key: "confirmWindowStillVisibleTitle" },
|
||||
content: { key: "confirmWindowStillVisibleContent" },
|
||||
acceptButtonText: { key: "ok" },
|
||||
cancelButtonText: null,
|
||||
type: "info",
|
||||
});
|
||||
let enabled = true;
|
||||
try {
|
||||
enabled = await firstValueFrom(dialogRef.closed.pipe(timeout(10000)));
|
||||
} catch {
|
||||
enabled = false;
|
||||
} finally {
|
||||
dialogRef.close();
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
await this.desktopSettingsService.setPreventScreenshots(false);
|
||||
this.form.controls.allowScreenshots.setValue(true, { emitEvent: false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async generateVaultTimeoutOptions(): Promise<VaultTimeoutOption[]> {
|
||||
let vaultTimeoutOptions: VaultTimeoutOption[] = [
|
||||
{ name: this.i18nService.t("oneMinute"), value: 1 },
|
||||
|
||||
Reference in New Issue
Block a user