webkit

package
Version: v0.0.0-...-b6ae310 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2015 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CookiePersistentStorageText specifies that the cookies should be saved
	// in a text format.
	CookiePersistentStorageText = C.WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT
	// CookiePersistentStorageSQLite specifies that the cookies should be
	// saves in a SQLite format.
	CookiePersistentStorageSQLite = C.WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE
)
View Source
const (
	FindOptionsNone                          = C.WEBKIT_FIND_OPTIONS_NONE
	FindOptionsCaseInsensitive               = C.WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE
	FindOptionsAtWordStarts                  = C.WEBKIT_FIND_OPTIONS_AT_WORD_STARTS
	FindOptionsTreatMedialCapitalAsWordStart = C.WEBKIT_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START
	FindOptionsBackwards                     = C.WEBKIT_FIND_OPTIONS_BACKWARDS
	FindOptionsWrapAround                    = C.WEBKIT_FIND_OPTIONS_WRAP_AROUND
)
View Source
const (
	// UserContentInjectAllFrames specifies that user content should be
	// injected into all frames.
	UserContentInjectAllFrames = C.WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES
	// UserContentInjectTopFrame specifies that user content should be
	// injected only into the top-level frame.
	UserContentInjectTopFrame = C.WEBKIT_USER_CONTENT_INJECT_TOP_FRAME
)
View Source
const (
	// UserStyleLevelUser specifies that the style is considered dictated by
	// the user, and overrides any other conflicting CSS.
	UserStyleLevelUser = C.WEBKIT_USER_STYLE_LEVEL_USER
	// UserStyleLevelAuthor specifies that the style is considered dictated by
	// the website, and may be overriden by conflicting CSS.
	UserStyleLevelAuthor = C.WEBKIT_USER_STYLE_LEVEL_AUTHOR
)
View Source
const (
	// ProcessModelSharedSecondaryProcess specifies that the web process
	// should be shared between all WebViews.
	ProcessModelSharedSecondaryProcess = C.WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS
	// ProcessModelMultipleSecondaryProcesses specifies that (most) WebViews
	// should run their own web process.
	ProcessModelMultipleSecondaryProcesses = C.WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES
)
View Source
const (
	// CacheModelWebBrowser caches a large amount of previously visited
	// content.
	CacheModelWebBrowser = C.WEBKIT_CACHE_MODEL_WEB_BROWSER
	// CacheModelDocumentBrowser caches a moderate amount of content.
	CacheModelDocumentBrowser = C.WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER
	// CacheModelDocumentViewer completely disables the cache.
	CacheModelDocumentViewer = C.WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER
)

Variables

View Source
var SettingNames []string

SettingNames is a slice of the names of all webkit settings.

Functions

func GetSettingsType

func GetSettingsType(setting string) (reflect.Type, error)

GetSettingsType gets the type of a particular setting.

If the passed setting doesn't exist, an error is returned instead.

Types

type BackForwardList

type BackForwardList struct {
	*glib.Object
}

A BackForwardList is a list of elements to go back or forward in browser history to.

func (*BackForwardList) GetNthItem

func (bfl *BackForwardList) GetNthItem(n int) (*BackForwardListItem, bool)

GetNthItem retrieves the nth item, relative to the current item, from the BFL.

func (*BackForwardList) GetNthItemWeak

func (bfl *BackForwardList) GetNthItemWeak(n int) (*BackForwardListItem, bool)

GetNthItemWeak tries to behave like GetNthItem, but if it fails, tries to find the closest index for which it doesn't.

If there are no specified items in the given direction (or n == 0), false is returned.

Yes this isn't strictly a wrapper function, but it's very useful.

type BackForwardListItem

type BackForwardListItem struct {
	glib.InitiallyUnowned
}

A BackForwardListItem is a single item in a BackForwardList.

type CookieManager

type CookieManager struct {
	*glib.Object
}

CookieManager wraps WebKitCookieManager.

It keeps track or cookie policy.

func (*CookieManager) SetPersistentStorage

