Session

external class Session : EventEmitter(source)

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

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

A NetLog object for this session.

Link copied to clipboard

A Protocol object for this session.

Link copied to clipboard

A ServiceWorkers object for this session.

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

A WebRequest object for this session.

Functions

Link copied to clipboard
fun addListener(event: SessionEvent.EXTENSION_LOADED, listener: (event: Event<*>, extension: Extension) -> Unit)
fun addListener(event: SessionEvent.EXTENSION_READY, listener: (event: Event<*>, extension: Extension) -> Unit)
fun addListener(event: SessionEvent.EXTENSION_UNLOADED, listener: (event: Event<*>, extension: Extension) -> Unit)
fun addListener(event: SessionEvent.HID_DEVICE_ADDED, listener: (event: Event<*>, details: HidDeviceAddedDetails) -> Unit)
fun addListener(event: SessionEvent.HID_DEVICE_REMOVED, listener: (event: Event<*>, details: HidDeviceRemovedDetails) -> Unit)
fun addListener(event: SessionEvent.HID_DEVICE_REVOKED, listener: (event: Event<*>, details: HidDeviceRevokedDetails) -> Unit)
fun addListener(event: SessionEvent.PRECONNECT, listener: (event: Event<*>, preconnectUrl: String, allowCredentials: Boolean) -> Unit)
fun addListener(event: SessionEvent.SELECT_HID_DEVICE, listener: (event: Event<*>, details: SelectHidDeviceDetails, callback: (deviceId: String?) -> Unit) -> Unit)
fun addListener(event: SessionEvent.SELECT_SERIAL_PORT, listener: (event: Event<*>, ReadonlyArray<SerialPort>, webContents: WebContents, callback: (portId: String) -> Unit) -> Unit)
fun addListener(event: SessionEvent.SELECT_USB_DEVICE, listener: (event: Event<*>, details: SelectUsbDeviceDetails, callback: (deviceId: String?) -> Unit) -> Unit)
fun addListener(event: SessionEvent.SERIAL_PORT_ADDED, listener: (event: Event<*>, port: SerialPort, webContents: WebContents) -> Unit)
fun addListener(event: SessionEvent.SERIAL_PORT_REMOVED, listener: (event: Event<*>, port: SerialPort, webContents: WebContents) -> Unit)
fun addListener(event: SessionEvent.SERIAL_PORT_REVOKED, listener: (event: Event<*>, details: SerialPortRevokedDetails) -> Unit)
fun addListener(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_BEGIN, listener: (event: Event<*>, languageCode: String) -> Unit)
fun addListener(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_FAILURE, listener: (event: Event<*>, languageCode: String) -> Unit)
fun addListener(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_SUCCESS, listener: (event: Event<*>, languageCode: String) -> Unit)
fun addListener(event: SessionEvent.SPELLCHECK_DICTIONARY_INITIALIZED, listener: (event: Event<*>, languageCode: String) -> Unit)
fun addListener(event: SessionEvent.USB_DEVICE_ADDED, listener: (event: Event<*>, device: USBDevice, webContents: WebContents) -> Unit)
fun addListener(event: SessionEvent.USB_DEVICE_REMOVED, listener: (event: Event<*>, device: USBDevice, webContents: WebContents) -> Unit)
fun addListener(event: SessionEvent.USB_DEVICE_REVOKED, listener: (event: Event<*>, details: UsbDeviceRevokedDetails) -> Unit)
fun addListener(event: SessionEvent.WILL_DOWNLOAD, listener: (event: Event<*>, item: DownloadItem, webContents: WebContents) -> Unit)
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

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

Link copied to clipboard

resolves when the cache clear operation is complete.

Link copied to clipboard

resolves when the code cache clear operation is complete.

Link copied to clipboard

Resolves when the operation is complete.

Link copied to clipboard
fun clearStorageData(options: ClearStorageDataOptions = definedExternally): Promise<Void>

resolves when the storage data has been cleared.

Link copied to clipboard

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
Link copied to clipboard
fun fetch(input: String, init: SessionFetchInit = definedExternally): Promise<GlobalResponse>
fun fetch(input: GlobalRequest, init: SessionFetchInit = definedExternally): Promise<GlobalResponse>

see Response.

Link copied to clipboard

