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.
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.