func (cm *CookieManager) SetPersistentStorage(
	file string,
	storage C.WebKitCookiePersistentStorage)

SetPersistentStorage sets the file and format in which to store cookies persistently.

type Download

type Download struct {
	*glib.Object
}

A Download is a wrapper around WebKitDownload

It allows the tracking and controlling of downloads.

func (*Download) Cancel

func (d *Download) Cancel()

Cancel cancells the download.

func (*Download) GetDestination

func (d *Download) GetDestination() string

GetDestination gets the target uri for the download.

func (*Download) GetElapsedTime

func (d *Download) GetElapsedTime() time.Duration

GetElapsedTime gets the Duration which has passed since the download started.

func (*Download) GetEstimatedProgress

func (d *Download) GetEstimatedProgress() float64

GetEstimatedProgress gets an estimate for the download progress.

This is given as a fraction, i.e. a float between 0 and 1.

func (*Download) GetReceivedDataLength

func (d *Download) GetReceivedDataLength() int64

GetReceivedDataLength gets the length of the data received in bytes.

func (*Download) GetRequest

func (d *Download) GetRequest() *URIRequest

GetRequest gets the URIRequest associated with this download.

func (*Download) GetResponse

func (d *Download) GetResponse() (*URIResponse, error)

GetResponse gets the uri response to the download request.

Returns an error if the response is not yet available.

func (*Download) GetWebView

func (d *Download) GetWebView() (*WebView, error)

GetWebView gets the web view associated with this download.

func (*Download) SetDestination

func (d *Download) SetDestination(to string)

SetDestination sets the target uri for the download.

Note the word uri - for most purposes you'll need to use the file:/// protocol.

type FindController

type FindController struct {
	*glib.Object
}

func (*FindController) GetOptions

func (fc *FindController) GetOptions() C.guint32

func (*FindController) GetSearchText

func (fc *FindController) GetSearchText() string

func (*FindController) Search

func (fc *FindController) Search(term string, options C.guint32)

func (*FindController) SearchFinish

func (fc *FindController) SearchFinish()

func (*FindController) SearchNext

func (fc *FindController) SearchNext()

func (*FindController) SearchPrevious

func (fc *FindController) SearchPrevious()
type NavigationAction struct {
	// contains filtered or unexported fields
}

A NavigationAction describes the action taken to cause a navigation request.

func (a *NavigationAction) GetModifiers() uint

GetModifiers returns the modifier key mask pressed when the action was made.

func (a *NavigationAction) GetMouseButton() uint

GetMouseButton returns the mouse button used to trigger the action, or 0 if it wasn't triggered by mouse.

func (a *NavigationAction) GetRequest() *URIRequest

GetRequest gets the request associated with the navigation action.

type NavigationPolicyDecision struct {
	*glib.Object
}

A NavigationPolicyDecision is a decision of whether or not to navigate to a page.

func (d *NavigationPolicyDecision) Download()

Download downloads the resource referred to.

func (d *NavigationPolicyDecision) GetNavigationAction() *NavigationAction

GetNavigationAction returns the navigation action causing the navigation.

func (d *NavigationPolicyDecision) Ignore()

Ignore ignores the resource referred to.

func (d *NavigationPolicyDecision) Use()

Use proceeds to navigate to the resource referred to.

type PolicyDecision

type PolicyDecision interface {
	// Download downloads the resource referred to.
	Download()
	// Ignore makes the decision to take no action.
	Ignore()
	// Use makes the decision to go ahead with the suggested action.
	Use()
}

A PolicyDecision is an interface implemented by the various types of policy decisions, and has methods used to make said decisions.

type ResponsePolicyDecision

type ResponsePolicyDecision struct {
	*glib.Object
}

A ResponsePolicyDecision is a decision of whether or not to load a particular resource.

func (*ResponsePolicyDecision) Download

func (d *ResponsePolicyDecision) Download()

Download downloads the resource referred to.

func (*ResponsePolicyDecision) GetResponse

func (d *ResponsePolicyDecision) GetResponse() *URIResponse

GetResponse retrieves the uri response associated with this decision.

