diff --git a/src/app/services.module.ts b/src/app/services.module.ts index bf841c8c7c..e6733a7cc3 100644 --- a/src/app/services.module.ts +++ b/src/app/services.module.ts @@ -133,7 +133,8 @@ const environmentService = new EnvironmentService(apiService, storageService, no const eventService = new EventService(storageService, apiService, userService, cipherService); const systemService = new SystemService(storageService, vaultTimeoutService, messagingService, platformUtilsService, null); -const nativeMessagingService = new NativeMessagingService(cryptoFunctionService, cryptoService, platformUtilsService, logService, i18nService, userService); +const nativeMessagingService = new NativeMessagingService(cryptoFunctionService, cryptoService, platformUtilsService, + logService, i18nService, userService, messagingService); const analytics = new Analytics(window, () => isDev(), platformUtilsService, storageService, appIdService); containerService.attachToGlobal(window); diff --git a/src/main/messaging.main.ts b/src/main/messaging.main.ts index c7fa60e5ac..d8c1d0f020 100644 --- a/src/main/messaging.main.ts +++ b/src/main/messaging.main.ts @@ -44,6 +44,9 @@ export class MessagingMain { case 'hideToTray': this.main.trayMain.hideToTray(); break; + case 'setFocus': + this.setFocus(); + break; case 'enableBrowserIntegration': this.main.nativeMessagingMain.generateManifests(); this.main.nativeMessagingMain.listen(); @@ -82,4 +85,9 @@ export class MessagingMain { lockNowTrayMenuItem.enabled = isAuthenticated && !isLocked; } } + + private setFocus() { + this.main.trayMain.restoreFromTray(); + this.main.windowMain.win.focusOnWebView(); + } } diff --git a/src/main/nativeMessaging.main.ts b/src/main/nativeMessaging.main.ts index fc11132576..39dfbd492b 100644 --- a/src/main/nativeMessaging.main.ts +++ b/src/main/nativeMessaging.main.ts @@ -25,7 +25,7 @@ export class NativeMessagingMain { if (msg != null) { this.send(msg, socket); } - }) + }); }); ipc.server.on('connect', () => { diff --git a/src/services/nativeMessaging.service.ts b/src/services/nativeMessaging.service.ts index d9af63998d..4b3a5ceddd 100644 --- a/src/services/nativeMessaging.service.ts +++ b/src/services/nativeMessaging.service.ts @@ -3,12 +3,14 @@ import Swal from 'sweetalert2'; import { CryptoService } from 'jslib/abstractions/crypto.service'; import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service'; -import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; +import { I18nService } from 'jslib/abstractions/i18n.service'; import { LogService } from 'jslib/abstractions/log.service'; +import { MessagingService } from 'jslib/abstractions/messaging.service'; +import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; +import { UserService } from 'jslib/abstractions/user.service'; + import { Utils } from 'jslib/misc/utils'; import { SymmetricCryptoKey } from 'jslib/models/domain/symmetricCryptoKey'; -import { I18nService } from 'jslib/abstractions/i18n.service'; -import { UserService } from 'jslib/abstractions/user.service'; const MessageValidTimeout = 10 * 1000; const EncryptionAlgorithm = 'sha1'; @@ -17,7 +19,8 @@ export class NativeMessagingService { private sharedSecret: any; constructor(private cryptoFunctionService: CryptoFunctionService, private cryptoService: CryptoService, - private platformUtilService: PlatformUtilsService, private logService: LogService, private i18nService: I18nService, private userService: UserService) { + private platformUtilService: PlatformUtilsService, private logService: LogService, private i18nService: I18nService, + private userService: UserService, private messagingService: MessagingService) { ipcRenderer.on('nativeMessaging', async (event: any, message: any) => { this.messageHandler(message); }); @@ -30,6 +33,8 @@ export class NativeMessagingService { const remotePublicKey = Utils.fromB64ToArray(rawMessage.publicKey).buffer; const fingerprint = (await this.cryptoService.getFingerprint(await this.userService.getUserId(), remotePublicKey)).join(' '); + this.messagingService.send('setFocus'); + // Await confirmation that fingerprint is correct const submitted = await Swal.fire({ title: this.i18nService.t('verifyBrowserTitle'),