Skip to main content

Module url_callback

Module url_callback 

Source
Expand description

Process-local URL callback channels for navigation handoff. Process-local URL callback channels for WebView navigation.

A caller that needs to observe a specific navigation — and receive its URL without loading it — opens a channel for that URL, then awaits it:

let mut callback = lingxia_webview::url_callback::open_channel("myapp://callback")?;
// ... drive the WebView, then:
let url = callback.recv().await; // "myapp://callback?..."

While a channel is open, any managed WebView navigation (or new-window request) whose URL matches the channel’s callback URL is cancelled instead of loading, and the full URL is delivered to the channel. The callback URL is a plain navigation-target string: no AppLink, OS custom-scheme registration, or scheme handler is involved.

Interception is process-wide — any web content able to navigate can hit the callback URL — so the caller should tie the delivered URL back to the flow that opened the channel (e.g. via a query parameter it planted) before trusting it.

Structs§

InvalidCallbackUrl
Error returned by open_channel for an unusable callback URL.
UrlCallbackChannel
Receives WebView navigations intercepted for its callback URL. Dropping the channel stops the interception.

Functions§

dispatch
Route a navigation URL to the most recently opened matching channel. Returns true when a channel took it, in which case the navigation must be cancelled. Managed WebViews dispatch automatically in handle_navigation; this is public for platform surfaces backed by a bare native WebView, whose navigation delegates must offer the URL themselves. Called for every navigation, so the no-channel path is one atomic load.
open_channel
Open a callback channel for callback_url, e.g. "myapp://callback".