RestrictionAllowlist


@WebViewBuilder.Experimental
public final class RestrictionAllowlist


RestrictionAllowlist can be used to scope WebView behaviors to particular origin patterns.

Add a RestrictionAllowlist via addAllowlist. For example:

WebView webview = new WebViewBuilder(WebViewBuilder.PRESET_LEGACY)  .restrictJavaScriptInterfaces()  .addAllowlist(new RestrictionAllowlist.Builder(Set.of("https://example.com"))  .addJavaScriptInterface(someJavaScriptInterface, "myInterface")  .build())  .build();

This example creates a WebView where the addJavascriptInterface and removeJavascriptInterface APIs are disabled, but adds an allowlist that injects the someJavaScriptInterface object as window.myInterface into JavaScript only for frames with the https://example.com origin.

Summary

Nested types

public final class RestrictionAllowlist.Builder

RestrictionAllowlist builder.