Repository navigation
feat(webview2): Serve virtual host responses on Android - #25599
Draft
morning4coffe-dev wants to merge 4 commits into
Draft
morning4coffe-dev wants to merge 4 commits into
morning4coffe-dev wants to merge 4 commits into
Conversation
Decode an intercepted document as a browser would, insert the bridge and user scripts ahead of the first page script, and re-encode it as UTF-8 with a byte order mark. Also infer a request's resource context from the main-frame flag and its headers.
Raise WebResourceRequested on the UI thread and block the IO thread until handlers and deferrals complete (bounded), accept managed responses, infer the resource context from the request, and add document-created scripts, chrome.webview messaging and DOMContentLoaded on top of the shared bridge (BeforeParse for served documents, Late otherwise). NavigationCompleted now follows onPageFinished.
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.
Part of #25395. Stacked on #25594 (and through it #25593 and #25592): the base branch is
dev/doti/webview2-bridge-core, so only this PR's own commits are in the diff. This PR will be retargeted tomasteronce those merge. Work in progress, opened as a draft.Android's WebView already sees every request in
ShouldInterceptRequest, so the virtual host stayshttps://0.0.0.1/natively and nothing is rewritten (noISupportsCustomSchemeVirtualHostshere). What was missing is that a response could only be a native one, the event ran synchronously on the IO thread, andGetDeferraldid nothing.What it does
INativeWebResourceResponse(including the managed one fromCreateWebResourceResponse) is accepted throughWebResourceResponseSnapshotand turned into aWebResourceResponse; requests nobody answers load normally.ResourceContextDocument for main-frame navigations (helper with unit tests); request filters are honored.text/htmlresponses before the document is parsed (HtmlDocumentScriptInjector), and run on load for documents Uno does not intercept. This is isolated so thatWebViewCompat.addDocumentStartJavaScriptcan replace it if the dependency is accepted (open question on WebView2 on Skia: WebResourceRequested responses and the APIs BlazorWebView depends on are not implemented #25395).DOMContentLoadedandPostWebMessage*work through the bridge and the existingunoWebViewJavaScript interface.WebMessageReceived.Sourceis the WebView's current URL at message time (a JavaScript interface has no origin) and only the main frame is forwarded as far as the API allows.Verification
HtmlDocumentScriptInjectorandWebResourceContextHelpertests.Uno.UI.Runtime.Androidbuilds fornet10.0-android.Given_WebView2_VirtualHostResponses) compile but have not been executed: the local emulator did not start (the only available AVD is not usable on this machine), so nothing has been run on an Android WebView yet.Open
addJavascriptInterfaceis visible to every frame; the limits are documented.BlazorWebView.