#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
mod imp {
pub struct Webview {
webview: webkit2gtk::WebView,
}
impl Webview {
pub(crate) fn new(webview: webkit2gtk::WebView) -> Self {
Self { webview }
}
pub fn inner(&self) -> webkit2gtk::WebView {
self.webview.clone()
}
}
}
#[cfg(target_vendor = "apple")]
mod imp {
use std::ffi::c_void;
pub struct Webview {
webview: *const c_void,
manager: *const c_void,
#[cfg(target_os = "macos")]
ns_window: *const c_void,
#[cfg(target_os = "ios")]
view_controller: *const c_void,
}
impl Webview {
pub(crate) fn new(
webview: *const c_void,
manager: *const c_void,
#[cfg(target_os = "macos")] ns_window: *const c_void,
#[cfg(target_os = "ios")] view_controller: *const c_void,
) -> Self {
Self {
webview,
manager,
#[cfg(target_os = "macos")]
ns_window,
#[cfg(target_os = "ios")]
view_controller,
}
}
pub fn inner(&self) -> *const c_void {
self.webview
}
pub fn controller(&self) -> *const c_void {
self.manager
}
#[cfg(target_os = "macos")]
pub fn ns_window(&self) -> *const c_void {
self.ns_window
}
#[cfg(target_os = "ios")]
pub fn view_controller(&self) -> *const c_void {
self.view_controller
}
}
}
#[cfg(windows)]
mod imp {
use webview2_com::Microsoft::Web::WebView2::Win32::{
ICoreWebView2Controller, ICoreWebView2Environment,
};
pub struct Webview {
controller: ICoreWebView2Controller,
environment: ICoreWebView2Environment,
}
impl Webview {
pub(crate) fn new(
controller: ICoreWebView2Controller,
environment: ICoreWebView2Environment,
) -> Self {
Self {
controller,
environment,
}
}
pub fn controller(&self) -> ICoreWebView2Controller {
self.controller.clone()
}
pub fn environment(&self) -> ICoreWebView2Environment {
self.environment.clone()
}
}
}
#[cfg(target_os = "android")]
mod imp {
use wry::JniHandle;
pub struct Webview {
handle: JniHandle,
}
impl Webview {
pub(crate) fn new(handle: JniHandle) -> Self {
Self { handle }
}
pub fn jni_handle(&self) -> JniHandle {
self.handle
}
}
}
pub use imp::*;