Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/allow-downloads-default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
wry: patch
---

Enabled all downloads by default to match WebView2 and browser behavior on all platforms. To disable this, provide a custom `download_started_handler`.
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,8 @@ pub struct WebViewAttributes<'a> {
/// second is a mutable `PathBuf` reference that (possibly) represents where the file will be downloaded to. The latter
/// parameter can be used to set the download location by assigning a new path to it, the assigned path _must_ be
/// absolute. The closure returns a `bool` to allow or deny the download.
///
/// [`Self::default()`] sets a handler allowing all downloads to match browser behavior.
pub download_started_handler: Option<Box<dyn FnMut(String, &mut PathBuf) -> bool + 'static>>,

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