pub struct ExtensionRegistry { /* private fields */ }Expand description
Registry of active extensions for an app instance.
Built from the app’s manifest permissions and stored on the SPA tab. The registry owns the extension objects and provides the glue between the native WKScriptMessageHandler callbacks and each extension’s handler.
Implementations§
Source§impl ExtensionRegistry
impl ExtensionRegistry
pub fn new() -> Self
Sourcepub fn register(&mut self, ext: Box<dyn HostExtension>)
pub fn register(&mut self, ext: Box<dyn HostExtension>)
Register an extension.
Sourcepub fn extensions(&self) -> &[Box<dyn HostExtension>]
pub fn extensions(&self) -> &[Box<dyn HostExtension>]
Get all registered extensions.
Sourcepub fn combined_inject_script(&self) -> String
pub fn combined_inject_script(&self) -> String
Returns the concatenated JS injection scripts for all registered extensions.
Inject this string into the WebView after HOST_API_BRIDGE_SCRIPT so
that window.host.ext is populated before the SPA’s own scripts run.
Sourcepub fn channels(&self) -> Vec<&str>
pub fn channels(&self) -> Vec<&str>
Returns all channel names that need WKScriptMessageHandler registration.
Sourcepub fn dispatch(
&self,
channel: &str,
method: &str,
params: &str,
) -> Option<String>
pub fn dispatch( &self, channel: &str, method: &str, params: &str, ) -> Option<String>
Find extensions by channel name and dispatch a message to the first one that claims the method.
Returns the serialized JSON result, or None for fire-and-forget
messages and unknown channels.
Sourcepub fn drain_events(&self) -> Vec<HostPushEvent>
pub fn drain_events(&self) -> Vec<HostPushEvent>
Drain queued push events from all registered extensions.