Skip to main content

tauri_runtime_wry/
webview.rs

1// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
2// SPDX-License-Identifier: Apache-2.0
3// SPDX-License-Identifier: MIT
4
5#[cfg(any(
6  target_os = "linux",
7  target_os = "dragonfly",
8  target_os = "freebsd",
9  target_os = "netbsd",
10  target_os = "openbsd"
11))]
12mod imp {
13  pub type Webview = webkit2gtk::WebView;
14}
15
16#[cfg(target_vendor = "apple")]
17mod imp {
18  use std::ffi::c_void;
19
20  // These pointers are borrowed from ObjC `Retained` handles owned elsewhere and must
21  // not be mutated through. TODO: change these to `*const c_void` in v3 (breaking change).
22  pub struct Webview {
23    pub webview: *mut c_void,
24    pub manager: *mut c_void,
25    #[cfg(target_os = "macos")]
26    pub ns_window: *mut c_void,
27    #[cfg(target_os = "ios")]
28    pub view_controller: *mut c_void,
29  }
30}
31
32#[cfg(windows)]
33mod imp {
34  use webview2_com::Microsoft::Web::WebView2::Win32::{
35    ICoreWebView2Controller, ICoreWebView2Environment,
36  };
37  pub struct Webview {
38    pub controller: ICoreWebView2Controller,
39    pub environment: ICoreWebView2Environment,
40  }
41}
42
43#[cfg(target_os = "android")]
44mod imp {
45  use wry::JniHandle;
46  pub type Webview = JniHandle;
47}
48
49pub use imp::*;