1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

auto clear clipboard

This commit is contained in:
Kyle Spearrin
2019-02-27 11:29:31 -05:00
parent fdb822f8b3
commit 940b7c655c
6 changed files with 61 additions and 5 deletions

2
jslib

Submodule jslib updated: 9a4611ec5a...b9267c521d

View File

@@ -30,6 +30,14 @@
{{'options' | i18n}} {{'options' | i18n}}
</div> </div>
<div class="box-content box-content-padded"> <div class="box-content box-content-padded">
<div class="form-group">
<label for="clearClipboard">{{'clearClipboard' | i18n}}</label>
<select id="clearClipboard" name="ClearClipboard" [(ngModel)]="clearClipboard"
(change)="saveClearClipboard()">
<option *ngFor="let o of clearClipboardOptions" [ngValue]="o.value">{{o.name}}</option>
</select>
<small class="help-block">{{'clearClipboardDesc' | i18n}}</small>
</div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
<label for="disableFavicons"> <label for="disableFavicons">

View File

@@ -42,6 +42,8 @@ export class SettingsComponent implements OnInit {
localeOptions: any[]; localeOptions: any[];
theme: string; theme: string;
themeOptions: any[]; themeOptions: any[];
clearClipboard: number;
clearClipboardOptions: any[];
constructor(private analytics: Angulartics2, private toasterService: ToasterService, constructor(private analytics: Angulartics2, private toasterService: ToasterService,
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService, private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
@@ -77,6 +79,16 @@ export class SettingsComponent implements OnInit {
{ name: i18nService.t('dark'), value: 'dark' }, { name: i18nService.t('dark'), value: 'dark' },
{ name: 'Nord', value: 'nord' }, { name: 'Nord', value: 'nord' },
]; ];
this.clearClipboardOptions = [
{ name: i18nService.t('never'), value: null },
{ name: i18nService.t('tenSeconds'), value: 10 },
{ name: i18nService.t('twentySeconds'), value: 20 },
{ name: i18nService.t('thirtySeconds'), value: 30 },
{ name: i18nService.t('oneMinute'), value: 60 },
{ name: i18nService.t('twoMinutes'), value: 120 },
{ name: i18nService.t('fiveMinutes'), value: 300 },
];
} }
async ngOnInit() { async ngOnInit() {
@@ -91,6 +103,7 @@ export class SettingsComponent implements OnInit {
this.startToTray = await this.storageService.get<boolean>(ElectronConstants.enableStartToTrayKey); this.startToTray = await this.storageService.get<boolean>(ElectronConstants.enableStartToTrayKey);
this.locale = await this.storageService.get<string>(ConstantsService.localeKey); this.locale = await this.storageService.get<string>(ConstantsService.localeKey);
this.theme = await this.storageService.get<string>(ConstantsService.themeKey); this.theme = await this.storageService.get<string>(ConstantsService.themeKey);
this.clearClipboard = await this.storageService.get<number>(ConstantsService.clearClipboardKey);
} }
async saveLockOption() { async saveLockOption() {
@@ -184,6 +197,13 @@ export class SettingsComponent implements OnInit {
window.setTimeout(() => window.location.reload(), 200); window.setTimeout(() => window.location.reload(), 200);
} }
async saveClearClipboard() {
await this.storageService.save(ConstantsService.clearClipboardKey, this.clearClipboard);
this.analytics.eventTrack.next({
action: 'Set Clear Clipboard ' + (this.clearClipboard == null ? 'Disabled' : this.clearClipboard),
});
}
private callAnalytics(name: string, enabled: boolean) { private callAnalytics(name: string, enabled: boolean) {
const status = enabled ? 'Enabled' : 'Disabled'; const status = enabled ? 'Enabled' : 'Disabled';
this.analytics.eventTrack.next({ action: `${status} ${name}` }); this.analytics.eventTrack.next({ action: `${status} ${name}` });

View File

@@ -44,6 +44,7 @@ import { SearchService } from 'jslib/abstractions/search.service';
import { SettingsService } from 'jslib/abstractions/settings.service'; import { SettingsService } from 'jslib/abstractions/settings.service';
import { StorageService } from 'jslib/abstractions/storage.service'; import { StorageService } from 'jslib/abstractions/storage.service';
import { SyncService } from 'jslib/abstractions/sync.service'; import { SyncService } from 'jslib/abstractions/sync.service';
import { SystemService } from 'jslib/abstractions/system.service';
import { TokenService } from 'jslib/abstractions/token.service'; import { TokenService } from 'jslib/abstractions/token.service';
import { UserService } from 'jslib/abstractions/user.service'; import { UserService } from 'jslib/abstractions/user.service';
@@ -91,7 +92,7 @@ export class AppComponent implements OnInit {
private cryptoService: CryptoService, private componentFactoryResolver: ComponentFactoryResolver, private cryptoService: CryptoService, private componentFactoryResolver: ComponentFactoryResolver,
private messagingService: MessagingService, private collectionService: CollectionService, private messagingService: MessagingService, private collectionService: CollectionService,
private searchService: SearchService, private notificationsService: NotificationsService, private searchService: SearchService, private notificationsService: NotificationsService,
private platformUtilsService: PlatformUtilsService) { } private platformUtilsService: PlatformUtilsService, private systemService: SystemService) { }
ngOnInit() { ngOnInit() {
this.ngZone.runOutsideAngular(() => { this.ngZone.runOutsideAngular(() => {
@@ -114,12 +115,12 @@ export class AppComponent implements OnInit {
case 'unlocked': case 'unlocked':
this.notificationsService.updateConnection(); this.notificationsService.updateConnection();
this.updateAppMenu(); this.updateAppMenu();
this.lockService.cancelLockReload(); this.systemService.cancelProcessReload();
break; break;
case 'loggedOut': case 'loggedOut':
this.notificationsService.updateConnection(); this.notificationsService.updateConnection();
this.updateAppMenu(); this.updateAppMenu();
this.lockService.startLockReload(); this.systemService.startProcessReload();
break; break;
case 'logout': case 'logout':
this.logOut(!!message.expired); this.logOut(!!message.expired);
@@ -131,7 +132,7 @@ export class AppComponent implements OnInit {
this.router.navigate(['lock']); this.router.navigate(['lock']);
this.notificationsService.updateConnection(); this.notificationsService.updateConnection();
this.updateAppMenu(); this.updateAppMenu();
this.lockService.startLockReload(); this.systemService.startProcessReload();
break; break;
case 'reloadProcess': case 'reloadProcess':
window.location.reload(true); window.location.reload(true);
@@ -171,6 +172,9 @@ export class AppComponent implements OnInit {
properties: { label: message.label }, properties: { label: message.label },
}); });
break; break;
case 'copiedToClipboard':
this.systemService.clearClipboard(message.clipboardValue, message.clearMs);
break;
default: default:
} }
}); });

View File

@@ -42,6 +42,7 @@ import { SearchService } from 'jslib/services/search.service';
import { SettingsService } from 'jslib/services/settings.service'; import { SettingsService } from 'jslib/services/settings.service';
import { StateService } from 'jslib/services/state.service'; import { StateService } from 'jslib/services/state.service';
import { SyncService } from 'jslib/services/sync.service'; import { SyncService } from 'jslib/services/sync.service';
import { SystemService } from 'jslib/services/system.service';
import { TokenService } from 'jslib/services/token.service'; import { TokenService } from 'jslib/services/token.service';
import { TotpService } from 'jslib/services/totp.service'; import { TotpService } from 'jslib/services/totp.service';
import { UserService } from 'jslib/services/user.service'; import { UserService } from 'jslib/services/user.service';
@@ -72,6 +73,7 @@ import { SettingsService as SettingsServiceAbstraction } from 'jslib/abstraction
import { StateService as StateServiceAbstraction } from 'jslib/abstractions/state.service'; import { StateService as StateServiceAbstraction } from 'jslib/abstractions/state.service';
import { StorageService as StorageServiceAbstraction } from 'jslib/abstractions/storage.service'; import { StorageService as StorageServiceAbstraction } from 'jslib/abstractions/storage.service';
import { SyncService as SyncServiceAbstraction } from 'jslib/abstractions/sync.service'; import { SyncService as SyncServiceAbstraction } from 'jslib/abstractions/sync.service';
import { SystemService as SystemServiceAbstraction } from 'jslib/abstractions/system.service';
import { TokenService as TokenServiceAbstraction } from 'jslib/abstractions/token.service'; import { TokenService as TokenServiceAbstraction } from 'jslib/abstractions/token.service';
import { TotpService as TotpServiceAbstraction } from 'jslib/abstractions/totp.service'; import { TotpService as TotpServiceAbstraction } from 'jslib/abstractions/totp.service';
import { UserService as UserServiceAbstraction } from 'jslib/abstractions/user.service'; import { UserService as UserServiceAbstraction } from 'jslib/abstractions/user.service';
@@ -115,6 +117,7 @@ const auditService = new AuditService(cryptoFunctionService, apiService);
const notificationsService = new NotificationsService(userService, syncService, appIdService, const notificationsService = new NotificationsService(userService, syncService, appIdService,
apiService, lockService, async () => messagingService.send('logout', { expired: true })); apiService, lockService, async () => messagingService.send('logout', { expired: true }));
const environmentService = new EnvironmentService(apiService, storageService, notificationsService); const environmentService = new EnvironmentService(apiService, storageService, notificationsService);
const systemService = new SystemService(storageService, lockService, messagingService, platformUtilsService, null);
const analytics = new Analytics(window, () => isDev(), platformUtilsService, storageService, appIdService); const analytics = new Analytics(window, () => isDev(), platformUtilsService, storageService, appIdService);
containerService.attachToGlobal(window); containerService.attachToGlobal(window);
@@ -191,6 +194,7 @@ export function initFactory(): Function {
{ provide: ExportServiceAbstraction, useValue: exportService }, { provide: ExportServiceAbstraction, useValue: exportService },
{ provide: SearchServiceAbstraction, useValue: searchService }, { provide: SearchServiceAbstraction, useValue: searchService },
{ provide: NotificationsServiceAbstraction, useValue: notificationsService }, { provide: NotificationsServiceAbstraction, useValue: notificationsService },
{ provide: SystemServiceAbstraction, useValue: systemService },
{ {
provide: APP_INITIALIZER, provide: APP_INITIALIZER,
useFactory: initFactory, useFactory: initFactory,

View File

@@ -761,9 +761,21 @@
"immediately": { "immediately": {
"message": "Immediately" "message": "Immediately"
}, },
"tenSeconds": {
"message": "10 seconds"
},
"twentySeconds": {
"message": "20 seconds"
},
"thirtySeconds": {
"message": "30 seconds"
},
"oneMinute": { "oneMinute": {
"message": "1 minute" "message": "1 minute"
}, },
"twoMinutes": {
"message": "2 minutes"
},
"fiveMinutes": { "fiveMinutes": {
"message": "5 minutes" "message": "5 minutes"
}, },
@@ -797,6 +809,14 @@
"security": { "security": {
"message": "Security" "message": "Security"
}, },
"clearClipboard": {
"message": "Clear Clipboard",
"description": "Clipboard is the operating system thing where you copy/paste data to on your device."
},
"clearClipboardDesc": {
"message": "Automatically clear copied values from your clipboard.",
"description": "Clipboard is the operating system thing where you copy/paste data to on your device."
},
"disableFavicon": { "disableFavicon": {
"message": "Disable Website Icons" "message": "Disable Website Icons"
}, },