Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #16513 from atom/mkt-update-protocol-handler
Browse files Browse the repository at this point in the history
Update protocol client installation
  • Loading branch information
BinaryMuse committed Jan 9, 2018
2 parents 3f710a1 + 8bc7e8a commit bf4635c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/protocol-handler-installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,34 @@ 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) {
if (!this.isSupported()) {
return
}

if (!this.isDefaultProtocolClient()) {
if (this.shouldUpgradeProtocolClient()) {
this.setAsDefaultProtocolClient()
} else if (!this.isDefaultProtocolClient()) {
const behaviorWhenNotProtocolClient = config.get(SETTING)
switch (behaviorWhenNotProtocolClient) {
case PROMPT:
Expand Down

0 comments on commit bf4635c

Please sign in to comment.