Writes any unwritten DOMStorage data to disk.

Link copied to clipboard

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

A list of all loaded extensions.

Link copied to clipboard
fun getBlobData(identifier: String): Promise<Buffer>

resolves with blob data.

Link copied to clipboard

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
Link copied to clipboard

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

Link copied to clipboard

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

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): Promise<Extension>

resolves when the extension is loaded.

Link copied to clipboard
fun off(event: SessionEvent.EXTENSION_LOADED, listener: (event: Event<*>, extension: Extension) -> Unit)
fun off(event: SessionEvent.EXTENSION_READY, listener: (event: Event<*>, extension: Extension) -> Unit)
fun off(event: SessionEvent.EXTENSION_UNLOADED, listener: (event: Event<*>, extension: Extension) -> Unit)
fun off(event: SessionEvent.HID_DEVICE_ADDED, listener: (event: Event<*>, details: HidDeviceAddedDetails) -> Unit)
fun off(event: SessionEvent.HID_DEVICE_REMOVED, listener: (event: Event<*>, details: HidDeviceRemovedDetails) -> Unit)
fun off(event: SessionEvent.HID_DEVICE_REVOKED, listener: (event: Event<*>, details: HidDeviceRevokedDetails) -> Unit)
fun off(event: SessionEvent.PRECONNECT, listener: (event: Event<*>, preconnectUrl: String, allowCredentials: Boolean) -> Unit)
fun off(event: SessionEvent.SELECT_HID_DEVICE, listener: (event: Event<*>, details: SelectHidDeviceDetails, callback: (deviceId: String?) -> Unit) -> Unit)
fun off(event: SessionEvent.SELECT_SERIAL_PORT, listener: (event: Event<*>, ReadonlyArray<SerialPort>, webContents: WebContents, callback: (portId: String) -> Unit) -> Unit)
fun off(event: SessionEvent.SELECT_USB_DEVICE, listener: (event: Event<*>, details: SelectUsbDeviceDetails, callback: (deviceId: String?) -> Unit) -> Unit)
fun off(event: SessionEvent.SERIAL_PORT_ADDED, listener: (event: Event<*>, port: SerialPort, webContents: WebContents) -> Unit)
fun off(event: SessionEvent.SERIAL_PORT_REMOVED, listener: (event: Event<*>, port: SerialPort, webContents: WebContents) -> Unit)
fun off(event: SessionEvent.SERIAL_PORT_REVOKED, listener: (event: Event<*>, details: SerialPortRevokedDetails) -> Unit)
fun off(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_BEGIN, listener: (event: Event<*>, languageCode: String) -> Unit)
fun off(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_FAILURE, listener: (event: Event<*>, languageCode: String) -> Unit)
fun off(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_SUCCESS, listener: (event: Event<*>, languageCode: String) -> Unit)
fun off(event: SessionEvent.SPELLCHECK_DICTIONARY_INITIALIZED, listener: (event: Event<*>, languageCode: String) -> Unit)
fun off(event: SessionEvent.USB_DEVICE_ADDED, listener: (event: Event<*>, device: USBDevice, webContents: WebContents) -> Unit)
fun off(event: SessionEvent.USB_DEVICE_REMOVED, listener: (event: Event<*>, device: USBDevice, webContents: WebContents) -> Unit)
fun off(event: SessionEvent.USB_DEVICE_REVOKED, listener: (event: Event<*>, details: UsbDeviceRevokedDetails) -> Unit)
fun off(event: SessionEvent.WILL_DOWNLOAD, listener: (event: Event<*>, item: DownloadItem, webContents: WebContents) -> Unit)
Link copied to clipboard
fun on(event: SessionEvent.EXTENSION_LOADED, listener: (event: Event<*>, extension: Extension) -> Unit)

Emitted after an extension is loaded. This occurs whenever an extension is added to the "enabled" set of extensions. This includes:

fun on(event: SessionEvent.EXTENSION_READY, listener: (event: Event<*>, extension: Extension) -> Unit)

Emitted after an extension is loaded and all necessary browser state is initialized to support the start of the extension's background page.

fun on(event: SessionEvent.EXTENSION_UNLOADED, listener: (event: Event<*>, extension: Extension) -> Unit)

