Skip to content

Added Download Policy - #1135

Merged
FlorianRappl merged 6 commits into
developfrom
feature/download-policy
Nov 27, 2026
Merged

FlorianRappl merged 6 commits into
developfrom
feature/download-policy

Conversation

@FlorianRappl

Copy link
Copy Markdown
Collaborator

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.

FlorianRappl and others added 3 commits November 26, 2026 17:04
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
@FlorianRappl FlorianRappl added this to the 0.7.0 milestone Nov 26, 2026
@FlorianRappl FlorianRappl linked an issue Nov 26, 2026 that may be closed by this pull request
@FlorianRappl
FlorianRappl requested a balanced review from Copilot November 26, 2026 16:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread src/ElectronNET.Host/api/webContents.ts Resolved
Comment thread src/ElectronNET.API/API/Session.cs Resolved
Comment thread src/ElectronNET.Host/api/webContents.ts Resolved
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

pr-comment: Run #183

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
1800 1659 1 0 0 140 0 2m 25s

❌ Some tests failed!

Name Failure Message
❌ WebContentsTests - GetSetZoomLevel_check Expected ok to be 2.0, but found 0.0 (difference of -2).

Github Test Reporter by CTRF 💚

🔄 This comment has been updated

FlorianRappl and others added 2 commits November 27, 2026 07:54
- 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
@FlorianRappl
FlorianRappl merged commit 44ba85b into develop Nov 27, 2026
28 of 30 checks passed
@FlorianRappl
FlorianRappl deleted the feature/download-policy branch November 27, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent downloads

2 participants