chrome

package
v0.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

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

func New(chrome *js.Object) *C

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

func (c *C) Error() 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

func (c *C) OnConnectExternal(callback func(port *js.Object))

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

func (c *C) SendMessage(msg interface{}, callback func(rsp *js.Object))

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

func (c *C) SyncStorage() *Storage

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

func (s *Storage) Delete(keys []string, callback func(err error))

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

func (s *Storage) Get(callback func(data map[string]interface{}, err error))

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

func (s *Storage) Set(data map[string]interface{}, callback func(err error))

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.

Directories

Path Synopsis
Package fakes implements fake implementations of Chrome's extension APIs to ease unit testing.
Package fakes implements fake implementations of Chrome's extension APIs to ease unit testing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL