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: boolAllow 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§
Sourcepub fn with_internal_scheme(self, scheme: &str) -> Result<Self, String>
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.
Sourcepub fn decide(&self, url: &Url) -> NavDecision
pub fn decide(&self, url: &Url) -> NavDecision
Decide a top-level (or on_navigation) load.
Sourcepub fn decide_window_open(
&self,
url: &Url,
popup_shaped: bool,
opener: Option<&Url>,
) -> WindowOpenDecision
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.
Sourcepub fn decide_window_open_pinned(
&self,
url: &Url,
popup_shaped: bool,
opener: Option<&Url>,
pinned_origin: Option<&str>,
) -> WindowOpenDecision
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.
Sourcepub fn protocol_consent_scheme(&self, url: &Url) -> Option<String>
pub fn protocol_consent_scheme(&self, url: &Url) -> Option<String>
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.