@@ -37,8 +37,7 @@ use crate::{
3737 ipc:: { CommandArg , CommandItem , InvokeError , OwnedInvokeResponder } ,
3838 manager:: AppManager ,
3939 sealed:: { ManagerBase , RuntimeOrDispatch } ,
40- webview:: PageLoadPayload ,
41- webview:: WebviewBuilder ,
40+ webview:: { Cookie , PageLoadPayload , WebviewBuilder } ,
4241 window:: WindowBuilder ,
4342 AppHandle , Event , EventId , Manager , Runtime , Webview , WindowEvent ,
4443} ;
@@ -61,8 +60,8 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
6160 ///
6261 /// # Known issues
6362 ///
64- /// On Windows, this function deadlocks when used in a synchronous command, see [the Webview2 issue].
65- /// You should use `async` commands when creating windows.
63+ /// On Windows, this function deadlocks when used in a synchronous command and event handlers , see [the Webview2 issue].
64+ /// You should use `async` commands and separate threads when creating windows.
6665 ///
6766 /// # Examples
6867 ///
@@ -118,8 +117,8 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
118117 ///
119118 /// # Known issues
120119 ///
121- /// On Windows, this function deadlocks when used in a synchronous command, see [the Webview2 issue].
122- /// You should use `async` commands when creating windows.
120+ /// On Windows, this function deadlocks when used in a synchronous command or event handlers , see [the Webview2 issue].
121+ /// You should use `async` commands and separate threads when creating windows.
123122 ///
124123 /// # Examples
125124 ///
@@ -2043,6 +2042,52 @@ impl<R: Runtime> WebviewWindow<R> {
20432042 pub fn clear_all_browsing_data ( & self ) -> crate :: Result < ( ) > {
20442043 self . webview . clear_all_browsing_data ( )
20452044 }
2045+
2046+ /// Returns all cookies in the runtime's cookie store including HTTP-only and secure cookies.
2047+ ///
2048+ /// Note that cookies will only be returned for URLs with an http or https scheme.
2049+ /// Cookies set through javascript for local files
2050+ /// (such as those served from the tauri://) protocol are not currently supported.
2051+ ///
2052+ /// # Stability
2053+ ///
2054+ /// The return value of this function leverages [`tauri_runtime::Cookie`] which re-exports the cookie crate.
2055+ /// This dependency might receive updates in minor Tauri releases.
2056+ ///
2057+ /// # Known issues
2058+ ///
2059+ /// On Windows, this function deadlocks when used in a synchronous command or event handlers, see [the Webview2 issue].
2060+ /// You should use `async` commands and separate threads when reading cookies.
2061+ ///
2062+ /// [the Webview2 issue]: https://github.com/tauri-apps/wry/issues/583
2063+ pub fn cookies_for_url ( & self , url : Url ) -> crate :: Result < Vec < Cookie < ' static > > > {
2064+ self . webview . cookies_for_url ( url)
2065+ }
2066+
2067+ /// Returns all cookies in the runtime's cookie store for all URLs including HTTP-only and secure cookies.
2068+ ///
2069+ /// Note that cookies will only be returned for URLs with an http or https scheme.
2070+ /// Cookies set through javascript for local files
2071+ /// (such as those served from the tauri://) protocol are not currently supported.
2072+ ///
2073+ /// # Stability
2074+ ///
2075+ /// The return value of this function leverages [`tauri_runtime::Cookie`] which re-exports the cookie crate.
2076+ /// This dependency might receive updates in minor Tauri releases.
2077+ ///
2078+ /// # Known issues
2079+ ///
2080+ /// On Windows, this function deadlocks when used in a synchronous command or event handlers, see [the Webview2 issue].
2081+ /// You should use `async` commands and separate threads when reading cookies.
2082+ ///
2083+ /// ## Platform-specific
2084+ ///
2085+ /// - **Android**: Unsupported, always returns an empty [`Vec`].
2086+ ///
2087+ /// [the Webview2 issue]: https://github.com/tauri-apps/wry/issues/583
2088+ pub fn cookies ( & self ) -> crate :: Result < Vec < Cookie < ' static > > > {
2089+ self . webview . cookies ( )
2090+ }
20462091}
20472092
20482093impl < R : Runtime > Listener < R > for WebviewWindow < R > {
0 commit comments