platform/electron/session-security
Interfaces
Section titled “Interfaces”PermissionHandler
Section titled “PermissionHandler”Defined in: app/src/platform/electron/session-security.ts:14
Decides about the permissions of the pages of a session, asking the user where needed.
Methods
Section titled “Methods”check()
Section titled “check()”check(
contents,permission,requestingOrigin,details):boolean
Defined in: app/src/platform/electron/session-security.ts:29
Whether a page has a permission already, for checks such as Notification.permission.
Parameters
Section titled “Parameters”contents
Section titled “contents”WebContents | null
permission
Section titled “permission”string
requestingOrigin
Section titled “requestingOrigin”string
details
Section titled “details”PermissionCheckHandlerHandlerDetails
Returns
Section titled “Returns”boolean
request()
Section titled “request()”request(
contents,permission,mediaTypes,requestingUrl):Promise<boolean>
Defined in: app/src/platform/electron/session-security.ts:22
Answers a request of a page.
Parameters
Section titled “Parameters”contents
Section titled “contents”WebContents
The page.
permission
Section titled “permission”string
Electron’s name of the permission.
mediaTypes
Section titled “mediaTypes”readonly string[]
For media, the devices that the page wants.
requestingUrl
Section titled “requestingUrl”string
The address of the frame that asks, which can be an embedded one.
Returns
Section titled “Returns”Promise<boolean>
shareScreen()
Section titled “shareScreen()”shareScreen(
request,callback):void
Defined in: app/src/platform/electron/session-security.ts:36
Answers a page that wants to share the screen or a window.
Parameters
Section titled “Parameters”request
Section titled “request”DisplayMediaRequestHandlerHandlerRequest
callback
Section titled “callback”(streams) => void
Returns
Section titled “Returns”void
WebContentsGuardOptions
Section titled “WebContentsGuardOptions”Defined in: app/src/platform/electron/session-security.ts:81
Options for guardWebContents.
Properties
Section titled “Properties”blocksPopup?
Section titled “blocksPopup?”
readonlyoptionalblocksPopup?: (url,opener) =>boolean
Defined in: app/src/platform/electron/session-security.ts:97
Tells whether a popup that a page opens is blocked, such as by the content blocker.
Parameters
Section titled “Parameters”string
opener
Section titled “opener”WebContents
Returns
Section titled “Returns”boolean
isInternal
Section titled “isInternal”
readonlyisInternal: (contents) =>boolean
Defined in: app/src/platform/electron/session-security.ts:83
Tells whether a WebContents belongs to the browser’s own UI.
Parameters
Section titled “Parameters”contents
Section titled “contents”WebContents
Returns
Section titled “Returns”boolean
logger
Section titled “logger”
readonlylogger:Logger
Defined in: app/src/platform/electron/session-security.ts:98
openWindow
Section titled “openWindow”
readonlyopenWindow: (contents,opener,request) =>void
Defined in: app/src/platform/electron/session-security.ts:91
Shows the page that a script opened, which Chromium made with the opener, in a tab or, for a popup, in a window of its own.
Parameters
Section titled “Parameters”contents
Section titled “contents”WebContents
The new page.
opener
Section titled “opener”WebContents
The page whose script opened it.
request
Section titled “request”The address, how the page asked for it, and the features of a popup.
disposition
Section titled “disposition”string
features
Section titled “features”string
string
Returns
Section titled “Returns”void
Functions
Section titled “Functions”cleanUserAgent()
Section titled “cleanUserAgent()”cleanUserAgent(
userAgent):string
Defined in: app/src/platform/electron/session-security.ts:166
Builds a user agent without the app and Electron tokens, so sites see a plain Chromium.
Parameters
Section titled “Parameters”userAgent
Section titled “userAgent”string
The default user agent.
Returns
Section titled “Returns”string
guardWebContents()
Section titled “guardWebContents()”guardWebContents(
app,options):void
Defined in: app/src/platform/electron/session-security.ts:111
Applies navigation and window guards to every WebContents that is created:
<webview>is never attached.- Pages cannot open free windows: what a script opens becomes a tab, or a popup window of the browser, and keeps its opener.
- The browser’s own views never leave their
app://origin. - Web content never navigates to
app://.
Parameters
Section titled “Parameters”App
The Electron app.
options
Section titled “options”Callbacks into the window layer.
Returns
Section titled “Returns”void
hardenSession()
Section titled “hardenSession()”hardenSession(
session,permissions?):void
Defined in: app/src/platform/electron/session-security.ts:50
Hardens a session: permission requests and checks go to the handler, or are refused without one, as for the browser’s own pages; device access is denied and spellchecking is switched off on Windows and Linux, because it would download dictionaries from a third-party server. Electron grants everything by default, so this runs on every session.
Parameters
Section titled “Parameters”session
Section titled “session”Session
Any session.
permissions?
Section titled “permissions?”Decides about the permissions of web pages.
Returns
Section titled “Returns”void