-
Notifications
You must be signed in to change notification settings - Fork 90
/
browsers.go
206 lines (186 loc) · 6.14 KB
/
browsers.go
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
package browser
import (
"errors"
"os/exec"
"runtime"
)
// A browser supported by Granted.
const (
ChromeKey string = "CHROME"
BraveKey string = "BRAVE"
EdgeKey string = "EDGE"
FirefoxKey string = "FIREFOX"
WaterfoxKey string = "WATERFOX"
ChromiumKey string = "CHROMIUM"
SafariKey string = "SAFARI"
StdoutKey string = "STDOUT"
FirefoxStdoutKey string = "FIREFOX_STDOUT"
ArcKey string = "ARC"
FirefoxDevEditionKey string = "FIREFOX_DEV"
CommonFateKey string = "COMMON_FATE"
)
// A few default paths to check for the browser
var ChromePathMac = []string{"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"}
var ChromePathLinux = []string{`/usr/bin/google-chrome`, `/../../mnt/c/Program Files/Google/Chrome/Application/chrome.exe`, `/../../mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`}
var ChromePathWindows = []string{`\Program Files\Google\Chrome\Application\chrome.exe`, `\Program Files (x86)\Google\Chrome\Application\chrome.exe`}
var BravePathMac = []string{"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"}
var BravePathLinux = []string{`/usr/bin/brave-browser`, `/../../mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe`}
var BravePathWindows = []string{`\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe`}
var EdgePathMac = []string{"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"}
var EdgePathLinux = []string{`/usr/bin/edge`, `/../../mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe`}
var EdgePathWindows = []string{`\Program Files (x86)\Microsoft\Edge\Application\msedge.exe`}
var FirefoxPathMac = []string{"/Applications/Firefox.app/Contents/MacOS/firefox"}
var FirefoxPathLinux = []string{`/usr/bin/firefox`, `/../../mnt/c/Program Files/Mozilla Firefox/firefox.exe`}
var FirefoxPathWindows = []string{`\Program Files\Mozilla Firefox\firefox.exe`}
var FirefoxDevPathMac = []string{"/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox"}
var FirefoxDevPathLinux = []string{`/usr/bin/firefox-developer`, `/../../mnt/c/Program Files/Firefox Developer Edition/firefox.exe`}
var FirefoxDevPathWindows = []string{`\Program Files\Firefox Developer Edition\firefox.exe`}
var WaterfoxPathMac = []string{"/Applications/Waterfox.app/Contents/MacOS/waterfox"}
var WaterfoxPathLinux = []string{`/usr/bin/waterfox`, `/../../mnt/c/Program Files/Waterfox/waterfox.exe`}
var WaterfoxPathWindows = []string{`\Program Files\Waterfox\waterfox.exe`}
var ChromiumPathMac = []string{"/Applications/Chromium.app/Contents/MacOS/Chromium"}
var ChromiumPathLinux = []string{`/usr/bin/chromium`, `/../../mnt/c/Program Files/Chromium/chromium.exe`}
var ChromiumPathWindows = []string{`\Program Files\Chromium\chromium.exe`}
var SafariPathMac = []string{"/Applications/Safari.app/Contents/MacOS/Safari"}
var ArcPathMac = []string{"/Applications/Arc.app/Contents/MacOS/Arc"}
func ChromePathDefaults() ([]string, error) {
// check linuxpath for binary install
path, err := exec.LookPath("google-chrome-stable")
if err != nil {
path, err = exec.LookPath("google-chrome")
if err == nil {
return []string{path}, nil
}
}
if err == nil {
return []string{path}, nil
}
switch runtime.GOOS {
case "windows":
return ChromePathWindows, nil
case "darwin":
return ChromePathMac, nil
case "linux":
return ChromePathLinux, nil
default:
return nil, errors.New("os not supported")
}
}
func BravePathDefaults() ([]string, error) {
// check linuxpath for binary install
path, err := exec.LookPath("brave")
if err == nil {
return []string{path}, nil
}
switch runtime.GOOS {
case "windows":
return BravePathWindows, nil
case "darwin":
return BravePathMac, nil
case "linux":
return BravePathLinux, nil
default:
return nil, errors.New("os not supported")
}
}
func EdgePathDefaults() ([]string, error) {
// check linuxpath for binary install
path, err := exec.LookPath("edge")
if err == nil {
return []string{path}, nil
}
switch runtime.GOOS {
case "windows":
return EdgePathWindows, nil
case "darwin":
return EdgePathMac, nil
case "linux":
return EdgePathLinux, nil
default:
return nil, errors.New("os not supported")
}
}
func FirefoxPathDefaults() ([]string, error) {
// check linuxpath for binary install
path, err := exec.LookPath("firefox")
if err == nil {
return []string{path}, nil
}
switch runtime.GOOS {
case "windows":
return FirefoxPathWindows, nil
case "darwin":
return FirefoxPathMac, nil
case "linux":
return FirefoxPathLinux, nil
default:
return nil, errors.New("os not supported")
}
}
func FirefoxDevPathDefaults() ([]string, error) {
// check linuxpath for binary install
path, err := exec.LookPath("firefox-developer")
if err == nil {
return []string{path}, nil
}
switch runtime.GOOS {
case "windows":
return FirefoxDevPathWindows, nil
case "darwin":
return FirefoxDevPathMac, nil
case "linux":
return FirefoxDevPathLinux, nil
default:
return nil, errors.New("os not supported")
}
}
func WaterfoxPathDefaults() ([]string, error) {
// check linuxpath for binary install
path, err := exec.LookPath("waterfox")
if err == nil {
return []string{path}, nil
}
switch runtime.GOOS {
case "windows":
return WaterfoxPathWindows, nil
case "darwin":
return WaterfoxPathMac, nil
case "linux":
return WaterfoxPathLinux, nil
default:
return nil, errors.New("os not supported")
}
}
func ChromiumPathDefaults() ([]string, error) {
// check linuxpath for binary install
path, err := exec.LookPath("chromium")
if err == nil {
return []string{path}, nil
}
switch runtime.GOOS {
case "windows":
return ChromiumPathWindows, nil
case "darwin":
return ChromiumPathMac, nil
case "linux":
return ChromiumPathLinux, nil
default:
return nil, errors.New("os not supported")
}
}
func SafariPathDefaults() ([]string, error) {
switch runtime.GOOS {
case "darwin":
return SafariPathMac, nil
default:
return nil, errors.New("os not supported")
}
}
func ArcPathDefaults() ([]string, error) {
switch runtime.GOOS {
case "darwin":
return ArcPathMac, nil
default:
return nil, errors.New("os not supported")
}
}