Documentation
¶
Overview ¶
Package chrome exposes Go versions of Chrome's extension APIs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type C ¶
type C struct {
// contains filtered or unexported fields
}
C provides access to Chrome's extension APIs.
func New ¶
New returns an instance of C that can be used to access Chrome's extension APIs. Set chrome to nil to access the default Chrome API implementation; it should only be overridden for testing.
func (*C) Error ¶
Error returns the error (if any) from the last call. Returns nil if there was no error.
See https://developer.chrome.com/apps/runtime#property-lastError.
func (*C) OnConnectExternal ¶
OnConnectExternal installs a callback that will be invoked when an external connection is received.
See https://developer.chrome.com/apps/runtime#event-onConnectExternal.
func (*C) OnMessage ¶
func (c *C) OnMessage(callback func(header *js.Object, sender *js.Object, sendResponse func(interface{})) bool)
OnMessage installs a callback that will be invoked when the extension receives a message.
See https://developer.chrome.com/apps/runtime#event-onMessage.
func (*C) SendMessage ¶
SendMessage sends a message within our extension. While the underlying Chrome API supports sending a message to another extension, we only expose functionality to send within the same extension.
See https://developer.chrome.com/apps/runtime#method-sendMessage.
func (*C) SyncStorage ¶
SyncStorage returns a Storage object that can be used to to store persistent data that is synchronized with Chrome Sync.
See https://developer.chrome.com/apps/storage#property-sync.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage supports storing and retrieving data using Chrome's Storage API.
func (*Storage) Delete ¶
Delete removes the items from storage with the specified keys. If a key is not found in storage, it will be silently ignored (i.e., no error will be returned). Callback is invoked when complete.
See remove() in https://developer.chrome.com/apps/storage#type-StorageArea.
func (*Storage) Get ¶
Get reads all the data items currently stored. The callback will be invoked when complete, suppliing the items read and indicating any errors. The data suppiled with the callback is a map of key-value pairs, with each representing a distinct item from storage.
See get() in https://developer.chrome.com/apps/storage#type-StorageArea.
func (*Storage) Set ¶
Set stores new data in storage. data is a map of key-value pairs to be stored. If a key already exists, it will be overwritten. Callback will be invoked when complete.
See set() in https://developer.chrome.com/apps/storage#type-StorageArea.