forked from browserutils/kooky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
container.go
52 lines (44 loc) · 1.18 KB
/
container.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
package firefox
import (
"encoding/json"
"strings"
)
// for the official "Firefox Multi-Account Containers" addon
func (s *CookieStore) initContainersMap() error {
if s.Containers != nil || s.contFile == nil {
return nil
}
conts := &containers{}
err := json.NewDecoder(s.contFile).Decode(conts)
if err != nil {
return err
}
contMap := make(map[int]string)
for _, cont := range conts.Identities {
var name string
if cont.Name != nil {
name = *cont.Name
if strings.HasPrefix(name, `userContextIdInternal.`) {
name = ``
}
}
contMap[cont.UserContextID] = name
}
s.Containers = contMap
return nil
}
type containers struct {
Identities []struct {
AccessKey *string `json:"accessKey,omitempty"`
Color string `json:"color"`
Icon string `json:"icon"`
L10nID *string `json:"l10nID,omitempty"`
Name *string `json:"name,omitempty"`
Public bool `json:"public"`
TelemetryID *int `json:"telemetryId,omitempty"`
UserContextID int `json:"userContextId"`
} `json:"identities"`
LastUserContextID int `json:"lastUserContextId"`
Version int `json:"version"`
}
// TODO names of default container