Conversation
Implements the Acode-Foundation#2772 WebView API checklist: - incognito option (default true): never serves from the HTTP cache (LOAD_NO_CACHE) and clears navigation history + form data on destroy. Documented platform limits: the disk cache and CookieManager are app-wide singletons shared with the host app WebView, so they are intentionally left untouched — wiping them would evict the main app's own cache/cookies. - userAgent create option + setUserAgent() runtime action (JS bridge included) for per-instance User-Agent overrides; validated non-empty, stored and applied lazily for fullscreen instances. - New events over the existing message-callback channel: pageStarted, progressChanged (0..100), loadError ({url, code, description}, main-frame only) alongside pageFinished/titleChanged. Java is new-API guarded (WebResourceError paths only run on API 23+); the legacy onReceivedError overload is kept for older runtimes.
|
| public void onReceivedError( | ||
| WebView view, WebResourceRequest request, WebResourceError error | ||
| ) { | ||
| super.onReceivedError(view, request, error); |
There was a problem hiding this comment.
For a main-frame load failure, this modern callback delegates to the deprecated callback, which can emit loadError when the failing URL matches view.getUrl(). The modern callback then emits the same event again, causing subscribers to process one navigation failure twice.
Knowledge Base Used:
…t in managed API Fix duplicate loadError: WebViewClient's base onReceivedError(WebView, WebResourceRequest, WebResourceError) forwards main-frame errors to the deprecated overload via virtual dispatch, so the super call in the modern callback re-entered our deprecated override and emitted a second loadError for the same failure. The modern callback is now the canonical path (minSdk 26 guarantees API 23+): it no longer delegates and emits directly, exactly once. The deprecated overload remains as the pre-23 fallback and can no longer double-emit. Fix managed API gaps: webviewAPI.create() now forwards the incognito and userAgent options to the native bridge (matching the documented bridge options), and the WebView class exposes a setUserAgent(userAgent) setter that delegates to the native setUserAgent action.
Implements #2772 for the WebView plugin API:
incognitocreate option (default true):LOAD_NO_CACHE, clears navigation history and form data on destroy.userAgentcreate option plus asetUserAgent(id, ua)runtime action (native + JS bridge).pageStarted,progressChanged(0-100), andloadError({url, code, description}, main-frame only), alongsidepageFinished/titleChanged.Two honest notes:
CookieManagerand the WebView disk cache are app-wide singletons shared with the host app WebView, so this deliberately avoids wiping them. Documented in code and in the JS API docs.