navigationDelegate property
A delegate function that decides how to handle navigation actions.
When a navigation is initiated by the WebView (e.g when a user clicks a link) this delegate is called and has to decide how to proceed with the navigation.
See NavigationDecision for possible decisions the delegate can take.
When null all navigation actions are allowed.
Caveats on Android:
- Navigation actions targeted to the main frame can be intercepted, navigation actions targeted to subframes are allowed regardless of the value returned by this delegate.
- Setting a navigationDelegate makes the WebView treat all navigations as if they were triggered by a user gesture, this disables some of Chromium's security mechanisms. A navigationDelegate should only be set when loading trusted content.
- On Android WebView versions earlier than 67(most devices running at least Android L+ should have
a later version):
- When a navigationDelegate is set pages with frames are not properly handled by the webview, and frames will be opened in the main frame.
- When a navigationDelegate is set HTTP requests do not include the HTTP referer header.
Implementation
final NavigationDelegate? navigationDelegate;