Repository navigation
Added Download Policy - #1135
Merged
Merged
Conversation
Electron's will-download event requires preventDefault/setSavePath to be called synchronously, which the async bridge cannot do. Instead, .NET now sends a DownloadPolicy (blocked/allowed extensions, save directory, overwrite) to the host, which applies it synchronously in will-download. OnDownloadStarted, OnDownloadBlocked and OnDownloadDone notify .NET. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019sgeiSkC4w68XJ1ZFmPsqs
…into feature/download-policy
Closed
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Case-sensitive reservations can let concurrent downloads overwrite the same Windows file despite overwrite protection, and listener lifecycle defects plus missing allow-list rejection coverage remain unresolved.
4 open issues
1 file not reviewed
src/ElectronNET.Host/api/webContents.js: Generated file
What changed in this PR
Adds session-level download management to ElectronNET, connecting .NET policy configuration and lifecycle events to synchronous enforcement in the Electron host.
Changes:
- Adds extension allow/block lists, automatic save directories, and overwrite handling.
- Exposes download started, blocked, and completed events through the .NET API.
- Adds integration tests, usage documentation, and changelog entries.
| File | Description |
|---|---|
src/ElectronNET.IntegrationTests/Tests/SessionTests.cs |
Tests extension blocking and automatic file saving. |
src/ElectronNET.Host/api/webContents.ts |
Implements download policies, destination selection, and event forwarding. |
src/ElectronNET.Host/api/webContents.js.map |
Updates source mappings for the generated host code. |
src/ElectronNET.Host/api/webContents.js |
Includes the compiled download-management implementation. |
src/ElectronNET.API/API/Session.cs |
Exposes policy configuration and download events. |
src/ElectronNET.API/API/Entities/DownloadPolicy.cs |
Defines filtering, save-directory, and overwrite options. |
src/ElectronNET.API/API/Entities/DownloadInfo.cs |
Defines download metadata and completion states. |
docs/API/WebContents.md |
Documents policy configuration and event usage. |
Changelog.md |
Records download support and other API additions. |
Review effort: Balanced
pr-comment: Run #183
❌ Some tests failed!
Github Test Reporter by CTRF 💚 🔄 This comment has been updated |
- Synchronize download event handler changes with the bridge registration - Keep the session of a download registration so it can be removed after the window is gone, and drop registrations when the web contents are destroyed - Use case-insensitive save path reservations on Windows and macOS - Added test for downloads rejected by the allow-list Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019sgeiSkC4w68XJ1ZFmPsqs
…NET/Electron.NET into feature/download-policy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


This pull request introduces a comprehensive download management system to ElectronNET, allowing fine-grained control over file downloads at the Electron session level. The main changes include new APIs for blocking or allowing downloads by file extension, saving downloads to a specified directory, and emitting events for download lifecycle stages. These features are implemented in both the .NET and Electron host layers, with supporting documentation and changelog updates.