From a33bbc70ae38e683a8c402f3f0855d9c531b87b9 Mon Sep 17 00:00:00 2001 From: lloydzhou Date: Wed, 25 Sep 2024 11:45:35 +0800 Subject: [PATCH 1/5] update --- src/webkitgtk/web_context.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/webkitgtk/web_context.rs b/src/webkitgtk/web_context.rs index ae7fe834b..624e5eaf7 100644 --- a/src/webkitgtk/web_context.rs +++ b/src/webkitgtk/web_context.rs @@ -41,10 +41,7 @@ impl WebContextImpl { if let Some(data_directory) = data.data_directory() { let data_manager = WebsiteDataManager::builder() .base_data_directory( - data_directory - .join("databases") - .join("indexeddb") - .to_string_lossy(), + data_directory.to_string_lossy(), ) .build(); if let Some(cookie_manager) = data_manager.cookie_manager() { From bab69f3623aed33eb3ee8e9a8e6a2c0d8367c957 Mon Sep 17 00:00:00 2001 From: Lloyd Zhou Date: Wed, 25 Sep 2024 18:31:33 +0800 Subject: [PATCH 2/5] Create fixed-data_directory-error-for-webkitgtk.md add change log --- .changes/fixed-data_directory-error-for-webkitgtk.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/fixed-data_directory-error-for-webkitgtk.md diff --git a/.changes/fixed-data_directory-error-for-webkitgtk.md b/.changes/fixed-data_directory-error-for-webkitgtk.md new file mode 100644 index 000000000..a0858e629 --- /dev/null +++ b/.changes/fixed-data_directory-error-for-webkitgtk.md @@ -0,0 +1,5 @@ +--- +"wry": patch +--- + +fixed: `data_directory` error for webkitgtk on linux From e5b4b7990bbce4041cb74137be81413f2d1c76c1 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Thu, 26 Sep 2024 05:26:26 +0300 Subject: [PATCH 3/5] Update .changes/fixed-data_directory-error-for-webkitgtk.md --- .changes/fixed-data_directory-error-for-webkitgtk.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changes/fixed-data_directory-error-for-webkitgtk.md b/.changes/fixed-data_directory-error-for-webkitgtk.md index a0858e629..b64495c82 100644 --- a/.changes/fixed-data_directory-error-for-webkitgtk.md +++ b/.changes/fixed-data_directory-error-for-webkitgtk.md @@ -2,4 +2,4 @@ "wry": patch --- -fixed: `data_directory` error for webkitgtk on linux +On Linux, fixed incorrect path for indexeddb database directory which made apps using `wry@0.24` and `tauri@1` migrating to `wry@>=0.38` and `tauri@2` lose their indexeddb data. From ee05c7403c4951e84e826e8e7f34c846a28f4e58 Mon Sep 17 00:00:00 2001 From: Justin Bennett Date: Wed, 25 Sep 2024 19:29:03 -0400 Subject: [PATCH 4/5] feat: add `WebView::load_html` for loading HTML after intialization (#1368) --- .changes/load-html.md | 5 +++++ src/android/main_pipe.rs | 7 +++++++ src/android/mod.rs | 5 +++++ src/lib.rs | 5 +++++ src/webkitgtk/mod.rs | 5 +++++ src/webview2/mod.rs | 5 +++++ src/wkwebview/mod.rs | 5 +++++ 7 files changed, 37 insertions(+) create mode 100644 .changes/load-html.md diff --git a/.changes/load-html.md b/.changes/load-html.md new file mode 100644 index 000000000..0cab0240f --- /dev/null +++ b/.changes/load-html.md @@ -0,0 +1,5 @@ +--- +"wry": minor +--- + +Add `Webview::load_html`. diff --git a/src/android/main_pipe.rs b/src/android/main_pipe.rs index ae7ebc460..37f5f8708 100644 --- a/src/android/main_pipe.rs +++ b/src/android/main_pipe.rs @@ -300,6 +300,12 @@ impl<'a> MainPipe<'a> { .call_method(webview, "clearAllBrowsingData", "()V", &[])?; } } + WebViewMessage::LoadHtml(html) => { + if let Some(webview) = &self.webview { + let html = self.env.new_string(html)?; + load_html(&mut self.env, webview.as_obj(), &html)?; + } + } } } Ok(()) @@ -369,6 +375,7 @@ pub(crate) enum WebViewMessage { GetUrl(Sender), Jni(Box), LoadUrl(String, Option), + LoadHtml(String), ClearAllBrowsingData, } diff --git a/src/android/mod.rs b/src/android/mod.rs index 401d25397..273117df8 100644 --- a/src/android/mod.rs +++ b/src/android/mod.rs @@ -351,6 +351,11 @@ impl InnerWebView { Ok(()) } + pub fn load_html(&self, html: &str) -> Result<()> { + MainPipe::send(WebViewMessage::LoadHtml(html.to_string())); + Ok(()) + } + pub fn clear_all_browsing_data(&self) -> Result<()> { MainPipe::send(WebViewMessage::ClearAllBrowsingData); Ok(()) diff --git a/src/lib.rs b/src/lib.rs index 3f052be27..d6fdb94f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1477,6 +1477,11 @@ impl WebView { self.webview.load_url_with_headers(url, headers) } + /// Load html content into the webview + pub fn load_html(&self, html: &str) -> Result<()> { + self.webview.load_html(html) + } + /// Clear all browsing data pub fn clear_all_browsing_data(&self) -> Result<()> { self.webview.clear_all_browsing_data() diff --git a/src/webkitgtk/mod.rs b/src/webkitgtk/mod.rs index e92ee5651..14583ddd2 100644 --- a/src/webkitgtk/mod.rs +++ b/src/webkitgtk/mod.rs @@ -673,6 +673,11 @@ impl InnerWebView { Ok(()) } + pub fn load_html(&self, html: &str) -> Result<()> { + self.webview.load_html(html, None); + Ok(()) + } + pub fn clear_all_browsing_data(&self) -> Result<()> { if let Some(context) = self.webview.context() { if let Some(data_manger) = context.website_data_manager() { diff --git a/src/webview2/mod.rs b/src/webview2/mod.rs index 2dfb53474..18ff184eb 100644 --- a/src/webview2/mod.rs +++ b/src/webview2/mod.rs @@ -1205,6 +1205,11 @@ impl InnerWebView { load_url_with_headers(&self.webview, &self.env, url, headers) } + pub fn load_html(&self, html: &str) -> Result<()> { + let html = HSTRING::from(html); + unsafe { self.webview.NavigateToString(&html) }.map_err(Into::into) + } + pub fn bounds(&self) -> Result { let mut bounds = Rect::default(); let mut rect = RECT::default(); diff --git a/src/wkwebview/mod.rs b/src/wkwebview/mod.rs index 752211a48..6ff79df70 100644 --- a/src/wkwebview/mod.rs +++ b/src/wkwebview/mod.rs @@ -1130,6 +1130,11 @@ r#"Object.defineProperty(window, 'ipc', { self.navigate_to_url(url, Some(headers)) } + pub fn load_html(&self, html: &str) -> crate::Result<()> { + self.navigate_to_string(html); + Ok(()) + } + pub fn clear_all_browsing_data(&self) -> Result<()> { unsafe { let config: id = msg_send![self.webview, configuration]; From 6e1ea71e99b399b9cad2aef347c02275eee53231 Mon Sep 17 00:00:00 2001 From: amrbashir Date: Thu, 26 Sep 2024 05:28:58 +0300 Subject: [PATCH 5/5] fmt --- src/webkitgtk/web_context.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/webkitgtk/web_context.rs b/src/webkitgtk/web_context.rs index 624e5eaf7..2971b033b 100644 --- a/src/webkitgtk/web_context.rs +++ b/src/webkitgtk/web_context.rs @@ -40,9 +40,7 @@ impl WebContextImpl { let mut context_builder = WebContext::builder(); if let Some(data_directory) = data.data_directory() { let data_manager = WebsiteDataManager::builder() - .base_data_directory( - data_directory.to_string_lossy(), - ) + .base_data_directory(data_directory.to_string_lossy()) .build(); if let Some(cookie_manager) = data_manager.cookie_manager() { cookie_manager.set_persistent_storage(