func (*ResponsePolicyDecision) Ignore

func (d *ResponsePolicyDecision) Ignore()

Ignore ignores the resource referred to.

func (*ResponsePolicyDecision) Use

func (d *ResponsePolicyDecision) Use()

Use proceeds to navigate to the resource referred to.

type SecurityManager

type SecurityManager struct {
	*glib.Object
}

A SecurityManager is a wrapper around WebKitSecurityManager.

It manages the security level of different URI schemes.

func (*SecurityManager) RegisterURISchemeAsCorsEnabled

func (sm *SecurityManager) RegisterURISchemeAsCorsEnabled(scheme string)

RegisterURISchemeAsCorsEnabled registers the scheme as a CORS enabled scheme.

func (*SecurityManager) RegisterURISchemeAsDisplayIsolated

func (sm *SecurityManager) RegisterURISchemeAsDisplayIsolated(scheme string)

RegisterURISchemeAsDisplayIsolated registers a uri scheme such that only pages on the same scheme can display it.

func (*SecurityManager) RegisterURISchemeAsEmptyDocument

func (sm *SecurityManager) RegisterURISchemeAsEmptyDocument(scheme string)

RegisterURISchemeAsEmptyDocument registers a uri scheme as an empty document scheme.

func (*SecurityManager) RegisterURISchemeAsLocal

func (sm *SecurityManager) RegisterURISchemeAsLocal(scheme string)

RegisterURISchemeAsLocal registers a uri scheme as being local, i.e. non- local pages can't interact with it.

func (*SecurityManager) RegisterURISchemeAsNoAccess

func (sm *SecurityManager) RegisterURISchemeAsNoAccess(scheme string)

RegisterURISchemeAsNoAccess registers a uri scheme to have no access to web pages in other schemes.

func (*SecurityManager) RegisterURISchemeAsSecure

func (sm *SecurityManager) RegisterURISchemeAsSecure(scheme string)

RegisterURISchemeAsSecure silences mixed content warning for this scheme on https sites.

type Settings

type Settings struct {
	*glib.Object
}

Settings are a collection of settings for webkit.

func NewSettings

func NewSettings() *Settings

NewSettings creates a new set of settings, with the default contents.

func (*Settings) Clone

func (s *Settings) Clone() *Settings

Clone clones a set of settings.

func (*Settings) GetBool

func (s *Settings) GetBool(setting string) bool

GetBool gets a single boolean setting.

Type checks are not made, if the setting isn't boolean, the behaviour is undefined.

func (*Settings) GetString

func (s *Settings) GetString(setting string) string

GetString gets a single string setting.

Type checks are not made, if the setting isn't a string, the behaviour is undefined.

func (*Settings) GetUint

func (s *Settings) GetUint(setting string) uint

GetUint gets a single uint setting.

Type checks are not made, if the setting isn't a uint, the behaviour is undefined.

func (*Settings) SetBool

func (s *Settings) SetBool(setting string, to bool)

SetBool sets a single boolean setting.

Type checks are not made, if the setting isn't boolean, this method will panic.

func (*Settings) SetString

func (s *Settings) SetString(setting string, to string)

SetString sets a single string settings.

Type checks are not made, if the setting isn't a string, this method will panic.

func (*Settings) SetUint

func (s *Settings) SetUint(setting string, to uint)

SetUint sets a single uint setting.

Type checks are not made, if the setting isn't a uint, this method will panic.

type URIRequest

type URIRequest struct {
	*glib.Object
}

URIRequest wraps a WebKitURIRequest.

It keeps track of a request for a specific URI.

type URIResponse

type URIResponse struct {
	*glib.Object
}

A URIResponse captures basic information about the response to a web request.

func (*URIResponse) GetMimeType

func (r *URIResponse) GetMimeType() string

GetMimeType retrieves the mime type of the response.

func (*URIResponse) GetURI

func (r *URIResponse) GetURI() string

GetURI gets the uri for which this is the response.

type URISchemeRequest

type URISchemeRequest struct {
	*glib.Object
}

A URISchemeRequest is a wrapper around a WebKitURISchemeRequest.

