webkit

package module
v0.0.0-...-04fcbab Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

README

webkit

C bindings to webkit for Go (Golang).

Installation
go get github.com/abcum/webkit
Building

go install -tags 'webkit_2_14' 

go install -tags 'webkit_2_16' 
Requirements
  • Golang >= 1.2
  • GTK+ >= 3.0
  • WebKit2GTK+ >= 2.0.0

Alpine Linux

apk --update install gcc musl-dev gtk+3.0-dev webkit2gtk-dev

Ubuntu 13.10

sudo add-apt-repository ppa:gnome3-team/gnome3-staging
sudo apt-get update
sudo apt-get install libwebkit2gtk-3.0-dev

Ubuntu 13.04

sudo add-apt-repository ppa:gnome3-team/gnome3
sudo apt-get update
sudo apt-get install libwebkit2gtk-3.0-dev

Arch Linux

sudo pacman -S webkitgtk

For WebKit licensing and copyright information, click here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheModel

type CacheModel int

CacheModel describes the caching behavior.

const (
	// DocumentViewerCacheModel disables the cache completely, which substantially reduces memory
	// usage. Useful for applications that only access a single local file, with no navigation to
	// other pages. No remote resources will be cached.
	DocumentViewerCacheModel CacheModel = iota
	// WebBrowserCacheModel improves document load speed substantially by caching a very large number
	// of resources and previously viewed content.
	WebBrowserCacheModel
	// DocumentBrowserCacheModel is a cache model optimized for viewing a series of local files, e.g.
	// a documentation viewer or a website designer. WebKit will cache a moderate number of resources.
	DocumentBrowserCacheModel
)

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context manages aspects common to all WebViews.

func NewContext

func NewContext() *Context

NewContext creates a new WebContext.

func NewDefaultContext

func NewDefaultContext() *Context

NewDefaultContext returns the default WebContext.

func (*Context) ClearCache

func (c *Context) ClearCache()

ClearCache clears all resources currently cached.

func (*Context) GetCacheModel

func (c *Context) GetCacheModel() CacheModel

GetCacheModel returns the current cache model.

func (*Context) GetProcessModel

func (c *Context) GetProcessModel() ProcessModel

GetProcessModel returns the current process model.

func (*Context) GetTLSErrorsPolicy

func (c *Context) GetTLSErrorsPolicy() TLSErrorsPolicy

GetTLSErrorsPolicy returns the current tls errors policy.

func (*Context) SetCacheModel

func (c *Context) SetCacheModel(model CacheModel)

SetCacheModel sets the current cache model.

func (*Context) SetProcessModel

func (c *Context) SetProcessModel(model ProcessModel)

SetProcessModel sets the current process model.

func (*Context) SetTLSErrorsPolicy

func (c *Context) SetTLSErrorsPolicy(policy TLSErrorsPolicy)

SetTLSErrorsPolicy sets the current tls errors policy.

type LoadEvent

type LoadEvent int

LoadEvent denotes the different events that happen during a WebView load operation.

See also: WebKitLoadEvent at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#WebKitLoadEvent.

const (
	LoadStarted LoadEvent = iota
	LoadRedirected
	LoadCommitted
	LoadFinished
)

LoadEvent enum values are described at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#WebKitLoadEvent.

type ProcessModel

type ProcessModel int

ProcessModel describes the process behavior.

const (
	// SharedProcessModel uses a single process to perform content rendering. The process is shared
	// among all the WebKitWebView instances created by the application: if the process hangs or
	// crashes all the web views in the application will be affected. This is the default process
	// model, and it should suffice for most cases.
	SharedProcessModel ProcessModel = iota
	// MultipleProcessModel uses one process for each WebKitWebView, while still allowing for some
	// of them to share a process in certain situations. The main advantage of this process model
	// is that the rendering process for a web view can crash while the rest of the views keep working
	// normally. This process model is indicated for applications which may use a number of web views
	// and the content of in each must not interfere with the rest — for example a full-fledged web
	// browser with support for multiple tabs.
	MultipleProcessModel
)

type Settings

type Settings struct {
	// contains filtered or unexported fields
}

Settings manages the behaviour of a single WebView.

func NewSettings

func NewSettings() *Settings

NewSettings creates a new Settings with default values.

func (*Settings) GetAutoLoadImages

func (s *Settings) GetAutoLoadImages() bool

GetAutoLoadImages gets whether images should be automatically loaded or not. On devices where network bandwidth is of concern, it might be useful to turn this property off.

func (*Settings) GetFrameFlattening

func (s *Settings) GetFrameFlattening() bool

GetFrameFlattening gets whether to enable the frame flattening. With this setting each subframe is expanded to its contents, which will flatten all the frames to become one scrollable page.

func (*Settings) GetHTML5Database

func (s *Settings) GetHTML5Database() bool

GetHTML5Database gets whether to enable HTML5 client-side SQL database support. Client-side SQL database allows web pages to store structured data and be able to use SQL to manipulate that data asynchronously.

func (*Settings) GetJavaAllowed

func (s *Settings) GetJavaAllowed() bool

GetJavaAllowed gets whether or not Java is enabled on the page.

