Session

external class Session(source)

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val availableSpellCheckerLanguages: <Error class: unknown class><String>

A string[] array which consists of all the known available spell checker languages. Providing a language code to the setSpellCheckerLanguages API that isn't in this array will result in an error.

Link copied to clipboard

A Cookies object for this session.

Link copied to clipboard
val extensionLoadedEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, Extension>>
Link copied to clipboard
val extensionReadyEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, Extension>>
Link copied to clipboard
val extensionUnloadedEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, Extension>>
Link copied to clipboard
val fileSystemAccessRestrictedEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, FileSystemAccessRestrictedDetails, (action: SessionFileSystemAccessRestrictedListenerCallbackAction) -> Unit>>
Link copied to clipboard
val hidDeviceAddedEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, HidDeviceAddedDetails>>
Link copied to clipboard
val hidDeviceRemovedEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, HidDeviceRemovedDetails>>
Link copied to clipboard
val hidDeviceRevokedEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, HidDeviceRevokedDetails>>
Link copied to clipboard

A NetLog object for this session.

Link copied to clipboard
val preconnectEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, String, Boolean>>
Link copied to clipboard

A Protocol object for this session.

Link copied to clipboard
val selectHidDeviceEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, SelectHidDeviceDetails, (deviceId: String?) -> Unit>>
Link copied to clipboard
val selectSerialPortEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, <Error class: unknown class><SerialPort>, WebContents, (portId: String) -> Unit>>
Link copied to clipboard
val selectUsbDeviceEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, SelectUsbDeviceDetails, (deviceId: String?) -> Unit>>
Link copied to clipboard
val serialPortAddedEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, SerialPort, WebContents>>
Link copied to clipboard
val serialPortRemovedEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, SerialPort, WebContents>>
Link copied to clipboard
val serialPortRevokedEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, SerialPortRevokedDetails>>
Link copied to clipboard

A ServiceWorkers object for this session.

Link copied to clipboard
val spellcheckDictionaryDownloadBeginEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, String>>
Link copied to clipboard
val spellcheckDictionaryDownloadFailureEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, String>>
Link copied to clipboard
val spellcheckDictionaryDownloadSuccessEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, String>>
Link copied to clipboard
val spellcheckDictionaryInitializedEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, String>>
Link copied to clipboard

A boolean indicating whether builtin spell checker is enabled.

Link copied to clipboard

A string | null indicating the absolute file system path where data for this session is persisted on disk. For in memory sessions this returns null.

Link copied to clipboard
val usbDeviceAddedEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, USBDevice, WebContents>>
Link copied to clipboard
val usbDeviceRemovedEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, USBDevice, WebContents>>
Link copied to clipboard
val usbDeviceRevokedEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, UsbDeviceRevokedDetails>>
Link copied to clipboard

A WebRequest object for this session.

Link copied to clipboard
val willDownloadEvent: <Error class: unknown class><<Error class: unknown class><Event<*>, DownloadItem, WebContents>>

Functions

Link copied to clipboard

Whether the word was successfully written to the custom dictionary. This API will not work on non-persistent (in-memory) sessions.

Link copied to clipboard

Dynamically sets whether to always send credentials for HTTP NTLM or Negotiate authentication.

Link copied to clipboard
fun clearAuthCache(): <Error class: unknown class><<Error class: unknown class>>

resolves when the session’s HTTP authentication cache has been cleared.

Link copied to clipboard
fun clearCache(): <Error class: unknown class><<Error class: unknown class>>

resolves when the cache clear operation is complete.

Link copied to clipboard
fun clearCodeCaches(options: ClearCodeCachesOptions): <Error class: unknown class><<Error class: unknown class>>

resolves when the code cache clear operation is complete.

Link copied to clipboard
fun clearData(options: ClearDataOptions = definedExternally): <Error class: unknown class><<Error class: unknown class>>

resolves when all data has been cleared.

Link copied to clipboard
fun clearHostResolverCache(): <Error class: unknown class><<Error class: unknown class>>

Resolves when the operation is complete.

Link copied to clipboard
fun clearStorageData(options: ClearStorageDataOptions = definedExternally): <Error class: unknown class><<Error class: unknown class>>

resolves when the storage data has been cleared.

Link copied to clipboard
fun closeAllConnections(): <Error class: unknown class><<Error class: unknown class>>

Resolves when all connections are closed.

