Skip to content

Commit 1456f8e

Browse files
authored
fix: Allow downloads by default on linux/macos to match windows behavior (#1602)
1 parent 5399823 commit 1456f8e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
wry: patch
3+
---
4+
5+
Enabled all downloads by default to match WebView2 and browser behavior on all platforms. To disable this, provide a custom `download_started_handler`.

src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,8 @@ pub struct WebViewAttributes<'a> {
585585
/// second is a mutable `PathBuf` reference that (possibly) represents where the file will be downloaded to. The latter
586586
/// parameter can be used to set the download location by assigning a new path to it, the assigned path _must_ be
587587
/// absolute. The closure returns a `bool` to allow or deny the download.
588+
///
589+
/// [`Self::default()`] sets a handler allowing all downloads to match browser behavior.
588590
pub download_started_handler: Option<Box<dyn FnMut(String, &mut PathBuf) -> bool + 'static>>,
589591

590592
/// A download completion handler to manage downloads that have finished.
@@ -718,7 +720,7 @@ impl Default for WebViewAttributes<'_> {
718720
ipc_handler: None,
719721
drag_drop_handler: None,
720722
navigation_handler: None,
721-
download_started_handler: None,
723+
download_started_handler: Some(Box::new(|_, _| true)),
722724
download_completed_handler: None,
723725
new_window_req_handler: None,
724726
clipboard: false,
@@ -1159,6 +1161,8 @@ impl<'a> WebViewBuilder<'a> {
11591161
/// second is a mutable `PathBuf` reference that (possibly) represents where the file will be downloaded to. The latter
11601162
/// parameter can be used to set the download location by assigning a new path to it, the assigned path _must_ be
11611163
/// absolute. The closure returns a `bool` to allow or deny the download.
1164+
///
1165+
/// By default a handler that allows all downloads is set to match browser behavior.
11621166
pub fn with_download_started_handler(
11631167
mut self,
11641168
download_started_handler: impl FnMut(String, &mut PathBuf) -> bool + 'static,

0 commit comments

Comments
 (0)