Skip to main content

NavPolicy

Struct NavPolicy 

Source
pub struct NavPolicy {
    pub internal_hosts: Vec<String>,
    pub allow_loopback: bool,
    pub broker_host: Option<String>,
    pub popup_origins: Vec<String>,
    pub internal_schemes: Vec<String>,
}

Fields§

§internal_hosts: Vec<String>

Extra hosts served in place, e.g. an app’s own https://app.example surface.

§allow_loopback: bool

Allow localhost / loopback (Vite dev server). Defaults on only with the dev-overrides feature.

§broker_host: Option<String>

ViewRight-style broker host. https://<host>/?target=<url> navigates nothing and asks the shell to open target externally (only when target has an external scheme).

§popup_origins: Vec<String>

Origins (scheme://host[:port]) allowed to open popup windows in-app.

§internal_schemes: Vec<String>

Extra schemes the host serves as its own content, loaded in place like tauri: (a custom protocol registered by the app). Empty by default; add with NavPolicy::with_internal_scheme.

Implementations§

Source§

impl NavPolicy

Source

pub fn with_internal_scheme(self, scheme: &str) -> Result<Self, String>

This policy with scheme also loaded in place (see NavPolicy::internal_schemes). Errors on a malformed scheme or a web, script or file scheme. The built-in set is unchanged.

Source

pub fn decide(&self, url: &Url) -> NavDecision

Decide a top-level (or on_navigation) load.

Source

pub fn decide_window_open( &self, url: &Url, popup_shaped: bool, opener: Option<&Url>, ) -> WindowOpenDecision

Decide a page-initiated window.open / target=_blank. popup_shaped is true for a sized popup request; only those from a trusted opener to an allow-listed HTTPS origin become windows, everything else leaves for the browser. A non-web scheme is Deny; ask NavPolicy::protocol_consent_scheme whether it needs person consent.

Source

pub fn decide_window_open_pinned( &self, url: &Url, popup_shaped: bool, opener: Option<&Url>, pinned_origin: Option<&str>, ) -> WindowOpenDecision

NavPolicy::decide_window_open with the app’s pinned server origin (scheme://host[:port]). When pinned_origin is Some, a popup opens only when the opener’s origin equals it (an unknown opener is external); when None, an unknown opener defers to the origin allow-list and a known one must be served in place.

The scheme of a non-web window.open target (for example zoom: or ms-settings:) that an app with a consent surface may confirm with the person before handing it to the system. None for web schemes and for schemes the shell serves or refuses outright (internal, file:, javascript:). NavPolicy::decide_window_open returns Deny for every such target either way.

Trait Implementations§

Source§

impl Clone for NavPolicy

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 NavPolicy

Source§

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

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

impl Default for NavPolicy

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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,