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_enabledis honored, and it defaults tofalse, 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_zoomis 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_backandgo_forwardare untouched, and an app that navigates its webview normally can take the accelerators back withChromeCommandGroup::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
impl AsCefWebviewAttributes for CefWebviewAttributes
Source§fn as_cef_webview_attributes_mut(&mut self) -> Option<&mut CefWebviewAttributes>
fn as_cef_webview_attributes_mut(&mut self) -> Option<&mut CefWebviewAttributes>
None when the attributes belong to another runtime.Source§impl Clone for CefWebviewAttributes
impl Clone for CefWebviewAttributes
Source§impl Debug for CefWebviewAttributes
impl Debug for CefWebviewAttributes
Auto Trait Implementations§
impl !RefUnwindSafe for CefWebviewAttributes
impl !UnwindSafe for CefWebviewAttributes
impl Freeze for CefWebviewAttributes
impl Send for CefWebviewAttributes
impl Sync for CefWebviewAttributes
impl Unpin for CefWebviewAttributes
impl UnsafeUnpin for CefWebviewAttributes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U> ConvertReturnValue<U> for Twhere
T: Into<U>,
impl<T, U> ConvertReturnValue<U> for Twhere
T: Into<U>,
fn wrap_result(self) -> U
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.