Files
Electron.NET/src/ElectronNET.API/API/Entities/WebPreferences.cs

250 lines
11 KiB
C#
Raw Normal View History

using System.ComponentModel;
using System.Runtime.Versioning;
namespace ElectronNET.API.Entities
{
/// <summary>
///
/// </summary>
/// <remarks>Up-to-date with Electron API 39.2</remarks>
public class WebPreferences
{
/// <summary>
/// Whether to enable DevTools. If it is set to false, can not use
/// BrowserWindow.webContents.openDevTools() to open DevTools.Default is true.
/// </summary>
[DefaultValue(true)]
public bool DevTools { get; set; } = true;
/// <summary>
/// Whether node integration is enabled. Required to enable IPC. Default is true.
/// </summary>
[DefaultValue(true)]
public bool NodeIntegration { get; set; } = true;
/// <summary>
/// Whether node integration is enabled in web workers. Default is false.
/// </summary>
public bool NodeIntegrationInWorker { get; set; }
/// <summary>
/// Experimental option for enabling Node.js support in sub-frames such as iframes and child windows.
/// </summary>
public bool NodeIntegrationInSubFrames { get; set; }
/// <summary>
/// Specifies a script that will be loaded before other scripts run in the page.
/// This script will always have access to node APIs no matter whether node
/// integration is turned on or off.The value should be the absolute file path to
/// the script. When node integration is turned off, the preload script can
/// reintroduce Node global symbols back to the global scope.
/// </summary>
public string Preload { get; set; }
/// <summary>
/// If set, this will sandbox the renderer associated with the window, making it compatible with the Chromium OS-level sandbox and disabling the Node.js engine. This is not the same as the nodeIntegration option and the APIs available to the preload script are more limited. Default is true since Electron 20. The sandbox will automatically be disabled when nodeIntegration is set to true.
/// </summary>
public bool Sandbox { get; set; }
/// <summary>
/// Sets the session used by the page according to the session's partition string.
/// If partition starts with persist:, the page will use a persistent session
/// available to all pages in the app with the same partition.If there is no
/// persist: prefix, the page will use an in-memory session. By assigning the same
/// partition, multiple pages can share the same session.Default is the default
/// session.
/// </summary>
public string Partition { get; set; }
/// <summary>
/// The default zoom factor of the page, 3.0 represents 300%. Default is 1.0.
/// </summary>
[DefaultValue(1.0)]
public double ZoomFactor { get; set; } = 1.0;
/// <summary>
/// Enables JavaScript support. Default is true.
/// </summary>
[DefaultValue(true)]
public bool Javascript { get; set; } = true;
/// <summary>
/// When false, it will disable the same-origin policy (usually using testing
/// websites by people), and set allowRunningInsecureContent to true if this options
/// has not been set by user. Default is true.
/// </summary>
[DefaultValue(true)]
public bool WebSecurity { get; set; } = true;
/// <summary>
/// Allow an https page to run JavaScript, CSS or plugins from http URLs. Default is
/// false.
/// </summary>
public bool AllowRunningInsecureContent { get; set; }
/// <summary>
/// Enables image support. Default is true.
/// </summary>
[DefaultValue(true)]
public bool Images { get; set; } = true;
/// <summary>
/// Specifies how to run image animations (e.g. GIFs). Can be 'animate', 'animateOnce' or 'noAnimation'. Default is 'animate'.
/// </summary>
public string ImageAnimationPolicy { get; set; }
/// <summary>
/// Make TextArea elements resizable. Default is true.
/// </summary>
[DefaultValue(true)]
public bool TextAreasAreResizable { get; set; } = true;
/// <summary>
/// Enables WebGL support. Default is true.
/// </summary>
[DefaultValue(true)]
public bool Webgl { get; set; } = true;
/// <summary>
/// Enables WebAudio support. Default is true.
/// </summary>
[DefaultValue(true)]
public bool Webaudio { get; set; } = true;
/// <summary>
/// Whether plugins should be enabled. Default is false.
/// </summary>
public bool Plugins { get; set; }
/// <summary>
/// Enables Chromium's experimental features. Default is false.
/// </summary>
public bool ExperimentalFeatures { get; set; }
/// <summary>
/// Enables Chromium's experimental canvas features. Default is false.
/// </summary>
/// <remarks>Not documented by MCP electronjs web-preferences.</remarks>
public bool ExperimentalCanvasFeatures { get; set; }
/// <summary>
/// Enables scroll bounce (rubber banding) effect on macOS. Default is false.
/// </summary>
[SupportedOSPlatform("macos")]
public bool ScrollBounce { get; set; }
/// <summary>
/// A list of feature strings separated by ,, like CSSVariables,KeyboardEventKey to
/// enable.The full list of supported feature strings can be found in the file.
/// </summary>
public string EnableBlinkFeatures { get; set; }
/// <summary>
/// A list of feature strings separated by ,, like CSSVariables,KeyboardEventKey to
/// disable.The full list of supported feature strings can be found in the file.
/// </summary>
public string DisableBlinkFeatures { get; set; }
/// <summary>
/// Sets the default font for the font-family.
/// </summary>
public DefaultFontFamily DefaultFontFamily { get; set; }
/// <summary>
/// Defaults to 16.
/// </summary>
public int DefaultFontSize { get; set; } = 16;
/// <summary>
/// Defaults to 13.
/// </summary>
[DefaultValue(13)]
public int DefaultMonospaceFontSize { get; set; } = 13;
/// <summary>
/// Defaults to 0.
/// </summary>
[DefaultValue(0)]
public int MinimumFontSize { get; set; } = 0;
/// <summary>
/// Defaults to ISO-8859-1.
/// </summary>
/// <remarks>Not documented by MCP electronjs web-preferences.</remarks>
public string DefaultEncoding { get; set; }
/// <summary>
/// Whether to throttle animations and timers when the page becomes background. This
/// also affects the[Page Visibility API][#page-visibility]. Defaults to true.
/// </summary>
[DefaultValue(true)]
public bool BackgroundThrottling { get; set; } = true;
/// <summary>
/// Whether to enable offscreen rendering for the browser window. Defaults to false.
/// </summary>
public bool Offscreen { get; set; }
/// <summary>
/// Whether to run Electron APIs and the specified preload script in a separate
2020-05-21 22:39:52 +02:00
/// JavaScript context. Defaults to false. The context that the preload script runs
/// in will still have full access to the document and window globals but it will
/// use its own set of JavaScript builtins (Array, Object, JSON, etc.) and will be
/// isolated from any changes made to the global environment by the loaded page.The
/// Electron API will only be available in the preload script and not the loaded
/// page. This option should be used when loading potentially untrusted remote
/// content to ensure the loaded content cannot tamper with the preload script and
/// any Electron APIs being used. This option uses the same technique used by . You
/// can access this context in the dev tools by selecting the 'Electron Isolated
/// Context' entry in the combo box at the top of the Console tab. This option is
/// currently experimental and may change or be removed in future Electron releases.
/// </summary>
[DefaultValue(false)]
public bool ContextIsolation { get; set; } = false;
/// <summary>
/// Whether to use native window.open(). Defaults to false. This option is currently experimental.
/// </summary>
public bool NativeWindowOpen { get; set; }
/// <summary>
/// Whether to enable the Webview. Defaults to the value of the nodeIntegration option. The
/// preload script configured for the Webview will have node integration enabled
/// when it is executed so you should ensure remote/untrusted content is not able to
/// create a Webview tag with a possibly malicious preload script.You can use the
/// will-attach-webview event on to strip away the preload script and to validate or
/// alter the Webview's initial settings.
/// </summary>
/// <value>
/// <c>true</c> if [webview tag]; otherwise, <c>false</c>.
/// </value>
2019-05-16 03:13:35 +02:00
[DefaultValue(false)]
public bool WebviewTag { get; set; } = false;
/// <summary>
/// Whether to enable the remote module. Defaults to false.
/// </summary>
[DefaultValue(false)]
public bool EnableRemoteModule { get; set; } = false;
/// <summary>
/// Gets or sets a value indicating whether to enable preferred size mode. The preferred size is the minimum size needed to contain the layout of the document—without requiring scrolling. Enabling this will cause the 'preferred-size-changed' event to be emitted on the WebContents when the preferred size changes. Default is false.
/// </summary>
[DefaultValue(false)]
public bool EnablePreferredSizeMode { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to enable background transparency for the guest page. Default is true.
/// Note: The guest page's text and background colors are derived from the color scheme of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent.
/// </summary>
[DefaultValue(true)]
public bool Transparent { get; set; } = true;
/// <summary>
/// Gets or sets a value indicating whether to enable the 'paste' execCommand. Deprecated. Default is false.
/// </summary>
[DefaultValue(false)]
[System.Obsolete("enableDeprecatedPaste is deprecated in Electron; avoid using.")]
public bool EnableDeprecatedPaste { get; set; }
}
2025-11-15 08:05:31 +01:00
}