-
Notifications
You must be signed in to change notification settings - Fork 0
/
browsers.go
47 lines (41 loc) · 984 Bytes
/
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
package browsers
/* Saved password */
type Password struct {
OriginUrl, ActionUrl string
Username, UsernameElement string
Password, PasswordElement string
}
type Browser interface {
Name() string
/* Load all saved passwords from browser store */
SavedPasswords() ([]Password, error)
}
var browsers = make(map[string]Browser)
func AddBrowser(b Browser) {
if _, already := browsers[b.Name()]; already {
panic(b)
}
browsers[b.Name()] = b
}
func Browsers() map[string]Browser {
return browsers
}
/* Load all saved passwords from all browsers */
func SavedPasswords() (passwds []Password, errs map[string]error) {
for bname, b := range browsers {
if currentPasswds, err := b.SavedPasswords(); err == nil {
if currentPasswds != nil {
if passwds == nil {
passwds = make([]Password, 0)
}
passwds = append(passwds, currentPasswds...)
}
} else {
if errs == nil {
errs = make(map[string]error)
}
errs[bname] = err
}
}
return
}