Link copied to clipboard

Allows resuming cancelled or interrupted downloads from previous Session. The API will generate a DownloadItem that can be accessed with the will-download event. The DownloadItem will not have any WebContents associated with it and the initial state will be interrupted. The download will start only when the resume API is called on the DownloadItem.

Link copied to clipboard

Disables any network emulation already active for the session. Resets to the original network configuration.

Link copied to clipboard
fun downloadURL(url: String, options: DownloadURLOptions = definedExternally)

Initiates a download of the resource at url. The API will generate a DownloadItem that can be accessed with the will-download event.

Link copied to clipboard

Emulates network with the given configuration for the session.

Link copied to clipboard
fun fetch(input: GlobalRequest, init: SessionFetchInit = definedExternally): <Error class: unknown class><GlobalResponse>
fun fetch(input: String, init: SessionFetchInit = definedExternally): <Error class: unknown class><GlobalResponse>

see Response.

Link copied to clipboard

Writes any unwritten DOMStorage data to disk.

Link copied to clipboard
fun forceReloadProxyConfig(): <Error class: unknown class><<Error class: unknown class>>

Resolves when the all internal states of proxy service is reset and the latest proxy configuration is reapplied if it's already available. The pac script will be fetched from pacScript again if the proxy mode is pac_script.

Link copied to clipboard
fun getAllExtensions(): <Error class: unknown class><Extension>

A list of all loaded extensions.

Link copied to clipboard
fun getBlobData(identifier: String): <Error class: unknown class><<Error class: unknown class><out <Error class: unknown class>>>

resolves with blob data.

Link copied to clipboard
fun getCacheSize(): <Error class: unknown class><Double>

the session's current cache size, in bytes.

Link copied to clipboard
fun getExtension(extensionId: String): Extension?

The loaded extension with the given ID.

Link copied to clipboard
fun getPreloads(): <Error class: unknown class><String>

an array of paths to preload scripts that have been registered.

Link copied to clipboard
fun getSpellCheckerLanguages(): <Error class: unknown class><String>

An array of language codes the spellchecker is enabled for. If this list is empty the spellchecker will fallback to using en-US. By default on launch if this setting is an empty list Electron will try to populate this setting with the current OS locale. This setting is persisted across restarts.

Link copied to clipboard

The absolute file system path where data for this session is persisted on disk. For in memory sessions this returns null.

Link copied to clipboard

The user agent for this session.

Link copied to clipboard

Whether or not this session is a persistent one. The default webContents session of a BrowserWindow is persistent. When creating a session from a partition, session prefixed with persist: will be persistent, while others will be temporary.

Link copied to clipboard

Whether the builtin spell checker is enabled.

Link copied to clipboard
fun listWordsInSpellCheckerDictionary(): <Error class: unknown class><<Error class: unknown class><String>>

An array of all words in app's custom dictionary. Resolves when the full dictionary is loaded from disk.

Link copied to clipboard
fun loadExtension(path: String, options: LoadExtensionOptions = definedExternally): <Error class: unknown class><Extension>

resolves when the extension is loaded.

Link copied to clipboard

Preconnects the given number of sockets to an origin.

Link copied to clipboard
fun removeExtension(extensionId: String)

Unloads an extension.

Link copied to clipboard

Whether the word was successfully removed from the custom dictionary. This API will not work on non-persistent (in-memory) sessions.

Link copied to clipboard
fun resolveHost(host: String, options: ResolveHostOptions = definedExternally): <Error class: unknown class><ResolvedHost>

Resolves with the resolved IP addresses for the host.

Link copied to clipboard
fun resolveProxy(url: String): <Error class: unknown class><String>

Resolves with the proxy information for url.

Link copied to clipboard
fun setBluetoothPairingHandler(handler: (details: BluetoothPairingHandlerHandlerDetails, callback: (response: Response) -> Unit) -> Unit?)

Sets a handler to respond to Bluetooth pairing requests. This handler allows developers to handle devices that require additional validation before pairing. When a handler is not defined, any pairing on Linux or Windows that requires additional validation will be automatically cancelled. macOS does not require a handler because macOS handles the pairing automatically. To clear the handler, call setBluetoothPairingHandler(null).

Link copied to clipboard
fun setCertificateVerifyProc(proc: (request: Request, callback: (verificationResult: Double) -> Unit) -> Unit?)