func (*Settings) GetJavascriptAllowed

func (s *Settings) GetJavascriptAllowed() bool

GetJavascriptAllowed gets whether or not JavaScript executes within the page.

func (*Settings) GetOfflineCache

func (s *Settings) GetOfflineCache() bool

GetOfflineCache gets whether HTML5 offline web application cache support is enabled or not. Offline web application cache allows web applications to run even when the user is not connected to the network.

func (*Settings) GetUserAgent

func (s *Settings) GetUserAgent() string

GetUserAgent gets the user-agent string used by WebKit.

func (*Settings) SetAutoLoadImages

func (s *Settings) SetAutoLoadImages(enabled bool)

SetAutoLoadImages sets whether images should be automatically loaded or not. On devices where network bandwidth is of concern, it might be useful to turn this property off.

func (*Settings) SetFrameFlattening

func (s *Settings) SetFrameFlattening(enabled bool)

SetFrameFlattening sets whether to enable the frame flattening. With this setting each subframe is expanded to its contents, which will flatten all the frames to become one scrollable page.

func (*Settings) SetHTML5Database

func (s *Settings) SetHTML5Database(enabled bool)

SetHTML5Database sets whether to enable HTML5 client-side SQL database support. Client-side SQL database allows web pages to store structured data and be able to use SQL to manipulate that data asynchronously.

func (*Settings) SetJavaAllowed

func (s *Settings) SetJavaAllowed(enabled bool)

SetJavaAllowed sets whether or not Java is enabled on the page.

func (*Settings) SetJavascriptAllowed

func (s *Settings) SetJavascriptAllowed(enabled bool)

SetJavascriptAllowed sets whether or not JavaScript executes within the page.

func (*Settings) SetOfflineCache

func (s *Settings) SetOfflineCache(enabled bool)

SetOfflineCache sets whether HTML5 offline web application cache support is enabled or not. Offline web application cache allows web applications to run even when the user is not connected to the network.

func (*Settings) SetUserAgent

func (s *Settings) SetUserAgent(userAgent string)

SetUserAgent sets the user-agent string used by WebKit. Unusual user-agent strings may cause web content to render incorrectly or fail to run, as many web pages are written to parse the user-agent strings of only the most popular browsers. Therefore, it's typically better to not completely override the standard user-agent, but to use SetUserAgentWithApplicationDetails() instead.

func (*Settings) SetUserAgentWithApplicationDetails

func (s *Settings) SetUserAgentWithApplicationDetails(appName, appVersion string)

SetUserAgentWithApplicationDetails sets the “user-agent” property by appending the application details to the default user agent. If no application name or version is given, the default user agent used will be used. If only the version is given, the default engine version is used with the given application name.

type TLSErrorsPolicy

type TLSErrorsPolicy int

TLSErrorsPolicy describes how tls errors are handled.

const (
	// IgnoreTLSErrorsPolicy ignores TLS errors
	IgnoreTLSErrorsPolicy TLSErrorsPolicy = iota
	// FailTLSErrorsPolicy ensures that TLS errors will emit “load-failed-with-tls-errors” and, if
	// the signal is handled, finish the load. In case the signal is not handled, “load-failed” is
	// emitted before the load finishes.
	FailTLSErrorsPolicy
)

type WebView

type WebView struct {
	*gtk.Widget
	// contains filtered or unexported fields
}

WebView represents a WebKit WebView.

func NewWebView

func NewWebView() *WebView

NewWebView creates a new WebView with the default Context.

func NewWebViewWithContext

func NewWebViewWithContext(ctx *Context) *WebView

NewWebViewWithContext creates a new WebView with the given Contect.

func (*WebView) Context

func (v *WebView) Context() *Context

Context returns the current Context of the WebView.

func (*WebView) Destroy

func (v *WebView) Destroy()

Destroy destroys the WebView's corresponding GtkWidget and marks its internal WebKitWebView as nil so that it can't be accidentally reused.

func (*WebView) GetSnapshot

func (v *WebView) GetSnapshot(resultCallback func(result *image.RGBA, err error))

GetSnapshot runs asynchronously, taking a snapshot of the WebView. Upon completion, resultCallback will be called with a copy of the underlying bitmap backing store for the frame, or with an error encountered during execution.

See also: webkit_web_view_get_snapshot at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-get-snapshot

func (*WebView) LoadHtml

func (v *WebView) LoadHtml(content, baseURI string)

LoadHtml loads the given content into the WebView, with a mime-type of "text/html", and sets the base uri of the html content to the specified uri.

func (*WebView) LoadText

func (v *WebView) LoadText(content string)

LoadText loads the given content into the WebView, with a mime-type of "text/plain".

func (*WebView) LoadUri

func (v *WebView) LoadUri(uri string)

LoadUri requests loading of the specified URI string.

func (*WebView) Settings

func (v *WebView) Settings() *Settings

Settings returns the current settings for this WebView.

func (*WebView) Title

func (v *WebView) Title() string

Title returns the current active title of the WebView.

func (*WebView) URI

func (v *WebView) URI() string

URI returns the current active URI of the WebView.

Jump to

Keyboard shortcuts

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