wry

Trait WebViewBuilderExtWindows

source
pub trait WebViewBuilderExtWindows {
    // Required methods
    fn with_additional_browser_args<S: Into<String>>(
        self,
        additional_args: S,
    ) -> Self;
    fn with_browser_accelerator_keys(self, enabled: bool) -> Self;
    fn with_theme(self, theme: Theme) -> Self;
    fn with_https_scheme(self, enabled: bool) -> Self;
    fn with_scroll_bar_style(self, style: ScrollBarStyle) -> Self;
    fn with_browser_extensions_enabled(self, enabled: bool) -> Self;
}

Required Methods§

source

fn with_additional_browser_args<S: Into<String>>( self, additional_args: S, ) -> Self

Pass additional args to WebView2 upon creating the webview.

§Warning
  • Webview instances with different browser arguments must also have different data directories.
  • By default wry passes --disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection --autoplay-policy=no-user-gesture-required if autoplay is enabled and --proxy-server=<scheme>://<host>:<port> if a proxy is set. so if you use this method, you have to add these arguments yourself if you want to keep the same behavior.
source

fn with_browser_accelerator_keys(self, enabled: bool) -> Self

Determines whether browser-specific accelerator keys are enabled. When this setting is set to false, it disables all accelerator keys that access features specific to a web browser. The default value is true. See the following link to know more details.

Setting to false does nothing on WebView2 Runtime version before 92.0.902.0, see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10824-prerelease

https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2settings#arebrowseracceleratorkeysenabled

source

fn with_theme(self, theme: Theme) -> Self

Specifies the theme of webview2. This affects things like prefers-color-scheme.

Defaults to Theme::Auto which will follow the OS defaults.

Requires WebView2 Runtime version 101.0.1210.39 or higher, does nothing on older versions, see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10121039

source

fn with_https_scheme(self, enabled: bool) -> Self

Determines whether the custom protocols should use https://<scheme>.path/to/page instead of the default http://<scheme>.path/to/page.

Using a http scheme will allow mixed content when trying to fetch http endpoints and is therefore less secure but will match the behavior of the <scheme>://path/to/page protocols used on macOS and Linux.

The default value is false.

source

fn with_scroll_bar_style(self, style: ScrollBarStyle) -> Self

Specifies the native scrollbar style to use with webview2. CSS styles that modify the scrollbar are applied on top of the native appearance configured here.

Defaults to [ScrollbarStyle::Default] which is the browser default used by Microsoft Edge.

Requires WebView2 Runtime version 125.0.2535.41 or higher, does nothing on older versions, see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/?tabs=dotnetcsharp#10253541

source

fn with_browser_extensions_enabled(self, enabled: bool) -> Self

Determines whether the ability to install and enable extensions is enabled.

By default, extensions are disabled.

Requires WebView2 Runtime version 1.0.2210.55 or higher, does nothing on older versions, see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/archive?tabs=dotnetcsharp#10221055

Object Safety§

This trait is not object safe.

Implementors§