Session
Properties
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.
A ServiceWorkers
object for this session.
A boolean
indicating whether builtin spell checker is enabled.
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
.
A WebRequest
object for this session.
Functions
Whether the word was successfully written to the custom dictionary. This API will not work on non-persistent (in-memory) sessions.
Dynamically sets whether to always send credentials for HTTP NTLM or Negotiate authentication.
resolves when the session’s HTTP authentication cache has been cleared.
resolves when the cache clear operation is complete.
resolves when the code cache clear operation is complete.
Resolves when the operation is complete.
resolves when the storage data has been cleared.
Resolves when all connections are closed.
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.
Disables any network emulation already active for the session
. Resets to the original network configuration.
Initiates a download of the resource at url
. The API will generate a DownloadItem that can be accessed with the will-download event.
Emulates network with the given configuration for the session
.
see Response.
Writes any unwritten DOMStorage data to disk.
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
.
A list of all loaded extensions.
resolves with blob data.
the session's current cache size, in bytes.
The loaded extension with the given ID.
an array of paths to preload scripts that have been registered.
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.
The absolute file system path where data for this session is persisted on disk. For in memory sessions this returns null
.
The user agent for this session.
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.
Whether the builtin spell checker is enabled.
An array of all words in app's custom dictionary. Resolves when the full dictionary is loaded from disk.
resolves when the extension is loaded.
Emitted after an extension is loaded. This occurs whenever an extension is added to the "enabled" set of extensions. This includes:
Emitted after an extension is loaded and all necessary browser state is initialized to support the start of the extension's background page.
Emitted after an extension is unloaded. This occurs when Session.removeExtension
is called.
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.
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.
Emitted after HIDDevice.forget()
has been called. This event can be used to help maintain persistent storage of permissions when setDevicePermissionHandler
is used.
Emitted when a render process requests preconnection to a URL, generally due to a resource hint.
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)
.
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.
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)
.
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.
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.
Emitted after SerialPort.forget()
has been called. This event can be used to help maintain persistent storage of permissions when setDevicePermissionHandler
is used.
Emitted when a hunspell dictionary file starts downloading
Emitted when a hunspell dictionary file download fails. For details on the failure you should collect a netlog and inspect the download request.
Emitted when a hunspell dictionary file has been successfully downloaded
Emitted when a hunspell dictionary file has been successfully initialized. This occurs after the file has been downloaded.
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.
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.
Emitted after USBDevice.forget()
has been called. This event can be used to help maintain persistent storage of permissions when setDevicePermissionHandler
is used.
Emitted when Electron is about to download item
in webContents
.
Preconnects the given number of sockets to an origin.
Unloads an extension.
Whether the word was successfully removed from the custom dictionary. This API will not work on non-persistent (in-memory) sessions.
Resolves with the resolved IP addresses for the host
.
Resolves with the proxy information for url
.
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)
.
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.
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.
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
.
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.
Sets download saving directory. By default, the download directory will be the Downloads
under the respective app folder.
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)
.
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.
Adds scripts that will be executed on ALL web contents that are associated with this session just before normal preload
scripts run.
Resolves when the proxy setting process is complete.
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.
Sets whether to enable the builtin spell checker.
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.
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.
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:
Overrides the userAgent
and acceptLanguages
for this session.