Sets the certificate verify proc for session, the proc will be called with proc(request, callback) whenever a server certificate verification is requested. Calling callback(0) accepts the certificate, calling callback(-2) rejects it.

Link copied to clipboard

Sets the directory to store the generated JS code cache for this session. The directory is not required to be created by the user before this call, the runtime will create if it does not exist otherwise will use the existing directory. If directory cannot be created, then code cache will not be used and all operations related to code cache will fail silently inside the runtime. By default, the directory will be Code Cache under the respective user data folder.

Link copied to clipboard

Sets the handler which can be used to respond to device permission checks for the session. Returning true will allow the device to be permitted and false will reject it. To clear the handler, call setDevicePermissionHandler(null). This handler can be used to provide default permissioning to devices without first calling for permission to devices (eg via navigator.hid.requestDevice). If this handler is not defined, the default device permissions as granted through device selection (eg via navigator.hid.requestDevice) will be used. Additionally, the default behavior of Electron is to store granted device permission in memory. If longer term storage is needed, a developer can store granted device permissions (eg when handling the select-hid-device event) and then read from that storage with setDevicePermissionHandler.

Link copied to clipboard
fun setDisplayMediaRequestHandler(    handler: (request: DisplayMediaRequestHandlerHandlerRequest, callback: (streams: Streams) -> Unit) -> Unit?,     opts: DisplayMediaRequestHandlerOpts = definedExternally)

This handler will be called when web content requests access to display media via the navigator.mediaDevices.getDisplayMedia API. Use the desktopCapturer API to choose which stream(s) to grant access to.

Link copied to clipboard

Sets download saving directory. By default, the download directory will be the Downloads under the respective app folder.

Link copied to clipboard

Sets the handler which can be used to respond to permission checks for the session. Returning true will allow the permission and false will reject it. Please note that you must also implement setPermissionRequestHandler to get complete permission handling. Most web APIs do a permission check and then make a permission request if the check is denied. To clear the handler, call setPermissionCheckHandler(null).

Link copied to clipboard
fun setPermissionRequestHandler(    handler: (webContents: WebContents, permission: SessionSetPermissionRequestHandlerHandlerPermission, callback: (permissionGranted: Boolean) -> Unit, details: Any) -> Unit?)

Sets the handler which can be used to respond to permission requests for the session. Calling callback(true) will allow the permission and callback(false) will reject it. To clear the handler, call setPermissionRequestHandler(null). Please note that you must also implement setPermissionCheckHandler to get complete permission handling. Most web APIs do a permission check and then make a permission request if the check is denied.

Link copied to clipboard
fun setPreloads(preloads: <Error class: unknown class><String>)

Adds scripts that will be executed on ALL web contents that are associated with this session just before normal preload scripts run.

Link copied to clipboard
fun setProxy(config: ProxyConfig): <Error class: unknown class><<Error class: unknown class>>

Resolves when the proxy setting process is complete.

Link copied to clipboard

By default Electron will download hunspell dictionaries from the Chromium CDN. If you want to override this behavior you can use this API to point the dictionary downloader at your own hosted version of the hunspell dictionaries. We publish a hunspell_dictionaries.zip file with each release which contains the files you need to host here.

Link copied to clipboard

Sets whether to enable the builtin spell checker.

Link copied to clipboard
fun setSpellCheckerLanguages(languages: <Error class: unknown class><String>)

The built in spellchecker does not automatically detect what language a user is typing in. In order for the spell checker to correctly check their words you must call this API with an array of language codes. You can get the list of supported language codes with the ses.availableSpellCheckerLanguages property.

Link copied to clipboard
fun setSSLConfig(config: Config)

Sets the SSL configuration for the session. All subsequent network requests will use the new configuration. Existing network connections (such as WebSocket connections) will not be terminated, but old sockets in the pool will not be reused for new connections.

Link copied to clipboard
fun setUSBProtectedClassesHandler(handler: (details: USBProtectedClassesHandlerHandlerDetails) -> <Error class: unknown class><String>?)

Sets the handler which can be used to override which USB classes are protected. The return value for the handler is a string array of USB classes which should be considered protected (eg not available in the renderer). Valid values for the array are:

Link copied to clipboard
fun setUserAgent(userAgent: String, acceptLanguages: String = definedExternally)

Overrides the userAgent and acceptLanguages for this session.