Skip to main content

CefWebviewAttributes

Struct CefWebviewAttributes 

Source
pub struct CefWebviewAttributes {
    pub offscreen: Option<Offscreen>,
    pub runtime_style: Option<RuntimeStyle>,
    pub frame_event_handler: Option<Arc<FrameEventHandler>>,
    pub console_message_handler: Option<Arc<ConsoleMessageHandler>>,
    pub allowed_chrome_commands: Vec<ChromeCommandGroup>,
    pub browser_settings_callback: Option<Arc<BrowserSettingsCallback>>,
}
Expand description

The CEF-specific webview attributes, set through WebviewWindowBuilderCefExt.

§Permission requests on CEF

The runtime honors WebviewAttributes::on_permission_request — an Allow grants without showing Chrome’s prompt, a Deny refuses without one — with three things worth knowing before relying on it.

§Most decisions are made once per origin and then persist

Chromium consults a permission prompt only while the stored content setting for that (origin, permission) still says “ask”, and answering the prompt persists the decision to the on-disk profile. Everything routed through the prompt therefore reaches the handler once per origin and permission, ever, including across restarts, and nothing calls back to say the app changed its mind: revoking a grant means rewriting the content setting through the request context.

Camera and microphone are the exception. Chromium routes every getUserMedia() call through the media path, so those two do reach the handler on each call and a changing answer is honored.

§Permissions Tauri has no kind for arrive as PermissionKind::Other

Chromium has more request types than Tauri has kinds. Storage access, FedCM, protocol handler registration, idle detection, local and loopback network access, web app installation, the WebXR sessions, hand tracking, keyboard lock and disk quota all arrive as PermissionKind::Other, as does any request type a future CEF build adds.

Failing closed is deliberate, but it means a handler written elsewhere as match kind { Camera => Allow, _ => Deny } hard-denies all of them here, and denying storage access or FedCM breaks third-party SSO flows outright. Return PermissionResponse::Default for the kinds you did not mean to answer about, and CEF’s own handling runs for them unchanged.

§PermissionKind::DisplayCapture is never granted by an Allow

A getDisplayMedia() request the handler answers Allow is handed back to CEF, which shows Chromium’s desktop media picker under Chrome style and refuses under Alloy style. A Deny still refuses it outright.

Granting it from the handler would grant everything: CEF builds the stream from the permission mask, and a desktop video bit with no requested source synthesises the full desktop and returns it with no picker at all. Since PermissionKind::DisplayCapture names no screen, window or tab, a blanket .on_permission_request(|_| PermissionResponse::Allow) would silently hand any page in the webview a full-desktop stream.

§Chrome accelerators an app window does not get

A Chrome style browser keeps its whole accelerator table live even hosted as a child view with no browser UI, so this runtime swallows the commands that have no meaning in an app window (new window and tab, the tab strip, history and downloads and settings, print, save page, view source, the omnibox focus commands). Any family of them can be kept with allow_chrome_commands; see ChromeCommandGroup for what each family covers. Two of the exclusions take away keystrokes users expect:

  • Zoom. WebviewAttributes::zoom_hotkeys_enabled is honored, and it defaults to false, so Ctrl+Plus, Ctrl+Minus and Ctrl+0 do not zoom unless the webview opted in. Ctrl+mouse wheel zoom is unaffected either way, since Chromium applies it in the render widget rather than through the command controller. On Linux and macOS Tauri also injects a JavaScript zoom polyfill when the flag is true, which coexists with Chrome’s own accelerator, so a keyboard zoom steps twice there. WebviewDispatch::set_zoom is untouched.

  • History. Alt+Left and Alt+Right do not navigate the session history. The browser is created at an internal placeholder URL and then navigated to the app’s own, so the app’s first screen already sits on a second history entry and going back from it lands on a blank page. The page context menu drops Back and Forward for the same reason. WebviewDispatch::go_back and go_forward are untouched, and an app that navigates its webview normally can take the accelerators back with ChromeCommandGroup::History.

Fields§

§offscreen: Option<Offscreen>

Windowless rendering and application-provided CEF callbacks.

§runtime_style: Option<RuntimeStyle>

The browser runtime style, see RuntimeStyle. CEF picks one when not set.

§frame_event_handler: Option<Arc<FrameEventHandler>>

Observer of the native lifecycle events of every frame of the webview.

Scoped to this webview’s own native browser — its main frame and its child frames. Every notification carries that one browser_id. A CEF-owned popup is a separate browser that navigates wherever its own content goes, and a FrameEvent carries the full URL, so popups are never reported here. Observe them through Webview::popups, whose FrameNavigationState follows a popup’s native lifecycle without exposing its URLs.

§console_message_handler: Option<Arc<ConsoleMessageHandler>>

Observer of the messages the renderer writes to the JavaScript console.

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.

§allowed_chrome_commands: Vec<ChromeCommandGroup>

Families of Chrome commands this webview keeps rather than swallows.

Empty by default, which blocks every group in ChromeCommandGroup.

§browser_settings_callback: Option<Arc<BrowserSettingsCallback>>

Last look at the cef::BrowserSettings before the browser is created.

Runs after the runtime has mapped the portable WebviewAttributes, so it can change what the runtime decided as well as set the fields that have no portable equivalent — the font families and sizes, remote_fonts, local_storage, databases, webgl, tab_to_links, javascript_dom_paste, default_encoding.

Trait Implementations§

Source§

impl AsCefWebviewAttributes for CefWebviewAttributes

Source§

fn as_cef_webview_attributes_mut(&mut self) -> Option<&mut CefWebviewAttributes>

Returns the CEF attributes, None when the attributes belong to another runtime.
Source§

impl Clone for CefWebviewAttributes

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CefWebviewAttributes

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CefWebviewAttributes

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, U> ConvertParam<U> for T
where T: Into<U>,

Source§

fn into_raw(self) -> U

Source§

impl<T, U> ConvertReturnValue<U> for T
where T: Into<U>,

Source§

fn wrap_result(self) -> U

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UserEvent for T
where T: Debug + Clone + Send + 'static,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more