-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathbrowser_action.go
83 lines (65 loc) · 2.61 KB
/
browser_action.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
package chrome
import "github.com/gopherjs/gopherjs/js"
type BrowserAction struct {
o *js.Object
}
/*
* Types
*/
type ColorArray []int
/*
* Methods:
*/
// SetTitle sets the title of the browser action. This shows up in the tooltip.
func (b *BrowserAction) SetTitle(details Object) {
b.o.Call("setTitle", details)
}
// GetTitle gets the title of the browser action.
func (b *BrowserAction) GetTitle(details Object, callback func(result string)) {
b.o.Call("getTitle", details, callback)
}
// SetIcon sets the icon for the browser action. The icon can be specified either as the path to an image
// file or as the pixel data from a canvas element, or as map of either one of those. Either the path
// or the imageData property must be specified.
func (b *BrowserAction) SetIcon(details Object, callback func()) {
b.o.Call("setIcon", details, callback)
}
// SetPopup sets the html document to be opened as a popup when the user clicks on the browser action's icon.
func (b *BrowserAction) SetPopup(details Object) {
b.o.Call("setPopup", details)
}
// GetPopup gets the html document set as the popup for this browser action.
func (b *BrowserAction) GetPopup(details Object, callback func(result string)) {
b.o.Call("getPopup", details, callback)
}
// SetBadgeText sets the badge text for the browser action. The badge is displayed on top of the icon.
func (b *BrowserAction) SetBadgeText(details Object) {
b.o.Call("setBadgeText", details)
}
// getBadgeText gets the badge text of the browser action. If no tab is specified, the non-tab-specific badge text is returned.
func (b *BrowserAction) getBadgeText(details Object, callback func(result string)) {
b.o.Call("getBadgeText", details, callback)
}
// SetBadgeBackgroundColor sets the background color for the badge.
func (b *BrowserAction) SetBadgeBackgroundColor(details Object) {
b.o.Call("setBadgeBackgroundColor", details)
}
// GetBadgeBackgroundColor gets the background color of the browser action.
func (b *BrowserAction) GetBadgeBackgroundColor(details Object, callback func(result ColorArray)) {
b.o.Call("getBadgeBackgroundColor", details, callback)
}
// Enable enables the browser action for a tab. By default, browser actions are enabled.
func (b *BrowserAction) Enable(tabId int) {
b.o.Call("enable", tabId)
}
// Disable disables the browser action for a tab.
func (b *BrowserAction) Disable(tabId int) {
b.o.Call("disable", tabId)
}
/*
* Events
*/
// OnClicked fired when a browser action icon is clicked. This event will not fire if the browser action has a popup.
func (b *BrowserAction) OnClicked(callback func(tab Tab)) {
b.o.Get("onClicked").Call("addListener", callback)
}