From 3bfe5e4a65ab643813127b1bf32ec12468a05009 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Mon, 9 Dec 2024 02:09:57 -0800 Subject: [PATCH] [PM-13099] Enable browserintegration on dmg builds on adding an env variable (#11359) * Enable browserintegration on dmg builds on adding an env variable * Fix crash * Cleanup --- .../src/app/accounts/settings.component.ts | 76 ++++++++++--------- apps/desktop/src/platform/preload.ts | 11 ++- apps/desktop/src/utils.ts | 10 +++ 3 files changed, 62 insertions(+), 35 deletions(-) diff --git a/apps/desktop/src/app/accounts/settings.component.ts b/apps/desktop/src/app/accounts/settings.component.ts index a8ce45f53c7..387e6823f31 100644 --- a/apps/desktop/src/app/accounts/settings.component.ts +++ b/apps/desktop/src/app/accounts/settings.component.ts @@ -632,43 +632,51 @@ export class SettingsComponent implements OnInit, OnDestroy { } async saveBrowserIntegration() { - if ( - ipc.platform.deviceType === DeviceType.MacOsDesktop && - !this.platformUtilsService.isMacAppStore() && - !ipc.platform.isDev - ) { - await this.dialogService.openSimpleDialog({ - title: { key: "browserIntegrationUnsupportedTitle" }, - content: { key: "browserIntegrationMasOnlyDesc" }, - acceptButtonText: { key: "ok" }, - cancelButtonText: null, - type: "warning", - }); + const skipSupportedPlatformCheck = + ipc.platform.allowBrowserintegrationOverride || ipc.platform.isDev; - this.form.controls.enableBrowserIntegration.setValue(false); - return; - } else if (ipc.platform.isWindowsStore) { - await this.dialogService.openSimpleDialog({ - title: { key: "browserIntegrationUnsupportedTitle" }, - content: { key: "browserIntegrationWindowsStoreDesc" }, - acceptButtonText: { key: "ok" }, - cancelButtonText: null, - type: "warning", - }); + if (skipSupportedPlatformCheck) { + if ( + ipc.platform.deviceType === DeviceType.MacOsDesktop && + !this.platformUtilsService.isMacAppStore() + ) { + await this.dialogService.openSimpleDialog({ + title: { key: "browserIntegrationUnsupportedTitle" }, + content: { key: "browserIntegrationMasOnlyDesc" }, + acceptButtonText: { key: "ok" }, + cancelButtonText: null, + type: "warning", + }); - this.form.controls.enableBrowserIntegration.setValue(false); - return; - } else if (ipc.platform.isSnapStore || ipc.platform.isFlatpak) { - await this.dialogService.openSimpleDialog({ - title: { key: "browserIntegrationUnsupportedTitle" }, - content: { key: "browserIntegrationLinuxDesc" }, - acceptButtonText: { key: "ok" }, - cancelButtonText: null, - type: "warning", - }); + this.form.controls.enableBrowserIntegration.setValue(false); + return; + } - this.form.controls.enableBrowserIntegration.setValue(false); - return; + if (ipc.platform.isWindowsStore) { + await this.dialogService.openSimpleDialog({ + title: { key: "browserIntegrationUnsupportedTitle" }, + content: { key: "browserIntegrationWindowsStoreDesc" }, + acceptButtonText: { key: "ok" }, + cancelButtonText: null, + type: "warning", + }); + + this.form.controls.enableBrowserIntegration.setValue(false); + return; + } + + if (ipc.platform.isSnapStore || ipc.platform.isFlatpak) { + await this.dialogService.openSimpleDialog({ + title: { key: "browserIntegrationUnsupportedTitle" }, + content: { key: "browserIntegrationLinuxDesc" }, + acceptButtonText: { key: "ok" }, + cancelButtonText: null, + type: "warning", + }); + + this.form.controls.enableBrowserIntegration.setValue(false); + return; + } } await this.desktopSettingsService.setBrowserIntegrationEnabled( diff --git a/apps/desktop/src/platform/preload.ts b/apps/desktop/src/platform/preload.ts index 30e248d352c..0b61d894776 100644 --- a/apps/desktop/src/platform/preload.ts +++ b/apps/desktop/src/platform/preload.ts @@ -11,7 +11,15 @@ import { Message, UnencryptedMessageResponse, } from "../models/native-messaging"; -import { isAppImage, isDev, isFlatpak, isMacAppStore, isSnapStore, isWindowsStore } from "../utils"; +import { + allowBrowserintegrationOverride, + isAppImage, + isDev, + isFlatpak, + isMacAppStore, + isSnapStore, + isWindowsStore, +} from "../utils"; import { ClipboardWriteMessage } from "./types/clipboard"; @@ -140,6 +148,7 @@ export default { isFlatpak: isFlatpak(), isSnapStore: isSnapStore(), isAppImage: isAppImage(), + allowBrowserintegrationOverride: allowBrowserintegrationOverride(), reloadProcess: () => ipcRenderer.send("reload-process"), focusWindow: () => ipcRenderer.send("window-focus"), hideWindow: () => ipcRenderer.send("window-hide"), diff --git a/apps/desktop/src/utils.ts b/apps/desktop/src/utils.ts index 98bdebb0cc3..88feadd6721 100644 --- a/apps/desktop/src/utils.ts +++ b/apps/desktop/src/utils.ts @@ -70,6 +70,16 @@ export function isWindowsPortable() { return isWindows() && process.env.PORTABLE_EXECUTABLE_DIR != null; } +/** + * We block the browser integration on some unsupported platforms, which also + * blocks partially supported platforms (mac .dmg in dev builds) / prevents + * experimenting with the feature for QA. So this env var allows overriding + * the block. + */ +export function allowBrowserintegrationOverride() { + return process.env.ALLOW_BROWSER_INTEGRATION_OVERRIDE === "true"; +} + /** * Sanitize user agent so external resources used by the app can't built data on our users. */