FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
atom/src/protocol-handler-installer.js at master · codrut/atom · GitHub
codrut
/
atom
Public
forked from
atom/atom
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
atom
/
src
/
protocol-handler-installer.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
92 lines (82 loc) · 2.4 KB
Breadcrumbs
atom
/
src
/
protocol-handler-installer.js
Copy path
File metadata and controls
92 lines (82 loc) · 2.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const
{
remote
}
=
require
(
'electron'
)
const
SETTING
=
'core.uriHandlerRegistration'
const
PROMPT
=
'prompt'
const
ALWAYS
=
'always'
const
NEVER
=
'never'
module
.
exports
=
class
ProtocolHandlerInstaller
{
isSupported
(
)
{
return
[
'win32'
,
'darwin'
]
.
includes
(
process
.
platform
)
}
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'
]
)
}
initialize
(
config
,
notifications
)
{
if
(
!
this
.
isSupported
(
)
)
{
return
}
if
(
!
this
.
isDefaultProtocolClient
(
)
)
{
const
behaviorWhenNotProtocolClient
=
config
.
get
(
SETTING
)
switch
(
behaviorWhenNotProtocolClient
)
{
case
PROMPT
:
this
.
promptToBecomeProtocolClient
(
config
,
notifications
)
break
case
ALWAYS
:
this
.
setAsDefaultProtocolClient
(
)
break
case
NEVER
:
default
:
// Do nothing
}
}
}
promptToBecomeProtocolClient
(
config
,
notifications
)
{
let
notification
const
withSetting
=
(
value
,
fn
)
=>
{
return
function
(
)
{
config
.
set
(
SETTING
,
value
)
fn
(
)
}
}
const
accept
=
(
)
=>
{
notification
.
dismiss
(
)
this
.
setAsDefaultProtocolClient
(
)
}
const
decline
=
(
)
=>
{
notification
.
dismiss
(
)
}
notification
=
notifications
.
addInfo
(
'Register as default atom:// URI handler?'
,
{
dismissable
:
true
,
icon
:
'link'
,
description
:
'Atom is not currently set as the defaut handler for atom:// URIs. Would you like Atom to handle '
+
'atom:// URIs?'
,
buttons
:
[
{
text
:
'Yes'
,
className
:
'btn btn-info btn-primary'
,
onDidClick
:
accept
}
,
{
text
:
'Yes, Always'
,
className
:
'btn btn-info'
,
onDidClick
:
withSetting
(
ALWAYS
,
accept
)
}
,
{
text
:
'No'
,
className
:
'btn btn-info'
,
onDidClick
:
decline
}
,
{
text
:
'No, Never'
,
className
:
'btn btn-info'
,
onDidClick
:
withSetting
(
NEVER
,
decline
)
}
]
}
)
}
}
Back
|
FazBrowse Home
|
New Git URL