mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Merge pull request #16521 from atom/dg-remove-protocol-handler-if-set-to-never-on-startup
If protocol handler set to never, unregister it on Windows
This commit is contained in:
@@ -59,7 +59,8 @@ module.exports = function (packagedAppPath) {
|
||||
relativePath === path.join('..', 'node_modules', 'tar', 'tar.js') ||
|
||||
relativePath === path.join('..', 'node_modules', 'temp', 'lib', 'temp.js') ||
|
||||
relativePath === path.join('..', 'node_modules', 'tmp', 'lib', 'tmp.js') ||
|
||||
relativePath === path.join('..', 'node_modules', 'tree-sitter', 'index.js')
|
||||
relativePath === path.join('..', 'node_modules', 'tree-sitter', 'index.js') ||
|
||||
relativePath === path.join('..', 'node_modules', 'winreg', 'lib', 'registry.js')
|
||||
)
|
||||
}
|
||||
}).then((snapshotScript) => {
|
||||
|
||||
@@ -11,10 +11,6 @@ class ProtocolHandlerInstaller {
|
||||
return ['win32', 'darwin'].includes(process.platform)
|
||||
}
|
||||
|
||||
isOldDefaultProtocolClient () {
|
||||
return remote.app.isDefaultProtocolClient('atom', process.execPath, ['--uri-handler'])
|
||||
}
|
||||
|
||||
isDefaultProtocolClient () {
|
||||
return remote.app.isDefaultProtocolClient('atom', process.execPath, ['--uri-handler', '--'])
|
||||
}
|
||||
@@ -25,32 +21,33 @@ class ProtocolHandlerInstaller {
|
||||
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.shouldUpgradeProtocolClient()) {
|
||||
this.setAsDefaultProtocolClient()
|
||||
} else if (!this.isDefaultProtocolClient()) {
|
||||
const behaviorWhenNotProtocolClient = config.get(SETTING)
|
||||
switch (behaviorWhenNotProtocolClient) {
|
||||
case PROMPT:
|
||||
const behaviorWhenNotProtocolClient = config.get(SETTING)
|
||||
switch (behaviorWhenNotProtocolClient) {
|
||||
case PROMPT:
|
||||
if (!this.isDefaultProtocolClient()) {
|
||||
this.promptToBecomeProtocolClient(config, notifications)
|
||||
break
|
||||
case ALWAYS:
|
||||
}
|
||||
break
|
||||
case ALWAYS:
|
||||
if (!this.isDefaultProtocolClient()) {
|
||||
this.setAsDefaultProtocolClient()
|
||||
break
|
||||
case NEVER:
|
||||
default:
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
break
|
||||
case NEVER:
|
||||
if (process.platform === 'win32') {
|
||||
// Only win32 supports deregistration
|
||||
const Registry = require('winreg')
|
||||
const commandKey = new Registry({hive: 'HKCR', key: `\\atom`})
|
||||
commandKey.destroy((_err, _val) => { /* no op */ })
|
||||
}
|
||||
break
|
||||
default:
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user