webkit

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package webkit provides Go bindings for the WebKit framework.

Integrate web content seamlessly into your app, and customize content interactions to meet your app’s needs.

Use the WebKit framework to integrate richly styled web content into your app’s native content. WebKit offers a full browsing experience for your content, offering a platform-native view and supporting classes to:

WebKit APIs

Safari Support

  • Optimizing Your Website for Safari: Improve your website by optimizing it for Safari.
  • Delivering Video Content for Safari: Improve the performance and appearance of video in your website in Safari.
  • Promoting Apps with Smart App Banners: Create a banner to promote your app on the App Store from a website.

WebDriver

  • macOS WebDriver Commands for Safari 11.1 and earlier: Test your web content using the WebDriver commands supported by Safari 11.1 and earlier.
  • macOS WebDriver Commands for Safari 12 and later: Test your web content using the WebDriver commands supported by Safari 12 and later.
  • About WebDriver for Safari: Enhance testing of your web content using Safari’s enhancements to WebDriver.
  • Testing with WebDriver in Safari: Enable WebDriver and run a test.

Enumerations

  • WKSecurityRestrictionMode

Key Types

  • WKWebView - An object that displays interactive web content, such as for an in-app browser.
  • WKWebExtensionContext - An object that represents the runtime environment for a web extension.
  • WKWebExtension - An object that encapsulates a web extension’s resources that the manifest file defines.
  • WKWebExtensionController - An object that manages a set of loaded extension contexts.
  • WKWebViewConfiguration - A collection of properties that you use to initialize a web view.
  • WKWebExtensionMatchPattern - An object that represents a way to specify groups of URLs.
  • WKWebsiteDataStore - An object that manages cookies, disk and memory caches, and other types of data for a web view.
  • WKUserContentController - An object for managing interactions between JavaScript code and your web view, and for filtering content in your web view.
  • WKWebExtensionAction - An object that encapsulates the properties for an individual web extension action.
  • WKPreferences - An object that encapsulates the standard behaviors to apply to websites.

Code generated from Apple documentation. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var (
	// See: https://developer.apple.com/documentation/WebKit/NSReadAccessURLDocumentOption
	ReadAccessURLDocumentOption appkit.NSAttributedStringDocumentReadingOptionKey
	// WKWebExtensionContextDeniedPermissionMatchPatternsWereRemovedNotification is a notification the system sends whenever a web extension context has newly removed denied permission match patterns.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/deniedPermissionMatchPatternsWereRemovedNotification
	WKWebExtensionContextDeniedPermissionMatchPatternsWereRemovedNotification foundation.NSNotificationName
	// WKWebExtensionContextDeniedPermissionsWereRemovedNotification is a notification the system sends whenever a web extension context has newly removed denied permissions.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/deniedPermissionsWereRemovedNotification
	WKWebExtensionContextDeniedPermissionsWereRemovedNotification foundation.NSNotificationName
	// See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/errorDomain
	WKWebExtensionContextErrorDomain foundation.NSErrorDomain
	// WKWebExtensionContextErrorsDidUpdateNotification is this notification is sent whenever a web extension context has new errors or errors were cleared.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/errorsDidUpdateNotification
	WKWebExtensionContextErrorsDidUpdateNotification foundation.NSNotificationName
	// WKWebExtensionContextGrantedPermissionMatchPatternsWereRemovedNotification is this notification is sent whenever a web extension context has newly removed granted permission match patterns.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/grantedPermissionMatchPatternsWereRemovedNotification
	WKWebExtensionContextGrantedPermissionMatchPatternsWereRemovedNotification foundation.NSNotificationName
	// WKWebExtensionContextGrantedPermissionsWereRemovedNotification is this notification is sent whenever a web extension context has newly removed granted permissions.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/grantedPermissionsWereRemovedNotification
	WKWebExtensionContextGrantedPermissionsWereRemovedNotification foundation.NSNotificationName
	// WKWebExtensionContextPermissionMatchPatternsWereDeniedNotification is this notification is sent whenever a web extension context has newly denied permission match patterns.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/permissionMatchPatternsWereDeniedNotification
	WKWebExtensionContextPermissionMatchPatternsWereDeniedNotification foundation.NSNotificationName
	// WKWebExtensionContextPermissionMatchPatternsWereGrantedNotification is this notification is sent whenever a web extension context has newly granted permission match patterns.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/permissionMatchPatternsWereGrantedNotification
	WKWebExtensionContextPermissionMatchPatternsWereGrantedNotification foundation.NSNotificationName
	// WKWebExtensionContextPermissionsWereDeniedNotification is this notification is sent whenever a web extension context has newly denied permissions.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/permissionsWereDeniedNotification
	WKWebExtensionContextPermissionsWereDeniedNotification foundation.NSNotificationName
	// WKWebExtensionContextPermissionsWereGrantedNotification is this notification is sent whenever a web extension context has newly granted permissions.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/permissionsWereGrantedNotification
	WKWebExtensionContextPermissionsWereGrantedNotification foundation.NSNotificationName
	// WKWebExtensionDataRecordErrorDomain is indicates a [WKWebExtension.DataRecord] error.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebExtension/DataRecord/errorDomain
	WKWebExtensionDataRecordErrorDomain foundation.NSErrorDomain
	// WKWebExtensionErrorDomain is indicates a web extension error.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebExtension/errorDomain
	WKWebExtensionErrorDomain foundation.NSErrorDomain
	// WKWebExtensionMatchPatternErrorDomain is a string that identifies the error domain.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/errorDomain
	WKWebExtensionMatchPatternErrorDomain foundation.NSErrorDomain
	// WKWebExtensionMessagePortErrorDomain is a string that identifies the error domain.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MessagePort/errorDomain
	WKWebExtensionMessagePortErrorDomain foundation.NSErrorDomain
)
View Source
var (
	// WKErrorDomain is string that identifies the WebKit error domain.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKErrorDomain
	WKErrorDomain string
	// WKWebsiteDataTypeCookies is cookies.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeCookies
	WKWebsiteDataTypeCookies string
	// WKWebsiteDataTypeDiskCache is on-disk caches.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeDiskCache
	WKWebsiteDataTypeDiskCache string
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeFetchCache
	WKWebsiteDataTypeFetchCache string
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeFileSystem
	WKWebsiteDataTypeFileSystem string
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeHashSalt
	WKWebsiteDataTypeHashSalt string
	// WKWebsiteDataTypeIndexedDBDatabases is indexedDB databases.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeIndexedDBDatabases
	WKWebsiteDataTypeIndexedDBDatabases string
	// WKWebsiteDataTypeLocalStorage is hTML local storage.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeLocalStorage
	WKWebsiteDataTypeLocalStorage string
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeMediaKeys
	WKWebsiteDataTypeMediaKeys string
	// WKWebsiteDataTypeMemoryCache is in-memory caches.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeMemoryCache
	WKWebsiteDataTypeMemoryCache string
	// WKWebsiteDataTypeOfflineWebApplicationCache is hTML offline web app caches.
	//
	// Deprecated: Deprecated since macOS 26.2. WebApplicationCache is no longer supported
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeOfflineWebApplicationCache
	WKWebsiteDataTypeOfflineWebApplicationCache string
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeScreenTime
	WKWebsiteDataTypeScreenTime string
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeSearchFieldRecentSearches
	WKWebsiteDataTypeSearchFieldRecentSearches string
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeServiceWorkerRegistrations
	WKWebsiteDataTypeServiceWorkerRegistrations string
	// WKWebsiteDataTypeSessionStorage is hTML session storage.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeSessionStorage
	WKWebsiteDataTypeSessionStorage string
	// WKWebsiteDataTypeWebSQLDatabases is webSQL databases.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataTypeWebSQLDatabases
	WKWebsiteDataTypeWebSQLDatabases string
)
View Source
var WKWebExtensionContextNotificationUserInfoKeys struct {
	// MatchPatterns: The corresponding value represents the affected permission match patterns in [WKWebExtensionContext](<doc://com.apple.webkit/documentation/WebKit/WKWebExtensionContext>) notifications.
	MatchPatterns WKWebExtensionContextNotificationUserInfoKey
	// Permissions: The corresponding value represents the affected permissions in [WKWebExtensionContext](<doc://com.apple.webkit/documentation/WebKit/WKWebExtensionContext>) notifications.
	Permissions WKWebExtensionContextNotificationUserInfoKey
}

WKWebExtensionContextNotificationUserInfoKeys provides typed accessors for WKWebExtensionContextNotificationUserInfoKey constants.

View Source
var WKWebExtensionDataTypes struct {
	// Local: Specifies local storage, including `browser.StorageXCUIElementTypeLocal()`.
	Local WKWebExtensionDataType
	// Session: Specifies session storage, including `browser.StorageXCUIElementTypeSession()`.
	Session WKWebExtensionDataType
	// Synchronized: Specifies synchronized storage, including `browser.StorageXCUIElementTypeSync()`.
	Synchronized WKWebExtensionDataType
}

WKWebExtensionDataTypes provides typed accessors for WKWebExtensionDataType constants.

View Source
var WKWebExtensionPermissions struct {
	// ActiveTab: A request indicating that when a person interacts with the extension, the system grants extra permissions for the active tab only.
	ActiveTab WKWebExtensionPermission
	// Alarms: A request for access to the `browser.Alarms()` APIs.
	Alarms WKWebExtensionPermission
	// ClipboardWrite: A request for access to write to the clipboard.
	ClipboardWrite WKWebExtensionPermission
	// ContextMenus: A request for access to the `browser.ContextMenus()` APIs.
	ContextMenus WKWebExtensionPermission
	// Cookies: A request for access to the `browser.Cookies()` APIs.
	Cookies WKWebExtensionPermission
	// DeclarativeNetRequest: A request for access to the `browser.DeclarativeNetRequest()` APIs.
	DeclarativeNetRequest WKWebExtensionPermission
	// DeclarativeNetRequestFeedback: A request for access to the `browser.DeclarativeNetRequest()` APIs with extra information on matched rules.
	DeclarativeNetRequestFeedback WKWebExtensionPermission
	// DeclarativeNetRequestWithHostAccess: A request for access to the `browser.DeclarativeNetRequest()` APIs with the ability to modify or redirect requests.
	DeclarativeNetRequestWithHostAccess WKWebExtensionPermission
	// Menus: A request for access to the `browser.Menus()` APIs.
	Menus WKWebExtensionPermission
	// NativeMessaging: A request for access to send messages to the app extension bundle.
	NativeMessaging WKWebExtensionPermission
	// Scripting: A request for access to the `browser.Scripting()` APIs.
	Scripting WKWebExtensionPermission
	// Storage: A request for access to the `browser.Storage()` APIs.
	Storage WKWebExtensionPermission
	// Tabs: A request for access to extra information on the `browser.Tabs()` APIs.
	Tabs WKWebExtensionPermission
	// UnlimitedStorage: A request for access to an unlimited quota on the `browser.StorageXCUIElementTypeLocal()` APIs.
	UnlimitedStorage WKWebExtensionPermission
	// WebNavigation: A request for access to the `browser.WebNavigation()` APIs.
	WebNavigation WKWebExtensionPermission
	// WebRequest: A request for access to the `browser.WebRequest()` APIs.
	WebRequest WKWebExtensionPermission
}

WKWebExtensionPermissions provides typed accessors for WKWebExtensionPermission constants.

Functions

func NewBoolBlock

func NewBoolBlock(handler BoolHandler) (objc.ID, func())

NewBoolBlock wraps a Go BoolHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [WKNavigationDelegate.WebViewAuthenticationChallengeShouldAllowDeprecatedTLS]
  • [WKNavigationDelegate.WebViewShouldGoToBackForwardListItemWillUseInstantBackCompletionHandler]
  • [WKUIDelegate.WebViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler]

func NewDataBlock

func NewDataBlock(handler DataHandler) (objc.ID, func())

NewDataBlock wraps a Go DataHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewDataErrorBlock

func NewDataErrorBlock(handler DataErrorHandler) (objc.ID, func())

NewDataErrorBlock wraps a Go DataErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewErrorBlock

func NewErrorBlock(handler ErrorHandler) (objc.ID, func())

NewErrorBlock wraps a Go ErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • WKContentRuleListStore.RemoveContentRuleListForIdentifierCompletionHandler
  • WKWebExtensionContext.LoadBackgroundContentWithCompletionHandler
  • [WKWebExtensionControllerDelegate.WebExtensionControllerConnectUsingMessagePortForExtensionContextCompletionHandler]
  • [WKWebExtensionControllerDelegate.WebExtensionControllerOpenOptionsPageForExtensionContextCompletionHandler]
  • [WKWebExtensionControllerDelegate.WebExtensionControllerPresentPopupForActionForExtensionContextCompletionHandler]
  • WKWebExtensionMessagePort.SendMessageCompletionHandler
  • [WKWebExtensionTab.ActivateForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.CloseForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.GoBackForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.GoForwardForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.LoadURLForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.ReloadFromOriginForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.SetMutedForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.SetParentTabForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.SetPinnedForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.SetReaderModeActiveForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.SetSelectedForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.SetZoomFactorForWebExtensionContextCompletionHandler]
  • [WKWebExtensionWindow.CloseForWebExtensionContextCompletionHandler]
  • [WKWebExtensionWindow.FocusForWebExtensionContextCompletionHandler]
  • [WKWebExtensionWindow.SetFrameForWebExtensionContextCompletionHandler]
  • [WKWebExtensionWindow.SetWindowStateForWebExtensionContextCompletionHandler]
  • WKWebView.RestoreDataCompletionHandler
  • [WKWebsiteDataStore.RemoveDataStoreForIdentifierCompletionHandler]
  • WKWebsiteDataStore.RestoreDataCompletionHandler

func NewLocaleErrorBlock

func NewLocaleErrorBlock(handler LocaleErrorHandler) (objc.ID, func())

NewLocaleErrorBlock wraps a Go LocaleErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [WKWebExtensionTab.DetectWebpageLocaleForWebExtensionContextCompletionHandler]

func NewObjectErrorBlock

func NewObjectErrorBlock(handler ObjectErrorHandler) (objc.ID, func())

NewObjectErrorBlock wraps a Go ObjectErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewUIContextMenuConfigurationBlock

func NewUIContextMenuConfigurationBlock(handler UIContextMenuConfigurationHandler) (objc.ID, func())

NewUIContextMenuConfigurationBlock wraps a Go UIContextMenuConfigurationHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [WKUIDelegate.WebViewContextMenuConfigurationForElementCompletionHandler]

func NewURLBlock

func NewURLBlock(handler URLHandler) (objc.ID, func())

NewURLBlock wraps a Go URLHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [WKDownloadDelegate.DownloadDecideDestinationUsingResponseSuggestedFilenameCompletionHandler]
  • [WKDownloadDelegate.DownloadDecidePlaceholderPolicy]

func NewURLCredentialBlock

func NewURLCredentialBlock(handler URLCredentialHandler) (objc.ID, func())

NewURLCredentialBlock wraps a Go URLCredentialHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [WKDownloadDelegate.DownloadDidReceiveAuthenticationChallengeCompletionHandler]
  • [WKNavigationDelegate.WebViewDidReceiveAuthenticationChallengeCompletionHandler]

func NewWKContentRuleListErrorBlock

func NewWKContentRuleListErrorBlock(handler WKContentRuleListErrorHandler) (objc.ID, func())

NewWKContentRuleListErrorBlock wraps a Go WKContentRuleListErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewWKCookiePolicyBlock

func NewWKCookiePolicyBlock(handler WKCookiePolicyHandler) (objc.ID, func())

NewWKCookiePolicyBlock wraps a Go WKCookiePolicyHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewWKDialogResultBlock

func NewWKDialogResultBlock(handler WKDialogResultHandler) (objc.ID, func())

NewWKDialogResultBlock wraps a Go WKDialogResultHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [WKUIDelegate.WebViewShowLockdownModeFirstUseMessageCompletionHandler]

func NewWKDownloadBlock

func NewWKDownloadBlock(handler WKDownloadHandler) (objc.ID, func())

NewWKDownloadBlock wraps a Go WKDownloadHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewWKDownloadRedirectPolicyBlock

func NewWKDownloadRedirectPolicyBlock(handler WKDownloadRedirectPolicyHandler) (objc.ID, func())

NewWKDownloadRedirectPolicyBlock wraps a Go WKDownloadRedirectPolicyHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [WKDownloadDelegate.DownloadWillPerformHTTPRedirectionNewRequestDecisionHandler]

func NewWKFindResultBlock

func NewWKFindResultBlock(handler WKFindResultHandler) (objc.ID, func())

NewWKFindResultBlock wraps a Go WKFindResultHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewWKMediaPlaybackStateBlock

func NewWKMediaPlaybackStateBlock(handler WKMediaPlaybackStateHandler) (objc.ID, func())

NewWKMediaPlaybackStateBlock wraps a Go WKMediaPlaybackStateHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewWKNavigationActionPolicyBlock

func NewWKNavigationActionPolicyBlock(handler WKNavigationActionPolicyHandler) (objc.ID, func())

NewWKNavigationActionPolicyBlock wraps a Go WKNavigationActionPolicyHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [WKNavigationDelegate.WebViewDecidePolicyForNavigationActionDecisionHandler]

func NewWKNavigationResponsePolicyBlock

func NewWKNavigationResponsePolicyBlock(handler WKNavigationResponsePolicyHandler) (objc.ID, func())

NewWKNavigationResponsePolicyBlock wraps a Go WKNavigationResponsePolicyHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [WKNavigationDelegate.WebViewDecidePolicyForNavigationResponseDecisionHandler]

func NewWKPermissionDecisionBlock

func NewWKPermissionDecisionBlock(handler WKPermissionDecisionHandler) (objc.ID, func())

NewWKPermissionDecisionBlock wraps a Go WKPermissionDecisionHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [WKUIDelegate.WebViewRequestDeviceOrientationAndMotionPermissionForOriginInitiatedByFrameDecisionHandler]
  • [WKUIDelegate.WebViewRequestMediaCapturePermissionForOriginInitiatedByFrameTypeDecisionHandler]

func NewWKWebExtensionDataRecordBlock

func NewWKWebExtensionDataRecordBlock(handler WKWebExtensionDataRecordHandler) (objc.ID, func())

NewWKWebExtensionDataRecordBlock wraps a Go WKWebExtensionDataRecordHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

func NewWKWebExtensionErrorBlock

func NewWKWebExtensionErrorBlock(handler WKWebExtensionErrorHandler) (objc.ID, func())

NewWKWebExtensionErrorBlock wraps a Go WKWebExtensionErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [WKWebExtension.ExtensionWithAppExtensionBundleCompletionHandler]
  • [WKWebExtension.ExtensionWithResourceBaseURLCompletionHandler]

func NewWKWebExtensionTabErrorBlock

func NewWKWebExtensionTabErrorBlock(handler WKWebExtensionTabErrorHandler) (objc.ID, func())

NewWKWebExtensionTabErrorBlock wraps a Go WKWebExtensionTabErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [WKWebExtensionControllerDelegate.WebExtensionControllerOpenNewTabUsingConfigurationForExtensionContextCompletionHandler]
  • [WKWebExtensionTab.DuplicateUsingConfigurationForWebExtensionContextCompletionHandler]

func NewWKWebExtensionWindowErrorBlock

func NewWKWebExtensionWindowErrorBlock(handler WKWebExtensionWindowErrorHandler) (objc.ID, func())

NewWKWebExtensionWindowErrorBlock wraps a Go WKWebExtensionWindowErrorHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [WKWebExtensionControllerDelegate.WebExtensionControllerOpenNewWindowUsingConfigurationForExtensionContextCompletionHandler]

func NewWKWebpagePreferencesBlock

func NewWKWebpagePreferencesBlock(handler WKWebpagePreferencesHandler) (objc.ID, func())

NewWKWebpagePreferencesBlock wraps a Go WKWebpagePreferencesHandler as an Objective-C block. The caller must defer the returned cleanup function.

Used by:

  • [WKNavigationDelegate.WebViewDecidePolicyForNavigationActionPreferencesDecisionHandler]

Types

type BoolHandler

type BoolHandler = func(bool)

BoolHandler handles The completion handler block to execute with the decision.

  • decision: A Boolean value that indicates whether to continue to use a deprecated version of TLS. Specify [true](<doc://com.apple.documentation/documentation/Swift/true>) to continue, or [false](<doc://com.apple.documentation/documentation/Swift/false>) to reject the connection.

Used by:

  • [WKNavigationDelegate.WebViewAuthenticationChallengeShouldAllowDeprecatedTLS]
  • [WKNavigationDelegate.WebViewShouldGoToBackForwardListItemWillUseInstantBackCompletionHandler]
  • [WKUIDelegate.WebViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler]

type DOMEventExceptionCode

type DOMEventExceptionCode uint32

See: https://developer.apple.com/documentation/WebKit/DOMEventExceptionCode

const (
	DOM_UNSPECIFIED_EVENT_TYPE_ERR DOMEventExceptionCode = 0
)

func (DOMEventExceptionCode) String

func (e DOMEventExceptionCode) String() string

type DOMExceptionCode

type DOMExceptionCode uint32

See: https://developer.apple.com/documentation/WebKit/DOMExceptionCode

const (
	DOM_DOMSTRING_SIZE_ERR          DOMExceptionCode = 2
	DOM_HIERARCHY_REQUEST_ERR       DOMExceptionCode = 3
	DOM_INDEX_SIZE_ERR              DOMExceptionCode = 1
	DOM_INUSE_ATTRIBUTE_ERR         DOMExceptionCode = 10
	DOM_INVALID_ACCESS_ERR          DOMExceptionCode = 15
	DOM_INVALID_CHARACTER_ERR       DOMExceptionCode = 5
	DOM_INVALID_MODIFICATION_ERR    DOMExceptionCode = 13
	DOM_INVALID_STATE_ERR           DOMExceptionCode = 11
	DOM_NAMESPACE_ERR               DOMExceptionCode = 14
	DOM_NOT_FOUND_ERR               DOMExceptionCode = 8
	DOM_NOT_SUPPORTED_ERR           DOMExceptionCode = 9
	DOM_NO_DATA_ALLOWED_ERR         DOMExceptionCode = 6
	DOM_NO_MODIFICATION_ALLOWED_ERR DOMExceptionCode = 7
	DOM_SYNTAX_ERR                  DOMExceptionCode = 12
	DOM_WRONG_DOCUMENT_ERR          DOMExceptionCode = 4
)

func (DOMExceptionCode) String

func (e DOMExceptionCode) String() string

type DOMRangeExceptionCode

type DOMRangeExceptionCode uint32

See: https://developer.apple.com/documentation/WebKit/DOMRangeExceptionCode

const (
	DOM_BAD_BOUNDARYPOINTS_ERR DOMRangeExceptionCode = 1
	DOM_INVALID_NODE_TYPE_ERR  DOMRangeExceptionCode = 2
)

func (DOMRangeExceptionCode) String

func (e DOMRangeExceptionCode) String() string

type DOMXPathExceptionCode

type DOMXPathExceptionCode uint32

See: https://developer.apple.com/documentation/WebKit/DOMXPathExceptionCode

const (
	DOM_INVALID_EXPRESSION_ERR DOMXPathExceptionCode = 51
	DOM_TYPE_ERR               DOMXPathExceptionCode = 52
)

func (DOMXPathExceptionCode) String

func (e DOMXPathExceptionCode) String() string

type DataErrorHandler

type DataErrorHandler = func(*foundation.NSData, error)

DataErrorHandler handles The completion handler to call when the data is ready.

  • pdfDocumentData: A data object that contains the PDF data to use for rendering the contents of the web view.
  • error: An error object if a problem occurred, or `nil` on success.

The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.

Used by:

type DataHandler

type DataHandler = func(*foundation.NSData)

DataHandler handles A closure you provide to capture and store data so that you can resume the download later.

Used by:

type Dom

type Dom uint
const (
	DOM_ADDITION                                  Dom = 2
	DOM_ANY_TYPE                                  Dom = 0
	DOM_ANY_UNORDERED_NODE_TYPE                   Dom = 8
	DOM_ATTRIBUTE_NODE                            Dom = 2
	DOM_AT_TARGET                                 Dom = 2
	DOM_BOOLEAN_TYPE                              Dom = 3
	DOM_BOTH                                      Dom = 2
	DOM_BUBBLING_PHASE                            Dom = 3
	DOM_CAPTURING_PHASE                           Dom = 1
	DOM_CDATA_SECTION_NODE                        Dom = 4
	DOM_CHARSET_RULE                              Dom = 2
	DOM_COMMENT_NODE                              Dom = 8
	DOM_DOCUMENT_FRAGMENT_NODE                    Dom = 11
	DOM_DOCUMENT_NODE                             Dom = 9
	DOM_DOCUMENT_POSITION_CONTAINED_BY            Dom = 16
	DOM_DOCUMENT_POSITION_CONTAINS                Dom = 8
	DOM_DOCUMENT_POSITION_DISCONNECTED            Dom = 1
	DOM_DOCUMENT_POSITION_FOLLOWING               Dom = 4
	DOM_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC Dom = 32
	DOM_DOCUMENT_POSITION_PRECEDING               Dom = 2
	DOM_DOCUMENT_TYPE_NODE                        Dom = 10
	DOM_ELEMENT_NODE                              Dom = 1
	DOM_END_TO_END                                Dom = 2
	DOM_END_TO_START                              Dom = 3
	DOM_ENTITY_NODE                               Dom = 6
	DOM_ENTITY_REFERENCE_NODE                     Dom = 5
	DOM_FILTER_ACCEPT                             Dom = 1
	DOM_FILTER_REJECT                             Dom = 2
	DOM_FILTER_SKIP                               Dom = 3
	DOM_FIRST_ORDERED_NODE_TYPE                   Dom = 9
	DOM_FONT_FACE_RULE                            Dom = 5
	DOM_HORIZONTAL                                Dom = 0
	DOM_IMPORT_RULE                               Dom = 3
	DOM_KEYFRAMES_RULE                            Dom = 7
	DOM_KEYFRAME_RULE                             Dom = 8
	DOM_MEDIA_RULE                                Dom = 4
	DOM_MODIFICATION                              Dom = 1
	DOM_NAMESPACE_RULE                            Dom = 10
	DOM_NODE_AFTER                                Dom = 1
	DOM_NODE_BEFORE                               Dom = 0
	DOM_NODE_BEFORE_AND_AFTER                     Dom = 2
	DOM_NODE_INSIDE                               Dom = 3
	DOM_NONE                                      Dom = 0
	DOM_NOTATION_NODE                             Dom = 12
	DOM_NUMBER_TYPE                               Dom = 1
	DOM_ORDERED_NODE_ITERATOR_TYPE                Dom = 5
	DOM_ORDERED_NODE_SNAPSHOT_TYPE                Dom = 7
	DOM_PAGE_RULE                                 Dom = 6
	DOM_PROCESSING_INSTRUCTION_NODE               Dom = 7
	DOM_REMOVAL                                   Dom = 3
	DOM_SHOW_ALL                                  Dom = 4294967295
	DOM_SHOW_ATTRIBUTE                            Dom = 2
	DOM_SHOW_CDATA_SECTION                        Dom = 8
	DOM_SHOW_COMMENT                              Dom = 128
	DOM_SHOW_DOCUMENT                             Dom = 256
	DOM_SHOW_DOCUMENT_FRAGMENT                    Dom = 1024
	DOM_SHOW_DOCUMENT_TYPE                        Dom = 512
	DOM_SHOW_ELEMENT                              Dom = 1
	DOM_SHOW_ENTITY                               Dom = 32
	DOM_SHOW_ENTITY_REFERENCE                     Dom = 16
	DOM_SHOW_NOTATION                             Dom = 2048
	DOM_SHOW_PROCESSING_INSTRUCTION               Dom = 64
	DOM_SHOW_TEXT                                 Dom = 4
	DOM_START_TO_END                              Dom = 1
	DOM_START_TO_START                            Dom = 0
	DOM_STRING_TYPE                               Dom = 2
	DOM_STYLE_RULE                                Dom = 1
	DOM_SUPPORTS_RULE                             Dom = 12
	DOM_TEXT_NODE                                 Dom = 3
	DOM_UNKNOWN_RULE                              Dom = 0
	DOM_UNORDERED_NODE_ITERATOR_TYPE              Dom = 4
	DOM_UNORDERED_NODE_SNAPSHOT_TYPE              Dom = 6
	DOM_VERTICAL                                  Dom = 1
	DOM_WEBKIT_KEYFRAMES_RULE                     Dom = 7
	DOM_WEBKIT_KEYFRAME_RULE                      Dom = 8
	DOM_WEBKIT_REGION_RULE                        Dom = 16
)

func (Dom) String

func (e Dom) String() string

type DomAllowKeyboard

type DomAllowKeyboard uint
const (
	DOM_ALLOW_KEYBOARD_INPUT DomAllowKeyboard = 1
)

func (DomAllowKeyboard) String

func (e DomAllowKeyboard) String() string

type DomCSS

type DomCSS uint
const (
	DOM_CSS_ATTR            DomCSS = 22
	DOM_CSS_CM              DomCSS = 6
	DOM_CSS_COUNTER         DomCSS = 23
	DOM_CSS_CUSTOM          DomCSS = 3
	DOM_CSS_DEG             DomCSS = 11
	DOM_CSS_DIMENSION       DomCSS = 18
	DOM_CSS_EMS             DomCSS = 3
	DOM_CSS_EXS             DomCSS = 4
	DOM_CSS_GRAD            DomCSS = 13
	DOM_CSS_HZ              DomCSS = 16
	DOM_CSS_IDENT           DomCSS = 21
	DOM_CSS_IN              DomCSS = 8
	DOM_CSS_INHERIT         DomCSS = 0
	DOM_CSS_KHZ             DomCSS = 17
	DOM_CSS_MM              DomCSS = 7
	DOM_CSS_MS              DomCSS = 14
	DOM_CSS_NUMBER          DomCSS = 1
	DOM_CSS_PC              DomCSS = 10
	DOM_CSS_PERCENTAGE      DomCSS = 2
	DOM_CSS_PRIMITIVE_VALUE DomCSS = 1
	DOM_CSS_PT              DomCSS = 9
	DOM_CSS_PX              DomCSS = 5
	DOM_CSS_RAD             DomCSS = 12
	DOM_CSS_RECT            DomCSS = 24
	DOM_CSS_RGBCOLOR        DomCSS = 25
	DOM_CSS_S               DomCSS = 15
	DOM_CSS_STRING          DomCSS = 19
	DOM_CSS_UNKNOWN         DomCSS = 0
	DOM_CSS_URI             DomCSS = 20
	DOM_CSS_VALUE_LIST      DomCSS = 2
	DOM_CSS_VH              DomCSS = 27
	DOM_CSS_VMAX            DomCSS = 29
	DOM_CSS_VMIN            DomCSS = 28
	DOM_CSS_VW              DomCSS = 26
)

func (DomCSS) String

func (e DomCSS) String() string

type DomDomDelta

type DomDomDelta uint
const (
	DOM_DOM_DELTA_LINE  DomDomDelta = 1
	DOM_DOM_DELTA_PAGE  DomDomDelta = 2
	DOM_DOM_DELTA_PIXEL DomDomDelta = 0
)

func (DomDomDelta) String

func (e DomDomDelta) String() string

type DomKeyLocation

type DomKeyLocation uint
const (
	DOM_KEY_LOCATION_LEFT     DomKeyLocation = 1
	DOM_KEY_LOCATION_NUMPAD   DomKeyLocation = 3
	DOM_KEY_LOCATION_RIGHT    DomKeyLocation = 2
	DOM_KEY_LOCATION_STANDARD DomKeyLocation = 0
)

func (DomKeyLocation) String

func (e DomKeyLocation) String() string

type ErrorHandler

type ErrorHandler = func(error)

ErrorHandler handles A completion handler block to call after the removal of the content rule list.

  • error: `nil` on success, or an error object if the store encountered an error when deleting the rule list.

The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.

Used by:

  • WKContentRuleListStore.RemoveContentRuleListForIdentifierCompletionHandler
  • WKWebExtensionContext.LoadBackgroundContentWithCompletionHandler
  • [WKWebExtensionControllerDelegate.WebExtensionControllerConnectUsingMessagePortForExtensionContextCompletionHandler]
  • [WKWebExtensionControllerDelegate.WebExtensionControllerOpenOptionsPageForExtensionContextCompletionHandler]
  • [WKWebExtensionControllerDelegate.WebExtensionControllerPresentPopupForActionForExtensionContextCompletionHandler]
  • WKWebExtensionMessagePort.SendMessageCompletionHandler
  • [WKWebExtensionTab.ActivateForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.CloseForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.GoBackForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.GoForwardForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.LoadURLForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.ReloadFromOriginForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.SetMutedForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.SetParentTabForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.SetPinnedForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.SetReaderModeActiveForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.SetSelectedForWebExtensionContextCompletionHandler]
  • [WKWebExtensionTab.SetZoomFactorForWebExtensionContextCompletionHandler]
  • [WKWebExtensionWindow.CloseForWebExtensionContextCompletionHandler]
  • [WKWebExtensionWindow.FocusForWebExtensionContextCompletionHandler]
  • [WKWebExtensionWindow.SetFrameForWebExtensionContextCompletionHandler]
  • [WKWebExtensionWindow.SetWindowStateForWebExtensionContextCompletionHandler]
  • WKWebView.RestoreDataCompletionHandler
  • [WKWebsiteDataStore.RemoveDataStoreForIdentifierCompletionHandler]
  • WKWebsiteDataStore.RestoreDataCompletionHandler

type IWKBackForwardList

type IWKBackForwardList interface {
	objectivec.IObject

	// The item immediately preceding the current item, if any.
	BackItem() IWKBackForwardListItem
	// The current item.
	CurrentItem() IWKBackForwardListItem
	// The item immediately following the current item, if any.
	ForwardItem() IWKBackForwardListItem

	// Returns the item at the relative offset from the current item.
	ItemAtIndex(index int) IWKBackForwardListItem

	// The array of items that precede the current item.
	BackList() []WKBackForwardListItem
	// The array of items that follow the current item.
	ForwardList() []WKBackForwardListItem

	// The web view’s back-forward list.
	BackForwardList() IWKBackForwardList
	SetBackForwardList(value IWKBackForwardList)
}

An interface definition for the WKBackForwardList class.

Getting the Most Recent Items

  • [IWKBackForwardList.BackItem]: The item immediately preceding the current item, if any.
  • [IWKBackForwardList.CurrentItem]: The current item.
  • [IWKBackForwardList.ForwardItem]: The item immediately following the current item, if any.

Getting Specific Items in the List

  • [IWKBackForwardList.ItemAtIndex]: Returns the item at the relative offset from the current item.

Getting Sublists

  • [IWKBackForwardList.BackList]: The array of items that precede the current item.
  • [IWKBackForwardList.ForwardList]: The array of items that follow the current item.

See: https://developer.apple.com/documentation/WebKit/WKBackForwardList

type IWKBackForwardListItem

type IWKBackForwardListItem interface {
	objectivec.IObject

	// The title of the webpage this item represents.
	Title() string
	// The URL of the webpage this item represents.
	URL() foundation.INSURL

	// The source URL that originally asked the web view to load this page.
	InitialURL() foundation.INSURL
}

An interface definition for the WKBackForwardListItem class.

Getting the Page-Specific Information

  • [IWKBackForwardListItem.Title]: The title of the webpage this item represents.
  • [IWKBackForwardListItem.URL]: The URL of the webpage this item represents.

Getting the Requesting Page

  • [IWKBackForwardListItem.InitialURL]: The source URL that originally asked the web view to load this page.

See: https://developer.apple.com/documentation/WebKit/WKBackForwardListItem

type IWKContentRuleList

type IWKContentRuleList interface {
	objectivec.IObject

	// The identifier for the rule list.
	Identifier() string
}

An interface definition for the WKContentRuleList class.

Getting the Rules List Identifier

  • [IWKContentRuleList.Identifier]: The identifier for the rule list.

See: https://developer.apple.com/documentation/WebKit/WKContentRuleList

type IWKContentRuleListStore

type IWKContentRuleListStore interface {
	objectivec.IObject

	// Compiles the specified JSON content into a new rule list and adds it to the current data store.
	CompileContentRuleListForIdentifierEncodedContentRuleListCompletionHandler(identifier string, encodedContentRuleList string, completionHandler WKContentRuleListErrorHandler)
	// Removes a rule list from the current data store asynchronously.
	RemoveContentRuleListForIdentifierCompletionHandler(identifier string, completionHandler ErrorHandler)

	// Fetches the identifiers for all rule lists in the store asynchronously.
	GetAvailableContentRuleListIdentifiers(completionHandler VoidHandler)
	// Searches asynchronously for a specific rule list in the data store.
	LookUpContentRuleListForIdentifierCompletionHandler(identifier string, completionHandler WKContentRuleListErrorHandler)
}

An interface definition for the WKContentRuleListStore class.

Creating and Deleting Content Rule Lists

  • [IWKContentRuleListStore.CompileContentRuleListForIdentifierEncodedContentRuleListCompletionHandler]: Compiles the specified JSON content into a new rule list and adds it to the current data store.
  • [IWKContentRuleListStore.RemoveContentRuleListForIdentifierCompletionHandler]: Removes a rule list from the current data store asynchronously.

Accessing the Current Rule Lists

  • [IWKContentRuleListStore.GetAvailableContentRuleListIdentifiers]: Fetches the identifiers for all rule lists in the store asynchronously.
  • [IWKContentRuleListStore.LookUpContentRuleListForIdentifierCompletionHandler]: Searches asynchronously for a specific rule list in the data store.

See: https://developer.apple.com/documentation/WebKit/WKContentRuleListStore

type IWKContentWorld

type IWKContentWorld interface {
	objectivec.IObject

	// The name of a custom content world.
	Name() string
}

An interface definition for the WKContentWorld class.

Retrieving a Custom Content World

  • [IWKContentWorld.Name]: The name of a custom content world.

See: https://developer.apple.com/documentation/WebKit/WKContentWorld

type IWKDownload

type IWKDownload interface {
	objectivec.IObject

	// An object you use to track download progress and handle redirects, authentication challenges, and failures.
	Delegate() WKDownloadDelegate
	SetDelegate(value WKDownloadDelegate)
	// Cancels the download, and optionally captures data so that you can resume the download later.
	Cancel(completionHandler DataHandler)

	// An object that represents the request that initiated the download.
	OriginalRequest() foundation.NSURLRequest
	// The web view where the download initiated.
	WebView() IWKWebView

	UserInitiated() bool
	OriginatingFrame() IWKFrameInfo
}

An interface definition for the WKDownload class.

Managing the download

  • [IWKDownload.Delegate]: An object you use to track download progress and handle redirects, authentication challenges, and failures.
  • [IWKDownload.SetDelegate]
  • [IWKDownload.Cancel]: Cancels the download, and optionally captures data so that you can resume the download later.

Inspecting the download

  • [IWKDownload.OriginalRequest]: An object that represents the request that initiated the download.
  • [IWKDownload.WebView]: The web view where the download initiated.

Instance Properties

  • [IWKDownload.UserInitiated]
  • [IWKDownload.OriginatingFrame]

See: https://developer.apple.com/documentation/WebKit/WKDownload

type IWKFindConfiguration

type IWKFindConfiguration interface {
	objectivec.IObject

	// A Boolean value that indicates the search direction, relative to the current selection.
	Backwards() bool
	SetBackwards(value bool)
	// A Boolean value that indicates whether to consider case when matching the search string.
	CaseSensitive() bool
	SetCaseSensitive(value bool)
	// A Boolean value that indicates whether the search wraps around to the other side of the page.
	Wraps() bool
	SetWraps(value bool)
}

An interface definition for the WKFindConfiguration class.

Configuring the Search Parameters

  • [IWKFindConfiguration.Backwards]: A Boolean value that indicates the search direction, relative to the current selection.
  • [IWKFindConfiguration.SetBackwards]
  • [IWKFindConfiguration.CaseSensitive]: A Boolean value that indicates whether to consider case when matching the search string.
  • [IWKFindConfiguration.SetCaseSensitive]
  • [IWKFindConfiguration.Wraps]: A Boolean value that indicates whether the search wraps around to the other side of the page.
  • [IWKFindConfiguration.SetWraps]

See: https://developer.apple.com/documentation/WebKit/WKFindConfiguration

type IWKFindResult

type IWKFindResult interface {
	objectivec.IObject

	// A Boolean value that indicates whether the web view found a match during the search.
	MatchFound() bool
}

An interface definition for the WKFindResult class.

Getting the Search Result

  • [IWKFindResult.MatchFound]: A Boolean value that indicates whether the web view found a match during the search.

See: https://developer.apple.com/documentation/WebKit/WKFindResult

type IWKFrameInfo

type IWKFrameInfo interface {
	objectivec.IObject

	// A Boolean value indicating whether the frame is the web site’s main frame or a subframe.
	MainFrame() bool
	// The frame’s current request.
	Request() foundation.NSURLRequest
	// The frame’s security origin.
	SecurityOrigin() IWKSecurityOrigin
	// The web view that contains this frame and the containing webpage.
	WebView() IWKWebView
}

An interface definition for the WKFrameInfo class.

Inspecting frame information

  • [IWKFrameInfo.MainFrame]: A Boolean value indicating whether the frame is the web site’s main frame or a subframe.
  • [IWKFrameInfo.Request]: The frame’s current request.
  • [IWKFrameInfo.SecurityOrigin]: The frame’s security origin.
  • [IWKFrameInfo.WebView]: The web view that contains this frame and the containing webpage.

See: https://developer.apple.com/documentation/WebKit/WKFrameInfo

type IWKHTTPCookieStore

type IWKHTTPCookieStore interface {
	objectivec.IObject

	// Adds a cookie to the cookie store.
	SetCookieCompletionHandler(cookie foundation.NSHTTPCookie, completionHandler VoidHandler)
	// Deletes the specified cookie.
	DeleteCookieCompletionHandler(cookie foundation.NSHTTPCookie, completionHandler VoidHandler)

	// Returns a cookie policy that indicates whether the cookie store allows cookie storage.
	GetCookiePolicy(completionHandler WKCookiePolicyHandler)
	// Sets a cookie policy that indicates whether the cookie store allows cookie storage.
	SetCookiePolicyCompletionHandler(policy WKCookiePolicy, completionHandler VoidHandler)

	// Adds an observer to the cookie store.
	AddObserver(observer WKHTTPCookieStoreObserver)
	// Removes an observer from the cookie store.
	RemoveObserver(observer WKHTTPCookieStoreObserver)

	SetCookiesCompletionHandler(cookies []foundation.NSHTTPCookie, completionHandler VoidHandler)

	// The local files WebKit can access when loading content.
	ReadAccessURL() foundation.NSString
}

An interface definition for the WKHTTPCookieStore class.

Managing cookies

  • [IWKHTTPCookieStore.SetCookieCompletionHandler]: Adds a cookie to the cookie store.
  • [IWKHTTPCookieStore.DeleteCookieCompletionHandler]: Deletes the specified cookie.
  • [IWKHTTPCookieStore.GetCookiePolicy]: Returns a cookie policy that indicates whether the cookie store allows cookie storage.
  • [IWKHTTPCookieStore.SetCookiePolicyCompletionHandler]: Sets a cookie policy that indicates whether the cookie store allows cookie storage.
  • [IWKHTTPCookieStore.AddObserver]: Adds an observer to the cookie store.
  • [IWKHTTPCookieStore.RemoveObserver]: Removes an observer from the cookie store.

Instance Methods

  • [IWKHTTPCookieStore.SetCookiesCompletionHandler]

See: https://developer.apple.com/documentation/WebKit/WKHTTPCookieStore

type IWKNavigation

type IWKNavigation interface {
	objectivec.IObject

	// The content mode WebKit uses to load the webpage.
	EffectiveContentMode() WKContentMode
}

An interface definition for the WKNavigation class.

Getting the Content Mode

  • [IWKNavigation.EffectiveContentMode]: The content mode WebKit uses to load the webpage.

See: https://developer.apple.com/documentation/WebKit/WKNavigation

type IWKNavigationAction

type IWKNavigationAction interface {
	objectivec.IObject

	// The type of action that triggered the navigation.
	NavigationType() WKNavigationType

	// The URL request object associated with the navigation action.
	Request() foundation.NSURLRequest
	// The frame that requested the navigation.
	SourceFrame() IWKFrameInfo
	// The frame in which to display the new content.
	TargetFrame() IWKFrameInfo
	// A Boolean value that indicates whether the web content provided an attribute that indicates a download.
	ShouldPerformDownload() bool

	// The number of the mouse button that caused the navigation request.
	ButtonNumber() objectivec.IObject
	// The modifier keys that were pressed at the time of the navigation request.
	ModifierFlags() objectivec.IObject

	IsContentRuleListRedirect() bool
}

An interface definition for the WKNavigationAction class.

Getting the navigation type

  • [IWKNavigationAction.NavigationType]: The type of action that triggered the navigation.

Inspecting navigation information

  • [IWKNavigationAction.Request]: The URL request object associated with the navigation action.
  • [IWKNavigationAction.SourceFrame]: The frame that requested the navigation.
  • [IWKNavigationAction.TargetFrame]: The frame in which to display the new content.
  • [IWKNavigationAction.ShouldPerformDownload]: A Boolean value that indicates whether the web content provided an attribute that indicates a download.

Inspecting user actions

  • [IWKNavigationAction.ButtonNumber]: The number of the mouse button that caused the navigation request.
  • [IWKNavigationAction.ModifierFlags]: The modifier keys that were pressed at the time of the navigation request.

Instance Properties

  • [IWKNavigationAction.IsContentRuleListRedirect]

See: https://developer.apple.com/documentation/WebKit/WKNavigationAction

type IWKNavigationResponse

type IWKNavigationResponse interface {
	objectivec.IObject

	// The frame’s response.
	Response() foundation.NSURLResponse

	// A Boolean value that indicates whether WebKit is capable of displaying the response’s MIME type natively.
	CanShowMIMEType() bool
	// A Boolean value that indicates whether the response targets the web view’s main frame.
	ForMainFrame() bool
}

An interface definition for the WKNavigationResponse class.

Getting the Response Details

  • [IWKNavigationResponse.Response]: The frame’s response.

Getting Additional Response Information

  • [IWKNavigationResponse.CanShowMIMEType]: A Boolean value that indicates whether WebKit is capable of displaying the response’s MIME type natively.
  • [IWKNavigationResponse.ForMainFrame]: A Boolean value that indicates whether the response targets the web view’s main frame.

See: https://developer.apple.com/documentation/WebKit/WKNavigationResponse

type IWKOpenPanelParameters

type IWKOpenPanelParameters interface {
	objectivec.IObject

	// A Boolean value that indicates whether the file upload control supports multiple files.
	AllowsMultipleSelection() bool
	// A Boolean value that indicates whether the file upload control supports the selection of directories.
	AllowsDirectories() bool
}

An interface definition for the WKOpenPanelParameters class.

Configuring the panel parameters

  • [IWKOpenPanelParameters.AllowsMultipleSelection]: A Boolean value that indicates whether the file upload control supports multiple files.
  • [IWKOpenPanelParameters.AllowsDirectories]: A Boolean value that indicates whether the file upload control supports the selection of directories.

See: https://developer.apple.com/documentation/WebKit/WKOpenPanelParameters

type IWKPDFConfiguration

type IWKPDFConfiguration interface {
	objectivec.IObject

	// A Boolean value that indicates whether the PDF may have a transparent background.
	AllowTransparentBackground() bool
	SetAllowTransparentBackground(value bool)

	// The portion of your web view to capture, specified as a rectangle in the view’s coordinate system.
	Rect() corefoundation.CGRect
	SetRect(value corefoundation.CGRect)
}

An interface definition for the WKPDFConfiguration class.

Specifying snapshot properties

  • [IWKPDFConfiguration.AllowTransparentBackground]: A Boolean value that indicates whether the PDF may have a transparent background.
  • [IWKPDFConfiguration.SetAllowTransparentBackground]

See: https://developer.apple.com/documentation/WebKit/WKPDFConfiguration

type IWKPreferences

type IWKPreferences interface {
	objectivec.IObject

	// The minimum font size, in points.
	MinimumFontSize() float64
	SetMinimumFontSize(value float64)
	// A Boolean value that indicates whether to include any background color or graphics when printing content.
	ShouldPrintBackgrounds() bool
	SetShouldPrintBackgrounds(value bool)

	// A Boolean value that indicates whether pressing the tab key changes the focus to links and form controls.
	TabFocusesLinks() bool
	SetTabFocusesLinks(value bool)
	// A Boolean value that indicates whether to allow people to select or otherwise interact with text.
	TextInteractionEnabled() bool
	SetTextInteractionEnabled(value bool)
	// A Boolean value that indicates whether a web view can display content full screen.
	ElementFullscreenEnabled() bool
	SetElementFullscreenEnabled(value bool)
	// A policy you set to specify how a web view that’s not in a window handles tasks.
	InactiveSchedulingPolicy() WKInactiveSchedulingPolicy
	SetInactiveSchedulingPolicy(value WKInactiveSchedulingPolicy)

	// A Boolean value that indicates whether JavaScript can open windows without user interaction.
	JavaScriptCanOpenWindowsAutomatically() bool
	SetJavaScriptCanOpenWindowsAutomatically(value bool)
	// A Boolean that indicates whether to apply site-specific compatibility workarounds.
	SiteSpecificQuirksModeEnabled() bool
	SetSiteSpecificQuirksModeEnabled(value bool)

	// A Boolean value that indicates whether the web view shows warnings for suspected fraudulent content, such as malware or phishing attemps.
	FraudulentWebsiteWarningEnabled() bool
	SetFraudulentWebsiteWarningEnabled(value bool)

	// The object that manages the preference-related settings for the web view.
	Preferences() IWKPreferences
	SetPreferences(value IWKPreferences)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the WKPreferences class.

Setting Rendering Preferences

  • [IWKPreferences.MinimumFontSize]: The minimum font size, in points.
  • [IWKPreferences.SetMinimumFontSize]
  • [IWKPreferences.ShouldPrintBackgrounds]: A Boolean value that indicates whether to include any background color or graphics when printing content.
  • [IWKPreferences.SetShouldPrintBackgrounds]

Setting Behavior Preferences

  • [IWKPreferences.TabFocusesLinks]: A Boolean value that indicates whether pressing the tab key changes the focus to links and form controls.
  • [IWKPreferences.SetTabFocusesLinks]
  • [IWKPreferences.TextInteractionEnabled]: A Boolean value that indicates whether to allow people to select or otherwise interact with text.
  • [IWKPreferences.SetTextInteractionEnabled]
  • [IWKPreferences.ElementFullscreenEnabled]: A Boolean value that indicates whether a web view can display content full screen.
  • [IWKPreferences.SetElementFullscreenEnabled]
  • [IWKPreferences.InactiveSchedulingPolicy]: A policy you set to specify how a web view that’s not in a window handles tasks.
  • [IWKPreferences.SetInactiveSchedulingPolicy]

Setting Java and JavaScript Preferences

  • [IWKPreferences.JavaScriptCanOpenWindowsAutomatically]: A Boolean value that indicates whether JavaScript can open windows without user interaction.
  • [IWKPreferences.SetJavaScriptCanOpenWindowsAutomatically]
  • [IWKPreferences.SiteSpecificQuirksModeEnabled]: A Boolean that indicates whether to apply site-specific compatibility workarounds.
  • [IWKPreferences.SetSiteSpecificQuirksModeEnabled]

Setting Fraud Warning Preferences

  • [IWKPreferences.FraudulentWebsiteWarningEnabled]: A Boolean value that indicates whether the web view shows warnings for suspected fraudulent content, such as malware or phishing attemps.
  • [IWKPreferences.SetFraudulentWebsiteWarningEnabled]

See: https://developer.apple.com/documentation/WebKit/WKPreferences

type IWKScriptMessage

type IWKScriptMessage interface {
	objectivec.IObject

	// The body of the message.
	Body() objectivec.IObject

	// The frame that sent the message.
	FrameInfo() IWKFrameInfo
	// The web view that sent the message.
	WebView() IWKWebView
	// The namespace in which the JavaScript code executes.
	World() IWKContentWorld

	// The name of the message handler to which the message is sent.
	Name() string
}

An interface definition for the WKScriptMessage class.

Getting the Message Contents

  • [IWKScriptMessage.Body]: The body of the message.
  • [IWKScriptMessage.FrameInfo]: The frame that sent the message.
  • [IWKScriptMessage.WebView]: The web view that sent the message.
  • [IWKScriptMessage.World]: The namespace in which the JavaScript code executes.

Getting the Message Handler’s Name

  • [IWKScriptMessage.Name]: The name of the message handler to which the message is sent.

See: https://developer.apple.com/documentation/WebKit/WKScriptMessage

type IWKSecurityOrigin

type IWKSecurityOrigin interface {
	objectivec.IObject

	// The security origin’s host.
	Host() string
	// The security origin’s port.
	Port() int

	// The security origin’s protocol.
	Protocol() string
}

An interface definition for the WKSecurityOrigin class.

Getting the Host Information

  • [IWKSecurityOrigin.Host]: The security origin’s host.
  • [IWKSecurityOrigin.Port]: The security origin’s port.

Getting the Host Protocol

  • [IWKSecurityOrigin.Protocol]: The security origin’s protocol.

See: https://developer.apple.com/documentation/WebKit/WKSecurityOrigin

type IWKSnapshotConfiguration

type IWKSnapshotConfiguration interface {
	objectivec.IObject

	// The portion of your web view to capture, specified as a rectangle in the view’s coordinate system.
	Rect() corefoundation.CGRect
	SetRect(value corefoundation.CGRect)
	// The width of the captured image, in points.
	SnapshotWidth() foundation.NSNumber
	SetSnapshotWidth(value foundation.NSNumber)

	// A Boolean value that indicates whether to take the snapshot after incorporating any pending screen updates.
	AfterScreenUpdates() bool
	SetAfterScreenUpdates(value bool)
}

An interface definition for the WKSnapshotConfiguration class.

Specifying the snapshot dimensions

  • [IWKSnapshotConfiguration.Rect]: The portion of your web view to capture, specified as a rectangle in the view’s coordinate system.
  • [IWKSnapshotConfiguration.SetRect]
  • [IWKSnapshotConfiguration.SnapshotWidth]: The width of the captured image, in points.
  • [IWKSnapshotConfiguration.SetSnapshotWidth]

Configuring the capture behavior

  • [IWKSnapshotConfiguration.AfterScreenUpdates]: A Boolean value that indicates whether to take the snapshot after incorporating any pending screen updates.
  • [IWKSnapshotConfiguration.SetAfterScreenUpdates]

See: https://developer.apple.com/documentation/WebKit/WKSnapshotConfiguration

type IWKUserContentController

type IWKUserContentController interface {
	objectivec.IObject

	// Injects the specified script into the webpage’s content.
	AddUserScript(userScript IWKUserScript)
	// Removes all user scripts from the web view.
	RemoveAllUserScripts()
	// The user scripts associated with the user content controller.
	UserScripts() []WKUserScript

	// Installs a message handler that you can call from your JavaScript code.
	AddScriptMessageHandlerName(scriptMessageHandler WKScriptMessageHandler, name string)
	// Installs a message handler that you can call from the specified content world in your JavaScript code.
	AddScriptMessageHandlerContentWorldName(scriptMessageHandler WKScriptMessageHandler, world IWKContentWorld, name string)
	// Installs a message handler that returns a reply to your JavaScript code.
	AddScriptMessageHandlerWithReplyContentWorldName(scriptMessageHandlerWithReply WKScriptMessageHandlerWithReply, contentWorld IWKContentWorld, name string)
	// Uninstalls the custom message handler with the specified name from your JavaScript code.
	RemoveScriptMessageHandlerForName(name string)
	// Uninstalls a custom message handler from the specified content world in your JavaScript code.
	RemoveScriptMessageHandlerForNameContentWorld(name string, contentWorld IWKContentWorld)
	// Uninstalls all custom message handlers from the specified content world in your JavaScript code.
	RemoveAllScriptMessageHandlersFromContentWorld(contentWorld IWKContentWorld)
	// Uninstalls all custom message handlers associated with the user content controller.
	RemoveAllScriptMessageHandlers()

	// Adds the specified content rule list to the content controller object.
	AddContentRuleList(contentRuleList IWKContentRuleList)
	// Removes the specified rule list from the content controller object.
	RemoveContentRuleList(contentRuleList IWKContentRuleList)
	// Removes all rules lists from the content controller.
	RemoveAllContentRuleLists()

	// The object that coordinates interactions between your app’s native code and the webpage’s scripts and other content.
	UserContentController() IWKUserContentController
	SetUserContentController(value IWKUserContentController)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the WKUserContentController class.

Adding and Removing Custom Scripts

  • [IWKUserContentController.AddUserScript]: Injects the specified script into the webpage’s content.
  • [IWKUserContentController.RemoveAllUserScripts]: Removes all user scripts from the web view.
  • [IWKUserContentController.UserScripts]: The user scripts associated with the user content controller.

Adding and Removing Message Handlers

  • [IWKUserContentController.AddScriptMessageHandlerName]: Installs a message handler that you can call from your JavaScript code.
  • [IWKUserContentController.AddScriptMessageHandlerContentWorldName]: Installs a message handler that you can call from the specified content world in your JavaScript code.
  • [IWKUserContentController.AddScriptMessageHandlerWithReplyContentWorldName]: Installs a message handler that returns a reply to your JavaScript code.
  • [IWKUserContentController.RemoveScriptMessageHandlerForName]: Uninstalls the custom message handler with the specified name from your JavaScript code.
  • [IWKUserContentController.RemoveScriptMessageHandlerForNameContentWorld]: Uninstalls a custom message handler from the specified content world in your JavaScript code.
  • [IWKUserContentController.RemoveAllScriptMessageHandlersFromContentWorld]: Uninstalls all custom message handlers from the specified content world in your JavaScript code.
  • [IWKUserContentController.RemoveAllScriptMessageHandlers]: Uninstalls all custom message handlers associated with the user content controller.

Adding and Removing Content Rules

  • [IWKUserContentController.AddContentRuleList]: Adds the specified content rule list to the content controller object.
  • [IWKUserContentController.RemoveContentRuleList]: Removes the specified rule list from the content controller object.
  • [IWKUserContentController.RemoveAllContentRuleLists]: Removes all rules lists from the content controller.

See: https://developer.apple.com/documentation/WebKit/WKUserContentController

type IWKUserScript

type IWKUserScript interface {
	objectivec.IObject

	// Creates a user script object that contains the specified source code and attributes.
	InitWithSourceInjectionTimeForMainFrameOnly(source string, injectionTime WKUserScriptInjectionTime, forMainFrameOnly bool) WKUserScript
	// Creates a user script object that is scoped to a particular content world.
	InitWithSourceInjectionTimeForMainFrameOnlyInContentWorld(source string, injectionTime WKUserScriptInjectionTime, forMainFrameOnly bool, contentWorld IWKContentWorld) WKUserScript

	// The script’s source code.
	Source() string
	// The time at which to inject the script into the webpage.
	InjectionTime() WKUserScriptInjectionTime
	// A Boolean value that indicates whether to inject the script into the main frame or all frames.
	ForMainFrameOnly() bool
}

An interface definition for the WKUserScript class.

Creating a User Script Object

  • [IWKUserScript.InitWithSourceInjectionTimeForMainFrameOnly]: Creates a user script object that contains the specified source code and attributes.
  • [IWKUserScript.InitWithSourceInjectionTimeForMainFrameOnlyInContentWorld]: Creates a user script object that is scoped to a particular content world.

Inspecting Script Information

  • [IWKUserScript.Source]: The script’s source code.
  • [IWKUserScript.InjectionTime]: The time at which to inject the script into the webpage.
  • [IWKUserScript.ForMainFrameOnly]: A Boolean value that indicates whether to inject the script into the main frame or all frames.

See: https://developer.apple.com/documentation/WebKit/WKUserScript

type IWKWebExtension

type IWKWebExtension interface {
	objectivec.IObject

	// The set of websites that the extension requires access to for injected content and for receiving messages from websites.
	AllRequestedMatchPatterns() foundation.INSSet
	// The default locale for the extension.
	DefaultLocale() foundation.NSLocale
	// The default localized extension action label.
	DisplayActionLabel() string
	// The localized extension description.
	DisplayDescription() string
	// The localized extension name.
	DisplayName() string
	// The localized extension short name.
	DisplayShortName() string
	// The localized extension display version.
	DisplayVersion() string
	// An array of all errors that occurred during the processing of the extension.
	Errors() []foundation.NSError
	// A Boolean value indicating whether the extension has background content that can run when needed.
	HasBackgroundContent() bool
	// A Boolean value indicating whether the extension includes commands that users can invoke.
	HasCommands() bool
	// A Boolean value indicating whether the extension includes rules used for content modification or blocking.
	HasContentModificationRules() bool
	// A Boolean value indicating whether the extension has script or stylesheet content that can be injected into webpages.
	HasInjectedContent() bool
	// A Boolean value indicating whether the extension has an options page.
	HasOptionsPage() bool
	// A Boolean value indicating whether the extension provides an alternative to the default new tab page.
	HasOverrideNewTabPage() bool
	// A Boolean value indicating whether the extension has background content that stays in memory as long as the extension is loaded.
	HasPersistentBackgroundContent() bool
	// The parsed manifest as a dictionary.
	Manifest() foundation.INSDictionary
	// The parsed manifest version, or `0` if there is no version specified in the manifest.
	ManifestVersion() float64
	// The set of websites that the extension may need access to for optional functionality.
	OptionalPermissionMatchPatterns() foundation.INSSet
	// The set of permissions that the extension may need for optional functionality.
	OptionalPermissions() foundation.INSSet
	// The set of websites that the extension requires access to for its base functionality.
	RequestedPermissionMatchPatterns() foundation.INSSet
	// The set of permissions that the extension requires for its base functionality.
	RequestedPermissions() foundation.INSSet
	// The extension version.
	Version() string

	// Returns the default action icon for the specified size.
	ActionIconForSize(size corefoundation.CGSize) objc.ID
	// Returns the extension’s icon image for the specified size.
	IconForSize(size corefoundation.CGSize) objc.ID
	// Checks if a manifest version is supported by the extension.
	SupportsManifestVersion(manifestVersion float64) bool
}

An interface definition for the WKWebExtension class.

Instance Properties

  • [IWKWebExtension.AllRequestedMatchPatterns]: The set of websites that the extension requires access to for injected content and for receiving messages from websites.
  • [IWKWebExtension.DefaultLocale]: The default locale for the extension.
  • [IWKWebExtension.DisplayActionLabel]: The default localized extension action label.
  • [IWKWebExtension.DisplayDescription]: The localized extension description.
  • [IWKWebExtension.DisplayName]: The localized extension name.
  • [IWKWebExtension.DisplayShortName]: The localized extension short name.
  • [IWKWebExtension.DisplayVersion]: The localized extension display version.
  • [IWKWebExtension.Errors]: An array of all errors that occurred during the processing of the extension.
  • [IWKWebExtension.HasBackgroundContent]: A Boolean value indicating whether the extension has background content that can run when needed.
  • [IWKWebExtension.HasCommands]: A Boolean value indicating whether the extension includes commands that users can invoke.
  • [IWKWebExtension.HasContentModificationRules]: A Boolean value indicating whether the extension includes rules used for content modification or blocking.
  • [IWKWebExtension.HasInjectedContent]: A Boolean value indicating whether the extension has script or stylesheet content that can be injected into webpages.
  • [IWKWebExtension.HasOptionsPage]: A Boolean value indicating whether the extension has an options page.
  • [IWKWebExtension.HasOverrideNewTabPage]: A Boolean value indicating whether the extension provides an alternative to the default new tab page.
  • [IWKWebExtension.HasPersistentBackgroundContent]: A Boolean value indicating whether the extension has background content that stays in memory as long as the extension is loaded.
  • [IWKWebExtension.Manifest]: The parsed manifest as a dictionary.
  • [IWKWebExtension.ManifestVersion]: The parsed manifest version, or `0` if there is no version specified in the manifest.
  • [IWKWebExtension.OptionalPermissionMatchPatterns]: The set of websites that the extension may need access to for optional functionality.
  • [IWKWebExtension.OptionalPermissions]: The set of permissions that the extension may need for optional functionality.
  • [IWKWebExtension.RequestedPermissionMatchPatterns]: The set of websites that the extension requires access to for its base functionality.
  • [IWKWebExtension.RequestedPermissions]: The set of permissions that the extension requires for its base functionality.
  • [IWKWebExtension.Version]: The extension version.

Instance Methods

  • [IWKWebExtension.ActionIconForSize]: Returns the default action icon for the specified size.
  • [IWKWebExtension.IconForSize]: Returns the extension’s icon image for the specified size.
  • [IWKWebExtension.SupportsManifestVersion]: Checks if a manifest version is supported by the extension.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension

type IWKWebExtensionAction

type IWKWebExtensionAction interface {
	objectivec.IObject

	// The tab that this action is associated with, or `nil` if it’s the default action.
	AssociatedTab() WKWebExtensionTab
	// The badge text for the action.
	BadgeText() string
	// A Boolean value indicating whether the badge text is unread.
	HasUnreadBadgeText() bool
	SetHasUnreadBadgeText(value bool)
	// The name shown when inspecting the pop-up web view.
	InspectionName() string
	SetInspectionName(value string)
	// A Boolean value indicating whether the action is enabled.
	Enabled() bool
	// The localized display label for the action.
	Label() string
	// The menu items provided by the extension for this action.
	MenuItems() []objectivec.IObject
	// A popover that presents a web view loaded with the pop-up page for this action, or `nil` if no popup is specified.
	PopupPopover() appkit.NSPopover
	// A web view loaded with the pop-up page for this action, or `nil` if no pop-up is specified.
	PopupWebView() IWKWebView
	// A Boolean value indicating whether the action has a pop-up.
	PresentsPopup() bool
	// The extension context to which this action is related.
	WebExtensionContext() IWKWebExtensionContext

	// Triggers the dismissal process of the pop-up.
	ClosePopup()
	// Returns the action icon for the specified size.
	IconForSize(size corefoundation.CGSize) objc.ID
}

An interface definition for the WKWebExtensionAction class.

Instance Properties

  • [IWKWebExtensionAction.AssociatedTab]: The tab that this action is associated with, or `nil` if it’s the default action.
  • [IWKWebExtensionAction.BadgeText]: The badge text for the action.
  • [IWKWebExtensionAction.HasUnreadBadgeText]: A Boolean value indicating whether the badge text is unread.
  • [IWKWebExtensionAction.SetHasUnreadBadgeText]
  • [IWKWebExtensionAction.InspectionName]: The name shown when inspecting the pop-up web view.
  • [IWKWebExtensionAction.SetInspectionName]
  • [IWKWebExtensionAction.Enabled]: A Boolean value indicating whether the action is enabled.
  • [IWKWebExtensionAction.Label]: The localized display label for the action.
  • [IWKWebExtensionAction.MenuItems]: The menu items provided by the extension for this action.
  • [IWKWebExtensionAction.PopupPopover]: A popover that presents a web view loaded with the pop-up page for this action, or `nil` if no popup is specified.
  • [IWKWebExtensionAction.PopupWebView]: A web view loaded with the pop-up page for this action, or `nil` if no pop-up is specified.
  • [IWKWebExtensionAction.PresentsPopup]: A Boolean value indicating whether the action has a pop-up.
  • [IWKWebExtensionAction.WebExtensionContext]: The extension context to which this action is related.

Instance Methods

  • [IWKWebExtensionAction.ClosePopup]: Triggers the dismissal process of the pop-up.
  • [IWKWebExtensionAction.IconForSize]: Returns the action icon for the specified size.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action

type IWKWebExtensionCommand

type IWKWebExtensionCommand interface {
	objectivec.IObject

	// The primary key used to trigger the command, distinct from any modifier flags.
	ActivationKey() string
	SetActivationKey(value string)
	// A unique identifier for the command.
	Identifier() string
	// A menu item representation of the web extension command for use in menus.
	MenuItem() objectivec.IObject
	// The modifier flags used with the activation key to trigger the command.
	ModifierFlags() objectivec.IObject
	SetModifierFlags(value objectivec.IObject)
	// A descriptive title for the command to help discoverability.
	Title() string
	// The web extension context associated with the command.
	WebExtensionContext() IWKWebExtensionContext
}

An interface definition for the WKWebExtensionCommand class.

Instance Properties

  • [IWKWebExtensionCommand.ActivationKey]: The primary key used to trigger the command, distinct from any modifier flags.
  • [IWKWebExtensionCommand.SetActivationKey]
  • [IWKWebExtensionCommand.Identifier]: A unique identifier for the command.
  • [IWKWebExtensionCommand.MenuItem]: A menu item representation of the web extension command for use in menus.
  • [IWKWebExtensionCommand.ModifierFlags]: The modifier flags used with the activation key to trigger the command.
  • [IWKWebExtensionCommand.SetModifierFlags]
  • [IWKWebExtensionCommand.Title]: A descriptive title for the command to help discoverability.
  • [IWKWebExtensionCommand.WebExtensionContext]: The web extension context associated with the command.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Command

type IWKWebExtensionContext

type IWKWebExtensionContext interface {
	objectivec.IObject

	// Returns a web extension context initialized with a specified extension.
	InitForExtension(extension IWKWebExtension) WKWebExtensionContext

	// The base URL the context uses for loading extension resources or injecting content into webpages.
	BaseURL() foundation.INSURL
	SetBaseURL(value foundation.INSURL)
	// The commands associated with the extension.
	Commands() []WKWebExtensionCommand
	// The currently granted permission match patterns that have not expired.
	CurrentPermissionMatchPatterns() foundation.INSSet
	// The currently granted permissions that have not expired.
	CurrentPermissions() foundation.INSSet
	// The currently denied permission match patterns and their expiration dates.
	DeniedPermissionMatchPatterns() foundation.INSDictionary
	SetDeniedPermissionMatchPatterns(value foundation.INSDictionary)
	// The currently denied permissions and their expiration dates.
	DeniedPermissions() foundation.INSDictionary
	SetDeniedPermissions(value foundation.INSDictionary)
	// All errors that occurred in the extension context.
	Errors() []foundation.NSError
	// The window that currently has focus for this extension.
	FocusedWindow() WKWebExtensionWindow
	// The currently granted permission match patterns and their expiration dates.
	GrantedPermissionMatchPatterns() foundation.INSDictionary
	SetGrantedPermissionMatchPatterns(value foundation.INSDictionary)
	// The currently granted permissions and their expiration dates.
	GrantedPermissions() foundation.INSDictionary
	SetGrantedPermissions(value foundation.INSDictionary)
	// A Boolean value indicating if the currently granted permission match patterns set contains the `<all_urls>` pattern or any `*` host patterns.
	HasAccessToAllHosts() bool
	// A Boolean value indicating if the currently granted permission match patterns set contains the `<all_urls>` pattern.
	HasAccessToAllURLs() bool
	// A Boolean value indicating if the extension has access to private data.
	HasAccessToPrivateData() bool
	SetHasAccessToPrivateData(value bool)
	// A boolean value indicating whether the extension includes rules used for content modification or blocking.
	HasContentModificationRules() bool
	// A Boolean value indicating whether the extension has script or stylesheet content that can be injected into webpages.
	HasInjectedContent() bool
	// A Boolean value indicating if the extension has requested optional access to all hosts.
	HasRequestedOptionalAccessToAllHosts() bool
	SetHasRequestedOptionalAccessToAllHosts(value bool)
	// The name shown when inspecting the background web view.
	InspectionName() string
	SetInspectionName(value string)
	// Determines whether Web Inspector can inspect the [WKWebView](<doc://com.apple.webkit/documentation/WebKit/WKWebView>) instances for this context.
	Inspectable() bool
	SetInspectable(value bool)
	// A Boolean value indicating if this context is loaded in an extension controller.
	Loaded() bool
	// A set of open tabs in all open windows that are exposed to this extension.
	OpenTabs() foundation.INSSet
	// The open windows that are exposed to this extension.
	OpenWindows() []objectivec.IObject
	// The URL of the extension’s options page, if the extension has one.
	OptionsPageURL() foundation.INSURL
	// The URL to use as an alternative to the default new tab page, if the extension has one.
	OverrideNewTabPageURL() foundation.INSURL
	// A unique identifier used to distinguish the extension from other extensions and target it for messages.
	UniqueIdentifier() string
	SetUniqueIdentifier(value string)
	// Specifies unsupported APIs for this extension, making them `undefined` in JavaScript.
	UnsupportedAPIs() foundation.INSSet
	SetUnsupportedAPIs(value foundation.INSSet)
	// The extension this context represents.
	WebExtension() IWKWebExtension
	// The extension controller this context is loaded in, otherwise `nil` if it isn’t loaded.
	WebExtensionController() IWKWebExtensionController
	// The web view configuration to use for web views that load pages from this extension.
	WebViewConfiguration() IWKWebViewConfiguration

	// Retrieves the extension action for a given tab, or the default action if `nil` is passed.
	ActionForTab(tab WKWebExtensionTab) IWKWebExtensionAction
	// Called by the app to clear a user gesture in a specific tab.
	ClearUserGestureInTab(tab WKWebExtensionTab)
	// Retrieves the command associated with the given event without performing it.
	CommandForEvent(event appkit.NSEvent) IWKWebExtensionCommand
	// Called by the app when the properties of a tab are changed to fire appropriate events with only this extension.
	DidChangeTabPropertiesForTab(properties WKWebExtensionTabChangedProperties, changedTab WKWebExtensionTab)
	// Called by the app when a window is closed to fire appropriate events with only this extension.
	DidCloseWindow(closedWindow WKWebExtensionWindow)
	// Called by the app when tabs are deselected to fire appropriate events with only this extension.
	DidDeselectTabs(deselectedTabs []objectivec.IObject)
	// Called by the app when a window gains focus to fire appropriate events with only this extension.
	DidFocusWindow(focusedWindow WKWebExtensionWindow)
	// Called by the app when a new tab is opened to fire appropriate events with only this extension.
	DidOpenTab(newTab WKWebExtensionTab)
	// Called by the app when a new window is opened to fire appropriate events with only this extension.
	DidOpenWindow(newWindow WKWebExtensionWindow)
	// Called by the app when a tab is replaced by another tab to fire appropriate events with only this extension.
	DidReplaceTabWithTab(oldTab WKWebExtensionTab, newTab WKWebExtensionTab)
	// Called by the app when tabs are selected to fire appropriate events with only this extension.
	DidSelectTabs(selectedTabs []objectivec.IObject)
	// Checks the specified URL against the currently granted permission match patterns.
	HasAccessToURL(url foundation.INSURL) bool
	// Checks the specified URL against the currently granted permission match patterns in a specific tab.
	HasAccessToURLInTab(url foundation.INSURL, tab WKWebExtensionTab) bool
	// Indicates if a user gesture is currently active in the specified tab.
	HasActiveUserGestureInTab(tab WKWebExtensionTab) bool
	// Checks if the extension has script or stylesheet content that can be injected into the specified URL.
	HasInjectedContentForURL(url foundation.INSURL) bool
	// Checks the specified permission against the currently granted permissions.
	HasPermission(permission WKWebExtensionPermission) bool
	// Checks the specified permission against the currently granted permissions in a specific tab.
	HasPermissionInTab(permission WKWebExtensionPermission, tab WKWebExtensionTab) bool
	// Loads the background content if needed for the extension.
	LoadBackgroundContentWithCompletionHandler(completionHandler ErrorHandler)
	// Retrieves the menu items for a given tab.
	MenuItemsForTab(tab WKWebExtensionTab) []objectivec.IObject
	// Performs the extension action associated with the specified tab or performs the default action if `nil` is passed.
	PerformActionForTab(tab WKWebExtensionTab)
	// Performs the specified command, triggering events specific to this extension.
	PerformCommand(command IWKWebExtensionCommand)
	// Performs the command associated with the given event.
	PerformCommandForEvent(event appkit.NSEvent) bool
	// Checks the specified permission against the currently denied, granted, and requested permissions.
	PermissionStatusForPermission(permission WKWebExtensionPermission) WKWebExtensionContextPermissionStatus
	// Checks the specified match pattern against the currently denied, granted, and requested permission match patterns.
	PermissionStatusForMatchPattern(pattern IWKWebExtensionMatchPattern) WKWebExtensionContextPermissionStatus
	// Checks the specified URL against the currently denied, granted, and requested permission match patterns.
	PermissionStatusForURL(url foundation.INSURL) WKWebExtensionContextPermissionStatus
	// Checks the specified permission against the currently denied, granted, and requested permissions.
	PermissionStatusForPermissionInTab(permission WKWebExtensionPermission, tab WKWebExtensionTab) WKWebExtensionContextPermissionStatus
	// Checks the specified URL against the currently denied, granted, and requested permission match patterns.
	PermissionStatusForURLInTab(url foundation.INSURL, tab WKWebExtensionTab) WKWebExtensionContextPermissionStatus
	// Checks the specified match pattern against the currently denied, granted, and requested permission match patterns.
	PermissionStatusForMatchPatternInTab(pattern IWKWebExtensionMatchPattern, tab WKWebExtensionTab) WKWebExtensionContextPermissionStatus
	// Sets the status of a permission with a distant future expiration date.
	SetPermissionStatusForPermission(status WKWebExtensionContextPermissionStatus, permission WKWebExtensionPermission)
	// Sets the permission status of a URL with a distant future expiration date.
	SetPermissionStatusForURL(status WKWebExtensionContextPermissionStatus, url foundation.INSURL)
	// Sets the status of a match pattern with a distant future expiration date.
	SetPermissionStatusForMatchPattern(status WKWebExtensionContextPermissionStatus, pattern IWKWebExtensionMatchPattern)
	// Sets the permission status of a URL with a distant future expiration date.
	SetPermissionStatusForURLExpirationDate(status WKWebExtensionContextPermissionStatus, url foundation.INSURL, expirationDate foundation.INSDate)
	// Sets the status of a permission with a specific expiration date.
	SetPermissionStatusForPermissionExpirationDate(status WKWebExtensionContextPermissionStatus, permission WKWebExtensionPermission, expirationDate foundation.INSDate)
	// Sets the status of a match pattern with a specific expiration date.
	SetPermissionStatusForMatchPatternExpirationDate(status WKWebExtensionContextPermissionStatus, pattern IWKWebExtensionMatchPattern, expirationDate foundation.INSDate)
	// Should be called by the app when a user gesture is performed in a specific tab.
	UserGesturePerformedInTab(tab WKWebExtensionTab)

	// Called by the app when a tab is activated to notify only this specific extension.
	DidActivateTabPreviousActiveTab(activatedTab WKWebExtensionTab, previousTab WKWebExtensionTab)
	// Called by the app when a tab is closed to fire appropriate events with only this extension.
	DidCloseTabWindowIsClosing(closedTab WKWebExtensionTab, windowIsClosing bool)
	// Called by the app when a tab is moved to fire appropriate events with only this extension.
	DidMoveTabFromIndexInWindow(movedTab WKWebExtensionTab, index uint, oldWindow WKWebExtensionWindow)
}

An interface definition for the WKWebExtensionContext class.

Initializers

  • [IWKWebExtensionContext.InitForExtension]: Returns a web extension context initialized with a specified extension.

Instance Properties

  • [IWKWebExtensionContext.BaseURL]: The base URL the context uses for loading extension resources or injecting content into webpages.
  • [IWKWebExtensionContext.SetBaseURL]
  • [IWKWebExtensionContext.Commands]: The commands associated with the extension.
  • [IWKWebExtensionContext.CurrentPermissionMatchPatterns]: The currently granted permission match patterns that have not expired.
  • [IWKWebExtensionContext.CurrentPermissions]: The currently granted permissions that have not expired.
  • [IWKWebExtensionContext.DeniedPermissionMatchPatterns]: The currently denied permission match patterns and their expiration dates.
  • [IWKWebExtensionContext.SetDeniedPermissionMatchPatterns]
  • [IWKWebExtensionContext.DeniedPermissions]: The currently denied permissions and their expiration dates.
  • [IWKWebExtensionContext.SetDeniedPermissions]
  • [IWKWebExtensionContext.Errors]: All errors that occurred in the extension context.
  • [IWKWebExtensionContext.FocusedWindow]: The window that currently has focus for this extension.
  • [IWKWebExtensionContext.GrantedPermissionMatchPatterns]: The currently granted permission match patterns and their expiration dates.
  • [IWKWebExtensionContext.SetGrantedPermissionMatchPatterns]
  • [IWKWebExtensionContext.GrantedPermissions]: The currently granted permissions and their expiration dates.
  • [IWKWebExtensionContext.SetGrantedPermissions]
  • [IWKWebExtensionContext.HasAccessToAllHosts]: A Boolean value indicating if the currently granted permission match patterns set contains the `<all_urls>` pattern or any `*` host patterns.
  • [IWKWebExtensionContext.HasAccessToAllURLs]: A Boolean value indicating if the currently granted permission match patterns set contains the `<all_urls>` pattern.
  • [IWKWebExtensionContext.HasAccessToPrivateData]: A Boolean value indicating if the extension has access to private data.
  • [IWKWebExtensionContext.SetHasAccessToPrivateData]
  • [IWKWebExtensionContext.HasContentModificationRules]: A boolean value indicating whether the extension includes rules used for content modification or blocking.
  • [IWKWebExtensionContext.HasInjectedContent]: A Boolean value indicating whether the extension has script or stylesheet content that can be injected into webpages.
  • [IWKWebExtensionContext.HasRequestedOptionalAccessToAllHosts]: A Boolean value indicating if the extension has requested optional access to all hosts.
  • [IWKWebExtensionContext.SetHasRequestedOptionalAccessToAllHosts]
  • [IWKWebExtensionContext.InspectionName]: The name shown when inspecting the background web view.
  • [IWKWebExtensionContext.SetInspectionName]
  • [IWKWebExtensionContext.Inspectable]: Determines whether Web Inspector can inspect the WKWebView(<doc://com.apple.webkit/documentation/WebKit/WKWebView>) instances for this context.
  • [IWKWebExtensionContext.SetInspectable]
  • [IWKWebExtensionContext.Loaded]: A Boolean value indicating if this context is loaded in an extension controller.
  • [IWKWebExtensionContext.OpenTabs]: A set of open tabs in all open windows that are exposed to this extension.
  • [IWKWebExtensionContext.OpenWindows]: The open windows that are exposed to this extension.
  • [IWKWebExtensionContext.OptionsPageURL]: The URL of the extension’s options page, if the extension has one.
  • [IWKWebExtensionContext.OverrideNewTabPageURL]: The URL to use as an alternative to the default new tab page, if the extension has one.
  • [IWKWebExtensionContext.UniqueIdentifier]: A unique identifier used to distinguish the extension from other extensions and target it for messages.
  • [IWKWebExtensionContext.SetUniqueIdentifier]
  • [IWKWebExtensionContext.UnsupportedAPIs]: Specifies unsupported APIs for this extension, making them `undefined` in JavaScript.
  • [IWKWebExtensionContext.SetUnsupportedAPIs]
  • [IWKWebExtensionContext.WebExtension]: The extension this context represents.
  • [IWKWebExtensionContext.WebExtensionController]: The extension controller this context is loaded in, otherwise `nil` if it isn’t loaded.
  • [IWKWebExtensionContext.WebViewConfiguration]: The web view configuration to use for web views that load pages from this extension.

Instance Methods

  • [IWKWebExtensionContext.ActionForTab]: Retrieves the extension action for a given tab, or the default action if `nil` is passed.
  • [IWKWebExtensionContext.ClearUserGestureInTab]: Called by the app to clear a user gesture in a specific tab.
  • [IWKWebExtensionContext.CommandForEvent]: Retrieves the command associated with the given event without performing it.
  • [IWKWebExtensionContext.DidChangeTabPropertiesForTab]: Called by the app when the properties of a tab are changed to fire appropriate events with only this extension.
  • [IWKWebExtensionContext.DidCloseWindow]: Called by the app when a window is closed to fire appropriate events with only this extension.
  • [IWKWebExtensionContext.DidDeselectTabs]: Called by the app when tabs are deselected to fire appropriate events with only this extension.
  • [IWKWebExtensionContext.DidFocusWindow]: Called by the app when a window gains focus to fire appropriate events with only this extension.
  • [IWKWebExtensionContext.DidOpenTab]: Called by the app when a new tab is opened to fire appropriate events with only this extension.
  • [IWKWebExtensionContext.DidOpenWindow]: Called by the app when a new window is opened to fire appropriate events with only this extension.
  • [IWKWebExtensionContext.DidReplaceTabWithTab]: Called by the app when a tab is replaced by another tab to fire appropriate events with only this extension.
  • [IWKWebExtensionContext.DidSelectTabs]: Called by the app when tabs are selected to fire appropriate events with only this extension.
  • [IWKWebExtensionContext.HasAccessToURL]: Checks the specified URL against the currently granted permission match patterns.
  • [IWKWebExtensionContext.HasAccessToURLInTab]: Checks the specified URL against the currently granted permission match patterns in a specific tab.
  • [IWKWebExtensionContext.HasActiveUserGestureInTab]: Indicates if a user gesture is currently active in the specified tab.
  • [IWKWebExtensionContext.HasInjectedContentForURL]: Checks if the extension has script or stylesheet content that can be injected into the specified URL.
  • [IWKWebExtensionContext.HasPermission]: Checks the specified permission against the currently granted permissions.
  • [IWKWebExtensionContext.HasPermissionInTab]: Checks the specified permission against the currently granted permissions in a specific tab.
  • [IWKWebExtensionContext.LoadBackgroundContentWithCompletionHandler]: Loads the background content if needed for the extension.
  • [IWKWebExtensionContext.MenuItemsForTab]: Retrieves the menu items for a given tab.
  • [IWKWebExtensionContext.PerformActionForTab]: Performs the extension action associated with the specified tab or performs the default action if `nil` is passed.
  • [IWKWebExtensionContext.PerformCommand]: Performs the specified command, triggering events specific to this extension.
  • [IWKWebExtensionContext.PerformCommandForEvent]: Performs the command associated with the given event.
  • [IWKWebExtensionContext.PermissionStatusForPermission]: Checks the specified permission against the currently denied, granted, and requested permissions.
  • [IWKWebExtensionContext.PermissionStatusForMatchPattern]: Checks the specified match pattern against the currently denied, granted, and requested permission match patterns.
  • [IWKWebExtensionContext.PermissionStatusForURL]: Checks the specified URL against the currently denied, granted, and requested permission match patterns.
  • [IWKWebExtensionContext.PermissionStatusForPermissionInTab]: Checks the specified permission against the currently denied, granted, and requested permissions.
  • [IWKWebExtensionContext.PermissionStatusForURLInTab]: Checks the specified URL against the currently denied, granted, and requested permission match patterns.
  • [IWKWebExtensionContext.PermissionStatusForMatchPatternInTab]: Checks the specified match pattern against the currently denied, granted, and requested permission match patterns.
  • [IWKWebExtensionContext.SetPermissionStatusForPermission]: Sets the status of a permission with a distant future expiration date.
  • [IWKWebExtensionContext.SetPermissionStatusForURL]: Sets the permission status of a URL with a distant future expiration date.
  • [IWKWebExtensionContext.SetPermissionStatusForMatchPattern]: Sets the status of a match pattern with a distant future expiration date.
  • [IWKWebExtensionContext.SetPermissionStatusForURLExpirationDate]: Sets the permission status of a URL with a distant future expiration date.
  • [IWKWebExtensionContext.SetPermissionStatusForPermissionExpirationDate]: Sets the status of a permission with a specific expiration date.
  • [IWKWebExtensionContext.SetPermissionStatusForMatchPatternExpirationDate]: Sets the status of a match pattern with a specific expiration date.
  • [IWKWebExtensionContext.UserGesturePerformedInTab]: Should be called by the app when a user gesture is performed in a specific tab.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext

type IWKWebExtensionController

type IWKWebExtensionController interface {
	objectivec.IObject

	// Returns a web extension controller initialized with the specified configuration.
	InitWithConfiguration(configuration IWKWebExtensionControllerConfiguration) WKWebExtensionController

	// A copy of the configuration with which the web extension controller was initialized.
	Configuration() IWKWebExtensionControllerConfiguration
	// The extension controller delegate.
	Delegate() WKWebExtensionControllerDelegate
	SetDelegate(value WKWebExtensionControllerDelegate)
	// A set of all the currently loaded extension contexts.
	ExtensionContexts() foundation.INSSet
	// A set of all the currently loaded extensions.
	Extensions() foundation.INSSet

	// Should be called by the app when the properties of a tab are changed to fire appropriate events with all loaded web extensions.
	DidChangeTabPropertiesForTab(properties WKWebExtensionTabChangedProperties, changedTab WKWebExtensionTab)
	// Should be called by the app when a window is closed to fire appropriate events with all loaded web extensions.
	DidCloseWindow(closedWindow WKWebExtensionWindow)
	// Should be called by the app when tabs are deselected to fire appropriate events with all loaded web extensions.
	DidDeselectTabs(deselectedTabs []objectivec.IObject)
	// Should be called by the app when a window gains focus to fire appropriate events with all loaded web extensions.
	DidFocusWindow(focusedWindow WKWebExtensionWindow)
	// Should be called by the app when a new tab is opened to fire appropriate events with all loaded web extensions.
	DidOpenTab(newTab WKWebExtensionTab)
	// Should be called by the app when a new window is opened to fire appropriate events with all loaded web extensions.
	DidOpenWindow(newWindow WKWebExtensionWindow)
	// Should be called by the app when a tab is replaced by another tab to fire appropriate events with all loaded web extensions.
	DidReplaceTabWithTab(oldTab WKWebExtensionTab, newTab WKWebExtensionTab)
	// Should be called by the app when tabs are selected to fire appropriate events with all loaded web extensions.
	DidSelectTabs(selectedTabs []objectivec.IObject)
	// Returns a loaded extension context matching the specified URL.
	ExtensionContextForURL(URL foundation.INSURL) IWKWebExtensionContext
	// Returns a loaded extension context for the specified extension.
	ExtensionContextForExtension(extension IWKWebExtension) IWKWebExtensionContext
	// Fetches a data record containing the given extension data types for a specific known web extension context.
	FetchDataRecordOfTypesForExtensionContextCompletionHandler(dataTypes foundation.INSSet, extensionContext IWKWebExtensionContext, completionHandler WKWebExtensionDataRecordHandler)
	// Loads the specified extension context.
	LoadExtensionContextError(extensionContext IWKWebExtensionContext) (bool, error)
	// Removes extension data of the given types for the given data records.
	RemoveDataOfTypesFromDataRecordsCompletionHandler(dataTypes foundation.INSSet, dataRecords []WKWebExtensionDataRecord, completionHandler VoidHandler)
	// Unloads the specified extension context.
	UnloadExtensionContextError(extensionContext IWKWebExtensionContext) (bool, error)

	WebExtensionController() IWKWebExtensionController
	SetWebExtensionController(value IWKWebExtensionController)
	// Should be called by the app when a tab is activated to notify all loaded web extensions.
	DidActivateTabPreviousActiveTab(activatedTab WKWebExtensionTab, previousTab WKWebExtensionTab)
	// Should be called by the app when a tab is closed to fire appropriate events with all loaded web extensions.
	DidCloseTabWindowIsClosing(closedTab WKWebExtensionTab, windowIsClosing bool)
	// Should be called by the app when a tab is moved to fire appropriate events with all loaded web extensions.
	DidMoveTabFromIndexInWindow(movedTab WKWebExtensionTab, index uint, oldWindow WKWebExtensionWindow)
}

An interface definition for the WKWebExtensionController class.

Initializers

  • [IWKWebExtensionController.InitWithConfiguration]: Returns a web extension controller initialized with the specified configuration.

Instance Properties

  • [IWKWebExtensionController.Configuration]: A copy of the configuration with which the web extension controller was initialized.
  • [IWKWebExtensionController.Delegate]: The extension controller delegate.
  • [IWKWebExtensionController.SetDelegate]
  • [IWKWebExtensionController.ExtensionContexts]: A set of all the currently loaded extension contexts.
  • [IWKWebExtensionController.Extensions]: A set of all the currently loaded extensions.

Instance Methods

  • [IWKWebExtensionController.DidChangeTabPropertiesForTab]: Should be called by the app when the properties of a tab are changed to fire appropriate events with all loaded web extensions.
  • [IWKWebExtensionController.DidCloseWindow]: Should be called by the app when a window is closed to fire appropriate events with all loaded web extensions.
  • [IWKWebExtensionController.DidDeselectTabs]: Should be called by the app when tabs are deselected to fire appropriate events with all loaded web extensions.
  • [IWKWebExtensionController.DidFocusWindow]: Should be called by the app when a window gains focus to fire appropriate events with all loaded web extensions.
  • [IWKWebExtensionController.DidOpenTab]: Should be called by the app when a new tab is opened to fire appropriate events with all loaded web extensions.
  • [IWKWebExtensionController.DidOpenWindow]: Should be called by the app when a new window is opened to fire appropriate events with all loaded web extensions.
  • [IWKWebExtensionController.DidReplaceTabWithTab]: Should be called by the app when a tab is replaced by another tab to fire appropriate events with all loaded web extensions.
  • [IWKWebExtensionController.DidSelectTabs]: Should be called by the app when tabs are selected to fire appropriate events with all loaded web extensions.
  • [IWKWebExtensionController.ExtensionContextForURL]: Returns a loaded extension context matching the specified URL.
  • [IWKWebExtensionController.ExtensionContextForExtension]: Returns a loaded extension context for the specified extension.
  • [IWKWebExtensionController.FetchDataRecordOfTypesForExtensionContextCompletionHandler]: Fetches a data record containing the given extension data types for a specific known web extension context.
  • [IWKWebExtensionController.LoadExtensionContextError]: Loads the specified extension context.
  • [IWKWebExtensionController.RemoveDataOfTypesFromDataRecordsCompletionHandler]: Removes extension data of the given types for the given data records.
  • [IWKWebExtensionController.UnloadExtensionContextError]: Unloads the specified extension context.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController

type IWKWebExtensionControllerConfiguration

type IWKWebExtensionControllerConfiguration interface {
	objectivec.IObject

	// The default data store for website data and cookie access in extension contexts.
	DefaultWebsiteDataStore() IWKWebsiteDataStore
	SetDefaultWebsiteDataStore(value IWKWebsiteDataStore)
	// The unique identifier used for persistent configuration storage, or `nil` when it is the default or not persistent.
	Identifier() foundation.NSUUID
	// A Boolean value indicating if this context will write data to the the file system.
	Persistent() bool
	// The web view configuration to be used as a basis for configuring web views in extension contexts.
	WebViewConfiguration() IWKWebViewConfiguration
	SetWebViewConfiguration(value IWKWebViewConfiguration)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the WKWebExtensionControllerConfiguration class.

Instance Properties

  • [IWKWebExtensionControllerConfiguration.DefaultWebsiteDataStore]: The default data store for website data and cookie access in extension contexts.
  • [IWKWebExtensionControllerConfiguration.SetDefaultWebsiteDataStore]
  • [IWKWebExtensionControllerConfiguration.Identifier]: The unique identifier used for persistent configuration storage, or `nil` when it is the default or not persistent.
  • [IWKWebExtensionControllerConfiguration.Persistent]: A Boolean value indicating if this context will write data to the the file system.
  • [IWKWebExtensionControllerConfiguration.WebViewConfiguration]: The web view configuration to be used as a basis for configuring web views in extension contexts.
  • [IWKWebExtensionControllerConfiguration.SetWebViewConfiguration]

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/Configuration-swift.class

type IWKWebExtensionDataRecord

type IWKWebExtensionDataRecord interface {
	objectivec.IObject

	// The set of data types contained in this data record.
	ContainedDataTypes() foundation.INSSet
	// The display name for the web extension to which this data record belongs.
	DisplayName() string
	// An array of errors that may have occurred when either calculating or deleting storage.
	Errors() []foundation.NSError
	// The total size in bytes of all data types contained in this data record.
	TotalSizeInBytes() uint
	// Unique identifier for the web extension context to which this data record belongs.
	UniqueIdentifier() string

	// Retrieves the size in bytes of the specific data types in this data record.
	SizeInBytesOfTypes(dataTypes foundation.INSSet) uint
}

An interface definition for the WKWebExtensionDataRecord class.

Instance Properties

  • [IWKWebExtensionDataRecord.ContainedDataTypes]: The set of data types contained in this data record.
  • [IWKWebExtensionDataRecord.DisplayName]: The display name for the web extension to which this data record belongs.
  • [IWKWebExtensionDataRecord.Errors]: An array of errors that may have occurred when either calculating or deleting storage.
  • [IWKWebExtensionDataRecord.TotalSizeInBytes]: The total size in bytes of all data types contained in this data record.
  • [IWKWebExtensionDataRecord.UniqueIdentifier]: Unique identifier for the web extension context to which this data record belongs.

Instance Methods

  • [IWKWebExtensionDataRecord.SizeInBytesOfTypes]: Retrieves the size in bytes of the specific data types in this data record.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/DataRecord

type IWKWebExtensionMatchPattern

type IWKWebExtensionMatchPattern interface {
	objectivec.IObject

	// Returns a pattern object for the specified scheme, host, and path strings.
	InitWithSchemeHostPathError(scheme string, host string, path string) (WKWebExtensionMatchPattern, error)
	// Returns a pattern object for the specified pattern string.
	InitWithStringError(string_ string) (WKWebExtensionMatchPattern, error)

	// The host part of the pattern string, unless [matchesAllURLs](<doc://com.apple.webkit/documentation/WebKit/WKWebExtension/MatchPattern/matchesAllURLs>) is [YES].
	Host() string
	// A Boolean value that indicates if the pattern is `<all_urls>` or has `*` as the host.
	MatchesAllHosts() bool
	// A Boolean value that indicates if the pattern is `<all_urls>`.
	MatchesAllURLs() bool
	// The path part of the pattern string, unless [matchesAllURLs](<doc://com.apple.webkit/documentation/WebKit/WKWebExtension/MatchPattern/matchesAllURLs>) is [YES].
	Path() string
	// The scheme part of the pattern string, unless [matchesAllURLs](<doc://com.apple.webkit/documentation/WebKit/WKWebExtension/MatchPattern/matchesAllURLs>) is [YES].
	Scheme() string
	// The original pattern string.
	String() string

	// Matches the receiver pattern against the specified URL.
	MatchesURL(url foundation.INSURL) bool
	// Matches the receiver pattern against the specified pattern.
	MatchesPattern(pattern IWKWebExtensionMatchPattern) bool
	// Matches the receiver pattern against the specified URL with options.
	MatchesURLOptions(url foundation.INSURL, options WKWebExtensionMatchPatternOptions) bool
	// Matches the receiver pattern against the specified pattern with options.
	MatchesPatternOptions(pattern IWKWebExtensionMatchPattern, options WKWebExtensionMatchPatternOptions) bool

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the WKWebExtensionMatchPattern class.

Initializers

  • [IWKWebExtensionMatchPattern.InitWithSchemeHostPathError]: Returns a pattern object for the specified scheme, host, and path strings.
  • [IWKWebExtensionMatchPattern.InitWithStringError]: Returns a pattern object for the specified pattern string.

Instance Properties

  • [IWKWebExtensionMatchPattern.Host]: The host part of the pattern string, unless [matchesAllURLs](<doc://com.apple.webkit/documentation/WebKit/WKWebExtension/MatchPattern/matchesAllURLs>) is [YES].
  • [IWKWebExtensionMatchPattern.MatchesAllHosts]: A Boolean value that indicates if the pattern is `<all_urls>` or has `*` as the host.
  • [IWKWebExtensionMatchPattern.MatchesAllURLs]: A Boolean value that indicates if the pattern is `<all_urls>`.
  • [IWKWebExtensionMatchPattern.Path]: The path part of the pattern string, unless [matchesAllURLs](<doc://com.apple.webkit/documentation/WebKit/WKWebExtension/MatchPattern/matchesAllURLs>) is [YES].
  • [IWKWebExtensionMatchPattern.Scheme]: The scheme part of the pattern string, unless [matchesAllURLs](<doc://com.apple.webkit/documentation/WebKit/WKWebExtension/MatchPattern/matchesAllURLs>) is [YES].
  • [IWKWebExtensionMatchPattern.String]: The original pattern string.

Instance Methods

  • [IWKWebExtensionMatchPattern.MatchesURL]: Matches the receiver pattern against the specified URL.
  • [IWKWebExtensionMatchPattern.MatchesPattern]: Matches the receiver pattern against the specified pattern.
  • [IWKWebExtensionMatchPattern.MatchesURLOptions]: Matches the receiver pattern against the specified URL with options.
  • [IWKWebExtensionMatchPattern.MatchesPatternOptions]: Matches the receiver pattern against the specified pattern with options.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern

type IWKWebExtensionMessagePort

type IWKWebExtensionMessagePort interface {
	objectivec.IObject

	// The unique identifier for the app to which this port should be connected.
	ApplicationIdentifier() string
	// The block to be executed when the port disconnects.
	DisconnectHandler() ErrorHandler
	SetDisconnectHandler(value ErrorHandler)
	// Indicates whether the message port is disconnected.
	Disconnected() bool
	// The block to be executed when a message is received from the web extension.
	MessageHandler() ObjectErrorHandler
	SetMessageHandler(value ObjectErrorHandler)

	// Disconnects the port, terminating all further messages.
	Disconnect()
	// Disconnects the port, terminating all further messages with an optional error.
	DisconnectWithError(error_ foundation.INSError)
	// Sends a message to the connected web extension.
	SendMessageCompletionHandler(message objectivec.IObject, completionHandler ErrorHandler)
}

An interface definition for the WKWebExtensionMessagePort class.

Instance Properties

  • [IWKWebExtensionMessagePort.ApplicationIdentifier]: The unique identifier for the app to which this port should be connected.
  • [IWKWebExtensionMessagePort.DisconnectHandler]: The block to be executed when the port disconnects.
  • [IWKWebExtensionMessagePort.SetDisconnectHandler]
  • [IWKWebExtensionMessagePort.Disconnected]: Indicates whether the message port is disconnected.
  • [IWKWebExtensionMessagePort.MessageHandler]: The block to be executed when a message is received from the web extension.
  • [IWKWebExtensionMessagePort.SetMessageHandler]

Instance Methods

  • [IWKWebExtensionMessagePort.Disconnect]: Disconnects the port, terminating all further messages.
  • [IWKWebExtensionMessagePort.DisconnectWithError]: Disconnects the port, terminating all further messages with an optional error.
  • [IWKWebExtensionMessagePort.SendMessageCompletionHandler]: Sends a message to the connected web extension.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MessagePort

type IWKWebExtensionTabConfiguration

type IWKWebExtensionTabConfiguration interface {
	objectivec.IObject

	// Indicates the position where the tab should be opened within the window.
	Index() int
	SetIndex(value int)
	// Indicates the parent tab with which the tab should be related.
	ParentTab() WKWebExtensionTab
	// Indicates whether the tab should be added to the current tab selection.
	ShouldAddToSelection() bool
	// Indicates whether the tab should be the active tab.
	ShouldBeActive() bool
	// Indicates whether the tab should be muted.
	ShouldBeMuted() bool
	// Indicates whether the tab should be pinned.
	ShouldBePinned() bool
	// Indicates whether reader mode in the tab should be active.
	ShouldReaderModeBeActive() bool
	// Indicates the initial URL for the tab.
	Url() foundation.INSURL
	// Indicates the window where the tab should be opened.
	Window() WKWebExtensionWindow
}

An interface definition for the WKWebExtensionTabConfiguration class.

Instance Properties

  • [IWKWebExtensionTabConfiguration.Index]: Indicates the position where the tab should be opened within the window.
  • [IWKWebExtensionTabConfiguration.SetIndex]
  • [IWKWebExtensionTabConfiguration.ParentTab]: Indicates the parent tab with which the tab should be related.
  • [IWKWebExtensionTabConfiguration.ShouldAddToSelection]: Indicates whether the tab should be added to the current tab selection.
  • [IWKWebExtensionTabConfiguration.ShouldBeActive]: Indicates whether the tab should be the active tab.
  • [IWKWebExtensionTabConfiguration.ShouldBeMuted]: Indicates whether the tab should be muted.
  • [IWKWebExtensionTabConfiguration.ShouldBePinned]: Indicates whether the tab should be pinned.
  • [IWKWebExtensionTabConfiguration.ShouldReaderModeBeActive]: Indicates whether reader mode in the tab should be active.
  • [IWKWebExtensionTabConfiguration.Url]: Indicates the initial URL for the tab.
  • [IWKWebExtensionTabConfiguration.Window]: Indicates the window where the tab should be opened.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/TabConfiguration

type IWKWebExtensionWindowConfiguration

type IWKWebExtensionWindowConfiguration interface {
	objectivec.IObject

	// Indicates the frame where the window should be positioned on the main screen.
	Frame() corefoundation.CGRect
	// Indicates whether the window should be focused.
	ShouldBeFocused() bool
	// Indicates whether the window should be private.
	ShouldBePrivate() bool
	// Indicates the URLs that the window should initially load as tabs.
	TabURLs() []foundation.NSURL
	// Indicates the existing tabs that should be moved to the window.
	Tabs() []objectivec.IObject
	// Indicates the window state for the window.
	WindowState() WKWebExtensionWindowState
	// Indicates the window type for the window.
	WindowType() WKWebExtensionWindowType
}

An interface definition for the WKWebExtensionWindowConfiguration class.

Instance Properties

  • [IWKWebExtensionWindowConfiguration.Frame]: Indicates the frame where the window should be positioned on the main screen.
  • [IWKWebExtensionWindowConfiguration.ShouldBeFocused]: Indicates whether the window should be focused.
  • [IWKWebExtensionWindowConfiguration.ShouldBePrivate]: Indicates whether the window should be private.
  • [IWKWebExtensionWindowConfiguration.TabURLs]: Indicates the URLs that the window should initially load as tabs.
  • [IWKWebExtensionWindowConfiguration.Tabs]: Indicates the existing tabs that should be moved to the window.
  • [IWKWebExtensionWindowConfiguration.WindowState]: Indicates the window state for the window.
  • [IWKWebExtensionWindowConfiguration.WindowType]: Indicates the window type for the window.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/WindowConfiguration

type IWKWebView

type IWKWebView interface {
	appkit.INSView

	// Creates a web view and initializes it with the specified frame and configuration data.
	InitWithFrameConfiguration(frame corefoundation.CGRect, configuration IWKWebViewConfiguration) WKWebView
	// The object that contains the configuration details for the web view.
	Configuration() IWKWebViewConfiguration

	// The object you use to integrate custom user interface elements, such as contextual menus or panels, into web view interactions.
	UIDelegate() WKUIDelegate
	SetUIDelegate(value WKUIDelegate)

	// The object you use to manage navigation behavior for the web view.
	NavigationDelegate() WKNavigationDelegate
	SetNavigationDelegate(value WKNavigationDelegate)

	// Loads the web content that the specified URL request object references and navigates to that content.
	LoadRequest(request foundation.NSURLRequest) IWKNavigation
	// Loads the content of the specified data object and navigates to it.
	LoadDataMIMETypeCharacterEncodingNameBaseURL(data foundation.INSData, MIMEType string, characterEncodingName string, baseURL foundation.INSURL) IWKNavigation
	// Loads the contents of the specified HTML string and navigates to it.
	LoadHTMLStringBaseURL(string_ string, baseURL foundation.INSURL) IWKNavigation
	// Loads the web content from the file the URL request object specifies and navigates to that content.
	LoadFileRequestAllowingReadAccessToURL(request foundation.NSURLRequest, readAccessURL foundation.INSURL) IWKNavigation
	// Loads the web content from the specified file and navigates to it.
	LoadFileURLAllowingReadAccessToURL(URL foundation.INSURL, readAccessURL foundation.INSURL) IWKNavigation
	// Loads the web content from the data you provide as if the data were the response to the request.
	LoadSimulatedRequestResponseResponseData(request foundation.NSURLRequest, response foundation.NSURLResponse, data foundation.INSData) IWKNavigation
	// Loads the web content from the HTML you provide as if the HTML were the response to the request.
	LoadSimulatedRequestResponseHTMLString(request foundation.NSURLRequest, string_ string) IWKNavigation
	// A Boolean value that indicates whether the view is currently loading content.
	Loading() bool
	// An estimate of what fraction of the current navigation has been loaded.
	EstimatedProgress() float64

	// Reloads the current webpage.
	Reload() IWKNavigation
	// Reloads the current webpage.
	ReloadWithSender(sender objectivec.IObject)
	// Reloads the current webpage, and performs end-to-end revalidation of the content using cache-validating conditionals, if possible.
	ReloadFromOrigin() IWKNavigation
	// Reloads the current webpage, and performs end-to-end revalidation of the content using cache-validating conditionals, if possible.
	ReloadFromOriginWithSender(sender objectivec.IObject)
	// Stops loading all resources on the current page.
	StopLoading()
	// Stops loading all resources on the current page.
	StopLoadingWithSender(sender objectivec.IObject)

	// Starts to download the resource at the URL in the request.
	StartDownloadUsingRequestCompletionHandler(request foundation.NSURLRequest, completionHandler WKDownloadHandler)
	// Resumes a failed or canceled download.
	ResumeDownloadFromResumeDataCompletionHandler(resumeData foundation.INSData, completionHandler WKDownloadHandler)

	// A Boolean value that indicates whether you can inspect the view with Safari Web Inspector.
	Inspectable() bool
	SetInspectable(value bool)

	// The page title.
	Title() string
	// The URL for the current webpage.
	URL() foundation.INSURL
	// The media type for the contents of the web view.
	MediaType() string
	SetMediaType(value string)
	// The custom user agent string.
	CustomUserAgent() string
	SetCustomUserAgent(value string)
	// The trust management object you use to evaluate trust for the current webpage.
	ServerTrust() security.SecTrustRef
	// A Boolean value that indicates whether the web view loaded all resources on the page through securely encrypted connections.
	HasOnlySecureContent() bool
	// The theme color that the system gets from the first valid meta tag in the webpage.
	ThemeColor() objc.ID
	// The color the web view displays behind the active page, visible when the user scrolls beyond the bounds of the page.
	UnderPageBackgroundColor() objc.ID
	SetUnderPageBackgroundColor(value objc.ID)

	// The scale factor by which the web view scales content relative to its bounds.
	PageZoom() float64
	SetPageZoom(value float64)
	// A Boolean value that indicates whether magnify gestures change the web view’s magnification.
	AllowsMagnification() bool
	SetAllowsMagnification(value bool)
	// The factor by which the page content is currently scaled.
	Magnification() float64
	SetMagnification(value float64)
	// Scales the page content and centers the result on the specified point.
	SetMagnificationCenteredAtPoint(magnification float64, point corefoundation.CGPoint)

	// Pauses playback of all media in the web view.
	PauseAllMediaPlaybackWithCompletionHandler(completionHandler VoidHandler)
	// Requests the playback status of media in the web view.
	RequestMediaPlaybackStateWithCompletionHandler(completionHandler WKMediaPlaybackStateHandler)
	// Changes whether the webpage is suspending playback of all media in the page.
	SetAllMediaPlaybackSuspendedCompletionHandler(suspended bool, completionHandler VoidHandler)
	// Closes all media the web view is presenting, including picture-in-picture video and fullscreen video.
	CloseAllMediaPresentationsWithCompletionHandler(completionHandler VoidHandler)

	// An enumeration case that indicates whether the webpage is using the camera to capture images or video.
	CameraCaptureState() WKMediaCaptureState
	// An enumeration case that indicates whether the webpage is using the microphone to capture audio.
	MicrophoneCaptureState() WKMediaCaptureState
	// Changes whether the webpage is using the camera to capture images or video.
	SetCameraCaptureStateCompletionHandler(state WKMediaCaptureState, completionHandler VoidHandler)
	// Changes whether the webpage is using the microphone to capture audio.
	SetMicrophoneCaptureStateCompletionHandler(state WKMediaCaptureState, completionHandler VoidHandler)

	// A Boolean value that indicates whether horizontal swipe gestures trigger backward and forward page navigation.
	AllowsBackForwardNavigationGestures() bool
	SetAllowsBackForwardNavigationGestures(value bool)
	// The web view’s back-forward list.
	BackForwardList() IWKBackForwardList
	// Navigates to the back item in the back-forward list.
	GoBackWithSender(sender objectivec.IObject)
	// Navigates to the back item in the back-forward list.
	GoBack() IWKNavigation
	// Navigates to the forward item in the back-forward list.
	GoForwardWithSender(sender objectivec.IObject)
	// Navigates to the forward item in the back-forward list.
	GoForward() IWKNavigation
	// Navigates to an item from the back-forward list and sets it as the current item.
	GoToBackForwardListItem(item IWKBackForwardListItem) IWKNavigation
	// A Boolean value that indicates whether there is a valid back item in the back-forward list.
	CanGoBack() bool
	// A Boolean value that indicates whether there is a valid forward item in the back-forward list.
	CanGoForward() bool
	// A Boolean value that determines whether pressing a link displays a preview of the destination for the link.
	AllowsLinkPreview() bool
	SetAllowsLinkPreview(value bool)
	// An object you use to capture the current state of interaction in a web view so that you can restore that state later to another web view.
	InteractionState() objectivec.IObject
	SetInteractionState(value objectivec.IObject)

	// Evaluates the specified JavaScript string.
	EvaluateJavaScriptCompletionHandler(javaScriptString string, completionHandler ObjectErrorHandler)

	// Returns the print operation object to use when printing the contents of the web view.
	PrintOperationWithPrintInfo(printInfo appkit.NSPrintInfo) appkit.NSPrintOperation

	FullscreenState() WKFullscreenState

	SetMinimumViewportInsetMaximumViewportInset(minimumViewportInset objectivec.IObject, maximumViewportInset objectivec.IObject)
	MinimumViewportInset() objectivec.IObject
	MaximumViewportInset() objectivec.IObject

	IsBlockedByScreenTime() bool
	WritingToolsActive() bool
	ObscuredContentInsets() objectivec.IObject
	SetObscuredContentInsets(value objectivec.IObject)

	FetchDataOfTypesCompletionHandler(dataTypes WKWebViewDataType, completionHandler DataErrorHandler)
	RestoreDataCompletionHandler(data foundation.INSData, completionHandler ErrorHandler)

	// Generates PDF data from the web view’s contents asynchronously.
	CreatePDFWithConfigurationCompletionHandler(pdfConfiguration IWKPDFConfiguration, completionHandler DataErrorHandler)
	// Creates a web archive of the web view’s contents asynchronously.
	CreateWebArchiveDataWithCompletionHandler(completionHandler DataErrorHandler)
	// Searches for the specified string in the web view’s content.
	FindStringWithConfigurationCompletionHandler(string_ string, configuration IWKFindConfiguration, completionHandler WKFindResultHandler)
}

An interface definition for the WKWebView class.

Creating a web view

  • [IWKWebView.InitWithFrameConfiguration]: Creates a web view and initializes it with the specified frame and configuration data.
  • [IWKWebView.Configuration]: The object that contains the configuration details for the web view.

Displaying native user interface elements

  • [IWKWebView.UIDelegate]: The object you use to integrate custom user interface elements, such as contextual menus or panels, into web view interactions.
  • [IWKWebView.SetUIDelegate]

Managing navigation between webpages

  • [IWKWebView.NavigationDelegate]: The object you use to manage navigation behavior for the web view.
  • [IWKWebView.SetNavigationDelegate]

Loading web content

  • [IWKWebView.LoadRequest]: Loads the web content that the specified URL request object references and navigates to that content.
  • [IWKWebView.LoadDataMIMETypeCharacterEncodingNameBaseURL]: Loads the content of the specified data object and navigates to it.
  • [IWKWebView.LoadHTMLStringBaseURL]: Loads the contents of the specified HTML string and navigates to it.
  • [IWKWebView.LoadFileRequestAllowingReadAccessToURL]: Loads the web content from the file the URL request object specifies and navigates to that content.
  • [IWKWebView.LoadFileURLAllowingReadAccessToURL]: Loads the web content from the specified file and navigates to it.
  • [IWKWebView.LoadSimulatedRequestResponseResponseData]: Loads the web content from the data you provide as if the data were the response to the request.
  • [IWKWebView.LoadSimulatedRequestResponseHTMLString]: Loads the web content from the HTML you provide as if the HTML were the response to the request.
  • [IWKWebView.Loading]: A Boolean value that indicates whether the view is currently loading content.
  • [IWKWebView.EstimatedProgress]: An estimate of what fraction of the current navigation has been loaded.

Managing the loading process

  • [IWKWebView.Reload]: Reloads the current webpage.
  • [IWKWebView.ReloadWithSender]: Reloads the current webpage.
  • [IWKWebView.ReloadFromOrigin]: Reloads the current webpage, and performs end-to-end revalidation of the content using cache-validating conditionals, if possible.
  • [IWKWebView.ReloadFromOriginWithSender]: Reloads the current webpage, and performs end-to-end revalidation of the content using cache-validating conditionals, if possible.
  • [IWKWebView.StopLoading]: Stops loading all resources on the current page.
  • [IWKWebView.StopLoadingWithSender]: Stops loading all resources on the current page.

Managing downloads

  • [IWKWebView.StartDownloadUsingRequestCompletionHandler]: Starts to download the resource at the URL in the request.
  • [IWKWebView.ResumeDownloadFromResumeDataCompletionHandler]: Resumes a failed or canceled download.

Making web content inspectable

  • [IWKWebView.Inspectable]: A Boolean value that indicates whether you can inspect the view with Safari Web Inspector.
  • [IWKWebView.SetInspectable]

Inspecting the view information

  • [IWKWebView.Title]: The page title.
  • [IWKWebView.URL]: The URL for the current webpage.
  • [IWKWebView.MediaType]: The media type for the contents of the web view.
  • [IWKWebView.SetMediaType]
  • [IWKWebView.CustomUserAgent]: The custom user agent string.
  • [IWKWebView.SetCustomUserAgent]
  • [IWKWebView.ServerTrust]: The trust management object you use to evaluate trust for the current webpage.
  • [IWKWebView.HasOnlySecureContent]: A Boolean value that indicates whether the web view loaded all resources on the page through securely encrypted connections.
  • [IWKWebView.ThemeColor]: The theme color that the system gets from the first valid meta tag in the webpage.
  • [IWKWebView.UnderPageBackgroundColor]: The color the web view displays behind the active page, visible when the user scrolls beyond the bounds of the page.
  • [IWKWebView.SetUnderPageBackgroundColor]

Scaling content

  • [IWKWebView.PageZoom]: The scale factor by which the web view scales content relative to its bounds.
  • [IWKWebView.SetPageZoom]
  • [IWKWebView.AllowsMagnification]: A Boolean value that indicates whether magnify gestures change the web view’s magnification.
  • [IWKWebView.SetAllowsMagnification]
  • [IWKWebView.Magnification]: The factor by which the page content is currently scaled.
  • [IWKWebView.SetMagnification]
  • [IWKWebView.SetMagnificationCenteredAtPoint]: Scales the page content and centers the result on the specified point.

Interacting with media

  • [IWKWebView.PauseAllMediaPlaybackWithCompletionHandler]: Pauses playback of all media in the web view.
  • [IWKWebView.RequestMediaPlaybackStateWithCompletionHandler]: Requests the playback status of media in the web view.
  • [IWKWebView.SetAllMediaPlaybackSuspendedCompletionHandler]: Changes whether the webpage is suspending playback of all media in the page.
  • [IWKWebView.CloseAllMediaPresentationsWithCompletionHandler]: Closes all media the web view is presenting, including picture-in-picture video and fullscreen video.

Managing the microphone and camera

  • [IWKWebView.CameraCaptureState]: An enumeration case that indicates whether the webpage is using the camera to capture images or video.
  • [IWKWebView.MicrophoneCaptureState]: An enumeration case that indicates whether the webpage is using the microphone to capture audio.
  • [IWKWebView.SetCameraCaptureStateCompletionHandler]: Changes whether the webpage is using the camera to capture images or video.
  • [IWKWebView.SetMicrophoneCaptureStateCompletionHandler]: Changes whether the webpage is using the microphone to capture audio.

Navigating between webpages

  • [IWKWebView.AllowsBackForwardNavigationGestures]: A Boolean value that indicates whether horizontal swipe gestures trigger backward and forward page navigation.
  • [IWKWebView.SetAllowsBackForwardNavigationGestures]
  • [IWKWebView.BackForwardList]: The web view’s back-forward list.
  • [IWKWebView.GoBackWithSender]: Navigates to the back item in the back-forward list.
  • [IWKWebView.GoBack]: Navigates to the back item in the back-forward list.
  • [IWKWebView.GoForwardWithSender]: Navigates to the forward item in the back-forward list.
  • [IWKWebView.GoForward]: Navigates to the forward item in the back-forward list.
  • [IWKWebView.GoToBackForwardListItem]: Navigates to an item from the back-forward list and sets it as the current item.
  • [IWKWebView.CanGoBack]: A Boolean value that indicates whether there is a valid back item in the back-forward list.
  • [IWKWebView.CanGoForward]: A Boolean value that indicates whether there is a valid forward item in the back-forward list.
  • [IWKWebView.AllowsLinkPreview]: A Boolean value that determines whether pressing a link displays a preview of the destination for the link.
  • [IWKWebView.SetAllowsLinkPreview]
  • [IWKWebView.InteractionState]: An object you use to capture the current state of interaction in a web view so that you can restore that state later to another web view.
  • [IWKWebView.SetInteractionState]

Executing JavaScript

  • [IWKWebView.EvaluateJavaScriptCompletionHandler]: Evaluates the specified JavaScript string.

Capturing the web view’s content

  • [IWKWebView.PrintOperationWithPrintInfo]: Returns the print operation object to use when printing the contents of the web view.

Handling full-screen transitions

  • [IWKWebView.FullscreenState]

Configuring viewport insets

  • [IWKWebView.SetMinimumViewportInsetMaximumViewportInset]
  • [IWKWebView.MinimumViewportInset]
  • [IWKWebView.MaximumViewportInset]

Instance Properties

  • [IWKWebView.IsBlockedByScreenTime]
  • [IWKWebView.WritingToolsActive]
  • [IWKWebView.ObscuredContentInsets]
  • [IWKWebView.SetObscuredContentInsets]

Instance Methods

  • [IWKWebView.FetchDataOfTypesCompletionHandler]
  • [IWKWebView.RestoreDataCompletionHandler]

See: https://developer.apple.com/documentation/WebKit/WKWebView

type IWKWebViewConfiguration

type IWKWebViewConfiguration interface {
	objectivec.IObject

	// The object you use to get and set the site’s cookies and to track the cached data objects.
	WebsiteDataStore() IWKWebsiteDataStore
	SetWebsiteDataStore(value IWKWebsiteDataStore)
	// The object that coordinates interactions between your app’s native code and the webpage’s scripts and other content.
	UserContentController() IWKUserContentController
	SetUserContentController(value IWKUserContentController)
	// The app name that appears in the user agent string.
	ApplicationNameForUserAgent() string
	SetApplicationNameForUserAgent(value string)
	// A Boolean value that indicates whether the web view limits navigation to pages within the app’s domain.
	LimitsNavigationsToAppBoundDomains() bool
	SetLimitsNavigationsToAppBoundDomains(value bool)
	// A Boolean value that indicates whether the web view should automatically upgrade supported HTTP requests to HTTPS.
	UpgradeKnownHostsToHTTPS() bool
	SetUpgradeKnownHostsToHTTPS(value bool)

	// The object that manages the preference-related settings for the web view.
	Preferences() IWKPreferences
	SetPreferences(value IWKPreferences)
	// The default preferences to use when loading and rendering content.
	DefaultWebpagePreferences() IWKWebpagePreferences
	SetDefaultWebpagePreferences(value IWKWebpagePreferences)

	// Registers an object to load resources associated with the specified URL scheme.
	SetURLSchemeHandlerForURLScheme(urlSchemeHandler WKURLSchemeHandler, urlScheme string)
	// Returns the currently registered handler object for the specified URL scheme.
	UrlSchemeHandlerForURLScheme(urlScheme string) WKURLSchemeHandler

	// A Boolean value that indicates whether the web view suppresses content rendering until the content is fully loaded into memory.
	SuppressesIncrementalRendering() bool
	SetSuppressesIncrementalRendering(value bool)

	// A Boolean value that indicates whether the web view allows media playback over AirPlay.
	AllowsAirPlayForMediaPlayback() bool
	SetAllowsAirPlayForMediaPlayback(value bool)
	// The media types that require a user gesture to begin playing.
	MediaTypesRequiringUserActionForPlayback() WKAudiovisualMediaTypes
	SetMediaTypesRequiringUserActionForPlayback(value WKAudiovisualMediaTypes)

	// The directionality of user interface elements.
	UserInterfaceDirectionPolicy() WKUserInterfaceDirectionPolicy
	SetUserInterfaceDirectionPolicy(value WKUserInterfaceDirectionPolicy)

	AllowsInlinePredictions() bool
	SetAllowsInlinePredictions(value bool)
	ShowsSystemScreenTimeBlockingView() bool
	SetShowsSystemScreenTimeBlockingView(value bool)
	SupportsAdaptiveImageGlyph() bool
	SetSupportsAdaptiveImageGlyph(value bool)
	WebExtensionController() IWKWebExtensionController
	SetWebExtensionController(value IWKWebExtensionController)
	WritingToolsBehavior() objectivec.IObject
	SetWritingToolsBehavior(value objectivec.IObject)

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the WKWebViewConfiguration class.

Configuring the web view’s behavior

  • [IWKWebViewConfiguration.WebsiteDataStore]: The object you use to get and set the site’s cookies and to track the cached data objects.
  • [IWKWebViewConfiguration.SetWebsiteDataStore]
  • [IWKWebViewConfiguration.UserContentController]: The object that coordinates interactions between your app’s native code and the webpage’s scripts and other content.
  • [IWKWebViewConfiguration.SetUserContentController]
  • [IWKWebViewConfiguration.ApplicationNameForUserAgent]: The app name that appears in the user agent string.
  • [IWKWebViewConfiguration.SetApplicationNameForUserAgent]
  • [IWKWebViewConfiguration.LimitsNavigationsToAppBoundDomains]: A Boolean value that indicates whether the web view limits navigation to pages within the app’s domain.
  • [IWKWebViewConfiguration.SetLimitsNavigationsToAppBoundDomains]
  • [IWKWebViewConfiguration.UpgradeKnownHostsToHTTPS]: A Boolean value that indicates whether the web view should automatically upgrade supported HTTP requests to HTTPS.
  • [IWKWebViewConfiguration.SetUpgradeKnownHostsToHTTPS]

Configuring the web view’s preferences

  • [IWKWebViewConfiguration.Preferences]: The object that manages the preference-related settings for the web view.
  • [IWKWebViewConfiguration.SetPreferences]
  • [IWKWebViewConfiguration.DefaultWebpagePreferences]: The default preferences to use when loading and rendering content.
  • [IWKWebViewConfiguration.SetDefaultWebpagePreferences]

Adding handlers for custom URL schemes

  • [IWKWebViewConfiguration.SetURLSchemeHandlerForURLScheme]: Registers an object to load resources associated with the specified URL scheme.
  • [IWKWebViewConfiguration.UrlSchemeHandlerForURLScheme]: Returns the currently registered handler object for the specified URL scheme.

Configuring the rendering behavior

  • [IWKWebViewConfiguration.SuppressesIncrementalRendering]: A Boolean value that indicates whether the web view suppresses content rendering until the content is fully loaded into memory.
  • [IWKWebViewConfiguration.SetSuppressesIncrementalRendering]

Setting media playback preferences

  • [IWKWebViewConfiguration.AllowsAirPlayForMediaPlayback]: A Boolean value that indicates whether the web view allows media playback over AirPlay.
  • [IWKWebViewConfiguration.SetAllowsAirPlayForMediaPlayback]
  • [IWKWebViewConfiguration.MediaTypesRequiringUserActionForPlayback]: The media types that require a user gesture to begin playing.
  • [IWKWebViewConfiguration.SetMediaTypesRequiringUserActionForPlayback]

Selecting user interface directionality

  • [IWKWebViewConfiguration.UserInterfaceDirectionPolicy]: The directionality of user interface elements.
  • [IWKWebViewConfiguration.SetUserInterfaceDirectionPolicy]

Instance Properties

  • [IWKWebViewConfiguration.AllowsInlinePredictions]
  • [IWKWebViewConfiguration.SetAllowsInlinePredictions]
  • [IWKWebViewConfiguration.ShowsSystemScreenTimeBlockingView]
  • [IWKWebViewConfiguration.SetShowsSystemScreenTimeBlockingView]
  • [IWKWebViewConfiguration.SupportsAdaptiveImageGlyph]
  • [IWKWebViewConfiguration.SetSupportsAdaptiveImageGlyph]
  • [IWKWebViewConfiguration.WebExtensionController]
  • [IWKWebViewConfiguration.SetWebExtensionController]
  • [IWKWebViewConfiguration.WritingToolsBehavior]
  • [IWKWebViewConfiguration.SetWritingToolsBehavior]

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration

type IWKWebpagePreferences

type IWKWebpagePreferences interface {
	objectivec.IObject

	// A Boolean value that indicates whether JavaScript from web content is allowed to run.
	AllowsContentJavaScript() bool
	SetAllowsContentJavaScript(value bool)

	// The content mode for the web view to use when it loads and renders a webpage.
	PreferredContentMode() WKContentMode
	SetPreferredContentMode(value WKContentMode)

	// A Boolean value that indicates whether to use Lockdown Mode in the web view.
	LockdownModeEnabled() bool
	SetLockdownModeEnabled(value bool)

	PreferredHTTPSNavigationPolicy() WKWebpagePreferencesUpgradeToHTTPSPolicy
	SetPreferredHTTPSNavigationPolicy(value WKWebpagePreferencesUpgradeToHTTPSPolicy)

	SecurityRestrictionMode() WKSecurityRestrictionMode
	SetSecurityRestrictionMode(value WKSecurityRestrictionMode)
}

An interface definition for the WKWebpagePreferences class.

Setting the JavaScript preferences

  • [IWKWebpagePreferences.AllowsContentJavaScript]: A Boolean value that indicates whether JavaScript from web content is allowed to run.
  • [IWKWebpagePreferences.SetAllowsContentJavaScript]

Setting the preferred content mode

  • [IWKWebpagePreferences.PreferredContentMode]: The content mode for the web view to use when it loads and renders a webpage.
  • [IWKWebpagePreferences.SetPreferredContentMode]

Getting Lockdown Mode info

  • [IWKWebpagePreferences.LockdownModeEnabled]: A Boolean value that indicates whether to use Lockdown Mode in the web view.
  • [IWKWebpagePreferences.SetLockdownModeEnabled]

Instance Properties

  • [IWKWebpagePreferences.PreferredHTTPSNavigationPolicy]
  • [IWKWebpagePreferences.SetPreferredHTTPSNavigationPolicy]

See: https://developer.apple.com/documentation/WebKit/WKWebpagePreferences

type IWKWebsiteDataRecord

type IWKWebsiteDataRecord interface {
	objectivec.IObject

	// The display name for the data record.
	DisplayName() string

	// The types of data associated with the record.
	DataTypes() foundation.INSSet

	// The local files WebKit can access when loading content.
	ReadAccessURL() foundation.NSString
}

An interface definition for the WKWebsiteDataRecord class.

Getting the Record Information

  • [IWKWebsiteDataRecord.DisplayName]: The display name for the data record.

Getting the Data Type

  • [IWKWebsiteDataRecord.DataTypes]: The types of data associated with the record.

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataRecord

type IWKWebsiteDataStore

type IWKWebsiteDataStore interface {
	objectivec.IObject

	// An identifier that uniquely identifies a data store.
	Identifier() foundation.NSUUID
	// A Boolean value that indicates whether this object stores data to disk.
	Persistent() bool

	// The object that manages the HTTP cookies for your website.
	HttpCookieStore() IWKHTTPCookieStore

	// Removes the specified types of website data from one or more data records.
	RemoveDataOfTypesForDataRecordsCompletionHandler(dataTypes foundation.INSSet, dataRecords []WKWebsiteDataRecord, completionHandler VoidHandler)
	// Removes website data that changed after the specified date.
	RemoveDataOfTypesModifiedSinceCompletionHandler(dataTypes foundation.INSSet, date foundation.INSDate, completionHandler VoidHandler)

	FetchDataOfTypesCompletionHandler(dataTypes foundation.INSSet, completionHandler DataErrorHandler)
	RestoreDataCompletionHandler(data foundation.INSData, completionHandler ErrorHandler)

	ProxyConfigurations() []objectivec.Object
	SetProxyConfigurations(value []objectivec.Object)
	// The local files WebKit can access when loading content.
	ReadAccessURL() foundation.NSString
	// The object you use to get and set the site’s cookies and to track the cached data objects.
	WebsiteDataStore() IWKWebsiteDataStore
	SetWebsiteDataStore(value IWKWebsiteDataStore)
	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the WKWebsiteDataStore class.

Inspecting data store properties

  • [IWKWebsiteDataStore.Identifier]: An identifier that uniquely identifies a data store.
  • [IWKWebsiteDataStore.Persistent]: A Boolean value that indicates whether this object stores data to disk.
  • [IWKWebsiteDataStore.HttpCookieStore]: The object that manages the HTTP cookies for your website.

Removing specific types of data

  • [IWKWebsiteDataStore.RemoveDataOfTypesForDataRecordsCompletionHandler]: Removes the specified types of website data from one or more data records.
  • [IWKWebsiteDataStore.RemoveDataOfTypesModifiedSinceCompletionHandler]: Removes website data that changed after the specified date.

Instance Methods

  • [IWKWebsiteDataStore.FetchDataOfTypesCompletionHandler]
  • [IWKWebsiteDataStore.RestoreDataCompletionHandler]

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataStore

type IWKWindowFeatures

type IWKWindowFeatures interface {
	objectivec.IObject

	// A Boolean value that indicates whether to make the containing window window resizable.
	AllowsResizing() foundation.NSNumber
	// The requested height of the containing window.
	Height() foundation.NSNumber
	// The requested width of the containing window.
	Width() foundation.NSNumber
	// The requested x-coordinate of the containing window.
	X() foundation.NSNumber
	// The requested y-coordinate of the containing window.
	Y() foundation.NSNumber

	// A Boolean value that indicates whether the webpage requests a visible menu bar.
	MenuBarVisibility() foundation.NSNumber
	// A Boolean value that indicates whether the webpage requested a visible status bar.
	StatusBarVisibility() foundation.NSNumber
	// A Boolean value that indicates whether the webpage requested a visible toolbar.
	ToolbarsVisibility() foundation.NSNumber
}

An interface definition for the WKWindowFeatures class.

Inspecting Window Position and Dimensions

  • [IWKWindowFeatures.AllowsResizing]: A Boolean value that indicates whether to make the containing window window resizable.
  • [IWKWindowFeatures.Height]: The requested height of the containing window.
  • [IWKWindowFeatures.Width]: The requested width of the containing window.
  • [IWKWindowFeatures.X]: The requested x-coordinate of the containing window.
  • [IWKWindowFeatures.Y]: The requested y-coordinate of the containing window.

Inspecting Visibility Properties

  • [IWKWindowFeatures.MenuBarVisibility]: A Boolean value that indicates whether the webpage requests a visible menu bar.
  • [IWKWindowFeatures.StatusBarVisibility]: A Boolean value that indicates whether the webpage requested a visible status bar.
  • [IWKWindowFeatures.ToolbarsVisibility]: A Boolean value that indicates whether the webpage requested a visible toolbar.

See: https://developer.apple.com/documentation/WebKit/WKWindowFeatures

type IWebResource

type IWebResource interface {
	objectivec.IObject

	// Initializes and returns a web resource instance.
	InitWithDataURLMIMETypeTextEncodingNameFrameName(data foundation.INSData, URL foundation.INSURL, MIMEType string, textEncodingName string, frameName string) WebResource

	// The receiver’s data.
	Data() foundation.INSData
	// The receiver’s URL.
	URL() foundation.INSURL
	// The receiver’s MIME type.
	MIMEType() string
	// The receiver’s text encoding name.
	TextEncodingName() string
	// The name of the frame. If the receiver does not represent the contents of an entire HTML frame, this is `nil`.
	FrameName() string

	EncodeWithCoder(coder foundation.INSCoder)
}

An interface definition for the WebResource class.

Initializing

  • [IWebResource.InitWithDataURLMIMETypeTextEncodingNameFrameName]: Initializes and returns a web resource instance.

Getting attributes

  • [IWebResource.Data]: The receiver’s data.
  • [IWebResource.URL]: The receiver’s URL.
  • [IWebResource.MIMEType]: The receiver’s MIME type.
  • [IWebResource.TextEncodingName]: The receiver’s text encoding name.
  • [IWebResource.FrameName]: The name of the frame. If the receiver does not represent the contents of an entire HTML frame, this is `nil`.

See: https://developer.apple.com/documentation/WebKit/WebResource

type LocaleErrorHandler

type LocaleErrorHandler = func(*foundation.NSLocale, error)

LocaleErrorHandler handles A block that must be called upon completion. The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.

Used by:

  • [WKWebExtensionTab.DetectWebpageLocaleForWebExtensionContextCompletionHandler]

type NSHTTPCookieArrayHandler

type NSHTTPCookieArrayHandler = func(*[]foundation.NSHTTPCookie)

NSHTTPCookieArrayHandler handles A completion handler block to execute asynchronously with the results.

  • cookieArray: An array of [HTTPCookie](<doc://com.apple.documentation/documentation/Foundation/HTTPCookie>) objects. If the store contains no cookies, this parameter contains an empty array.

Used by:

  • [WKHTTPCookieStore.GetAllCookies]

type NSURLArrayHandler

type NSURLArrayHandler = func(*[]foundation.NSURL)

NSURLArrayHandler handles The completion handler the system calls after a person dismisses the open panel.

Used by:

  • [WKUIDelegate.WebViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler]

type NSUUIDArrayHandler

type NSUUIDArrayHandler = func(*[]foundation.NSUUID)

NSUUIDArrayHandler handles A block to invoke with the fetched list of unique identifiers.

Used by:

  • [WKWebsiteDataStore.FetchAllDataStoreIdentifiers]

type ObjectErrorHandler

type ObjectErrorHandler = func(objectivec.IObject, error)

ObjectErrorHandler handles A handler block to execute when script evaluation finishes.

  • object: The result of the script evaluation, or `nil` if an error occurred.
  • error: `nil` on success, or an error object with information about the problem.

The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.

Used by:

type StringHandler

type StringHandler = func(*string)

StringHandler handles A reply handler block to execute with the response to send back to the webpage.

  • reply: An object that contains the data to return to the webpage. Allowed types for this parameter are [NSNumber](<doc://com.apple.documentation/documentation/Foundation/NSNumber>), [NSString](<doc://com.apple.documentation/documentation/Foundation/NSString>), [NSDate](<doc://com.apple.documentation/documentation/Foundation/NSDate>), [NSArray](<doc://com.apple.documentation/documentation/Foundation/NSArray>), [NSDictionary](<doc://com.apple.documentation/documentation/Foundation/NSDictionary>), and [NSNull](<doc://com.apple.documentation/documentation/Foundation/NSNull>). Specify `nil` if an error occurred.
  • errorMessage: `nil` on success, or a string that describes the error that occurred.

Used by:

  • [WKScriptMessageHandlerWithReply.UserContentControllerDidReceiveScriptMessageReplyHandler]
  • [WKUIDelegate.WebViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler]

type StringSetDateHandler

type StringSetDateHandler = func(*foundation.INSSet, *foundation.NSDate)

StringSetDateHandler handles A block to be called with the set of allowed permissions and an optional expiration date.

Used by:

  • [WKWebExtensionControllerDelegate.WebExtensionControllerPromptForPermissionsInTabForExtensionContextCompletionHandler]

type UIContextMenuConfigurationHandler

type UIContextMenuConfigurationHandler = func(*objectivec.Object)

UIContextMenuConfigurationHandler handles The completion handler for you to call with information about how you want to handle the interaction.

  • configuration: The [UIContextMenuConfiguration](<doc://com.apple.documentation/documentation/UIKit/UIContextMenuConfiguration>) object that contains the details of how you want to handle the interaction. Specify `nil` for this parameter if you don’t want to show a contextual menu.

Used by:

  • [WKUIDelegate.WebViewContextMenuConfigurationForElementCompletionHandler]

type UIImageErrorHandler

type UIImageErrorHandler = func(*objc.ID, error)

UIImageErrorHandler handles The completion handler to call when the image is ready.

  • snapshotImage: A platform-native image that contains the specified portion of the web view.
  • error: An error object if a problem occurred, or `nil` on success.

Used by:

  • [WKWebExtensionTab.TakeSnapshotUsingConfigurationForWebExtensionContextCompletionHandler]
  • [WKWebView.TakeSnapshotWithConfigurationCompletionHandler]

type URLCredentialHandler

type URLCredentialHandler = func(*foundation.NSURLCredential)

URLCredentialHandler handles A closure you must invoke to respond to the authentication challenge.

  • disposition: The option to use to handle the challenge. For a list of options, see [URLSession.AuthChallengeDisposition](<doc://com.apple.documentation/documentation/Foundation/URLSession/AuthChallengeDisposition>).
  • credential: The credential to use for authentication when the `disposition` parameter contains the value [URLSession.AuthChallengeDisposition.useCredential](<doc://com.apple.documentation/documentation/Foundation/URLSession/AuthChallengeDisposition/useCredential>). Specify `nil` to continue without a credential.

Used by:

  • [WKDownloadDelegate.DownloadDidReceiveAuthenticationChallengeCompletionHandler]
  • [WKNavigationDelegate.WebViewDidReceiveAuthenticationChallengeCompletionHandler]

type URLHandler

type URLHandler = func(*foundation.NSURL)

URLHandler handles A closure you invoke with a destination file URL to begin the download, or `nil` to cancel the download.

Used by:

  • [WKDownloadDelegate.DownloadDecideDestinationUsingResponseSuggestedFilenameCompletionHandler]
  • [WKDownloadDelegate.DownloadDecidePlaceholderPolicy]

type URLSetDateHandler

type URLSetDateHandler = func(*foundation.INSSet, *foundation.NSDate)

URLSetDateHandler handles A block to be called with the set of allowed URLs and an optional expiration date.

Used by:

  • [WKWebExtensionControllerDelegate.WebExtensionControllerPromptForPermissionToAccessURLsInTabForExtensionContextCompletionHandler]

type VoidHandler

type VoidHandler = func()

VoidHandler handles A completion handler block to call with the results.

  • identifierArray: An array of strings, each of which corresponds to an identifier for a rule list in the data store. Use each string to look up the associated WKContentRuleList(<doc://com.apple.webkit/documentation/WebKit/WKContentRuleList>) object. If the data store has no rule lists, the array is empty.

Used by:

type WKAudiovisualMediaTypes

type WKAudiovisualMediaTypes uint

See: https://developer.apple.com/documentation/WebKit/WKAudiovisualMediaTypes

const (
	// WKAudiovisualMediaTypeAll: All media types require a user gesture to begin playing.
	WKAudiovisualMediaTypeAll WKAudiovisualMediaTypes = 0
	// WKAudiovisualMediaTypeAudio: Media types that contain audio require a user gesture to begin playing.
	WKAudiovisualMediaTypeAudio WKAudiovisualMediaTypes = 1
	// WKAudiovisualMediaTypeNone: No media types require a user gesture to begin playing.
	WKAudiovisualMediaTypeNone WKAudiovisualMediaTypes = 0
	// WKAudiovisualMediaTypeVideo: Media types that contain video require a user gesture to begin playing.
	WKAudiovisualMediaTypeVideo WKAudiovisualMediaTypes = 2
)

func (WKAudiovisualMediaTypes) String

func (e WKAudiovisualMediaTypes) String() string

type WKBackForwardList

type WKBackForwardList struct {
	objectivec.Object
}

An object that manages the list of previously loaded webpages, which the web view uses for forward and backward navigation.

Overview

Use a WKBackForwardList object to retrieve a web view’s previously loaded pages. Typically, you don’t create WKBackForwardList objects directly. Each web view creates one automatically and uses it to store the history of all loaded pages. Fetch this object from your web view’s [BackForwardList] property and use its contents to facilitate programmatic navigation.

Getting the Most Recent Items

Getting Specific Items in the List

Getting Sublists

See: https://developer.apple.com/documentation/WebKit/WKBackForwardList

func NewWKBackForwardList

func NewWKBackForwardList() WKBackForwardList

NewWKBackForwardList creates a new WKBackForwardList instance.

func WKBackForwardListFromID

func WKBackForwardListFromID(id objc.ID) WKBackForwardList

WKBackForwardListFromID constructs a WKBackForwardList from an objc.ID.

An object that manages the list of previously loaded webpages, which the web view uses for forward and backward navigation.

func (WKBackForwardList) Autorelease

func (b WKBackForwardList) Autorelease() WKBackForwardList

Autorelease adds the receiver to the current autorelease pool.

func (WKBackForwardList) BackForwardList

func (b WKBackForwardList) BackForwardList() IWKBackForwardList

The web view’s back-forward list.

See: https://developer.apple.com/documentation/webkit/wkwebview/backforwardlist

func (WKBackForwardList) BackItem

The item immediately preceding the current item, if any.

Discussion

If the current item is the first item in the list, the value in this property is `nil`.

See: https://developer.apple.com/documentation/WebKit/WKBackForwardList/backItem

func (WKBackForwardList) BackList

The array of items that precede the current item.

Discussion

The items are in the order in which the web view originally visited them.

See: https://developer.apple.com/documentation/WebKit/WKBackForwardList/backList

func (WKBackForwardList) ForwardItem

func (b WKBackForwardList) ForwardItem() IWKBackForwardListItem

The item immediately following the current item, if any.

Discussion

If the current item is the last item in the list, this value in this property is `nil`.

See: https://developer.apple.com/documentation/WebKit/WKBackForwardList/forwardItem

func (WKBackForwardList) ForwardList

func (b WKBackForwardList) ForwardList() []WKBackForwardListItem

The array of items that follow the current item.

Discussion

The items are in the order in which the web view originally visited them.

See: https://developer.apple.com/documentation/WebKit/WKBackForwardList/forwardList

func (WKBackForwardList) Init

Init initializes the instance.

func (WKBackForwardList) ItemAtIndex

func (b WKBackForwardList) ItemAtIndex(index int) IWKBackForwardListItem

Returns the item at the relative offset from the current item.

index: The offset of the desired item from the current item. Specify `0` for the current item, `-1` for the immediately preceding item, `1` for the immediately following item, and so on.

Return Value

The item at the specified offset from the current item, or `nil` if the `index` exceeds the limits of the list.

See: https://developer.apple.com/documentation/WebKit/WKBackForwardList/item(at:)

func (WKBackForwardList) SetBackForwardList

func (b WKBackForwardList) SetBackForwardList(value IWKBackForwardList)

type WKBackForwardListClass

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

func GetWKBackForwardListClass

func GetWKBackForwardListClass() WKBackForwardListClass

GetWKBackForwardListClass returns the class object for WKBackForwardList.

func (WKBackForwardListClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKBackForwardListClass) Class

func (wc WKBackForwardListClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKBackForwardListItem

type WKBackForwardListItem struct {
	objectivec.Object
}

A representation of a webpage that the web view previously visited.

Overview

Use a WKBackForwardListItem object to get information about previously visited webpages. This object identifies the page’s title and URL. It also identifes the URL that requested the webpage.

You don’t create WKBackForwardListItem objects directly. Instead, a WKBackForwardList object creates them in conjunction with its associated web view when the web view loads new pages.

Getting the Page-Specific Information

Getting the Requesting Page

See: https://developer.apple.com/documentation/WebKit/WKBackForwardListItem

func NewWKBackForwardListItem

func NewWKBackForwardListItem() WKBackForwardListItem

NewWKBackForwardListItem creates a new WKBackForwardListItem instance.

func WKBackForwardListItemFromID

func WKBackForwardListItemFromID(id objc.ID) WKBackForwardListItem

WKBackForwardListItemFromID constructs a WKBackForwardListItem from an objc.ID.

A representation of a webpage that the web view previously visited.

func (WKBackForwardListItem) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKBackForwardListItem) Init

Init initializes the instance.

func (WKBackForwardListItem) InitialURL

func (b WKBackForwardListItem) InitialURL() foundation.INSURL

The source URL that originally asked the web view to load this page.

See: https://developer.apple.com/documentation/WebKit/WKBackForwardListItem/initialURL

func (WKBackForwardListItem) Title

func (b WKBackForwardListItem) Title() string

The title of the webpage this item represents.

See: https://developer.apple.com/documentation/WebKit/WKBackForwardListItem/title

func (WKBackForwardListItem) URL

The URL of the webpage this item represents.

See: https://developer.apple.com/documentation/WebKit/WKBackForwardListItem/url

type WKBackForwardListItemClass

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

func GetWKBackForwardListItemClass

func GetWKBackForwardListItemClass() WKBackForwardListItemClass

GetWKBackForwardListItemClass returns the class object for WKBackForwardListItem.

func (WKBackForwardListItemClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKBackForwardListItemClass) Class

Class returns the underlying Objective-C class pointer.

type WKContentMode

type WKContentMode int

See: https://developer.apple.com/documentation/WebKit/WKWebpagePreferences/ContentMode

const (
	// WKContentModeDesktop: The content mode that represents a desktop experience.
	WKContentModeDesktop WKContentMode = 2
	// WKContentModeMobile: The content mode that represents a mobile experience.
	WKContentModeMobile WKContentMode = 1
	// WKContentModeRecommended: The content mode that is appropriate for the current device.
	WKContentModeRecommended WKContentMode = 0
)

func (WKContentMode) String

func (e WKContentMode) String() string

type WKContentRuleList

type WKContentRuleList struct {
	objectivec.Object
}

A compiled list of rules to apply to web content.

Overview

A WKContentRuleList object represents a compiled set of rules for modifying how a webpage loads content. You don’t create a WKContentRuleList directly. Instead, you specify your rules in JSON format and compile them using the [CompileContentRuleListForIdentifierEncodedContentRuleListCompletionHandler] method of WKContentRuleListStore. That method compiles your rules into an efficient byte format and returns them in an instance of this class.

Content rule lists use the same syntax as content blocker extensions in Safari. For more information on how to specify the JSON for your rule lists, see Creating a content blocker.

Getting the Rules List Identifier

See: https://developer.apple.com/documentation/WebKit/WKContentRuleList

func NewWKContentRuleList

func NewWKContentRuleList() WKContentRuleList

NewWKContentRuleList creates a new WKContentRuleList instance.

func WKContentRuleListFromID

func WKContentRuleListFromID(id objc.ID) WKContentRuleList

WKContentRuleListFromID constructs a WKContentRuleList from an objc.ID.

A compiled list of rules to apply to web content.

func (WKContentRuleList) Autorelease

func (c WKContentRuleList) Autorelease() WKContentRuleList

Autorelease adds the receiver to the current autorelease pool.

func (WKContentRuleList) Identifier

func (c WKContentRuleList) Identifier() string

The identifier for the rule list.

Discussion

You specify the identifier for your rule lists at compile time in the [CompileContentRuleListForIdentifierEncodedContentRuleListCompletionHandler] method of WKContentRuleListStore. You also use this identifier to look up the rules list later.

See: https://developer.apple.com/documentation/WebKit/WKContentRuleList/identifier

func (WKContentRuleList) Init

Init initializes the instance.

type WKContentRuleListClass

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

func GetWKContentRuleListClass

func GetWKContentRuleListClass() WKContentRuleListClass

GetWKContentRuleListClass returns the class object for WKContentRuleList.

func (WKContentRuleListClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKContentRuleListClass) Class

func (wc WKContentRuleListClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKContentRuleListErrorHandler

type WKContentRuleListErrorHandler = func(*WKContentRuleList, error)

WKContentRuleListErrorHandler handles A completion handler block to call after compilation finishes.

  • ruleList: The WKContentRuleList(<doc://com.apple.webkit/documentation/WebKit/WKContentRuleList>) object that encapsulates the compiled rules derived from the `encodedContentRuleList` parameter. This parameter is `nil` if an error occurs during compilation.
  • error: `nil` on success, or an error object if a problem occurred.

The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.

Used by:

type WKContentRuleListStore

type WKContentRuleListStore struct {
	objectivec.Object
}

An object that contains the rules for how to load and filter content in the web view.

Overview

Use a WKContentRuleListStore to compile and manage rules for filtering content in a web view. Rule lists act as content blockers inside your app. You use them to prevent the web view from loading specific content, either based on the original location of that content or other criteria you specify. For example, a corporate app might use rules to prevent the web view from loading content that originates from outside the corporate network.

Fetch the default WKContentRuleListStore object or create a custom store object and use it to compile or access the available rules. Each store object stores its existing rules persistently in the file system and loads those rules at creation time. A store object doesn’t automatically apply any of its rules to a particular web view. To apply a rule to a web view, add it to the WKUserContentController object of the web view’s configuration object.

Creating and Deleting Content Rule Lists

Accessing the Current Rule Lists

See: https://developer.apple.com/documentation/WebKit/WKContentRuleListStore

func NewContentRuleListStoreWithURL

func NewContentRuleListStoreWithURL(url foundation.INSURL) WKContentRuleListStore

Creates a new content rule list store in the specified directory.

url: A URL that specifies a directory. The returned object uses this directory to store its content rules persistently. For example, you might store your app-specific rules in your app’s container directory.

Return Value

A content rule store associated with the specified directory.

Discussion

If the specified directory already contains compiled rule lists, this method loads those rules and adds them to the returned object. If you change any rules after creating this object, the store saves those changes to the same directory.

See: https://developer.apple.com/documentation/WebKit/WKContentRuleListStore/init(url:)

func NewWKContentRuleListStore

func NewWKContentRuleListStore() WKContentRuleListStore

NewWKContentRuleListStore creates a new WKContentRuleListStore instance.

func WKContentRuleListStoreFromID

func WKContentRuleListStoreFromID(id objc.ID) WKContentRuleListStore

WKContentRuleListStoreFromID constructs a WKContentRuleListStore from an objc.ID.

An object that contains the rules for how to load and filter content in the web view.

func (WKContentRuleListStore) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKContentRuleListStore) CompileContentRuleListForIdentifierEncodedContentRuleList

func (c WKContentRuleListStore) CompileContentRuleListForIdentifierEncodedContentRuleList(ctx context.Context, identifier string, encodedContentRuleList string) (*WKContentRuleList, error)

CompileContentRuleListForIdentifierEncodedContentRuleList is a synchronous wrapper around WKContentRuleListStore.CompileContentRuleListForIdentifierEncodedContentRuleListCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKContentRuleListStore) CompileContentRuleListForIdentifierEncodedContentRuleListCompletionHandler

func (c WKContentRuleListStore) CompileContentRuleListForIdentifierEncodedContentRuleListCompletionHandler(identifier string, encodedContentRuleList string, completionHandler WKContentRuleListErrorHandler)

Compiles the specified JSON content into a new rule list and adds it to the current data store.

identifier: A unique identifier for the new list. If a list with the specified identifier already exists in the store, this method overwrites the old rule list with the new content.

encodedContentRuleList: The JSON source for the new rule list. For information about how to format the JSON content, see Creating a content blocker.

completionHandler: A completion handler block to call after compilation finishes. This block has no return value and takes the following parameters:

ruleList: The WKContentRuleList object that encapsulates the compiled rules derived from the `encodedContentRuleList` parameter. This parameter is `nil` if an error occurs during compilation. error: `nil` on success, or an error object if a problem occurred.

See: https://developer.apple.com/documentation/WebKit/WKContentRuleListStore/compileContentRuleList(forIdentifier:encodedContentRuleList:completionHandler:)

func (WKContentRuleListStore) GetAvailableContentRuleListIdentifiers

func (c WKContentRuleListStore) GetAvailableContentRuleListIdentifiers(completionHandler VoidHandler)

Fetches the identifiers for all rule lists in the store asynchronously.

completionHandler: A completion handler block to call with the results. This block has no return value and takes the following parameter:

identifierArray: An array of strings, each of which corresponds to an identifier for a rule list in the data store. Use each string to look up the associated WKContentRuleList object. If the data store has no rule lists, the array is empty.

See: https://developer.apple.com/documentation/WebKit/WKContentRuleListStore/getAvailableContentRuleListIdentifiers(_:)

func (WKContentRuleListStore) GetAvailableContentRuleListIdentifiersSync

func (c WKContentRuleListStore) GetAvailableContentRuleListIdentifiersSync(ctx context.Context) error

GetAvailableContentRuleListIdentifiersSync is a synchronous wrapper around WKContentRuleListStore.GetAvailableContentRuleListIdentifiers. It blocks until the completion handler fires or the context is cancelled.

func (WKContentRuleListStore) Init

Init initializes the instance.

func (WKContentRuleListStore) LookUpContentRuleListForIdentifier

func (c WKContentRuleListStore) LookUpContentRuleListForIdentifier(ctx context.Context, identifier string) (*WKContentRuleList, error)

LookUpContentRuleListForIdentifier is a synchronous wrapper around WKContentRuleListStore.LookUpContentRuleListForIdentifierCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKContentRuleListStore) LookUpContentRuleListForIdentifierCompletionHandler

func (c WKContentRuleListStore) LookUpContentRuleListForIdentifierCompletionHandler(identifier string, completionHandler WKContentRuleListErrorHandler)

Searches asynchronously for a specific rule list in the data store.

identifier: The identifier of the list you want.

completionHandler: A completion handler block to call with the results of the search. This block has no return value and takes the following parameters:

ruleList: The WKContentRuleList object with the specified identifier. This parameter is `nil` if the error occurs during the search. error: `nil` on success, or an error object if an error occurs during the search.

See: https://developer.apple.com/documentation/WebKit/WKContentRuleListStore/lookUpContentRuleList(forIdentifier:completionHandler:)

func (WKContentRuleListStore) RemoveContentRuleListForIdentifier

func (c WKContentRuleListStore) RemoveContentRuleListForIdentifier(ctx context.Context, identifier string) error

RemoveContentRuleListForIdentifier is a synchronous wrapper around WKContentRuleListStore.RemoveContentRuleListForIdentifierCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKContentRuleListStore) RemoveContentRuleListForIdentifierCompletionHandler

func (c WKContentRuleListStore) RemoveContentRuleListForIdentifierCompletionHandler(identifier string, completionHandler ErrorHandler)

Removes a rule list from the current data store asynchronously.

identifier: The unique identifier for the rule list.

completionHandler: A completion handler block to call after the removal of the content rule list. This block has no return value and takes the following parameter:

error: `nil` on success, or an error object if the store encountered an error when deleting the rule list.

Discussion

This method also removes the persistent copy of the rules stored on disk.

See: https://developer.apple.com/documentation/WebKit/WKContentRuleListStore/removeContentRuleList(forIdentifier:completionHandler:)

type WKContentRuleListStoreClass

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

func GetWKContentRuleListStoreClass

func GetWKContentRuleListStoreClass() WKContentRuleListStoreClass

GetWKContentRuleListStoreClass returns the class object for WKContentRuleListStore.

func (WKContentRuleListStoreClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKContentRuleListStoreClass) Class

Class returns the underlying Objective-C class pointer.

func (WKContentRuleListStoreClass) DefaultStore

func (_WKContentRuleListStoreClass WKContentRuleListStoreClass) DefaultStore() WKContentRuleListStore

Returns the default content rule list store.

Return Value

The default rule list store.

Discussion

The default store contains the rules that your app created specifically for the current user.

See: https://developer.apple.com/documentation/WebKit/WKContentRuleListStore/default()

type WKContentWorld

type WKContentWorld struct {
	objectivec.Object
}

An object that defines a scope of execution for JavaScript code, and which you use to prevent conflicts between different scripts.

Overview

Use a WKContentWorld object as a namespace to separate your app’s web environment from the environment of individual webpages or scripts you execute. Content worlds help prevent issues that occur when two scripts modify environment variables in conflicting ways. Executing a script in its own content world effectively gives it a separate copy of the environment variables to modify. You might use this support in the following scenarios:

- You have complex script logic to bridge your web content to your app, but your web content has complex script libraries of its own. In that scenario, use one content world for your app-specific scripts and a separate content world for your content-specific scripts. - You implement a web browser that supports JavaScript extensions. In that scenario, create a unique content world for each extension to prevent conflicts between the extensions.

A WKContentWorld object is a namespace and doesn’t persist data outside of the current web view or webpage. If you use the same content world in two WKWebView objects, variables in one web view’s content world don’t appear in the other web view. Similarly, when the user or your app navigates to a new webpage, variables from the previous page are gone, even if both pages share the same content world.

Use the methods and properties of this class to fetch the content world you need. WKContentWorld provides a default content world for your app and a content world for the current web page. You can also create new content worlds. For example, you might create a custom content world for each JavaScript extension you manage. Specify the content world object when configuring or executing scripts associated with your content.

Retrieving a Custom Content World

See: https://developer.apple.com/documentation/WebKit/WKContentWorld

func NewWKContentWorld

func NewWKContentWorld() WKContentWorld

NewWKContentWorld creates a new WKContentWorld instance.

func WKContentWorldFromID

func WKContentWorldFromID(id objc.ID) WKContentWorld

WKContentWorldFromID constructs a WKContentWorld from an objc.ID.

An object that defines a scope of execution for JavaScript code, and which you use to prevent conflicts between different scripts.

func (WKContentWorld) Autorelease

func (c WKContentWorld) Autorelease() WKContentWorld

Autorelease adds the receiver to the current autorelease pool.

func (WKContentWorld) Init

func (c WKContentWorld) Init() WKContentWorld

Init initializes the instance.

func (WKContentWorld) Name

func (c WKContentWorld) Name() string

The name of a custom content world.

Discussion

This property contains a valid string only for content worlds you retrieve using the [WorldWithName] function. The value of this property is `nil` for the content worlds in the [DefaultClientWorld] and [PageWorld] properties.

See: https://developer.apple.com/documentation/WebKit/WKContentWorld/name

type WKContentWorldClass

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

func GetWKContentWorldClass

func GetWKContentWorldClass() WKContentWorldClass

GetWKContentWorldClass returns the class object for WKContentWorld.

func (WKContentWorldClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKContentWorldClass) Class

func (wc WKContentWorldClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (WKContentWorldClass) DefaultClientWorld

func (_WKContentWorldClass WKContentWorldClass) DefaultClientWorld() WKContentWorld

The default world for clients.

See: https://developer.apple.com/documentation/WebKit/WKContentWorld/defaultClient

func (WKContentWorldClass) PageWorld

func (_WKContentWorldClass WKContentWorldClass) PageWorld() WKContentWorld

The content world for the current webpage’s content.

Discussion

This property contains the content world for scripts that the current webpage executes. Be careful when manipulating variables in this content world. If you modify a variable with the same name as one the webpage uses, you may unintentionally disrupt the normal operation of that page.

See: https://developer.apple.com/documentation/WebKit/WKContentWorld/page

func (WKContentWorldClass) WorldWithName

func (_WKContentWorldClass WKContentWorldClass) WorldWithName(name string) WKContentWorld

Returns the custom content world with the specified name.

name: The name of the content world you want. If no content world with that name exists, this method creates a new WKContentWorld object and returns it. The next time you request a content world with the same name, this method returns the object it previously created.

Return Value

The content world with the specified name.

Discussion

Use this method to create unique content worlds for your script code. For example, if you execute scripts from multiple JavaScript extensions, you might use this method to create a content world based on a unique string associated with that extension.

See: https://developer.apple.com/documentation/WebKit/WKContentWorld/world(name:)

type WKCookiePolicy

type WKCookiePolicy int

See: https://developer.apple.com/documentation/WebKit/WKHTTPCookieStore/CookiePolicy

const (
	// WKCookiePolicyAllow: A case that indicates the cookie store allows cookie storage.
	WKCookiePolicyAllow WKCookiePolicy = 0
	// WKCookiePolicyDisallow: A case that indicates the cookie store does not allow cookie storage.
	WKCookiePolicyDisallow WKCookiePolicy = 1
)

func (WKCookiePolicy) String

func (e WKCookiePolicy) String() string

type WKCookiePolicyHandler

type WKCookiePolicyHandler = func(int)

WKCookiePolicyHandler handles The completion handler block to execute asynchronously with the cookie policy.

  • cookiePolicy: A [WKHTTPCookieStore.CookiePolicy](<doc://com.apple.webkit/documentation/WebKit/WKHTTPCookieStore/CookiePolicy>) case that indicates whether the cookie store allows cookie storage.

Used by:

type WKDataDetectorTypes

type WKDataDetectorTypes uint

See: https://developer.apple.com/documentation/WebKit/WKDataDetectorTypes

const (
	// WKDataDetectorTypeAddress: Detect addresses in text and turn them into links to display the location.
	WKDataDetectorTypeAddress WKDataDetectorTypes = 0
	// WKDataDetectorTypeAll: Detect all data types and turn them into links.
	WKDataDetectorTypeAll WKDataDetectorTypes = 0
	// WKDataDetectorTypeCalendarEvent: Turn future dates and times into links to create calendar events.
	WKDataDetectorTypeCalendarEvent WKDataDetectorTypes = 0
	// WKDataDetectorTypeFlightNumber: Detect flight numbers in text and turn them into links.
	WKDataDetectorTypeFlightNumber WKDataDetectorTypes = 0
	// WKDataDetectorTypeLink: Detect URLs in text and turn them into links.
	WKDataDetectorTypeLink WKDataDetectorTypes = 0
	// WKDataDetectorTypeLookupSuggestion: Detect Spotlight suggestions and turn them into links.
	WKDataDetectorTypeLookupSuggestion WKDataDetectorTypes = 0
	// WKDataDetectorTypeNone: No data detection.
	WKDataDetectorTypeNone WKDataDetectorTypes = 0
	// WKDataDetectorTypePhoneNumber: Detect phone numbers in text and create a link to call the specified number.
	WKDataDetectorTypePhoneNumber WKDataDetectorTypes = 0
	// WKDataDetectorTypeTrackingNumber: Detect tracking numbers in text and turn them into links.
	WKDataDetectorTypeTrackingNumber WKDataDetectorTypes = 0
	// Deprecated.
	WKDataDetectorTypeSpotlightSuggestion WKDataDetectorTypes = 0
)

func (WKDataDetectorTypes) String

func (e WKDataDetectorTypes) String() string

type WKDialogResult

type WKDialogResult int

See: https://developer.apple.com/documentation/WebKit/WKDialogResult

const (
	// WKDialogResultAskAgain: A result that indicates the delegate didn’t display a message, so other web views should check again.
	WKDialogResultAskAgain WKDialogResult = 2
	// WKDialogResultHandled: A result that indicates the delegate displayed the first use message.
	WKDialogResultHandled WKDialogResult = 3
	// WKDialogResultShowDefault: A result that indicates the delegate didn’t display a message, so the web view should show the default Lockdown Mode message.
	WKDialogResultShowDefault WKDialogResult = 1
)

func (WKDialogResult) String

func (e WKDialogResult) String() string

type WKDialogResultHandler

type WKDialogResultHandler = func(int)

WKDialogResultHandler handles A block you must invoke to resume after the web view displays the first use dialog.

  • dialogResult: A display result case that indicates how the method handled the display request.

Used by:

  • [WKUIDelegate.WebViewShowLockdownModeFirstUseMessageCompletionHandler]

type WKDownload

type WKDownload struct {
	objectivec.Object
}

An object that represents the download of a web resource.

Managing the download

Inspecting the download

Instance Properties

See: https://developer.apple.com/documentation/WebKit/WKDownload

func NewWKDownload

func NewWKDownload() WKDownload

NewWKDownload creates a new WKDownload instance.

func WKDownloadFromID

func WKDownloadFromID(id objc.ID) WKDownload

WKDownloadFromID constructs a WKDownload from an objc.ID.

An object that represents the download of a web resource.

func (WKDownload) Autorelease

func (d WKDownload) Autorelease() WKDownload

Autorelease adds the receiver to the current autorelease pool.

func (WKDownload) Cancel

func (d WKDownload) Cancel(completionHandler DataHandler)

Cancels the download, and optionally captures data so that you can resume the download later.

completionHandler: A closure you provide to capture and store data so that you can resume the download later.

See: https://developer.apple.com/documentation/WebKit/WKDownload/cancel(_:)

func (WKDownload) CancelSync

func (d WKDownload) CancelSync(ctx context.Context) (*foundation.NSData, error)

CancelSync is a synchronous wrapper around WKDownload.Cancel. It blocks until the completion handler fires or the context is cancelled.

func (WKDownload) Delegate

func (d WKDownload) Delegate() WKDownloadDelegate

An object you use to track download progress and handle redirects, authentication challenges, and failures.

See: https://developer.apple.com/documentation/WebKit/WKDownload/delegate

func (WKDownload) Init

func (d WKDownload) Init() WKDownload

Init initializes the instance.

func (WKDownload) OriginalRequest

func (d WKDownload) OriginalRequest() foundation.NSURLRequest

An object that represents the request that initiated the download.

See: https://developer.apple.com/documentation/WebKit/WKDownload/originalRequest

func (WKDownload) SetDelegate

func (d WKDownload) SetDelegate(value WKDownloadDelegate)

func (WKDownload) WebView

func (d WKDownload) WebView() IWKWebView

The web view where the download initiated.

See: https://developer.apple.com/documentation/WebKit/WKDownload/webView

type WKDownloadClass

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

func GetWKDownloadClass

func GetWKDownloadClass() WKDownloadClass

GetWKDownloadClass returns the class object for WKDownload.

func (WKDownloadClass) Alloc

func (wc WKDownloadClass) Alloc() WKDownload

Alloc allocates memory for a new instance of the class.

func (WKDownloadClass) Class

func (wc WKDownloadClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKDownloadDelegate

type WKDownloadDelegate interface {
	objectivec.IObject

	// Asks the delegate to provide a file destination where the system should write the download data.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKDownloadDelegate/download(_:decideDestinationUsing:suggestedFilename:completionHandler:)
	DownloadDecideDestinationUsingResponseSuggestedFilenameCompletionHandler(download IWKDownload, response foundation.NSURLResponse, suggestedFilename string, completionHandler URLHandler)
}

A protocol you implement to track download progress and handle redirects, authentication challenges, and failures.

See: https://developer.apple.com/documentation/WebKit/WKDownloadDelegate

type WKDownloadDelegateConfig

type WKDownloadDelegateConfig struct {

	// Tracking Download Progress
	// DownloadDidFinish — Tells the delegate that the download finished.
	DownloadDidFinish func(download WKDownload)
	// DownloadDidFailWithErrorResumeData — Tells the delegate that the download failed, with error information and data you can use to restart the download.
	DownloadDidFailWithErrorResumeData func(download WKDownload, error_ foundation.NSError, resumeData foundation.NSData)

	// Instance Methods
	DownloadDidReceiveFinalURL func(download WKDownload, url foundation.NSURL)
}

WKDownloadDelegateConfig holds optional typed callbacks for WKDownloadDelegate methods. Set non-nil fields to register the corresponding Objective-C delegate method. Methods with nil callbacks are not registered, so [NSObject.RespondsToSelector] returns false for them — matching the Objective-C delegate pattern exactly.

See Apple Documentation for protocol details.

type WKDownloadDelegateObject

type WKDownloadDelegateObject struct {
	objectivec.Object
}

WKDownloadDelegateObject wraps an existing Objective-C object that conforms to the WKDownloadDelegate protocol.

func NewWKDownloadDelegate

func NewWKDownloadDelegate(config WKDownloadDelegateConfig) WKDownloadDelegateObject

NewWKDownloadDelegate creates an Objective-C object implementing the WKDownloadDelegate protocol.

Each call registers a unique Objective-C class containing only the methods set in config. This means [NSObject.RespondsToSelector] works correctly for optional delegate methods — only non-nil callbacks are registered.

The returned WKDownloadDelegateObject satisfies the WKDownloadDelegate interface and can be passed directly to SetDelegate and similar methods.

See Apple Documentation for protocol details.

func WKDownloadDelegateObjectFromID

func WKDownloadDelegateObjectFromID(id objc.ID) WKDownloadDelegateObject

WKDownloadDelegateObjectFromID constructs a WKDownloadDelegateObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (WKDownloadDelegateObject) BaseObject

func (WKDownloadDelegateObject) DownloadDecideDestinationUsingResponseSuggestedFilenameCompletionHandler

func (o WKDownloadDelegateObject) DownloadDecideDestinationUsingResponseSuggestedFilenameCompletionHandler(download IWKDownload, response foundation.NSURLResponse, suggestedFilename string, completionHandler URLHandler)

Asks the delegate to provide a file destination where the system should write the download data.

download: The download that needs a file destination where the systems should write the download data.

response: A response from the server for an HTTP request, or a synthesized response for a blob download.

suggestedFilename: A string with a filename suggestion to use in creating the file destination.

completionHandler: A closure you invoke with a destination file URL to begin the download, or `nil` to cancel the download.

Discussion

The suggested filename can come from the response or from the web content.

The destination file URL must meet the following requirements:

- It’s a file that doesn’t exist. - It’s in a directory that exists. - It’s in a directory that WebKit can write to.

See: https://developer.apple.com/documentation/WebKit/WKDownloadDelegate/download(_:decideDestinationUsing:suggestedFilename:completionHandler:)

func (WKDownloadDelegateObject) DownloadDidFailWithErrorResumeData

func (o WKDownloadDelegateObject) DownloadDidFailWithErrorResumeData(download IWKDownload, error_ foundation.INSError, resumeData foundation.INSData)

Tells the delegate that the download failed, with error information and data you can use to restart the download.

download: The download that failed.

error: An error describing what caused the download to fail.

resumeData: A data object you use to restart the download.

Discussion

To restart a failed download, call [ResumeDownloadFromResumeDataCompletionHandler] with `resumeData`.

See: https://developer.apple.com/documentation/WebKit/WKDownloadDelegate/download(_:didFailWithError:resumeData:)

func (WKDownloadDelegateObject) DownloadDidFinish

func (o WKDownloadDelegateObject) DownloadDidFinish(download IWKDownload)

Tells the delegate that the download finished.

download: The download that finished.

See: https://developer.apple.com/documentation/WebKit/WKDownloadDelegate/downloadDidFinish(_:)

func (WKDownloadDelegateObject) DownloadDidReceiveAuthenticationChallengeCompletionHandler

func (o WKDownloadDelegateObject) DownloadDidReceiveAuthenticationChallengeCompletionHandler(download IWKDownload, challenge foundation.NSURLAuthenticationChallenge, completionHandler URLCredentialHandler)

Asks the delegate to respond to an authentication challenge.

download: The download that received the authentication challenge.

challenge: The authentication challenge.

completionHandler: A closure you must invoke to respond to the authentication challenge. Provide the closure with a disposition that describes how to respond to the authorization challenge, and optional credentials.

Discussion

Determine how to respond to the authentication challenge in this method. Then invoke `completionHandler` with a disposition that describes how to respond to the authorization challenge, and optional credentials.

If you don’t implement this method, the web view responds to the challenge with URLSession.AuthChallengeDisposition.rejectProtectionSpace.

See: https://developer.apple.com/documentation/WebKit/WKDownloadDelegate/download(_:didReceive:completionHandler:)

func (WKDownloadDelegateObject) DownloadWillPerformHTTPRedirectionNewRequestDecisionHandler

func (o WKDownloadDelegateObject) DownloadWillPerformHTTPRedirectionNewRequestDecisionHandler(download IWKDownload, response foundation.NSHTTPURLResponse, request foundation.NSURLRequest, decisionHandler WKDownloadRedirectPolicyHandler)

Asks the delegate to respond to the download’s redirect response.

download: The download that receives the redirect response.

response: The redirect response.

request: The new request the web view sends as a result of the redirect response.

decisionHandler: A closure you must invoke, providing a download redirect policy that indicates whether to proceed with the redirect.

Discussion

Determine whether to proceed with the redirect. Then invoke the decisionHandler closure, providing a download redirect policy that indicates whether to proceed with the redirect.

If you don’t implement this method, the web view proceeds with all redirects.

See: https://developer.apple.com/documentation/WebKit/WKDownloadDelegate/download(_:willPerformHTTPRedirection:newRequest:decisionHandler:)

type WKDownloadHandler

type WKDownloadHandler = func(*WKDownload)

WKDownloadHandler handles A closure the system executes when it has started to download the resource.

Used by:

type WKDownloadPlaceholderPolicy

type WKDownloadPlaceholderPolicy int

See: https://developer.apple.com/documentation/WebKit/WKDownload/PlaceholderPolicy

const (
	WKDownloadPlaceholderPolicyDisable WKDownloadPlaceholderPolicy = 0
	WKDownloadPlaceholderPolicyEnable  WKDownloadPlaceholderPolicy = 1
)

func (WKDownloadPlaceholderPolicy) String

type WKDownloadRedirectPolicy

type WKDownloadRedirectPolicy int

See: https://developer.apple.com/documentation/WebKit/WKDownload/RedirectPolicy

const (
	// WKDownloadRedirectPolicyAllow: Allow a redirect to proceed.
	WKDownloadRedirectPolicyAllow WKDownloadRedirectPolicy = 1
	// WKDownloadRedirectPolicyCancel: Cancel the redirect action.
	WKDownloadRedirectPolicyCancel WKDownloadRedirectPolicy = 0
)

func (WKDownloadRedirectPolicy) String

func (e WKDownloadRedirectPolicy) String() string

type WKDownloadRedirectPolicyHandler

type WKDownloadRedirectPolicyHandler = func(int)

WKDownloadRedirectPolicyHandler handles A closure you must invoke, providing a download redirect policy that indicates whether to proceed with the redirect.

Used by:

  • [WKDownloadDelegate.DownloadWillPerformHTTPRedirectionNewRequestDecisionHandler]

type WKErrorCode

type WKErrorCode int

See: https://developer.apple.com/documentation/WebKit/WKError/Code

const (
	// WKErrorAttributedStringContentFailedToLoad: An error that indicates the failure to navigate to web content from an attributed string.
	WKErrorAttributedStringContentFailedToLoad WKErrorCode = 10
	// WKErrorAttributedStringContentLoadTimedOut: An error that indicates a timeout occurred while trying to load web content from an attributed string.
	WKErrorAttributedStringContentLoadTimedOut WKErrorCode = 11
	// WKErrorContentRuleListStoreCompileFailed: An error that indicates the compilation of a rule list failed.
	WKErrorContentRuleListStoreCompileFailed WKErrorCode = 6
	// WKErrorContentRuleListStoreLookUpFailed: An error that indicates a content rule list data store didn’t find a rule list with the specified identifier.
	WKErrorContentRuleListStoreLookUpFailed WKErrorCode = 7
	// WKErrorContentRuleListStoreRemoveFailed: An error that indicates a failure to remove a content rule list from the rule list data store object.
	WKErrorContentRuleListStoreRemoveFailed WKErrorCode = 8
	// WKErrorContentRuleListStoreVersionMismatch: An error that indicates the rule list version is outdated and cannot be read.
	WKErrorContentRuleListStoreVersionMismatch WKErrorCode = 9
	// WKErrorCredentialNotFound: An error that indicates the system could not find a passkey during an export.
	WKErrorCredentialNotFound WKErrorCode = 17
	// WKErrorDuplicateCredential: An error that indicates the system found a duplicate passkey during an import.
	WKErrorDuplicateCredential WKErrorCode = 15
	// WKErrorJavaScriptAppBoundDomain: An error that indicates JavaScript execution failed due to an app-bound domain restriction.
	WKErrorJavaScriptAppBoundDomain WKErrorCode = 14
	// WKErrorJavaScriptExceptionOccurred: An error that indicates a JavaScript exception occurred.
	WKErrorJavaScriptExceptionOccurred WKErrorCode = 4
	// WKErrorJavaScriptInvalidFrameTarget: An error that indicates your content referenced an invalid web frame.
	WKErrorJavaScriptInvalidFrameTarget WKErrorCode = 12
	// WKErrorJavaScriptResultTypeIsUnsupported: An error that indicates the result of JavaScript execution could not be returned.
	WKErrorJavaScriptResultTypeIsUnsupported WKErrorCode = 5
	// WKErrorMalformedCredential: An error that indicates the system could not parse passkey data during an import.
	WKErrorMalformedCredential WKErrorCode = 16
	// WKErrorNavigationAppBoundDomain: An error that indicates navigation failed due to an app-bound domain restriction.
	WKErrorNavigationAppBoundDomain WKErrorCode = 13
	// WKErrorUnknown: An error that indicates an unknown issue occurred.
	WKErrorUnknown WKErrorCode = 1
	// WKErrorWebContentProcessTerminated: An error that indicates the web process that contains the content is no longer running.
	WKErrorWebContentProcessTerminated WKErrorCode = 2
	// WKErrorWebViewInvalidated: An error that indicates the web view was invalidated.
	WKErrorWebViewInvalidated WKErrorCode = 3
)

func (WKErrorCode) String

func (e WKErrorCode) String() string

type WKFindConfiguration

type WKFindConfiguration struct {
	objectivec.Object
}

The configuration parameters to use when searching the contents of the web view.

Overview

Create a WKFindConfiguration object and configure its attributes to specify how to perform searches within the web view’s contents. To initiate a search, call the appropriate method of WKWebView and pass this object along with the search string.

Configuring the Search Parameters

See: https://developer.apple.com/documentation/WebKit/WKFindConfiguration

func NewWKFindConfiguration

func NewWKFindConfiguration() WKFindConfiguration

NewWKFindConfiguration creates a new WKFindConfiguration instance.

func WKFindConfigurationFromID

func WKFindConfigurationFromID(id objc.ID) WKFindConfiguration

WKFindConfigurationFromID constructs a WKFindConfiguration from an objc.ID.

The configuration parameters to use when searching the contents of the web view.

func (WKFindConfiguration) Autorelease

func (f WKFindConfiguration) Autorelease() WKFindConfiguration

Autorelease adds the receiver to the current autorelease pool.

func (WKFindConfiguration) Backwards

func (f WKFindConfiguration) Backwards() bool

A Boolean value that indicates the search direction, relative to the current selection.

Discussion

When the value of this property is true, searches proceed backward from the current selection. When the value is false, searches proceed forward from the current selection. The default value of this property is false.

The web view respects the writing direction of its content. For example, a forward search moves right-to-left and top-to-bottom for a right-to-left language.

See: https://developer.apple.com/documentation/WebKit/WKFindConfiguration/backwards

func (WKFindConfiguration) CaseSensitive

func (f WKFindConfiguration) CaseSensitive() bool

A Boolean value that indicates whether to consider case when matching the search string.

Discussion

When the value of this property is true, the web view takes case into account when matching the search string. The default value of this property is false.

See: https://developer.apple.com/documentation/WebKit/WKFindConfiguration/caseSensitive

func (WKFindConfiguration) Init

Init initializes the instance.

func (WKFindConfiguration) SetBackwards

func (f WKFindConfiguration) SetBackwards(value bool)

func (WKFindConfiguration) SetCaseSensitive

func (f WKFindConfiguration) SetCaseSensitive(value bool)

func (WKFindConfiguration) SetWraps

func (f WKFindConfiguration) SetWraps(value bool)

func (WKFindConfiguration) Wraps

func (f WKFindConfiguration) Wraps() bool

A Boolean value that indicates whether the search wraps around to the other side of the page.

Discussion

When the value of this property is true, the search wraps and continues at the other end of the page. For example, when a forward search reaches the bottom of the page, the search wraps back to the top of the page and continues. When a backward search reaches the top of the page, the search wraps back to the bottom of the page. The default value of this property is true.

See: https://developer.apple.com/documentation/WebKit/WKFindConfiguration/wraps

type WKFindConfigurationClass

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

func GetWKFindConfigurationClass

func GetWKFindConfigurationClass() WKFindConfigurationClass

GetWKFindConfigurationClass returns the class object for WKFindConfiguration.

func (WKFindConfigurationClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKFindConfigurationClass) Class

func (wc WKFindConfigurationClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKFindResult

type WKFindResult struct {
	objectivec.Object
}

An object that contains the results of searching the web view’s contents.

Overview

When you perform a search using the methods of WKWebView, the web view creates a WKFindResult object and delivers it to your completion handler. You don’t create instances of this class directly. Use the objects that the web view provides to determine whether it found a match for the content.

Getting the Search Result

See: https://developer.apple.com/documentation/WebKit/WKFindResult

func NewWKFindResult

func NewWKFindResult() WKFindResult

NewWKFindResult creates a new WKFindResult instance.

func WKFindResultFromID

func WKFindResultFromID(id objc.ID) WKFindResult

WKFindResultFromID constructs a WKFindResult from an objc.ID.

An object that contains the results of searching the web view’s contents.

func (WKFindResult) Autorelease

func (f WKFindResult) Autorelease() WKFindResult

Autorelease adds the receiver to the current autorelease pool.

func (WKFindResult) Init

func (f WKFindResult) Init() WKFindResult

Init initializes the instance.

func (WKFindResult) MatchFound

func (f WKFindResult) MatchFound() bool

A Boolean value that indicates whether the web view found a match during the search.

Discussion

The value of this property is true if the web view found a match, or false if it didn’t.

See: https://developer.apple.com/documentation/WebKit/WKFindResult/matchFound

type WKFindResultClass

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

func GetWKFindResultClass

func GetWKFindResultClass() WKFindResultClass

GetWKFindResultClass returns the class object for WKFindResult.

func (WKFindResultClass) Alloc

func (wc WKFindResultClass) Alloc() WKFindResult

Alloc allocates memory for a new instance of the class.

func (WKFindResultClass) Class

func (wc WKFindResultClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKFindResultHandler

type WKFindResultHandler = func(*WKFindResult)

WKFindResultHandler handles The completion handler to call with the results of the search.

  • result: The object that contains the results of the search.

Used by:

type WKFrameInfo

type WKFrameInfo struct {
	objectivec.Object
}

An object that contains information about a frame on a webpage.

Overview

An instance of this class is a transient, data-only object; it does not uniquely identify a frame across multiple delegate method calls.

Inspecting frame information

See: https://developer.apple.com/documentation/WebKit/WKFrameInfo

func NewWKFrameInfo

func NewWKFrameInfo() WKFrameInfo

NewWKFrameInfo creates a new WKFrameInfo instance.

func WKFrameInfoFromID

func WKFrameInfoFromID(id objc.ID) WKFrameInfo

WKFrameInfoFromID constructs a WKFrameInfo from an objc.ID.

An object that contains information about a frame on a webpage.

func (WKFrameInfo) Autorelease

func (f WKFrameInfo) Autorelease() WKFrameInfo

Autorelease adds the receiver to the current autorelease pool.

func (WKFrameInfo) Init

func (f WKFrameInfo) Init() WKFrameInfo

Init initializes the instance.

func (WKFrameInfo) MainFrame

func (f WKFrameInfo) MainFrame() bool

A Boolean value indicating whether the frame is the web site’s main frame or a subframe.

See: https://developer.apple.com/documentation/WebKit/WKFrameInfo/isMainFrame

func (WKFrameInfo) Request

func (f WKFrameInfo) Request() foundation.NSURLRequest

The frame’s current request.

See: https://developer.apple.com/documentation/WebKit/WKFrameInfo/request

func (WKFrameInfo) SecurityOrigin

func (f WKFrameInfo) SecurityOrigin() IWKSecurityOrigin

The frame’s security origin.

Discussion

The WKSecurityOrigin object consists of a host name, a protocol, and a port number.

See: https://developer.apple.com/documentation/WebKit/WKFrameInfo/securityOrigin

func (WKFrameInfo) WebView

func (f WKFrameInfo) WebView() IWKWebView

The web view that contains this frame and the containing webpage.

See: https://developer.apple.com/documentation/WebKit/WKFrameInfo/webView

type WKFrameInfoClass

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

func GetWKFrameInfoClass

func GetWKFrameInfoClass() WKFrameInfoClass

GetWKFrameInfoClass returns the class object for WKFrameInfo.

func (WKFrameInfoClass) Alloc

func (wc WKFrameInfoClass) Alloc() WKFrameInfo

Alloc allocates memory for a new instance of the class.

func (WKFrameInfoClass) Class

func (wc WKFrameInfoClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKFullscreenState

type WKFullscreenState int

See: https://developer.apple.com/documentation/WebKit/WKWebView/FullscreenState-swift.enum

const (
	WKFullscreenStateEnteringFullscreen WKFullscreenState = 1
	WKFullscreenStateExitingFullscreen  WKFullscreenState = 3
	WKFullscreenStateInFullscreen       WKFullscreenState = 2
	WKFullscreenStateNotInFullscreen    WKFullscreenState = 0
)

func (WKFullscreenState) String

func (e WKFullscreenState) String() string

type WKHTTPCookieStore

type WKHTTPCookieStore struct {
	objectivec.Object
}

An object that manages the HTTP cookies associated with a particular web view.

Overview

Use a WKHTTPCookieStore to specify the initial cookies for your webpages, and to manage cookies for your web content. For example, you might use this object to delete the cookie for the current session when the user logs out. To detect when the webpage changes a cookie, install a cookie observer using the WKHTTPCookieStore.AddObserver method.

You don’t create a WKHTTPCookieStore object directly. Instead, retrieve this object from the WKWebsiteDataStore object in your web view’s configuration object.

Managing cookies

Instance Methods

See: https://developer.apple.com/documentation/WebKit/WKHTTPCookieStore

func NewWKHTTPCookieStore

func NewWKHTTPCookieStore() WKHTTPCookieStore

NewWKHTTPCookieStore creates a new WKHTTPCookieStore instance.

func WKHTTPCookieStoreFromID

func WKHTTPCookieStoreFromID(id objc.ID) WKHTTPCookieStore

WKHTTPCookieStoreFromID constructs a WKHTTPCookieStore from an objc.ID.

An object that manages the HTTP cookies associated with a particular web view.

func (WKHTTPCookieStore) AddObserver

func (h WKHTTPCookieStore) AddObserver(observer WKHTTPCookieStoreObserver)

Adds an observer to the cookie store.

observer: The observer object to add. The cookie store doesn’t maintain a strong reference to the object you specify. You are responsible for removing your observer object before it becomes invalid.

See: https://developer.apple.com/documentation/WebKit/WKHTTPCookieStore/add(_:)

func (WKHTTPCookieStore) Autorelease

func (h WKHTTPCookieStore) Autorelease() WKHTTPCookieStore

Autorelease adds the receiver to the current autorelease pool.

func (WKHTTPCookieStore) DeleteCookie

func (h WKHTTPCookieStore) DeleteCookie(ctx context.Context, cookie foundation.NSHTTPCookie) error

DeleteCookie is a synchronous wrapper around WKHTTPCookieStore.DeleteCookieCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKHTTPCookieStore) DeleteCookieCompletionHandler

func (h WKHTTPCookieStore) DeleteCookieCompletionHandler(cookie foundation.NSHTTPCookie, completionHandler VoidHandler)

Deletes the specified cookie.

cookie: The cookie to delete.

completionHandler: A completion handler block to execute asynchronously after the method successfully deletes the cookie. This block has no return value and no parameters.

See: https://developer.apple.com/documentation/WebKit/WKHTTPCookieStore/delete(_:completionHandler:)

func (WKHTTPCookieStore) GetCookiePolicy

func (h WKHTTPCookieStore) GetCookiePolicy(completionHandler WKCookiePolicyHandler)

Returns a cookie policy that indicates whether the cookie store allows cookie storage.

completionHandler: The completion handler block to execute asynchronously with the cookie policy. This block has no return value, and takes the following parameter:

cookiePolicy: A WKHTTPCookieStore.CookiePolicy case that indicates whether the cookie store allows cookie storage.

See: https://developer.apple.com/documentation/WebKit/WKHTTPCookieStore/getCookiePolicy(_:)

func (WKHTTPCookieStore) GetCookiePolicySync

func (h WKHTTPCookieStore) GetCookiePolicySync(ctx context.Context) (int, error)

GetCookiePolicySync is a synchronous wrapper around WKHTTPCookieStore.GetCookiePolicy. It blocks until the completion handler fires or the context is cancelled.

func (WKHTTPCookieStore) Init

Init initializes the instance.

func (WKHTTPCookieStore) ReadAccessURL

func (h WKHTTPCookieStore) ReadAccessURL() foundation.NSString

The local files WebKit can access when loading content.

See: https://developer.apple.com/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/readAccessURL

func (WKHTTPCookieStore) RemoveObserver

func (h WKHTTPCookieStore) RemoveObserver(observer WKHTTPCookieStoreObserver)

Removes an observer from the cookie store.

observer: The observer object to remove.

See: https://developer.apple.com/documentation/WebKit/WKHTTPCookieStore/remove(_:)

func (WKHTTPCookieStore) SetCookie

func (h WKHTTPCookieStore) SetCookie(ctx context.Context, cookie foundation.NSHTTPCookie) error

SetCookie is a synchronous wrapper around WKHTTPCookieStore.SetCookieCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKHTTPCookieStore) SetCookieCompletionHandler

func (h WKHTTPCookieStore) SetCookieCompletionHandler(cookie foundation.NSHTTPCookie, completionHandler VoidHandler)

Adds a cookie to the cookie store.

cookie: The cookie to add.

completionHandler: A completion handler block to execute asynchronously after the method successfully stores the cookie. This block has no return value and no parameters.

See: https://developer.apple.com/documentation/WebKit/WKHTTPCookieStore/setCookie(_:completionHandler:)

func (WKHTTPCookieStore) SetCookiePolicy

func (h WKHTTPCookieStore) SetCookiePolicy(ctx context.Context, policy WKCookiePolicy) error

SetCookiePolicy is a synchronous wrapper around WKHTTPCookieStore.SetCookiePolicyCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKHTTPCookieStore) SetCookiePolicyCompletionHandler

func (h WKHTTPCookieStore) SetCookiePolicyCompletionHandler(policy WKCookiePolicy, completionHandler VoidHandler)

Sets a cookie policy that indicates whether the cookie store allows cookie storage.

policy: A cookie policy that indicates whether the cookie store allows cookie storage.

completionHandler: A block the system invokes after it sets the cookie policy.

See: https://developer.apple.com/documentation/WebKit/WKHTTPCookieStore/setCookiePolicy(_:completionHandler:)

func (WKHTTPCookieStore) SetCookiesCompletionHandler

func (h WKHTTPCookieStore) SetCookiesCompletionHandler(cookies []foundation.NSHTTPCookie, completionHandler VoidHandler)

cookies: An array of cookies to set.

completionHandler: A block to invoke once the cookies have been stored.

Discussion

Set multiple cookies.

See: https://developer.apple.com/documentation/WebKit/WKHTTPCookieStore/setCookies(_:completionHandler:)

type WKHTTPCookieStoreClass

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

func GetWKHTTPCookieStoreClass

func GetWKHTTPCookieStoreClass() WKHTTPCookieStoreClass

GetWKHTTPCookieStoreClass returns the class object for WKHTTPCookieStore.

func (WKHTTPCookieStoreClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKHTTPCookieStoreClass) Class

func (wc WKHTTPCookieStoreClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKHTTPCookieStoreObserver

type WKHTTPCookieStoreObserver interface {
	objectivec.IObject
}

The methods to adopt in an object that monitors changes to a webpage’s cookies.

See: https://developer.apple.com/documentation/WebKit/WKHTTPCookieStoreObserver

type WKHTTPCookieStoreObserverObject

type WKHTTPCookieStoreObserverObject struct {
	objectivec.Object
}

WKHTTPCookieStoreObserverObject wraps an existing Objective-C object that conforms to the WKHTTPCookieStoreObserver protocol.

func WKHTTPCookieStoreObserverObjectFromID

func WKHTTPCookieStoreObserverObjectFromID(id objc.ID) WKHTTPCookieStoreObserverObject

WKHTTPCookieStoreObserverObjectFromID constructs a WKHTTPCookieStoreObserverObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (WKHTTPCookieStoreObserverObject) BaseObject

func (WKHTTPCookieStoreObserverObject) CookiesDidChangeInCookieStore

func (o WKHTTPCookieStoreObserverObject) CookiesDidChangeInCookieStore(cookieStore IWKHTTPCookieStore)

Tells the delegate that the cookies in the specified cookie store changed.

cookieStore: The cookie store that contains the modified cookies.

Discussion

When the value of a cookie changes, the cookie store calls this method on all registered observer objects. Use this method to fetch the new cookie values and update any app-specific data structures or JavaScript environment variables that use those values.

See: https://developer.apple.com/documentation/WebKit/WKHTTPCookieStoreObserver/cookiesDidChange(in:)

type WKInactiveSchedulingPolicy

type WKInactiveSchedulingPolicy int

See: https://developer.apple.com/documentation/WebKit/WKPreferences/InactiveSchedulingPolicy-swift.enum

const (
	// WKInactiveSchedulingPolicyNone: A policy where a web view that’s not in a window runs tasks normally.
	WKInactiveSchedulingPolicyNone WKInactiveSchedulingPolicy = 2
	// WKInactiveSchedulingPolicySuspend: A policy where a web view that’s not in a window fully suspends tasks.
	WKInactiveSchedulingPolicySuspend WKInactiveSchedulingPolicy = 0
	// WKInactiveSchedulingPolicyThrottle: A policy where a web view that’s not in a window limits processing, but does not fully suspend tasks.
	WKInactiveSchedulingPolicyThrottle WKInactiveSchedulingPolicy = 1
)

func (WKInactiveSchedulingPolicy) String

type WKMediaCaptureState

type WKMediaCaptureState int

See: https://developer.apple.com/documentation/WebKit/WKMediaCaptureState

const (
	// WKMediaCaptureStateActive: The media device is actively capturing audio or video.
	WKMediaCaptureStateActive WKMediaCaptureState = 1
	// WKMediaCaptureStateMuted: The media device is muted, and not actively capturing audio or video.
	WKMediaCaptureStateMuted WKMediaCaptureState = 2
	// WKMediaCaptureStateNone: The media device is off.
	WKMediaCaptureStateNone WKMediaCaptureState = 0
)

func (WKMediaCaptureState) String

func (e WKMediaCaptureState) String() string

type WKMediaCaptureType

type WKMediaCaptureType int

See: https://developer.apple.com/documentation/WebKit/WKMediaCaptureType

const (
	// WKMediaCaptureTypeCamera: A media device that can capture video.
	WKMediaCaptureTypeCamera WKMediaCaptureType = 0
	// WKMediaCaptureTypeCameraAndMicrophone: A media device or devices that can capture audio and video.
	WKMediaCaptureTypeCameraAndMicrophone WKMediaCaptureType = 2
	// WKMediaCaptureTypeMicrophone: A media device that can capture audio.
	WKMediaCaptureTypeMicrophone WKMediaCaptureType = 1
)

func (WKMediaCaptureType) String

func (e WKMediaCaptureType) String() string

type WKMediaPlaybackState

type WKMediaPlaybackState int

See: https://developer.apple.com/documentation/WebKit/WKMediaPlaybackState

const (
	// WKMediaPlaybackStateNone: There is no media to play back.
	WKMediaPlaybackStateNone WKMediaPlaybackState = 0
	// WKMediaPlaybackStatePaused: The media playback is paused.
	WKMediaPlaybackStatePaused WKMediaPlaybackState = 2
	// WKMediaPlaybackStatePlaying: The media is playing.
	WKMediaPlaybackStatePlaying WKMediaPlaybackState = 1
	// WKMediaPlaybackStateSuspended: The media is not playing, and cannot be resumed until the user revokes the suspension.
	WKMediaPlaybackStateSuspended WKMediaPlaybackState = 3
)

func (WKMediaPlaybackState) String

func (e WKMediaPlaybackState) String() string

type WKMediaPlaybackStateHandler

type WKMediaPlaybackStateHandler = func(int)

WKMediaPlaybackStateHandler handles A closure the system executes after the web view determines the current state of media playback.

Used by:

type WKNavigation

type WKNavigation struct {
	objectivec.Object
}

An object that tracks the loading progress of a webpage.

Overview

A WKNavigation object uniquely identifies a load request for a webpage. When you ask a web view to load content or navigate to a page, the web view returns a WKNavigation object that identifies your request. As the load operation progresses, the web view reports progress of that operation to various methods of its navigation delegate, passing them the matching WKNavigation object.

Getting the Content Mode

See: https://developer.apple.com/documentation/WebKit/WKNavigation

func NewWKNavigation

func NewWKNavigation() WKNavigation

NewWKNavigation creates a new WKNavigation instance.

func WKNavigationFromID

func WKNavigationFromID(id objc.ID) WKNavigation

WKNavigationFromID constructs a WKNavigation from an objc.ID.

An object that tracks the loading progress of a webpage.

func (WKNavigation) Autorelease

func (n WKNavigation) Autorelease() WKNavigation

Autorelease adds the receiver to the current autorelease pool.

func (WKNavigation) EffectiveContentMode

func (n WKNavigation) EffectiveContentMode() WKContentMode

The content mode WebKit uses to load the webpage.

See: https://developer.apple.com/documentation/WebKit/WKNavigation/effectiveContentMode

func (WKNavigation) Init

func (n WKNavigation) Init() WKNavigation

Init initializes the instance.

type WKNavigationAction

type WKNavigationAction struct {
	objectivec.Object
}

An object that contains information about an action that causes navigation to occur.

Overview

Use a WKNavigationAction object to make policy decisions about whether to allow navigation within your app’s web view. You don’t create WKNavigationAction objects directly. Instead, the web view creates them and delivers them to the appropriate delegate objects. Use the methods of your delegate to analyze the action and determine whether to allow the resulting navigation to occur.

Getting the navigation type

Inspecting navigation information

Inspecting user actions

Instance Properties

See: https://developer.apple.com/documentation/WebKit/WKNavigationAction

func NewWKNavigationAction

func NewWKNavigationAction() WKNavigationAction

NewWKNavigationAction creates a new WKNavigationAction instance.

func WKNavigationActionFromID

func WKNavigationActionFromID(id objc.ID) WKNavigationAction

WKNavigationActionFromID constructs a WKNavigationAction from an objc.ID.

An object that contains information about an action that causes navigation to occur.

func (WKNavigationAction) Autorelease

func (n WKNavigationAction) Autorelease() WKNavigationAction

Autorelease adds the receiver to the current autorelease pool.

func (WKNavigationAction) ButtonNumber

func (n WKNavigationAction) ButtonNumber() objectivec.IObject

The number of the mouse button that caused the navigation request.

See: https://developer.apple.com/documentation/WebKit/WKNavigationAction/buttonNumber

func (WKNavigationAction) Init

Init initializes the instance.

func (WKNavigationAction) IsContentRuleListRedirect

func (n WKNavigationAction) IsContentRuleListRedirect() bool

Discussion

Whether or not the navigation is a redirect from a content rule list.

See: https://developer.apple.com/documentation/WebKit/WKNavigationAction/isContentRuleListRedirect

func (WKNavigationAction) ModifierFlags

func (n WKNavigationAction) ModifierFlags() objectivec.IObject

The modifier keys that were pressed at the time of the navigation request.

See: https://developer.apple.com/documentation/WebKit/WKNavigationAction/modifierFlags

func (WKNavigationAction) NavigationType

func (n WKNavigationAction) NavigationType() WKNavigationType

The type of action that triggered the navigation.

Discussion

The value is one of the constants of the enumerated type WKNavigationType.

See: https://developer.apple.com/documentation/WebKit/WKNavigationAction/navigationType

func (WKNavigationAction) Request

The URL request object associated with the navigation action.

See: https://developer.apple.com/documentation/WebKit/WKNavigationAction/request

func (WKNavigationAction) ShouldPerformDownload

func (n WKNavigationAction) ShouldPerformDownload() bool

A Boolean value that indicates whether the web content provided an attribute that indicates a download.

See: https://developer.apple.com/documentation/WebKit/WKNavigationAction/shouldPerformDownload

func (WKNavigationAction) SourceFrame

func (n WKNavigationAction) SourceFrame() IWKFrameInfo

The frame that requested the navigation.

See: https://developer.apple.com/documentation/WebKit/WKNavigationAction/sourceFrame

func (WKNavigationAction) TargetFrame

func (n WKNavigationAction) TargetFrame() IWKFrameInfo

The frame in which to display the new content.

Discussion

If the target of the navigation is a new window, this property is `nil`.

See: https://developer.apple.com/documentation/WebKit/WKNavigationAction/targetFrame

type WKNavigationActionClass

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

func GetWKNavigationActionClass

func GetWKNavigationActionClass() WKNavigationActionClass

GetWKNavigationActionClass returns the class object for WKNavigationAction.

func (WKNavigationActionClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKNavigationActionClass) Class

func (wc WKNavigationActionClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKNavigationActionPolicy

type WKNavigationActionPolicy int

See: https://developer.apple.com/documentation/WebKit/WKNavigationActionPolicy

const (
	// WKNavigationActionPolicyAllow: Allow the navigation to continue.
	WKNavigationActionPolicyAllow WKNavigationActionPolicy = 1
	// WKNavigationActionPolicyCancel: Cancel the navigation.
	WKNavigationActionPolicyCancel WKNavigationActionPolicy = 0
	// WKNavigationActionPolicyDownload: Allow the download to proceed.
	WKNavigationActionPolicyDownload WKNavigationActionPolicy = 2
)

func (WKNavigationActionPolicy) String

func (e WKNavigationActionPolicy) String() string

type WKNavigationActionPolicyHandler

type WKNavigationActionPolicyHandler = func(int)

WKNavigationActionPolicyHandler handles A completion handler block to call with the results about whether to allow or cancel the navigation.

  • policy: A constant that indicates whether to cancel or allow the navigation. For a list of possible values, see WKNavigationActionPolicy(<doc://com.apple.webkit/documentation/WebKit/WKNavigationActionPolicy>).

Used by:

  • [WKNavigationDelegate.WebViewDecidePolicyForNavigationActionDecisionHandler]

type WKNavigationClass

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

func GetWKNavigationClass

func GetWKNavigationClass() WKNavigationClass

GetWKNavigationClass returns the class object for WKNavigation.

func (WKNavigationClass) Alloc

func (wc WKNavigationClass) Alloc() WKNavigation

Alloc allocates memory for a new instance of the class.

func (WKNavigationClass) Class

func (wc WKNavigationClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKNavigationDelegate

type WKNavigationDelegate interface {
	objectivec.IObject
}

Methods for accepting or rejecting navigation changes, and for tracking the progress of navigation requests.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate

type WKNavigationDelegateConfig

type WKNavigationDelegateConfig struct {

	// Tracking the load progress of a request
	// WebViewDidStartProvisionalNavigation — Tells the delegate that navigation from the main frame has started.
	WebViewDidStartProvisionalNavigation func(webView WKWebView, navigation WKNavigation)
	// WebViewDidReceiveServerRedirectForProvisionalNavigation — Tells the delegate that the web view received a server redirect for a request.
	WebViewDidReceiveServerRedirectForProvisionalNavigation func(webView WKWebView, navigation WKNavigation)

	// Responding to navigation errors
	// WebViewDidFailProvisionalNavigationWithError — Tells the delegate that an error occurred during the early navigation process.
	WebViewDidFailProvisionalNavigationWithError func(webView WKWebView, navigation WKNavigation, error_ foundation.NSError)
	// WebViewWebContentProcessDidTerminate — Tells the delegate that the web view’s content process was terminated.
	WebViewWebContentProcessDidTerminate func(webView WKWebView)

	// Other Methods
	// WebViewDidCommitNavigation — Tells the delegate that the web view has started to receive content for the main frame.
	WebViewDidCommitNavigation func(webView WKWebView, navigation WKNavigation)
	// WebViewDidFinishNavigation — Tells the delegate that navigation is complete.
	WebViewDidFinishNavigation func(webView WKWebView, navigation WKNavigation)
	// WebViewDidFailNavigationWithError — Tells the delegate that an error occurred during navigation.
	WebViewDidFailNavigationWithError func(webView WKWebView, navigation WKNavigation, error_ foundation.NSError)
	// WebViewNavigationResponseDidBecomeDownload — Tells the delegate that a navigation response became a download.
	WebViewNavigationResponseDidBecomeDownload func(webView WKWebView, navigationResponse WKNavigationResponse, download WKDownload)
	// WebViewNavigationActionDidBecomeDownload — Tells the delegate that a navigation action became a download.
	WebViewNavigationActionDidBecomeDownload func(webView WKWebView, navigationAction WKNavigationAction, download WKDownload)
}

WKNavigationDelegateConfig holds optional typed callbacks for WKNavigationDelegate methods. Set non-nil fields to register the corresponding Objective-C delegate method. Methods with nil callbacks are not registered, so [NSObject.RespondsToSelector] returns false for them — matching the Objective-C delegate pattern exactly.

See Apple Documentation for protocol details.

type WKNavigationDelegateObject

type WKNavigationDelegateObject struct {
	objectivec.Object
}

WKNavigationDelegateObject wraps an existing Objective-C object that conforms to the WKNavigationDelegate protocol.

func NewWKNavigationDelegate

func NewWKNavigationDelegate(config WKNavigationDelegateConfig) WKNavigationDelegateObject

NewWKNavigationDelegate creates an Objective-C object implementing the WKNavigationDelegate protocol.

Each call registers a unique Objective-C class containing only the methods set in config. This means [NSObject.RespondsToSelector] works correctly for optional delegate methods — only non-nil callbacks are registered.

The returned WKNavigationDelegateObject satisfies the WKNavigationDelegate interface and can be passed directly to SetDelegate and similar methods.

See Apple Documentation for protocol details.

func WKNavigationDelegateObjectFromID

func WKNavigationDelegateObjectFromID(id objc.ID) WKNavigationDelegateObject

WKNavigationDelegateObjectFromID constructs a WKNavigationDelegateObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (WKNavigationDelegateObject) BaseObject

func (WKNavigationDelegateObject) WebViewAuthenticationChallengeShouldAllowDeprecatedTLS

func (o WKNavigationDelegateObject) WebViewAuthenticationChallengeShouldAllowDeprecatedTLS(webView IWKWebView, challenge foundation.NSURLAuthenticationChallenge, decisionHandler BoolHandler)

Asks the delegate whether to continue with a connection that uses a deprecated version of TLS.

webView: The web view that receives the authentication challenge.

challenge: The authentication challenge.

decisionHandler: The completion handler block to execute with the decision. This handler has no return value and takes the following parameter:

decision: A Boolean value that indicates whether to continue to use a deprecated version of TLS. Specify true to continue, or false to reject the connection.

Discussion

If you don’t implement this method, the web view uses system settings to determine whether to allow the use of deprecated versions of TLS.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webView(_:authenticationChallenge:shouldAllowDeprecatedTLS:)

func (WKNavigationDelegateObject) WebViewDecidePolicyForNavigationActionDecisionHandler

func (o WKNavigationDelegateObject) WebViewDecidePolicyForNavigationActionDecisionHandler(webView IWKWebView, navigationAction IWKNavigationAction, decisionHandler WKNavigationActionPolicyHandler)

Asks the delegate for permission to navigate to new content based on the specified action information.

webView: The web view from which the navigation request began.

navigationAction: Details about the action that triggered the navigation request.

decisionHandler: A completion handler block to call with the results about whether to allow or cancel the navigation. This handler has no return value and takes the following parameter:

policy: A constant that indicates whether to cancel or allow the navigation. For a list of possible values, see WKNavigationActionPolicy.

Discussion

Use this method to allow or deny a navigation request that originated with the specified action. The web view calls this method after the interaction occurs but before it attempts to load any content. If you implement this method, always execute the `decisionHandler` block at some point. You may execute it synchronously from your delegate method’s implementation, or execute it asynchronously after your method returns.

If your delegate object implements the [WebViewDecidePolicyForNavigationActionPreferencesDecisionHandler] method, the web view doesn’t call this method.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webView(_:decidePolicyFor:decisionHandler:)-2ni62

func (WKNavigationDelegateObject) WebViewDecidePolicyForNavigationActionPreferencesDecisionHandler

func (o WKNavigationDelegateObject) WebViewDecidePolicyForNavigationActionPreferencesDecisionHandler(webView IWKWebView, navigationAction IWKNavigationAction, preferences IWKWebpagePreferences, decisionHandler WKWebpagePreferencesHandler)

Asks the delegate for permission to navigate to new content based on the specified preferences and action information.

webView: The web view from which the navigation request began.

navigationAction: Details about the action that triggered the navigation request.

preferences: The default preferences to use when displaying the new webpage. Specify the default preferences for pages using the [DefaultWebpagePreferences] property of WKWebViewConfiguration when you create your web view.

decisionHandler: A completion handler block to call with the results about whether to allow or cancel the navigation. This handler has no return value and takes the following parameters:

policy: A constant that indicates whether to cancel or allow the navigation. For a list of possible values, see WKNavigationActionPolicy. preferences: The set of preferences to apply to the page if the navigation is allowed. You may pass the object from the `preferences` parameter or configure a new preferences object and pass it instead.

Discussion

Use this method to allow or deny a navigation request that originated with the specified action. The web view calls this method after the interaction occurs but before it attempts to load any content. If you implement this method, always execute the `decisionHandler` block at some point. You may execute it synchronously from your delegate method’s implementation, or execute it asynchronously after your method returns.

If your delegate object implements this method, the web view doesn’t call the [WebViewDecidePolicyForNavigationActionDecisionHandler] method.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webView(_:decidePolicyFor:preferences:decisionHandler:)

func (WKNavigationDelegateObject) WebViewDecidePolicyForNavigationResponseDecisionHandler

func (o WKNavigationDelegateObject) WebViewDecidePolicyForNavigationResponseDecisionHandler(webView IWKWebView, navigationResponse IWKNavigationResponse, decisionHandler WKNavigationResponsePolicyHandler)

Asks the delegate for permission to navigate to new content after the response to the navigation request is known.

webView: The web view from which the navigation request began.

navigationResponse: Descriptive information about the navigation response.

decisionHandler: A completion handler block to call with the results about whether to allow or cancel the navigation. This handler has no return value and takes the following parameter:

policy: A constant that indicates whether to cancel or allow the navigation. For a list of possible values, see WKNavigationResponsePolicy.

Discussion

Use this method to allow or deny a navigation request after the web view receives the response to its original URL request. The `navigationResponse` parameter contains the details of the response, including the type of data that the response contains. If you implement this method, always execute the `decisionHandler` block at some point. You may execute it synchronously from your delegate method’s implementation, or execute it asynchronously after your method returns.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webView(_:decidePolicyFor:decisionHandler:)-19mn2

func (WKNavigationDelegateObject) WebViewDidCommitNavigation

func (o WKNavigationDelegateObject) WebViewDidCommitNavigation(webView IWKWebView, navigation IWKNavigation)

Tells the delegate that the web view has started to receive content for the main frame.

webView: The web view that is loading the content.

navigation: The navigation object that uniquely identifies the load request.

Discussion

After the navigation delegate’s [WebViewDecidePolicyForNavigationResponseDecisionHandler] method approves the navigation response, the web view begins processing it. As changes become ready, the web view calls this method immediately before it starts to update the main frame.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webView(_:didCommit:)

func (WKNavigationDelegateObject) WebViewDidFailNavigationWithError

func (o WKNavigationDelegateObject) WebViewDidFailNavigationWithError(webView IWKWebView, navigation IWKNavigation, error_ foundation.INSError)

Tells the delegate that an error occurred during navigation.

webView: The web view that reported the error.

navigation: The navigation object for the operation. This object corresponds to a WKNavigation object that WebKit returned when the load operation began. You use it to track the progress of that operation.

error: The error that occurred.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webView(_:didFail:withError:)

func (WKNavigationDelegateObject) WebViewDidFailProvisionalNavigationWithError

func (o WKNavigationDelegateObject) WebViewDidFailProvisionalNavigationWithError(webView IWKWebView, navigation IWKNavigation, error_ foundation.INSError)

Tells the delegate that an error occurred during the early navigation process.

webView: The web view that called the delegate method.

navigation: The navigation object for the operation. This object corresponds to a WKNavigation object that WebKit returned when the load operation began. You use it to track the progress of that operation.

error: The error that occurred.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webView(_:didFailProvisionalNavigation:withError:)

func (WKNavigationDelegateObject) WebViewDidFinishNavigation

func (o WKNavigationDelegateObject) WebViewDidFinishNavigation(webView IWKWebView, navigation IWKNavigation)

Tells the delegate that navigation is complete.

webView: The web view that loaded the content.

navigation: The navigation object that finished.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webView(_:didFinish:)

func (WKNavigationDelegateObject) WebViewDidReceiveAuthenticationChallengeCompletionHandler

func (o WKNavigationDelegateObject) WebViewDidReceiveAuthenticationChallengeCompletionHandler(webView IWKWebView, challenge foundation.NSURLAuthenticationChallenge, completionHandler URLCredentialHandler)

Asks the delegate to respond to an authentication challenge.

webView: The web view that receives the authentication challenge.

challenge: The authentication challenge.

completionHandler: A completion handler block to execute with the response. This handler has no return value and takes the following parameters:

disposition: The option to use to handle the challenge. For a list of options, see URLSession.AuthChallengeDisposition. credential: The credential to use for authentication when the `disposition` parameter contains the value URLSession.AuthChallengeDisposition.useCredential. Specify `nil` to continue without a credential.

Discussion

If you don’t implement this method, the web view responds to the authentication challenge with the URLSession.AuthChallengeDisposition.rejectProtectionSpace disposition.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webView(_:didReceive:completionHandler:)

func (WKNavigationDelegateObject) WebViewDidReceiveServerRedirectForProvisionalNavigation

func (o WKNavigationDelegateObject) WebViewDidReceiveServerRedirectForProvisionalNavigation(webView IWKWebView, navigation IWKNavigation)

Tells the delegate that the web view received a server redirect for a request.

webView: The web view that is loading the content.

navigation: The navigation object that received a server redirect.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webView(_:didReceiveServerRedirectForProvisionalNavigation:)

func (WKNavigationDelegateObject) WebViewDidStartProvisionalNavigation

func (o WKNavigationDelegateObject) WebViewDidStartProvisionalNavigation(webView IWKWebView, navigation IWKNavigation)

Tells the delegate that navigation from the main frame has started.

webView: The web view that is loading the content.

navigation: The navigation object associated with the load request.

Discussion

The web view calls this method after it receives provisional approval to process a navigation request, but before it receives a response to that request.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webView(_:didStartProvisionalNavigation:)

func (WKNavigationDelegateObject) WebViewNavigationActionDidBecomeDownload

func (o WKNavigationDelegateObject) WebViewNavigationActionDidBecomeDownload(webView IWKWebView, navigationAction IWKNavigationAction, download IWKDownload)

Tells the delegate that a navigation action became a download.

webView: The web view in which the navigation action took place.

navigationAction: Descriptive information about the navigation response that turned into a download.

download: An object that represents the download of a web resource.

Discussion

Implement this method to begin tracking download progress.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webView(_:navigationAction:didBecome:)

func (WKNavigationDelegateObject) WebViewNavigationResponseDidBecomeDownload

func (o WKNavigationDelegateObject) WebViewNavigationResponseDidBecomeDownload(webView IWKWebView, navigationResponse IWKNavigationResponse, download IWKDownload)

Tells the delegate that a navigation response became a download.

webView: The web view in which the navigation response took place.

navigationResponse: Descriptive information about the navigation response that turned into a download.

download: An object that represents the download of a web resource.

Discussion

Implement this method to begin tracking download progress.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webView(_:navigationResponse:didBecome:)

func (WKNavigationDelegateObject) WebViewShouldGoToBackForwardListItemWillUseInstantBackCompletionHandler

func (o WKNavigationDelegateObject) WebViewShouldGoToBackForwardListItemWillUseInstantBackCompletionHandler(webView IWKWebView, backForwardListItem IWKBackForwardListItem, willUseInstantBack bool, completionHandler BoolHandler)

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webView(_:shouldGoTo:willUseInstantBack:completionHandler:)

func (WKNavigationDelegateObject) WebViewWebContentProcessDidTerminate

func (o WKNavigationDelegateObject) WebViewWebContentProcessDidTerminate(webView IWKWebView)

Tells the delegate that the web view’s content process was terminated.

webView: The web view whose underlying web content process was terminated.

Discussion

Web views use a separate process to render and manage web content. WebKit calls this method when the process for the specified web view terminates for any reason.

See: https://developer.apple.com/documentation/WebKit/WKNavigationDelegate/webViewWebContentProcessDidTerminate(_:)

type WKNavigationResponse

type WKNavigationResponse struct {
	objectivec.Object
}

An object that contains the response to a navigation request, and which you use to make navigation-related policy decisions.

Overview

Use a WKNavigationResponse object to make policy decisions about whether to allow navigation within your app’s web view. You don’t create WKNavigationResponse objects directly. Instead, the web view creates them and delivers them to the appropriate delegate objects. Use the methods of your delegate to analyze the response and determine whether to allow the resulting navigation to occur.

Getting the Response Details

Getting Additional Response Information

See: https://developer.apple.com/documentation/WebKit/WKNavigationResponse

func NewWKNavigationResponse

func NewWKNavigationResponse() WKNavigationResponse

NewWKNavigationResponse creates a new WKNavigationResponse instance.

func WKNavigationResponseFromID

func WKNavigationResponseFromID(id objc.ID) WKNavigationResponse

WKNavigationResponseFromID constructs a WKNavigationResponse from an objc.ID.

An object that contains the response to a navigation request, and which you use to make navigation-related policy decisions.

func (WKNavigationResponse) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKNavigationResponse) CanShowMIMEType

func (n WKNavigationResponse) CanShowMIMEType() bool

A Boolean value that indicates whether WebKit is capable of displaying the response’s MIME type natively.

Discussion

The value of this property is true if WebKit is able to display the MIME type.

See: https://developer.apple.com/documentation/WebKit/WKNavigationResponse/canShowMIMEType

func (WKNavigationResponse) ForMainFrame

func (n WKNavigationResponse) ForMainFrame() bool

A Boolean value that indicates whether the response targets the web view’s main frame.

Discussion

The value of this property is true if the response targets the main frame. The value is false if the response targets a different frame, such as the frame in a new window.

See: https://developer.apple.com/documentation/WebKit/WKNavigationResponse/isForMainFrame

func (WKNavigationResponse) Init

Init initializes the instance.

func (WKNavigationResponse) Response

The frame’s response.

Discussion

Allowing a navigation response with a MIME type that WebKit can’t display causes the navigation to fail.

See: https://developer.apple.com/documentation/WebKit/WKNavigationResponse/response

type WKNavigationResponseClass

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

func GetWKNavigationResponseClass

func GetWKNavigationResponseClass() WKNavigationResponseClass

GetWKNavigationResponseClass returns the class object for WKNavigationResponse.

func (WKNavigationResponseClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKNavigationResponseClass) Class

Class returns the underlying Objective-C class pointer.

type WKNavigationResponsePolicy

type WKNavigationResponsePolicy int

See: https://developer.apple.com/documentation/WebKit/WKNavigationResponsePolicy

const (
	// WKNavigationResponsePolicyAllow: Allow the navigation to continue.
	WKNavigationResponsePolicyAllow WKNavigationResponsePolicy = 1
	// WKNavigationResponsePolicyCancel: Cancel the navigation.
	WKNavigationResponsePolicyCancel WKNavigationResponsePolicy = 0
	// WKNavigationResponsePolicyDownload: Allow the download to proceed.
	WKNavigationResponsePolicyDownload WKNavigationResponsePolicy = 2
)

func (WKNavigationResponsePolicy) String

type WKNavigationResponsePolicyHandler

type WKNavigationResponsePolicyHandler = func(int)

WKNavigationResponsePolicyHandler handles A completion handler block to call with the results about whether to allow or cancel the navigation.

  • policy: A constant that indicates whether to cancel or allow the navigation. For a list of possible values, see WKNavigationResponsePolicy(<doc://com.apple.webkit/documentation/WebKit/WKNavigationResponsePolicy>).

Used by:

  • [WKNavigationDelegate.WebViewDecidePolicyForNavigationResponseDecisionHandler]

type WKNavigationType

type WKNavigationType int

See: https://developer.apple.com/documentation/WebKit/WKNavigationType

const (
	// WKNavigationTypeBackForward: A request for the frame’s next or previous item.
	WKNavigationTypeBackForward WKNavigationType = 2
	// WKNavigationTypeFormResubmitted: A request to resubmit a form.
	WKNavigationTypeFormResubmitted WKNavigationType = 4
	// WKNavigationTypeFormSubmitted: A request to submit a form.
	WKNavigationTypeFormSubmitted WKNavigationType = 1
	// WKNavigationTypeLinkActivated: A link activation.
	WKNavigationTypeLinkActivated WKNavigationType = 0
	// WKNavigationTypeOther: A navigation request that originates for some other reason.
	WKNavigationTypeOther WKNavigationType = -1
	// WKNavigationTypeReload: A request to reload the webpage.
	WKNavigationTypeReload WKNavigationType = 3
)

func (WKNavigationType) String

func (e WKNavigationType) String() string

type WKOpenPanelParameters

type WKOpenPanelParameters struct {
	objectivec.Object
}

The configuration details of a file upload control in your web content.

Overview

Use a WKOpenPanelParameters to determine the configuration of a file upload control. You don’t create this object directly. Instead, a web view creates one and passes it to the [WebViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler] method of its UI delegate object when it displays a file upload control.

Configuring the panel parameters

See: https://developer.apple.com/documentation/WebKit/WKOpenPanelParameters

func NewWKOpenPanelParameters

func NewWKOpenPanelParameters() WKOpenPanelParameters

NewWKOpenPanelParameters creates a new WKOpenPanelParameters instance.

func WKOpenPanelParametersFromID

func WKOpenPanelParametersFromID(id objc.ID) WKOpenPanelParameters

WKOpenPanelParametersFromID constructs a WKOpenPanelParameters from an objc.ID.

The configuration details of a file upload control in your web content.

func (WKOpenPanelParameters) AllowsDirectories

func (o WKOpenPanelParameters) AllowsDirectories() bool

A Boolean value that indicates whether the file upload control supports the selection of directories.

See: https://developer.apple.com/documentation/WebKit/WKOpenPanelParameters/allowsDirectories

func (WKOpenPanelParameters) AllowsMultipleSelection

func (o WKOpenPanelParameters) AllowsMultipleSelection() bool

A Boolean value that indicates whether the file upload control supports multiple files.

See: https://developer.apple.com/documentation/WebKit/WKOpenPanelParameters/allowsMultipleSelection

func (WKOpenPanelParameters) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKOpenPanelParameters) Init

Init initializes the instance.

type WKOpenPanelParametersClass

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

func GetWKOpenPanelParametersClass

func GetWKOpenPanelParametersClass() WKOpenPanelParametersClass

GetWKOpenPanelParametersClass returns the class object for WKOpenPanelParameters.

func (WKOpenPanelParametersClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKOpenPanelParametersClass) Class

Class returns the underlying Objective-C class pointer.

type WKPDFConfiguration

type WKPDFConfiguration struct {
	objectivec.Object
}

The configuration data to use when generating a PDF representation of a web view’s contents.

Overview

Create a WKPDFConfiguration object when you want to generate a PDF version of your web view’s content. Use this object to specify the portion of the web view to capture. To generate the PDF content, pass the configuration object to the createPDF(configuration:completionHandler:) method of WKWebView, which returns the PDF data for you to use.

Specifying snapshot properties

See: https://developer.apple.com/documentation/WebKit/WKPDFConfiguration

func NewWKPDFConfiguration

func NewWKPDFConfiguration() WKPDFConfiguration

NewWKPDFConfiguration creates a new WKPDFConfiguration instance.

func WKPDFConfigurationFromID

func WKPDFConfigurationFromID(id objc.ID) WKPDFConfiguration

WKPDFConfigurationFromID constructs a WKPDFConfiguration from an objc.ID.

The configuration data to use when generating a PDF representation of a web view’s contents.

func (WKPDFConfiguration) AllowTransparentBackground

func (p WKPDFConfiguration) AllowTransparentBackground() bool

A Boolean value that indicates whether the PDF may have a transparent background.

See: https://developer.apple.com/documentation/WebKit/WKPDFConfiguration/allowTransparentBackground

func (WKPDFConfiguration) Autorelease

func (p WKPDFConfiguration) Autorelease() WKPDFConfiguration

Autorelease adds the receiver to the current autorelease pool.

func (WKPDFConfiguration) Init

Init initializes the instance.

func (WKPDFConfiguration) Rect

The portion of your web view to capture, specified as a rectangle in the view’s coordinate system.

Discussion

The default value of this property is CGRectNull, which captures everything in the view’s bounds rectangle. If you specify a custom rectangle, it must lie within the bounds rectangle of the WKWebView object.

See: https://developer.apple.com/documentation/WebKit/WKPDFConfiguration/rect-3xww9

func (WKPDFConfiguration) SetAllowTransparentBackground

func (p WKPDFConfiguration) SetAllowTransparentBackground(value bool)

func (WKPDFConfiguration) SetRect

func (p WKPDFConfiguration) SetRect(value corefoundation.CGRect)

type WKPDFConfigurationClass

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

func GetWKPDFConfigurationClass

func GetWKPDFConfigurationClass() WKPDFConfigurationClass

GetWKPDFConfigurationClass returns the class object for WKPDFConfiguration.

func (WKPDFConfigurationClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKPDFConfigurationClass) Class

func (wc WKPDFConfigurationClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKPermissionDecision

type WKPermissionDecision int

See: https://developer.apple.com/documentation/WebKit/WKPermissionDecision

const (
	// WKPermissionDecisionDeny: Deny permission for the requested resource.
	WKPermissionDecisionDeny WKPermissionDecision = 2
	// WKPermissionDecisionGrant: Grant permission for the requested resource.
	WKPermissionDecisionGrant WKPermissionDecision = 1
	// WKPermissionDecisionPrompt: Prompt the user for permission for the requested resource.
	WKPermissionDecisionPrompt WKPermissionDecision = 0
)

func (WKPermissionDecision) String

func (e WKPermissionDecision) String() string

type WKPermissionDecisionHandler

type WKPermissionDecisionHandler = func(int)

WKPermissionDecisionHandler handles A closure that you call from your delegate method.

Used by:

  • [WKUIDelegate.WebViewRequestDeviceOrientationAndMotionPermissionForOriginInitiatedByFrameDecisionHandler]
  • [WKUIDelegate.WebViewRequestMediaCapturePermissionForOriginInitiatedByFrameTypeDecisionHandler]

type WKPreferences

type WKPreferences struct {
	objectivec.Object
}

An object that encapsulates the standard behaviors to apply to websites.

Overview

Use a WKPreferences object to specify the preferences for your website, including the minimum font size, the JavaScript behavior, and the behavior for handling fraudulent websites. Create this object and assign it to the [Preferences] property of the WKWebViewConfiguration object you use to create your web view.

Setting Rendering Preferences

Setting Behavior Preferences

Setting Java and JavaScript Preferences

Setting Fraud Warning Preferences

See: https://developer.apple.com/documentation/WebKit/WKPreferences

func NewWKPreferences

func NewWKPreferences() WKPreferences

NewWKPreferences creates a new WKPreferences instance.

func WKPreferencesFromID

func WKPreferencesFromID(id objc.ID) WKPreferences

WKPreferencesFromID constructs a WKPreferences from an objc.ID.

An object that encapsulates the standard behaviors to apply to websites.

func (WKPreferences) Autorelease

func (p WKPreferences) Autorelease() WKPreferences

Autorelease adds the receiver to the current autorelease pool.

func (WKPreferences) ElementFullscreenEnabled

func (p WKPreferences) ElementFullscreenEnabled() bool

A Boolean value that indicates whether a web view can display content full screen.

Discussion

The default value for this preference is false.

See: https://developer.apple.com/documentation/WebKit/WKPreferences/isElementFullscreenEnabled

func (WKPreferences) EncodeWithCoder

func (p WKPreferences) EncodeWithCoder(coder foundation.INSCoder)

func (WKPreferences) FraudulentWebsiteWarningEnabled

func (p WKPreferences) FraudulentWebsiteWarningEnabled() bool

A Boolean value that indicates whether the web view shows warnings for suspected fraudulent content, such as malware or phishing attemps.

Discussion

The default value of this property is true.

See: https://developer.apple.com/documentation/WebKit/WKPreferences/isFraudulentWebsiteWarningEnabled

func (WKPreferences) InactiveSchedulingPolicy

func (p WKPreferences) InactiveSchedulingPolicy() WKInactiveSchedulingPolicy

A policy you set to specify how a web view that’s not in a window handles tasks.

Discussion

Set this to indicate how a web view that’s not in a window handles tasks; for example, when the web view is in a background tab in a browser. The default value is WKInactiveSchedulingPolicySuspend.

A web view that’s not in a window is exempted from this policy if it is playing media, performing media capture, or performing another user-interactive activity.

See: https://developer.apple.com/documentation/WebKit/WKPreferences/inactiveSchedulingPolicy-swift.property

func (WKPreferences) Init

func (p WKPreferences) Init() WKPreferences

Init initializes the instance.

func (WKPreferences) JavaScriptCanOpenWindowsAutomatically

func (p WKPreferences) JavaScriptCanOpenWindowsAutomatically() bool

A Boolean value that indicates whether JavaScript can open windows without user interaction.

Discussion

The default value is false in iOS and true in macOS.

See: https://developer.apple.com/documentation/WebKit/WKPreferences/javaScriptCanOpenWindowsAutomatically

func (WKPreferences) MinimumFontSize

func (p WKPreferences) MinimumFontSize() float64

The minimum font size, in points.

Discussion

The default value is `0`.

See: https://developer.apple.com/documentation/WebKit/WKPreferences/minimumFontSize

func (WKPreferences) Preferences

func (p WKPreferences) Preferences() IWKPreferences

The object that manages the preference-related settings for the web view.

See: https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/preferences

func (WKPreferences) SetElementFullscreenEnabled

func (p WKPreferences) SetElementFullscreenEnabled(value bool)

func (WKPreferences) SetFraudulentWebsiteWarningEnabled

func (p WKPreferences) SetFraudulentWebsiteWarningEnabled(value bool)

func (WKPreferences) SetInactiveSchedulingPolicy

func (p WKPreferences) SetInactiveSchedulingPolicy(value WKInactiveSchedulingPolicy)

func (WKPreferences) SetJavaScriptCanOpenWindowsAutomatically

func (p WKPreferences) SetJavaScriptCanOpenWindowsAutomatically(value bool)

func (WKPreferences) SetMinimumFontSize

func (p WKPreferences) SetMinimumFontSize(value float64)

func (WKPreferences) SetPreferences

func (p WKPreferences) SetPreferences(value IWKPreferences)

func (WKPreferences) SetShouldPrintBackgrounds

func (p WKPreferences) SetShouldPrintBackgrounds(value bool)

func (WKPreferences) SetSiteSpecificQuirksModeEnabled

func (p WKPreferences) SetSiteSpecificQuirksModeEnabled(value bool)
func (p WKPreferences) SetTabFocusesLinks(value bool)

func (WKPreferences) SetTextInteractionEnabled

func (p WKPreferences) SetTextInteractionEnabled(value bool)

func (WKPreferences) ShouldPrintBackgrounds

func (p WKPreferences) ShouldPrintBackgrounds() bool

A Boolean value that indicates whether to include any background color or graphics when printing content.

Discussion

The default value for this preference is false.

See: https://developer.apple.com/documentation/WebKit/WKPreferences/shouldPrintBackgrounds

func (WKPreferences) SiteSpecificQuirksModeEnabled

func (p WKPreferences) SiteSpecificQuirksModeEnabled() bool

A Boolean that indicates whether to apply site-specific compatibility workarounds.

Discussion

The default value for this preference is true.

See: https://developer.apple.com/documentation/WebKit/WKPreferences/isSiteSpecificQuirksModeEnabled

func (p WKPreferences) TabFocusesLinks() bool

A Boolean value that indicates whether pressing the tab key changes the focus to links and form controls.

When the value of this property is true, the web view includes links and form controls in the set of items that may receive focus. Pressing the Option key temporarily reverses this preference.

See: https://developer.apple.com/documentation/WebKit/WKPreferences/tabFocusesLinks

func (WKPreferences) TextInteractionEnabled

func (p WKPreferences) TextInteractionEnabled() bool

A Boolean value that indicates whether to allow people to select or otherwise interact with text.

Discussion

The default value for this preference is true on macOS and iOS. On watchOS, the default value is false.

See: https://developer.apple.com/documentation/WebKit/WKPreferences/isTextInteractionEnabled

type WKPreferencesClass

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

func GetWKPreferencesClass

func GetWKPreferencesClass() WKPreferencesClass

GetWKPreferencesClass returns the class object for WKPreferences.

func (WKPreferencesClass) Alloc

func (wc WKPreferencesClass) Alloc() WKPreferences

Alloc allocates memory for a new instance of the class.

func (WKPreferencesClass) Class

func (wc WKPreferencesClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKScriptMessage

type WKScriptMessage struct {
	objectivec.Object
}

An object that encapsulates a message sent by JavaScript code from a webpage.

Overview

Use a WKScriptMessage object to get details about a JavaScript message sent to a custom message handler in your app. You don’t create WKScriptMessage objects directly. When JavaScript code targets one of your app’s message handlers, the WKUserContentController object of the web view creates a WKScriptMessage object and delivers it to the message handler’s delegate method. Use the object you’re provided to process the message and provide an appropriate response.

For more information about handling script messages, see the WKScriptMessageHandler and WKScriptMessageHandlerWithReply protocols. For information about how to register message handlers, see the methods of WKUserContentController.

Getting the Message Contents

Getting the Message Handler’s Name

See: https://developer.apple.com/documentation/WebKit/WKScriptMessage

func NewWKScriptMessage

func NewWKScriptMessage() WKScriptMessage

NewWKScriptMessage creates a new WKScriptMessage instance.

func WKScriptMessageFromID

func WKScriptMessageFromID(id objc.ID) WKScriptMessage

WKScriptMessageFromID constructs a WKScriptMessage from an objc.ID.

An object that encapsulates a message sent by JavaScript code from a webpage.

func (WKScriptMessage) Autorelease

func (s WKScriptMessage) Autorelease() WKScriptMessage

Autorelease adds the receiver to the current autorelease pool.

func (WKScriptMessage) Body

The body of the message.

Discussion

Allowed types are NSNumber, NSString, NSDate, NSArray, NSDictionary, and NSNull.

See: https://developer.apple.com/documentation/WebKit/WKScriptMessage/body

func (WKScriptMessage) FrameInfo

func (s WKScriptMessage) FrameInfo() IWKFrameInfo

The frame that sent the message.

See: https://developer.apple.com/documentation/WebKit/WKScriptMessage/frameInfo

func (WKScriptMessage) Init

Init initializes the instance.

func (WKScriptMessage) Name

func (s WKScriptMessage) Name() string

The name of the message handler to which the message is sent.

See: https://developer.apple.com/documentation/WebKit/WKScriptMessage/name

func (WKScriptMessage) WebView

func (s WKScriptMessage) WebView() IWKWebView

The web view that sent the message.

See: https://developer.apple.com/documentation/WebKit/WKScriptMessage/webView

func (WKScriptMessage) World

func (s WKScriptMessage) World() IWKContentWorld

The namespace in which the JavaScript code executes.

Discussion

For more information about content worlds, see WKContentWorld.

See: https://developer.apple.com/documentation/WebKit/WKScriptMessage/world

type WKScriptMessageClass

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

func GetWKScriptMessageClass

func GetWKScriptMessageClass() WKScriptMessageClass

GetWKScriptMessageClass returns the class object for WKScriptMessage.

func (WKScriptMessageClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKScriptMessageClass) Class

func (wc WKScriptMessageClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKScriptMessageHandler

type WKScriptMessageHandler interface {
	objectivec.IObject

	// Tells the handler that a webpage sent a script message.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKScriptMessageHandler/userContentController(_:didReceive:)
	UserContentControllerDidReceiveScriptMessage(userContentController IWKUserContentController, message IWKScriptMessage)
}

An interface for receiving messages from JavaScript code running in a webpage.

See: https://developer.apple.com/documentation/WebKit/WKScriptMessageHandler

type WKScriptMessageHandlerObject

type WKScriptMessageHandlerObject struct {
	objectivec.Object
}

WKScriptMessageHandlerObject wraps an existing Objective-C object that conforms to the WKScriptMessageHandler protocol.

func WKScriptMessageHandlerObjectFromID

func WKScriptMessageHandlerObjectFromID(id objc.ID) WKScriptMessageHandlerObject

WKScriptMessageHandlerObjectFromID constructs a WKScriptMessageHandlerObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (WKScriptMessageHandlerObject) BaseObject

func (WKScriptMessageHandlerObject) UserContentControllerDidReceiveScriptMessage

func (o WKScriptMessageHandlerObject) UserContentControllerDidReceiveScriptMessage(userContentController IWKUserContentController, message IWKScriptMessage)

Tells the handler that a webpage sent a script message.

userContentController: The user content controller that delivered the message to your handler.

message: An object that contains the message details.

Discussion

Use this method to respond to a message sent from the webpage’s JavaScript code. Use the message parameter to get the message contents and to determine the originating web view.

See: https://developer.apple.com/documentation/WebKit/WKScriptMessageHandler/userContentController(_:didReceive:)

type WKScriptMessageHandlerWithReply

type WKScriptMessageHandlerWithReply interface {
	objectivec.IObject
}

An interface for responding to messages from JavaScript code running in a webpage.

See: https://developer.apple.com/documentation/WebKit/WKScriptMessageHandlerWithReply

type WKScriptMessageHandlerWithReplyObject

type WKScriptMessageHandlerWithReplyObject struct {
	objectivec.Object
}

WKScriptMessageHandlerWithReplyObject wraps an existing Objective-C object that conforms to the WKScriptMessageHandlerWithReply protocol.

func WKScriptMessageHandlerWithReplyObjectFromID

func WKScriptMessageHandlerWithReplyObjectFromID(id objc.ID) WKScriptMessageHandlerWithReplyObject

WKScriptMessageHandlerWithReplyObjectFromID constructs a WKScriptMessageHandlerWithReplyObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (WKScriptMessageHandlerWithReplyObject) BaseObject

type WKSecurityOrigin

type WKSecurityOrigin struct {
	objectivec.Object
}

An object that identifies the origin of a particular resource.

Overview

A WKSecurityOrigin object is a transient, data-only object that identifies the host name, protocol, and port number associated with a particular resource. You don’t create WKSecurityOrigin objects directly. Instead, WebKit creates them for the resources it loads. A load is any load URL has the same security origin as the requesting web site. First-party webpages can access each other’s resources, such as scripts and databases.

Because a WKSecurityOrigin object is transient, it doesn’t uniquely identify a security origin across multiple delegate method calls.

Getting the Host Information

Getting the Host Protocol

See: https://developer.apple.com/documentation/WebKit/WKSecurityOrigin

func NewWKSecurityOrigin

func NewWKSecurityOrigin() WKSecurityOrigin

NewWKSecurityOrigin creates a new WKSecurityOrigin instance.

func WKSecurityOriginFromID

func WKSecurityOriginFromID(id objc.ID) WKSecurityOrigin

WKSecurityOriginFromID constructs a WKSecurityOrigin from an objc.ID.

An object that identifies the origin of a particular resource.

func (WKSecurityOrigin) Autorelease

func (s WKSecurityOrigin) Autorelease() WKSecurityOrigin

Autorelease adds the receiver to the current autorelease pool.

func (WKSecurityOrigin) Host

func (s WKSecurityOrigin) Host() string

The security origin’s host.

See: https://developer.apple.com/documentation/WebKit/WKSecurityOrigin/host

func (WKSecurityOrigin) Init

Init initializes the instance.

func (WKSecurityOrigin) Port

func (s WKSecurityOrigin) Port() int

The security origin’s port.

See: https://developer.apple.com/documentation/WebKit/WKSecurityOrigin/port

func (WKSecurityOrigin) Protocol

func (s WKSecurityOrigin) Protocol() string

The security origin’s protocol.

See: https://developer.apple.com/documentation/WebKit/WKSecurityOrigin/protocol

type WKSecurityOriginClass

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

func GetWKSecurityOriginClass

func GetWKSecurityOriginClass() WKSecurityOriginClass

GetWKSecurityOriginClass returns the class object for WKSecurityOrigin.

func (WKSecurityOriginClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKSecurityOriginClass) Class

func (wc WKSecurityOriginClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKSecurityRestrictionMode

type WKSecurityRestrictionMode int

See: https://developer.apple.com/documentation/WebKit/WKSecurityRestrictionMode

const (
	WKSecurityRestrictionModeLockdown              WKSecurityRestrictionMode = 2
	WKSecurityRestrictionModeMaximizeCompatibility WKSecurityRestrictionMode = 1
	WKSecurityRestrictionModeNone                  WKSecurityRestrictionMode = 0
)

func (WKSecurityRestrictionMode) String

func (e WKSecurityRestrictionMode) String() string

type WKSelectionGranularity

type WKSelectionGranularity int

See: https://developer.apple.com/documentation/WebKit/WKSelectionGranularity

const (
	// Deprecated.
	WKSelectionGranularityCharacter WKSelectionGranularity = 0
	// Deprecated.
	WKSelectionGranularityDynamic WKSelectionGranularity = 0
)

func (WKSelectionGranularity) String

func (e WKSelectionGranularity) String() string

type WKSnapshotConfiguration

type WKSnapshotConfiguration struct {
	objectivec.Object
}

The configuration data to use when generating an image from a web view’s contents.

Overview

Create a WKSnapshotConfiguration object when you want to generate an image based on your web view’s content. Use this object to specify the portion of the web view to capture and the capture behavior. To generate the snapshot, pass the configuration object to the [TakeSnapshotWithConfigurationCompletionHandler] method of WKWebView, which returns a platform-native image for you to use.

Specifying the snapshot dimensions

Configuring the capture behavior

See: https://developer.apple.com/documentation/WebKit/WKSnapshotConfiguration

func NewWKSnapshotConfiguration

func NewWKSnapshotConfiguration() WKSnapshotConfiguration

NewWKSnapshotConfiguration creates a new WKSnapshotConfiguration instance.

func WKSnapshotConfigurationFromID

func WKSnapshotConfigurationFromID(id objc.ID) WKSnapshotConfiguration

WKSnapshotConfigurationFromID constructs a WKSnapshotConfiguration from an objc.ID.

The configuration data to use when generating an image from a web view’s contents.

func (WKSnapshotConfiguration) AfterScreenUpdates

func (s WKSnapshotConfiguration) AfterScreenUpdates() bool

A Boolean value that indicates whether to take the snapshot after incorporating any pending screen updates.

Discussion

The default value of this property is true, which causes the web view to incorporate any recent changes to the view’s content and then generate the snapshot. If you change the value to false, the web view takes the snapshot immediately, and before incorporating any new changes.

See: https://developer.apple.com/documentation/WebKit/WKSnapshotConfiguration/afterScreenUpdates

func (WKSnapshotConfiguration) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKSnapshotConfiguration) Init

Init initializes the instance.

func (WKSnapshotConfiguration) Rect

The portion of your web view to capture, specified as a rectangle in the view’s coordinate system.

Discussion

The default value of this property is CGRectNull, which captures everything in the view’s bounds rectangle. If you specify a custom rectangle, it must lie within the bounds rectangle of the WKWebView object.

See: https://developer.apple.com/documentation/WebKit/WKSnapshotConfiguration/rect

func (WKSnapshotConfiguration) SetAfterScreenUpdates

func (s WKSnapshotConfiguration) SetAfterScreenUpdates(value bool)

func (WKSnapshotConfiguration) SetRect

func (WKSnapshotConfiguration) SetSnapshotWidth

func (s WKSnapshotConfiguration) SetSnapshotWidth(value foundation.NSNumber)

func (WKSnapshotConfiguration) SnapshotWidth

func (s WKSnapshotConfiguration) SnapshotWidth() foundation.NSNumber

The width of the captured image, in points.

Discussion

Use this property to scale the generated image to the specified width. The web view maintains the aspect ratio of the captured content, but scales it to match the width you specify.

The default value of this property is `nil`, which returns an image whose size matches the original size of the captured rectangle.

See: https://developer.apple.com/documentation/WebKit/WKSnapshotConfiguration/snapshotWidth

type WKSnapshotConfigurationClass

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

func GetWKSnapshotConfigurationClass

func GetWKSnapshotConfigurationClass() WKSnapshotConfigurationClass

GetWKSnapshotConfigurationClass returns the class object for WKSnapshotConfiguration.

func (WKSnapshotConfigurationClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKSnapshotConfigurationClass) Class

Class returns the underlying Objective-C class pointer.

type WKUIDelegate

type WKUIDelegate interface {
	objectivec.IObject
}

The methods for presenting native user interface elements on behalf of a webpage.

See: https://developer.apple.com/documentation/WebKit/WKUIDelegate

type WKUIDelegateConfig

type WKUIDelegateConfig struct {

	// Creating and closing the web view
	// WebViewDidClose — Notifies your app that the DOM window closed successfully.
	WebViewDidClose func(webView WKWebView)

	// Other Methods
	// WebViewCreateWebViewWithConfigurationForNavigationActionWindowFeatures — Creates a new web view.
	WebViewCreateWebViewWithConfigurationForNavigationActionWindowFeatures func(webView WKWebView, configuration WKWebViewConfiguration, navigationAction WKNavigationAction, windowFeatures WKWindowFeatures) WKWebView
}

WKUIDelegateConfig holds optional typed callbacks for WKUIDelegate methods. Set non-nil fields to register the corresponding Objective-C delegate method. Methods with nil callbacks are not registered, so [NSObject.RespondsToSelector] returns false for them — matching the Objective-C delegate pattern exactly.

See Apple Documentation for protocol details.

type WKUIDelegateObject

type WKUIDelegateObject struct {
	objectivec.Object
}

WKUIDelegateObject wraps an existing Objective-C object that conforms to the WKUIDelegate protocol.

func NewWKUIDelegate

func NewWKUIDelegate(config WKUIDelegateConfig) WKUIDelegateObject

NewWKUIDelegate creates an Objective-C object implementing the WKUIDelegate protocol.

Each call registers a unique Objective-C class containing only the methods set in config. This means [NSObject.RespondsToSelector] works correctly for optional delegate methods — only non-nil callbacks are registered.

The returned WKUIDelegateObject satisfies the WKUIDelegate interface and can be passed directly to SetDelegate and similar methods.

See Apple Documentation for protocol details.

func WKUIDelegateObjectFromID

func WKUIDelegateObjectFromID(id objc.ID) WKUIDelegateObject

WKUIDelegateObjectFromID constructs a WKUIDelegateObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (WKUIDelegateObject) BaseObject

func (o WKUIDelegateObject) BaseObject() objectivec.Object

func (WKUIDelegateObject) WebViewContextMenuConfigurationForElementCompletionHandler

func (o WKUIDelegateObject) WebViewContextMenuConfigurationForElementCompletionHandler(webView IWKWebView, elementInfo unsafe.Pointer, completionHandler UIContextMenuConfigurationHandler)

Tells the delegate that a contextual menu interaction began.

webView: The web view in which the interaction occurred.

elementInfo: An object that contains information about the element involved in the interaction.

completionHandler: The completion handler for you to call with information about how you want to handle the interaction. This handler block has no return value and takes the following parameter:

configuration: The UIContextMenuConfiguration object that contains the details of how you want to handle the interaction. Specify `nil` for this parameter if you don’t want to show a contextual menu.

See: https://developer.apple.com/documentation/WebKit/WKUIDelegate/webView(_:contextMenuConfigurationForElement:completionHandler:)

func (WKUIDelegateObject) WebViewContextMenuDidEndForElement

func (o WKUIDelegateObject) WebViewContextMenuDidEndForElement(webView IWKWebView, elementInfo unsafe.Pointer)

Tells the delegate that the web view dismissed the contextual menu for the specified element.

webView: The web view in which the interaction occurred.

elementInfo: An object that contains information about the element involved in the interaction.

See: https://developer.apple.com/documentation/WebKit/WKUIDelegate/webView(_:contextMenuDidEndForElement:)

func (WKUIDelegateObject) WebViewContextMenuForElementWillCommitWithAnimator

func (o WKUIDelegateObject) WebViewContextMenuForElementWillCommitWithAnimator(webView IWKWebView, elementInfo unsafe.Pointer, animator objectivec.IObject)

Provides the delegate with the animator object that the web view uses to display the contextual menu.

webView: The web view in which the interaction occurred.

elementInfo: An object that contains information about the element involved in the interaction.

animator: The animator object to use to commit additional animations related to the appearance of the contextual menu.

See: https://developer.apple.com/documentation/WebKit/WKUIDelegate/webView(_:contextMenuForElement:willCommitWithAnimator:)

func (WKUIDelegateObject) WebViewContextMenuWillPresentForElement

func (o WKUIDelegateObject) WebViewContextMenuWillPresentForElement(webView IWKWebView, elementInfo unsafe.Pointer)

Tells the delegate that the web view is about to present the contextual menu for the specified element.

webView: The web view in which the interaction occurred.

elementInfo: An object that contains information about the element involved in the interaction.

See: https://developer.apple.com/documentation/WebKit/WKUIDelegate/webView(_:contextMenuWillPresentForElement:)

func (WKUIDelegateObject) WebViewCreateWebViewWithConfigurationForNavigationActionWindowFeatures

func (o WKUIDelegateObject) WebViewCreateWebViewWithConfigurationForNavigationActionWindowFeatures(webView IWKWebView, configuration IWKWebViewConfiguration, navigationAction IWKNavigationAction, windowFeatures IWKWindowFeatures) IWKWebView

Creates a new web view.

webView: The web view invoking the delegate method.

configuration: The configuration to use when creating the new web view.

navigationAction: The navigation action causing the new web view to be created.

windowFeatures: Window features requested by the webpage.

Return Value

A new web view or `nil`.

Discussion

The web view returned must be created with the specified configuration. WebKit loads the request in the returned web view.

See: https://developer.apple.com/documentation/WebKit/WKUIDelegate/webView(_:createWebViewWith:for:windowFeatures:)

func (WKUIDelegateObject) WebViewDidClose

func (o WKUIDelegateObject) WebViewDidClose(webView IWKWebView)

Notifies your app that the DOM window closed successfully.

webView: The web view invoking the delegate method.

Discussion

Your app should remove the web view from the view hierarchy and update the UI as needed, for instance by closing the containing browser tab or window.

See: https://developer.apple.com/documentation/WebKit/WKUIDelegate/webViewDidClose(_:)

func (WKUIDelegateObject) WebViewRequestDeviceOrientationAndMotionPermissionForOriginInitiatedByFrameDecisionHandler

func (o WKUIDelegateObject) WebViewRequestDeviceOrientationAndMotionPermissionForOriginInitiatedByFrameDecisionHandler(webView IWKWebView, origin IWKSecurityOrigin, frame IWKFrameInfo, decisionHandler WKPermissionDecisionHandler)

Determines whether a web resource, which the security origin object describes, can access the device’s orientation and motion.

webView: The web view requesting permission for orientation and motion information.

origin: An object that identifies the host name, protocol, and port number for a web resource.

frame: The frame that initiates the request in the web view.

decisionHandler: A closure that you call from your delegate method. Pass the permission decision you determine to the closure.

Discussion

If you don’t implement this method in your delegate, the system returns WKPermissionDecisionPrompt.

See: https://developer.apple.com/documentation/WebKit/WKUIDelegate/webView(_:requestDeviceOrientationAndMotionPermissionFor:initiatedByFrame:decisionHandler:)

func (WKUIDelegateObject) WebViewRequestMediaCapturePermissionForOriginInitiatedByFrameTypeDecisionHandler

func (o WKUIDelegateObject) WebViewRequestMediaCapturePermissionForOriginInitiatedByFrameTypeDecisionHandler(webView IWKWebView, origin IWKSecurityOrigin, frame IWKFrameInfo, type_ WKMediaCaptureType, decisionHandler WKPermissionDecisionHandler)

Determines whether a web resource, which the security origin object describes, can access to the device’s microphone audio and camera video.

webView: The web view requesting permission for microphone audio and camera video.

origin: An object that identifies the host name, protocol, and port number for a web resource.

frame: The frame that initiates the request in the web view.

type: An enumeration case representing a type of media capture device, like a microphone or camera.

decisionHandler: A closure that you call from your delegate method. Pass the permission decision you determine to the closure.

Discussion

If you don’t implement this method in your delegate, the system returns WKPermissionDecisionPrompt.

See: https://developer.apple.com/documentation/WebKit/WKUIDelegate/webView(_:requestMediaCapturePermissionFor:initiatedByFrame:type:decisionHandler:)

func (WKUIDelegateObject) WebViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler

func (o WKUIDelegateObject) WebViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler(webView IWKWebView, message string, frame IWKFrameInfo, completionHandler VoidHandler)

Displays a JavaScript alert panel.

webView: The web view invoking the delegate method.

message: The message to be displayed.

frame: Information about the frame whose JavaScript process initiated this call.

completionHandler: The completion handler to call after the alert panel has been dismissed.

Discussion

For user security, implementations of this method should call attention to the fact that a specific website controls the content in this panel. A simple formula for identifying the controlling website is `frame.Request().URL.Host()`. The panel should have a single OK button.

See: https://developer.apple.com/documentation/WebKit/WKUIDelegate/webView(_:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:)

func (WKUIDelegateObject) WebViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler

func (o WKUIDelegateObject) WebViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler(webView IWKWebView, message string, frame IWKFrameInfo, completionHandler BoolHandler)

Displays a JavaScript confirm panel.

webView: The web view invoking the delegate method.

message: The message to be displayed.

frame: Information about the frame whose JavaScript process initiated this call.

completionHandler: The completion handler to call after the confirm panel has been dismissed. Pass true if the user chose OK, and pass false if the user chose Cancel.

Discussion

For user security, implementations of this method should call attention to the fact that a specific website controls the content in this panel. A simple formula for identifying the controlling website is `frame.Request().URL.Host()`. The panel should have two buttons, typically OK and Cancel.

See: https://developer.apple.com/documentation/WebKit/WKUIDelegate/webView(_:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)

func (WKUIDelegateObject) WebViewShowLockdownModeFirstUseMessageCompletionHandler

func (o WKUIDelegateObject) WebViewShowLockdownModeFirstUseMessageCompletionHandler(webView IWKWebView, message string, completionHandler WKDialogResultHandler)

Displays a custom Lockdown Mode first use message.

webView: The web view that is requesting to display the Lockdown Mode first use dialog.

message: The message for the web view to display if the delegate does not display the first use dialog.

completionHandler: A block you must invoke to resume after the web view displays the first use dialog. The block does not return a value, and accepts the following parameter:

dialogResult: A display result case that indicates how the method handled the display request.

Discussion

Implement this method to display a custom Lockdown Mode message, or to suppress the message. Return, or call the completion handler, with a WKDialogResult case that indicates how your method handled the display request. For more information about Lockdown Mode, see About Lockdown Mode.

If you don’t implement this method, the web view displays the default message.

See: https://developer.apple.com/documentation/WebKit/WKUIDelegate/webView(_:showLockdownModeFirstUseMessage:completionHandler:)

func (WKUIDelegateObject) WebViewWillDismissEditMenuWithAnimator

func (o WKUIDelegateObject) WebViewWillDismissEditMenuWithAnimator(webView IWKWebView, animator objectivec.IObject)

Tells the delegate that the web view is about to dismiss an edit menu.

See: https://developer.apple.com/documentation/WebKit/WKUIDelegate/webView(_:willDismissEditMenuWithAnimator:)

func (WKUIDelegateObject) WebViewWillPresentEditMenuWithAnimator

func (o WKUIDelegateObject) WebViewWillPresentEditMenuWithAnimator(webView IWKWebView, animator objectivec.IObject)

Tells the delegate that the web view is about to present an edit menu.

See: https://developer.apple.com/documentation/WebKit/WKUIDelegate/webView(_:willPresentEditMenuWithAnimator:)

type WKURLSchemeHandler

type WKURLSchemeHandler interface {
	objectivec.IObject

	// Asks your handler to begin loading the data for the specified resource.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKURLSchemeHandler/webView(_:start:)
	WebViewStartURLSchemeTask(webView IWKWebView, urlSchemeTask WKURLSchemeTask)

	// Asks your handler to stop loading the data for the specified resource.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKURLSchemeHandler/webView(_:stop:)
	WebViewStopURLSchemeTask(webView IWKWebView, urlSchemeTask WKURLSchemeTask)
}

A protocol for loading resources with URL schemes that WebKit doesn’t handle.

See: https://developer.apple.com/documentation/WebKit/WKURLSchemeHandler

type WKURLSchemeHandlerObject

type WKURLSchemeHandlerObject struct {
	objectivec.Object
}

WKURLSchemeHandlerObject wraps an existing Objective-C object that conforms to the WKURLSchemeHandler protocol.

func WKURLSchemeHandlerObjectFromID

func WKURLSchemeHandlerObjectFromID(id objc.ID) WKURLSchemeHandlerObject

WKURLSchemeHandlerObjectFromID constructs a WKURLSchemeHandlerObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (WKURLSchemeHandlerObject) BaseObject

func (WKURLSchemeHandlerObject) WebViewStartURLSchemeTask

func (o WKURLSchemeHandlerObject) WebViewStartURLSchemeTask(webView IWKWebView, urlSchemeTask WKURLSchemeTask)

Asks your handler to begin loading the data for the specified resource.

webView: The web view that requires the resource.

urlSchemeTask: The task object that identifies the resource to load. You also use this object to report the progress of the load operation back to the web view.

Discussion

When a web view encounters a resource with your custom URL scheme, it calls this method on the appropriate handler object. Use your implementation of this method to begin loading the resource. Call the methods of the provided WKURLSchemeTask object to report the progress of the loading operation back to the web view. You also use that object to deliver the resource data to the web view.

See: https://developer.apple.com/documentation/WebKit/WKURLSchemeHandler/webView(_:start:)

func (WKURLSchemeHandlerObject) WebViewStopURLSchemeTask

func (o WKURLSchemeHandlerObject) WebViewStopURLSchemeTask(webView IWKWebView, urlSchemeTask WKURLSchemeTask)

Asks your handler to stop loading the data for the specified resource.

webView: The web view that asked you to stop loading the resource.

urlSchemeTask: The task object that identifies the resource the web view no longer needs.

Discussion

If WebKit determines that it no longer needs a resource that your handler is loading, it calls this method to stop the load operation. Typically, WebKit calls this method when the user navigates to another page, but may call it for other reasons.

When WebKit calls this method, stop the load operation immediately for the specified resource and free up any allocated memory for it. Don’t call any methods of the provided `urlSchemeTask` object to report your progress back to WebKit. If you do, the methods of that object raise an exception.

See: https://developer.apple.com/documentation/WebKit/WKURLSchemeHandler/webView(_:stop:)

type WKURLSchemeTask

type WKURLSchemeTask interface {
	objectivec.IObject

	// Information about the resource to load.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKURLSchemeTask/request
	Request() foundation.NSURLRequest

	// Returns a URL response to WebKit with information about the requested resource.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKURLSchemeTask/didReceive(_:)-2u23r
	DidReceiveResponse(response foundation.NSURLResponse)

	// Sends some or all of the resource data to WebKit.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKURLSchemeTask/didReceive(_:)-8t5f8
	DidReceiveData(data foundation.INSData)

	// Signals the successful completion of the task.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKURLSchemeTask/didFinish()
	DidFinish()

	// Completes the task and reports the specified error back to WebKit.
	//
	// See: https://developer.apple.com/documentation/WebKit/WKURLSchemeTask/didFailWithError(_:)
	DidFailWithError(error_ foundation.INSError)
}

An interface that WebKit uses to request custom resources from your app.

See: https://developer.apple.com/documentation/WebKit/WKURLSchemeTask

type WKURLSchemeTaskObject

type WKURLSchemeTaskObject struct {
	objectivec.Object
}

WKURLSchemeTaskObject wraps an existing Objective-C object that conforms to the WKURLSchemeTask protocol.

func WKURLSchemeTaskObjectFromID

func WKURLSchemeTaskObjectFromID(id objc.ID) WKURLSchemeTaskObject

WKURLSchemeTaskObjectFromID constructs a WKURLSchemeTaskObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (WKURLSchemeTaskObject) BaseObject

func (o WKURLSchemeTaskObject) BaseObject() objectivec.Object

func (WKURLSchemeTaskObject) DidFailWithError

func (o WKURLSchemeTaskObject) DidFailWithError(error_ foundation.INSError)

Completes the task and reports the specified error back to WebKit.

error: The error that caused the task to fail.

Discussion

This method signals to WebKit that the task is complete, but failed with the specified error. Use this method to report any errors during the load process.

After calling this method, it’s a programmer error to call other methods of the task object, and those methods raise an exception if you do. This method raises an exception if you call it after WebKit calls the [WebViewStopURLSchemeTask] method of the corresponding handler object.

See: https://developer.apple.com/documentation/WebKit/WKURLSchemeTask/didFailWithError(_:)

func (WKURLSchemeTaskObject) DidFinish

func (o WKURLSchemeTaskObject) DidFinish()

Signals the successful completion of the task.

Discussion

This method signals to WebKit that it has all of the resource’s data and the task is now complete. Call this method after sending a response and the resource data to WebKit using the [DidReceiveResponse] and [DidReceiveData] methods.

This method raises an exception if you call it before the [DidReceiveResponse] method, or if the task is already complete. It also raises an exception if you call it after WebKit calls the [WebViewStopURLSchemeTask] method of the corresponding handler object.

See: https://developer.apple.com/documentation/WebKit/WKURLSchemeTask/didFinish()

func (WKURLSchemeTaskObject) DidReceiveData

func (o WKURLSchemeTaskObject) DidReceiveData(data foundation.INSData)

Sends some or all of the resource data to WebKit.

data: Data for the resource. This object may contain all of the data or only some of it.

Discussion

Call this method to deliver any resource data back to WebKit. If you load the data incrementally, you may call this method multiple times to deliver each new portion of the data. Each time you call this method, WebKit appends the new data to any previously received data.

This method raises an exception if you call it before the [DidReceiveResponse] method, or after the [DidFinish] method. It also raises an exception if you call it after WebKit calls the [WebViewStopURLSchemeTask] method of the corresponding handler object.

See: https://developer.apple.com/documentation/WebKit/WKURLSchemeTask/didReceive(_:)-8t5f8

func (WKURLSchemeTaskObject) DidReceiveResponse

func (o WKURLSchemeTaskObject) DidReceiveResponse(response foundation.NSURLResponse)

Returns a URL response to WebKit with information about the requested resource.

response: The response to return to WebKit. Your response object must include the MIME type of the requested resource.

Discussion

Call this method to provide WebKit with the MIME type of the requested resource and its expected size. You must call this method at least once for each task, and you may call it multiple times if needed. Always call it before sending any data back to WebKit using the [DidReceiveData] method.

It is a programmer error to call this method after calling the [DidFinish] method of the same task object. It is also a programmer error to call this method after WebKit calls the [WebViewStopURLSchemeTask] method of the corresponding handler object. If you do, this method raises an exception in both cases.

See: https://developer.apple.com/documentation/WebKit/WKURLSchemeTask/didReceive(_:)-2u23r

func (WKURLSchemeTaskObject) Request

Information about the resource to load.

See: https://developer.apple.com/documentation/WebKit/WKURLSchemeTask/request

type WKUserContentController

type WKUserContentController struct {
	objectivec.Object
}

An object for managing interactions between JavaScript code and your web view, and for filtering content in your web view.

Overview

A WKUserContentController object provides a bridge between your app and the JavaScript code running in the web view. Use this object to do the following:

- Inject JavaScript code into webpages running in your web view. - Install custom JavaScript functions that call through to your app’s native code. - Specify custom filters to prevent the webpage from loading restricted content.

Create and configure a WKUserContentController object as part of your overall web view setup. Assign the object to the [UserContentController] property of your WKWebViewConfiguration object before creating your web view.

Adding and Removing Custom Scripts

Adding and Removing Message Handlers

Adding and Removing Content Rules

See: https://developer.apple.com/documentation/WebKit/WKUserContentController

func NewWKUserContentController

func NewWKUserContentController() WKUserContentController

NewWKUserContentController creates a new WKUserContentController instance.

func WKUserContentControllerFromID

func WKUserContentControllerFromID(id objc.ID) WKUserContentController

WKUserContentControllerFromID constructs a WKUserContentController from an objc.ID.

An object for managing interactions between JavaScript code and your web view, and for filtering content in your web view.

func (WKUserContentController) AddContentRuleList

func (u WKUserContentController) AddContentRuleList(contentRuleList IWKContentRuleList)

Adds the specified content rule list to the content controller object.

contentRuleList: The rule list to add. Create and retrieve rules lists using a [WKContentExtensionStore] object.

Discussion

Call this method to apply a set of content filtering rules to your web view’s configuration.

See: https://developer.apple.com/documentation/WebKit/WKUserContentController/add(_:)

func (WKUserContentController) AddScriptMessageHandlerContentWorldName

func (u WKUserContentController) AddScriptMessageHandlerContentWorldName(scriptMessageHandler WKScriptMessageHandler, world IWKContentWorld, name string)

Installs a message handler that you can call from the specified content world in your JavaScript code.

scriptMessageHandler: The message handler object that implements your custom code. This object must adopt the WKScriptMessageHandler protocol.

world: The content world in which to install the message handler. Use the content world to scope your message handler to specific parts of your JavaScript code.

name: The name of the message handler. This parameter must be unique within the user content controller and must not be an empty string.

The user content controller uses this parameter to define a JavaScript function for your message handler in all frames in the specified content world. The name of this function is `window.WebkitXCUIElementTypeMessageHandlers().“XCUIElementTypePostMessage()`, where corresponds to the value of this parameter. For example, if you specify the string [MyFunction], the user content controller defines the `window.WebkitXCUIElementTypeMessageHandlers().MyFunction.PostMessage()` function in JavaScript.

Discussion

To execute your handler’s code, call the JavaScript function that this method defines. You may pass a parameter value to the method. The user content controller packages that value into an appropriate type and delivers it to your content handler’s delegate method.

See: https://developer.apple.com/documentation/WebKit/WKUserContentController/add(_:contentWorld:name:)

func (WKUserContentController) AddScriptMessageHandlerName

func (u WKUserContentController) AddScriptMessageHandlerName(scriptMessageHandler WKScriptMessageHandler, name string)

Installs a message handler that you can call from your JavaScript code.

scriptMessageHandler: The message handler object that implements your custom code. This object must adopt the WKScriptMessageHandler protocol.

name: The name of the message handler. This parameter must be unique within the user content controller and must not be an empty string.

The user content controller uses this parameter to define a JavaScript function for your message handler in the page’s main content world. The name of this function is `window.WebkitXCUIElementTypeMessageHandlers().“XCUIElementTypePostMessage()`, where corresponds to the value of this parameter. For example, if you specify the string [MyFunction], the user content controller defines the `window.WebkitXCUIElementTypeMessageHandlers().MyFunction.PostMessage()` function in JavaScript.

Discussion

To execute your handler’s code, call the JavaScript function that this method defines. You may pass a parameter value to the method. The user content controller packages that value into an appropriate type and delivers it to your content handler’s delegate method.

This method uses the content world from the [PageWorld] property of WKContentWorld.

See: https://developer.apple.com/documentation/WebKit/WKUserContentController/add(_:name:)

func (WKUserContentController) AddScriptMessageHandlerWithReplyContentWorldName

func (u WKUserContentController) AddScriptMessageHandlerWithReplyContentWorldName(scriptMessageHandlerWithReply WKScriptMessageHandlerWithReply, contentWorld IWKContentWorld, name string)

Installs a message handler that returns a reply to your JavaScript code.

scriptMessageHandlerWithReply: The message handler object that implements your custom code. This object must adopt the WKScriptMessageHandlerWithReply protocol.

contentWorld: The content world in which to install the message handler. Use the content world to scope your message handler to specific parts of your JavaScript code.

name: The name of the message handler. This parameter must be unique within the user content controller and must not be an empty string.

The user content controller uses this parameter to define a JavaScript function for your message handler in all frames in the specified content world. The name of this function is `window.WebkitXCUIElementTypeMessageHandlers().“XCUIElementTypePostMessage()`, where corresponds to the value of this parameter. For example, if you specify the string [MyFunction], the user content controller defines the `window.WebkitXCUIElementTypeMessageHandlers().MyFunction.PostMessage()` function in JavaScript.

Discussion

To execute your handler’s code, call the JavaScript function that this method defines. You may pass a parameter value to the method. The user content controller packages that value into an appropriate type and delivers it to your content handler’s delegate method.

See: https://developer.apple.com/documentation/WebKit/WKUserContentController/addScriptMessageHandler(_:contentWorld:name:)

func (WKUserContentController) AddUserScript

func (u WKUserContentController) AddUserScript(userScript IWKUserScript)

Injects the specified script into the webpage’s content.

userScript: The user script to add to the web view’s current page.

See: https://developer.apple.com/documentation/WebKit/WKUserContentController/addUserScript(_:)

func (WKUserContentController) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKUserContentController) EncodeWithCoder

func (u WKUserContentController) EncodeWithCoder(coder foundation.INSCoder)

func (WKUserContentController) Init

Init initializes the instance.

func (WKUserContentController) RemoveAllContentRuleLists

func (u WKUserContentController) RemoveAllContentRuleLists()

Removes all rules lists from the content controller.

Discussion

This method removes the rule lists only from the user content controller object. You can still access rule lists from the WKContentRuleListStore objects you used to create them.

See: https://developer.apple.com/documentation/WebKit/WKUserContentController/removeAllContentRuleLists()

func (WKUserContentController) RemoveAllScriptMessageHandlers

func (u WKUserContentController) RemoveAllScriptMessageHandlers()

Uninstalls all custom message handlers associated with the user content controller.

Discussion

Use this method to remove all message handlers in all content worlds in your JavaScript code.

See: https://developer.apple.com/documentation/WebKit/WKUserContentController/removeAllScriptMessageHandlers()

func (WKUserContentController) RemoveAllScriptMessageHandlersFromContentWorld

func (u WKUserContentController) RemoveAllScriptMessageHandlersFromContentWorld(contentWorld IWKContentWorld)

Uninstalls all custom message handlers from the specified content world in your JavaScript code.

contentWorld: The content world from which to remove the message handler. For more information about content worlds, see WKContentWorld.

Discussion

Use this method to remove all message handlers in the specified content world. Message handlers in other content worlds are unaffected.

See: https://developer.apple.com/documentation/WebKit/WKUserContentController/removeAllScriptMessageHandlers(from:)

func (WKUserContentController) RemoveAllUserScripts

func (u WKUserContentController) RemoveAllUserScripts()

Removes all user scripts from the web view.

See: https://developer.apple.com/documentation/WebKit/WKUserContentController/removeAllUserScripts()

func (WKUserContentController) RemoveContentRuleList

func (u WKUserContentController) RemoveContentRuleList(contentRuleList IWKContentRuleList)

Removes the specified rule list from the content controller object.

contentRuleList: The rule list to remove.

Discussion

This method removes the rule list only from the user content controller object. You can still access the rule list from the WKContentRuleListStore object you used to create it.

See: https://developer.apple.com/documentation/WebKit/WKUserContentController/remove(_:)

func (WKUserContentController) RemoveScriptMessageHandlerForName

func (u WKUserContentController) RemoveScriptMessageHandlerForName(name string)

Uninstalls the custom message handler with the specified name from your JavaScript code.

name: The name of the message handler to remove. If no message handler with this name exists in the user content controller, this method does nothing.

Discussion

Use this method to remove a message handler that you previously installed using the [AddScriptMessageHandlerName] method. This method removes the message handler from the page content world — that is, the content world available from the [PageWorld] property of WKContentWorld. If you installed the message handler in a different content world, this method doesn’t remove it.

See: https://developer.apple.com/documentation/WebKit/WKUserContentController/removeScriptMessageHandler(forName:)

func (WKUserContentController) RemoveScriptMessageHandlerForNameContentWorld

func (u WKUserContentController) RemoveScriptMessageHandlerForNameContentWorld(name string, contentWorld IWKContentWorld)

Uninstalls a custom message handler from the specified content world in your JavaScript code.

name: The name of the message handler to remove. If no message handler with this name exists in the user content controller, this method does nothing.

contentWorld: The content world from which to remove the message handler. For more information about content worlds, see WKContentWorld.

See: https://developer.apple.com/documentation/WebKit/WKUserContentController/removeScriptMessageHandler(forName:contentWorld:)

func (WKUserContentController) SetUserContentController

func (u WKUserContentController) SetUserContentController(value IWKUserContentController)

func (WKUserContentController) UserContentController

func (u WKUserContentController) UserContentController() IWKUserContentController

The object that coordinates interactions between your app’s native code and the webpage’s scripts and other content.

See: https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/usercontentcontroller

func (WKUserContentController) UserScripts

func (u WKUserContentController) UserScripts() []WKUserScript

The user scripts associated with the user content controller.

See: https://developer.apple.com/documentation/WebKit/WKUserContentController/userScripts

type WKUserContentControllerClass

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

func GetWKUserContentControllerClass

func GetWKUserContentControllerClass() WKUserContentControllerClass

GetWKUserContentControllerClass returns the class object for WKUserContentController.

func (WKUserContentControllerClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKUserContentControllerClass) Class

Class returns the underlying Objective-C class pointer.

type WKUserInterfaceDirectionPolicy

type WKUserInterfaceDirectionPolicy int

See: https://developer.apple.com/documentation/WebKit/WKUserInterfaceDirectionPolicy

const (
	// WKUserInterfaceDirectionPolicyContent: The directionality follows the CSS/HTML/XHTML specifications.
	WKUserInterfaceDirectionPolicyContent WKUserInterfaceDirectionPolicy = 0
	// WKUserInterfaceDirectionPolicySystem: The directionality follows the view’s user interface layout direction.
	WKUserInterfaceDirectionPolicySystem WKUserInterfaceDirectionPolicy = 1
)

func (WKUserInterfaceDirectionPolicy) String

type WKUserScript

type WKUserScript struct {
	objectivec.Object
}

A script that the web view injects into a webpage.

Overview

Create a WKUserScript object when you want to inject custom script code into the pages of your web view. Use this object to specify the JavaScript code to inject, and parameters relating to when and how to inject that code. Before you create the web view, add this object to the WKUserContentController object associated with your web view’s configuration.

Creating a User Script Object

Inspecting Script Information

See: https://developer.apple.com/documentation/WebKit/WKUserScript

func NewUserScriptWithSourceInjectionTimeForMainFrameOnly

func NewUserScriptWithSourceInjectionTimeForMainFrameOnly(source string, injectionTime WKUserScriptInjectionTime, forMainFrameOnly bool) WKUserScript

Creates a user script object that contains the specified source code and attributes.

source: The script’s source code.

injectionTime: The time at which to inject the script into the webpage. For a list of possible values, see WKUserScriptInjectionTime.

forMainFrameOnly: A Boolean value that indicates whether to inject the script into the main frame. Specify true to inject the script only into the main frame, or false to inject it into all frames.

Return Value

An initialized user script, or `nil` if initialization failed.

Discussion

This method sets the script’s content world to the object in the [PageWorld] property of WKContentWorld.

See: https://developer.apple.com/documentation/WebKit/WKUserScript/init(source:injectionTime:forMainFrameOnly:)

func NewUserScriptWithSourceInjectionTimeForMainFrameOnlyInContentWorld

func NewUserScriptWithSourceInjectionTimeForMainFrameOnlyInContentWorld(source string, injectionTime WKUserScriptInjectionTime, forMainFrameOnly bool, contentWorld IWKContentWorld) WKUserScript

Creates a user script object that is scoped to a particular content world.

source: The script’s source code.

injectionTime: The time at which to inject the script into the webpage. For a list of possible values, see WKUserScriptInjectionTime.

forMainFrameOnly: A Boolean value that indicates whether to inject the script into the main frame. Specify true to inject the script only into the main frame, or false to inject it into all frames.

contentWorld: The namespace in which to evaluate the script. This parameter doesn’t apply to changes your script makes to the underlying web content, such as the document’s DOM structure. Those changes remain visible to all scripts, regardless of which content world you specify. For more information about content worlds, see WKContentWorld.

Return Value

An initialized user script, or `nil` if initialization failed.

See: https://developer.apple.com/documentation/WebKit/WKUserScript/init(source:injectionTime:forMainFrameOnly:in:)

func NewWKUserScript

func NewWKUserScript() WKUserScript

NewWKUserScript creates a new WKUserScript instance.

func WKUserScriptFromID

func WKUserScriptFromID(id objc.ID) WKUserScript

WKUserScriptFromID constructs a WKUserScript from an objc.ID.

A script that the web view injects into a webpage.

func (WKUserScript) Autorelease

func (u WKUserScript) Autorelease() WKUserScript

Autorelease adds the receiver to the current autorelease pool.

func (WKUserScript) ForMainFrameOnly

func (u WKUserScript) ForMainFrameOnly() bool

A Boolean value that indicates whether to inject the script into the main frame or all frames.

Discussion

When the value of this property is true, the web view injects the script only into the main frame. When the value is false, the web view injects the script into all frames.

See: https://developer.apple.com/documentation/WebKit/WKUserScript/isForMainFrameOnly

func (WKUserScript) Init

func (u WKUserScript) Init() WKUserScript

Init initializes the instance.

func (WKUserScript) InitWithSourceInjectionTimeForMainFrameOnly

func (u WKUserScript) InitWithSourceInjectionTimeForMainFrameOnly(source string, injectionTime WKUserScriptInjectionTime, forMainFrameOnly bool) WKUserScript

Creates a user script object that contains the specified source code and attributes.

source: The script’s source code.

injectionTime: The time at which to inject the script into the webpage. For a list of possible values, see WKUserScriptInjectionTime.

forMainFrameOnly: A Boolean value that indicates whether to inject the script into the main frame. Specify true to inject the script only into the main frame, or false to inject it into all frames.

Return Value

An initialized user script, or `nil` if initialization failed.

Discussion

This method sets the script’s content world to the object in the [PageWorld] property of WKContentWorld.

See: https://developer.apple.com/documentation/WebKit/WKUserScript/init(source:injectionTime:forMainFrameOnly:)

func (WKUserScript) InitWithSourceInjectionTimeForMainFrameOnlyInContentWorld

func (u WKUserScript) InitWithSourceInjectionTimeForMainFrameOnlyInContentWorld(source string, injectionTime WKUserScriptInjectionTime, forMainFrameOnly bool, contentWorld IWKContentWorld) WKUserScript

Creates a user script object that is scoped to a particular content world.

source: The script’s source code.

injectionTime: The time at which to inject the script into the webpage. For a list of possible values, see WKUserScriptInjectionTime.

forMainFrameOnly: A Boolean value that indicates whether to inject the script into the main frame. Specify true to inject the script only into the main frame, or false to inject it into all frames.

contentWorld: The namespace in which to evaluate the script. This parameter doesn’t apply to changes your script makes to the underlying web content, such as the document’s DOM structure. Those changes remain visible to all scripts, regardless of which content world you specify. For more information about content worlds, see WKContentWorld.

Return Value

An initialized user script, or `nil` if initialization failed.

See: https://developer.apple.com/documentation/WebKit/WKUserScript/init(source:injectionTime:forMainFrameOnly:in:)

func (WKUserScript) InjectionTime

func (u WKUserScript) InjectionTime() WKUserScriptInjectionTime

The time at which to inject the script into the webpage.

Discussion

The value is one of the constants of the enumerated type WKUserScriptInjectionTime.

See: https://developer.apple.com/documentation/WebKit/WKUserScript/injectionTime

func (WKUserScript) Source

func (u WKUserScript) Source() string

The script’s source code.

See: https://developer.apple.com/documentation/WebKit/WKUserScript/source

type WKUserScriptClass

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

func GetWKUserScriptClass

func GetWKUserScriptClass() WKUserScriptClass

GetWKUserScriptClass returns the class object for WKUserScript.

func (WKUserScriptClass) Alloc

func (wc WKUserScriptClass) Alloc() WKUserScript

Alloc allocates memory for a new instance of the class.

func (WKUserScriptClass) Class

func (wc WKUserScriptClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKUserScriptInjectionTime

type WKUserScriptInjectionTime int

See: https://developer.apple.com/documentation/WebKit/WKUserScriptInjectionTime

const (
	// WKUserScriptInjectionTimeAtDocumentEnd: A constant to inject the script after the document finishes loading, but before loading any other subresources.
	WKUserScriptInjectionTimeAtDocumentEnd WKUserScriptInjectionTime = 1
	// WKUserScriptInjectionTimeAtDocumentStart: A constant to inject the script after the creation of the webpage’s document element, but before loading any other content.
	WKUserScriptInjectionTimeAtDocumentStart WKUserScriptInjectionTime = 0
)

func (WKUserScriptInjectionTime) String

func (e WKUserScriptInjectionTime) String() string

type WKWebExtension

type WKWebExtension struct {
	objectivec.Object
}

An object that encapsulates a web extension’s resources that the manifest file defines.

Overview

This class reads and parses the `manifest.Json()` file along with the supporting resources like icons and localizations.

Instance Properties

Instance Methods

See: https://developer.apple.com/documentation/WebKit/WKWebExtension

func NewWKWebExtension

func NewWKWebExtension() WKWebExtension

NewWKWebExtension creates a new WKWebExtension instance.

func WKWebExtensionFromID

func WKWebExtensionFromID(id objc.ID) WKWebExtension

WKWebExtensionFromID constructs a WKWebExtension from an objc.ID.

An object that encapsulates a web extension’s resources that the manifest file defines.

func (WKWebExtension) ActionIconForSize

func (w WKWebExtension) ActionIconForSize(size corefoundation.CGSize) objc.ID

Returns the default action icon for the specified size.

size: The size to use when looking up the action icon.

Return Value

The action icon, or `nil` if the icon was unable to be loaded.

Discussion

This icon serves as a default and should be used to represent the extension in contexts like action sheets or toolbars prior to the extension being loaded into an extension context. Once the extension is loaded, use the [ActionForTab] API to get the tab-specific icon.

The returned image will be the best match for the specified size that is available in the extension’s action icon set. If no matching icon is available, the method will fall back to the extension’s icon.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/actionIcon(for:)

func (WKWebExtension) AllRequestedMatchPatterns

func (w WKWebExtension) AllRequestedMatchPatterns() foundation.INSSet

The set of websites that the extension requires access to for injected content and for receiving messages from websites.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/allRequestedMatchPatterns

func (WKWebExtension) Autorelease

func (w WKWebExtension) Autorelease() WKWebExtension

Autorelease adds the receiver to the current autorelease pool.

func (WKWebExtension) DefaultLocale

func (w WKWebExtension) DefaultLocale() foundation.NSLocale

The default locale for the extension.

Discussion

Returns `nil` if there was no default locale specified.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/defaultLocale

func (WKWebExtension) DisplayActionLabel

func (w WKWebExtension) DisplayActionLabel() string

The default localized extension action label.

Discussion

Returns `nil` if there was no default action label specified.

This label serves as a default and should be used to represent the extension in contexts like action sheets or toolbars prior to the extension being loaded into an extension context. Once the extension is loaded, use the [ActionForTab] API to get the tab-specific label.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/displayActionLabel

func (WKWebExtension) DisplayDescription

func (w WKWebExtension) DisplayDescription() string

The localized extension description.

Discussion

Returns `nil` if there was no description specified.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/displayDescription

func (WKWebExtension) DisplayName

func (w WKWebExtension) DisplayName() string

The localized extension name.

Discussion

Returns `nil` if there was no name specified.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/displayName

func (WKWebExtension) DisplayShortName

func (w WKWebExtension) DisplayShortName() string

The localized extension short name.

Discussion

Returns `nil` if there was no short name specified.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/displayShortName

func (WKWebExtension) DisplayVersion

func (w WKWebExtension) DisplayVersion() string

The localized extension display version.

Discussion

Returns `nil` if there was no display version specified.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/displayVersion

func (WKWebExtension) Errors

func (w WKWebExtension) Errors() []foundation.NSError

An array of all errors that occurred during the processing of the extension.

Discussion

Provides an array of all parse-time errors for the extension, with repeat errors consolidated into a single entry for the original occurrence only. If no errors occurred, an empty array is returned.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/errors

func (WKWebExtension) HasBackgroundContent

func (w WKWebExtension) HasBackgroundContent() bool

A Boolean value indicating whether the extension has background content that can run when needed.

Discussion

If this property is [YES], the extension can run in the background even when no webpages are open.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/hasBackgroundContent

func (WKWebExtension) HasCommands

func (w WKWebExtension) HasCommands() bool

A Boolean value indicating whether the extension includes commands that users can invoke.

Discussion

If this property is [YES], the extension contains one or more commands that can be performed by the user. These commands should be accessible via keyboard shortcuts, menu items, or other user interface elements provided by the app. The list of commands can be accessed via [Commands] on an extension context, and invoked via [PerformCommand].

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/hasCommands

func (WKWebExtension) HasContentModificationRules

func (w WKWebExtension) HasContentModificationRules() bool

A Boolean value indicating whether the extension includes rules used for content modification or blocking.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/hasContentModificationRules

func (WKWebExtension) HasInjectedContent

func (w WKWebExtension) HasInjectedContent() bool

A Boolean value indicating whether the extension has script or stylesheet content that can be injected into webpages.

Discussion

If this property is [YES], the extension has content that can be injected by matching against the extension’s requested match patterns.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/hasInjectedContent

func (WKWebExtension) HasOptionsPage

func (w WKWebExtension) HasOptionsPage() bool

A Boolean value indicating whether the extension has an options page.

Discussion

If this property is [YES], the extension includes a dedicated options page where users can customize settings. The app should provide access to this page through a user interface element, which can be accessed via [OptionsPageURL] on an extension context.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/hasOptionsPage

func (WKWebExtension) HasOverrideNewTabPage

func (w WKWebExtension) HasOverrideNewTabPage() bool

A Boolean value indicating whether the extension provides an alternative to the default new tab page.

Discussion

If this property is [YES], the extension can specify a custom page that can be displayed when a new tab is opened in the app, instead of the default new tab page. The app should prompt the user for permission to use the extension’s new tab page as the default, which can be accessed via [OverrideNewTabPageURL] on an extension context.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/hasOverrideNewTabPage

func (WKWebExtension) HasPersistentBackgroundContent

func (w WKWebExtension) HasPersistentBackgroundContent() bool

A Boolean value indicating whether the extension has background content that stays in memory as long as the extension is loaded.

Discussion

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/hasPersistentBackgroundContent

func (WKWebExtension) IconForSize

func (w WKWebExtension) IconForSize(size corefoundation.CGSize) objc.ID

Returns the extension’s icon image for the specified size.

size: The size to use when looking up the icon.

Return Value

The extension’s icon image, or `nil` if the icon was unable to be loaded.

Discussion

This icon should represent the extension in settings or other areas that show the extension. The returned image will be the best match for the specified size that is available in the extension’s icon set. If no matching icon can be found, the method will return `nil`.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/icon(for:)

func (WKWebExtension) Init

func (w WKWebExtension) Init() WKWebExtension

Init initializes the instance.

func (WKWebExtension) Manifest

The parsed manifest as a dictionary.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/manifest

func (WKWebExtension) ManifestVersion

func (w WKWebExtension) ManifestVersion() float64

The parsed manifest version, or `0` if there is no version specified in the manifest.

Discussion

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/manifestVersion

func (WKWebExtension) OptionalPermissionMatchPatterns

func (w WKWebExtension) OptionalPermissionMatchPatterns() foundation.INSSet

The set of websites that the extension may need access to for optional functionality.

Discussion

These match patterns can be requested by the extension at a later time.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/optionalPermissionMatchPatterns

func (WKWebExtension) OptionalPermissions

func (w WKWebExtension) OptionalPermissions() foundation.INSSet

The set of permissions that the extension may need for optional functionality.

Discussion

These permissions can be requested by the extension at a later time.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/optionalPermissions

func (WKWebExtension) RequestedPermissionMatchPatterns

func (w WKWebExtension) RequestedPermissionMatchPatterns() foundation.INSSet

The set of websites that the extension requires access to for its base functionality.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/requestedPermissionMatchPatterns

func (WKWebExtension) RequestedPermissions

func (w WKWebExtension) RequestedPermissions() foundation.INSSet

The set of permissions that the extension requires for its base functionality.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/requestedPermissions

func (WKWebExtension) SupportsManifestVersion

func (w WKWebExtension) SupportsManifestVersion(manifestVersion float64) bool

Checks if a manifest version is supported by the extension.

manifestVersion: The version number to check.

Return Value

Returns [YES] if the extension specified a manifest version that is greater than or equal to `manifestVersion`.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/supportsManifestVersion(_:)

func (WKWebExtension) Version

func (w WKWebExtension) Version() string

The extension version.

Discussion

Returns `nil` if there was no version specified.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/version

type WKWebExtensionAction

type WKWebExtensionAction struct {
	objectivec.Object
}

An object that encapsulates the properties for an individual web extension action.

Overview

This class provides access to action properties, such as pop-up, icon, or title, with tab-specific values.

Instance Properties

Instance Methods

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action

func NewWKWebExtensionAction

func NewWKWebExtensionAction() WKWebExtensionAction

NewWKWebExtensionAction creates a new WKWebExtensionAction instance.

func WKWebExtensionActionFromID

func WKWebExtensionActionFromID(id objc.ID) WKWebExtensionAction

WKWebExtensionActionFromID constructs a WKWebExtensionAction from an objc.ID.

An object that encapsulates the properties for an individual web extension action.

func (WKWebExtensionAction) AssociatedTab

func (w WKWebExtensionAction) AssociatedTab() WKWebExtensionTab

The tab that this action is associated with, or `nil` if it’s the default action.

Discussion

When this property is `nil`, it indicates that the action is the default action and not associated with a specific tab.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action/associatedTab

func (WKWebExtensionAction) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKWebExtensionAction) BadgeText

func (w WKWebExtensionAction) BadgeText() string

The badge text for the action.

Discussion

Provides the text that appears on the badge for the action. An empty string signifies that no badge should be shown.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action/badgeText

func (WKWebExtensionAction) ClosePopup

func (w WKWebExtensionAction) ClosePopup()

Triggers the dismissal process of the pop-up.

Discussion

Invoke this method to manage the pop-up’s lifecycle, ensuring the web view is unloaded and resources are released once the pop-up closes. This method is automatically called upon the dismissal of the action’s UIViewController or NSPopover. For custom scenarios where the pop-up’s lifecycle is manually managed, it must be explicitly invoked to ensure proper closure.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action/closePopup()

func (WKWebExtensionAction) Enabled

func (w WKWebExtensionAction) Enabled() bool

A Boolean value indicating whether the action is enabled.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action/isEnabled

func (WKWebExtensionAction) HasUnreadBadgeText

func (w WKWebExtensionAction) HasUnreadBadgeText() bool

A Boolean value indicating whether the badge text is unread.

Discussion

This property is automatically set to [YES] when [BadgeText] changes and is not empty. If [BadgeText] becomes empty or the popup associated with the action is presented, this property is automatically set to [NO]. Additionally, it should be set to [NO] by the app when the badge has been presented to the user. This property is useful for higher-level notification badges when extensions might be hidden behind an action sheet.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action/hasUnreadBadgeText

func (WKWebExtensionAction) IconForSize

func (w WKWebExtensionAction) IconForSize(size corefoundation.CGSize) objc.ID

Returns the action icon for the specified size.

size: The size to use when looking up the action icon.

Return Value

The action icon, or `nil` if the icon was unable to be loaded.

Discussion

This icon should represent the extension in action sheets or toolbars. The returned image will be the best match for the specified size that is available in the extension’s action icon set. If no matching icon is available, the method will fall back to the extension’s icon.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action/icon(for:)

func (WKWebExtensionAction) Init

Init initializes the instance.

func (WKWebExtensionAction) InspectionName

func (w WKWebExtensionAction) InspectionName() string

The name shown when inspecting the pop-up web view.

Discussion

This is the text that will appear when inspecting the pop-up web view.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action/inspectionName

func (WKWebExtensionAction) Label

func (w WKWebExtensionAction) Label() string

The localized display label for the action.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action/label

func (WKWebExtensionAction) MenuItems

func (w WKWebExtensionAction) MenuItems() []objectivec.IObject

The menu items provided by the extension for this action.

Discussion

Provides menu items supplied by the extension, allowing the user to perform extension-defined actions.

The app is responsible for displaying these menu items, typically in a context menu or a long-press menu on the action in action sheets or toolbars.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action/menuItems

func (WKWebExtensionAction) PopupPopover

func (w WKWebExtensionAction) PopupPopover() appkit.NSPopover

A popover that presents a web view loaded with the pop-up page for this action, or `nil` if no popup is specified.

Discussion

This popover contains a view controller with a web view preloaded with the pop-up page. It automatically adjusts its size to fit the web view’s content size. The [PresentsPopup] property should be checked to determine the availability of a pop-up before using this property. Dismissing the popover will close the pop-up and unload the web view.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action/popupPopover

func (WKWebExtensionAction) PopupWebView

func (w WKWebExtensionAction) PopupWebView() IWKWebView

A web view loaded with the pop-up page for this action, or `nil` if no pop-up is specified.

Discussion

The web view will be preloaded with the pop-up page upon first access or after it has been unloaded. Use the [PresentsPopup] property to determine whether a pop-up should be displayed before using this property.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action/popupWebView

func (WKWebExtensionAction) PresentsPopup

func (w WKWebExtensionAction) PresentsPopup() bool

A Boolean value indicating whether the action has a pop-up.

Discussion

Use this property to check if the action has a pop-up before attempting to show any pop-up views.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action/presentsPopup

func (WKWebExtensionAction) SetHasUnreadBadgeText

func (w WKWebExtensionAction) SetHasUnreadBadgeText(value bool)

func (WKWebExtensionAction) SetInspectionName

func (w WKWebExtensionAction) SetInspectionName(value string)

func (WKWebExtensionAction) WebExtensionContext

func (w WKWebExtensionAction) WebExtensionContext() IWKWebExtensionContext

The extension context to which this action is related.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Action/webExtensionContext

type WKWebExtensionActionClass

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

func GetWKWebExtensionActionClass

func GetWKWebExtensionActionClass() WKWebExtensionActionClass

GetWKWebExtensionActionClass returns the class object for WKWebExtensionAction.

func (WKWebExtensionActionClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebExtensionActionClass) Class

Class returns the underlying Objective-C class pointer.

type WKWebExtensionClass

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

func GetWKWebExtensionClass

func GetWKWebExtensionClass() WKWebExtensionClass

GetWKWebExtensionClass returns the class object for WKWebExtension.

func (WKWebExtensionClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebExtensionClass) Class

func (wc WKWebExtensionClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (WKWebExtensionClass) ExtensionWithAppExtensionBundle

func (wc WKWebExtensionClass) ExtensionWithAppExtensionBundle(ctx context.Context, appExtensionBundle foundation.NSBundle) (*WKWebExtension, error)

ExtensionWithAppExtensionBundle is a synchronous wrapper around [WKWebExtension.ExtensionWithAppExtensionBundleCompletionHandler]. It blocks until the completion handler fires or the context is cancelled.

func (WKWebExtensionClass) ExtensionWithAppExtensionBundleCompletionHandler

func (_WKWebExtensionClass WKWebExtensionClass) ExtensionWithAppExtensionBundleCompletionHandler(appExtensionBundle foundation.NSBundle, completionHandler WKWebExtensionErrorHandler)

Returns a web extension initialized with a specified app extension bundle.

appExtensionBundle: The bundle to use for the new web extension.

completionHandler: A block to be called with an initialized web extension, or `nil` if the object could not be initialized due to an error.

Discussion

The app extension bundle must contain a `manifest.Json()` file in its resources directory. If the manifest is invalid or missing, or the bundle is otherwise improperly configured, an error will be returned.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/extensionWithAppExtensionBundle:completionHandler:

func (WKWebExtensionClass) ExtensionWithResourceBaseURL

func (wc WKWebExtensionClass) ExtensionWithResourceBaseURL(ctx context.Context, resourceBaseURL foundation.INSURL) (*WKWebExtension, error)

ExtensionWithResourceBaseURL is a synchronous wrapper around [WKWebExtension.ExtensionWithResourceBaseURLCompletionHandler]. It blocks until the completion handler fires or the context is cancelled.

func (WKWebExtensionClass) ExtensionWithResourceBaseURLCompletionHandler

func (_WKWebExtensionClass WKWebExtensionClass) ExtensionWithResourceBaseURLCompletionHandler(resourceBaseURL foundation.INSURL, completionHandler WKWebExtensionErrorHandler)

Returns a web extension initialized with a specified resource base URL, which can point to either a directory or a ZIP archive.

resourceBaseURL: The file URL to use for the new web extension.

completionHandler: A block to be called with an initialized web extension, or `nil` if the object could not be initialized due to an error.

Discussion

The URL must be a file URL that points to either a directory with a `manifest.Json()` file or a ZIP archive containing a `manifest.Json()` file. If the manifest is invalid or missing, or the URL points to an unsupported format or invalid archive, an error will be returned.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/extensionWithResourceBaseURL:completionHandler:

type WKWebExtensionCommand

type WKWebExtensionCommand struct {
	objectivec.Object
}

An object that encapsulates the properties for an individual web extension command.

Overview

Provides access to command properties such as a unique identifier, a descriptive title, and shortcut keys. Commands can be used by a web extension to perform specific actions within a web extension context, such toggling features, or interacting with web content. These commands enhance the functionality of the extension by allowing users to invoke actions quickly.

Instance Properties

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Command

func NewWKWebExtensionCommand

func NewWKWebExtensionCommand() WKWebExtensionCommand

NewWKWebExtensionCommand creates a new WKWebExtensionCommand instance.

func WKWebExtensionCommandFromID

func WKWebExtensionCommandFromID(id objc.ID) WKWebExtensionCommand

WKWebExtensionCommandFromID constructs a WKWebExtensionCommand from an objc.ID.

An object that encapsulates the properties for an individual web extension command.

func (WKWebExtensionCommand) ActivationKey

func (w WKWebExtensionCommand) ActivationKey() string

The primary key used to trigger the command, distinct from any modifier flags.

Discussion

This property can be customized within the app to avoid conflicts with existing shortcuts or to enable user personalization.

It should accurately represent the activation key as used by the app, which the extension can use to display the complete shortcut in its interface.

If no shortcut is desired for the command, the property should be set to `nil`. This value should be saved and restored as needed by the app.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Command/activationKey

func (WKWebExtensionCommand) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKWebExtensionCommand) Identifier

func (w WKWebExtensionCommand) Identifier() string

A unique identifier for the command.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Command/id

func (WKWebExtensionCommand) Init

Init initializes the instance.

func (WKWebExtensionCommand) MenuItem

A menu item representation of the web extension command for use in menus.

Discussion

Provides a representation of the web extension command as a menu item to display in the app.

Selecting the menu item will perform the command, offering a convenient and visual way for users to execute this web extension command.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Command/menuItem

func (WKWebExtensionCommand) ModifierFlags

func (w WKWebExtensionCommand) ModifierFlags() objectivec.IObject

The modifier flags used with the activation key to trigger the command.

Discussion

This property can be customized within the app to avoid conflicts with existing shortcuts or to enable user personalization. It should accurately represent the modifier keys as used by the app, which the extension can use to display the complete shortcut in its interface.

If no modifiers are desired for the command, the property should be set to `0`. This value should be saved and restored as needed by the app.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Command/modifierFlags

func (WKWebExtensionCommand) SetActivationKey

func (w WKWebExtensionCommand) SetActivationKey(value string)

func (WKWebExtensionCommand) SetModifierFlags

func (w WKWebExtensionCommand) SetModifierFlags(value objectivec.IObject)

func (WKWebExtensionCommand) Title

func (w WKWebExtensionCommand) Title() string

A descriptive title for the command to help discoverability.

Discussion

This title can be displayed in user interface elements such as keyboard shortcuts lists or menu items to help users understand its purpose.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Command/title

func (WKWebExtensionCommand) WebExtensionContext

func (w WKWebExtensionCommand) WebExtensionContext() IWKWebExtensionContext

The web extension context associated with the command.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Command/webExtensionContext

type WKWebExtensionCommandClass

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

func GetWKWebExtensionCommandClass

func GetWKWebExtensionCommandClass() WKWebExtensionCommandClass

GetWKWebExtensionCommandClass returns the class object for WKWebExtensionCommand.

func (WKWebExtensionCommandClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebExtensionCommandClass) Class

Class returns the underlying Objective-C class pointer.

type WKWebExtensionContext

type WKWebExtensionContext struct {
	objectivec.Object
}

An object that represents the runtime environment for a web extension.

Overview

This class provides methods for managing the extension’s permissions, allowing it to inject content, run background logic, show popovers, and display other web-based UI to the user.

Initializers

Instance Properties

Instance Methods

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext

func NewWKWebExtensionContext

func NewWKWebExtensionContext() WKWebExtensionContext

NewWKWebExtensionContext creates a new WKWebExtensionContext instance.

func NewWebExtensionContextForExtension

func NewWebExtensionContextForExtension(extension IWKWebExtension) WKWebExtensionContext

Returns a web extension context initialized with a specified extension.

extension: The extension to use for the new web extension context.

Return Value

An initialized web extension context.

Discussion

This is a designated initializer.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/init(for:)

func WKWebExtensionContextFromID

func WKWebExtensionContextFromID(id objc.ID) WKWebExtensionContext

WKWebExtensionContextFromID constructs a WKWebExtensionContext from an objc.ID.

An object that represents the runtime environment for a web extension.

func (WKWebExtensionContext) ActionForTab

Retrieves the extension action for a given tab, or the default action if `nil` is passed.

tab: The tab for which to retrieve the extension action, or `nil` to get the default action.

Discussion

The returned object represents the action specific to the tab when provided; otherwise, it returns the default action. The default action is useful when the context is unrelated to a specific tab. When possible, specify the tab to get the most context-relevant action.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/action(for:)

func (WKWebExtensionContext) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKWebExtensionContext) BaseURL

The base URL the context uses for loading extension resources or injecting content into webpages.

Discussion

The default value is a unique URL using the `webkit-extension` scheme. The base URL can be set to any URL, but only the scheme and host will be used. The scheme cannot be a scheme that is already supported by WKWebView (e.g. http, https, etc.). Setting is only allowed when the context is not loaded.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/baseURL

func (WKWebExtensionContext) ClearUserGestureInTab

func (w WKWebExtensionContext) ClearUserGestureInTab(tab WKWebExtensionTab)

Called by the app to clear a user gesture in a specific tab.

tab: The tab from which the user gesture should be cleared.

Discussion

When a user gesture is no longer relevant in a tab, this method should be called to update the extension context.

This will revoke the extension’s access to features that require active user interaction, such as `activeTab`. User gestures are automatically cleared during navigation in certain scenarios; this method is needed if the app intends to clear the gesture more aggressively.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/clearUserGesture(in:)

func (WKWebExtensionContext) CommandForEvent

Retrieves the command associated with the given event without performing it.

event: The event for which to retrieve the corresponding command.

Return Value

The command associated with the event, or `nil` if there is no such command.

Discussion

Returns the command that corresponds to the provided event, if such a command exists. This provides a way to programmatically determine what action would occur for a given event, without triggering the command.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/command(for:)

func (WKWebExtensionContext) Commands

The commands associated with the extension.

Discussion

Provides all commands registered within the extension. Each command represents an action or behavior available for the web extension.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/commands

func (WKWebExtensionContext) CurrentPermissionMatchPatterns

func (w WKWebExtensionContext) CurrentPermissionMatchPatterns() foundation.INSSet

The currently granted permission match patterns that have not expired.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/currentPermissionMatchPatterns

func (WKWebExtensionContext) CurrentPermissions

func (w WKWebExtensionContext) CurrentPermissions() foundation.INSSet

The currently granted permissions that have not expired.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/currentPermissions

func (WKWebExtensionContext) DeniedPermissionMatchPatterns

func (w WKWebExtensionContext) DeniedPermissionMatchPatterns() foundation.INSDictionary

The currently denied permission match patterns and their expiration dates.

Discussion

Match patterns that don’t expire will have a distant future date. This will never include expired entries at time of access.

Setting this property will replace all existing entries. Use this property for saving and restoring permission status in bulk.

Match patterns in this dictionary should be explicitly denied by the user before being added. Any match pattern in this collection will not be presented for approval again until they expire. This value should be saved and restored as needed by the app.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/deniedPermissionMatchPatterns

func (WKWebExtensionContext) DeniedPermissions

func (w WKWebExtensionContext) DeniedPermissions() foundation.INSDictionary

The currently denied permissions and their expiration dates.

Discussion

Permissions that don’t expire will have a distant future date. This will never include expired entries at time of access.

Setting this property will replace all existing entries. Use this property for saving and restoring permission status in bulk.

Permissions in this dictionary should be explicitly denied by the user before being added. Any match pattern in this collection will not be presented for approval again until they expire. This value should be saved and restored as needed by the app.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/deniedPermissions

func (WKWebExtensionContext) DidActivateTabPreviousActiveTab

func (w WKWebExtensionContext) DidActivateTabPreviousActiveTab(activatedTab WKWebExtensionTab, previousTab WKWebExtensionTab)

Called by the app when a tab is activated to notify only this specific extension.

activatedTab: The tab that has become active.

previousTab: The tab that was active before. This parameter can be `nil` if there was no previously active tab.

Discussion

This method informs only the specific extension of the tab activation. If the intention is to inform all loaded extensions consistently, you should use the respective method on the extension controller instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/didActivateTab:previousActiveTab:

func (WKWebExtensionContext) DidChangeTabPropertiesForTab

func (w WKWebExtensionContext) DidChangeTabPropertiesForTab(properties WKWebExtensionTabChangedProperties, changedTab WKWebExtensionTab)

Called by the app when the properties of a tab are changed to fire appropriate events with only this extension.

properties: The properties of the tab that were changed.

changedTab: The tab whose properties were changed.

Discussion

This method informs only the specific extension of the changes to a tab’s properties. If the intention is to inform all loaded extensions consistently, you should use the respective method on the extension controller instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/didChangeTabProperties(_:for:)

func (WKWebExtensionContext) DidCloseTabWindowIsClosing

func (w WKWebExtensionContext) DidCloseTabWindowIsClosing(closedTab WKWebExtensionTab, windowIsClosing bool)

Called by the app when a tab is closed to fire appropriate events with only this extension.

closedTab: The tab that was closed.

windowIsClosing: A Boolean value indicating whether the window containing the tab is also closing.

Discussion

This method informs only the specific extension of the closure of a tab. If the intention is to inform all loaded extensions consistently, you should use the respective method on the extension controller instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/didCloseTab:windowIsClosing:

func (WKWebExtensionContext) DidCloseWindow

func (w WKWebExtensionContext) DidCloseWindow(closedWindow WKWebExtensionWindow)

Called by the app when a window is closed to fire appropriate events with only this extension.

closedWindow: The window that was closed.

Discussion

This method informs only the specific extension of the closure of a window. If the intention is to inform all loaded extensions consistently, you should use the respective method on the extension controller instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/didCloseWindow(_:)

func (WKWebExtensionContext) DidDeselectTabs

func (w WKWebExtensionContext) DidDeselectTabs(deselectedTabs []objectivec.IObject)

Called by the app when tabs are deselected to fire appropriate events with only this extension.

deselectedTabs: The set of tabs that were deselected.

Discussion

This method informs only the specific extension that tabs have been deselected. If the intention is to inform all loaded extensions consistently, you should use the respective method on the extension controller instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/didDeselectTabs(_:)

func (WKWebExtensionContext) DidFocusWindow

func (w WKWebExtensionContext) DidFocusWindow(focusedWindow WKWebExtensionWindow)

Called by the app when a window gains focus to fire appropriate events with only this extension.

focusedWindow: The window that gained focus, or `nil` if no window has focus or a window has focus that is not visible to this extension.

Discussion

This method informs only the specific extension that a window has gained focus. If the intention is to inform all loaded extensions consistently, you should use the respective method on the extension controller instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/didFocusWindow(_:)

func (WKWebExtensionContext) DidMoveTabFromIndexInWindow

func (w WKWebExtensionContext) DidMoveTabFromIndexInWindow(movedTab WKWebExtensionTab, index uint, oldWindow WKWebExtensionWindow)

Called by the app when a tab is moved to fire appropriate events with only this extension.

movedTab: The tab that was moved.

index: The old index of the tab within the window.

oldWindow: The window that the tab was moved from, or `nil` if the tab isn’t moving from an open window.

Discussion

If the window is staying the same, the current window should be specified. This method informs only the specific extension that a tab has been moved. If the intention is to inform all loaded extensions consistently, you should use the respective method on the extension controller instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/didMoveTab:fromIndex:inWindow:

func (WKWebExtensionContext) DidOpenTab

func (w WKWebExtensionContext) DidOpenTab(newTab WKWebExtensionTab)

Called by the app when a new tab is opened to fire appropriate events with only this extension.

newTab: The newly opened tab.

Discussion

This method informs only the specific extension of the opening of a new tab. If the intention is to inform all loaded extensions consistently, you should use the respective method on the extension controller instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/didOpenTab(_:)

func (WKWebExtensionContext) DidOpenWindow

func (w WKWebExtensionContext) DidOpenWindow(newWindow WKWebExtensionWindow)

Called by the app when a new window is opened to fire appropriate events with only this extension.

newWindow: The newly opened window.

Discussion

This method informs only the specific extension of the opening of a new window. If the intention is to inform all loaded extensions consistently, you should use the respective method on the extension controller instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/didOpenWindow(_:)

func (WKWebExtensionContext) DidReplaceTabWithTab

func (w WKWebExtensionContext) DidReplaceTabWithTab(oldTab WKWebExtensionTab, newTab WKWebExtensionTab)

Called by the app when a tab is replaced by another tab to fire appropriate events with only this extension.

oldTab: The tab that was replaced.

newTab: The tab that replaced the old tab.

Discussion

This method informs only the specific extension that a tab has been replaced. If the intention is to inform all loaded extensions consistently, you should use the respective method on the extension controller instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/didReplaceTab(_:with:)

func (WKWebExtensionContext) DidSelectTabs

func (w WKWebExtensionContext) DidSelectTabs(selectedTabs []objectivec.IObject)

Called by the app when tabs are selected to fire appropriate events with only this extension.

selectedTabs: The set of tabs that were selected.

Discussion

This method informs only the specific extension that tabs have been selected. If the intention is to inform all loaded extensions consistently, you should use the respective method on the extension controller instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/didSelectTabs(_:)

func (WKWebExtensionContext) Errors

All errors that occurred in the extension context.

Discussion

Provides an array of all parse-time and runtime errors for the extension and extension context, with repeat errors consolidated into a single entry for the original occurrence. If no errors occurred, an empty array is returned.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/errors

func (WKWebExtensionContext) FocusedWindow

func (w WKWebExtensionContext) FocusedWindow() WKWebExtensionWindow

The window that currently has focus for this extension.

Discussion

Provides the window that currently has focus, as set by the [DidFocusWindow] method.

It will be `nil` if no window has focus or if a window has focus that is not visible to the extension. Initially populated by the window returned by the extension controller delegate method [WebExtensionControllerFocusedWindowForExtensionContext].

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/focusedWindow

func (WKWebExtensionContext) GrantedPermissionMatchPatterns

func (w WKWebExtensionContext) GrantedPermissionMatchPatterns() foundation.INSDictionary

The currently granted permission match patterns and their expiration dates.

Discussion

Match patterns that don’t expire will have a distant future date. This will never include expired entries at time of access.

Setting this property will replace all existing entries. Use this property for saving and restoring permission status in bulk.

Match patterns in this dictionary should be explicitly granted by the user before being added. Any match pattern in this collection will not be presented for approval again until they expire. This value should be saved and restored as needed by the app.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/grantedPermissionMatchPatterns

func (WKWebExtensionContext) GrantedPermissions

func (w WKWebExtensionContext) GrantedPermissions() foundation.INSDictionary

The currently granted permissions and their expiration dates.

Discussion

Permissions that don’t expire will have a distant future date. This will never include expired entries at time of access.

Setting this property will replace all existing entries. Use this property for saving and restoring permission status in bulk.

Permissions in this dictionary should be explicitly granted by the user before being added. Any permissions in this collection will not be presented for approval again until they expire. This value should be saved and restored as needed by the app.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/grantedPermissions

func (WKWebExtensionContext) HasAccessToAllHosts

func (w WKWebExtensionContext) HasAccessToAllHosts() bool

A Boolean value indicating if the currently granted permission match patterns set contains the “ pattern or any `*` host patterns.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/hasAccessToAllHosts

func (WKWebExtensionContext) HasAccessToAllURLs

func (w WKWebExtensionContext) HasAccessToAllURLs() bool

A Boolean value indicating if the currently granted permission match patterns set contains the “ pattern.

Discussion

This does not check for any `*` host patterns. In most cases you should use the broader [HasAccessToAllHosts].

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/hasAccessToAllURLs

func (WKWebExtensionContext) HasAccessToPrivateData

func (w WKWebExtensionContext) HasAccessToPrivateData() bool

A Boolean value indicating if the extension has access to private data.

Discussion

If this property is true, the extension is granted permission to interact with private windows, tabs, and cookies. Access to private data should be explicitly allowed by the user before setting this property. This value should be saved and restored as needed by the app.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/hasAccessToPrivateData

func (WKWebExtensionContext) HasAccessToURL

func (w WKWebExtensionContext) HasAccessToURL(url foundation.INSURL) bool

Checks the specified URL against the currently granted permission match patterns.

url: The URL for which to return the status.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/hasAccess(to:)

func (WKWebExtensionContext) HasAccessToURLInTab

func (w WKWebExtensionContext) HasAccessToURLInTab(url foundation.INSURL, tab WKWebExtensionTab) bool

Checks the specified URL against the currently granted permission match patterns in a specific tab.

url: The URL for which to return the status.

tab: The tab in which to return the permission status, or `nil` if the tab is not known or the global status is desired.

Discussion

Some match patterns can be granted on a per-tab basis. When the tab is known, access checks should always use this method.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/hasAccess(to:in:)

func (WKWebExtensionContext) HasActiveUserGestureInTab

func (w WKWebExtensionContext) HasActiveUserGestureInTab(tab WKWebExtensionTab) bool

Indicates if a user gesture is currently active in the specified tab.

tab: The tab for which to check for an active user gesture.

Discussion

An active user gesture may influence the availability of certain permissions, such as `activeTab`. User gestures can be triggered by various user interactions with the web extension, including clicking on extension menu items, executing extension commands, or interacting with extension actions. A tab as having an active user gesture enables the extension to access features that require user interaction.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/hasActiveUserGesture(in:)

func (WKWebExtensionContext) HasContentModificationRules

func (w WKWebExtensionContext) HasContentModificationRules() bool

A boolean value indicating whether the extension includes rules used for content modification or blocking.

Discussion

This includes both static rules available in the extension’s manifest and dynamic rules applied during a browsing session.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/hasContentModificationRules

func (WKWebExtensionContext) HasInjectedContent

func (w WKWebExtensionContext) HasInjectedContent() bool

A Boolean value indicating whether the extension has script or stylesheet content that can be injected into webpages.

Discussion

If this property is [YES], the extension has content that can be injected by matching against the extension’s requested match patterns.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/hasInjectedContent

func (WKWebExtensionContext) HasInjectedContentForURL

func (w WKWebExtensionContext) HasInjectedContentForURL(url foundation.INSURL) bool

Checks if the extension has script or stylesheet content that can be injected into the specified URL.

url: The webpage URL to check.

Return Value

Returns [YES] if the extension has content that can be injected by matching the URL against the extension’s requested match patterns.

Discussion

The extension context will still need to be loaded and have granted website permissions for its content to actually be injected.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/hasInjectedContent(for:)

func (WKWebExtensionContext) HasPermission

func (w WKWebExtensionContext) HasPermission(permission WKWebExtensionPermission) bool

Checks the specified permission against the currently granted permissions.

permission: The permission for which to return the status.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/hasPermission(_:)

func (WKWebExtensionContext) HasPermissionInTab

func (w WKWebExtensionContext) HasPermissionInTab(permission WKWebExtensionPermission, tab WKWebExtensionTab) bool

Checks the specified permission against the currently granted permissions in a specific tab.

permission: The permission for which to return the status.

tab: The tab in which to return the permission status, or `nil` if the tab is not known or the global status is desired.

Discussion

Permissions can be granted on a per-tab basis. When the tab is known, permission checks should always use this method.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/hasPermission(_:in:)

func (WKWebExtensionContext) HasRequestedOptionalAccessToAllHosts

func (w WKWebExtensionContext) HasRequestedOptionalAccessToAllHosts() bool

A Boolean value indicating if the extension has requested optional access to all hosts.

Discussion

If this property is [YES], the extension has asked for access to all hosts in a call to `browser.RuntimeXCUIElementTypePermissionsXCUIElementTypeRequest()`, and future permission checks will present discrete hosts for approval as being implicitly requested. This value should be saved and restored as needed by the app.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/hasRequestedOptionalAccessToAllHosts

func (WKWebExtensionContext) Init

Init initializes the instance.

func (WKWebExtensionContext) InitForExtension

func (w WKWebExtensionContext) InitForExtension(extension IWKWebExtension) WKWebExtensionContext

Returns a web extension context initialized with a specified extension.

extension: The extension to use for the new web extension context.

Return Value

An initialized web extension context.

Discussion

This is a designated initializer.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/init(for:)

func (WKWebExtensionContext) Inspectable

func (w WKWebExtensionContext) Inspectable() bool

Determines whether Web Inspector can inspect the WKWebView instances for this context.

Discussion

A context can control multiple WKWebView instances, from the background content, to the popover.

You should set this to [YES] when needed for debugging purposes. The default value is [NO].

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/isInspectable

func (WKWebExtensionContext) InspectionName

func (w WKWebExtensionContext) InspectionName() string

The name shown when inspecting the background web view.

Discussion

This is the text that will appear when inspecting the background web view.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/inspectionName

func (WKWebExtensionContext) LoadBackgroundContent

func (w WKWebExtensionContext) LoadBackgroundContent(ctx context.Context) error

LoadBackgroundContent is a synchronous wrapper around WKWebExtensionContext.LoadBackgroundContentWithCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebExtensionContext) LoadBackgroundContentWithCompletionHandler

func (w WKWebExtensionContext) LoadBackgroundContentWithCompletionHandler(completionHandler ErrorHandler)

Loads the background content if needed for the extension.

completionHandler: A block to be called upon completion of the loading process, with an optional error.

Discussion

This method forces the loading of the background content for the extension that will otherwise be loaded on-demand during specific events.

It is useful when the app requires the background content to be loaded for other reasons. If the background content is already loaded, the completion handler will be called immediately. An error will occur if the extension does not have any background content to load or loading fails.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/loadBackgroundContent(completionHandler:)

func (WKWebExtensionContext) Loaded

func (w WKWebExtensionContext) Loaded() bool

A Boolean value indicating if this context is loaded in an extension controller.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/isLoaded

func (WKWebExtensionContext) MenuItemsForTab

func (w WKWebExtensionContext) MenuItemsForTab(tab WKWebExtensionTab) []objectivec.IObject

Retrieves the menu items for a given tab.

tab: The tab for which to retrieve the menu items.

Discussion

Returns menu items provided by the extension, allowing the user to perform extension-defined actions on the tab.

The app is responsible for displaying these menu items, typically in a context menu or a long-press menu on the tab.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/menuItems(for:)

func (WKWebExtensionContext) OpenTabs

A set of open tabs in all open windows that are exposed to this extension.

Discussion

Provides a set of tabs in all open windows that are visible to the extension, as updated by the [DidOpenTab] and [DidCloseTabWindowIsClosing] methods.

Initially populated by the tabs in the windows returned by the extension controller delegate method [WebExtensionControllerOpenWindowsForExtensionContext].

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/openTabs

func (WKWebExtensionContext) OpenWindows

func (w WKWebExtensionContext) OpenWindows() []objectivec.IObject

The open windows that are exposed to this extension.

Discussion

Provides the windows that are open and visible to the extension, as updated by the [DidOpenWindow] and [DidCloseWindow] methods.

Initially populated by the windows returned by the extension controller delegate method [WebExtensionControllerOpenWindowsForExtensionContext].

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/openWindows

func (WKWebExtensionContext) OptionsPageURL

func (w WKWebExtensionContext) OptionsPageURL() foundation.INSURL

The URL of the extension’s options page, if the extension has one.

Discussion

Provides the URL for the dedicated options page, if provided by the extension; otherwise `nil` if no page is defined.

The app should provide access to this page through a user interface element.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/optionsPageURL

func (WKWebExtensionContext) OverrideNewTabPageURL

func (w WKWebExtensionContext) OverrideNewTabPageURL() foundation.INSURL

The URL to use as an alternative to the default new tab page, if the extension has one.

Discussion

Provides the URL for a new tab page, if provided by the extension; otherwise `nil` if no page is defined.

The app should prompt the user for permission to use the extension’s new tab page as the default.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/overrideNewTabPageURL

func (WKWebExtensionContext) PerformActionForTab

func (w WKWebExtensionContext) PerformActionForTab(tab WKWebExtensionTab)

Performs the extension action associated with the specified tab or performs the default action if `nil` is passed.

tab: The tab for which to perform the extension action, or `nil` to perform the default action.

Discussion

Performing the action will mark the tab, if specified, as having an active user gesture. When the `tab` parameter is `nil`, the default action is performed. The action can either trigger an event or display a popup, depending on how the extension is configured.

If the action is configured to display a popup, implementing the appropriate web extension controller delegate method is required; otherwise, no action is performed for popup actions.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/performAction(for:)

func (WKWebExtensionContext) PerformCommand

func (w WKWebExtensionContext) PerformCommand(command IWKWebExtensionCommand)

Performs the specified command, triggering events specific to this extension.

command: The command to be performed.

Discussion

This method performs the given command as if it was triggered by a user gesture within the context of the focused window and active tab.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/performCommand(_:)

func (WKWebExtensionContext) PerformCommandForEvent

func (w WKWebExtensionContext) PerformCommandForEvent(event appkit.NSEvent) bool

Performs the command associated with the given event.

event: The event representing the user input.

Return Value

Returns [YES] if a command corresponding to the event was found and performed, [NO] otherwise.

Discussion

This method checks for a command corresponding to the provided event and performs it, if available. The app should use this method to perform any extension commands at an appropriate time in the app’s event handling, like in sendEvent(_:) of NSApplication or sendEvent(_:) of NSWindow subclasses.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/performCommand(for:)-8btj0

func (WKWebExtensionContext) PermissionStatusForMatchPattern

Checks the specified match pattern against the currently denied, granted, and requested permission match patterns.

pattern: The pattern for which to return the status.

Discussion

Match patterns can be granted on a per-tab basis. When the tab is known, access checks should always use the method that checks in a tab.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/permissionStatus(for:)-7mu8

func (WKWebExtensionContext) PermissionStatusForMatchPatternInTab

Checks the specified match pattern against the currently denied, granted, and requested permission match patterns.

pattern: The pattern for which to return the status.

tab: The tab in which to return the permission status, or `nil` if the tab is not known or the global status is desired.

Discussion

Match patterns can be granted on a per-tab basis. When the tab is known, access checks should always use this method.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/permissionStatus(for:in:)-nqhm

func (WKWebExtensionContext) PermissionStatusForPermission

func (w WKWebExtensionContext) PermissionStatusForPermission(permission WKWebExtensionPermission) WKWebExtensionContextPermissionStatus

Checks the specified permission against the currently denied, granted, and requested permissions.

permission: The permission for which to return the status.

Discussion

Permissions can be granted on a per-tab basis. When the tab is known, access checks should always use the method that checks in a tab.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/permissionStatus(for:)-3qq2w

func (WKWebExtensionContext) PermissionStatusForPermissionInTab

func (w WKWebExtensionContext) PermissionStatusForPermissionInTab(permission WKWebExtensionPermission, tab WKWebExtensionTab) WKWebExtensionContextPermissionStatus

Checks the specified permission against the currently denied, granted, and requested permissions.

permission: The permission for which to return the status.

tab: The tab in which to return the permission status, or `nil` if the tab is not known or the global status is desired.

Discussion

Permissions can be granted on a per-tab basis. When the tab is known, access checks should always specify the tab.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/permissionStatus(for:in:)-4h82n

func (WKWebExtensionContext) PermissionStatusForURL

Checks the specified URL against the currently denied, granted, and requested permission match patterns.

url: The URL for which to return the status.

Discussion

URLs and match patterns can be granted on a per-tab basis. When the tab is known, access checks should always use the method that checks in a tab.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/permissionStatus(for:)-7ojrb

func (WKWebExtensionContext) PermissionStatusForURLInTab

Checks the specified URL against the currently denied, granted, and requested permission match patterns.

url: The URL for which to return the status.

tab: The tab in which to return the permission status, or `nil` if the tab is not known or the global status is desired.

Discussion

URLs and match patterns can be granted on a per-tab basis. When the tab is known, access checks should always use this method.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/permissionStatus(for:in:)-96xaf

func (WKWebExtensionContext) SetBaseURL

func (w WKWebExtensionContext) SetBaseURL(value foundation.INSURL)

func (WKWebExtensionContext) SetDeniedPermissionMatchPatterns

func (w WKWebExtensionContext) SetDeniedPermissionMatchPatterns(value foundation.INSDictionary)

func (WKWebExtensionContext) SetDeniedPermissions

func (w WKWebExtensionContext) SetDeniedPermissions(value foundation.INSDictionary)

func (WKWebExtensionContext) SetGrantedPermissionMatchPatterns

func (w WKWebExtensionContext) SetGrantedPermissionMatchPatterns(value foundation.INSDictionary)

func (WKWebExtensionContext) SetGrantedPermissions

func (w WKWebExtensionContext) SetGrantedPermissions(value foundation.INSDictionary)

func (WKWebExtensionContext) SetHasAccessToPrivateData

func (w WKWebExtensionContext) SetHasAccessToPrivateData(value bool)

func (WKWebExtensionContext) SetHasRequestedOptionalAccessToAllHosts

func (w WKWebExtensionContext) SetHasRequestedOptionalAccessToAllHosts(value bool)

func (WKWebExtensionContext) SetInspectable

func (w WKWebExtensionContext) SetInspectable(value bool)

func (WKWebExtensionContext) SetInspectionName

func (w WKWebExtensionContext) SetInspectionName(value string)

func (WKWebExtensionContext) SetPermissionStatusForMatchPattern

func (w WKWebExtensionContext) SetPermissionStatusForMatchPattern(status WKWebExtensionContextPermissionStatus, pattern IWKWebExtensionMatchPattern)

Sets the status of a match pattern with a distant future expiration date.

status: The new permission status to set for the given match pattern.

pattern: The match pattern for which to set the status.

Discussion

This method will update [GrantedPermissionMatchPatterns] and [DeniedPermissionMatchPatterns]. Use this method for changing a single match pattern’s status. Only WKWebExtensionContextPermissionStatusDeniedExplicitly, WKWebExtensionContextPermissionStatusUnknown, and WKWebExtensionContextPermissionStatusGrantedExplicitly states are allowed to be set using this method.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/setPermissionStatus(_:for:)-6auqv

func (WKWebExtensionContext) SetPermissionStatusForMatchPatternExpirationDate

func (w WKWebExtensionContext) SetPermissionStatusForMatchPatternExpirationDate(status WKWebExtensionContextPermissionStatus, pattern IWKWebExtensionMatchPattern, expirationDate foundation.INSDate)

Sets the status of a match pattern with a specific expiration date.

status: The new permission status to set for the given match pattern.

pattern: The match pattern for which to set the status.

expirationDate: The expiration date for the new permission status, or `nil` for distant future.

Discussion

This method will update [GrantedPermissionMatchPatterns] and [DeniedPermissionMatchPatterns]. Use this method for changing a single match pattern’s status.

Passing a `nil` expiration date will be treated as a distant future date. Only WKWebExtensionContextPermissionStatusDeniedExplicitly, WKWebExtensionContextPermissionStatusUnknown, and WKWebExtensionContextPermissionStatusGrantedExplicitly states are allowed to be set using this method.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/setPermissionStatus(_:for:expirationDate:)-7038f

func (WKWebExtensionContext) SetPermissionStatusForPermission

func (w WKWebExtensionContext) SetPermissionStatusForPermission(status WKWebExtensionContextPermissionStatus, permission WKWebExtensionPermission)

Sets the status of a permission with a distant future expiration date.

status: The new permission status to set for the given permission.

permission: The permission for which to set the status.

Discussion

This method will update [GrantedPermissions] and [DeniedPermissions]. Use this method for changing a single permission’s status.

Only WKWebExtensionContextPermissionStatusDeniedExplicitly, WKWebExtensionContextPermissionStatusUnknown, and WKWebExtensionContextPermissionStatusGrantedExplicitly states are allowed to be set using this method.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/setPermissionStatus(_:for:)-4u95f

func (WKWebExtensionContext) SetPermissionStatusForPermissionExpirationDate

func (w WKWebExtensionContext) SetPermissionStatusForPermissionExpirationDate(status WKWebExtensionContextPermissionStatus, permission WKWebExtensionPermission, expirationDate foundation.INSDate)

Sets the status of a permission with a specific expiration date.

status: The new permission status to set for the given permission.

permission: The permission for which to set the status.

expirationDate: The expiration date for the new permission status, or \c nil for distant future.

Discussion

This method will update [GrantedPermissions] and [DeniedPermissions]. Use this method for changing a single permission’s status.

Passing a `nil` expiration date will be treated as a distant future date. Only WKWebExtensionContextPermissionStatusDeniedExplicitly, WKWebExtensionContextPermissionStatusUnknown, and WKWebExtensionContextPermissionStatusGrantedExplicitly states are allowed to be set using this method.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/setPermissionStatus(_:for:expirationDate:)-692ui

func (WKWebExtensionContext) SetPermissionStatusForURL

func (w WKWebExtensionContext) SetPermissionStatusForURL(status WKWebExtensionContextPermissionStatus, url foundation.INSURL)

Sets the permission status of a URL with a distant future expiration date.

status: The new permission status to set for the given URL.

url: The URL for which to set the status.

Discussion

The URL is converted into a match pattern and will update [GrantedPermissionMatchPatterns] and [DeniedPermissionMatchPatterns]. Use this method for changing a single URL’s status. Only WKWebExtensionContextPermissionStatusDeniedExplicitly, WKWebExtensionContextPermissionStatusUnknown, and WKWebExtensionContextPermissionStatusGrantedExplicitly states are allowed to be set using this method.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/setPermissionStatus(_:for:)-5xahd

func (WKWebExtensionContext) SetPermissionStatusForURLExpirationDate

func (w WKWebExtensionContext) SetPermissionStatusForURLExpirationDate(status WKWebExtensionContextPermissionStatus, url foundation.INSURL, expirationDate foundation.INSDate)

Sets the permission status of a URL with a distant future expiration date.

status: The new permission status to set for the given URL.

url: The URL for which to set the status.

expirationDate: The expiration date for the new permission status, or `nil` for distant future.

Discussion

The URL is converted into a match pattern and will update [GrantedPermissionMatchPatterns] and [DeniedPermissionMatchPatterns]. Use this method for changing a single URL’s status. Passing a `nil` expiration date will be treated as a distant future date. Only WKWebExtensionContextPermissionStatusDeniedExplicitly, WKWebExtensionContextPermissionStatusUnknown, and WKWebExtensionContextPermissionStatusGrantedExplicitly states are allowed to be set using this method.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/setPermissionStatus(_:for:expirationDate:)-5q9id

func (WKWebExtensionContext) SetUniqueIdentifier

func (w WKWebExtensionContext) SetUniqueIdentifier(value string)

func (WKWebExtensionContext) SetUnsupportedAPIs

func (w WKWebExtensionContext) SetUnsupportedAPIs(value foundation.INSSet)

func (WKWebExtensionContext) UniqueIdentifier

func (w WKWebExtensionContext) UniqueIdentifier() string

A unique identifier used to distinguish the extension from other extensions and target it for messages.

Discussion

The default value is a unique value that matches the host in the default base URL. The identifier can be any value that is unique. Setting is only allowed when the context is not loaded. This value is accessible by the extension via `browser.RuntimeXCUIElementTypeId()` and is used for messaging the extension via `browser.RuntimeXCUIElementTypeSendMessage()`.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/uniqueIdentifier

func (WKWebExtensionContext) UnsupportedAPIs

func (w WKWebExtensionContext) UnsupportedAPIs() foundation.INSSet

Specifies unsupported APIs for this extension, making them `undefined` in JavaScript.

Discussion

This property allows the app to specify a subset of web extension APIs that it chooses not to support, effectively making these APIs `undefined` within the extension’s JavaScript contexts. This enables extensions to employ feature detection techniques for unsupported APIs, allowing them to adapt their behavior based on the APIs actually supported by the app. Setting is only allowed when the context is not loaded. Only certain APIs can be specified here, particularly those within the `browser` namespace and other dynamic functions and properties, anything else will be silently ignored.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/unsupportedAPIs

func (WKWebExtensionContext) UserGesturePerformedInTab

func (w WKWebExtensionContext) UserGesturePerformedInTab(tab WKWebExtensionTab)

Should be called by the app when a user gesture is performed in a specific tab.

tab: The tab in which the user gesture was performed.

Discussion

When a user gesture is performed in a tab, this method should be called to update the extension context.

This enables the extension to be aware of the user gesture, potentially granting it access to features that require user interaction, such as `activeTab`. Not required if using [PerformActionForTab].

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/userGesturePerformed(in:)

func (WKWebExtensionContext) WebExtension

func (w WKWebExtensionContext) WebExtension() IWKWebExtension

The extension this context represents.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/webExtension

func (WKWebExtensionContext) WebExtensionController

func (w WKWebExtensionContext) WebExtensionController() IWKWebExtensionController

The extension controller this context is loaded in, otherwise `nil` if it isn’t loaded.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/webExtensionController

func (WKWebExtensionContext) WebViewConfiguration

func (w WKWebExtensionContext) WebViewConfiguration() IWKWebViewConfiguration

The web view configuration to use for web views that load pages from this extension.

Discussion

Returns a customized copy of the configuration, originally set in the web extension controller configuration, for this extension.

The app must use this configuration when initializing web views intended to navigate to a URL originating from this extension’s base URL.

The app must also swap web views in tabs when navigating to and from web extension URLs. This property returns `nil` if the context isn’t associated with a web extension controller. The returned configuration copy can be customized prior to web view initialization.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/webViewConfiguration

type WKWebExtensionContextClass

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

func GetWKWebExtensionContextClass

func GetWKWebExtensionContextClass() WKWebExtensionContextClass

GetWKWebExtensionContextClass returns the class object for WKWebExtensionContext.

func (WKWebExtensionContextClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebExtensionContextClass) Class

Class returns the underlying Objective-C class pointer.

func (WKWebExtensionContextClass) ContextForExtension

func (_WKWebExtensionContextClass WKWebExtensionContextClass) ContextForExtension(extension IWKWebExtension) WKWebExtensionContext

Returns a web extension context initialized with the specified extension.

extension: The extension to use for the new web extension context.

Return Value

An initialized web extension context.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/contextForExtension:

type WKWebExtensionContextError

type WKWebExtensionContextError int

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/Error/Code

const (
	// WKWebExtensionContextErrorAlreadyLoaded: Indicates that the context is already loaded by a WKWebExtensionController.
	WKWebExtensionContextErrorAlreadyLoaded WKWebExtensionContextError = 2
	// WKWebExtensionContextErrorBackgroundContentFailedToLoad: Indicates that an error occurred loading the background content.
	WKWebExtensionContextErrorBackgroundContentFailedToLoad WKWebExtensionContextError = 6
	// WKWebExtensionContextErrorBaseURLAlreadyInUse: Indicates that another context is already using the specified base URL.
	WKWebExtensionContextErrorBaseURLAlreadyInUse WKWebExtensionContextError = 4
	// WKWebExtensionContextErrorNoBackgroundContent: Indicates that the extension does not have background content.
	WKWebExtensionContextErrorNoBackgroundContent WKWebExtensionContextError = 5
	// WKWebExtensionContextErrorNotLoaded: Indicates that the context is not loaded by a WKWebExtensionController.
	WKWebExtensionContextErrorNotLoaded WKWebExtensionContextError = 3
	// WKWebExtensionContextErrorUnknown: Indicates that an unknown error occurred.
	WKWebExtensionContextErrorUnknown WKWebExtensionContextError = 1
)

func (WKWebExtensionContextError) String

type WKWebExtensionContextNotificationUserInfoKey

type WKWebExtensionContextNotificationUserInfoKey = string

WKWebExtensionContextNotificationUserInfoKey is constants for specifying web extension context information in notifications.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/NotificationUserInfoKey

type WKWebExtensionContextPermissionStatus

type WKWebExtensionContextPermissionStatus int

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionContext/PermissionStatus

const (
	// WKWebExtensionContextPermissionStatusDeniedExplicitly: Indicates that the permission was explicitly denied.
	WKWebExtensionContextPermissionStatusDeniedExplicitly WKWebExtensionContextPermissionStatus = -3
	// WKWebExtensionContextPermissionStatusDeniedImplicitly: Indicates that the permission was implicitly denied because of another explicitly denied permission.
	WKWebExtensionContextPermissionStatusDeniedImplicitly WKWebExtensionContextPermissionStatus = -2
	// WKWebExtensionContextPermissionStatusGrantedExplicitly: Indicates that the permission was explicitly granted permission.
	WKWebExtensionContextPermissionStatusGrantedExplicitly WKWebExtensionContextPermissionStatus = 3
	// WKWebExtensionContextPermissionStatusGrantedImplicitly: Indicates that the permission was implicitly granted because of another explicitly granted permission.
	WKWebExtensionContextPermissionStatusGrantedImplicitly WKWebExtensionContextPermissionStatus = 2
	// WKWebExtensionContextPermissionStatusRequestedExplicitly: Indicates that the permission was explicitly requested.
	WKWebExtensionContextPermissionStatusRequestedExplicitly WKWebExtensionContextPermissionStatus = 1
	// WKWebExtensionContextPermissionStatusRequestedImplicitly: Indicates that the permission was implicitly requested because of another explicitly requested permission.
	WKWebExtensionContextPermissionStatusRequestedImplicitly WKWebExtensionContextPermissionStatus = -1
	// WKWebExtensionContextPermissionStatusUnknown: Indicates an unknown permission status.
	WKWebExtensionContextPermissionStatusUnknown WKWebExtensionContextPermissionStatus = 0
)

func (WKWebExtensionContextPermissionStatus) String

type WKWebExtensionController

type WKWebExtensionController struct {
	objectivec.Object
}

An object that manages a set of loaded extension contexts.

Overview

You can have one or more extension controller instances, allowing different parts of the app to use different sets of extensions.

You can associate a controller with WKWebView using the [WebExtensionController] property on WKWebViewConfiguration.

Initializers

Instance Properties

Instance Methods

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController

func NewWKWebExtensionController

func NewWKWebExtensionController() WKWebExtensionController

NewWKWebExtensionController creates a new WKWebExtensionController instance.

func NewWebExtensionControllerWithConfiguration

func NewWebExtensionControllerWithConfiguration(configuration IWKWebExtensionControllerConfiguration) WKWebExtensionController

Returns a web extension controller initialized with the specified configuration.

configuration: The configuration for the new web extension controller.

Return Value

An initialized web extension controller, or nil if the object could not be initialized.

Discussion

This is a designated initializer. You can use [Init] to initialize an instance with the default configuration. The initializer copies the specified configuration, so mutating the configuration after invoking the initializer has no effect on the web extension controller.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/init(configuration:)

func WKWebExtensionControllerFromID

func WKWebExtensionControllerFromID(id objc.ID) WKWebExtensionController

WKWebExtensionControllerFromID constructs a WKWebExtensionController from an objc.ID.

An object that manages a set of loaded extension contexts.

func (WKWebExtensionController) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKWebExtensionController) Configuration

A copy of the configuration with which the web extension controller was initialized.

Discussion

Mutating the configuration has no effect on the web extension controller.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/configuration-swift.property

func (WKWebExtensionController) DidActivateTabPreviousActiveTab

func (w WKWebExtensionController) DidActivateTabPreviousActiveTab(activatedTab WKWebExtensionTab, previousTab WKWebExtensionTab)

Should be called by the app when a tab is activated to notify all loaded web extensions.

activatedTab: The tab that has become active.

previousTab: The tab that was active before. This parameter can be \c nil if there was no previously active tab.

Discussion

This method informs all loaded extensions of the tab activation, ensuring consistent state awareness across extensions.

If the intention is to inform only a specific extension, use the respective method on that extension’s context instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/didActivateTab:previousActiveTab:

func (WKWebExtensionController) DidChangeTabPropertiesForTab

func (w WKWebExtensionController) DidChangeTabPropertiesForTab(properties WKWebExtensionTabChangedProperties, changedTab WKWebExtensionTab)

Should be called by the app when the properties of a tab are changed to fire appropriate events with all loaded web extensions.

properties: The properties of the tab that were changed.

changedTab: The tab whose properties were changed.

Discussion

This method informs all loaded extensions of changes to tab properties, ensuring a unified understanding across extensions.

If the intention is to inform only a specific extension, you should use the respective method on that extension’s context instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/didChangeTabProperties(_:for:)

func (WKWebExtensionController) DidCloseTabWindowIsClosing

func (w WKWebExtensionController) DidCloseTabWindowIsClosing(closedTab WKWebExtensionTab, windowIsClosing bool)

Should be called by the app when a tab is closed to fire appropriate events with all loaded web extensions.

closedTab: The tab that was closed.

windowIsClosing: A boolean value indicating whether the window containing the tab is also closing.

Discussion

This method informs all loaded extensions of the closing of a tab, ensuring consistent understanding across extensions.

If the intention is to inform only a specific extension, you should use the respective method on that extension’s context instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/didCloseTab:windowIsClosing:

func (WKWebExtensionController) DidCloseWindow

func (w WKWebExtensionController) DidCloseWindow(closedWindow WKWebExtensionWindow)

Should be called by the app when a window is closed to fire appropriate events with all loaded web extensions.

Discussion

- closedWindow: The window that was closed.

This method informs all loaded extensions of the closure of a window, ensuring consistent understanding across extensions.

If the intention is to inform only a specific extension, you should use the respective method on that extension’s context instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/didCloseWindow(_:)

func (WKWebExtensionController) DidDeselectTabs

func (w WKWebExtensionController) DidDeselectTabs(deselectedTabs []objectivec.IObject)

Should be called by the app when tabs are deselected to fire appropriate events with all loaded web extensions.

deselectedTabs: The set of tabs that were deselected.

Discussion

This method informs all loaded extensions that tabs have been deselected, ensuring consistent understanding across extensions.

If the intention is to inform only a specific extension, you should use the respective method on that extension’s context instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/didDeselectTabs(_:)

func (WKWebExtensionController) DidFocusWindow

func (w WKWebExtensionController) DidFocusWindow(focusedWindow WKWebExtensionWindow)

Should be called by the app when a window gains focus to fire appropriate events with all loaded web extensions.

focusedWindow: The window that gained focus, or \c nil if no window has focus or a window has focus that is not visible to extensions.

Discussion

This method informs all loaded extensions of the focused window, ensuring consistent understanding across extensions.

If the intention is to inform only a specific extension, you should use the respective method on that extension’s context instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/didFocusWindow(_:)

func (WKWebExtensionController) DidMoveTabFromIndexInWindow

func (w WKWebExtensionController) DidMoveTabFromIndexInWindow(movedTab WKWebExtensionTab, index uint, oldWindow WKWebExtensionWindow)

Should be called by the app when a tab is moved to fire appropriate events with all loaded web extensions.

movedTab: The tab that was moved.

index: The old index of the tab within the window.

oldWindow: The window that the tab was moved from, or `nil` if the tab is moving from no open window.

Discussion

This method informs all loaded extensions of the movement of a tab, ensuring consistent understanding across extensions.

If the window is staying the same, the current window should be specified. If the intention is to inform only a specific extension, use the respective method on that extension’s context instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/didMoveTab:fromIndex:inWindow:

func (WKWebExtensionController) DidOpenTab

func (w WKWebExtensionController) DidOpenTab(newTab WKWebExtensionTab)

Should be called by the app when a new tab is opened to fire appropriate events with all loaded web extensions.

newTab: The newly opened tab.

Discussion

This method informs all loaded extensions of the opening of a new tab, ensuring consistent understanding across extensions.

If the intention is to inform only a specific extension, you should use the respective method on that extension’s context instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/didOpenTab(_:)

func (WKWebExtensionController) DidOpenWindow

func (w WKWebExtensionController) DidOpenWindow(newWindow WKWebExtensionWindow)

Should be called by the app when a new window is opened to fire appropriate events with all loaded web extensions.

newWindow: The newly opened window.

Discussion

This method informs all loaded extensions of the opening of a new window, ensuring consistent understanding across extensions.

If the intention is to inform only a specific extension, you should use the respective method on that extension’s context instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/didOpenWindow(_:)

func (WKWebExtensionController) DidReplaceTabWithTab

func (w WKWebExtensionController) DidReplaceTabWithTab(oldTab WKWebExtensionTab, newTab WKWebExtensionTab)

Should be called by the app when a tab is replaced by another tab to fire appropriate events with all loaded web extensions.

oldTab: The tab that was replaced.

newTab: The tab that replaced the old tab.

Discussion

This method informs all loaded extensions of the replacement of a tab, ensuring consistent understanding across extensions.

If the intention is to inform only a specific extension, you should use the respective method on that extension’s context instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/didReplaceTab(_:with:)

func (WKWebExtensionController) DidSelectTabs

func (w WKWebExtensionController) DidSelectTabs(selectedTabs []objectivec.IObject)

Should be called by the app when tabs are selected to fire appropriate events with all loaded web extensions.

selectedTabs: The set of tabs that were selected.

Discussion

This method informs all loaded extensions that tabs have been selected, ensuring consistent understanding across extensions.

If the intention is to inform only a specific extension, you should use the respective method on that extension’s context instead.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/didSelectTabs(_:)

func (WKWebExtensionController) ExtensionContextForExtension

func (w WKWebExtensionController) ExtensionContextForExtension(extension IWKWebExtension) IWKWebExtensionContext

Returns a loaded extension context for the specified extension.

extension: An extension to lookup.

Return Value

An extension context or `nil` if no match was found.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/extensionContext(for:)-6ecpm

func (WKWebExtensionController) ExtensionContextForURL

func (w WKWebExtensionController) ExtensionContextForURL(URL foundation.INSURL) IWKWebExtensionContext

Returns a loaded extension context matching the specified URL.

URL: The URL to lookup.

Return Value

An extension context or `nil` if no match was found.

Discussion

This method is useful for determining the extension context to use when about to navigate to an extension URL. For example, you could use this method to retrieve the appropriate extension context and then use its [WebViewConfiguration] property to configure a web view for loading that URL.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/extensionContext(for:)-2kr4

func (WKWebExtensionController) ExtensionContexts

func (w WKWebExtensionController) ExtensionContexts() foundation.INSSet

A set of all the currently loaded extension contexts.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/extensionContexts

func (WKWebExtensionController) Extensions

A set of all the currently loaded extensions.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/extensions

func (WKWebExtensionController) FetchDataRecordOfTypesForExtensionContext

func (w WKWebExtensionController) FetchDataRecordOfTypesForExtensionContext(ctx context.Context, dataTypes foundation.INSSet, extensionContext IWKWebExtensionContext) (*WKWebExtensionDataRecord, error)

FetchDataRecordOfTypesForExtensionContext is a synchronous wrapper around WKWebExtensionController.FetchDataRecordOfTypesForExtensionContextCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebExtensionController) FetchDataRecordOfTypesForExtensionContextCompletionHandler

func (w WKWebExtensionController) FetchDataRecordOfTypesForExtensionContextCompletionHandler(dataTypes foundation.INSSet, extensionContext IWKWebExtensionContext, completionHandler WKWebExtensionDataRecordHandler)

Fetches a data record containing the given extension data types for a specific known web extension context.

dataTypes: The extension data types to fetch records for.

extensionContext: The specific web extension context to fetch records for.

completionHandler: A block to invoke when the data record has been fetched.

Discussion

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/fetchDataRecord(ofTypes:for:completionHandler:)

func (WKWebExtensionController) Init

Init initializes the instance.

func (WKWebExtensionController) InitWithConfiguration

Returns a web extension controller initialized with the specified configuration.

configuration: The configuration for the new web extension controller.

Return Value

An initialized web extension controller, or nil if the object could not be initialized.

Discussion

This is a designated initializer. You can use [Init] to initialize an instance with the default configuration. The initializer copies the specified configuration, so mutating the configuration after invoking the initializer has no effect on the web extension controller.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/init(configuration:)

func (WKWebExtensionController) LoadExtensionContextError

func (w WKWebExtensionController) LoadExtensionContextError(extensionContext IWKWebExtensionContext) (bool, error)

Loads the specified extension context.

Discussion

Causes the context to start, loading any background content, and injecting any content into relevant tabs.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/load(_:)

func (WKWebExtensionController) RemoveDataOfTypesFromDataRecordsCompletionHandler

func (w WKWebExtensionController) RemoveDataOfTypesFromDataRecordsCompletionHandler(dataTypes foundation.INSSet, dataRecords []WKWebExtensionDataRecord, completionHandler VoidHandler)

Removes extension data of the given types for the given data records.

dataTypes: The extension data types that should be removed.

dataRecords: The extension data records to delete data from.

completionHandler: A block to invoke when the data has been removed.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/removeData(ofTypes:from:completionHandler:)

func (WKWebExtensionController) SetDelegate

func (WKWebExtensionController) SetWebExtensionController

func (w WKWebExtensionController) SetWebExtensionController(value IWKWebExtensionController)

func (WKWebExtensionController) UnloadExtensionContextError

func (w WKWebExtensionController) UnloadExtensionContextError(extensionContext IWKWebExtensionContext) (bool, error)

Unloads the specified extension context.

Discussion

Causes the context to stop running.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/unload(_:)

type WKWebExtensionControllerClass

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

func GetWKWebExtensionControllerClass

func GetWKWebExtensionControllerClass() WKWebExtensionControllerClass

GetWKWebExtensionControllerClass returns the class object for WKWebExtensionController.

func (WKWebExtensionControllerClass) AllExtensionDataTypes

func (_WKWebExtensionControllerClass WKWebExtensionControllerClass) AllExtensionDataTypes() foundation.INSSet

Returns a set of all available extension data types.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/allExtensionDataTypes

func (WKWebExtensionControllerClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebExtensionControllerClass) Class

Class returns the underlying Objective-C class pointer.

type WKWebExtensionControllerConfiguration

type WKWebExtensionControllerConfiguration struct {
	objectivec.Object
}

A WKWebExtensionControllerConfiguration object with which to initialize a web extension controller.

Overview

Contains properties used to configure a WKWebExtensionController.

Instance Properties

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/Configuration-swift.class

func NewWKWebExtensionControllerConfiguration

func NewWKWebExtensionControllerConfiguration() WKWebExtensionControllerConfiguration

NewWKWebExtensionControllerConfiguration creates a new WKWebExtensionControllerConfiguration instance.

func NewWebExtensionControllerConfigurationWithIdentifier

func NewWebExtensionControllerConfigurationWithIdentifier(identifier foundation.NSUUID) WKWebExtensionControllerConfiguration

Returns a new configuration that is persistent and unique for the specified identifier.

Discussion

If a WKWebExtensionController is associated with a unique persistent configuration, data will be written to the file system in a unique location based on the specified identifier.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/Configuration-swift.class/init(identifier:)

func WKWebExtensionControllerConfigurationFromID

func WKWebExtensionControllerConfigurationFromID(id objc.ID) WKWebExtensionControllerConfiguration

WKWebExtensionControllerConfigurationFromID constructs a WKWebExtensionControllerConfiguration from an objc.ID.

A WKWebExtensionControllerConfiguration object with which to initialize a web extension controller.

func (WKWebExtensionControllerConfiguration) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKWebExtensionControllerConfiguration) DefaultWebsiteDataStore

func (w WKWebExtensionControllerConfiguration) DefaultWebsiteDataStore() IWKWebsiteDataStore

The default data store for website data and cookie access in extension contexts.

Discussion

This property sets the primary data store for managing website data, including cookies, which extensions can access, subject to the granted permissions within the extension contexts. Defaults to [DefaultDataStore].

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/Configuration-swift.class/defaultWebsiteDataStore

func (WKWebExtensionControllerConfiguration) EncodeWithCoder

func (WKWebExtensionControllerConfiguration) Identifier

The unique identifier used for persistent configuration storage, or `nil` when it is the default or not persistent.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/Configuration-swift.class/identifier

func (WKWebExtensionControllerConfiguration) Init

Init initializes the instance.

func (WKWebExtensionControllerConfiguration) Persistent

A Boolean value indicating if this context will write data to the the file system.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/Configuration-swift.class/isPersistent

func (WKWebExtensionControllerConfiguration) SetDefaultWebsiteDataStore

func (w WKWebExtensionControllerConfiguration) SetDefaultWebsiteDataStore(value IWKWebsiteDataStore)

func (WKWebExtensionControllerConfiguration) SetWebViewConfiguration

func (w WKWebExtensionControllerConfiguration) SetWebViewConfiguration(value IWKWebViewConfiguration)

func (WKWebExtensionControllerConfiguration) WebViewConfiguration

The web view configuration to be used as a basis for configuring web views in extension contexts.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/Configuration-swift.class/webViewConfiguration

type WKWebExtensionControllerConfigurationClass

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

func GetWKWebExtensionControllerConfigurationClass

func GetWKWebExtensionControllerConfigurationClass() WKWebExtensionControllerConfigurationClass

GetWKWebExtensionControllerConfigurationClass returns the class object for WKWebExtensionControllerConfiguration.

func (WKWebExtensionControllerConfigurationClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebExtensionControllerConfigurationClass) Class

Class returns the underlying Objective-C class pointer.

func (WKWebExtensionControllerConfigurationClass) DefaultConfiguration

func (_WKWebExtensionControllerConfigurationClass WKWebExtensionControllerConfigurationClass) DefaultConfiguration() WKWebExtensionControllerConfiguration

Returns a new default configuration that is persistent and not unique.

Discussion

If a WKWebExtensionController is associated with a persistent configuration, data will be written to the file system in a common location. When using multiple extension controllers, each controller should use a unique configuration to avoid conflicts.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/Configuration-swift.class/default()

func (WKWebExtensionControllerConfigurationClass) NonPersistentConfiguration

func (_WKWebExtensionControllerConfigurationClass WKWebExtensionControllerConfigurationClass) NonPersistentConfiguration() WKWebExtensionControllerConfiguration

Returns a new non-persistent configuration.

Discussion

If a WKWebExtensionController is associated with a non-persistent configuration, no data will be written to the file system. This is useful for extensions in “private browsing” situations.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionController/Configuration-swift.class/nonPersistent()

type WKWebExtensionControllerDelegate

type WKWebExtensionControllerDelegate interface {
	objectivec.IObject
}

A group of methods you use to customize web extension interactions.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionControllerDelegate

type WKWebExtensionControllerDelegateConfig

type WKWebExtensionControllerDelegateConfig struct {

	// Other Methods
	// WebExtensionControllerDidUpdateActionForExtensionContext — Called when an action’s properties are updated.
	WebExtensionControllerDidUpdateActionForExtensionContext func(controller WKWebExtensionController, action WKWebExtensionAction, context WKWebExtensionContext)
}

WKWebExtensionControllerDelegateConfig holds optional typed callbacks for WKWebExtensionControllerDelegate methods. Set non-nil fields to register the corresponding Objective-C delegate method. Methods with nil callbacks are not registered, so [NSObject.RespondsToSelector] returns false for them — matching the Objective-C delegate pattern exactly.

See Apple Documentation for protocol details.

type WKWebExtensionControllerDelegateObject

type WKWebExtensionControllerDelegateObject struct {
	objectivec.Object
}

WKWebExtensionControllerDelegateObject wraps an existing Objective-C object that conforms to the WKWebExtensionControllerDelegate protocol.

func NewWKWebExtensionControllerDelegate

func NewWKWebExtensionControllerDelegate(config WKWebExtensionControllerDelegateConfig) WKWebExtensionControllerDelegateObject

NewWKWebExtensionControllerDelegate creates an Objective-C object implementing the WKWebExtensionControllerDelegate protocol.

Each call registers a unique Objective-C class containing only the methods set in config. This means [NSObject.RespondsToSelector] works correctly for optional delegate methods — only non-nil callbacks are registered.

The returned WKWebExtensionControllerDelegateObject satisfies the WKWebExtensionControllerDelegate interface and can be passed directly to SetDelegate and similar methods.

See Apple Documentation for protocol details.

func WKWebExtensionControllerDelegateObjectFromID

func WKWebExtensionControllerDelegateObjectFromID(id objc.ID) WKWebExtensionControllerDelegateObject

WKWebExtensionControllerDelegateObjectFromID constructs a WKWebExtensionControllerDelegateObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (WKWebExtensionControllerDelegateObject) BaseObject

func (WKWebExtensionControllerDelegateObject) WebExtensionControllerConnectUsingMessagePortForExtensionContextCompletionHandler

func (o WKWebExtensionControllerDelegateObject) WebExtensionControllerConnectUsingMessagePortForExtensionContextCompletionHandler(controller IWKWebExtensionController, port IWKWebExtensionMessagePort, extensionContext IWKWebExtensionContext, completionHandler ErrorHandler)

Called when an extension context wants to establish a persistent connection to an application.

controller: The web extension controller that is managing the extension.

port: A port object for handling the message exchange.

extensionContext: The context in which the web extension is running.

completionHandler: A block to be called when the connection is ready to use, taking an optional error. If the connection is successfully established, the error should be \c nil.

Discussion

This method should be implemented by the app to handle establishing connections to applications.

The provided WKWebExtensionMessagePort object can be used to handle message sending, receiving, and disconnection.

You should retain the port object for as long as the connection remains active. Releasing the port will disconnect it.

If not implemented, the default behavior is to pass the messages to the app extension handler within the extension’s bundle, if the extension was loaded from an app extension bundle; otherwise, no action is performed if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionControllerDelegate/webExtensionController(_:connectUsing:for:completionHandler:)

func (WKWebExtensionControllerDelegateObject) WebExtensionControllerDidUpdateActionForExtensionContext

func (o WKWebExtensionControllerDelegateObject) WebExtensionControllerDidUpdateActionForExtensionContext(controller IWKWebExtensionController, action IWKWebExtensionAction, context IWKWebExtensionContext)

Called when an action’s properties are updated.

controller: The web extension controller initiating the request.

action: The web extension action whose properties are updated.

context: The context within which the web extension is running.

Discussion

This method is called when an action’s properties are updated and should be reflected in the app’s user interface.

The app should ensure that any visible changes, such as icons and labels, are updated accordingly.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionControllerDelegate/webExtensionController(_:didUpdate:forExtensionContext:)

func (WKWebExtensionControllerDelegateObject) WebExtensionControllerFocusedWindowForExtensionContext

func (o WKWebExtensionControllerDelegateObject) WebExtensionControllerFocusedWindowForExtensionContext(controller IWKWebExtensionController, extensionContext IWKWebExtensionContext) WKWebExtensionWindow

Called when an extension context requests the currently focused window.

controller: The web extension controller that is managing the extension.

extensionContext: The context in which the web extension is running.

Discussion

This method can be optionally implemented by the app to designate the window currently in focus to the extension.

If not implemented, the first window in the result of [WebExtensionControllerOpenWindowsForExtensionContext] is used.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionControllerDelegate/webExtensionController(_:focusedWindowFor:)

func (WKWebExtensionControllerDelegateObject) WebExtensionControllerOpenNewTabUsingConfigurationForExtensionContextCompletionHandler

func (o WKWebExtensionControllerDelegateObject) WebExtensionControllerOpenNewTabUsingConfigurationForExtensionContextCompletionHandler(controller IWKWebExtensionController, configuration IWKWebExtensionTabConfiguration, extensionContext IWKWebExtensionContext, completionHandler WKWebExtensionTabErrorHandler)

Called when an extension context requests a new tab to be opened.

controller: The web extension controller that is managing the extension.

configuration: The configuration specifying how the new tab should be created.

extensionContext: The context in which the web extension is running.

completionHandler: A block to be called with the newly created tab or `nil` if the tab wasn’t created. An error should be provided if any errors occurred.

Discussion

This method should be implemented by the app to handle requests to open new tabs. The app can decide how to handle the process based on the provided configuration and existing tabs. Once handled, the app should call the completion handler with the opened tab or `nil` if the request was declined or failed. If not implemented, the extension will be unable to open new tabs.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionControllerDelegate/webExtensionController(_:openNewTabUsing:for:completionHandler:)

func (WKWebExtensionControllerDelegateObject) WebExtensionControllerOpenNewWindowUsingConfigurationForExtensionContextCompletionHandler

func (o WKWebExtensionControllerDelegateObject) WebExtensionControllerOpenNewWindowUsingConfigurationForExtensionContextCompletionHandler(controller IWKWebExtensionController, configuration IWKWebExtensionWindowConfiguration, extensionContext IWKWebExtensionContext, completionHandler WKWebExtensionWindowErrorHandler)

Called when an extension context requests a new window to be opened.

controller: The web extension controller that is managing the extension.

configuration: The configuration specifying how the new window should be created.

extensionContext: The context in which the web extension is running.

completionHandler: A block to be called with the newly created window or `nil` if the window wasn’t created. An error should be provided if any errors occurred.

Discussion

This method should be implemented by the app to handle requests to open new windows. The app can decide how to handle the process based on the provided configuration and existing windows. Once handled, the app should call the completion handler with the opened window or `nil` if the request was declined or failed. If not implemented, the extension will be unable to open new windows.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionControllerDelegate/webExtensionController(_:openNewWindowUsing:for:completionHandler:)

func (WKWebExtensionControllerDelegateObject) WebExtensionControllerOpenOptionsPageForExtensionContextCompletionHandler

func (o WKWebExtensionControllerDelegateObject) WebExtensionControllerOpenOptionsPageForExtensionContextCompletionHandler(controller IWKWebExtensionController, extensionContext IWKWebExtensionContext, completionHandler ErrorHandler)

Called when an extension context requests its options page to be opened.

controller: The web extension controller that is managing the extension.

extensionContext: The context in which the web extension is running.

completionHandler: A block to be called once the options page has been displayed or with an error if the page could not be shown.

Discussion

This method should be implemented by the app to handle requests to display the extension’s options page. The app can decide how and where to display the options page (e.g., in a new tab or a separate window). The app should call the completion handler once the options page is visible to the user, or with an error if the operation was declined or failed. If not implemented, the options page will be opened in a new tab using the [WebExtensionControllerOpenNewTabUsingConfigurationForExtensionContextCompletionHandler] delegate method.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionControllerDelegate/webExtensionController(_:openOptionsPageFor:completionHandler:)

func (WKWebExtensionControllerDelegateObject) WebExtensionControllerOpenWindowsForExtensionContext

func (o WKWebExtensionControllerDelegateObject) WebExtensionControllerOpenWindowsForExtensionContext(controller IWKWebExtensionController, extensionContext IWKWebExtensionContext) []objectivec.IObject

Called when an extension context requests the list of ordered open windows.

controller: The web extension controller that is managing the extension.

extensionContext: The context in which the web extension is running.

Discussion

This method should be implemented by the app to provide the extension with the ordered open windows. Depending on your app’s requirements, you may return different windows for each extension or the same windows for all extensions. The first window in the returned array must correspond to the currently focused window and match the result of [WebExtensionControllerFocusedWindowForExtensionContext].

If [WebExtensionControllerFocusedWindowForExtensionContext] returns `nil`, indicating that no window has focus or the focused window is not visible to the extension, the first window in the list returned by this method will be considered the presumed focused window. An empty result indicates no open windows are available for the extension. Defaults to an empty array if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionControllerDelegate/webExtensionController(_:openWindowsFor:)

func (WKWebExtensionControllerDelegateObject) WebExtensionControllerPresentPopupForActionForExtensionContextCompletionHandler

func (o WKWebExtensionControllerDelegateObject) WebExtensionControllerPresentPopupForActionForExtensionContextCompletionHandler(controller IWKWebExtensionController, action IWKWebExtensionAction, context IWKWebExtensionContext, completionHandler ErrorHandler)

Called when a popup is requested to be displayed for a specific action.

controller: The web extension controller initiating the request.

action: The action for which the popup is requested.

context: The context within which the web extension is running.

completionHandler: A block to be called once the popup display operation is completed.

Discussion

This method is called in response to the extension’s scripts or when invoking [PerformActionForTab] if the action has a popup.

The associated tab, if applicable, can be located through the [AssociatedTab] property of the `action` parameter. This delegate method is called when the web view for the popup is fully loaded and ready to display. Implementing this method is needed if the app intends to support programmatically showing the popup by the extension, although it is recommended for handling both programmatic and user-initiated cases.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionControllerDelegate/webExtensionController(_:presentActionPopup:for:completionHandler:)

func (WKWebExtensionControllerDelegateObject) WebExtensionControllerSendMessageToApplicationWithIdentifierForExtensionContextReplyHandler

func (o WKWebExtensionControllerDelegateObject) WebExtensionControllerSendMessageToApplicationWithIdentifierForExtensionContextReplyHandler(controller IWKWebExtensionController, message objectivec.IObject, applicationIdentifier string, extensionContext IWKWebExtensionContext, replyHandler ObjectErrorHandler)

Called when an extension context wants to send a one-time message to an application.

controller: The web extension controller that is managing the extension.

message: The message to be sent.

applicationIdentifier: The unique identifier for the application, or \c nil if none was specified.

extensionContext: The context in which the web extension is running.

replyHandler: A block to be called with a JSON-serializable reply message or an error.

Discussion

This method should be implemented by the app to handle one-off messages to applications.

If not implemented, the default behavior is to pass the message to the app extension handler within the extension’s bundle, if the extension was loaded from an app extension bundle; otherwise, no action is performed if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionControllerDelegate/webExtensionController(_:sendMessage:toApplicationWithIdentifier:for:replyHandler:)

type WKWebExtensionDataRecord

type WKWebExtensionDataRecord struct {
	objectivec.Object
}

An object that represents a record of stored data for a specific web extension context.

Overview

Contains properties and methods to query the data types and sizes.

Instance Properties

Instance Methods

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/DataRecord

func NewWKWebExtensionDataRecord

func NewWKWebExtensionDataRecord() WKWebExtensionDataRecord

NewWKWebExtensionDataRecord creates a new WKWebExtensionDataRecord instance.

func WKWebExtensionDataRecordFromID

func WKWebExtensionDataRecordFromID(id objc.ID) WKWebExtensionDataRecord

WKWebExtensionDataRecordFromID constructs a WKWebExtensionDataRecord from an objc.ID.

An object that represents a record of stored data for a specific web extension context.

func (WKWebExtensionDataRecord) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKWebExtensionDataRecord) ContainedDataTypes

func (w WKWebExtensionDataRecord) ContainedDataTypes() foundation.INSSet

The set of data types contained in this data record.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/DataRecord/containedDataTypes

func (WKWebExtensionDataRecord) DisplayName

func (w WKWebExtensionDataRecord) DisplayName() string

The display name for the web extension to which this data record belongs.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/DataRecord/displayName

func (WKWebExtensionDataRecord) Errors

An array of errors that may have occurred when either calculating or deleting storage.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/DataRecord/errors

func (WKWebExtensionDataRecord) Init

Init initializes the instance.

func (WKWebExtensionDataRecord) SizeInBytesOfTypes

func (w WKWebExtensionDataRecord) SizeInBytesOfTypes(dataTypes foundation.INSSet) uint

Retrieves the size in bytes of the specific data types in this data record.

dataTypes: The set of data types to measure the size for.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/DataRecord/sizeInBytes(ofTypes:)

func (WKWebExtensionDataRecord) TotalSizeInBytes

func (w WKWebExtensionDataRecord) TotalSizeInBytes() uint

The total size in bytes of all data types contained in this data record.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/DataRecord/totalSizeInBytes

func (WKWebExtensionDataRecord) UniqueIdentifier

func (w WKWebExtensionDataRecord) UniqueIdentifier() string

Unique identifier for the web extension context to which this data record belongs.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/DataRecord/uniqueIdentifier

type WKWebExtensionDataRecordArrayHandler

type WKWebExtensionDataRecordArrayHandler = func(*[]WKWebExtensionDataRecord)

WKWebExtensionDataRecordArrayHandler handles A block to invoke when the data records have been fetched.

Used by:

  • [WKWebExtensionController.FetchDataRecordsOfTypesCompletionHandler]

type WKWebExtensionDataRecordClass

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

func GetWKWebExtensionDataRecordClass

func GetWKWebExtensionDataRecordClass() WKWebExtensionDataRecordClass

GetWKWebExtensionDataRecordClass returns the class object for WKWebExtensionDataRecord.

func (WKWebExtensionDataRecordClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebExtensionDataRecordClass) Class

Class returns the underlying Objective-C class pointer.

type WKWebExtensionDataRecordError

type WKWebExtensionDataRecordError int

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/DataRecord/Error/Code

const (
	// WKWebExtensionDataRecordErrorLocalStorageFailed: Indicates a failure occurred when either deleting or calculating local storage.
	WKWebExtensionDataRecordErrorLocalStorageFailed WKWebExtensionDataRecordError = 2
	// WKWebExtensionDataRecordErrorSessionStorageFailed: Indicates a failure occurred when either deleting or calculating session storage.
	WKWebExtensionDataRecordErrorSessionStorageFailed WKWebExtensionDataRecordError = 3
	// WKWebExtensionDataRecordErrorSynchronizedStorageFailed: Indicates a failure occurred when either deleting or calculating synchronized storage.
	WKWebExtensionDataRecordErrorSynchronizedStorageFailed WKWebExtensionDataRecordError = 4
	// WKWebExtensionDataRecordErrorUnknown: Indicates that an unknown error occurred.
	WKWebExtensionDataRecordErrorUnknown WKWebExtensionDataRecordError = 1
)

func (WKWebExtensionDataRecordError) String

type WKWebExtensionDataRecordHandler

type WKWebExtensionDataRecordHandler = func(*WKWebExtensionDataRecord)

WKWebExtensionDataRecordHandler handles A block to invoke when the data record has been fetched.

Used by:

type WKWebExtensionDataType

type WKWebExtensionDataType = string

WKWebExtensionDataType is constants for specifying data types for a [WKWebExtension.DataRecord].

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/DataType

type WKWebExtensionError

type WKWebExtensionError int

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Error/Code

const (
	// WKWebExtensionErrorInvalidArchive: Indicates that the archive file is invalid or corrupt.
	WKWebExtensionErrorInvalidArchive WKWebExtensionError = 9
	// WKWebExtensionErrorInvalidBackgroundPersistence: Indicates that the extension specified background persistence that was not compatible with the platform or features requested.
	WKWebExtensionErrorInvalidBackgroundPersistence WKWebExtensionError = 8
	// WKWebExtensionErrorInvalidDeclarativeNetRequestEntry: Indicates that an invalid declarative net request entry was encountered.
	WKWebExtensionErrorInvalidDeclarativeNetRequestEntry WKWebExtensionError = 7
	// WKWebExtensionErrorInvalidManifest: Indicates that an invalid `manifest.Json()` was encountered.
	WKWebExtensionErrorInvalidManifest WKWebExtensionError = 4
	// WKWebExtensionErrorInvalidManifestEntry: Indicates that an invalid manifest entry was encountered.
	WKWebExtensionErrorInvalidManifestEntry WKWebExtensionError = 6
	// WKWebExtensionErrorInvalidResourceCodeSignature: Indicates that a resource failed the bundle’s code signature checks.
	WKWebExtensionErrorInvalidResourceCodeSignature WKWebExtensionError = 3
	// WKWebExtensionErrorResourceNotFound: Indicates that a specified resource was not found on disk.
	WKWebExtensionErrorResourceNotFound WKWebExtensionError = 2
	// WKWebExtensionErrorUnknown: Indicates that an unknown error occurred.
	WKWebExtensionErrorUnknown WKWebExtensionError = 1
	// WKWebExtensionErrorUnsupportedManifestVersion: Indicates that the manifest version is not supported.
	WKWebExtensionErrorUnsupportedManifestVersion WKWebExtensionError = 5
)

func (WKWebExtensionError) String

func (e WKWebExtensionError) String() string

type WKWebExtensionErrorHandler

type WKWebExtensionErrorHandler = func(*WKWebExtension, error)

WKWebExtensionErrorHandler handles A block to be called with an initialized web extension, or `nil` if the object could not be initialized due to an error. The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.

Used by:

  • [WKWebExtension.ExtensionWithAppExtensionBundleCompletionHandler]
  • [WKWebExtension.ExtensionWithResourceBaseURLCompletionHandler]

type WKWebExtensionMatchPattern

type WKWebExtensionMatchPattern struct {
	objectivec.Object
}

An object that represents a way to specify groups of URLs.

Overview

All match patterns are specified as strings. Apart from the special “ pattern, match patterns consist of three parts: scheme, host, and path.

Initializers

Instance Properties

Instance Methods

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern

func NewWKWebExtensionMatchPattern

func NewWKWebExtensionMatchPattern() WKWebExtensionMatchPattern

NewWKWebExtensionMatchPattern creates a new WKWebExtensionMatchPattern instance.

func NewWebExtensionMatchPatternWithSchemeHostPathError

func NewWebExtensionMatchPatternWithSchemeHostPathError(scheme string, host string, path string) (WKWebExtensionMatchPattern, error)

Returns a pattern object for the specified scheme, host, and path strings.

scheme: On output, a pointer to an error object that describes why the method failed, or `nil` if no error occurred. If you are not interested in the error information, pass `nil` for this parameter.

Return Value

A pattern object, or `nil` if any of the strings are invalid and an error will be set.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/init(scheme:host:path:)

func NewWebExtensionMatchPatternWithStringError

func NewWebExtensionMatchPatternWithStringError(string_ string) (WKWebExtensionMatchPattern, error)

Returns a pattern object for the specified pattern string.

string: On output, a pointer to an error object that describes why the method failed, or `nil` if no error occurred. If you are not interested in the error information, pass `nil` for this parameter.

Return Value

A pattern object, or `nil` if the pattern string is invalid and an error will be set.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/init(string:)

func WKWebExtensionMatchPatternFromID

func WKWebExtensionMatchPatternFromID(id objc.ID) WKWebExtensionMatchPattern

WKWebExtensionMatchPatternFromID constructs a WKWebExtensionMatchPattern from an objc.ID.

An object that represents a way to specify groups of URLs.

func (WKWebExtensionMatchPattern) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKWebExtensionMatchPattern) EncodeWithCoder

func (w WKWebExtensionMatchPattern) EncodeWithCoder(coder foundation.INSCoder)

func (WKWebExtensionMatchPattern) Host

The host part of the pattern string, unless [MatchesAllURLs] is [YES].

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/host

func (WKWebExtensionMatchPattern) Init

Init initializes the instance.

func (WKWebExtensionMatchPattern) InitWithSchemeHostPathError

func (w WKWebExtensionMatchPattern) InitWithSchemeHostPathError(scheme string, host string, path string) (WKWebExtensionMatchPattern, error)

Returns a pattern object for the specified scheme, host, and path strings.

scheme: On output, a pointer to an error object that describes why the method failed, or `nil` if no error occurred. If you are not interested in the error information, pass `nil` for this parameter.

Return Value

A pattern object, or `nil` if any of the strings are invalid and an error will be set.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/init(scheme:host:path:)

func (WKWebExtensionMatchPattern) InitWithStringError

func (w WKWebExtensionMatchPattern) InitWithStringError(string_ string) (WKWebExtensionMatchPattern, error)

Returns a pattern object for the specified pattern string.

string: On output, a pointer to an error object that describes why the method failed, or `nil` if no error occurred. If you are not interested in the error information, pass `nil` for this parameter.

Return Value

A pattern object, or `nil` if the pattern string is invalid and an error will be set.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/init(string:)

func (WKWebExtensionMatchPattern) MatchesAllHosts

func (w WKWebExtensionMatchPattern) MatchesAllHosts() bool

A Boolean value that indicates if the pattern is “ or has `*` as the host.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/matchesAllHosts

func (WKWebExtensionMatchPattern) MatchesAllURLs

func (w WKWebExtensionMatchPattern) MatchesAllURLs() bool

A Boolean value that indicates if the pattern is “.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/matchesAllURLs

func (WKWebExtensionMatchPattern) MatchesPattern

Matches the receiver pattern against the specified pattern.

pattern: The pattern to match against the receiver pattern.

Return Value

A Boolean value indicating if the receiver pattern matches the specified pattern.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/matches(_:)-4d84f

func (WKWebExtensionMatchPattern) MatchesPatternOptions

Matches the receiver pattern against the specified pattern with options.

pattern: The pattern to match against the receiver pattern.

options: The options to use while matching.

Return Value

A Boolean value indicating if the receiver pattern matches the specified pattern.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/matches(_:options:)-fnde

func (WKWebExtensionMatchPattern) MatchesURL

Matches the receiver pattern against the specified URL.

url: The URL to match against the receiver pattern.

Return Value

A Boolean value indicating if the pattern matches the specified URL.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/matches(_:)-471rf

func (WKWebExtensionMatchPattern) MatchesURLOptions

Matches the receiver pattern against the specified URL with options.

url: The URL to match against the receiver pattern.

options: The options to use while matching.

Return Value

A Boolean value indicating if the pattern matches the specified URL.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/matches(_:options:)-5wo3g

func (WKWebExtensionMatchPattern) Path

The path part of the pattern string, unless [MatchesAllURLs] is [YES].

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/path

func (WKWebExtensionMatchPattern) Scheme

The scheme part of the pattern string, unless [MatchesAllURLs] is [YES].

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/scheme

func (WKWebExtensionMatchPattern) String

The original pattern string.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/string

type WKWebExtensionMatchPatternClass

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

func GetWKWebExtensionMatchPatternClass

func GetWKWebExtensionMatchPatternClass() WKWebExtensionMatchPatternClass

GetWKWebExtensionMatchPatternClass returns the class object for WKWebExtensionMatchPattern.

func (WKWebExtensionMatchPatternClass) AllHostsAndSchemesMatchPattern

func (_WKWebExtensionMatchPatternClass WKWebExtensionMatchPatternClass) AllHostsAndSchemesMatchPattern() WKWebExtensionMatchPattern

Returns a pattern object that has `*` for scheme, host, and path.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/allHostsAndSchemes()

func (WKWebExtensionMatchPatternClass) AllURLsMatchPattern

func (_WKWebExtensionMatchPatternClass WKWebExtensionMatchPatternClass) AllURLsMatchPattern() WKWebExtensionMatchPattern

Returns a pattern object for “.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/allURLs()

func (WKWebExtensionMatchPatternClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebExtensionMatchPatternClass) Class

Class returns the underlying Objective-C class pointer.

func (WKWebExtensionMatchPatternClass) MatchPatternWithSchemeHostPath

func (_WKWebExtensionMatchPatternClass WKWebExtensionMatchPatternClass) MatchPatternWithSchemeHostPath(scheme string, host string, path string) WKWebExtensionMatchPattern

Returns a pattern object for the specified scheme, host, and path strings.

Return Value

A pattern object, or `nil` if any of the strings are invalid.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionMatchPattern/matchPatternWithScheme:host:path:

func (WKWebExtensionMatchPatternClass) MatchPatternWithString

func (_WKWebExtensionMatchPatternClass WKWebExtensionMatchPatternClass) MatchPatternWithString(string_ string) WKWebExtensionMatchPattern

Returns a pattern object for the specified pattern string.

Return Value

Returns `nil` if the pattern string is invalid.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionMatchPattern/matchPatternWithString:

func (WKWebExtensionMatchPatternClass) RegisterCustomURLScheme

func (_WKWebExtensionMatchPatternClass WKWebExtensionMatchPatternClass) RegisterCustomURLScheme(urlScheme string)

Registers a custom URL scheme that can be used in match patterns.

urlScheme: The custom URL scheme to register.

Discussion

This method should be used to register any custom URL schemes used by the app for the extension base URLs, other than `webkit-extension`, or if extensions should have access to other supported URL schemes when using “.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/registerCustomURLScheme(_:)

type WKWebExtensionMatchPatternError

type WKWebExtensionMatchPatternError int

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/Error/Code

const (
	// WKWebExtensionMatchPatternErrorInvalidHost: Indicates that the host component was invalid.
	WKWebExtensionMatchPatternErrorInvalidHost WKWebExtensionMatchPatternError = 3
	// WKWebExtensionMatchPatternErrorInvalidPath: Indicates that the path component was invalid.
	WKWebExtensionMatchPatternErrorInvalidPath WKWebExtensionMatchPatternError = 4
	// WKWebExtensionMatchPatternErrorInvalidScheme: Indicates that the scheme component was invalid.
	WKWebExtensionMatchPatternErrorInvalidScheme WKWebExtensionMatchPatternError = 2
	// WKWebExtensionMatchPatternErrorUnknown: Indicates that an unknown error occurred.
	WKWebExtensionMatchPatternErrorUnknown WKWebExtensionMatchPatternError = 1
)

func (WKWebExtensionMatchPatternError) String

type WKWebExtensionMatchPatternOptions

type WKWebExtensionMatchPatternOptions uint

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MatchPattern/Options

const (
	// WKWebExtensionMatchPatternOptionsIgnorePaths: Indicates that the host components should be ignored while matching.
	WKWebExtensionMatchPatternOptionsIgnorePaths WKWebExtensionMatchPatternOptions = 2
	// WKWebExtensionMatchPatternOptionsIgnoreSchemes: Indicates that the scheme components should be ignored while matching.
	WKWebExtensionMatchPatternOptionsIgnoreSchemes WKWebExtensionMatchPatternOptions = 1
	// WKWebExtensionMatchPatternOptionsMatchBidirectionally: Indicates that two patterns should be checked in either direction while matching.
	WKWebExtensionMatchPatternOptionsMatchBidirectionally WKWebExtensionMatchPatternOptions = 4
	// WKWebExtensionMatchPatternOptionsNone: Indicates no special matching options.
	WKWebExtensionMatchPatternOptionsNone WKWebExtensionMatchPatternOptions = 0
)

func (WKWebExtensionMatchPatternOptions) String

type WKWebExtensionMatchPatternSetDateHandler

type WKWebExtensionMatchPatternSetDateHandler = func(*foundation.INSSet, *foundation.NSDate)

WKWebExtensionMatchPatternSetDateHandler handles A block to be called with the set of allowed match patterns and an optional expiration date.

Used by:

  • [WKWebExtensionControllerDelegate.WebExtensionControllerPromptForPermissionMatchPatternsInTabForExtensionContextCompletionHandler]

type WKWebExtensionMessagePort

type WKWebExtensionMessagePort struct {
	objectivec.Object
}

An object that manages message-based communication with a web extension.

Overview

Contains properties and methods to handle message exchanges with a web extension.

Instance Properties

Instance Methods

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MessagePort

func NewWKWebExtensionMessagePort

func NewWKWebExtensionMessagePort() WKWebExtensionMessagePort

NewWKWebExtensionMessagePort creates a new WKWebExtensionMessagePort instance.

func WKWebExtensionMessagePortFromID

func WKWebExtensionMessagePortFromID(id objc.ID) WKWebExtensionMessagePort

WKWebExtensionMessagePortFromID constructs a WKWebExtensionMessagePort from an objc.ID.

An object that manages message-based communication with a web extension.

func (WKWebExtensionMessagePort) ApplicationIdentifier

func (w WKWebExtensionMessagePort) ApplicationIdentifier() string

The unique identifier for the app to which this port should be connected.

Discussion

This identifier is provided by the web extension and may or may not be used by the app. It’s up to the app to decide how to interpret this identifier.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MessagePort/applicationIdentifier

func (WKWebExtensionMessagePort) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKWebExtensionMessagePort) Disconnect

func (w WKWebExtensionMessagePort) Disconnect()

Disconnects the port, terminating all further messages.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MessagePort/disconnect()

func (WKWebExtensionMessagePort) DisconnectHandler

func (w WKWebExtensionMessagePort) DisconnectHandler() ErrorHandler

The block to be executed when the port disconnects.

Discussion

An optional block to be invoked when the port disconnects, taking an optional error that indicates if the disconnection was caused by an error.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MessagePort/disconnectHandler

func (WKWebExtensionMessagePort) DisconnectWithError

func (w WKWebExtensionMessagePort) DisconnectWithError(error_ foundation.INSError)

Disconnects the port, terminating all further messages with an optional error.

error: An optional error indicating the reason for disconnection.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MessagePort/disconnect(throwing:)

func (WKWebExtensionMessagePort) Disconnected

func (w WKWebExtensionMessagePort) Disconnected() bool

Indicates whether the message port is disconnected.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MessagePort/isDisconnected

func (WKWebExtensionMessagePort) Init

Init initializes the instance.

func (WKWebExtensionMessagePort) MessageHandler

func (w WKWebExtensionMessagePort) MessageHandler() ObjectErrorHandler

The block to be executed when a message is received from the web extension.

Discussion

An optional block to be invoked when a message is received, taking two parameters: the message and an optional error.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MessagePort/messageHandler

func (WKWebExtensionMessagePort) SendMessage

func (w WKWebExtensionMessagePort) SendMessage(ctx context.Context, message objectivec.IObject) error

SendMessage is a synchronous wrapper around WKWebExtensionMessagePort.SendMessageCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebExtensionMessagePort) SendMessageCompletionHandler

func (w WKWebExtensionMessagePort) SendMessageCompletionHandler(message objectivec.IObject, completionHandler ErrorHandler)

Sends a message to the connected web extension.

message: The JSON-serializable message to be sent.

completionHandler: An optional block to be invoked after the message is sent, taking an optional error.

Discussion

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MessagePort/sendMessage(_:completionHandler:)

func (WKWebExtensionMessagePort) SetDisconnectHandler

func (w WKWebExtensionMessagePort) SetDisconnectHandler(value ErrorHandler)

func (WKWebExtensionMessagePort) SetMessageHandler

func (w WKWebExtensionMessagePort) SetMessageHandler(value ObjectErrorHandler)

type WKWebExtensionMessagePortClass

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

func GetWKWebExtensionMessagePortClass

func GetWKWebExtensionMessagePortClass() WKWebExtensionMessagePortClass

GetWKWebExtensionMessagePortClass returns the class object for WKWebExtensionMessagePort.

func (WKWebExtensionMessagePortClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebExtensionMessagePortClass) Class

Class returns the underlying Objective-C class pointer.

type WKWebExtensionMessagePortError

type WKWebExtensionMessagePortError int

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/MessagePort/Error/Code

const (
	// WKWebExtensionMessagePortErrorMessageInvalid: Indicates that the message is invalid.
	WKWebExtensionMessagePortErrorMessageInvalid WKWebExtensionMessagePortError = 3
	// WKWebExtensionMessagePortErrorNotConnected: Indicates that the message port is disconnected.
	WKWebExtensionMessagePortErrorNotConnected WKWebExtensionMessagePortError = 2
	// WKWebExtensionMessagePortErrorUnknown: Indicates that an unknown error occurred.
	WKWebExtensionMessagePortErrorUnknown WKWebExtensionMessagePortError = 1
)

func (WKWebExtensionMessagePortError) String

type WKWebExtensionPermission

type WKWebExtensionPermission = string

WKWebExtensionPermission is constants for specifying permission in a WKWebExtensionContext.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/Permission

type WKWebExtensionTab

type WKWebExtensionTab interface {
	objectivec.IObject
}

A protocol with methods that represent a tab to web extensions.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab

type WKWebExtensionTabChangedProperties

type WKWebExtensionTabChangedProperties uint

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/TabChangedProperties

const (
	// WKWebExtensionTabChangedPropertiesLoading: Indicates the loading state changed.
	WKWebExtensionTabChangedPropertiesLoading WKWebExtensionTabChangedProperties = 2
	// WKWebExtensionTabChangedPropertiesMuted: Indicates the muted state changed.
	WKWebExtensionTabChangedPropertiesMuted WKWebExtensionTabChangedProperties = 4
	// WKWebExtensionTabChangedPropertiesNone: Indicates nothing changed.
	WKWebExtensionTabChangedPropertiesNone WKWebExtensionTabChangedProperties = 0
	// WKWebExtensionTabChangedPropertiesPinned: Indicates the pinned state changed.
	WKWebExtensionTabChangedPropertiesPinned WKWebExtensionTabChangedProperties = 8
	// WKWebExtensionTabChangedPropertiesPlayingAudio: Indicates the audio playback state changed.
	WKWebExtensionTabChangedPropertiesPlayingAudio WKWebExtensionTabChangedProperties = 16
	// WKWebExtensionTabChangedPropertiesReaderMode: Indicates the reader mode state changed.
	WKWebExtensionTabChangedPropertiesReaderMode WKWebExtensionTabChangedProperties = 32
	// WKWebExtensionTabChangedPropertiesSize: Indicates the size changed.
	WKWebExtensionTabChangedPropertiesSize WKWebExtensionTabChangedProperties = 64
	// WKWebExtensionTabChangedPropertiesTitle: Indicates the title changed.
	WKWebExtensionTabChangedPropertiesTitle WKWebExtensionTabChangedProperties = 128
	// WKWebExtensionTabChangedPropertiesURL: Indicates the URL changed.
	WKWebExtensionTabChangedPropertiesURL WKWebExtensionTabChangedProperties = 256
	// WKWebExtensionTabChangedPropertiesZoomFactor: Indicates the zoom factor changed.
	WKWebExtensionTabChangedPropertiesZoomFactor WKWebExtensionTabChangedProperties = 512
)

func (WKWebExtensionTabChangedProperties) String

type WKWebExtensionTabConfiguration

type WKWebExtensionTabConfiguration struct {
	objectivec.Object
}

An object that encapsulates configuration options for a tab in an extension.

Overview

This class holds various options that influence the behavior and initial state of a tab.

The app retains the discretion to disregard any or all of these options, or even opt not to create a tab.

Instance Properties

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/TabConfiguration

func NewWKWebExtensionTabConfiguration

func NewWKWebExtensionTabConfiguration() WKWebExtensionTabConfiguration

NewWKWebExtensionTabConfiguration creates a new WKWebExtensionTabConfiguration instance.

func WKWebExtensionTabConfigurationFromID

func WKWebExtensionTabConfigurationFromID(id objc.ID) WKWebExtensionTabConfiguration

WKWebExtensionTabConfigurationFromID constructs a WKWebExtensionTabConfiguration from an objc.ID.

An object that encapsulates configuration options for a tab in an extension.

func (WKWebExtensionTabConfiguration) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKWebExtensionTabConfiguration) Index

Indicates the position where the tab should be opened within the window.

See: https://developer.apple.com/documentation/webkit/wkwebextension/tabconfiguration/index

func (WKWebExtensionTabConfiguration) Init

Init initializes the instance.

func (WKWebExtensionTabConfiguration) ParentTab

Indicates the parent tab with which the tab should be related.

Discussion

If this property is `nil`, no parent tab was specified.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/TabConfiguration/parentTab

func (WKWebExtensionTabConfiguration) SetIndex

func (w WKWebExtensionTabConfiguration) SetIndex(value int)

func (WKWebExtensionTabConfiguration) ShouldAddToSelection

func (w WKWebExtensionTabConfiguration) ShouldAddToSelection() bool

Indicates whether the tab should be added to the current tab selection.

Discussion

If this property is [YES], the tab should be part of the current selection, but not necessarily become the active tab unless [ShouldBeActive] is also [YES]. If this property is [NO], the tab shouldn’t be part of the current selection.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/TabConfiguration/shouldAddToSelection

func (WKWebExtensionTabConfiguration) ShouldBeActive

func (w WKWebExtensionTabConfiguration) ShouldBeActive() bool

Indicates whether the tab should be the active tab.

Discussion

If this property is [YES], the tab should be made active in the window, ensuring it is the frontmost tab. Being active implies the tab is also selected. If this property is [NO], the tab shouldn’t affect the currently active tab.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/TabConfiguration/shouldBeActive

func (WKWebExtensionTabConfiguration) ShouldBeMuted

func (w WKWebExtensionTabConfiguration) ShouldBeMuted() bool

Indicates whether the tab should be muted.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/TabConfiguration/shouldBeMuted

func (WKWebExtensionTabConfiguration) ShouldBePinned

func (w WKWebExtensionTabConfiguration) ShouldBePinned() bool

Indicates whether the tab should be pinned.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/TabConfiguration/shouldBePinned

func (WKWebExtensionTabConfiguration) ShouldReaderModeBeActive

func (w WKWebExtensionTabConfiguration) ShouldReaderModeBeActive() bool

Indicates whether reader mode in the tab should be active.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/TabConfiguration/shouldReaderModeBeActive

func (WKWebExtensionTabConfiguration) Url

Indicates the initial URL for the tab.

Discussion

If this property is `nil`, the app’s default start page should appear in the tab.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/TabConfiguration/url

func (WKWebExtensionTabConfiguration) Window

Indicates the window where the tab should be opened.

Discussion

If this property is `nil`, no window was specified.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/TabConfiguration/window

type WKWebExtensionTabConfigurationClass

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

func GetWKWebExtensionTabConfigurationClass

func GetWKWebExtensionTabConfigurationClass() WKWebExtensionTabConfigurationClass

GetWKWebExtensionTabConfigurationClass returns the class object for WKWebExtensionTabConfiguration.

func (WKWebExtensionTabConfigurationClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebExtensionTabConfigurationClass) Class

Class returns the underlying Objective-C class pointer.

type WKWebExtensionTabErrorHandler

type WKWebExtensionTabErrorHandler = func(WKWebExtensionTab, error)

WKWebExtensionTabErrorHandler handles A block to be called with the newly created tab or `nil` if the tab wasn’t created. The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.

Used by:

  • [WKWebExtensionControllerDelegate.WebExtensionControllerOpenNewTabUsingConfigurationForExtensionContextCompletionHandler]
  • [WKWebExtensionTab.DuplicateUsingConfigurationForWebExtensionContextCompletionHandler]

type WKWebExtensionTabObject

type WKWebExtensionTabObject struct {
	objectivec.Object
}

WKWebExtensionTabObject wraps an existing Objective-C object that conforms to the WKWebExtensionTab protocol.

func WKWebExtensionTabObjectFromID

func WKWebExtensionTabObjectFromID(id objc.ID) WKWebExtensionTabObject

WKWebExtensionTabObjectFromID constructs a WKWebExtensionTabObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (WKWebExtensionTabObject) ActivateForWebExtensionContextCompletionHandler

func (o WKWebExtensionTabObject) ActivateForWebExtensionContextCompletionHandler(context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to activate the tab, making it frontmost.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

Upon activation, the tab should become the frontmost and either be the sole selected tab or be included among the selected tabs. No action is performed if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/activate(for:completionHandler:)

func (WKWebExtensionTabObject) BaseObject

func (o WKWebExtensionTabObject) BaseObject() objectivec.Object

func (WKWebExtensionTabObject) CloseForWebExtensionContextCompletionHandler

func (o WKWebExtensionTabObject) CloseForWebExtensionContextCompletionHandler(context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to close the tab.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

No action is performed if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/close(for:completionHandler:)

func (WKWebExtensionTabObject) DetectWebpageLocaleForWebExtensionContextCompletionHandler

func (o WKWebExtensionTabObject) DetectWebpageLocaleForWebExtensionContextCompletionHandler(context IWKWebExtensionContext, completionHandler LocaleErrorHandler)

Called to detect the locale of the webpage currently loaded in the tab.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. The block takes two arguments: the detected locale (or `nil` if the locale is unknown) and an error, which should be provided if any errors occurred.

Discussion

No action is performed if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/detectWebpageLocale(for:completionHandler:)

func (WKWebExtensionTabObject) DuplicateUsingConfigurationForWebExtensionContextCompletionHandler

func (o WKWebExtensionTabObject) DuplicateUsingConfigurationForWebExtensionContextCompletionHandler(configuration IWKWebExtensionTabConfiguration, context IWKWebExtensionContext, completionHandler WKWebExtensionTabErrorHandler)

Called to duplicate the tab.

configuration: The tab configuration influencing the duplicated tab’s properties.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes two arguments: the duplicated tab (or \c nil if no tab was created) and an error, which should be provided if any errors occurred.

Discussion

This is equivalent to the user selecting to duplicate the tab through a menu item, with the specified configuration.

No action is performed if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/duplicate(using:for:completionHandler:)

func (WKWebExtensionTabObject) GoBackForWebExtensionContextCompletionHandler

func (o WKWebExtensionTabObject) GoBackForWebExtensionContextCompletionHandler(context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to navigate the tab to the previous page in its history.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

Navigates to the previous page in the tab’s web view via [GoBack] if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/goBack(for:completionHandler:)

func (WKWebExtensionTabObject) GoForwardForWebExtensionContextCompletionHandler

func (o WKWebExtensionTabObject) GoForwardForWebExtensionContextCompletionHandler(context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to navigate the tab to the next page in its history.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

Navigates to the next page in the tab’s web view via [GoForward] if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/goForward(for:completionHandler:)

func (WKWebExtensionTabObject) IndexInWindowForWebExtensionContext

func (o WKWebExtensionTabObject) IndexInWindowForWebExtensionContext(context IWKWebExtensionContext) uint

Called when the index of the tab in the window is needed.

context: The context in which the web extension is running.

Discussion

This method should be implemented for better performance. Defaults to the window’s [TabsForWebExtensionContext] method to find the index if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/indexInWindow(for:)

func (WKWebExtensionTabObject) IsLoadingCompleteForWebExtensionContext

func (o WKWebExtensionTabObject) IsLoadingCompleteForWebExtensionContext(context IWKWebExtensionContext) bool

Called to check if the tab has finished loading.

context: The context in which the web extension is running.

Discussion

Defaults to [Loading] of the tab’s web view if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/isLoadingComplete(for:)

func (WKWebExtensionTabObject) IsMutedForWebExtensionContext

func (o WKWebExtensionTabObject) IsMutedForWebExtensionContext(context IWKWebExtensionContext) bool

Called to check if the tab is currently muted.

context: The context in which the web extension is running.

Discussion

Defaults to [NO] if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/isMuted(for:)

func (WKWebExtensionTabObject) IsPinnedForWebExtensionContext

func (o WKWebExtensionTabObject) IsPinnedForWebExtensionContext(context IWKWebExtensionContext) bool

Called when the pinned state of the tab is needed.

context: The context in which the web extension is running.

Discussion

Defaults to [NO] if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/isPinned(for:)

func (WKWebExtensionTabObject) IsPlayingAudioForWebExtensionContext

func (o WKWebExtensionTabObject) IsPlayingAudioForWebExtensionContext(context IWKWebExtensionContext) bool

Called to check if the tab is currently playing audio.

context: The context in which the web extension is running.

Discussion

Defaults to [NO] if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/isPlayingAudio(for:)

func (WKWebExtensionTabObject) IsReaderModeActiveForWebExtensionContext

func (o WKWebExtensionTabObject) IsReaderModeActiveForWebExtensionContext(context IWKWebExtensionContext) bool

Called to check if the tab is currently showing reader mode.

context: The context in which the web extension is running.

Discussion

Defaults to [NO] if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/isReaderModeActive(for:)

func (WKWebExtensionTabObject) IsReaderModeAvailableForWebExtensionContext

func (o WKWebExtensionTabObject) IsReaderModeAvailableForWebExtensionContext(context IWKWebExtensionContext) bool

Called to check if reader mode is available for the tab.

context: The context in which the web extension is running.

Discussion

Defaults to [NO] if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/isReaderModeAvailable(for:)

func (WKWebExtensionTabObject) IsSelectedForWebExtensionContext

func (o WKWebExtensionTabObject) IsSelectedForWebExtensionContext(context IWKWebExtensionContext) bool

Called when the selected state of the tab is needed.

context: The context in which the web extension is running.

Discussion

Defaults to [YES] for the active tab and [NO] for other tabs if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/isSelected(for:)

func (WKWebExtensionTabObject) LoadURLForWebExtensionContextCompletionHandler

func (o WKWebExtensionTabObject) LoadURLForWebExtensionContextCompletionHandler(url foundation.INSURL, context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to load a URL in the tab.

url: The URL to be loaded in the tab.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

If the tab is already loading a page, calling this method should stop the current page from loading and start loading the new URL. Loads the URL in the tab’s web view via [LoadRequest] if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/loadURL(_:for:completionHandler:)

func (WKWebExtensionTabObject) ParentTabForWebExtensionContext

func (o WKWebExtensionTabObject) ParentTabForWebExtensionContext(context IWKWebExtensionContext) WKWebExtensionTab

Called when the parent tab for the tab is needed.

context: The context in which the web extension is running.

Discussion

Defaults to `nil` if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/parentTab(for:)

func (WKWebExtensionTabObject) PendingURLForWebExtensionContext

func (o WKWebExtensionTabObject) PendingURLForWebExtensionContext(context IWKWebExtensionContext) foundation.INSURL

Called when the pending URL of the tab is needed.

context: The context in which the web extension is running.

Discussion

The pending URL is the URL of a page that is in the process of loading. If there is no pending URL, return `nil`.

Defaults to `nil` if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/pendingURL(for:)

func (WKWebExtensionTabObject) ReloadFromOriginForWebExtensionContextCompletionHandler

func (o WKWebExtensionTabObject) ReloadFromOriginForWebExtensionContextCompletionHandler(fromOrigin bool, context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to reload the current page in the tab.

fromOrigin: A boolean value indicating whether to reload the tab from the origin, bypassing the cache.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

Reloads the tab’s web view via [Reload] or [ReloadFromOrigin] if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/reload(fromOrigin:for:completionHandler:)

func (WKWebExtensionTabObject) SetMutedForWebExtensionContextCompletionHandler

func (o WKWebExtensionTabObject) SetMutedForWebExtensionContextCompletionHandler(muted bool, context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to set the mute state of the tab.

muted: A boolean indicating whether the tab should be muted.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

No action is performed if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/setMuted(_:for:completionHandler:)

func (WKWebExtensionTabObject) SetParentTabForWebExtensionContextCompletionHandler

func (o WKWebExtensionTabObject) SetParentTabForWebExtensionContextCompletionHandler(parentTab WKWebExtensionTab, context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to set or clear the parent tab for the tab.

parentTab: The tab that should be set as the parent of the tab. If \c nil is provided, the current parent tab should be cleared.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

No action is performed if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/setParentTab(_:for:completionHandler:)

func (WKWebExtensionTabObject) SetPinnedForWebExtensionContextCompletionHandler

func (o WKWebExtensionTabObject) SetPinnedForWebExtensionContextCompletionHandler(pinned bool, context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to set the pinned state of the tab.

pinned: A boolean value indicating whether to pin the tab.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

This is equivalent to the user selecting to pin or unpin the tab through a menu item. When a tab is pinned, it should be moved to the front of the tab bar and usually reduced in size. When a tab is unpinned, it should be restored to a normal size and position in the tab bar. No action is performed if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/setPinned(_:for:completionHandler:)

func (WKWebExtensionTabObject) SetReaderModeActiveForWebExtensionContextCompletionHandler

func (o WKWebExtensionTabObject) SetReaderModeActiveForWebExtensionContextCompletionHandler(active bool, context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to set the reader mode for the tab.

active: A boolean value indicating whether to activate reader mode.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

No action is performed if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/setReaderModeActive(_:for:completionHandler:)

func (WKWebExtensionTabObject) SetSelectedForWebExtensionContextCompletionHandler

func (o WKWebExtensionTabObject) SetSelectedForWebExtensionContextCompletionHandler(selected bool, context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to set the selected state of the tab.

selected: A boolean value indicating whether to select the tab.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

This is equivalent to the user command-clicking on the tab to add it to or remove it from a selection.

The method should update the tab’s selection state without changing the active tab. No action is performed if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/setSelected(_:for:completionHandler:)

func (WKWebExtensionTabObject) SetZoomFactorForWebExtensionContextCompletionHandler

func (o WKWebExtensionTabObject) SetZoomFactorForWebExtensionContextCompletionHandler(zoomFactor float64, context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to set the zoom factor of the tab.

zoomFactor: The desired zoom factor for the tab.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

Sets [PageZoom] of the tab’s web view if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/setZoomFactor(_:for:completionHandler:)

func (WKWebExtensionTabObject) ShouldBypassPermissionsForWebExtensionContext

func (o WKWebExtensionTabObject) ShouldBypassPermissionsForWebExtensionContext(context IWKWebExtensionContext) bool

Called to determine if the tab should bypass host permission checks.

context: The context in which the web extension is running.

Discussion

This method allows the app to dynamically control whether a tab can bypass standard host permission checks.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/shouldBypassPermissions(for:)

func (WKWebExtensionTabObject) ShouldGrantPermissionsOnUserGestureForWebExtensionContext

func (o WKWebExtensionTabObject) ShouldGrantPermissionsOnUserGestureForWebExtensionContext(context IWKWebExtensionContext) bool

Called to determine if permissions should be granted for the tab on user gesture.

context: The context in which the web extension is running.

Discussion

This method allows the app to control granting of permissions on a per-tab basis when triggered by a user gesture. Implementing this method enables the app to dynamically manage `activeTab` permissions based on the tab’s current state, the content being accessed, or other custom criteria.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/shouldGrantPermissionsOnUserGesture(for:)

func (WKWebExtensionTabObject) SizeForWebExtensionContext

func (o WKWebExtensionTabObject) SizeForWebExtensionContext(context IWKWebExtensionContext) corefoundation.CGSize

Called when the size of the tab is needed.

context: The context in which the web extension is running.

Discussion

Defaults to size of the tab’s web view if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/size(for:)

func (WKWebExtensionTabObject) TitleForWebExtensionContext

func (o WKWebExtensionTabObject) TitleForWebExtensionContext(context IWKWebExtensionContext) string

Called when the title of the tab is needed.

context: The context in which the web extension is running.

Discussion

Defaults to [Title] of the tab’s web view if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/title(for:)

func (WKWebExtensionTabObject) UrlForWebExtensionContext

func (o WKWebExtensionTabObject) UrlForWebExtensionContext(context IWKWebExtensionContext) foundation.INSURL

Called when the URL of the tab is needed.

context: The context in which the web extension is running.

Discussion

Defaults to [URL] of the tab’s web view if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/url(for:)

func (WKWebExtensionTabObject) WebViewForWebExtensionContext

func (o WKWebExtensionTabObject) WebViewForWebExtensionContext(context IWKWebExtensionContext) IWKWebView

Called when the web view for the tab is needed.

context: The context in which the web extension is running.

Discussion

The web view’s WKWebViewConfiguration must have its [WebExtensionController] property set to match the controller of the given context; otherwise `nil` will be used. Defaults to `nil` if not implemented. If `nil`, some critical features will not be available for this tab, such as content injection or modification.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/webView(for:)

func (WKWebExtensionTabObject) WindowForWebExtensionContext

func (o WKWebExtensionTabObject) WindowForWebExtensionContext(context IWKWebExtensionContext) WKWebExtensionWindow

Called when the window containing the tab is needed.

context: The context in which the web extension is running.

Discussion

Defaults to `nil` if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/window(for:)

func (WKWebExtensionTabObject) ZoomFactorForWebExtensionContext

func (o WKWebExtensionTabObject) ZoomFactorForWebExtensionContext(context IWKWebExtensionContext) float64

Called when the zoom factor of the tab is needed.

context: The context in which the web extension is running.

Discussion

Defaults to [PageZoom] of the tab’s web view if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionTab/zoomFactor(for:)

type WKWebExtensionWindow

type WKWebExtensionWindow interface {
	objectivec.IObject
}

A protocol with methods that represent a window to web extensions.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionWindow

type WKWebExtensionWindowConfiguration

type WKWebExtensionWindowConfiguration struct {
	objectivec.Object
}

An object that encapsulates configuration options for a window in an extension.

Overview

This class holds various options that influence the behavior and initial state of a window.

The app retains the discretion to disregard any or all of these options, or even opt not to create a window.

Instance Properties

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/WindowConfiguration

func NewWKWebExtensionWindowConfiguration

func NewWKWebExtensionWindowConfiguration() WKWebExtensionWindowConfiguration

NewWKWebExtensionWindowConfiguration creates a new WKWebExtensionWindowConfiguration instance.

func WKWebExtensionWindowConfigurationFromID

func WKWebExtensionWindowConfigurationFromID(id objc.ID) WKWebExtensionWindowConfiguration

WKWebExtensionWindowConfigurationFromID constructs a WKWebExtensionWindowConfiguration from an objc.ID.

An object that encapsulates configuration options for a window in an extension.

func (WKWebExtensionWindowConfiguration) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKWebExtensionWindowConfiguration) Frame

Indicates the frame where the window should be positioned on the main screen.

Discussion

This frame should override the app’s default window position and size.

Individual components (e.g., `origin.X()`, `size.Width()`) will be [NaN] if not specified.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/WindowConfiguration/frame

func (WKWebExtensionWindowConfiguration) Init

Init initializes the instance.

func (WKWebExtensionWindowConfiguration) ShouldBeFocused

func (w WKWebExtensionWindowConfiguration) ShouldBeFocused() bool

Indicates whether the window should be focused.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/WindowConfiguration/shouldBeFocused

func (WKWebExtensionWindowConfiguration) ShouldBePrivate

func (w WKWebExtensionWindowConfiguration) ShouldBePrivate() bool

Indicates whether the window should be private.

Discussion

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/WindowConfiguration/shouldBePrivate

func (WKWebExtensionWindowConfiguration) TabURLs

Indicates the URLs that the window should initially load as tabs.

Discussion

If [TabURLs] and [Tabs] are both empty, the app’s default start page should appear in a tab.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/WindowConfiguration/tabURLs

func (WKWebExtensionWindowConfiguration) Tabs

Indicates the existing tabs that should be moved to the window.

Discussion

If [Tabs] and [TabURLs] are both empty, the app’s default start page should appear in a tab.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/WindowConfiguration/tabs

func (WKWebExtensionWindowConfiguration) WindowState

Indicates the window state for the window.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/WindowConfiguration/windowState

func (WKWebExtensionWindowConfiguration) WindowType

Indicates the window type for the window.

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/WindowConfiguration/windowType

type WKWebExtensionWindowConfigurationClass

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

func GetWKWebExtensionWindowConfigurationClass

func GetWKWebExtensionWindowConfigurationClass() WKWebExtensionWindowConfigurationClass

GetWKWebExtensionWindowConfigurationClass returns the class object for WKWebExtensionWindowConfiguration.

func (WKWebExtensionWindowConfigurationClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebExtensionWindowConfigurationClass) Class

Class returns the underlying Objective-C class pointer.

type WKWebExtensionWindowErrorHandler

type WKWebExtensionWindowErrorHandler = func(WKWebExtensionWindow, error)

WKWebExtensionWindowErrorHandler handles A block to be called with the newly created window or `nil` if the window wasn’t created. The error can be type-asserted to *foundation.NSError for Domain, Code, and UserInfo.

Used by:

  • [WKWebExtensionControllerDelegate.WebExtensionControllerOpenNewWindowUsingConfigurationForExtensionContextCompletionHandler]

type WKWebExtensionWindowObject

type WKWebExtensionWindowObject struct {
	objectivec.Object
}

WKWebExtensionWindowObject wraps an existing Objective-C object that conforms to the WKWebExtensionWindow protocol.

func WKWebExtensionWindowObjectFromID

func WKWebExtensionWindowObjectFromID(id objc.ID) WKWebExtensionWindowObject

WKWebExtensionWindowObjectFromID constructs a WKWebExtensionWindowObject from an objc.ID. The object is determined to conform to the protocol at runtime.

func (WKWebExtensionWindowObject) ActiveTabForWebExtensionContext

func (o WKWebExtensionWindowObject) ActiveTabForWebExtensionContext(context IWKWebExtensionContext) WKWebExtensionTab

Called when the active tab is needed for the window.

context: The context in which the web extension is running.

Discussion

Defaults to `nil` if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionWindow/activeTab(for:)

func (WKWebExtensionWindowObject) BaseObject

func (WKWebExtensionWindowObject) CloseForWebExtensionContextCompletionHandler

func (o WKWebExtensionWindowObject) CloseForWebExtensionContextCompletionHandler(context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to close the window.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

No action is performed if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionWindow/close(for:completionHandler:)

func (WKWebExtensionWindowObject) FocusForWebExtensionContextCompletionHandler

func (o WKWebExtensionWindowObject) FocusForWebExtensionContextCompletionHandler(context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to focus the window.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

No action is performed if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionWindow/focus(for:completionHandler:)

func (WKWebExtensionWindowObject) FrameForWebExtensionContext

func (o WKWebExtensionWindowObject) FrameForWebExtensionContext(context IWKWebExtensionContext) corefoundation.CGRect

Called when the frame of the window is needed.

context: The context in which the web extension is running.

Discussion

Defaults to CGRectNull if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionWindow/frame(for:)

func (WKWebExtensionWindowObject) IsPrivateForWebExtensionContext

func (o WKWebExtensionWindowObject) IsPrivateForWebExtensionContext(context IWKWebExtensionContext) bool

Called when the private state of the window is needed.

context: The context in which the web extension is running.

Discussion

Defaults to [NO] if not implemented. This value is cached and will not change for the duration of the window or its contained tabs.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionWindow/isPrivate(for:)

func (WKWebExtensionWindowObject) ScreenFrameForWebExtensionContext

func (o WKWebExtensionWindowObject) ScreenFrameForWebExtensionContext(context IWKWebExtensionContext) corefoundation.CGRect

Called when the screen frame containing the window is needed.

context: The context associated with the running web extension.

Discussion

Defaults to CGRectNull if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionWindow/screenFrame(for:)

func (WKWebExtensionWindowObject) SetFrameForWebExtensionContextCompletionHandler

func (o WKWebExtensionWindowObject) SetFrameForWebExtensionContextCompletionHandler(frame corefoundation.CGRect, context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to set the frame of the window.

frame: The new frame of the window, in screen coordinates.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

On macOS, the implementation of both [FrameForWebExtensionContext] and [ScreenFrameForWebExtensionContext] are prerequisites. On iOS, iPadOS, and visionOS, only [FrameForWebExtensionContext] is a prerequisite. Without the respective method(s), this method will not be called.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionWindow/setFrame(_:for:completionHandler:)

func (WKWebExtensionWindowObject) SetWindowStateForWebExtensionContextCompletionHandler

func (o WKWebExtensionWindowObject) SetWindowStateForWebExtensionContextCompletionHandler(state WKWebExtensionWindowState, context IWKWebExtensionContext, completionHandler ErrorHandler)

Called to set the state of the window.

state: The new state of the window.

context: The context in which the web extension is running.

completionHandler: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

Discussion

The implementation of [WindowStateForWebExtensionContext] is a prerequisite.

Without it, this method will not be called.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionWindow/setWindowState(_:for:completionHandler:)

func (WKWebExtensionWindowObject) TabsForWebExtensionContext

func (o WKWebExtensionWindowObject) TabsForWebExtensionContext(context IWKWebExtensionContext) []objectivec.IObject

Called when the tabs are needed for the window.

context: The context in which the web extension is running.

Discussion

Defaults to an empty array if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionWindow/tabs(for:)

func (WKWebExtensionWindowObject) WindowStateForWebExtensionContext

func (o WKWebExtensionWindowObject) WindowStateForWebExtensionContext(context IWKWebExtensionContext) WKWebExtensionWindowState

Called when the state of the window is needed.

context: The context in which the web extension is running.

Discussion

Defaults to[WKWebExtensionWindowStateNormal] if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionWindow/windowState(for:)

func (WKWebExtensionWindowObject) WindowTypeForWebExtensionContext

func (o WKWebExtensionWindowObject) WindowTypeForWebExtensionContext(context IWKWebExtensionContext) WKWebExtensionWindowType

Called when the type of the window is needed.

context: The context in which the web extension is running.

Discussion

Defaults to[WKWebExtensionWindowTypeNormal] if not implemented.

See: https://developer.apple.com/documentation/WebKit/WKWebExtensionWindow/windowType(for:)

type WKWebExtensionWindowState

type WKWebExtensionWindowState int

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/WindowState

const (
	// WKWebExtensionWindowStateFullscreen: Indicates a window is in full-screen mode.
	WKWebExtensionWindowStateFullscreen WKWebExtensionWindowState = 3
	// WKWebExtensionWindowStateMaximized: Indicates a window is maximized.
	WKWebExtensionWindowStateMaximized WKWebExtensionWindowState = 2
	// WKWebExtensionWindowStateMinimized: Indicates a window is minimized.
	WKWebExtensionWindowStateMinimized WKWebExtensionWindowState = 1
	// WKWebExtensionWindowStateNormal: Indicates a window is in its normal state.
	WKWebExtensionWindowStateNormal WKWebExtensionWindowState = 0
)

func (WKWebExtensionWindowState) String

func (e WKWebExtensionWindowState) String() string

type WKWebExtensionWindowType

type WKWebExtensionWindowType int

See: https://developer.apple.com/documentation/WebKit/WKWebExtension/WindowType

const (
	// WKWebExtensionWindowTypeNormal: Indicates a normal window.
	WKWebExtensionWindowTypeNormal WKWebExtensionWindowType = 0
	// WKWebExtensionWindowTypePopup: Indicates a pop-up window.
	WKWebExtensionWindowTypePopup WKWebExtensionWindowType = 1
)

func (WKWebExtensionWindowType) String

func (e WKWebExtensionWindowType) String() string

type WKWebView

type WKWebView struct {
	appkit.NSView
}

An object that displays interactive web content, such as for an in-app browser.

Overview

A WKWebView object is a platform-native view that you use to incorporate web content seamlessly into your app’s UI. A web view supports a full web-browsing experience, and presents HTML, CSS, and JavaScript content alongside your app’s native views. Use it when web technologies satisfy your app’s layout and styling requirements more readily than native views. For example, you might use it when your app’s content changes frequently.

A web view offers control over the navigation and user experience through delegate objects. Use the navigation delegate to react when the user clicks links in your web content, or interacts with the content in a way that affects navigation. For example, you might prevent the user from navigating to new content unless specific conditions are met. Use the UI delegate to present native UI elements, such as alerts or contextual menus, in response to interactions with your web content.

Embed a WKWebView object programmatically into your view hierarchy, or add it using Interface Builder. Interface Builder supports many customizations, such as configuring data detectors, media playback, and interaction behaviors. For more extensive customizations, create your web view programmatically using a WKWebViewConfiguration object. For example, use a web view configuration object to specify handlers for custom URL schemes, manage cookies, and customize preferences for your web content.

Before your web view appears onscreen, load content from a web server using a URLRequest structure or load content directly from a local file or HTML string. The web view automatically loads embedded resources such as images or videos as part of the initial load request. It then renders your content and displays the results inside the view’s bounds rectangle. The following code example shows a view controller that replaces its default view with a custom WKWebView object.

A web view automatically converts telephone numbers that appear in web content to Phone links. When the user taps a Phone link, the Phone app launches and dials the number. Use the WKWebViewConfiguration object to change the default data detector behavior.

You can also use WKWebView.SetMagnificationCenteredAtPoint to programmatically set the scale of web content the first time it appears in a web view. Thereafter, the user can change the scale using gestures.

Manage the navigation through your web content

WKWebView provides a complete browsing experience, including the ability to navigate between different webpages using links, forward and back buttons, and more. When the user clicks a link in your content, the web view acts like a browser and displays the content at that link. To disallow navigation, or to customize your web view’s navigation behavior, provide your web view with a navigation delegate — an object that conforms to the WKNavigationDelegate protocol. Use your navigation delegate to modify the web view’s navigation behavior, or to track the loading progress of new content.

You can also use the methods of WKWebView to navigate programmatically through your content, or to trigger navigation from other parts of your app’s interface. For example, if your UI includes forward and back buttons, connect those buttons to the WKWebView.GoBack and WKWebView.GoForward methods of your web view to trigger the corresponding web navigation. Use the WKWebView.CanGoBack and WKWebView.CanGoForward properties to determine when to enable or disable your buttons.

Provide sharing options

People may want to share the contents of your web view with an app or other people. Use a UIActivityViewController to present a share sheet offering all the ways people can share the web content.

If your app has the com.apple.developer.web-browser entitlement, the iOS share sheet can offer Add to Home Screen for an `http` or `https` webpage, creating a convenient link to a web app or bookmark. To allow someone to add the current webpage to the Home Screen, include the WKWebView instance in the `activityItems` array when you call init(activityItems:applicationActivities:) to create the UIActivityViewController. For more information about building a browser app, see Preparing your app to be the default web browser.

Creating a web view

Displaying native user interface elements

Managing navigation between webpages

Loading web content

Managing the loading process

Managing downloads

Making web content inspectable

Inspecting the view information

Scaling content

Interacting with media

Managing the microphone and camera

Navigating between webpages

Executing JavaScript

Capturing the web view’s content

Handling full-screen transitions

Configuring viewport insets

Instance Properties

Instance Methods

See: https://developer.apple.com/documentation/WebKit/WKWebView

func NewWKWebView

func NewWKWebView() WKWebView

NewWKWebView creates a new WKWebView instance.

func NewWebViewWithCoder

func NewWebViewWithCoder(coder foundation.INSCoder) WKWebView

Returns an object initialized from data in the specified coder object.

coder: The coder object that contains the object’s data.

See: https://developer.apple.com/documentation/WebKit/WKWebView/init(coder:)

func NewWebViewWithFrameConfiguration

func NewWebViewWithFrameConfiguration(frame corefoundation.CGRect, configuration IWKWebViewConfiguration) WKWebView

Creates a web view and initializes it with the specified frame and configuration data.

frame: The frame rectangle for the new web view.

configuration: The configuration of the new web view. This method saves a copy of your configuration object. Changes you make to your original object after calling this method have no effect on the web view’s configuration. For a list of configuration options and their default values, see WKWebViewConfiguration.

Return Value

An initialized web view, or `nil` if the view couldn’t be initialized.

Discussion

This method is the designated initializer for the class. Use this method to create a web view that requires custom configuration. For example, use it when you need to specify custom cookies or content filters for the web content.

To create a web view with default configuration values, call the inherited init(frame:) method.

See: https://developer.apple.com/documentation/WebKit/WKWebView/init(frame:configuration:)

func WKWebViewFromID

func WKWebViewFromID(id objc.ID) WKWebView

WKWebViewFromID constructs a WKWebView from an objc.ID.

An object that displays interactive web content, such as for an in-app browser.

func (WKWebView) AllowsBackForwardNavigationGestures

func (w WKWebView) AllowsBackForwardNavigationGestures() bool

A Boolean value that indicates whether horizontal swipe gestures trigger backward and forward page navigation.

Discussion

The default value is false.

See: https://developer.apple.com/documentation/WebKit/WKWebView/allowsBackForwardNavigationGestures

func (WKWebView) AllowsLinkPreview

func (w WKWebView) AllowsLinkPreview() bool

A Boolean value that determines whether pressing a link displays a preview of the destination for the link.

Discussion

In iOS, this property is available on devices that support 3D Touch. In iOS 10 and later, the default value is true; in previous versions of iOS, the default value is false.

If you set this property’s value to true, an iOS user can press links to preview link destinations and detected data such as addresses and phone numbers. Such previews are known to users as . If a user presses deeper on a link preview, the preview navigates (or , in user terminology) to the destination. Because pop navigation switches the user from your app to Safari, it is opt-in for iOS apps.

If you want to support link preview in iOS but also want to keep users within your app, you can switch from using the WKWebView class to the SFSafariViewController class. If you are using a web view as an in-app browser, making this change is best practice. The Safari view controller class automatically supports link previews.

In macOS, this property is available on devices with a Force Touch trackpad. The default value is true.

With this property set to its default value of true, a macOS user can force click a link to display a preview window showing the link’s destination. If the user then clicks the preview, the destination opens in Safari.

On both platforms, all types of detected data respond to presses when this property is set to true. That is, in iOS 9 and OS X 10.11, you cannot specify which types of data are detected in the WKWebView class.

See: https://developer.apple.com/documentation/WebKit/WKWebView/allowsLinkPreview

func (WKWebView) AllowsMagnification

func (w WKWebView) AllowsMagnification() bool

A Boolean value that indicates whether magnify gestures change the web view’s magnification.

Discussion

The default value is false. You can set the `magnification` property even if `allowsMagnification` is set to false.

See: https://developer.apple.com/documentation/WebKit/WKWebView/allowsMagnification

func (WKWebView) Autorelease

func (w WKWebView) Autorelease() WKWebView

Autorelease adds the receiver to the current autorelease pool.

func (WKWebView) BackForwardList

func (w WKWebView) BackForwardList() IWKBackForwardList

The web view’s back-forward list.

See: https://developer.apple.com/documentation/WebKit/WKWebView/backForwardList

func (WKWebView) CameraCaptureState

func (w WKWebView) CameraCaptureState() WKMediaCaptureState

An enumeration case that indicates whether the webpage is using the camera to capture images or video.

See: https://developer.apple.com/documentation/WebKit/WKWebView/cameraCaptureState

func (WKWebView) CanGoBack

func (w WKWebView) CanGoBack() bool

A Boolean value that indicates whether there is a valid back item in the back-forward list.

See: https://developer.apple.com/documentation/WebKit/WKWebView/canGoBack

func (WKWebView) CanGoForward

func (w WKWebView) CanGoForward() bool

A Boolean value that indicates whether there is a valid forward item in the back-forward list.

See: https://developer.apple.com/documentation/WebKit/WKWebView/canGoForward

func (WKWebView) CloseAllMediaPresentations

func (w WKWebView) CloseAllMediaPresentations(ctx context.Context) error

CloseAllMediaPresentations is a synchronous wrapper around WKWebView.CloseAllMediaPresentationsWithCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebView) CloseAllMediaPresentationsWithCompletionHandler

func (w WKWebView) CloseAllMediaPresentationsWithCompletionHandler(completionHandler VoidHandler)

Closes all media the web view is presenting, including picture-in-picture video and fullscreen video.

completionHandler: A closure the system executes after it completes closing all media presentations.

See: https://developer.apple.com/documentation/WebKit/WKWebView/closeAllMediaPresentations(completionHandler:)

func (WKWebView) Configuration

func (w WKWebView) Configuration() IWKWebViewConfiguration

The object that contains the configuration details for the web view.

Discussion

Use the object in this property to obtain information about your web view’s configuration. Because this property returns a copy of the configuration object, changes you make to that object don’t affect the web view’s configuration.

If you didn’t create your web view using the [InitWithFrameConfiguration] method, this property contains a default configuration object.

See: https://developer.apple.com/documentation/WebKit/WKWebView/configuration

func (WKWebView) CreatePDFWithConfiguration

func (w WKWebView) CreatePDFWithConfiguration(ctx context.Context, pdfConfiguration IWKPDFConfiguration) (*foundation.NSData, error)

CreatePDFWithConfiguration is a synchronous wrapper around WKWebView.CreatePDFWithConfigurationCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebView) CreatePDFWithConfigurationCompletionHandler

func (w WKWebView) CreatePDFWithConfigurationCompletionHandler(pdfConfiguration IWKPDFConfiguration, completionHandler DataErrorHandler)

Generates PDF data from the web view’s contents asynchronously.

pdfConfiguration: The object that specifies the portion of the web view to capture as PDF data.

completionHandler: The completion handler to call when the data is ready. This block has no return value and takes the following parameters:

pdfDocumentData: A data object that contains the PDF data to use for rendering the contents of the web view. error: An error object if a problem occurred, or `nil` on success.

See: https://developer.apple.com/documentation/WebKit/WKWebView/createPDFWithConfiguration:completionHandler:

func (WKWebView) CreateWebArchiveData

func (w WKWebView) CreateWebArchiveData(ctx context.Context) (*foundation.NSData, error)

CreateWebArchiveData is a synchronous wrapper around WKWebView.CreateWebArchiveDataWithCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebView) CreateWebArchiveDataWithCompletionHandler

func (w WKWebView) CreateWebArchiveDataWithCompletionHandler(completionHandler DataErrorHandler)

Creates a web archive of the web view’s contents asynchronously.

completionHandler: The completion handler block to call when the web archive data is ready. This block has no return value and takes the following parameters:

data: A data object that contains the web archive. error: An error object if an error occurs, or `nil` on success.

See: https://developer.apple.com/documentation/WebKit/WKWebView/createWebArchiveDataWithCompletionHandler:

func (WKWebView) CustomUserAgent

func (w WKWebView) CustomUserAgent() string

The custom user agent string.

Discussion

Use this property to specify a custom user agent string for your web view. The default value of this property is `nil`.

See: https://developer.apple.com/documentation/WebKit/WKWebView/customUserAgent

func (WKWebView) EstimatedProgress

func (w WKWebView) EstimatedProgress() float64

An estimate of what fraction of the current navigation has been loaded.

Discussion

This value ranges from `0.0` to `1.0` based on the total number of bytes received, including the main document and all of its potential subresources. After navigation loading completes, the `estimatedProgress` value remains at `1.0` until a new navigation starts, at which point the `estimatedProgress` value resets to `0.0`. The WKWebView class is key-value observing (KVO) compliant for this property.

See: https://developer.apple.com/documentation/WebKit/WKWebView/estimatedProgress

func (WKWebView) EvaluateJavaScript

func (w WKWebView) EvaluateJavaScript(ctx context.Context, javaScriptString string) (objectivec.IObject, error)

EvaluateJavaScript is a synchronous wrapper around WKWebView.EvaluateJavaScriptCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebView) EvaluateJavaScriptCompletionHandler

func (w WKWebView) EvaluateJavaScriptCompletionHandler(javaScriptString string, completionHandler ObjectErrorHandler)

Evaluates the specified JavaScript string.

javaScriptString: The JavaScript string to evaluate.

completionHandler: A handler block to execute when script evaluation finishes. The method calls your block whether script evaluation completes successfully or fails. The block has no return value and takes the following parameters:

object: The result of the script evaluation, or `nil` if an error occurred. error: `nil` on success, or an error object with information about the problem.

Discussion

After evaluating the script, this method executes the completion handler block with either the result of the script evaluation or an error. The completion handler always runs on the app’s main thread.

See: https://developer.apple.com/documentation/WebKit/WKWebView/evaluateJavaScript(_:completionHandler:)

func (WKWebView) FetchDataOfTypes

func (w WKWebView) FetchDataOfTypes(ctx context.Context, dataTypes WKWebViewDataType) (*foundation.NSData, error)

FetchDataOfTypes is a synchronous wrapper around WKWebView.FetchDataOfTypesCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebView) FindStringWithConfiguration

func (w WKWebView) FindStringWithConfiguration(ctx context.Context, string_ string, configuration IWKFindConfiguration) (*WKFindResult, error)

FindStringWithConfiguration is a synchronous wrapper around WKWebView.FindStringWithConfigurationCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebView) FindStringWithConfigurationCompletionHandler

func (w WKWebView) FindStringWithConfigurationCompletionHandler(string_ string, configuration IWKFindConfiguration, completionHandler WKFindResultHandler)

Searches for the specified string in the web view’s content.

string: The search string to use.

configuration: The search parameters. Use this object to specify whether the search is case-sensitive, moves forward or backward, and wraps when it reaches the end of the page.

completionHandler: The completion handler to call with the results of the search. This handler has no return value and takes the following parameter:

result: The object that contains the results of the search.

See: https://developer.apple.com/documentation/WebKit/WKWebView/findString:withConfiguration:completionHandler:

func (WKWebView) GoBack

func (w WKWebView) GoBack() IWKNavigation

Navigates to the back item in the back-forward list.

Return Value

A new navigation to the requested item, or `nil` if there is no back item in the back-forward list.

See: https://developer.apple.com/documentation/WebKit/WKWebView/goBack()

func (WKWebView) GoBackWithSender

func (w WKWebView) GoBackWithSender(sender objectivec.IObject)

Navigates to the back item in the back-forward list.

sender: The object sending this message.

See: https://developer.apple.com/documentation/WebKit/WKWebView/goBack(_:)

func (WKWebView) GoForward

func (w WKWebView) GoForward() IWKNavigation

Navigates to the forward item in the back-forward list.

Return Value

A new navigation to the requested item, or `nil` if there is no forward item in the back-forward list.

See: https://developer.apple.com/documentation/WebKit/WKWebView/goForward()

func (WKWebView) GoForwardWithSender

func (w WKWebView) GoForwardWithSender(sender objectivec.IObject)

Navigates to the forward item in the back-forward list.

sender: The object sending this message.

See: https://developer.apple.com/documentation/WebKit/WKWebView/goForward(_:)

func (WKWebView) GoToBackForwardListItem

func (w WKWebView) GoToBackForwardListItem(item IWKBackForwardListItem) IWKNavigation

Navigates to an item from the back-forward list and sets it as the current item.

item: The item to navigate to. The item must be in the web view’s back-forward list.

Return Value

A new navigation to the requested item, or `nil` if it is already the current item or is not part of the web view’s back-forward list.

See: https://developer.apple.com/documentation/WebKit/WKWebView/go(to:)

func (WKWebView) HasOnlySecureContent

func (w WKWebView) HasOnlySecureContent() bool

A Boolean value that indicates whether the web view loaded all resources on the page through securely encrypted connections.

Discussion

WKWebView is key-value observing (KVO) compliant for this property.

See: https://developer.apple.com/documentation/WebKit/WKWebView/hasOnlySecureContent

func (WKWebView) Init

func (w WKWebView) Init() WKWebView

Init initializes the instance.

func (WKWebView) InitWithFrameConfiguration

func (w WKWebView) InitWithFrameConfiguration(frame corefoundation.CGRect, configuration IWKWebViewConfiguration) WKWebView

Creates a web view and initializes it with the specified frame and configuration data.

frame: The frame rectangle for the new web view.

configuration: The configuration of the new web view. This method saves a copy of your configuration object. Changes you make to your original object after calling this method have no effect on the web view’s configuration. For a list of configuration options and their default values, see WKWebViewConfiguration.

Return Value

An initialized web view, or `nil` if the view couldn’t be initialized.

Discussion

This method is the designated initializer for the class. Use this method to create a web view that requires custom configuration. For example, use it when you need to specify custom cookies or content filters for the web content.

To create a web view with default configuration values, call the inherited init(frame:) method.

See: https://developer.apple.com/documentation/WebKit/WKWebView/init(frame:configuration:)

func (WKWebView) Inspectable

func (w WKWebView) Inspectable() bool

A Boolean value that indicates whether you can inspect the view with Safari Web Inspector.

Discussion

Defaults to `false`.

Set to `true` at any point in the view’s lifetime to allow Safari Web Inspector access to inspect the view’s content. Then, select your view in Safari’s Develop menu for either your computer or an attached device to inspect it.

If you set this value to `false` during inspection, the system immediately closes Safari Web Inspector and does not provide any further information about the web content.

For more information, see Enabling the Inspection of Web Content in Apps.

See: https://developer.apple.com/documentation/WebKit/WKWebView/isInspectable

func (WKWebView) InteractionState

func (w WKWebView) InteractionState() objectivec.IObject

An object you use to capture the current state of interaction in a web view so that you can restore that state later to another web view.

See: https://developer.apple.com/documentation/WebKit/WKWebView/interactionState

func (WKWebView) IsBlockedByScreenTime

func (w WKWebView) IsBlockedByScreenTime() bool

Discussion

A Boolean value indicating whether Screen Time blocking has occurred.

See: https://developer.apple.com/documentation/WebKit/WKWebView/isBlockedByScreenTime

func (WKWebView) LoadDataMIMETypeCharacterEncodingNameBaseURL

func (w WKWebView) LoadDataMIMETypeCharacterEncodingNameBaseURL(data foundation.INSData, MIMEType string, characterEncodingName string, baseURL foundation.INSURL) IWKNavigation

Loads the content of the specified data object and navigates to it.

data: The data to use as the contents of the webpage.

MIMEType: The MIME type of the information in the `data` parameter. This parameter must not contain an empty string.

characterEncodingName: The data’s character encoding name.

baseURL: A URL that you use to resolve relative URLs within the document.

Return Value

A new navigation object for tracking the request.

Discussion

Use this method to navigate to a webpage that you loaded yourself and saved in a data object. For example, if you previously wrote HTML content to a data object, use this method to navigate to that content.

See: https://developer.apple.com/documentation/WebKit/WKWebView/load(_:mimeType:characterEncodingName:baseURL:)

func (WKWebView) LoadFileRequestAllowingReadAccessToURL

func (w WKWebView) LoadFileRequestAllowingReadAccessToURL(request foundation.NSURLRequest, readAccessURL foundation.INSURL) IWKNavigation

Loads the web content from the file the URL request object specifies and navigates to that content.

request: A URL request that specifies the file to display. The URL in this request must be a file-based URL.

readAccessURL: The URL of a file or directory containing web content that you grant the system permission to read. This URL must be a file-based URL and must not be empty. To prevent WebKit from reading any other content, specify the same value as the URL parameter. To read additional files related to the content file, specify a directory.

Return Value

A new navigation object you use to track the loading progress of the request.

Discussion

Provide the source of this load request for app activity data by setting the attribution parameter on your request.

See: https://developer.apple.com/documentation/WebKit/WKWebView/loadFileRequest(_:allowingReadAccessTo:)

func (WKWebView) LoadFileURLAllowingReadAccessToURL

func (w WKWebView) LoadFileURLAllowingReadAccessToURL(URL foundation.INSURL, readAccessURL foundation.INSURL) IWKNavigation

Loads the web content from the specified file and navigates to it.

URL: The URL of a file that contains web content. This URL must be a file-based URL.

readAccessURL: The URL of a file or directory containing web content that you grant the system permission to read. This URL must be a file-based URL and must not be empty. To prevent WebKit from reading any other content, specify the same value as the URL parameter. To read additional files related to the content file, specify a directory.

Return Value

A new navigation object you use to track the loading progress of the request.

Discussion

This method sets the source of this load request for app activity data to NSURLRequest.Attribution.developer. To specify the source of this load, use [LoadFileRequestAllowingReadAccessToURL] instead.

See: https://developer.apple.com/documentation/WebKit/WKWebView/loadFileURL(_:allowingReadAccessTo:)

func (WKWebView) LoadHTMLStringBaseURL

func (w WKWebView) LoadHTMLStringBaseURL(string_ string, baseURL foundation.INSURL) IWKNavigation

Loads the contents of the specified HTML string and navigates to it.

string: The string to use as the contents of the webpage.

baseURL: The base URL to use when the system resolves relative URLs within the HTML string.

Return Value

A new navigation object you use to track the loading progress of the request.

Discussion

Use this method to navigate to a webpage that you loaded or created yourself. For example, you might use this method to load HTML content that your app generates programmatically.

This method sets the source of this load request for app activity data to NSURLRequest.Attribution.developer.

See: https://developer.apple.com/documentation/WebKit/WKWebView/loadHTMLString(_:baseURL:)

func (WKWebView) LoadRequest

func (w WKWebView) LoadRequest(request foundation.NSURLRequest) IWKNavigation

Loads the web content that the specified URL request object references and navigates to that content.

request: A URL request that specifies the resource to display.

Return Value

A new navigation object that you use to track the loading progress of the request.

Discussion

Use this method to load a page from a local or network-based URL. For example, you might use this method to navigate to a network-based webpage.

Provide the source of this load request for app activity data by setting the attribution parameter on your request.

See: https://developer.apple.com/documentation/WebKit/WKWebView/load(_:)

func (WKWebView) LoadSimulatedRequestResponseHTMLString

func (w WKWebView) LoadSimulatedRequestResponseHTMLString(request foundation.NSURLRequest, string_ string) IWKNavigation

Loads the web content from the HTML you provide as if the HTML were the response to the request.

request: A URL request that specifies the base URL and other loading details the system uses to interpret the HTML you provide.

string: The HTML code you provide in a string to use as the contents of the webpage.

Return Value

A new navigation object you use to track the loading progress of the request.

See: https://developer.apple.com/documentation/WebKit/WKWebView/loadSimulatedRequest(_:responseHTML:)

func (WKWebView) LoadSimulatedRequestResponseResponseData

func (w WKWebView) LoadSimulatedRequestResponseResponseData(request foundation.NSURLRequest, response foundation.NSURLResponse, data foundation.INSData) IWKNavigation

Loads the web content from the data you provide as if the data were the response to the request.

request: A URL request that specifies the base URL and other loading details the system uses to interpret the data you provide.

response: A response the system uses to interpret the data you provide.

data: The data to use as the contents of the webpage.

Return Value

A new navigation object you use to track the loading progress of the request.

See: https://developer.apple.com/documentation/WebKit/WKWebView/loadSimulatedRequest(_:response:responseData:)

func (WKWebView) Loading

func (w WKWebView) Loading() bool

A Boolean value that indicates whether the view is currently loading content.

Discussion

Set to `true` if the receiver is still loading content; otherwise, `false.` The WKWebView class is key-value observing (KVO) compliant for this property.

See: https://developer.apple.com/documentation/WebKit/WKWebView/isLoading

func (WKWebView) Magnification

func (w WKWebView) Magnification() float64

The factor by which the page content is currently scaled.

Discussion

The default value is `1.0`.

See: https://developer.apple.com/documentation/WebKit/WKWebView/magnification

func (WKWebView) MediaType

func (w WKWebView) MediaType() string

The media type for the contents of the web view.

Discussion

When the value of this property is `nil`, the web view derives the current media type from the CSS media property of its content. If you assign a value other than `nil` to this property, the web view uses the value you provide instead. The default value of this property is `nil`.

See: https://developer.apple.com/documentation/WebKit/WKWebView/mediaType

func (WKWebView) MicrophoneCaptureState

func (w WKWebView) MicrophoneCaptureState() WKMediaCaptureState

An enumeration case that indicates whether the webpage is using the microphone to capture audio.

See: https://developer.apple.com/documentation/WebKit/WKWebView/microphoneCaptureState

func (WKWebView) NavigationDelegate

func (w WKWebView) NavigationDelegate() WKNavigationDelegate

The object you use to manage navigation behavior for the web view.

Discussion

Provide a delegate object when you want to manage or restrict navigation in your web content, track the progress of navigation requests, and handle authentication challenges for any new content. The object you specify must conform to the WKNavigationDelegate protocol.

See: https://developer.apple.com/documentation/WebKit/WKWebView/navigationDelegate

func (WKWebView) PageZoom

func (w WKWebView) PageZoom() float64

The scale factor by which the web view scales content relative to its bounds.

Discussion

The default value of this property is `1.0`, which displays the content without any scaling. Changing the value of this property is equivalent to setting the CSS `zoom` property on all page content.

See: https://developer.apple.com/documentation/WebKit/WKWebView/pageZoom

func (WKWebView) PauseAllMediaPlayback

func (w WKWebView) PauseAllMediaPlayback(ctx context.Context) error

PauseAllMediaPlayback is a synchronous wrapper around WKWebView.PauseAllMediaPlaybackWithCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebView) PauseAllMediaPlaybackWithCompletionHandler

func (w WKWebView) PauseAllMediaPlaybackWithCompletionHandler(completionHandler VoidHandler)

Pauses playback of all media in the web view.

completionHandler: A closure the system executes after the web view pauses media playback.

See: https://developer.apple.com/documentation/WebKit/WKWebView/pauseAllMediaPlayback(completionHandler:)

func (WKWebView) PrintOperationWithPrintInfo

func (w WKWebView) PrintOperationWithPrintInfo(printInfo appkit.NSPrintInfo) appkit.NSPrintOperation

Returns the print operation object to use when printing the contents of the web view.

printInfo: The printer information object to use when configuring the print operation.

Return Value

The print operation object to use when printing the web view, or `nil` if printing is not supported.

See: https://developer.apple.com/documentation/WebKit/WKWebView/printOperation(with:)

func (WKWebView) Reload

func (w WKWebView) Reload() IWKNavigation

Reloads the current webpage.

Return Value

A new navigation object to represent the reload operation.

See: https://developer.apple.com/documentation/WebKit/WKWebView/reload()

func (WKWebView) ReloadFromOrigin

func (w WKWebView) ReloadFromOrigin() IWKNavigation

Reloads the current webpage, and performs end-to-end revalidation of the content using cache-validating conditionals, if possible.

Return Value

A new navigation that represents the reloaded webpage.

See: https://developer.apple.com/documentation/WebKit/WKWebView/reloadFromOrigin()

func (WKWebView) ReloadFromOriginWithSender

func (w WKWebView) ReloadFromOriginWithSender(sender objectivec.IObject)

Reloads the current webpage, and performs end-to-end revalidation of the content using cache-validating conditionals, if possible.

sender: The object that sent the message.

Discussion

Make this method the action of any controls that trigger a reload of your web content. Connect your controls to this method programmatically or in Interface Builder.

See: https://developer.apple.com/documentation/WebKit/WKWebView/reloadFromOrigin(_:)

func (WKWebView) ReloadWithSender

func (w WKWebView) ReloadWithSender(sender objectivec.IObject)

Reloads the current webpage.

sender: The object that sent the message.

Discussion

Make this method the action of any controls that trigger a reload of your web content. Connect your controls to this method programmatically or in Interface Builder.

See: https://developer.apple.com/documentation/WebKit/WKWebView/reload(_:)

func (WKWebView) RequestMediaPlaybackState

func (w WKWebView) RequestMediaPlaybackState(ctx context.Context) (int, error)

RequestMediaPlaybackState is a synchronous wrapper around WKWebView.RequestMediaPlaybackStateWithCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebView) RequestMediaPlaybackStateWithCompletionHandler

func (w WKWebView) RequestMediaPlaybackStateWithCompletionHandler(completionHandler WKMediaPlaybackStateHandler)

Requests the playback status of media in the web view.

completionHandler: A closure the system executes after the web view determines the current state of media playback.

See: https://developer.apple.com/documentation/WebKit/WKWebView/requestMediaPlaybackState(completionHandler:)

func (WKWebView) RestoreData

func (w WKWebView) RestoreData(ctx context.Context, data foundation.INSData) error

RestoreData is a synchronous wrapper around WKWebView.RestoreDataCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebView) ResumeDownloadFromResumeData

func (w WKWebView) ResumeDownloadFromResumeData(ctx context.Context, resumeData foundation.INSData) (*WKDownload, error)

ResumeDownloadFromResumeData is a synchronous wrapper around WKWebView.ResumeDownloadFromResumeDataCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebView) ResumeDownloadFromResumeDataCompletionHandler

func (w WKWebView) ResumeDownloadFromResumeDataCompletionHandler(resumeData foundation.INSData, completionHandler WKDownloadHandler)

Resumes a failed or canceled download.

resumeData: An object with data that you use to resume a failed or canceled download.

completionHandler: A closure the system executes when it has resumed a download.

Discussion

To receive progress updates, set the delegate of the download object in the completion handler.

See: https://developer.apple.com/documentation/WebKit/WKWebView/resumeDownload(fromResumeData:completionHandler:)

func (WKWebView) ServerTrust

func (w WKWebView) ServerTrust() security.SecTrustRef

The trust management object you use to evaluate trust for the current webpage.

Discussion

Use the object in this property to validate the webpage’s certificate and associated credentials. WKWebView is key-value observing (KVO) compliant for this property.

See: https://developer.apple.com/documentation/WebKit/WKWebView/serverTrust

func (WKWebView) SetAllMediaPlaybackSuspended

func (w WKWebView) SetAllMediaPlaybackSuspended(ctx context.Context, suspended bool) error

SetAllMediaPlaybackSuspended is a synchronous wrapper around WKWebView.SetAllMediaPlaybackSuspendedCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebView) SetAllMediaPlaybackSuspendedCompletionHandler

func (w WKWebView) SetAllMediaPlaybackSuspendedCompletionHandler(suspended bool, completionHandler VoidHandler)

Changes whether the webpage is suspending playback of all media in the page.

suspended: A Boolean value that indicates whether the webpage should suspend media playback.

completionHandler: A closure the system executes after it completes changing the media playback suspension status.

Discussion

Pass `true` to pause all media the web view is playing. Neither the user nor the webpage can resume playback until you call this method again with `false`.

See: https://developer.apple.com/documentation/WebKit/WKWebView/setAllMediaPlaybackSuspended(_:completionHandler:)

func (WKWebView) SetAllowsBackForwardNavigationGestures

func (w WKWebView) SetAllowsBackForwardNavigationGestures(value bool)

func (WKWebView) SetAllowsLinkPreview

func (w WKWebView) SetAllowsLinkPreview(value bool)

func (WKWebView) SetAllowsMagnification

func (w WKWebView) SetAllowsMagnification(value bool)

func (WKWebView) SetCameraCaptureState

func (w WKWebView) SetCameraCaptureState(ctx context.Context, state WKMediaCaptureState) error

SetCameraCaptureState is a synchronous wrapper around WKWebView.SetCameraCaptureStateCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebView) SetCameraCaptureStateCompletionHandler

func (w WKWebView) SetCameraCaptureStateCompletionHandler(state WKMediaCaptureState, completionHandler VoidHandler)

Changes whether the webpage is using the camera to capture images or video.

state: An enumeration case that indicates whether the webpage should use the camera to capture images or video.

completionHandler: A closure the system executes after changing whether the webpage is using the camera to capture images or video.

See: https://developer.apple.com/documentation/WebKit/WKWebView/setCameraCaptureState(_:completionHandler:)

func (WKWebView) SetCustomUserAgent

func (w WKWebView) SetCustomUserAgent(value string)

func (WKWebView) SetInspectable

func (w WKWebView) SetInspectable(value bool)

func (WKWebView) SetInteractionState

func (w WKWebView) SetInteractionState(value objectivec.IObject)

func (WKWebView) SetMagnification

func (w WKWebView) SetMagnification(value float64)

func (WKWebView) SetMagnificationCenteredAtPoint

func (w WKWebView) SetMagnificationCenteredAtPoint(magnification float64, point corefoundation.CGPoint)

Scales the page content and centers the result on the specified point.

magnification: The factor by which to scale the content.

point: The point (in the web view’s bounds) at which to center magnification.

See: https://developer.apple.com/documentation/WebKit/WKWebView/setMagnification(_:centeredAt:)

func (WKWebView) SetMediaType

func (w WKWebView) SetMediaType(value string)

func (WKWebView) SetMicrophoneCaptureState

func (w WKWebView) SetMicrophoneCaptureState(ctx context.Context, state WKMediaCaptureState) error

SetMicrophoneCaptureState is a synchronous wrapper around WKWebView.SetMicrophoneCaptureStateCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebView) SetMicrophoneCaptureStateCompletionHandler

func (w WKWebView) SetMicrophoneCaptureStateCompletionHandler(state WKMediaCaptureState, completionHandler VoidHandler)

Changes whether the webpage is using the microphone to capture audio.

state: An enumeration case that indicates whether the webpage should use the microphone to capture audio.

completionHandler: A closure the system executes after changing whether the webpage is using the microphone to capture audio.

See: https://developer.apple.com/documentation/WebKit/WKWebView/setMicrophoneCaptureState(_:completionHandler:)

func (WKWebView) SetMinimumViewportInsetMaximumViewportInset

func (w WKWebView) SetMinimumViewportInsetMaximumViewportInset(minimumViewportInset objectivec.IObject, maximumViewportInset objectivec.IObject)

minimumViewportInset is a [uikit.UIEdgeInsets].

maximumViewportInset is a [uikit.UIEdgeInsets].

See: https://developer.apple.com/documentation/WebKit/WKWebView/setMinimumViewportInset(_:maximumViewportInset:) minimumViewportInset is a [uikit.UIEdgeInsets]. maximumViewportInset is a [uikit.UIEdgeInsets].

func (WKWebView) SetNavigationDelegate

func (w WKWebView) SetNavigationDelegate(value WKNavigationDelegate)

func (WKWebView) SetObscuredContentInsets

func (w WKWebView) SetObscuredContentInsets(value objectivec.IObject)

func (WKWebView) SetPageZoom

func (w WKWebView) SetPageZoom(value float64)

func (WKWebView) SetUIDelegate

func (w WKWebView) SetUIDelegate(value WKUIDelegate)

func (WKWebView) SetUnderPageBackgroundColor

func (w WKWebView) SetUnderPageBackgroundColor(value objc.ID)

func (WKWebView) StartDownloadUsingRequest

func (w WKWebView) StartDownloadUsingRequest(ctx context.Context, request foundation.NSURLRequest) (*WKDownload, error)

StartDownloadUsingRequest is a synchronous wrapper around WKWebView.StartDownloadUsingRequestCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebView) StartDownloadUsingRequestCompletionHandler

func (w WKWebView) StartDownloadUsingRequestCompletionHandler(request foundation.NSURLRequest, completionHandler WKDownloadHandler)

Starts to download the resource at the URL in the request.

request: An object that encapsulates a URL and other parameters that you need to download a resource from a webpage.

completionHandler: A closure the system executes when it has started to download the resource.

Discussion

To receive progress updates, set the delegate of the download object in the completion handler.

See: https://developer.apple.com/documentation/WebKit/WKWebView/startDownload(using:completionHandler:)

func (WKWebView) StopLoading

func (w WKWebView) StopLoading()

Stops loading all resources on the current page.

See: https://developer.apple.com/documentation/WebKit/WKWebView/stopLoading()

func (WKWebView) StopLoadingWithSender

func (w WKWebView) StopLoadingWithSender(sender objectivec.IObject)

Stops loading all resources on the current page.

sender: The object that sent the message.

Discussion

Make this method the action of any controls that stop the loading of your web content. Connect your controls to this method programmatically or in Interface Builder.

See: https://developer.apple.com/documentation/WebKit/WKWebView/stopLoading(_:)

func (WKWebView) ThemeColor

func (w WKWebView) ThemeColor() objc.ID

The theme color that the system gets from the first valid meta tag in the webpage.

See: https://developer.apple.com/documentation/WebKit/WKWebView/themeColor

func (WKWebView) Title

func (w WKWebView) Title() string

The page title.

Discussion

WKWebView is key-value observing (KVO) compliant for this property.

See: https://developer.apple.com/documentation/WebKit/WKWebView/title

func (WKWebView) UIDelegate

func (w WKWebView) UIDelegate() WKUIDelegate

The object you use to integrate custom user interface elements, such as contextual menus or panels, into web view interactions.

See: https://developer.apple.com/documentation/WebKit/WKWebView/uiDelegate

func (WKWebView) URL

func (w WKWebView) URL() foundation.INSURL

The URL for the current webpage.

Discussion

This property contains the URL for the webpage that the web view currently displays. Use this URL in places where you reflect the webpage address in your app’s user interface.

WKWebView is key-value observing (KVO) compliant for this property.

See: https://developer.apple.com/documentation/WebKit/WKWebView/url

func (WKWebView) UnderPageBackgroundColor

func (w WKWebView) UnderPageBackgroundColor() objc.ID

The color the web view displays behind the active page, visible when the user scrolls beyond the bounds of the page.

Discussion

The web view derives the default value of this property from the content of the page, using the background colors of the “ and “ elements with the background color of the web view. To override the default color, set this property to a new color.

See: https://developer.apple.com/documentation/WebKit/WKWebView/underPageBackgroundColor

type WKWebViewClass

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

func GetWKWebViewClass

func GetWKWebViewClass() WKWebViewClass

GetWKWebViewClass returns the class object for WKWebView.

func (WKWebViewClass) Alloc

func (wc WKWebViewClass) Alloc() WKWebView

Alloc allocates memory for a new instance of the class.

func (WKWebViewClass) Class

func (wc WKWebViewClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (WKWebViewClass) HandlesURLScheme

func (_WKWebViewClass WKWebViewClass) HandlesURLScheme(urlScheme string) bool

Returns a Boolean value that indicates whether WebKit natively supports resources with the specified URL scheme.

urlScheme: The URL scheme associated with the resource.

Return Value

true if WebKit provides native support for the URL scheme, or false if it doesn’t.

See: https://developer.apple.com/documentation/WebKit/WKWebView/handlesURLScheme(_:)

type WKWebViewConfiguration

type WKWebViewConfiguration struct {
	objectivec.Object
}

A collection of properties that you use to initialize a web view.

Overview

A WKWebViewConfiguration object provides information about how to configure a WKWebView object. Use your configuration object to specify:

- The initial cookies to make available to your web content - Handlers for any custom URL schemes your web content uses - Settings for how to handle media content - Information about how to manage selections within the web view - Custom scripts to inject into the webpage - Custom rules that determine how to render content

You create a WKWebViewConfiguration object in your code, configure its properties, and pass it to the initializer of your WKWebView object. The web view incorporates your configuration settings only at creation time; you cannot change those settings dynamically later.

Configuring the web view’s behavior

Configuring the web view’s preferences

Adding handlers for custom URL schemes

Configuring the rendering behavior

Setting media playback preferences

Selecting user interface directionality

Instance Properties

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration

func NewWKWebViewConfiguration

func NewWKWebViewConfiguration() WKWebViewConfiguration

NewWKWebViewConfiguration creates a new WKWebViewConfiguration instance.

func WKWebViewConfigurationFromID

func WKWebViewConfigurationFromID(id objc.ID) WKWebViewConfiguration

WKWebViewConfigurationFromID constructs a WKWebViewConfiguration from an objc.ID.

A collection of properties that you use to initialize a web view.

func (WKWebViewConfiguration) AllowsAirPlayForMediaPlayback

func (w WKWebViewConfiguration) AllowsAirPlayForMediaPlayback() bool

A Boolean value that indicates whether the web view allows media playback over AirPlay.

Discussion

The default value of this property is true.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/allowsAirPlayForMediaPlayback

func (WKWebViewConfiguration) ApplicationNameForUserAgent

func (w WKWebViewConfiguration) ApplicationNameForUserAgent() string

The app name that appears in the user agent string.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/applicationNameForUserAgent

func (WKWebViewConfiguration) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKWebViewConfiguration) DefaultWebpagePreferences

func (w WKWebViewConfiguration) DefaultWebpagePreferences() IWKWebpagePreferences

The default preferences to use when loading and rendering content.

Discussion

Use this property to specify the JavaScript settings and content mode for new webpages. When the web view navigates to a new page, it passes the default preferences to its navigation delegate, which can modify the preferences or pass them as they are.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/defaultWebpagePreferences

func (WKWebViewConfiguration) EncodeWithCoder

func (w WKWebViewConfiguration) EncodeWithCoder(coder foundation.INSCoder)

func (WKWebViewConfiguration) Init

Init initializes the instance.

func (WKWebViewConfiguration) LimitsNavigationsToAppBoundDomains

func (w WKWebViewConfiguration) LimitsNavigationsToAppBoundDomains() bool

A Boolean value that indicates whether the web view limits navigation to pages within the app’s domain.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/limitsNavigationsToAppBoundDomains

func (WKWebViewConfiguration) MediaTypesRequiringUserActionForPlayback

func (w WKWebViewConfiguration) MediaTypesRequiringUserActionForPlayback() WKAudiovisualMediaTypes

The media types that require a user gesture to begin playing.

Discussion

Use WKAudiovisualMediaTypeNone to indicate that no user gestures are required to begin playing media.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/mediaTypesRequiringUserActionForPlayback

func (WKWebViewConfiguration) Preferences

func (w WKWebViewConfiguration) Preferences() IWKPreferences

The object that manages the preference-related settings for the web view.

Discussion

Use the preferences object in this property to customize the rendering, JavaScript, and other preferences related to your web view. You can also change the preferences by assigning a new WKPreferences object to this property.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/preferences

func (WKWebViewConfiguration) SetAllowsAirPlayForMediaPlayback

func (w WKWebViewConfiguration) SetAllowsAirPlayForMediaPlayback(value bool)

func (WKWebViewConfiguration) SetAllowsInlinePredictions

func (w WKWebViewConfiguration) SetAllowsInlinePredictions(value bool)

func (WKWebViewConfiguration) SetApplicationNameForUserAgent

func (w WKWebViewConfiguration) SetApplicationNameForUserAgent(value string)

func (WKWebViewConfiguration) SetDefaultWebpagePreferences

func (w WKWebViewConfiguration) SetDefaultWebpagePreferences(value IWKWebpagePreferences)

func (WKWebViewConfiguration) SetLimitsNavigationsToAppBoundDomains

func (w WKWebViewConfiguration) SetLimitsNavigationsToAppBoundDomains(value bool)

func (WKWebViewConfiguration) SetMediaTypesRequiringUserActionForPlayback

func (w WKWebViewConfiguration) SetMediaTypesRequiringUserActionForPlayback(value WKAudiovisualMediaTypes)

func (WKWebViewConfiguration) SetPreferences

func (w WKWebViewConfiguration) SetPreferences(value IWKPreferences)

func (WKWebViewConfiguration) SetShowsSystemScreenTimeBlockingView

func (w WKWebViewConfiguration) SetShowsSystemScreenTimeBlockingView(value bool)

func (WKWebViewConfiguration) SetSupportsAdaptiveImageGlyph

func (w WKWebViewConfiguration) SetSupportsAdaptiveImageGlyph(value bool)

func (WKWebViewConfiguration) SetSuppressesIncrementalRendering

func (w WKWebViewConfiguration) SetSuppressesIncrementalRendering(value bool)

func (WKWebViewConfiguration) SetURLSchemeHandlerForURLScheme

func (w WKWebViewConfiguration) SetURLSchemeHandlerForURLScheme(urlSchemeHandler WKURLSchemeHandler, urlScheme string)

Registers an object to load resources associated with the specified URL scheme.

urlSchemeHandler: The object to handle the URL scheme. This object must adopt the WKURLSchemeHandler protocol.

urlScheme: The URL scheme to handle. Scheme names are case sensitive, must start with an ASCII letter, and may contain only ASCII letters, numbers, the “`+`” character, the “`-`” character, and the “`.`” character. This method raises an invalidArgumentException if the scheme name is an empty string or contains any other characters.

It is a programmer error to register a handler for a scheme WebKit already handles, such as `https`, and this method raises an invalidArgumentException if you try to do so. To determine whether WebKit handles a specific scheme, call the [HandlesURLScheme] class method of WKWebView.

Discussion

Use this method to register any custom resource types that your web content uses. For example, you might register a custom URL scheme for resources that you provide programmatically from your app.

It is a programmer error to call this method more than once for the same scheme.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/setURLSchemeHandler(_:forURLScheme:)

func (WKWebViewConfiguration) SetUpgradeKnownHostsToHTTPS

func (w WKWebViewConfiguration) SetUpgradeKnownHostsToHTTPS(value bool)

func (WKWebViewConfiguration) SetUserContentController

func (w WKWebViewConfiguration) SetUserContentController(value IWKUserContentController)

func (WKWebViewConfiguration) SetUserInterfaceDirectionPolicy

func (w WKWebViewConfiguration) SetUserInterfaceDirectionPolicy(value WKUserInterfaceDirectionPolicy)

func (WKWebViewConfiguration) SetWebExtensionController

func (w WKWebViewConfiguration) SetWebExtensionController(value IWKWebExtensionController)

func (WKWebViewConfiguration) SetWebsiteDataStore

func (w WKWebViewConfiguration) SetWebsiteDataStore(value IWKWebsiteDataStore)

func (WKWebViewConfiguration) SetWritingToolsBehavior

func (w WKWebViewConfiguration) SetWritingToolsBehavior(value objectivec.IObject)

func (WKWebViewConfiguration) ShowsSystemScreenTimeBlockingView

func (w WKWebViewConfiguration) ShowsSystemScreenTimeBlockingView() bool

Discussion

A Boolean value indicating whether the System Screen Time blocking view should be shown.

The default value is YES.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/showsSystemScreenTimeBlockingView

func (WKWebViewConfiguration) SuppressesIncrementalRendering

func (w WKWebViewConfiguration) SuppressesIncrementalRendering() bool

A Boolean value that indicates whether the web view suppresses content rendering until the content is fully loaded into memory.

Discussion

The default value of this property is false.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/suppressesIncrementalRendering

func (WKWebViewConfiguration) UpgradeKnownHostsToHTTPS

func (w WKWebViewConfiguration) UpgradeKnownHostsToHTTPS() bool

A Boolean value that indicates whether the web view should automatically upgrade supported HTTP requests to HTTPS.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/upgradeKnownHostsToHTTPS

func (WKWebViewConfiguration) UrlSchemeHandlerForURLScheme

func (w WKWebViewConfiguration) UrlSchemeHandlerForURLScheme(urlScheme string) WKURLSchemeHandler

Returns the currently registered handler object for the specified URL scheme.

urlScheme: The scheme to look up. Scheme names are case sensitive, must start with an ASCII letter, and may contain only ASCII letters, numbers, the “`+`” character, the “`-`” character, and the “`.`” character. If this parameter contains an empty string or the scheme name includes invalid characters, this method returns `nil`.

Return Value

The handler object for the specified scheme, or `nil` if the scheme has no handler.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/urlSchemeHandler(forURLScheme:)

func (WKWebViewConfiguration) UserContentController

func (w WKWebViewConfiguration) UserContentController() IWKUserContentController

The object that coordinates interactions between your app’s native code and the webpage’s scripts and other content.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/userContentController

func (WKWebViewConfiguration) UserInterfaceDirectionPolicy

func (w WKWebViewConfiguration) UserInterfaceDirectionPolicy() WKUserInterfaceDirectionPolicy

The directionality of user interface elements.

Discussion

The default value is WKUserInterfaceDirectionPolicyContent. For other possible values, see WKUserInterfaceDirectionPolicy.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/userInterfaceDirectionPolicy

func (WKWebViewConfiguration) WebExtensionController

func (w WKWebViewConfiguration) WebExtensionController() IWKWebExtensionController

Discussion

The web extension controller to associate with the web view.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/webExtensionController

func (WKWebViewConfiguration) WebsiteDataStore

func (w WKWebViewConfiguration) WebsiteDataStore() IWKWebsiteDataStore

The object you use to get and set the site’s cookies and to track the cached data objects.

Discussion

If you don’t assign a value to this property, the configuration object uses the default data store object to store data persistently. To create a private web-browsing session, create a nonpersistent data store using the [NonPersistentDataStore] method and assign it to this property. For more information, see WKWebsiteDataStore.

See: https://developer.apple.com/documentation/WebKit/WKWebViewConfiguration/websiteDataStore

type WKWebViewConfigurationClass

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

func GetWKWebViewConfigurationClass

func GetWKWebViewConfigurationClass() WKWebViewConfigurationClass

GetWKWebViewConfigurationClass returns the class object for WKWebViewConfiguration.

func (WKWebViewConfigurationClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebViewConfigurationClass) Class

Class returns the underlying Objective-C class pointer.

type WKWebViewDataType

type WKWebViewDataType uint

See: https://developer.apple.com/documentation/WebKit/WKWebViewDataType

const (
	WKWebViewDataTypeSessionStorage WKWebViewDataType = 1
)

func (WKWebViewDataType) String

func (e WKWebViewDataType) String() string

type WKWebpagePreferences

type WKWebpagePreferences struct {
	objectivec.Object
}

An object that specifies the behaviors to use when loading and rendering page content.

Overview

Create a WKWebpagePreferences object when you want to change the default rendering behavior of your web view. Typically, iOS devices render web content for a mobile experience, and Mac devices render content for a desktop experience.

Setting the JavaScript preferences

Setting the preferred content mode

Getting Lockdown Mode info

Instance Properties

See: https://developer.apple.com/documentation/WebKit/WKWebpagePreferences

func NewWKWebpagePreferences

func NewWKWebpagePreferences() WKWebpagePreferences

NewWKWebpagePreferences creates a new WKWebpagePreferences instance.

func WKWebpagePreferencesFromID

func WKWebpagePreferencesFromID(id objc.ID) WKWebpagePreferences

WKWebpagePreferencesFromID constructs a WKWebpagePreferences from an objc.ID.

An object that specifies the behaviors to use when loading and rendering page content.

func (WKWebpagePreferences) AllowsContentJavaScript

func (w WKWebpagePreferences) AllowsContentJavaScript() bool

A Boolean value that indicates whether JavaScript from web content is allowed to run.

Discussion

The default value of this property is true. If you change the value to false, the web view doesn’t execute JavaScript code referenced by the web content. That includes JavaScript code found in inline “ elements, “ URLs, and all other referenced JavaScript content.

See: https://developer.apple.com/documentation/WebKit/WKWebpagePreferences/allowsContentJavaScript

func (WKWebpagePreferences) Autorelease

Autorelease adds the receiver to the current autorelease pool.

func (WKWebpagePreferences) Init

Init initializes the instance.

func (WKWebpagePreferences) LockdownModeEnabled

func (w WKWebpagePreferences) LockdownModeEnabled() bool

A Boolean value that indicates whether to use Lockdown Mode in the web view.

Discussion

By default, this reflects whether the user has enabled Lockdown Mode on the device. Update this preference to override the device setting when you implement a per-website or similar setting.

For more information about Lockdown Mode, see About Lockdown Mode.

See: https://developer.apple.com/documentation/WebKit/WKWebpagePreferences/isLockdownModeEnabled

func (WKWebpagePreferences) PreferredContentMode

func (w WKWebpagePreferences) PreferredContentMode() WKContentMode

The content mode for the web view to use when it loads and renders a webpage.

Discussion

The default value of this property is WKContentModeRecommended. The web view ignores this preference for subframe navigation.

See: https://developer.apple.com/documentation/WebKit/WKWebpagePreferences/preferredContentMode

func (WKWebpagePreferences) PreferredHTTPSNavigationPolicy

func (w WKWebpagePreferences) PreferredHTTPSNavigationPolicy() WKWebpagePreferencesUpgradeToHTTPSPolicy

Discussion

A WKWebpagePreferencesUpgradeToHTTPSPolicy indicating the desired mode used when performing a top-level navigation to a webpage.

The default value is WKWebpagePreferencesUpgradeToHTTPSPolicyKeepAsRequested. The stated preference is ignored on subframe navigation, and it may be ignored based on system configuration. The upgradeKnownHostsToHTTPS property on WKWebViewConfiguration supercedes this policy for known hosts.

See: https://developer.apple.com/documentation/WebKit/WKWebpagePreferences/preferredHTTPSNavigationPolicy

func (WKWebpagePreferences) SecurityRestrictionMode

func (w WKWebpagePreferences) SecurityRestrictionMode() WKSecurityRestrictionMode

Discussion

Security restriction mode for this navigation.

Security restriction modes provide different levels of security hardening for high-risk browsing contexts. WKSecurityRestrictionModeMaximizeCompatibility provides additional hardening while maintaining full web compatibility:

- JavaScript JIT compilation disabled (interpreter-only execution) - Increased Memory Tagging Extension (MTE) coverage across allocations in the WebContent process Setting a security restriction mode creates separate, isolated WebContent processes for the specified protection level. This preference only applies to main frame navigations and will be ignored for subframe navigations. When set for a main frame, all subframe content and opened windows inherit the same security restrictions. When the system has chosen WKSecurityRestrictionModeLockdown (e.g., in Lockdown Mode), attempts to set a less restrictive mode will fail silently. The default value is WKSecurityRestrictionModeNone.

See: https://developer.apple.com/documentation/WebKit/WKWebpagePreferences/securityRestrictionMode

func (WKWebpagePreferences) SetAllowsContentJavaScript

func (w WKWebpagePreferences) SetAllowsContentJavaScript(value bool)

func (WKWebpagePreferences) SetLockdownModeEnabled

func (w WKWebpagePreferences) SetLockdownModeEnabled(value bool)

func (WKWebpagePreferences) SetPreferredContentMode

func (w WKWebpagePreferences) SetPreferredContentMode(value WKContentMode)

func (WKWebpagePreferences) SetPreferredHTTPSNavigationPolicy

func (w WKWebpagePreferences) SetPreferredHTTPSNavigationPolicy(value WKWebpagePreferencesUpgradeToHTTPSPolicy)

func (WKWebpagePreferences) SetSecurityRestrictionMode

func (w WKWebpagePreferences) SetSecurityRestrictionMode(value WKSecurityRestrictionMode)

type WKWebpagePreferencesClass

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

func GetWKWebpagePreferencesClass

func GetWKWebpagePreferencesClass() WKWebpagePreferencesClass

GetWKWebpagePreferencesClass returns the class object for WKWebpagePreferences.

func (WKWebpagePreferencesClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebpagePreferencesClass) Class

Class returns the underlying Objective-C class pointer.

type WKWebpagePreferencesHandler

type WKWebpagePreferencesHandler = func(*WKWebpagePreferences)

WKWebpagePreferencesHandler handles A completion handler block to call with the results about whether to allow or cancel the navigation.

  • policy: A constant that indicates whether to cancel or allow the navigation. For a list of possible values, see WKNavigationActionPolicy(<doc://com.apple.webkit/documentation/WebKit/WKNavigationActionPolicy>).
  • preferences: The set of preferences to apply to the page if the navigation is allowed. You may pass the object from the `preferences` parameter or configure a new preferences object and pass it instead.

Used by:

  • [WKNavigationDelegate.WebViewDecidePolicyForNavigationActionPreferencesDecisionHandler]

type WKWebpagePreferencesUpgradeToHTTPSPolicy

type WKWebpagePreferencesUpgradeToHTTPSPolicy int

See: https://developer.apple.com/documentation/WebKit/WKWebpagePreferences/UpgradeToHTTPSPolicy

const (
	WKWebpagePreferencesUpgradeToHTTPSPolicyAutomaticFallbackToHTTP    WKWebpagePreferencesUpgradeToHTTPSPolicy = 1
	WKWebpagePreferencesUpgradeToHTTPSPolicyErrorOnFailure             WKWebpagePreferencesUpgradeToHTTPSPolicy = 3
	WKWebpagePreferencesUpgradeToHTTPSPolicyKeepAsRequested            WKWebpagePreferencesUpgradeToHTTPSPolicy = 0
	WKWebpagePreferencesUpgradeToHTTPSPolicyUserMediatedFallbackToHTTP WKWebpagePreferencesUpgradeToHTTPSPolicy = 2
)

func (WKWebpagePreferencesUpgradeToHTTPSPolicy) String

type WKWebsiteDataRecord

type WKWebsiteDataRecord struct {
	objectivec.Object
}

A record of the data that a particular website stores persistently.

Overview

Use WKWebsiteDataRecord objects to discover the types of information that a website stores. Records identify the data types a website stores, but don’t identify the actual data. You might use this information to help the user manage website data. For example, Safari provides a way for users to view and remove website data. The domain name of each record contains the website’s domain name and suffix.

You don’t create WKWebsiteDataRecord objects directly. WebKit creates these records and stores them in the web view’s data store. Use the [FetchDataRecordsOfTypesCompletionHandler] of that data store to retrieve the current record objects. You also use that object to remove unwanted records.

Getting the Record Information

Getting the Data Type

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataRecord

func NewWKWebsiteDataRecord

func NewWKWebsiteDataRecord() WKWebsiteDataRecord

NewWKWebsiteDataRecord creates a new WKWebsiteDataRecord instance.

func WKWebsiteDataRecordFromID

func WKWebsiteDataRecordFromID(id objc.ID) WKWebsiteDataRecord

WKWebsiteDataRecordFromID constructs a WKWebsiteDataRecord from an objc.ID.

A record of the data that a particular website stores persistently.

func (WKWebsiteDataRecord) Autorelease

func (w WKWebsiteDataRecord) Autorelease() WKWebsiteDataRecord

Autorelease adds the receiver to the current autorelease pool.

func (WKWebsiteDataRecord) DataTypes

func (w WKWebsiteDataRecord) DataTypes() foundation.INSSet

The types of data associated with the record.

Discussion

Each record contains the set of types that the associated website stores. For a list of possible types, see Data Store Record Types.

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataRecord/dataTypes

func (WKWebsiteDataRecord) DisplayName

func (w WKWebsiteDataRecord) DisplayName() string

The display name for the data record.

Discussion

This property contains identifying information that you to display to users. Typically, the value is the website’s domain name and suffix taken from the host information in the resource’s security origin object. For more information, see WKSecurityOrigin.

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataRecord/displayName

func (WKWebsiteDataRecord) Init

Init initializes the instance.

func (WKWebsiteDataRecord) ReadAccessURL

func (w WKWebsiteDataRecord) ReadAccessURL() foundation.NSString

The local files WebKit can access when loading content.

See: https://developer.apple.com/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/readAccessURL

type WKWebsiteDataRecordArrayHandler

type WKWebsiteDataRecordArrayHandler = func(*[]WKWebsiteDataRecord)

WKWebsiteDataRecordArrayHandler handles The completion handler block to execute asynchronously with the results.

  • dataRecordArray: An array of WKWebsiteDataRecord(<doc://com.apple.webkit/documentation/WebKit/WKWebsiteDataRecord>) objects. Each object in this array corresponds to data for one of the requested types. If no records of the requested types exist, this array is empty.

Used by:

  • [WKWebsiteDataStore.FetchDataRecordsOfTypesCompletionHandler]

type WKWebsiteDataRecordClass

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

func GetWKWebsiteDataRecordClass

func GetWKWebsiteDataRecordClass() WKWebsiteDataRecordClass

GetWKWebsiteDataRecordClass returns the class object for WKWebsiteDataRecord.

func (WKWebsiteDataRecordClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebsiteDataRecordClass) Class

func (wc WKWebsiteDataRecordClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WKWebsiteDataStore

type WKWebsiteDataStore struct {
	objectivec.Object
}

An object that manages cookies, disk and memory caches, and other types of data for a web view.

Overview

Use a WKWebsiteDataStore object to configure and manage web site data. Specifically, use this object to:

- Manage cookies that your web site uses - Learn about the types of data that websites store - Remove unwanted web site data

Create a data store object and assign it to the [WebsiteDataStore] property of a WKWebViewConfiguration object before you create your web view.

By default, WKWebViewConfiguration uses the default data store returned by the [WKWebsiteDataStore.DefaultDataStore] method, which saves website data persistently to disk.

To implement private browsing, create a nonpersistent data store using the [WKWebsiteDataStore.NonPersistentDataStore] method instead.

To implement profile browsing, create a persistent data store using the [WKWebsiteDataStore.DataStoreForIdentifier] method, passing an identifier that you use to identify the data store.

Inspecting data store properties

Removing specific types of data

Instance Methods

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataStore

func NewWKWebsiteDataStore

func NewWKWebsiteDataStore() WKWebsiteDataStore

NewWKWebsiteDataStore creates a new WKWebsiteDataStore instance.

func NewWebsiteDataStoreForIdentifier

func NewWebsiteDataStoreForIdentifier(identifier foundation.NSUUID) WKWebsiteDataStore

Returns the persistent data store with the unique identifier you provide.

identifier: An identifier that uniquely identifies a data store.

Discussion

If the data store for the unique identifier you provide does not exist, the system creates and returns it. Use this method to get a data store for a profile.

This method throws an exception if the identifier is not valid.

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataStore/init(forIdentifier:)

func WKWebsiteDataStoreFromID

func WKWebsiteDataStoreFromID(id objc.ID) WKWebsiteDataStore

WKWebsiteDataStoreFromID constructs a WKWebsiteDataStore from an objc.ID.

An object that manages cookies, disk and memory caches, and other types of data for a web view.

func (WKWebsiteDataStore) Autorelease

func (w WKWebsiteDataStore) Autorelease() WKWebsiteDataStore

Autorelease adds the receiver to the current autorelease pool.

func (WKWebsiteDataStore) EncodeWithCoder

func (w WKWebsiteDataStore) EncodeWithCoder(coder foundation.INSCoder)

func (WKWebsiteDataStore) FetchDataOfTypes

func (w WKWebsiteDataStore) FetchDataOfTypes(ctx context.Context, dataTypes foundation.INSSet) (*foundation.NSData, error)

FetchDataOfTypes is a synchronous wrapper around WKWebsiteDataStore.FetchDataOfTypesCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebsiteDataStore) HttpCookieStore

func (w WKWebsiteDataStore) HttpCookieStore() IWKHTTPCookieStore

The object that manages the HTTP cookies for your website.

Discussion

Use the WKHTTPCookieStore object in this property to manage your website’s cookies. A cookie store object contains methods to add new cookies, and to remove cookies that don’t apply to your content. For example, you might initially use this object to add a cookie for the user’s login credentials and then delete that cookie when the user logs out.

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataStore/httpCookieStore

func (WKWebsiteDataStore) Identifier

func (w WKWebsiteDataStore) Identifier() foundation.NSUUID

An identifier that uniquely identifies a data store.

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataStore/identifier

func (WKWebsiteDataStore) Init

Init initializes the instance.

func (WKWebsiteDataStore) Persistent

func (w WKWebsiteDataStore) Persistent() bool

A Boolean value that indicates whether this object stores data to disk.

Discussion

The value of this property is true if the data store writes data to disk, or false if it doesn’t.

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataStore/isPersistent

func (WKWebsiteDataStore) ReadAccessURL

func (w WKWebsiteDataStore) ReadAccessURL() foundation.NSString

The local files WebKit can access when loading content.

See: https://developer.apple.com/documentation/Foundation/NSAttributedString/DocumentReadingOptionKey/readAccessURL

func (WKWebsiteDataStore) RemoveDataOfTypesForDataRecordsCompletionHandler

func (w WKWebsiteDataStore) RemoveDataOfTypesForDataRecordsCompletionHandler(dataTypes foundation.INSSet, dataRecords []WKWebsiteDataRecord, completionHandler VoidHandler)

Removes the specified types of website data from one or more data records.

dataTypes: The website data types to remove from the records.

dataRecords: The records that contain the data.

completionHandler: The completion handler block to execute asynchronously after the web view removes the specified data. This block has no return value and takes no parameters.

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataStore/removeData(ofTypes:for:completionHandler:)

func (WKWebsiteDataStore) RemoveDataOfTypesModifiedSince

func (w WKWebsiteDataStore) RemoveDataOfTypesModifiedSince(ctx context.Context, dataTypes foundation.INSSet, date foundation.INSDate) error

RemoveDataOfTypesModifiedSince is a synchronous wrapper around WKWebsiteDataStore.RemoveDataOfTypesModifiedSinceCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebsiteDataStore) RemoveDataOfTypesModifiedSinceCompletionHandler

func (w WKWebsiteDataStore) RemoveDataOfTypesModifiedSinceCompletionHandler(dataTypes foundation.INSSet, date foundation.INSDate, completionHandler VoidHandler)

Removes website data that changed after the specified date.

dataTypes: The website data types to remove.

date: The target date for the data removal. The data store removes data that a website changed after this date.

completionHandler: The completion handler block to execute asynchronously after the web view removes the specified data. This block has no return value and takes no parameters.

Discussion

This method removes the specified data type from all records, but only if a website modified the record’s data after the specified `date`.

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataStore/removeData(ofTypes:modifiedSince:completionHandler:)

func (WKWebsiteDataStore) RestoreData

func (w WKWebsiteDataStore) RestoreData(ctx context.Context, data foundation.INSData) error

RestoreData is a synchronous wrapper around WKWebsiteDataStore.RestoreDataCompletionHandler. It blocks until the completion handler fires or the context is cancelled.

func (WKWebsiteDataStore) SetProxyConfigurations

func (w WKWebsiteDataStore) SetProxyConfigurations(value []objectivec.Object)

func (WKWebsiteDataStore) SetWebsiteDataStore

func (w WKWebsiteDataStore) SetWebsiteDataStore(value IWKWebsiteDataStore)

func (WKWebsiteDataStore) WebsiteDataStore

func (w WKWebsiteDataStore) WebsiteDataStore() IWKWebsiteDataStore

The object you use to get and set the site’s cookies and to track the cached data objects.

See: https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/websitedatastore

type WKWebsiteDataStoreClass

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

func GetWKWebsiteDataStoreClass

func GetWKWebsiteDataStoreClass() WKWebsiteDataStoreClass

GetWKWebsiteDataStoreClass returns the class object for WKWebsiteDataStore.

func (WKWebsiteDataStoreClass) AllWebsiteDataTypes

func (_WKWebsiteDataStoreClass WKWebsiteDataStoreClass) AllWebsiteDataTypes() foundation.INSSet

Returns the set of all the available data types.

Discussion

Potential values in the set are WKWebsiteDataRecord constants.

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataStore/allWebsiteDataTypes()

func (WKWebsiteDataStoreClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWebsiteDataStoreClass) Class

func (wc WKWebsiteDataStoreClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

func (WKWebsiteDataStoreClass) DefaultDataStore

func (_WKWebsiteDataStoreClass WKWebsiteDataStoreClass) DefaultDataStore() WKWebsiteDataStore

Returns the default data store, which stores data persistently to disk.

Return Value

The default data store for websites.

Discussion

A web view configured with the default data store saves website data persistenly to disk. Use this data store to retain the state of web content between browsing sessions.

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataStore/default()

func (WKWebsiteDataStoreClass) NonPersistentDataStore

func (_WKWebsiteDataStoreClass WKWebsiteDataStoreClass) NonPersistentDataStore() WKWebsiteDataStore

Creates a new data store object that stores website data in memory, and doesn’t write that data to disk.

Return Value

A new data store object that doesn’t save data to disk.

Discussion

Use a nonpersistent data store to implement private browsing in your web view. This method creates a new data store that stores data only in memory, and doesn’t write that data to disk.

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataStore/nonPersistent()

func (WKWebsiteDataStoreClass) RemoveDataStoreForIdentifier

func (wc WKWebsiteDataStoreClass) RemoveDataStoreForIdentifier(ctx context.Context, identifier foundation.NSUUID) error

RemoveDataStoreForIdentifier is a synchronous wrapper around [WKWebsiteDataStore.RemoveDataStoreForIdentifierCompletionHandler]. It blocks until the completion handler fires or the context is cancelled.

func (WKWebsiteDataStoreClass) RemoveDataStoreForIdentifierCompletionHandler

func (_WKWebsiteDataStoreClass WKWebsiteDataStoreClass) RemoveDataStoreForIdentifierCompletionHandler(identifier foundation.NSUUID, completionHandler ErrorHandler)

Removes the data store that matches the identifier you provide.

identifier: An identifier that uniquely identifies a data store.

completionHandler: A block the system invokes after it removes the data store. This block has no return value, and takes the following parameter:

error: An error, if the system could not remove the data store.

Discussion

Call this method to remove the data store for the unique identifier. Release any WKWebView instances using the data store before you call this method. If the system cannot complete removal of the data store, this throws an error.

See: https://developer.apple.com/documentation/WebKit/WKWebsiteDataStore/remove(forIdentifier:completionHandler:)

type WKWindowFeatures

type WKWindowFeatures struct {
	objectivec.Object
}

Display-related attributes that a webpage requests for its window.

Overview

A WKWindowFeatures object contains the attributes that a webpage requests from its containing web view. You don’t create a WKWindowFeatures object directly. When a navigation action results in the display of a new web view, WKWebView creates this object and passes it to the [WebViewCreateWebViewWithConfigurationForNavigationActionWindowFeatures] method of its UI delegate object. The delegate uses the information in this object to configure and return the new web view.

Inspecting Window Position and Dimensions

Inspecting Visibility Properties

See: https://developer.apple.com/documentation/WebKit/WKWindowFeatures

func NewWKWindowFeatures

func NewWKWindowFeatures() WKWindowFeatures

NewWKWindowFeatures creates a new WKWindowFeatures instance.

func WKWindowFeaturesFromID

func WKWindowFeaturesFromID(id objc.ID) WKWindowFeatures

WKWindowFeaturesFromID constructs a WKWindowFeatures from an objc.ID.

Display-related attributes that a webpage requests for its window.

func (WKWindowFeatures) AllowsResizing

func (w WKWindowFeatures) AllowsResizing() foundation.NSNumber

A Boolean value that indicates whether to make the containing window window resizable.

Discussion

If the webpage didn’t request a resizable window, this property is `nil`.

See: https://developer.apple.com/documentation/WebKit/WKWindowFeatures/allowsResizing

func (WKWindowFeatures) Autorelease

func (w WKWindowFeatures) Autorelease() WKWindowFeatures

Autorelease adds the receiver to the current autorelease pool.

func (WKWindowFeatures) Height

The requested height of the containing window.

Discussion

The object in this property contains a CGFloat value. If the webpage didn’t request a specific window height, this property is `nil`.

See: https://developer.apple.com/documentation/WebKit/WKWindowFeatures/height

func (WKWindowFeatures) Init

Init initializes the instance.

func (WKWindowFeatures) MenuBarVisibility

func (w WKWindowFeatures) MenuBarVisibility() foundation.NSNumber

A Boolean value that indicates whether the webpage requests a visible menu bar.

Discussion

If the webpage didn’t request a visible menu bar, this property is `nil`.

See: https://developer.apple.com/documentation/WebKit/WKWindowFeatures/menuBarVisibility

func (WKWindowFeatures) StatusBarVisibility

func (w WKWindowFeatures) StatusBarVisibility() foundation.NSNumber

A Boolean value that indicates whether the webpage requested a visible status bar.

Discussion

If the webpage didn’t request a visible status bar, this property is `nil`.

See: https://developer.apple.com/documentation/WebKit/WKWindowFeatures/statusBarVisibility

func (WKWindowFeatures) ToolbarsVisibility

func (w WKWindowFeatures) ToolbarsVisibility() foundation.NSNumber

A Boolean value that indicates whether the webpage requested a visible toolbar.

Discussion

If the webpage didn’t request a visible toolbar, this property is `nil`.

See: https://developer.apple.com/documentation/WebKit/WKWindowFeatures/toolbarsVisibility

func (WKWindowFeatures) Width

The requested width of the containing window.

Discussion

The object in this property contains a CGFloat value. If the webpage didn’t request a specific window width, this property is `nil`.

See: https://developer.apple.com/documentation/WebKit/WKWindowFeatures/width

func (WKWindowFeatures) X

The requested x-coordinate of the containing window.

Discussion

The object in this property contains a CGFloat value. If the webpage didn’t request a specific window position, this property is `nil`.

See: https://developer.apple.com/documentation/WebKit/WKWindowFeatures/x

func (WKWindowFeatures) Y

The requested y-coordinate of the containing window.

Discussion

The object in this property contains a CGFloat value. If the webpage didn’t request a specific window position, this property is `nil`.

See: https://developer.apple.com/documentation/WebKit/WKWindowFeatures/y

type WKWindowFeaturesClass

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

func GetWKWindowFeaturesClass

func GetWKWindowFeaturesClass() WKWindowFeaturesClass

GetWKWindowFeaturesClass returns the class object for WKWindowFeatures.

func (WKWindowFeaturesClass) Alloc

Alloc allocates memory for a new instance of the class.

func (WKWindowFeaturesClass) Class

func (wc WKWindowFeaturesClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WebCacheModel

type WebCacheModel uint

See: https://developer.apple.com/documentation/WebKit/WebCacheModel

const (
	// Deprecated.
	WebCacheModelDocumentBrowser WebCacheModel = 1
	// Deprecated.
	WebCacheModelDocumentViewer WebCacheModel = 0
	// Deprecated.
	WebCacheModelPrimaryWebBrowser WebCacheModel = 2
)

func (WebCacheModel) String

func (e WebCacheModel) String() string

type WebDragDestinationAction

type WebDragDestinationAction uint

See: https://developer.apple.com/documentation/WebKit/WebDragDestinationAction

const (
	// Deprecated.
	WebDragDestinationActionAny WebDragDestinationAction = 0
	// Deprecated.
	WebDragDestinationActionDHTML WebDragDestinationAction = 1
	// Deprecated.
	WebDragDestinationActionEdit WebDragDestinationAction = 2
	// Deprecated.
	WebDragDestinationActionLoad WebDragDestinationAction = 4
	// Deprecated.
	WebDragDestinationActionNone WebDragDestinationAction = 0
)

func (WebDragDestinationAction) String

func (e WebDragDestinationAction) String() string

type WebDragSourceAction

type WebDragSourceAction uint

See: https://developer.apple.com/documentation/WebKit/WebDragSourceAction

const (
	// Deprecated.
	WebDragSourceActionAny WebDragSourceAction = 0
	// Deprecated.
	WebDragSourceActionDHTML WebDragSourceAction = 1
	// Deprecated.
	WebDragSourceActionImage WebDragSourceAction = 2
	// Deprecated.
	WebDragSourceActionLink WebDragSourceAction = 4
	// Deprecated.
	WebDragSourceActionNone WebDragSourceAction = 0
	// Deprecated.
	WebDragSourceActionSelection WebDragSourceAction = 8
)

func (WebDragSourceAction) String

func (e WebDragSourceAction) String() string

type WebKitError

type WebKitError int
const (
	WebKitErrorBlockedPlugInVersion               WebKitError = 203
	WebKitErrorCannotFindPlugIn                   WebKitError = 200
	WebKitErrorCannotLoadPlugIn                   WebKitError = 201
	WebKitErrorCannotShowMIMEType                 WebKitError = 100
	WebKitErrorCannotShowURL                      WebKitError = 101
	WebKitErrorFrameLoadInterruptedByPolicyChange WebKitError = 102
	WebKitErrorJavaUnavailable                    WebKitError = 202
)

func (WebKitError) String

func (e WebKitError) String() string

type WebMenuItem

type WebMenuItem uint
const (
	// WebMenuItemPDFActualSize: Display a PDF document at its original size.
	WebMenuItemPDFActualSize WebMenuItem = 24
	// WebMenuItemPDFAutoSize: Display a PDF document at a user-specified size.
	WebMenuItemPDFAutoSize WebMenuItem = 27
	// WebMenuItemPDFContinuous: Display all pages in a PDF document continuously, using a vertical scroll bar, if necessary.
	WebMenuItemPDFContinuous WebMenuItem = 30
	// WebMenuItemPDFFacingPages: Display a PDF document two pages at a time.
	WebMenuItemPDFFacingPages WebMenuItem = 29
	// WebMenuItemPDFNextPage: Display the next page of a PDF document.
	WebMenuItemPDFNextPage WebMenuItem = 31
	// WebMenuItemPDFPreviousPage: Display the previous page of a PDF document.
	WebMenuItemPDFPreviousPage WebMenuItem = 32
	// WebMenuItemPDFSinglePage: Display a PDF document one page at a time.
	WebMenuItemPDFSinglePage WebMenuItem = 28
	// WebMenuItemPDFZoomIn: Scale up a PDF document.
	WebMenuItemPDFZoomIn WebMenuItem = 25
	// WebMenuItemPDFZoomOut: Scale down a PDF document.
	WebMenuItemPDFZoomOut WebMenuItem = 26
	// WebMenuItemTagCopy: Copy the element to the clipboard.
	WebMenuItemTagCopy WebMenuItem = 8
	// WebMenuItemTagCopyImageToClipboard: Copy the image to the clipboard.
	WebMenuItemTagCopyImageToClipboard WebMenuItem = 6
	// WebMenuItemTagCopyLinkToClipboard: Copy the link to the clipboard.
	WebMenuItemTagCopyLinkToClipboard WebMenuItem = 3
	// WebMenuItemTagCut: Cut the currently selected content.
	WebMenuItemTagCut WebMenuItem = 13
	// WebMenuItemTagDownloadImageToDisk: Download the image to disk.
	WebMenuItemTagDownloadImageToDisk WebMenuItem = 5
	// WebMenuItemTagDownloadLinkToDisk: Download the link to a disk.
	WebMenuItemTagDownloadLinkToDisk WebMenuItem = 2
	// WebMenuItemTagGoBack: Load the previous page.
	WebMenuItemTagGoBack WebMenuItem = 9
	// WebMenuItemTagGoForward: Load the next page.
	WebMenuItemTagGoForward WebMenuItem = 10
	// WebMenuItemTagIgnoreSpelling: Ignore the misspelled word.
	WebMenuItemTagIgnoreSpelling WebMenuItem = 17
	// WebMenuItemTagLearnSpelling: Add the misspelled word to the user’s list of acceptable words.
	WebMenuItemTagLearnSpelling WebMenuItem = 18
	// WebMenuItemTagLookUpInDictionary: Look up the current selection in the Dictionary.
	WebMenuItemTagLookUpInDictionary WebMenuItem = 22
	// WebMenuItemTagNoGuessesFound: Indicate whether any suggested spellings for the misspelled word could be found.
	WebMenuItemTagNoGuessesFound WebMenuItem = 16
	// WebMenuItemTagOpenFrameInNewWindow: Open the frame in a new window.
	WebMenuItemTagOpenFrameInNewWindow WebMenuItem = 7
	// WebMenuItemTagOpenImageInNewWindow: Open the image in a new window.
	WebMenuItemTagOpenImageInNewWindow WebMenuItem = 4
	// WebMenuItemTagOpenLinkInNewWindow: Open the link in a new window.
	WebMenuItemTagOpenLinkInNewWindow WebMenuItem = 1
	// WebMenuItemTagOpenWithDefaultApplication: Open the current selection using the default application.
	WebMenuItemTagOpenWithDefaultApplication WebMenuItem = 23
	// WebMenuItemTagOther: Used when a tag for an item in the context menu can’t be determined.
	WebMenuItemTagOther WebMenuItem = 19
	// WebMenuItemTagPaste: Paste the content on the clipboard onto the current selection.
	WebMenuItemTagPaste WebMenuItem = 14
	// WebMenuItemTagReload: Reload the current page.
	WebMenuItemTagReload WebMenuItem = 12
	// WebMenuItemTagSearchInSpotlight: Search SpotLight for the current selection.
	WebMenuItemTagSearchInSpotlight WebMenuItem = 20
	// WebMenuItemTagSearchWeb: Search the web for the current selection.
	WebMenuItemTagSearchWeb WebMenuItem = 21
	// WebMenuItemTagSpellingGuess: Suggest spellings for the misspelled word.
	WebMenuItemTagSpellingGuess WebMenuItem = 15
	// WebMenuItemTagStop: Stop loading the current page.
	WebMenuItemTagStop WebMenuItem = 11
)

func (WebMenuItem) String

func (e WebMenuItem) String() string

type WebNavigationType

type WebNavigationType int

See: https://developer.apple.com/documentation/WebKit/WebNavigationType

const (
	// Deprecated.
	WebNavigationTypeBackForward WebNavigationType = 2
	// Deprecated.
	WebNavigationTypeFormResubmitted WebNavigationType = 4
	// Deprecated.
	WebNavigationTypeFormSubmitted WebNavigationType = 1
	// Deprecated.
	WebNavigationTypeLinkClicked WebNavigationType = 0
	// Deprecated.
	WebNavigationTypeOther WebNavigationType = 5
	// Deprecated.
	WebNavigationTypeReload WebNavigationType = 3
)

func (WebNavigationType) String

func (e WebNavigationType) String() string

type WebResource

type WebResource struct {
	objectivec.Object
}

A WebResource object represents a downloaded URL. It encapsulates the data of the download as well as other resource properties such as the URL, MIME type, and frame name.

Overview

Use the WebResource.InitWithDataURLMIMETypeTextEncodingNameFrameName method to initialize a newly created WebResource object. Use the other methods in this class to get the properties of a WebResource object.

Initializing

Getting attributes

See: https://developer.apple.com/documentation/WebKit/WebResource

func NewWebResource

func NewWebResource() WebResource

NewWebResource creates a new WebResource instance.

func NewWebResourceWithDataURLMIMETypeTextEncodingNameFrameName

func NewWebResourceWithDataURLMIMETypeTextEncodingNameFrameName(data foundation.INSData, URL foundation.INSURL, MIMEType string, textEncodingName string, frameName string) WebResource

Initializes and returns a web resource instance.

data: The download data.

URL: The download URL.

MIMEType: The MIME type of the data.

textEncodingName: The IANA encoding name (for example, “utf-8” or “utf-16”). This parameter may be `nil`.

frameName: The name of the frame. Use this parameter if the resource represents the contents of an entire HTML frame; otherwise pass `nil`.

Return Value

An initialized web resource.

See: https://developer.apple.com/documentation/WebKit/WebResource/init(data:url:mimeType:textEncodingName:frameName:)

func WebResourceFromID

func WebResourceFromID(id objc.ID) WebResource

WebResourceFromID constructs a WebResource from an objc.ID.

A WebResource object represents a downloaded URL. It encapsulates the data of the download as well as other resource properties such as the URL, MIME type, and frame name.

func (WebResource) Autorelease

func (w WebResource) Autorelease() WebResource

Autorelease adds the receiver to the current autorelease pool.

func (WebResource) Data

func (w WebResource) Data() foundation.INSData

The receiver’s data.

See: https://developer.apple.com/documentation/WebKit/WebResource/data

func (WebResource) EncodeWithCoder

func (w WebResource) EncodeWithCoder(coder foundation.INSCoder)

func (WebResource) FrameName

func (w WebResource) FrameName() string

The name of the frame. If the receiver does not represent the contents of an entire HTML frame, this is `nil`.

See: https://developer.apple.com/documentation/WebKit/WebResource/frameName

func (WebResource) Init

func (w WebResource) Init() WebResource

Init initializes the instance.

func (WebResource) InitWithDataURLMIMETypeTextEncodingNameFrameName

func (w WebResource) InitWithDataURLMIMETypeTextEncodingNameFrameName(data foundation.INSData, URL foundation.INSURL, MIMEType string, textEncodingName string, frameName string) WebResource

Initializes and returns a web resource instance.

data: The download data.

URL: The download URL.

MIMEType: The MIME type of the data.

textEncodingName: The IANA encoding name (for example, “utf-8” or “utf-16”). This parameter may be `nil`.

frameName: The name of the frame. Use this parameter if the resource represents the contents of an entire HTML frame; otherwise pass `nil`.

Return Value

An initialized web resource.

See: https://developer.apple.com/documentation/WebKit/WebResource/init(data:url:mimeType:textEncodingName:frameName:)

func (WebResource) MIMEType

func (w WebResource) MIMEType() string

The receiver’s MIME type.

See: https://developer.apple.com/documentation/WebKit/WebResource/mimeType

func (WebResource) TextEncodingName

func (w WebResource) TextEncodingName() string

The receiver’s text encoding name.

See: https://developer.apple.com/documentation/WebKit/WebResource/textEncodingName

func (WebResource) URL

func (w WebResource) URL() foundation.INSURL

The receiver’s URL.

See: https://developer.apple.com/documentation/WebKit/WebResource/url

type WebResourceClass

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

func GetWebResourceClass

func GetWebResourceClass() WebResourceClass

GetWebResourceClass returns the class object for WebResource.

func (WebResourceClass) Alloc

func (wc WebResourceClass) Alloc() WebResource

Alloc allocates memory for a new instance of the class.

func (WebResourceClass) Class

func (wc WebResourceClass) Class() objc.Class

Class returns the underlying Objective-C class pointer.

type WebViewInsertAction

type WebViewInsertAction int

See: https://developer.apple.com/documentation/WebKit/WebViewInsertAction

const (
	// Deprecated.
	WebViewInsertActionDropped WebViewInsertAction = 2
	// Deprecated.
	WebViewInsertActionPasted WebViewInsertAction = 1
	// Deprecated.
	WebViewInsertActionTyped WebViewInsertAction = 0
)

func (WebViewInsertAction) String

func (e WebViewInsertAction) String() string

Source Files

Jump to

Keyboard shortcuts

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