use crate::{net_job::NetJob, params::*, types::*, webview::WebView};
macro_rules! define_callback {
(
$(
$(#[$attr:meta])*
$name:ident: ($($arg:ty),*) $(-> $ret:ty)?
);* $(;)?
) => {
$(
$(#[$attr])*
pub trait $name: Fn($($arg),*) $(-> $ret)? + Send + 'static {}
impl<T> $name for T where T: Fn($($arg),*) $(-> $ret)? + Send + 'static {}
)*
};
}
define_callback!(
OnDownload: (&WebView, &DownloadParameters) -> bool;
OnDocumentReady: (&WebView, &WebFrameHandle);
OnNavigation: (&WebView, &NavigationParameters) -> bool;
OnCreateView: (&WebView, &CreateViewParameters) -> Option<WebView>
);
define_callback!(
OnQuery: (&WebView, &JsQueryParameters) -> JsQueryResult;
OnUrlChanged: (&WebView, &UrlChangedParameters);
OnTitleChanged: (&WebView, &str)
);
define_callback!(
OnAlertBox: (&WebView, &str);
OnConfirmBox: (&WebView, &str) -> bool;
OnPromptBox: (&WebView, &PromptParams) -> Option<String>
);
define_callback!(
OnClose: (&WebView) -> bool;
OnDestroy: (&WebView) -> bool
);
define_callback!(
OnLoadUrlBegin: (&WebView, &str, &NetJob) -> bool;
OnLoadUrlEnd: (&WebView, &str, &NetJob, &[u8])
);