feat: Implement WebResourceRequested event and filtering#22222
feat: Implement WebResourceRequested event and filtering#22222MartinZikmund merged 12 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements the WebResourceRequested event and filtering functionality for WebView2 across multiple platforms (Android, iOS, macOS, WASM, Windows). This feature allows applications to intercept and modify HTTP requests made by the WebView, enabling scenarios like custom header injection and request/response modification.
Key changes include:
- Cross-platform implementations with varying capabilities due to underlying platform WebView limitations
- JavaScript-based interception for iOS/macOS to inject headers into fetch/XMLHttpRequest calls
- Request re-fetching mechanism for Android with cookie synchronization
- Comprehensive event args, request, response, and header management classes
Reviewed changes
Copilot reviewed 34 out of 41 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
ISupportsWebResourceRequested.cs |
Defines interface for platform-specific WebResourceRequested implementations |
WebResourceFilter.cs |
Filter matching logic with wildcard URL pattern support |
CoreWebView2.cs |
Integration of WebResourceRequested event into CoreWebView2 API surface |
CoreWebView2WebResourceRequestedEventArgs.cs |
Cross-platform event args with platform-specific constructors |
CoreWebView2WebResourceRequest/Response.cs |
Request and response objects for event handling |
CoreWebView2HttpRequestHeaders/ResponseHeaders.cs |
Header manipulation with modification tracking |
UnoWKWebView.WebResourceRequested.iOSmacOS.cs |
iOS/macOS implementation using JavaScript injection for fetch/XHR |
NativeWebViewWrapper.WebResourceRequested.Android.cs |
Android implementation with request re-fetching and cookie sync |
MacOSNativeWebView.WebResourceRequested.cs |
macOS Skia implementation with cancel-and-reload pattern |
NativeWebView.WebResourceRequested.wasm.cs |
WASM implementation for iframe interception |
Win32NativeWebView.cs |
Windows Skia passthrough to native WebView2 |
UNOWebView.m/.h |
Native macOS callback integration |
WebView2_WebResourceRequested*.xaml/.cs |
Manual test samples |
WebView.md |
Comprehensive documentation with platform limitations table |
486a050 to
dca9457
Compare
|
|
|
The build 190266 found UI Test snapshots differences: Details
|
|
|
dca9457 to
a0a3bcb
Compare
|
|
|
The build 190432 found UI Test snapshots differences: Details
|
|
|
8f2fcde to
5124727
Compare
|
|
|
|
|
The build 190499 found UI Test snapshots differences: Details
|
|
|
|
|
…tibility - CoreWebView2: Match parameter name 'ResourceContext' (uppercase R) - CoreWebView2HttpRequestHeaders: Remove 'virtual' keyword to match non-virtual stubs No PackageDiffIgnore entries needed - signatures now match exactly.
d999a09 to
9e385a8
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 49 out of 56 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/Uno.UI/UI/Xaml/Controls/WebView/Native/Wasm/NativeCoreWebView2HttpRequestHeaders.wasm.cs:124
NativeCoreWebView2HttpRequestHeaders.wasm.csdeclaresNativeCoreWebView2HttpRequestHeadersunconditionally (no#if __WASM__ || WASM_SKIAguard), while Android and iOS/macOS define the same partial class in platform-guarded files. On Android/iOS builds this will result in duplicate member definitions for the same partial type and likely compilation errors. Please add the appropriate platform conditional (#if __WASM__ || WASM_SKIA/#endif) around this file’s implementation so that it is only compiled for the WASM targets, consistent with the other*.wasm.csfiles.
|
The build 191534 found UI Test snapshots differences: Details
|
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22222/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22222/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22222/docs/index.html |
|
The build 192475 found UI Test snapshots differences: Details
|
|
The build 192475 found UI Test snapshots differences: Details
|
|
The build 192475 found UI Test snapshots differences: Details
|
|
The build 192475 found UI Test snapshots differences: Details
|
|
|
|
The build 192475 found UI Test snapshots differences: Details
|
GitHub Issue: closes internal
PR Type:
What is the current behavior? 🤔
What is the new behavior? 🚀
PR Checklist ✅
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.