Emitted after an extension is unloaded. This occurs when Session.removeExtension is called.

fun on(event: SessionEvent.HID_DEVICE_ADDED, listener: (event: Event<*>, details: HidDeviceAddedDetails) -> Unit)

Emitted after navigator.hid.requestDevice has been called and select-hid-device has fired if a new device becomes available before the callback from select-hid-device is called. This event is intended for use when using a UI to ask users to pick a device so that the UI can be updated with the newly added device.

fun on(event: SessionEvent.HID_DEVICE_REMOVED, listener: (event: Event<*>, details: HidDeviceRemovedDetails) -> Unit)

Emitted after navigator.hid.requestDevice has been called and select-hid-device has fired if a device has been removed before the callback from select-hid-device is called. This event is intended for use when using a UI to ask users to pick a device so that the UI can be updated to remove the specified device.

fun on(event: SessionEvent.HID_DEVICE_REVOKED, listener: (event: Event<*>, details: HidDeviceRevokedDetails) -> Unit)

Emitted after HIDDevice.forget() has been called. This event can be used to help maintain persistent storage of permissions when setDevicePermissionHandler is used.

fun on(event: SessionEvent.PRECONNECT, listener: (event: Event<*>, preconnectUrl: String, allowCredentials: Boolean) -> Unit)

Emitted when a render process requests preconnection to a URL, generally due to a resource hint.

fun on(event: SessionEvent.SELECT_HID_DEVICE, listener: (event: Event<*>, details: SelectHidDeviceDetails, callback: (deviceId: String?) -> Unit) -> Unit)

Emitted when a HID device needs to be selected when a call to navigator.hid.requestDevice is made. callback should be called with deviceId to be selected; passing no arguments to callback will cancel the request. Additionally, permissioning on navigator.hid can be further managed by using ses.setPermissionCheckHandler(handler) and ses.setDevicePermissionHandler(handler).

fun on(event: SessionEvent.SELECT_SERIAL_PORT, listener: (event: Event<*>, ReadonlyArray<SerialPort>, webContents: WebContents, callback: (portId: String) -> Unit) -> Unit)

Emitted when a serial port needs to be selected when a call to navigator.serial.requestPort is made. callback should be called with portId to be selected, passing an empty string to callback will cancel the request. Additionally, permissioning on navigator.serial can be managed by using ses.setPermissionCheckHandler(handler) with the serial permission.

fun on(event: SessionEvent.SELECT_USB_DEVICE, listener: (event: Event<*>, details: SelectUsbDeviceDetails, callback: (deviceId: String?) -> Unit) -> Unit)

Emitted when a USB device needs to be selected when a call to navigator.usb.requestDevice is made. callback should be called with deviceId to be selected; passing no arguments to callback will cancel the request. Additionally, permissioning on navigator.usb can be further managed by using ses.setPermissionCheckHandler(handler) and ses.setDevicePermissionHandler(handler).

fun on(event: SessionEvent.SERIAL_PORT_ADDED, listener: (event: Event<*>, port: SerialPort, webContents: WebContents) -> Unit)

Emitted after navigator.serial.requestPort has been called and select-serial-port has fired if a new serial port becomes available before the callback from select-serial-port is called. This event is intended for use when using a UI to ask users to pick a port so that the UI can be updated with the newly added port.

fun on(event: SessionEvent.SERIAL_PORT_REMOVED, listener: (event: Event<*>, port: SerialPort, webContents: WebContents) -> Unit)

Emitted after navigator.serial.requestPort has been called and select-serial-port has fired if a serial port has been removed before the callback from select-serial-port is called. This event is intended for use when using a UI to ask users to pick a port so that the UI can be updated to remove the specified port.

fun on(event: SessionEvent.SERIAL_PORT_REVOKED, listener: (event: Event<*>, details: SerialPortRevokedDetails) -> Unit)

Emitted after SerialPort.forget() has been called. This event can be used to help maintain persistent storage of permissions when setDevicePermissionHandler is used.

fun on(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_BEGIN, listener: (event: Event<*>, languageCode: String) -> Unit)

Emitted when a hunspell dictionary file starts downloading

fun on(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_FAILURE, listener: (event: Event<*>, languageCode: String) -> Unit)