This is an object passes to registered scheme handlers when a request to that scheme is made. The scheme handler is responsible for completing the request.

func (*URISchemeRequest) Finish

func (r *URISchemeRequest) Finish(data []byte, mimeType string)

Finish completes the request with given data and mimeType.

This method is temporary and should be considered unstable. It will be replaced with a method using a Reader for retrieving data instead of the raw bytes.

func (*URISchemeRequest) FinishError

func (r *URISchemeRequest) FinishError(err error)

FinishError completes the request with an error.

func (*URISchemeRequest) GetPath

func (r *URISchemeRequest) GetPath() string

GetPath retrieves the URI path of the request.

func (*URISchemeRequest) GetScheme

func (r *URISchemeRequest) GetScheme() string

GetScheme retrieves the scheme of the request.

func (*URISchemeRequest) GetURI

func (r *URISchemeRequest) GetURI() string

GetURI retrieves the URI of the request.

type UserContentManager

type UserContentManager struct {
	*glib.Object
}

A UserContentManager is a wrapper around WebKitUserContentManager.

It manages user content (i.e. scripts and style sheets), for WebViews which link to it.

func NewUserContentManager

func NewUserContentManager() (*UserContentManager, error)

NewUserContentManager creates a new (blank) UserContentManager.

func (*UserContentManager) AddStyleSheet

func (ucm *UserContentManager) AddStyleSheet(s *UserStyleSheet)

AddStyleSheet attaches a UserStyleSheet to this UserContentManager.

type UserStyleSheet

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

A UserStyleSheet is a wrapper around WebKitUserStyleSheet.

It represents user-defined CSS rules, which can be applied to a website.

func NewUserStyleSheet

func NewUserStyleSheet(
	source string,
	frames C.WebKitUserContentInjectedFrames,
	level C.WebKitUserStyleLevel,
	whitelist []string,
	blacklist []string) (*UserStyleSheet, error)

NewUserStyleSheet creates a new user style sheet.

It takes the raw CSS source code, one of UserContentInjectAllFrames or UserContentInjectTopFrame; one of UserStyleLevelUser or UserStyleLevelAuthor; and uri white- and blacklists.

Passing nil for the whitelist implies all URIs are whitelisted; passing nil for the blacklist implies no URIs are blacklisted.

func (*UserStyleSheet) Native

func (css *UserStyleSheet) Native() uintptr

Native returns the pointer to the native C object of the style sheet.

type WebContext

type WebContext struct {
	*glib.Object
	// contains filtered or unexported fields
}

A WebContext is a wrapper around WebKitWebContext.

It manages aspects common to all WebViews.

func GetDefaultWebContext

func GetDefaultWebContext() *WebContext

GetDefaultWebContext gets the default web context (i.e. the WebContext used by all WebViews by default).

func (*WebContext) DownloadURI

func (c *WebContext) DownloadURI(uri string) *Download

DownloadURI requests the web context to download the specified URI.

func (*WebContext) GetCookieManager

func (c *WebContext) GetCookieManager() *CookieManager

GetCookieManager retrieves the web context's cookie manager.

func (*WebContext) GetSecurityManager

func (c *WebContext) GetSecurityManager() *SecurityManager

GetSecurityManager retrieves the web context's security manager.

func (*WebContext) RegisterURIScheme

func (c *WebContext) RegisterURIScheme(scheme string,
	callback func(*URISchemeRequest))

RegisterURIScheme registers a custom URI scheme.

func (*WebContext) SetCacheModel

func (c *WebContext) SetCacheModel(to C.WebKitCacheModel)

SetCacheModel sets the cache model to be used.

Should be one of CacheModelWebBrowser, CacheModelDocumentViewer or CacheModelDocumentBrowser

func (*WebContext) SetDiskCacheDirectory

func (c *WebContext) SetDiskCacheDirectory(to string)

SetDiskCacheDirectory sets the directory of the cache on disk.

func (*WebContext) SetFaviconDatabaseDirectory

func (c *WebContext) SetFaviconDatabaseDirectory(path string)

