-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[HybridWebView] Add the ability to intercept all web resource requests #28876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Files not reviewed (1)
- src/Controls/tests/DeviceTests/Resources/Raw/HybridTestRoot/index.html: Language not supported
Comments suppressed due to low confidence (2)
src/Core/src/Handlers/HybridWebView/HybridWebViewHandler.Windows.cs:241
- Switching to a universal filter '*' may intercept more requests than intended, including external resources. Consider verifying that this change does not introduce performance impacts or unintended side effects.
webView.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.All);
src/Controls/samples/Controls.Sample/Pages/Controls/HybridWebViewPage.xaml.cs:22
- [nitpick] The string literal 'badthing' is used directly in the condition; consider extracting it into a named constant to improve readability and ensure consistency.
if (e.PlatformArgs.WebResourceRequestedEventArgs.Request.Uri.Contains("badthing", StringComparison.InvariantCultureIgnoreCase))
Maybe if we land this, we won't need a "proxy" endpoint as all endpoints will become proxy-able: #25867 |
bb61da6
to
91f3bb2
Compare
a0103f5
to
a6bc950
Compare
b5635ad
to
41ba062
Compare
41ba062
to
9b25d52
Compare
/backport to release/10.0.1xx-preview4 |
Started backporting to release/10.0.1xx-preview4: https://github.com/dotnet/maui/actions/runs/14839378964 |
9b25d52
to
ff05a43
Compare
a2ecaa0
to
a0483ab
Compare
/rebase |
a0483ab
to
189ed00
Compare
/rebase |
189ed00
to
0c3297e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test failures are unrelated |
Description of Change
Note
I have created demo repo with the NuGet packages from the PR (but for .NET 9)
https://github.com/mattleibow/MauiHybridWebViewInterceptionDemo
Intercepting requests before they leave the browser will allow for the addition of headers as well as cancellation of the requests.
The API is only really fully shapeable once all the platforms are complete as each platform is really different, but the idea I have right now is a mix of all the platforms.
Tasks
Issues Fixed
Fixes #11382
Implementation Restrictions
http
andhttps
requests:https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/seturlschemehandler(_:forurlscheme:)#parameters
1
Notes:
1
: I seem to not get the event to fire but this is maybe because the WebView2 in .NET MAUI is a bit older that the fix. The [Windows] Upgrade to Windows App SDK 1.7 #28499 PR should update things.