Emitted when a hunspell dictionary file download fails. For details on the failure you should collect a netlog and inspect the download request.

fun on(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_SUCCESS, listener: (event: Event<*>, languageCode: String) -> Unit)

Emitted when a hunspell dictionary file has been successfully downloaded

fun on(event: SessionEvent.SPELLCHECK_DICTIONARY_INITIALIZED, listener: (event: Event<*>, languageCode: String) -> Unit)

Emitted when a hunspell dictionary file has been successfully initialized. This occurs after the file has been downloaded.

fun on(event: SessionEvent.USB_DEVICE_ADDED, listener: (event: Event<*>, device: USBDevice, webContents: WebContents) -> Unit)

Emitted after navigator.usb.requestDevice has been called and select-usb-device has fired if a new device becomes available before the callback from select-usb-device is called. This event is intended for use when using a UI to ask users to pick a device so that the UI can be updated with the newly added device.

fun on(event: SessionEvent.USB_DEVICE_REMOVED, listener: (event: Event<*>, device: USBDevice, webContents: WebContents) -> Unit)

Emitted after navigator.usb.requestDevice has been called and select-usb-device has fired if a device has been removed before the callback from select-usb-device is called. This event is intended for use when using a UI to ask users to pick a device so that the UI can be updated to remove the specified device.

fun on(event: SessionEvent.USB_DEVICE_REVOKED, listener: (event: Event<*>, details: UsbDeviceRevokedDetails) -> Unit)

Emitted after USBDevice.forget() has been called. This event can be used to help maintain persistent storage of permissions when setDevicePermissionHandler is used.

fun on(event: SessionEvent.WILL_DOWNLOAD, listener: (event: Event<*>, item: DownloadItem, webContents: WebContents) -> Unit)

Emitted when Electron is about to download item in webContents.