SetFaviconDatabaseDirectory sets the directory for the favicon database.

It also serves to enable said database in the first place.

Passing the empty string indicates using the default directory.

func (*WebContext) SetProcessModel

func (c *WebContext) SetProcessModel(to C.WebKitProcessModel)

SetProcessModel sets the model used for the distribution of web processes for WebViews.

Should be one of ProcessModelSharedSecondaryProcess and ProcessModelMultipleSecondaryProcesses.

func (*WebContext) SetWebExtensionsDirectory

func (c *WebContext) SetWebExtensionsDirectory(to string)

SetWebExtensionsDirectory sets the directory in which web extensions can be found.

type WebView

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

WebView represents a WebKitWebView widget.

func NewWebView

func NewWebView() (*WebView, error)

NewWebView creates and returns a new webkit webview.

func NewWebViewWithUserContentManager

func NewWebViewWithUserContentManager(
	ucm *UserContentManager) (*WebView, error)

NewWebViewWithUserContentManager creates a new WebView, using a specific UserContentManager.

func (*WebView) CanGoBack

func (w *WebView) CanGoBack() bool

CanGoBack checks whether it is possible to currently go back.

func (*WebView) CanGoForward

func (w *WebView) CanGoForward() bool

CanGoForward checks whether it is possible to currently go forward.

func (*WebView) GetBackForwardList

func (w *WebView) GetBackForwardList() *BackForwardList

GetBackForwardList gets the views list of back/forward steps in history.

Note that this call is fairly expensive and takes several conversions. Keep a reference if you use it more often.

func (*WebView) GetEstimatedLoadProgress

func (w *WebView) GetEstimatedLoadProgress() float64

GetEstimatedLoadProgress gets an estimation for the progress of a load operation.

func (*WebView) GetFavicon

func (w *WebView) GetFavicon() (uintptr, error)

GetFavicon retrieves the pointer to the cairo_surface_t of the favicon.

Returns an error if favicon is nil.

func (*WebView) GetFindController

func (w *WebView) GetFindController() *FindController

GetFindController retrieves the find controller used to control searches in this web view.

func (*WebView) GetPageID

func (w *WebView) GetPageID() uint64

GetPageID gets the ID of the web page corresponding to the web view.

func (*WebView) GetSettings

func (w *WebView) GetSettings() *Settings

GetSettings retrieves the settings used for this WebView.

func (*WebView) GetTitle

func (w *WebView) GetTitle() string

GetTitle gets the webviews current title.

func (*WebView) GetURI

func (w *WebView) GetURI() string

GetURI gets the currently displayed URI.

func (*WebView) GoBack

func (w *WebView) GoBack()

GoBack goes back one step in browser history.

func (*WebView) GoForward

func (w *WebView) GoForward()

GoForward goes forward one step in browser history.

func (*WebView) GoToBackForwardListItem

func (w *WebView) GoToBackForwardListItem(i *BackForwardListItem)

GoToBackForwardListItem goes to a specified item in the web views BFL.

func (*WebView) IsLoading

func (w *WebView) IsLoading() bool

IsLoading checks if a WebView is currently loading.

func (*WebView) LoadAlternateHTML

func (w *WebView) LoadAlternateHTML(
	content []byte,
	contentURI, baseURI string)

LoadAlternateHTML loads html into the web view, with a given uri.

baseURI is used to resolve relative paths in the html.

func (*WebView) LoadRequest

func (w *WebView) LoadRequest(req *URIRequest)

LoadRequest loads a specified URI request.

func (*WebView) LoadURI

func (w *WebView) LoadURI(uri string)

LoadURI requests loading of the speicified URI string.

func (*WebView) Reload

func (w *WebView) Reload()

Reload request the WebView to reload.

func (*WebView) ReloadBypassCache

func (w *WebView) ReloadBypassCache()

ReloadBypassCache request the WebView to reload, bypassing the cache..

func (*WebView) SetSettings

func (w *WebView) SetSettings(s *Settings)

SetSettings sets the settings used for this WebView.

Jump to

Keyboard shortcuts

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