Skip to content

platform/electron/session-security

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.

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.

WebContents | null

string

string

PermissionCheckHandlerHandlerDetails

boolean

request(contents, permission, mediaTypes, requestingUrl): Promise<boolean>

Defined in: app/src/platform/electron/session-security.ts:22

Answers a request of a page.

WebContents

The page.

string

Electron’s name of the permission.

readonly string[]

For media, the devices that the page wants.

string

The address of the frame that asks, which can be an embedded one.

Promise<boolean>

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.

DisplayMediaRequestHandlerHandlerRequest

(streams) => void

void


Defined in: app/src/platform/electron/session-security.ts:81

Options for guardWebContents.

readonly optional blocksPopup?: (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.

string

WebContents

boolean

readonly isInternal: (contents) => boolean

Defined in: app/src/platform/electron/session-security.ts:83

Tells whether a WebContents belongs to the browser’s own UI.

WebContents

boolean

readonly logger: Logger

Defined in: app/src/platform/electron/session-security.ts:98

readonly openWindow: (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.

WebContents

The new page.

WebContents

The page whose script opened it.

The address, how the page asked for it, and the features of a popup.

string

string

string

void

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.

string

The default user agent.

string


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

App

The Electron app.

WebContentsGuardOptions

Callbacks into the window layer.

void


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.

Session

Any session.

PermissionHandler

Decides about the permissions of web pages.

void