Link copied to clipboard
fun once(event: SessionEvent.EXTENSION_LOADED, listener: (event: Event<*>, extension: Extension) -> Unit)
fun once(event: SessionEvent.EXTENSION_READY, listener: (event: Event<*>, extension: Extension) -> Unit)
fun once(event: SessionEvent.EXTENSION_UNLOADED, listener: (event: Event<*>, extension: Extension) -> Unit)
fun once(event: SessionEvent.HID_DEVICE_ADDED, listener: (event: Event<*>, details: HidDeviceAddedDetails) -> Unit)
fun once(event: SessionEvent.HID_DEVICE_REMOVED, listener: (event: Event<*>, details: HidDeviceRemovedDetails) -> Unit)
fun once(event: SessionEvent.HID_DEVICE_REVOKED, listener: (event: Event<*>, details: HidDeviceRevokedDetails) -> Unit)
fun once(event: SessionEvent.PRECONNECT, listener: (event: Event<*>, preconnectUrl: String, allowCredentials: Boolean) -> Unit)
fun once(event: SessionEvent.SELECT_HID_DEVICE, listener: (event: Event<*>, details: SelectHidDeviceDetails, callback: (deviceId: String?) -> Unit) -> Unit)
fun once(event: SessionEvent.SELECT_SERIAL_PORT, listener: (event: Event<*>, ReadonlyArray<SerialPort>, webContents: WebContents, callback: (portId: String) -> Unit) -> Unit)
fun once(event: SessionEvent.SELECT_USB_DEVICE, listener: (event: Event<*>, details: SelectUsbDeviceDetails, callback: (deviceId: String?) -> Unit) -> Unit)
fun once(event: SessionEvent.SERIAL_PORT_ADDED, listener: (event: Event<*>, port: SerialPort, webContents: WebContents) -> Unit)
fun once(event: SessionEvent.SERIAL_PORT_REMOVED, listener: (event: Event<*>, port: SerialPort, webContents: WebContents) -> Unit)
fun once(event: SessionEvent.SERIAL_PORT_REVOKED, listener: (event: Event<*>, details: SerialPortRevokedDetails) -> Unit)
fun once(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_BEGIN, listener: (event: Event<*>, languageCode: String) -> Unit)
fun once(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_FAILURE, listener: (event: Event<*>, languageCode: String) -> Unit)
fun once(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_SUCCESS, listener: (event: Event<*>, languageCode: String) -> Unit)
fun once(event: SessionEvent.SPELLCHECK_DICTIONARY_INITIALIZED, listener: (event: Event<*>, languageCode: String) -> Unit)
fun once(event: SessionEvent.USB_DEVICE_ADDED, listener: (event: Event<*>, device: USBDevice, webContents: WebContents) -> Unit)
fun once(event: SessionEvent.USB_DEVICE_REMOVED, listener: (event: Event<*>, device: USBDevice, webContents: WebContents) -> Unit)
fun once(event: SessionEvent.USB_DEVICE_REVOKED, listener: (event: Event<*>, details: UsbDeviceRevokedDetails) -> Unit)
fun once(event: SessionEvent.WILL_DOWNLOAD, listener: (event: Event<*>, item: DownloadItem, webContents: WebContents) -> Unit)
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
fun removeListener(event: SessionEvent.EXTENSION_LOADED, listener: (event: Event<*>, extension: Extension) -> Unit)
fun removeListener(event: SessionEvent.EXTENSION_READY, listener: (event: Event<*>, extension: Extension) -> Unit)
fun removeListener(event: SessionEvent.EXTENSION_UNLOADED, listener: (event: Event<*>, extension: Extension) -> Unit)
fun removeListener(event: SessionEvent.HID_DEVICE_ADDED, listener: (event: Event<*>, details: HidDeviceAddedDetails) -> Unit)
fun removeListener(event: SessionEvent.HID_DEVICE_REMOVED, listener: (event: Event<*>, details: HidDeviceRemovedDetails) -> Unit)
fun removeListener(event: SessionEvent.HID_DEVICE_REVOKED, listener: (event: Event<*>, details: HidDeviceRevokedDetails) -> Unit)
fun removeListener(event: SessionEvent.PRECONNECT, listener: (event: Event<*>, preconnectUrl: String, allowCredentials: Boolean) -> Unit)
fun removeListener(event: SessionEvent.SELECT_HID_DEVICE, listener: (event: Event<*>, details: SelectHidDeviceDetails, callback: (deviceId: String?) -> Unit) -> Unit)
fun removeListener(event: SessionEvent.SELECT_SERIAL_PORT, listener: (event: Event<*>, ReadonlyArray<SerialPort>, webContents: WebContents, callback: (portId: String) -> Unit) -> Unit)
fun removeListener(event: SessionEvent.SELECT_USB_DEVICE, listener: (event: Event<*>, details: SelectUsbDeviceDetails, callback: (deviceId: String?) -> Unit) -> Unit)
fun removeListener(event: SessionEvent.SERIAL_PORT_ADDED, listener: (event: Event<*>, port: SerialPort, webContents: WebContents) -> Unit)
fun removeListener(event: SessionEvent.SERIAL_PORT_REMOVED, listener: (event: Event<*>, port: SerialPort, webContents: WebContents) -> Unit)
fun removeListener(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_BEGIN, listener: (event: Event<*>, languageCode: String) -> Unit)
fun removeListener(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_FAILURE, listener: (event: Event<*>, languageCode: String) -> Unit)
fun removeListener(event: SessionEvent.SPELLCHECK_DICTIONARY_DOWNLOAD_SUCCESS, listener: (event: Event<*>, languageCode: String) -> Unit)
fun removeListener(event: SessionEvent.SPELLCHECK_DICTIONARY_INITIALIZED, listener: (event: Event<*>, languageCode: String) -> Unit)
fun removeListener(event: SessionEvent.USB_DEVICE_ADDED, listener: (event: Event<*>, device: USBDevice, webContents: WebContents) -> Unit)
fun removeListener(event: SessionEvent.USB_DEVICE_REMOVED, listener: (event: Event<*>, device: USBDevice, webContents: WebContents) -> Unit)
fun removeListener(event: SessionEvent.USB_DEVICE_REVOKED, listener: (event: Event<*>, details: UsbDeviceRevokedDetails) -> Unit)
fun removeListener(event: SessionEvent.WILL_DOWNLOAD, listener: (event: Event<*>, item: DownloadItem, webContents: WebContents) -> Unit)
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): Promise<ResolvedHost>

Resolves with the resolved IP addresses for the host.

Link copied to clipboard

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?)

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
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: PermissionRequestHandlerHandlerDetails) -> 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

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

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

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

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.