From 8bc7e8a28ffd65f711a1da974f7ab696c662c4b5 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Mon, 8 Jan 2018 15:18:43 -0800 Subject: [PATCH] Update protocol client installation --- src/protocol-handler-installer.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/protocol-handler-installer.js b/src/protocol-handler-installer.js index 37df68389..04d212cb4 100644 --- a/src/protocol-handler-installer.js +++ b/src/protocol-handler-installer.js @@ -11,14 +11,24 @@ class ProtocolHandlerInstaller { return ['win32', 'darwin'].includes(process.platform) } - isDefaultProtocolClient () { + isOldDefaultProtocolClient () { return remote.app.isDefaultProtocolClient('atom', process.execPath, ['--uri-handler']) } + isDefaultProtocolClient () { + return remote.app.isDefaultProtocolClient('atom', process.execPath, ['--uri-handler', '--']) + } + setAsDefaultProtocolClient () { // This Electron API is only available on Windows and macOS. There might be some // hacks to make it work on Linux; see https://github.com/electron/electron/issues/6440 - return this.isSupported() && remote.app.setAsDefaultProtocolClient('atom', process.execPath, ['--uri-handler']) + return this.isSupported() && remote.app.setAsDefaultProtocolClient('atom', process.execPath, ['--uri-handler', '--']) + } + + shouldUpgradeProtocolClient () { + // macOS and Linux ignore the last argument to `app.isDefaultProtocolClient` + // so we only need to upgrade the handler on Windows. + return process.platform === 'win32' && this.isOldDefaultProtocolClient() } initialize (config, notifications) { @@ -26,7 +36,9 @@ class ProtocolHandlerInstaller { return } - if (!this.isDefaultProtocolClient()) { + if (this.shouldUpgradeProtocolClient()) { + this.setAsDefaultProtocolClient() + } else if (!this.isDefaultProtocolClient()) { const behaviorWhenNotProtocolClient = config.get(SETTING) switch (behaviorWhenNotProtocolClient) { case PROMPT: