Skip to main content

WebviewWindowBuilderCefExt

Trait WebviewWindowBuilderCefExt 

Source
pub trait WebviewWindowBuilderCefExt {
    // Required methods
    fn browser_runtime_style(self, style: RuntimeStyle) -> Self;
    fn on_frame_event<F: Fn(FrameEvent) + Send + Sync + 'static>(
        self,
        handler: F,
    ) -> Self;
    fn on_console_message<F: Fn(ConsoleMessage) + Send + Sync + 'static>(
        self,
        handler: F,
    ) -> Self;
    fn allow_chrome_commands<I: IntoIterator<Item = ChromeCommandGroup>>(
        self,
        groups: I,
    ) -> Self;
    fn with_browser_settings<F: Fn(&mut BrowserSettings) + Send + Sync + 'static>(
        self,
        callback: F,
    ) -> Self;
}
Expand description

CEF-specific APIs of tauri::WebviewWindowBuilder.

Required Methods§

Source

fn browser_runtime_style(self, style: RuntimeStyle) -> Self

Sets the browser runtime style.

See RuntimeStyle for more information.

Source

fn on_frame_event<F: Fn(FrameEvent) + Send + Sync + 'static>( self, handler: F, ) -> Self

Observes native CEF lifecycle events for main and child frames.

The callback runs synchronously on CEF’s UI thread. It must return promptly and must not wait for an event-loop operation. This observer does not replace the navigation policy configured by on_navigation. It is scoped to this webview’s own native browser, so a CEF-owned popup is a separate browser that is never reported here — observe popups through Webview::popups.

Source

fn on_console_message<F: Fn(ConsoleMessage) + Send + Sync + 'static>( self, handler: F, ) -> Self

Observes the messages the renderer writes to the JavaScript console, without DevTools having to be open.

The callback runs synchronously on CEF’s UI thread, so it must return promptly and must not wait for an event-loop operation. Observing a message does not suppress it: CEF logs it as it normally would. It is scoped to this webview’s own native browser, so neither a CEF-owned popup’s output nor that of a DevTools window opened on this webview is reported here.

Source

fn allow_chrome_commands<I: IntoIterator<Item = ChromeCommandGroup>>( self, groups: I, ) -> Self

Keeps the named families of Chrome commands rather than swallowing them.

A Chrome style browser keeps its whole accelerator table live even hosted as a child view with no browser UI, so by default this runtime swallows the commands that have no meaning in an app window — new window and tab, the tab strip, history, downloads and settings, print, save page, view source, the omnibox focus commands. Naming a ChromeCommandGroup here lets that family run the way it would in a browser. Calling this more than once replaces the previous list.

DevTools and zoom accelerators are not covered here: they follow WebviewAttributes::devtools and WebviewAttributes::zoom_hotkeys_enabled.

use tauri_runtime_cef::WebviewWindowBuilderCefExt;
// Ctrl+P prints and Alt+Left goes back, as a user expects.
builder.allow_chrome_commands([ChromeCommandGroup::Document, ChromeCommandGroup::History]);
Source

fn with_browser_settings<F: Fn(&mut BrowserSettings) + Send + Sync + 'static>( self, callback: F, ) -> Self

Takes a last look at the CEF BrowserSettings before the browser is created.

The runtime maps the portable WebviewAttributes onto these settings first, so this can change what it decided as well as reach the fields Tauri has no attribute for: the font families and sizes, remote_fonts, local_storage, databases, webgl, tab_to_links, javascript_dom_paste and default_encoding.

use tauri_runtime_cef::WebviewWindowBuilderCefExt;
use tauri_runtime_cef::cef::{State, sys::cef_state_t};

// An app that ships its own fonts has no use for the ones a page asks for.
builder.with_browser_settings(|settings| {
  settings.remote_fonts = State::from(cef_state_t::STATE_DISABLED);
});

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilderCefExt for WebviewWindowBuilder<'a, R, M>

Source§

fn browser_runtime_style(self, style: RuntimeStyle) -> Self

Source§

fn on_frame_event<F: Fn(FrameEvent) + Send + Sync + 'static>( self, handler: F, ) -> Self

Source§

fn on_console_message<F: Fn(ConsoleMessage) + Send + Sync + 'static>( self, handler: F, ) -> Self

Source§

fn allow_chrome_commands<I: IntoIterator<Item = ChromeCommandGroup>>( self, groups: I, ) -> Self

Source§

fn with_browser_settings<F: Fn(&mut BrowserSettings) + Send + Sync + 'static>( self, callback: F, ) -> Self

Implementors§