diff --git a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md index 403294ee39f..44f60d72f46 100644 --- a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md +++ b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md @@ -1,5 +1,7 @@ -## NEXT +## 3.16.0 +* Adds onReceivedHttpError WebViewClient callback to support + `PlatformNavigationDelegate.onHttpError`. * Updates minimum supported SDK version to Flutter 3.13/Dart 3.1. * Updates compileSdk to 34. diff --git a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/GeneratedAndroidWebView.java b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/GeneratedAndroidWebView.java index 0d0d37e5d3d..cfdadec4014 100644 --- a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/GeneratedAndroidWebView.java +++ b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/GeneratedAndroidWebView.java @@ -316,6 +316,58 @@ ArrayList toList() { } } + /** Generated class from Pigeon that represents data sent in messages. */ + public static final class WebResourceResponseData { + private @NonNull Long statusCode; + + public @NonNull Long getStatusCode() { + return statusCode; + } + + public void setStatusCode(@NonNull Long setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"statusCode\" is null."); + } + this.statusCode = setterArg; + } + + /** Constructor is non-public to enforce null safety; use Builder. */ + WebResourceResponseData() {} + + public static final class Builder { + + private @Nullable Long statusCode; + + public @NonNull Builder setStatusCode(@NonNull Long setterArg) { + this.statusCode = setterArg; + return this; + } + + public @NonNull WebResourceResponseData build() { + WebResourceResponseData pigeonReturn = new WebResourceResponseData(); + pigeonReturn.setStatusCode(statusCode); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(1); + toListResult.add(statusCode); + return toListResult; + } + + static @NonNull WebResourceResponseData fromList(@NonNull ArrayList list) { + WebResourceResponseData pigeonResult = new WebResourceResponseData(); + Object statusCode = list.get(0); + pigeonResult.setStatusCode( + (statusCode == null) + ? null + : ((statusCode instanceof Integer) ? (Integer) statusCode : (Long) statusCode)); + return pigeonResult; + } + } + /** Generated class from Pigeon that represents data sent in messages. */ public static final class WebResourceErrorData { private @NonNull Long errorCode; @@ -2388,6 +2440,8 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { return WebResourceErrorData.fromList((ArrayList) readValue(buffer)); case (byte) 129: return WebResourceRequestData.fromList((ArrayList) readValue(buffer)); + case (byte) 130: + return WebResourceResponseData.fromList((ArrayList) readValue(buffer)); default: return super.readValueOfType(type, buffer); } @@ -2401,6 +2455,9 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { } else if (value instanceof WebResourceRequestData) { stream.write(129); writeValue(stream, ((WebResourceRequestData) value).toList()); + } else if (value instanceof WebResourceResponseData) { + stream.write(130); + writeValue(stream, ((WebResourceResponseData) value).toList()); } else { super.writeValue(stream, value); } @@ -2455,6 +2512,23 @@ public void onPageFinished( channelReply -> callback.reply(null)); } + public void onReceivedHttpError( + @NonNull Long instanceIdArg, + @NonNull Long webViewInstanceIdArg, + @NonNull WebResourceRequestData requestArg, + @NonNull WebResourceResponseData responseArg, + @NonNull Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.webview_flutter_android.WebViewClientFlutterApi.onReceivedHttpError", + getCodec()); + channel.send( + new ArrayList( + Arrays.asList(instanceIdArg, webViewInstanceIdArg, requestArg, responseArg)), + channelReply -> callback.reply(null)); + } + public void onReceivedRequestError( @NonNull Long instanceIdArg, @NonNull Long webViewInstanceIdArg, diff --git a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewClientFlutterApiImpl.java b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewClientFlutterApiImpl.java index 7a5a057cf11..0bd280d705b 100644 --- a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewClientFlutterApiImpl.java +++ b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewClientFlutterApiImpl.java @@ -9,6 +9,7 @@ import android.webkit.HttpAuthHandler; import android.webkit.WebResourceError; import android.webkit.WebResourceRequest; +import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; import androidx.annotation.NonNull; @@ -70,6 +71,16 @@ static GeneratedAndroidWebView.WebResourceRequestData createWebResourceRequestDa return requestData.build(); } + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + static GeneratedAndroidWebView.WebResourceResponseData createWebResourceResponseData( + WebResourceResponse response) { + final GeneratedAndroidWebView.WebResourceResponseData.Builder responseData = + new GeneratedAndroidWebView.WebResourceResponseData.Builder() + .setStatusCode((long) response.getStatusCode()); + + return responseData.build(); + } + /** * Creates a Flutter api that sends messages to Dart. * @@ -110,6 +121,25 @@ public void onPageFinished( onPageFinished(getIdentifierForClient(webViewClient), webViewIdentifier, urlArg, callback); } + /** Passes arguments from {@link WebViewClient#onReceivedHttpError} to Dart. */ + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + public void onReceivedHttpError( + @NonNull WebViewClient webViewClient, + @NonNull WebView webView, + @NonNull WebResourceRequest request, + @NonNull WebResourceResponse response, + @NonNull Reply callback) { + webViewFlutterApi.create(webView, reply -> {}); + + final Long webViewIdentifier = instanceManager.getIdentifierForStrongReference(webView); + onReceivedHttpError( + getIdentifierForClient(webViewClient), + webViewIdentifier, + createWebResourceRequestData(request), + createWebResourceResponseData(response), + callback); + } + /** * Passes arguments from {@link WebViewClient#onReceivedError(WebView, WebResourceRequest, * WebResourceError)} to Dart. diff --git a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewClientHostApiImpl.java b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewClientHostApiImpl.java index 1ace7bfe072..a2ed499629c 100644 --- a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewClientHostApiImpl.java +++ b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewClientHostApiImpl.java @@ -12,6 +12,7 @@ import android.webkit.HttpAuthHandler; import android.webkit.WebResourceError; import android.webkit.WebResourceRequest; +import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; import androidx.annotation.NonNull; @@ -55,6 +56,14 @@ public void onPageFinished(@NonNull WebView view, @NonNull String url) { flutterApi.onPageFinished(this, view, url, reply -> {}); } + @Override + public void onReceivedHttpError( + @NonNull WebView view, + @NonNull WebResourceRequest request, + @NonNull WebResourceResponse response) { + flutterApi.onReceivedHttpError(this, view, request, response, reply -> {}); + } + @Override public void onReceivedError( @NonNull WebView view, @@ -140,6 +149,15 @@ public void onPageFinished(@NonNull WebView view, @NonNull String url) { flutterApi.onPageFinished(this, view, url, reply -> {}); } + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + @Override + public void onReceivedHttpError( + @NonNull WebView view, + @NonNull WebResourceRequest request, + @NonNull WebResourceResponse response) { + flutterApi.onReceivedHttpError(this, view, request, response, reply -> {}); + } + // This method is only called when the WebViewFeature.RECEIVE_WEB_RESOURCE_ERROR feature is // enabled. The deprecated method is called when a device doesn't support this. @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) diff --git a/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewClientTest.java b/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewClientTest.java index 8e6b58149d0..ea40742465f 100644 --- a/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewClientTest.java +++ b/packages/webview_flutter/webview_flutter_android/android/src/test/java/io/flutter/plugins/webviewflutter/WebViewClientTest.java @@ -13,6 +13,7 @@ import android.net.Uri; import android.webkit.WebResourceRequest; +import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; import androidx.annotation.NonNull; @@ -136,4 +137,28 @@ public void doUpdateVisitedHistory() { .doUpdateVisitedHistory( eq(webViewClient), eq(mockWebView), eq("https://www.google.com"), eq(true), any()); } + + @Test + public void onReceivedHttpError() { + final Uri mockUri = mock(Uri.class); + when(mockUri.toString()).thenReturn(""); + + final WebResourceRequest mockRequest = mock(WebResourceRequest.class); + when(mockRequest.getMethod()).thenReturn("method"); + when(mockRequest.getUrl()).thenReturn(mockUri); + when(mockRequest.isForMainFrame()).thenReturn(true); + when(mockRequest.getRequestHeaders()).thenReturn(null); + + final WebResourceResponse mockResponse = mock(WebResourceResponse.class); + when(mockResponse.getStatusCode()).thenReturn(404); + + webViewClient.onReceivedHttpError(mockWebView, mockRequest, mockResponse); + verify(mockFlutterApi) + .onReceivedHttpError( + eq(webViewClient), + eq(mockWebView), + any(WebResourceRequest.class), + any(WebResourceResponse.class), + any()); + } } diff --git a/packages/webview_flutter/webview_flutter_android/example/integration_test/webview_flutter_test.dart b/packages/webview_flutter/webview_flutter_android/example/integration_test/webview_flutter_test.dart index f599f07cc3a..cee7d65f33f 100644 --- a/packages/webview_flutter/webview_flutter_android/example/integration_test/webview_flutter_test.dart +++ b/packages/webview_flutter/webview_flutter_android/example/integration_test/webview_flutter_test.dart @@ -978,6 +978,81 @@ Future main() async { await pageFinishCompleter.future; }); + testWidgets('onHttpError', (WidgetTester tester) async { + final Completer errorCompleter = + Completer(); + + final PlatformWebViewController controller = PlatformWebViewController( + const PlatformWebViewControllerCreationParams(), + ); + unawaited(controller.setJavaScriptMode(JavaScriptMode.unrestricted)); + final PlatformNavigationDelegate delegate = PlatformNavigationDelegate( + const PlatformNavigationDelegateCreationParams(), + ); + unawaited(delegate.setOnHttpError((HttpResponseError error) { + errorCompleter.complete(error); + })); + unawaited(controller.setPlatformNavigationDelegate(delegate)); + unawaited(controller.loadRequest( + LoadRequestParams(uri: Uri.parse('$prefixUrl/favicon.ico')), + )); + + await tester.pumpWidget(Builder( + builder: (BuildContext context) { + return PlatformWebViewWidget( + PlatformWebViewWidgetCreationParams(controller: controller), + ).build(context); + }, + )); + + final HttpResponseError error = await errorCompleter.future; + + expect(error, isNotNull); + expect(error.response?.statusCode, 404); + }); + + testWidgets('onHttpError is not called when no HTTP error is received', + (WidgetTester tester) async { + const String testPage = ''' + + + + + + '''; + + final Completer errorCompleter = + Completer(); + final Completer pageFinishCompleter = Completer(); + + final PlatformWebViewController controller = PlatformWebViewController( + const PlatformWebViewControllerCreationParams(), + ); + unawaited(controller.setJavaScriptMode(JavaScriptMode.unrestricted)); + final PlatformNavigationDelegate delegate = PlatformNavigationDelegate( + const PlatformNavigationDelegateCreationParams(), + ); + unawaited(delegate.setOnHttpError((HttpResponseError error) { + errorCompleter.complete(error); + })); + unawaited(delegate.setOnPageFinished( + (_) => pageFinishCompleter.complete(), + )); + unawaited(controller.setPlatformNavigationDelegate(delegate)); + unawaited(controller.loadHtmlString(testPage)); + + await tester.pumpWidget(Builder( + builder: (BuildContext context) { + return PlatformWebViewWidget( + PlatformWebViewWidgetCreationParams(controller: controller), + ).build(context); + }, + )); + + expect(errorCompleter.future, doesNotComplete); + await pageFinishCompleter.future; + }); + testWidgets('can block requests', (WidgetTester tester) async { Completer pageLoaded = Completer(); diff --git a/packages/webview_flutter/webview_flutter_android/example/lib/main.dart b/packages/webview_flutter/webview_flutter_android/example/lib/main.dart index addccb00cde..0f2972f23ef 100644 --- a/packages/webview_flutter/webview_flutter_android/example/lib/main.dart +++ b/packages/webview_flutter/webview_flutter_android/example/lib/main.dart @@ -173,6 +173,11 @@ class _WebViewExampleState extends State { ..setOnPageFinished((String url) { debugPrint('Page finished loading: $url'); }) + ..setOnHttpError((HttpResponseError error) { + debugPrint( + 'HTTP error occured on page: ${error.response?.statusCode}', + ); + }) ..setOnWebResourceError((WebResourceError error) { debugPrint(''' Page resource error: diff --git a/packages/webview_flutter/webview_flutter_android/lib/src/android_proxy.dart b/packages/webview_flutter/webview_flutter_android/lib/src/android_proxy.dart index 9f02d1b5f93..78089d714b3 100644 --- a/packages/webview_flutter/webview_flutter_android/lib/src/android_proxy.dart +++ b/packages/webview_flutter/webview_flutter_android/lib/src/android_proxy.dart @@ -65,6 +65,11 @@ class AndroidWebViewProxy { final android_webview.WebViewClient Function({ void Function(android_webview.WebView webView, String url)? onPageStarted, void Function(android_webview.WebView webView, String url)? onPageFinished, + void Function( + android_webview.WebView webView, + android_webview.WebResourceRequest request, + android_webview.WebResourceResponse response, + )? onReceivedHttpError, void Function( android_webview.WebView webView, android_webview.WebResourceRequest request, diff --git a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.dart b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.dart index 0803198a176..61174ccbf63 100644 --- a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.dart +++ b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.dart @@ -775,6 +775,7 @@ class WebViewClient extends JavaObject { WebViewClient({ this.onPageStarted, this.onPageFinished, + this.onReceivedHttpError, this.onReceivedRequestError, @Deprecated('Only called on Android version < 23.') this.onReceivedError, this.requestLoading, @@ -796,6 +797,7 @@ class WebViewClient extends JavaObject { WebViewClient.detached({ this.onPageStarted, this.onPageFinished, + this.onReceivedHttpError, this.onReceivedRequestError, @Deprecated('Only called on Android version < 23.') this.onReceivedError, this.requestLoading, @@ -908,6 +910,15 @@ class WebViewClient extends JavaObject { /// reflect the state of the DOM at this point. final void Function(WebView webView, String url)? onPageFinished; + /// Notify the host application that an HTTP error has been received from the + /// server while loading a resource. + /// + /// HTTP errors have status codes >= 400. This callback will be called for any + /// resource (iframe, image, etc.), not just for the main page. Thus, it is + /// recommended to perform minimum required work in this callback. + final void Function(WebView webView, WebResourceRequest request, + WebResourceResponse response)? onReceivedHttpError; + /// Report web resource loading error to the host application. /// /// These errors usually indicate inability to connect to the server. Note @@ -981,6 +992,7 @@ class WebViewClient extends JavaObject { return WebViewClient.detached( onPageStarted: onPageStarted, onPageFinished: onPageFinished, + onReceivedHttpError: onReceivedHttpError, onReceivedRequestError: onReceivedRequestError, onReceivedError: onReceivedError, requestLoading: requestLoading, @@ -1470,6 +1482,19 @@ class WebResourceRequest { final Map requestHeaders; } +/// Encapsulates information about the web resource response. +/// +/// See [WebViewClient.onReceivedHttpError]. +class WebResourceResponse { + /// Constructs a [WebResourceResponse]. + WebResourceResponse({ + required this.statusCode, + }); + + /// The HTTP status code associated with the response. + final int statusCode; +} + /// Encapsulates information about errors occurred during loading of web resources. /// /// See [WebViewClient.onReceivedRequestError]. diff --git a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.g.dart b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.g.dart index e7ece16f722..5d2707f9472 100644 --- a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.g.dart +++ b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview.g.dart @@ -115,6 +115,27 @@ class WebResourceRequestData { } } +class WebResourceResponseData { + WebResourceResponseData({ + required this.statusCode, + }); + + int statusCode; + + Object encode() { + return [ + statusCode, + ]; + } + + static WebResourceResponseData decode(Object result) { + result as List; + return WebResourceResponseData( + statusCode: result[0]! as int, + ); + } +} + class WebResourceErrorData { WebResourceErrorData({ required this.errorCode, @@ -1700,6 +1721,9 @@ class _WebViewClientFlutterApiCodec extends StandardMessageCodec { } else if (value is WebResourceRequestData) { buffer.putUint8(129); writeValue(buffer, value.encode()); + } else if (value is WebResourceResponseData) { + buffer.putUint8(130); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -1712,6 +1736,8 @@ class _WebViewClientFlutterApiCodec extends StandardMessageCodec { return WebResourceErrorData.decode(readValue(buffer)!); case 129: return WebResourceRequestData.decode(readValue(buffer)!); + case 130: + return WebResourceResponseData.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); } @@ -1725,6 +1751,9 @@ abstract class WebViewClientFlutterApi { void onPageFinished(int instanceId, int webViewInstanceId, String url); + void onReceivedHttpError(int instanceId, int webViewInstanceId, + WebResourceRequestData request, WebResourceResponseData response); + void onReceivedRequestError(int instanceId, int webViewInstanceId, WebResourceRequestData request, WebResourceErrorData error); @@ -1796,6 +1825,38 @@ abstract class WebViewClientFlutterApi { }); } } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.webview_flutter_android.WebViewClientFlutterApi.onReceivedHttpError', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + channel.setMessageHandler(null); + } else { + channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.webview_flutter_android.WebViewClientFlutterApi.onReceivedHttpError was null.'); + final List args = (message as List?)!; + final int? arg_instanceId = (args[0] as int?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.webview_flutter_android.WebViewClientFlutterApi.onReceivedHttpError was null, expected non-null int.'); + final int? arg_webViewInstanceId = (args[1] as int?); + assert(arg_webViewInstanceId != null, + 'Argument for dev.flutter.pigeon.webview_flutter_android.WebViewClientFlutterApi.onReceivedHttpError was null, expected non-null int.'); + final WebResourceRequestData? arg_request = + (args[2] as WebResourceRequestData?); + assert(arg_request != null, + 'Argument for dev.flutter.pigeon.webview_flutter_android.WebViewClientFlutterApi.onReceivedHttpError was null, expected non-null WebResourceRequestData.'); + final WebResourceResponseData? arg_response = + (args[3] as WebResourceResponseData?); + assert(arg_response != null, + 'Argument for dev.flutter.pigeon.webview_flutter_android.WebViewClientFlutterApi.onReceivedHttpError was null, expected non-null WebResourceResponseData.'); + api.onReceivedHttpError(arg_instanceId!, arg_webViewInstanceId!, + arg_request!, arg_response!); + return; + }); + } + } { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.webview_flutter_android.WebViewClientFlutterApi.onReceivedRequestError', diff --git a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_api_impls.dart b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_api_impls.dart index f157c01a742..c6f3c29c1b8 100644 --- a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_api_impls.dart @@ -25,6 +25,13 @@ WebResourceRequest _toWebResourceRequest(WebResourceRequestData data) { ); } +/// Converts [WebResourceResponseData] to [WebResourceResponse] +WebResourceResponse _toWebResourceResponse(WebResourceResponseData data) { + return WebResourceResponse( + statusCode: data.statusCode, + ); +} + /// Converts [WebResourceErrorData] to [WebResourceError]. WebResourceError _toWebResourceError(WebResourceErrorData data) { return WebResourceError( @@ -700,6 +707,34 @@ class WebViewClientFlutterApiImpl extends WebViewClientFlutterApi { } } + @override + void onReceivedHttpError( + int instanceId, + int webViewInstanceId, + WebResourceRequestData request, + WebResourceResponseData response, + ) { + final WebViewClient? instance = instanceManager + .getInstanceWithWeakReference(instanceId) as WebViewClient?; + final WebView? webViewInstance = instanceManager + .getInstanceWithWeakReference(webViewInstanceId) as WebView?; + assert( + instance != null, + 'InstanceManager does not contain an WebViewClient with instanceId: $instanceId', + ); + assert( + webViewInstance != null, + 'InstanceManager does not contain an WebView with instanceId: $webViewInstanceId', + ); + if (instance!.onReceivedHttpError != null) { + instance.onReceivedHttpError!( + webViewInstance!, + _toWebResourceRequest(request), + _toWebResourceResponse(response), + ); + } + } + @override void onReceivedError( int instanceId, diff --git a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_controller.dart b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_controller.dart index b9dfe24a760..f353532bc5d 100644 --- a/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_controller.dart +++ b/packages/webview_flutter/webview_flutter_android/lib/src/android_webview_controller.dart @@ -1297,6 +1297,25 @@ class AndroidNavigationDelegate extends PlatformNavigationDelegate { callback(url); } }, + onReceivedHttpError: ( + android_webview.WebView webView, + android_webview.WebResourceRequest request, + android_webview.WebResourceResponse response, + ) { + if (weakThis.target?._onHttpError != null) { + weakThis.target!._onHttpError!( + HttpResponseError( + request: WebResourceRequest( + uri: Uri.parse(request.url), + ), + response: WebResourceResponse( + uri: null, + statusCode: response.statusCode, + ), + ), + ); + } + }, onReceivedRequestError: ( android_webview.WebView webView, android_webview.WebResourceRequest request, @@ -1429,6 +1448,7 @@ class AndroidNavigationDelegate extends PlatformNavigationDelegate { PageEventCallback? _onPageFinished; PageEventCallback? _onPageStarted; + HttpResponseErrorCallback? _onHttpError; ProgressCallback? _onProgress; WebResourceErrorCallback? _onWebResourceError; NavigationRequestCallback? _onNavigationRequest; @@ -1503,6 +1523,13 @@ class AndroidNavigationDelegate extends PlatformNavigationDelegate { _onPageFinished = onPageFinished; } + @override + Future setOnHttpError( + HttpResponseErrorCallback onHttpError, + ) async { + _onHttpError = onHttpError; + } + @override Future setOnProgress( ProgressCallback onProgress, diff --git a/packages/webview_flutter/webview_flutter_android/pigeons/android_webview.dart b/packages/webview_flutter/webview_flutter_android/pigeons/android_webview.dart index 8f40d9120ce..73b8093d05e 100644 --- a/packages/webview_flutter/webview_flutter_android/pigeons/android_webview.dart +++ b/packages/webview_flutter/webview_flutter_android/pigeons/android_webview.dart @@ -111,6 +111,14 @@ class WebResourceRequestData { Map requestHeaders; } +class WebResourceResponseData { + WebResourceResponseData( + this.statusCode, + ); + + int statusCode; +} + class WebResourceErrorData { WebResourceErrorData(this.errorCode, this.description); @@ -337,6 +345,13 @@ abstract class WebViewClientFlutterApi { void onPageFinished(int instanceId, int webViewInstanceId, String url); + void onReceivedHttpError( + int instanceId, + int webViewInstanceId, + WebResourceRequestData request, + WebResourceResponseData response, + ); + void onReceivedRequestError( int instanceId, int webViewInstanceId, diff --git a/packages/webview_flutter/webview_flutter_android/pubspec.yaml b/packages/webview_flutter/webview_flutter_android/pubspec.yaml index 9f3fd0602a1..01add915842 100644 --- a/packages/webview_flutter/webview_flutter_android/pubspec.yaml +++ b/packages/webview_flutter/webview_flutter_android/pubspec.yaml @@ -2,7 +2,7 @@ name: webview_flutter_android description: A Flutter plugin that provides a WebView widget on Android. repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22 -version: 3.15.0 +version: 3.16.0 environment: sdk: ^3.1.0 @@ -20,7 +20,7 @@ flutter: dependencies: flutter: sdk: flutter - webview_flutter_platform_interface: ^2.9.0 + webview_flutter_platform_interface: ^2.10.0 dev_dependencies: build_runner: ^2.1.4 diff --git a/packages/webview_flutter/webview_flutter_android/test/android_navigation_delegate_test.dart b/packages/webview_flutter/webview_flutter_android/test/android_navigation_delegate_test.dart index 36681d09216..85b99dec232 100644 --- a/packages/webview_flutter/webview_flutter_android/test/android_navigation_delegate_test.dart +++ b/packages/webview_flutter/webview_flutter_android/test/android_navigation_delegate_test.dart @@ -59,6 +59,29 @@ void main() { expect(callbackUrl, 'https://www.google.com'); }); + test('onHttpError from onReceivedHttpError', () { + final AndroidNavigationDelegate androidNavigationDelegate = + AndroidNavigationDelegate(_buildCreationParams()); + + late final HttpResponseError callbackError; + androidNavigationDelegate.setOnHttpError( + (HttpResponseError httpError) => callbackError = httpError); + + CapturingWebViewClient.lastCreatedDelegate.onReceivedHttpError!( + android_webview.WebView.detached(), + android_webview.WebResourceRequest( + url: 'https://www.google.com', + isForMainFrame: false, + isRedirect: true, + hasGesture: true, + method: 'GET', + requestHeaders: {'X-Mock': 'mocking'}, + ), + android_webview.WebResourceResponse(statusCode: 401)); + + expect(callbackError.response?.statusCode, 401); + }); + test('onWebResourceError from onReceivedRequestError', () { final AndroidNavigationDelegate androidNavigationDelegate = AndroidNavigationDelegate(_buildCreationParams()); @@ -532,6 +555,7 @@ class CapturingWebViewClient extends android_webview.WebViewClient { CapturingWebViewClient({ super.onPageFinished, super.onPageStarted, + super.onReceivedHttpError, super.onReceivedError, super.onReceivedHttpAuthRequest, super.onReceivedRequestError, diff --git a/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.dart b/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.dart index f912e8d5e64..dcc5b27abcd 100644 --- a/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.dart +++ b/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.dart @@ -140,6 +140,11 @@ void main() { onPageFinished, void Function(android_webview.WebView webView, String url)? onPageStarted, + void Function( + android_webview.WebView webView, + android_webview.WebResourceRequest request, + android_webview.WebResourceResponse response)? + onReceivedHttpError, @Deprecated('Only called on Android version < 23.') void Function( android_webview.WebView webView, diff --git a/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.mocks.dart b/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.mocks.dart index a7abc51261d..73c513c8af3 100644 --- a/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_android/test/android_webview_controller_test.mocks.dart @@ -343,6 +343,17 @@ class MockAndroidNavigationDelegate extends _i1.Mock returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override + _i9.Future setOnHttpError(_i3.HttpResponseErrorCallback? onHttpError) => + (super.noSuchMethod( + Invocation.method( + #setOnHttpError, + [onHttpError], + ), + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); + @override _i9.Future setOnProgress(_i3.ProgressCallback? onProgress) => (super.noSuchMethod( @@ -388,17 +399,6 @@ class MockAndroidNavigationDelegate extends _i1.Mock returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); - - @override - _i9.Future setOnHttpError(_i3.HttpResponseErrorCallback? onHttpError) => - (super.noSuchMethod( - Invocation.method( - #setOnHttpError, - [onHttpError], - ), - returnValue: _i9.Future.value(), - returnValueForMissingStub: _i9.Future.value(), - ) as _i9.Future); } /// A class which mocks [AndroidWebViewController]. @@ -892,7 +892,7 @@ class MockAndroidWebViewProxy extends _i1.Mock implements _i10.AndroidWebViewProxy { @override _i2.WebView Function( - {dynamic Function( + {void Function( int, int, int, @@ -900,7 +900,7 @@ class MockAndroidWebViewProxy extends _i1.Mock )? onScrollChanged}) get createAndroidWebView => (super.noSuchMethod( Invocation.getter(#createAndroidWebView), returnValue: ( - {dynamic Function( + {void Function( int, int, int, @@ -911,7 +911,7 @@ class MockAndroidWebViewProxy extends _i1.Mock Invocation.getter(#createAndroidWebView), ), returnValueForMissingStub: ( - {dynamic Function( + {void Function( int, int, int, @@ -922,7 +922,7 @@ class MockAndroidWebViewProxy extends _i1.Mock Invocation.getter(#createAndroidWebView), ), ) as _i2.WebView Function( - {dynamic Function( + {void Function( int, int, int, @@ -1137,6 +1137,11 @@ class MockAndroidWebViewProxy extends _i1.Mock String, String, )? onReceivedHttpAuthRequest, + void Function( + _i2.WebView, + _i2.WebResourceRequest, + _i2.WebResourceResponse, + )? onReceivedHttpError, void Function( _i2.WebView, _i2.WebResourceRequest, @@ -1178,6 +1183,11 @@ class MockAndroidWebViewProxy extends _i1.Mock String, String, )? onReceivedHttpAuthRequest, + void Function( + _i2.WebView, + _i2.WebResourceRequest, + _i2.WebResourceResponse, + )? onReceivedHttpError, void Function( _i2.WebView, _i2.WebResourceRequest, @@ -1222,6 +1232,11 @@ class MockAndroidWebViewProxy extends _i1.Mock String, String, )? onReceivedHttpAuthRequest, + void Function( + _i2.WebView, + _i2.WebResourceRequest, + _i2.WebResourceResponse, + )? onReceivedHttpError, void Function( _i2.WebView, _i2.WebResourceRequest, @@ -1266,6 +1281,11 @@ class MockAndroidWebViewProxy extends _i1.Mock String, String, )? onReceivedHttpAuthRequest, + void Function( + _i2.WebView, + _i2.WebResourceRequest, + _i2.WebResourceResponse, + )? onReceivedHttpError, void Function( _i2.WebView, _i2.WebResourceRequest, @@ -2117,6 +2137,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setSynchronousReturnValueForOnJsConfirm(bool? value) => (super.noSuchMethod( @@ -2127,6 +2148,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i9.Future setSynchronousReturnValueForOnJsPrompt(bool? value) => (super.noSuchMethod( @@ -2137,6 +2159,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i9.Future.value(), returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); + @override _i2.WebChromeClient copy() => (super.noSuchMethod( Invocation.method( diff --git a/packages/webview_flutter/webview_flutter_android/test/android_webview_test.dart b/packages/webview_flutter/webview_flutter_android/test/android_webview_test.dart index d542c498772..36b9c034357 100644 --- a/packages/webview_flutter/webview_flutter_android/test/android_webview_test.dart +++ b/packages/webview_flutter/webview_flutter_android/test/android_webview_test.dart @@ -642,6 +642,37 @@ void main() { expect(result, [mockWebView, 'https://www.google.com']); }); + test('onReceivedHttpError', () { + late final List result; + when(mockWebViewClient.onReceivedHttpError).thenReturn( + ( + WebView webView, + WebResourceRequest request, + WebResourceResponse response, + ) { + result = [webView, request, response]; + }, + ); + + flutterApi.onReceivedHttpError( + mockWebViewClientInstanceId, + mockWebViewInstanceId, + WebResourceRequestData( + url: 'https://www.google.com', + isForMainFrame: true, + hasGesture: true, + method: 'GET', + isRedirect: false, + requestHeaders: {}, + ), + WebResourceResponseData( + statusCode: 401, + ), + ); + + expect(result, [mockWebView, isNotNull, isNotNull]); + }); + test('onReceivedRequestError', () { late final List result; when(mockWebViewClient.onReceivedRequestError).thenReturn( diff --git a/packages/webview_flutter/webview_flutter_android/test/android_webview_test.mocks.dart b/packages/webview_flutter/webview_flutter_android/test/android_webview_test.mocks.dart index 4a9ced6a07b..54002135ab5 100644 --- a/packages/webview_flutter/webview_flutter_android/test/android_webview_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_android/test/android_webview_test.mocks.dart @@ -510,6 +510,7 @@ class MockTestWebChromeClientHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setSynchronousReturnValueForOnJsAlert( int? instanceId, @@ -525,6 +526,7 @@ class MockTestWebChromeClientHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setSynchronousReturnValueForOnJsConfirm( int? instanceId, @@ -540,6 +542,7 @@ class MockTestWebChromeClientHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); + @override void setSynchronousReturnValueForOnJsPrompt( int? instanceId, @@ -1340,6 +1343,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setSynchronousReturnValueForOnJsConfirm(bool? value) => (super.noSuchMethod( @@ -1350,6 +1354,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setSynchronousReturnValueForOnJsPrompt(bool? value) => (super.noSuchMethod( @@ -1360,6 +1365,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i2.WebChromeClient copy() => (super.noSuchMethod( Invocation.method( diff --git a/packages/webview_flutter/webview_flutter_android/test/legacy/webview_android_widget_test.mocks.dart b/packages/webview_flutter/webview_flutter_android/test/legacy/webview_android_widget_test.mocks.dart index f7a11fb9e87..84a778786ec 100644 --- a/packages/webview_flutter/webview_flutter_android/test/legacy/webview_android_widget_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_android/test/legacy/webview_android_widget_test.mocks.dart @@ -880,6 +880,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setSynchronousReturnValueForOnJsConfirm(bool? value) => (super.noSuchMethod( @@ -890,6 +891,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i5.Future setSynchronousReturnValueForOnJsPrompt(bool? value) => (super.noSuchMethod( @@ -900,6 +902,7 @@ class MockWebChromeClient extends _i1.Mock implements _i2.WebChromeClient { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override _i2.WebChromeClient copy() => (super.noSuchMethod( Invocation.method( diff --git a/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md b/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md index 8aa73ace026..70ba80cee6a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md +++ b/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md @@ -1,3 +1,8 @@ +## 3.13.0 + +* Adds `decidePolicyForNavigationResponse` to internal WKNavigationDelegate to support the + `PlatformNavigationDelegate.onHttpError` callback. + ## 3.12.0 * Adds support for `setOnScrollPositionChange` method to the `WebKitWebViewController`. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/integration_test/webview_flutter_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/example/integration_test/webview_flutter_test.dart index 91d9075cd47..80445b96fee 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/integration_test/webview_flutter_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/integration_test/webview_flutter_test.dart @@ -987,6 +987,81 @@ Future main() async { }, ); + testWidgets('onHttpError', (WidgetTester tester) async { + final Completer errorCompleter = + Completer(); + + final PlatformWebViewController controller = PlatformWebViewController( + const PlatformWebViewControllerCreationParams(), + ); + unawaited(controller.setJavaScriptMode(JavaScriptMode.unrestricted)); + final PlatformNavigationDelegate delegate = PlatformNavigationDelegate( + const PlatformNavigationDelegateCreationParams(), + ); + unawaited(delegate.setOnHttpError((HttpResponseError error) { + errorCompleter.complete(error); + })); + unawaited(controller.setPlatformNavigationDelegate(delegate)); + unawaited(controller.loadRequest( + LoadRequestParams(uri: Uri.parse('$prefixUrl/favicon.ico')), + )); + + await tester.pumpWidget(Builder( + builder: (BuildContext context) { + return PlatformWebViewWidget( + PlatformWebViewWidgetCreationParams(controller: controller), + ).build(context); + }, + )); + + final HttpResponseError error = await errorCompleter.future; + + expect(error, isNotNull); + expect(error.response?.statusCode, 404); + }); + + testWidgets('onHttpError is not called when no HTTP error is received', + (WidgetTester tester) async { + const String testPage = ''' + + + + + + '''; + + final Completer errorCompleter = + Completer(); + final Completer pageFinishCompleter = Completer(); + + final PlatformWebViewController controller = PlatformWebViewController( + const PlatformWebViewControllerCreationParams(), + ); + unawaited(controller.setJavaScriptMode(JavaScriptMode.unrestricted)); + final PlatformNavigationDelegate delegate = PlatformNavigationDelegate( + const PlatformNavigationDelegateCreationParams(), + ); + unawaited(delegate.setOnHttpError((HttpResponseError error) { + errorCompleter.complete(error); + })); + unawaited(delegate.setOnPageFinished( + (_) => pageFinishCompleter.complete(), + )); + unawaited(controller.setPlatformNavigationDelegate(delegate)); + unawaited(controller.loadHtmlString(testPage)); + + await tester.pumpWidget(Builder( + builder: (BuildContext context) { + return PlatformWebViewWidget( + PlatformWebViewWidgetCreationParams(controller: controller), + ).build(context); + }, + )); + + expect(errorCompleter.future, doesNotComplete); + await pageFinishCompleter.future; + }); + testWidgets('can block requests', (WidgetTester tester) async { Completer pageLoaded = Completer(); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFDataConvertersTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFDataConvertersTests.m index 7613bf02f75..a4ff58a47ea 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFDataConvertersTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFDataConvertersTests.m @@ -171,4 +171,34 @@ - (void)testNSKeyValueChangeKeyConversionReturnsUnknownIfUnrecognized { - (void)testWKNavigationTypeConversionReturnsUnknownIfUnrecognized { XCTAssertEqual(FWFWKNavigationTypeFromNativeWKNavigationType(-15), FWFWKNavigationTypeUnknown); } + +- (void)testFWFWKNavigationResponseDataFromNativeNavigationResponse { + WKNavigationResponse *mockResponse = OCMClassMock([WKNavigationResponse class]); + OCMStub([mockResponse isForMainFrame]).andReturn(YES); + + NSHTTPURLResponse *mockURLResponse = OCMClassMock([NSHTTPURLResponse class]); + OCMStub([mockURLResponse statusCode]).andReturn(1); + OCMStub([mockResponse response]).andReturn(mockURLResponse); + + FWFWKNavigationResponseData *data = + FWFWKNavigationResponseDataFromNativeNavigationResponse(mockResponse); + XCTAssertEqual(data.forMainFrame, YES); +} + +- (void)testFWFNSHttpUrlResponseDataFromNativeNSURLResponse { + NSHTTPURLResponse *mockResponse = OCMClassMock([NSHTTPURLResponse class]); + OCMStub([mockResponse statusCode]).andReturn(1); + + FWFNSHttpUrlResponseData *data = FWFNSHttpUrlResponseDataFromNativeNSURLResponse(mockResponse); + XCTAssertEqual(data.statusCode, 1); +} + +- (void)testFWFNativeWKNavigationResponsePolicyFromEnum { + XCTAssertEqual( + FWFNativeWKNavigationResponsePolicyFromEnum(FWFWKNavigationResponsePolicyEnumAllow), + WKNavigationResponsePolicyAllow); + XCTAssertEqual( + FWFNativeWKNavigationResponsePolicyFromEnum(FWFWKNavigationResponsePolicyEnumCancel), + WKNavigationResponsePolicyCancel); +} @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m index dc4cb3cf8ab..829d27643bf 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m @@ -267,4 +267,46 @@ - (void)testDidReceiveAuthenticationChallenge { XCTAssertEqual(callbackDisposition, NSURLSessionAuthChallengeCancelAuthenticationChallenge); XCTAssertEqualObjects(callbackCredential, credential); } + +- (void)testDecidePolicyForNavigationResponse { + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + + FWFNavigationDelegate *mockDelegate = [self mockNavigationDelegateWithManager:instanceManager + identifier:0]; + FWFNavigationDelegateFlutterApiImpl *mockFlutterAPI = + [self mockFlutterApiWithManager:instanceManager]; + + OCMStub([mockDelegate navigationDelegateAPI]).andReturn(mockFlutterAPI); + + WKWebView *mockWebView = OCMClassMock([WKWebView class]); + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:1]; + + WKNavigationResponse *mockNavigationResponse = OCMClassMock([WKNavigationResponse class]); + OCMStub([mockNavigationResponse isForMainFrame]).andReturn(YES); + + NSHTTPURLResponse *mockURLResponse = OCMClassMock([NSHTTPURLResponse class]); + OCMStub([mockURLResponse statusCode]).andReturn(1); + OCMStub([mockNavigationResponse response]).andReturn(mockURLResponse); + + OCMStub([mockFlutterAPI + decidePolicyForNavigationResponseForDelegateWithIdentifier:0 + webViewIdentifier:1 + navigationResponse:OCMOCK_ANY + completion: + ([OCMArg + invokeBlockWithArgs: + [[FWFWKNavigationResponsePolicyEnumBox + alloc] + initWithValue: + FWFWKNavigationResponsePolicyEnumAllow], + [NSNull null], nil])]); + + WKNavigationResponsePolicy __block callbackPolicy = -1; + [mockDelegate webView:mockWebView + decidePolicyForNavigationResponse:mockNavigationResponse + decisionHandler:^(WKNavigationResponsePolicy policy) { + callbackPolicy = policy; + }]; + XCTAssertEqual(callbackPolicy, WKNavigationResponsePolicyAllow); +} @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/lib/main.dart b/packages/webview_flutter/webview_flutter_wkwebview/example/lib/main.dart index 36f3a1eb9ad..68a9f1a0c4d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/lib/main.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/lib/main.dart @@ -174,6 +174,9 @@ class _WebViewExampleState extends State { ..setOnPageFinished((String url) { debugPrint('Page finished loading: $url'); }) + ..setOnHttpError((HttpResponseError error) { + debugPrint('Error occurred on page: ${error.response?.statusCode}'); + }) ..setOnWebResourceError((WebResourceError error) { debugPrint(''' Page resource error: diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.h index c4d37571d62..f97de9c8c19 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.h @@ -84,11 +84,32 @@ extern FWFWKNavigationActionData *FWFWKNavigationActionDataFromNativeWKNavigatio /// @return A FWFNSUrlRequestData. extern FWFNSUrlRequestData *FWFNSUrlRequestDataFromNativeNSURLRequest(NSURLRequest *request); -/// Converts a WKFrameInfo to an FWFWKFrameInfoData. -/// -/// @param info The object containing information to create a FWFWKFrameInfoData. -/// -/// @return A FWFWKFrameInfoData. +/** + * Converts a WKNavigationResponse to an FWFWKNavigationResponseData. + * + * @param response The object containing information to create a WKNavigationResponseData. + * + * @return A FWFWKNavigationResponseData. + */ +extern FWFWKNavigationResponseData *FWFWKNavigationResponseDataFromNativeNavigationResponse( + WKNavigationResponse *response); +/** + * Converts a NSURLResponse to an FWFNSHttpUrlResponseData. + * + * @param response The object containing information to create a WKNavigationActionData. + * + * @return A FWFNSHttpUrlResponseData. + */ +extern FWFNSHttpUrlResponseData *FWFNSHttpUrlResponseDataFromNativeNSURLResponse( + NSURLResponse *response); + +/** + * Converts a WKFrameInfo to an FWFWKFrameInfoData. + * + * @param info The object containing information to create a FWFWKFrameInfoData. + * + * @return A FWFWKFrameInfoData. + */ extern FWFWKFrameInfoData *FWFWKFrameInfoDataFromNativeWKFrameInfo(WKFrameInfo *info); /// Converts an FWFWKNavigationActionPolicyEnumData to a WKNavigationActionPolicy. @@ -99,11 +120,23 @@ extern FWFWKFrameInfoData *FWFWKFrameInfoDataFromNativeWKFrameInfo(WKFrameInfo * extern WKNavigationActionPolicy FWFNativeWKNavigationActionPolicyFromEnumData( FWFWKNavigationActionPolicyEnumData *data); -/// Converts a NSError to an FWFNSErrorData. -/// -/// @param error The object containing information to create a FWFNSErrorData. -/// -/// @return A FWFNSErrorData. +/** + * Converts an FWFWKNavigationResponsePolicyEnumData to a WKNavigationResponsePolicy. + * + * @param policy The data object containing information to create a WKNavigationResponsePolicy. + * + * @return A WKNavigationResponsePolicy or -1 if data could not be converted. + */ +extern WKNavigationResponsePolicy FWFNativeWKNavigationResponsePolicyFromEnum( + FWFWKNavigationResponsePolicyEnum policy); + +/** + * Converts a NSError to an FWFNSErrorData. + * + * @param error The object containing information to create a FWFNSErrorData. + * + * @return A FWFNSErrorData. + */ extern FWFNSErrorData *FWFNSErrorDataFromNativeNSError(NSError *error); /// Converts an NSKeyValueChangeKey to a FWFNSKeyValueChangeKeyEnumData. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.m index 9a5cc86fe95..51a5ada5030 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.m @@ -181,6 +181,24 @@ WKAudiovisualMediaTypes FWFNativeWKAudiovisualMediaTypeFromEnumData( request:FWFNSUrlRequestDataFromNativeNSURLRequest(info.request)]; } +FWFWKNavigationResponseData *FWFWKNavigationResponseDataFromNativeNavigationResponse( + WKNavigationResponse *response) { + return [FWFWKNavigationResponseData + makeWithResponse:FWFNSHttpUrlResponseDataFromNativeNSURLResponse(response.response) + forMainFrame:response.forMainFrame]; +} + +/// Cast the NSURLResponse object to NSHTTPURLResponse. +/// +/// NSURLResponse doesn't contain the status code so it must be cast to NSHTTPURLResponse. +/// This cast will always succeed because the NSURLResponse object actually is an instance of +/// NSHTTPURLResponse. See: +/// https://developer.apple.com/documentation/foundation/nsurlresponse#overview +FWFNSHttpUrlResponseData *FWFNSHttpUrlResponseDataFromNativeNSURLResponse(NSURLResponse *response) { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; + return [FWFNSHttpUrlResponseData makeWithStatusCode:httpResponse.statusCode]; +} + WKNavigationActionPolicy FWFNativeWKNavigationActionPolicyFromEnumData( FWFWKNavigationActionPolicyEnumData *data) { switch (data.value) { @@ -209,6 +227,18 @@ WKNavigationActionPolicy FWFNativeWKNavigationActionPolicyFromEnumData( return [FWFNSErrorData makeWithCode:error.code domain:error.domain userInfo:userInfo]; } +WKNavigationResponsePolicy FWFNativeWKNavigationResponsePolicyFromEnum( + FWFWKNavigationResponsePolicyEnum policy) { + switch (policy) { + case FWFWKNavigationResponsePolicyEnumAllow: + return WKNavigationResponsePolicyAllow; + case FWFWKNavigationResponsePolicyEnumCancel: + return WKNavigationResponsePolicyCancel; + } + + return -1; +} + FWFNSKeyValueChangeKeyEnumData *FWFNSKeyValueChangeKeyEnumDataFromNativeNSKeyValueChangeKey( NSKeyValueChangeKey key) { if ([key isEqualToString:NSKeyValueChangeIndexesKey]) { diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h index 3a0fa3021d2..984cfc93cc3 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v13.1.2), do not edit directly. +// Autogenerated from Pigeon (v13.0.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import @@ -130,6 +130,20 @@ typedef NS_ENUM(NSUInteger, FWFWKNavigationActionPolicyEnum) { - (instancetype)initWithValue:(FWFWKNavigationActionPolicyEnum)value; @end +/// Mirror of WKNavigationResponsePolicy. +/// +/// See https://developer.apple.com/documentation/webkit/wknavigationactionpolicy?language=objc. +typedef NS_ENUM(NSUInteger, FWFWKNavigationResponsePolicyEnum) { + FWFWKNavigationResponsePolicyEnumAllow = 0, + FWFWKNavigationResponsePolicyEnumCancel = 1, +}; + +/// Wrapper for FWFWKNavigationResponsePolicyEnum to allow for nullability. +@interface FWFWKNavigationResponsePolicyEnumBox : NSObject +@property(nonatomic, assign) FWFWKNavigationResponsePolicyEnum value; +- (instancetype)initWithValue:(FWFWKNavigationResponsePolicyEnum)value; +@end + /// Mirror of NSHTTPCookiePropertyKey. /// /// See https://developer.apple.com/documentation/foundation/nshttpcookiepropertykey. @@ -341,8 +355,10 @@ typedef NS_ENUM(NSUInteger, FWFNSUrlCredentialPersistence) { @class FWFWKPermissionDecisionData; @class FWFWKMediaCaptureTypeData; @class FWFNSUrlRequestData; +@class FWFNSHttpUrlResponseData; @class FWFWKUserScriptData; @class FWFWKNavigationActionData; +@class FWFWKNavigationResponseData; @class FWFWKFrameInfoData; @class FWFNSErrorData; @class FWFWKScriptMessageData; @@ -430,6 +446,16 @@ typedef NS_ENUM(NSUInteger, FWFNSUrlCredentialPersistence) { @property(nonatomic, copy) NSDictionary *allHttpHeaderFields; @end +/// Mirror of NSURLResponse. +/// +/// See https://developer.apple.com/documentation/foundation/nshttpurlresponse?language=objc. +@interface FWFNSHttpUrlResponseData : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithStatusCode:(NSInteger)statusCode; +@property(nonatomic, assign) NSInteger statusCode; +@end + /// Mirror of WKUserScript. /// /// See https://developer.apple.com/documentation/webkit/wkuserscript?language=objc. @@ -458,6 +484,18 @@ typedef NS_ENUM(NSUInteger, FWFNSUrlCredentialPersistence) { @property(nonatomic, assign) FWFWKNavigationType navigationType; @end +/// Mirror of WKNavigationResponse. +/// +/// See https://developer.apple.com/documentation/webkit/wknavigationresponse. +@interface FWFWKNavigationResponseData : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithResponse:(FWFNSHttpUrlResponseData *)response + forMainFrame:(BOOL)forMainFrame; +@property(nonatomic, strong) FWFNSHttpUrlResponseData *response; +@property(nonatomic, assign) BOOL forMainFrame; +@end + /// Mirror of WKFrameInfo. /// /// See https://developer.apple.com/documentation/webkit/wkframeinfo?language=objc. @@ -778,6 +816,15 @@ NSObject *FWFWKNavigationDelegateFlutterApiGetCodec(void); (void (^)(FWFWKNavigationActionPolicyEnumData *_Nullable, FlutterError *_Nullable))completion; +- (void)decidePolicyForNavigationResponseForDelegateWithIdentifier:(NSInteger)identifier + webViewIdentifier:(NSInteger)webViewIdentifier + navigationResponse:(FWFWKNavigationResponseData *) + navigationResponse + completion: + (void (^)( + FWFWKNavigationResponsePolicyEnumBox + *_Nullable, + FlutterError *_Nullable))completion; - (void)didFailNavigationForDelegateWithIdentifier:(NSInteger)identifier webViewIdentifier:(NSInteger)webViewIdentifier error:(FWFNSErrorData *)error diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m index 450efd64831..352f9b1c161 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v13.1.2), do not edit directly. +// Autogenerated from Pigeon (v13.0.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "FWFGeneratedWebKitApis.h" @@ -16,29 +16,6 @@ #error File requires ARC to be enabled. #endif -static NSArray *wrapResult(id result, FlutterError *error) { - if (error) { - return @[ - error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null] - ]; - } - return @[ result ?: [NSNull null] ]; -} - -static FlutterError *createConnectionError(NSString *channelName) { - return [FlutterError - errorWithCode:@"channel-error" - message:[NSString stringWithFormat:@"%@/%@/%@", - @"Unable to establish connection on channel: '", - channelName, @"'."] - details:@""]; -} - -static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { - id result = array[key]; - return (result == [NSNull null]) ? nil : result; -} - /// Mirror of NSKeyValueObservingOptions. /// /// See @@ -133,6 +110,19 @@ - (instancetype)initWithValue:(FWFWKNavigationActionPolicyEnum)value { } @end +/// Mirror of WKNavigationResponsePolicy. +/// +/// See https://developer.apple.com/documentation/webkit/wknavigationactionpolicy?language=objc. +@implementation FWFWKNavigationResponsePolicyEnumBox +- (instancetype)initWithValue:(FWFWKNavigationResponsePolicyEnum)value { + self = [super init]; + if (self) { + _value = value; + } + return self; +} +@end + /// Mirror of NSHTTPCookiePropertyKey. /// /// See https://developer.apple.com/documentation/foundation/nshttpcookiepropertykey. @@ -212,6 +202,19 @@ - (instancetype)initWithValue:(FWFNSUrlCredentialPersistence)value { } @end +static NSArray *wrapResult(id result, FlutterError *error) { + if (error) { + return @[ + error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null] + ]; + } + return @[ result ?: [NSNull null] ]; +} +static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { + id result = array[key]; + return (result == [NSNull null]) ? nil : result; +} + @interface FWFNSKeyValueObservingOptionsEnumData () + (FWFNSKeyValueObservingOptionsEnumData *)fromList:(NSArray *)list; + (nullable FWFNSKeyValueObservingOptionsEnumData *)nullableFromList:(NSArray *)list; @@ -272,6 +275,12 @@ + (nullable FWFNSUrlRequestData *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end +@interface FWFNSHttpUrlResponseData () ++ (FWFNSHttpUrlResponseData *)fromList:(NSArray *)list; ++ (nullable FWFNSHttpUrlResponseData *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + @interface FWFWKUserScriptData () + (FWFWKUserScriptData *)fromList:(NSArray *)list; + (nullable FWFWKUserScriptData *)nullableFromList:(NSArray *)list; @@ -284,6 +293,12 @@ + (nullable FWFWKNavigationActionData *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end +@interface FWFWKNavigationResponseData () ++ (FWFWKNavigationResponseData *)fromList:(NSArray *)list; ++ (nullable FWFWKNavigationResponseData *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + @interface FWFWKFrameInfoData () + (FWFWKFrameInfoData *)fromList:(NSArray *)list; + (nullable FWFWKFrameInfoData *)nullableFromList:(NSArray *)list; @@ -558,6 +573,27 @@ - (NSArray *)toList { } @end +@implementation FWFNSHttpUrlResponseData ++ (instancetype)makeWithStatusCode:(NSInteger)statusCode { + FWFNSHttpUrlResponseData *pigeonResult = [[FWFNSHttpUrlResponseData alloc] init]; + pigeonResult.statusCode = statusCode; + return pigeonResult; +} ++ (FWFNSHttpUrlResponseData *)fromList:(NSArray *)list { + FWFNSHttpUrlResponseData *pigeonResult = [[FWFNSHttpUrlResponseData alloc] init]; + pigeonResult.statusCode = [GetNullableObjectAtIndex(list, 0) integerValue]; + return pigeonResult; +} ++ (nullable FWFNSHttpUrlResponseData *)nullableFromList:(NSArray *)list { + return (list) ? [FWFNSHttpUrlResponseData fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + @(self.statusCode), + ]; +} +@end + @implementation FWFWKUserScriptData + (instancetype)makeWithSource:(NSString *)source injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime @@ -618,6 +654,32 @@ - (NSArray *)toList { } @end +@implementation FWFWKNavigationResponseData ++ (instancetype)makeWithResponse:(FWFNSHttpUrlResponseData *)response + forMainFrame:(BOOL)forMainFrame { + FWFWKNavigationResponseData *pigeonResult = [[FWFWKNavigationResponseData alloc] init]; + pigeonResult.response = response; + pigeonResult.forMainFrame = forMainFrame; + return pigeonResult; +} ++ (FWFWKNavigationResponseData *)fromList:(NSArray *)list { + FWFWKNavigationResponseData *pigeonResult = [[FWFWKNavigationResponseData alloc] init]; + pigeonResult.response = + [FWFNSHttpUrlResponseData nullableFromList:(GetNullableObjectAtIndex(list, 0))]; + pigeonResult.forMainFrame = [GetNullableObjectAtIndex(list, 1) boolValue]; + return pigeonResult; +} ++ (nullable FWFWKNavigationResponseData *)nullableFromList:(NSArray *)list { + return (list) ? [FWFWKNavigationResponseData fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + (self.response ? [self.response toList] : [NSNull null]), + @(self.forMainFrame), + ]; +} +@end + @implementation FWFWKFrameInfoData + (instancetype)makeWithIsMainFrame:(BOOL)isMainFrame request:(FWFNSUrlRequestData *)request { FWFWKFrameInfoData *pigeonResult = [[FWFWKFrameInfoData alloc] init]; @@ -1323,26 +1385,28 @@ - (instancetype)initWithBinaryMessenger:(NSObject *)bina } - (void)createWithIdentifier:(NSInteger)arg_identifier completion:(void (^)(FlutterError *_Nullable))completion { - NSString *channelName = - @"dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfigurationFlutterApi.create"; FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName:channelName + messageChannelWithName: + @"dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfigurationFlutterApi.create" binaryMessenger:self.binaryMessenger codec:FWFWKWebViewConfigurationFlutterApiGetCodec()]; - [channel sendMessage:@[ @(arg_identifier) ] - reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion([FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); - } else { - completion(nil); - } - } else { - completion(createConnectionError(channelName)); - } - }]; + [channel + sendMessage:@[ @(arg_identifier) ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion([FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + completion(nil); + } + } else { + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; } @end @@ -1716,28 +1780,30 @@ - (instancetype)initWithBinaryMessenger:(NSObject *)bina userContentControllerIdentifier:(NSInteger)arg_userContentControllerIdentifier message:(FWFWKScriptMessageData *)arg_message completion:(void (^)(FlutterError *_Nullable))completion { - NSString *channelName = @"dev.flutter.pigeon.webview_flutter_wkwebview." - @"WKScriptMessageHandlerFlutterApi.didReceiveScriptMessage"; FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName:channelName + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview." + @"WKScriptMessageHandlerFlutterApi.didReceiveScriptMessage" binaryMessenger:self.binaryMessenger codec:FWFWKScriptMessageHandlerFlutterApiGetCodec()]; - [channel sendMessage:@[ - @(arg_identifier), @(arg_userContentControllerIdentifier), arg_message ?: [NSNull null] - ] - reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion([FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); - } else { - completion(nil); - } - } else { - completion(createConnectionError(channelName)); - } - }]; + [channel + sendMessage:@[ + @(arg_identifier), @(arg_userContentControllerIdentifier), arg_message ?: [NSNull null] + ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion([FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + completion(nil); + } + } else { + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; } @end @@ -1782,13 +1848,17 @@ - (nullable id)readValueOfType:(UInt8)type { case 129: return [FWFNSErrorData fromList:[self readValue]]; case 130: - return [FWFNSUrlRequestData fromList:[self readValue]]; + return [FWFNSHttpUrlResponseData fromList:[self readValue]]; case 131: - return [FWFWKFrameInfoData fromList:[self readValue]]; + return [FWFNSUrlRequestData fromList:[self readValue]]; case 132: - return [FWFWKNavigationActionData fromList:[self readValue]]; + return [FWFWKFrameInfoData fromList:[self readValue]]; case 133: + return [FWFWKNavigationActionData fromList:[self readValue]]; + case 134: return [FWFWKNavigationActionPolicyEnumData fromList:[self readValue]]; + case 135: + return [FWFWKNavigationResponseData fromList:[self readValue]]; default: return [super readValueOfType:type]; } @@ -1805,18 +1875,24 @@ - (void)writeValue:(id)value { } else if ([value isKindOfClass:[FWFNSErrorData class]]) { [self writeByte:129]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFNSUrlRequestData class]]) { + } else if ([value isKindOfClass:[FWFNSHttpUrlResponseData class]]) { [self writeByte:130]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFWKFrameInfoData class]]) { + } else if ([value isKindOfClass:[FWFNSUrlRequestData class]]) { [self writeByte:131]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFWKNavigationActionData class]]) { + } else if ([value isKindOfClass:[FWFWKFrameInfoData class]]) { [self writeByte:132]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFWKNavigationActionPolicyEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKNavigationActionData class]]) { [self writeByte:133]; [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FWFWKNavigationActionPolicyEnumData class]]) { + [self writeByte:134]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FWFWKNavigationResponseData class]]) { + [self writeByte:135]; + [self writeValue:[value toList]]; } else { [super writeValue:value]; } @@ -1862,52 +1938,56 @@ - (void)didFinishNavigationForDelegateWithIdentifier:(NSInteger)arg_identifier webViewIdentifier:(NSInteger)arg_webViewIdentifier URL:(nullable NSString *)arg_url completion:(void (^)(FlutterError *_Nullable))completion { - NSString *channelName = @"dev.flutter.pigeon.webview_flutter_wkwebview." - @"WKNavigationDelegateFlutterApi.didFinishNavigation"; FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName:channelName + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview." + @"WKNavigationDelegateFlutterApi.didFinishNavigation" binaryMessenger:self.binaryMessenger codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; - [channel sendMessage:@[ @(arg_identifier), @(arg_webViewIdentifier), arg_url ?: [NSNull null] ] - reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion([FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); - } else { - completion(nil); - } - } else { - completion(createConnectionError(channelName)); - } - }]; + [channel + sendMessage:@[ @(arg_identifier), @(arg_webViewIdentifier), arg_url ?: [NSNull null] ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion([FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + completion(nil); + } + } else { + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; } - (void)didStartProvisionalNavigationForDelegateWithIdentifier:(NSInteger)arg_identifier webViewIdentifier:(NSInteger)arg_webViewIdentifier URL:(nullable NSString *)arg_url completion:(void (^)(FlutterError *_Nullable)) completion { - NSString *channelName = @"dev.flutter.pigeon.webview_flutter_wkwebview." - @"WKNavigationDelegateFlutterApi.didStartProvisionalNavigation"; FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName:channelName + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview." + @"WKNavigationDelegateFlutterApi.didStartProvisionalNavigation" binaryMessenger:self.binaryMessenger codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; - [channel sendMessage:@[ @(arg_identifier), @(arg_webViewIdentifier), arg_url ?: [NSNull null] ] - reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion([FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); - } else { - completion(nil); - } - } else { - completion(createConnectionError(channelName)); - } - }]; + [channel + sendMessage:@[ @(arg_identifier), @(arg_webViewIdentifier), arg_url ?: [NSNull null] ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion([FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + completion(nil); + } + } else { + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; } - (void)decidePolicyForNavigationActionForDelegateWithIdentifier:(NSInteger)arg_identifier webViewIdentifier:(NSInteger)arg_webViewIdentifier @@ -1918,10 +1998,9 @@ - (void)decidePolicyForNavigationActionForDelegateWithIdentifier:(NSInteger)arg_ FWFWKNavigationActionPolicyEnumData *_Nullable, FlutterError *_Nullable))completion { - NSString *channelName = @"dev.flutter.pigeon.webview_flutter_wkwebview." - @"WKNavigationDelegateFlutterApi.decidePolicyForNavigationAction"; FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName:channelName + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview." + @"WKNavigationDelegateFlutterApi.decidePolicyForNavigationAction" binaryMessenger:self.binaryMessenger codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; [channel sendMessage:@[ @@ -1939,60 +2018,107 @@ - (void)decidePolicyForNavigationActionForDelegateWithIdentifier:(NSInteger)arg_ completion(output, nil); } } else { - completion(nil, createConnectionError(channelName)); + completion(nil, [FlutterError + errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); } }]; } -- (void)didFailNavigationForDelegateWithIdentifier:(NSInteger)arg_identifier - webViewIdentifier:(NSInteger)arg_webViewIdentifier - error:(FWFNSErrorData *)arg_error - completion:(void (^)(FlutterError *_Nullable))completion { - NSString *channelName = @"dev.flutter.pigeon.webview_flutter_wkwebview." - @"WKNavigationDelegateFlutterApi.didFailNavigation"; +- (void)decidePolicyForNavigationResponseForDelegateWithIdentifier:(NSInteger)arg_identifier + webViewIdentifier:(NSInteger)arg_webViewIdentifier + navigationResponse:(FWFWKNavigationResponseData *) + arg_navigationResponse + completion: + (void (^)( + FWFWKNavigationResponsePolicyEnumBox + *_Nullable, + FlutterError *_Nullable)) + completion { FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName:channelName + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview." + @"WKNavigationDelegateFlutterApi.decidePolicyForNavigationResponse" binaryMessenger:self.binaryMessenger codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; - [channel sendMessage:@[ @(arg_identifier), @(arg_webViewIdentifier), arg_error ?: [NSNull null] ] + [channel sendMessage:@[ + @(arg_identifier), @(arg_webViewIdentifier), arg_navigationResponse ?: [NSNull null] + ] reply:^(NSArray *reply) { if (reply != nil) { if (reply.count > 1) { - completion([FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); + completion(nil, [FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); } else { - completion(nil); + NSNumber *outputAsNumber = reply[0] == [NSNull null] ? nil : reply[0]; + FWFWKNavigationResponsePolicyEnumBox *output = + outputAsNumber == nil ? nil + : [[FWFWKNavigationResponsePolicyEnumBox alloc] + initWithValue:[outputAsNumber integerValue]]; + completion(output, nil); } } else { - completion(createConnectionError(channelName)); + completion(nil, [FlutterError + errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); } }]; } +- (void)didFailNavigationForDelegateWithIdentifier:(NSInteger)arg_identifier + webViewIdentifier:(NSInteger)arg_webViewIdentifier + error:(FWFNSErrorData *)arg_error + completion:(void (^)(FlutterError *_Nullable))completion { + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview." + @"WKNavigationDelegateFlutterApi.didFailNavigation" + binaryMessenger:self.binaryMessenger + codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; + [channel + sendMessage:@[ @(arg_identifier), @(arg_webViewIdentifier), arg_error ?: [NSNull null] ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion([FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + completion(nil); + } + } else { + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; +} - (void)didFailProvisionalNavigationForDelegateWithIdentifier:(NSInteger)arg_identifier webViewIdentifier:(NSInteger)arg_webViewIdentifier error:(FWFNSErrorData *)arg_error completion:(void (^)(FlutterError *_Nullable)) completion { - NSString *channelName = @"dev.flutter.pigeon.webview_flutter_wkwebview." - @"WKNavigationDelegateFlutterApi.didFailProvisionalNavigation"; FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName:channelName + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview." + @"WKNavigationDelegateFlutterApi.didFailProvisionalNavigation" binaryMessenger:self.binaryMessenger codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; - [channel sendMessage:@[ @(arg_identifier), @(arg_webViewIdentifier), arg_error ?: [NSNull null] ] - reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion([FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); - } else { - completion(nil); - } - } else { - completion(createConnectionError(channelName)); - } - }]; + [channel + sendMessage:@[ @(arg_identifier), @(arg_webViewIdentifier), arg_error ?: [NSNull null] ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion([FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + completion(nil); + } + } else { + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; } - (void)webViewWebContentProcessDidTerminateForDelegateWithIdentifier:(NSInteger)arg_identifier webViewIdentifier: @@ -2000,40 +2126,41 @@ - (void)webViewWebContentProcessDidTerminateForDelegateWithIdentifier:(NSInteger completion: (void (^)(FlutterError *_Nullable)) completion { - NSString *channelName = @"dev.flutter.pigeon.webview_flutter_wkwebview." - @"WKNavigationDelegateFlutterApi.webViewWebContentProcessDidTerminate"; FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName:channelName + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview." + @"WKNavigationDelegateFlutterApi.webViewWebContentProcessDidTerminate" binaryMessenger:self.binaryMessenger codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; - [channel sendMessage:@[ @(arg_identifier), @(arg_webViewIdentifier) ] - reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion([FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); - } else { - completion(nil); - } - } else { - completion(createConnectionError(channelName)); - } - }]; -} -- (void) - didReceiveAuthenticationChallengeForDelegateWithIdentifier:(NSInteger)arg_identifier - webViewIdentifier:(NSInteger)arg_webViewIdentifier - challengeIdentifier:(NSInteger)arg_challengeIdentifier - completion: - (void (^)(FWFAuthenticationChallengeResponse - *_Nullable, - FlutterError *_Nullable)) + [channel + sendMessage:@[ @(arg_identifier), @(arg_webViewIdentifier) ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion([FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + completion(nil); + } + } else { + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; +} +- (void) + didReceiveAuthenticationChallengeForDelegateWithIdentifier:(NSInteger)arg_identifier + webViewIdentifier:(NSInteger)arg_webViewIdentifier + challengeIdentifier:(NSInteger)arg_challengeIdentifier + completion: + (void (^)(FWFAuthenticationChallengeResponse + *_Nullable, + FlutterError *_Nullable)) completion { - NSString *channelName = @"dev.flutter.pigeon.webview_flutter_wkwebview." - @"WKNavigationDelegateFlutterApi.didReceiveAuthenticationChallenge"; FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName:channelName + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview." + @"WKNavigationDelegateFlutterApi.didReceiveAuthenticationChallenge" binaryMessenger:self.binaryMessenger codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; [channel sendMessage:@[ @(arg_identifier), @(arg_webViewIdentifier), @(arg_challengeIdentifier) ] @@ -2049,7 +2176,10 @@ - (void)webViewWebContentProcessDidTerminateForDelegateWithIdentifier:(NSInteger completion(output, nil); } } else { - completion(nil, createConnectionError(channelName)); + completion(nil, [FlutterError + errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); } }]; } @@ -2261,52 +2391,56 @@ - (void)observeValueForObjectWithIdentifier:(NSInteger)arg_identifier (NSArray *)arg_changeKeys changeValues:(NSArray *)arg_changeValues completion:(void (^)(FlutterError *_Nullable))completion { - NSString *channelName = - @"dev.flutter.pigeon.webview_flutter_wkwebview.NSObjectFlutterApi.observeValue"; - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel messageChannelWithName:channelName - binaryMessenger:self.binaryMessenger - codec:FWFNSObjectFlutterApiGetCodec()]; - [channel sendMessage:@[ - @(arg_identifier), arg_keyPath ?: [NSNull null], @(arg_objectIdentifier), - arg_changeKeys ?: [NSNull null], arg_changeValues ?: [NSNull null] - ] - reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion([FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); - } else { - completion(nil); - } - } else { - completion(createConnectionError(channelName)); - } - }]; + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel + messageChannelWithName: + @"dev.flutter.pigeon.webview_flutter_wkwebview.NSObjectFlutterApi.observeValue" + binaryMessenger:self.binaryMessenger + codec:FWFNSObjectFlutterApiGetCodec()]; + [channel + sendMessage:@[ + @(arg_identifier), arg_keyPath ?: [NSNull null], @(arg_objectIdentifier), + arg_changeKeys ?: [NSNull null], arg_changeValues ?: [NSNull null] + ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion([FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + completion(nil); + } + } else { + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; } - (void)disposeObjectWithIdentifier:(NSInteger)arg_identifier completion:(void (^)(FlutterError *_Nullable))completion { - NSString *channelName = - @"dev.flutter.pigeon.webview_flutter_wkwebview.NSObjectFlutterApi.dispose"; - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel messageChannelWithName:channelName - binaryMessenger:self.binaryMessenger - codec:FWFNSObjectFlutterApiGetCodec()]; - [channel sendMessage:@[ @(arg_identifier) ] - reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion([FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); - } else { - completion(nil); - } - } else { - completion(createConnectionError(channelName)); - } - }]; + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel + messageChannelWithName: + @"dev.flutter.pigeon.webview_flutter_wkwebview.NSObjectFlutterApi.dispose" + binaryMessenger:self.binaryMessenger + codec:FWFNSObjectFlutterApiGetCodec()]; + [channel + sendMessage:@[ @(arg_identifier) ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion([FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + completion(nil); + } + } else { + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; } @end @@ -2324,34 +2458,38 @@ - (nullable id)readValueOfType:(UInt8)type { case 131: return [FWFNSHttpCookiePropertyKeyEnumData fromList:[self readValue]]; case 132: - return [FWFNSKeyValueChangeKeyEnumData fromList:[self readValue]]; + return [FWFNSHttpUrlResponseData fromList:[self readValue]]; case 133: - return [FWFNSKeyValueObservingOptionsEnumData fromList:[self readValue]]; + return [FWFNSKeyValueChangeKeyEnumData fromList:[self readValue]]; case 134: - return [FWFNSUrlRequestData fromList:[self readValue]]; + return [FWFNSKeyValueObservingOptionsEnumData fromList:[self readValue]]; case 135: - return [FWFObjectOrIdentifier fromList:[self readValue]]; + return [FWFNSUrlRequestData fromList:[self readValue]]; case 136: - return [FWFWKAudiovisualMediaTypeEnumData fromList:[self readValue]]; + return [FWFObjectOrIdentifier fromList:[self readValue]]; case 137: - return [FWFWKFrameInfoData fromList:[self readValue]]; + return [FWFWKAudiovisualMediaTypeEnumData fromList:[self readValue]]; case 138: - return [FWFWKMediaCaptureTypeData fromList:[self readValue]]; + return [FWFWKFrameInfoData fromList:[self readValue]]; case 139: - return [FWFWKNavigationActionData fromList:[self readValue]]; + return [FWFWKMediaCaptureTypeData fromList:[self readValue]]; case 140: - return [FWFWKNavigationActionPolicyEnumData fromList:[self readValue]]; + return [FWFWKNavigationActionData fromList:[self readValue]]; case 141: - return [FWFWKPermissionDecisionData fromList:[self readValue]]; + return [FWFWKNavigationActionPolicyEnumData fromList:[self readValue]]; case 142: - return [FWFWKScriptMessageData fromList:[self readValue]]; + return [FWFWKNavigationResponseData fromList:[self readValue]]; case 143: - return [FWFWKSecurityOriginData fromList:[self readValue]]; + return [FWFWKPermissionDecisionData fromList:[self readValue]]; case 144: - return [FWFWKUserScriptData fromList:[self readValue]]; + return [FWFWKScriptMessageData fromList:[self readValue]]; case 145: - return [FWFWKUserScriptInjectionTimeEnumData fromList:[self readValue]]; + return [FWFWKSecurityOriginData fromList:[self readValue]]; case 146: + return [FWFWKUserScriptData fromList:[self readValue]]; + case 147: + return [FWFWKUserScriptInjectionTimeEnumData fromList:[self readValue]]; + case 148: return [FWFWKWebsiteDataTypeEnumData fromList:[self readValue]]; default: return [super readValueOfType:type]; @@ -2375,51 +2513,57 @@ - (void)writeValue:(id)value { } else if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { [self writeByte:131]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFNSKeyValueChangeKeyEnumData class]]) { + } else if ([value isKindOfClass:[FWFNSHttpUrlResponseData class]]) { [self writeByte:132]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { + } else if ([value isKindOfClass:[FWFNSKeyValueChangeKeyEnumData class]]) { [self writeByte:133]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFNSUrlRequestData class]]) { + } else if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { [self writeByte:134]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFObjectOrIdentifier class]]) { + } else if ([value isKindOfClass:[FWFNSUrlRequestData class]]) { [self writeByte:135]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { + } else if ([value isKindOfClass:[FWFObjectOrIdentifier class]]) { [self writeByte:136]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFWKFrameInfoData class]]) { + } else if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { [self writeByte:137]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFWKMediaCaptureTypeData class]]) { + } else if ([value isKindOfClass:[FWFWKFrameInfoData class]]) { [self writeByte:138]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFWKNavigationActionData class]]) { + } else if ([value isKindOfClass:[FWFWKMediaCaptureTypeData class]]) { [self writeByte:139]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFWKNavigationActionPolicyEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKNavigationActionData class]]) { [self writeByte:140]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFWKPermissionDecisionData class]]) { + } else if ([value isKindOfClass:[FWFWKNavigationActionPolicyEnumData class]]) { [self writeByte:141]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFWKScriptMessageData class]]) { + } else if ([value isKindOfClass:[FWFWKNavigationResponseData class]]) { [self writeByte:142]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFWKSecurityOriginData class]]) { + } else if ([value isKindOfClass:[FWFWKPermissionDecisionData class]]) { [self writeByte:143]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFWKUserScriptData class]]) { + } else if ([value isKindOfClass:[FWFWKScriptMessageData class]]) { [self writeByte:144]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKSecurityOriginData class]]) { [self writeByte:145]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKUserScriptData class]]) { [self writeByte:146]; [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { + [self writeByte:147]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { + [self writeByte:148]; + [self writeValue:[value toList]]; } else { [super writeValue:value]; } @@ -3053,29 +3197,31 @@ - (void)onCreateWebViewForDelegateWithIdentifier:(NSInteger)arg_identifier configurationIdentifier:(NSInteger)arg_configurationIdentifier navigationAction:(FWFWKNavigationActionData *)arg_navigationAction completion:(void (^)(FlutterError *_Nullable))completion { - NSString *channelName = - @"dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegateFlutterApi.onCreateWebView"; - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel messageChannelWithName:channelName - binaryMessenger:self.binaryMessenger - codec:FWFWKUIDelegateFlutterApiGetCodec()]; - [channel sendMessage:@[ - @(arg_identifier), @(arg_webViewIdentifier), @(arg_configurationIdentifier), - arg_navigationAction ?: [NSNull null] - ] - reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion([FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); - } else { - completion(nil); - } - } else { - completion(createConnectionError(channelName)); - } - }]; + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel + messageChannelWithName: + @"dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegateFlutterApi.onCreateWebView" + binaryMessenger:self.binaryMessenger + codec:FWFWKUIDelegateFlutterApiGetCodec()]; + [channel + sendMessage:@[ + @(arg_identifier), @(arg_webViewIdentifier), @(arg_configurationIdentifier), + arg_navigationAction ?: [NSNull null] + ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion([FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + completion(nil); + } + } else { + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; } - (void)requestMediaCapturePermissionForDelegateWithIdentifier:(NSInteger)arg_identifier webViewIdentifier:(NSInteger)arg_webViewIdentifier @@ -3086,43 +3232,44 @@ - (void)requestMediaCapturePermissionForDelegateWithIdentifier:(NSInteger)arg_id (void (^)( FWFWKPermissionDecisionData *_Nullable, FlutterError *_Nullable))completion { - NSString *channelName = @"dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegateFlutterApi." - @"requestMediaCapturePermission"; - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel messageChannelWithName:channelName - binaryMessenger:self.binaryMessenger - codec:FWFWKUIDelegateFlutterApiGetCodec()]; - [channel sendMessage:@[ - @(arg_identifier), @(arg_webViewIdentifier), arg_origin ?: [NSNull null], - arg_frame ?: [NSNull null], arg_type ?: [NSNull null] - ] - reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion(nil, [FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); - } else { - FWFWKPermissionDecisionData *output = - reply[0] == [NSNull null] ? nil : reply[0]; - completion(output, nil); - } - } else { - completion(nil, createConnectionError(channelName)); - } - }]; + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegateFlutterApi." + @"requestMediaCapturePermission" + binaryMessenger:self.binaryMessenger + codec:FWFWKUIDelegateFlutterApiGetCodec()]; + [channel + sendMessage:@[ + @(arg_identifier), @(arg_webViewIdentifier), arg_origin ?: [NSNull null], + arg_frame ?: [NSNull null], arg_type ?: [NSNull null] + ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion(nil, [FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + FWFWKPermissionDecisionData *output = reply[0] == [NSNull null] ? nil : reply[0]; + completion(output, nil); + } + } else { + completion(nil, + [FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; } - (void)runJavaScriptAlertPanelForDelegateWithIdentifier:(NSInteger)arg_identifier message:(NSString *)arg_message frame:(FWFWKFrameInfoData *)arg_frame completion: (void (^)(FlutterError *_Nullable))completion { - NSString *channelName = @"dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegateFlutterApi." - @"runJavaScriptAlertPanel"; - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel messageChannelWithName:channelName - binaryMessenger:self.binaryMessenger - codec:FWFWKUIDelegateFlutterApiGetCodec()]; + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegateFlutterApi." + @"runJavaScriptAlertPanel" + binaryMessenger:self.binaryMessenger + codec:FWFWKUIDelegateFlutterApiGetCodec()]; [channel sendMessage:@[ @(arg_identifier), arg_message ?: [NSNull null], arg_frame ?: [NSNull null] ] reply:^(NSArray *reply) { @@ -3135,7 +3282,9 @@ - (void)runJavaScriptAlertPanelForDelegateWithIdentifier:(NSInteger)arg_identifi completion(nil); } } else { - completion(createConnectionError(channelName)); + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); } }]; } @@ -3145,12 +3294,11 @@ - (void)runJavaScriptConfirmPanelForDelegateWithIdentifier:(NSInteger)arg_identi completion: (void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion { - NSString *channelName = @"dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegateFlutterApi." - @"runJavaScriptConfirmPanel"; - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel messageChannelWithName:channelName - binaryMessenger:self.binaryMessenger - codec:FWFWKUIDelegateFlutterApiGetCodec()]; + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegateFlutterApi." + @"runJavaScriptConfirmPanel" + binaryMessenger:self.binaryMessenger + codec:FWFWKUIDelegateFlutterApiGetCodec()]; [channel sendMessage:@[ @(arg_identifier), arg_message ?: [NSNull null], arg_frame ?: [NSNull null] ] reply:^(NSArray *reply) { @@ -3164,7 +3312,10 @@ - (void)runJavaScriptConfirmPanelForDelegateWithIdentifier:(NSInteger)arg_identi completion(output, nil); } } else { - completion(nil, createConnectionError(channelName)); + completion(nil, + [FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); } }]; } @@ -3175,12 +3326,11 @@ - (void)runJavaScriptTextInputPanelForDelegateWithIdentifier:(NSInteger)arg_iden completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable)) completion { - NSString *channelName = @"dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegateFlutterApi." - @"runJavaScriptTextInputPanel"; - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel messageChannelWithName:channelName - binaryMessenger:self.binaryMessenger - codec:FWFWKUIDelegateFlutterApiGetCodec()]; + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegateFlutterApi." + @"runJavaScriptTextInputPanel" + binaryMessenger:self.binaryMessenger + codec:FWFWKUIDelegateFlutterApiGetCodec()]; [channel sendMessage:@[ @(arg_identifier), arg_prompt ?: [NSNull null], arg_defaultText ?: [NSNull null], arg_frame ?: [NSNull null] @@ -3196,7 +3346,10 @@ - (void)runJavaScriptTextInputPanelForDelegateWithIdentifier:(NSInteger)arg_iden completion(output, nil); } } else { - completion(nil, createConnectionError(channelName)); + completion(nil, [FlutterError + errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); } }]; } @@ -3362,25 +3515,27 @@ - (instancetype)initWithBinaryMessenger:(NSObject *)bina } - (void)createWithIdentifier:(NSInteger)arg_identifier completion:(void (^)(FlutterError *_Nullable))completion { - NSString *channelName = @"dev.flutter.pigeon.webview_flutter_wkwebview.NSUrlFlutterApi.create"; - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel messageChannelWithName:channelName - binaryMessenger:self.binaryMessenger - codec:FWFNSUrlFlutterApiGetCodec()]; - [channel sendMessage:@[ @(arg_identifier) ] - reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion([FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); - } else { - completion(nil); - } - } else { - completion(createConnectionError(channelName)); - } - }]; + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview.NSUrlFlutterApi.create" + binaryMessenger:self.binaryMessenger + codec:FWFNSUrlFlutterApiGetCodec()]; + [channel + sendMessage:@[ @(arg_identifier) ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion([FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + completion(nil); + } + } else { + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; } @end @@ -3439,26 +3594,28 @@ - (void)scrollViewDidScrollWithIdentifier:(NSInteger)arg_identifier x:(double)arg_x y:(double)arg_y completion:(void (^)(FlutterError *_Nullable))completion { - NSString *channelName = @"dev.flutter.pigeon.webview_flutter_wkwebview." - @"UIScrollViewDelegateFlutterApi.scrollViewDidScroll"; FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName:channelName + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview." + @"UIScrollViewDelegateFlutterApi.scrollViewDidScroll" binaryMessenger:self.binaryMessenger codec:FWFUIScrollViewDelegateFlutterApiGetCodec()]; - [channel sendMessage:@[ @(arg_identifier), @(arg_uiScrollViewIdentifier), @(arg_x), @(arg_y) ] - reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion([FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); - } else { - completion(nil); - } - } else { - completion(createConnectionError(channelName)); - } - }]; + [channel + sendMessage:@[ @(arg_identifier), @(arg_uiScrollViewIdentifier), @(arg_x), @(arg_y) ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion([FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + completion(nil); + } + } else { + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; } @end @@ -3527,29 +3684,31 @@ - (void)createWithIdentifier:(NSInteger)arg_identifier realm:(nullable NSString *)arg_realm authenticationMethod:(nullable NSString *)arg_authenticationMethod completion:(void (^)(FlutterError *_Nullable))completion { - NSString *channelName = - @"dev.flutter.pigeon.webview_flutter_wkwebview.NSUrlProtectionSpaceFlutterApi.create"; FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName:channelName + messageChannelWithName: + @"dev.flutter.pigeon.webview_flutter_wkwebview.NSUrlProtectionSpaceFlutterApi.create" binaryMessenger:self.binaryMessenger codec:FWFNSUrlProtectionSpaceFlutterApiGetCodec()]; - [channel sendMessage:@[ - @(arg_identifier), arg_host ?: [NSNull null], arg_realm ?: [NSNull null], - arg_authenticationMethod ?: [NSNull null] - ] - reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion([FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); - } else { - completion(nil); - } - } else { - completion(createConnectionError(channelName)); - } - }]; + [channel + sendMessage:@[ + @(arg_identifier), arg_host ?: [NSNull null], arg_realm ?: [NSNull null], + arg_authenticationMethod ?: [NSNull null] + ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion([FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + completion(nil); + } + } else { + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; } @end @@ -3575,25 +3734,27 @@ - (instancetype)initWithBinaryMessenger:(NSObject *)bina - (void)createWithIdentifier:(NSInteger)arg_identifier protectionSpaceIdentifier:(NSInteger)arg_protectionSpaceIdentifier completion:(void (^)(FlutterError *_Nullable))completion { - NSString *channelName = - @"dev.flutter.pigeon.webview_flutter_wkwebview.NSUrlAuthenticationChallengeFlutterApi.create"; FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName:channelName + messageChannelWithName:@"dev.flutter.pigeon.webview_flutter_wkwebview." + @"NSUrlAuthenticationChallengeFlutterApi.create" binaryMessenger:self.binaryMessenger codec:FWFNSUrlAuthenticationChallengeFlutterApiGetCodec()]; - [channel sendMessage:@[ @(arg_identifier), @(arg_protectionSpaceIdentifier) ] - reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion([FlutterError errorWithCode:reply[0] - message:reply[1] - details:reply[2]]); - } else { - completion(nil); - } - } else { - completion(createConnectionError(channelName)); - } - }]; + [channel + sendMessage:@[ @(arg_identifier), @(arg_protectionSpaceIdentifier) ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion([FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + completion(nil); + } + } else { + completion([FlutterError errorWithCode:@"channel-error" + message:@"Unable to establish connection on channel." + details:@""]); + } + }]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m index db8c4562748..2718702d4b9 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m @@ -72,6 +72,24 @@ - (void)didStartProvisionalNavigationForDelegate:(FWFNavigationDelegate *)instan completion:completion]; } +- (void)decidePolicyForNavigationResponseForDelegate:(FWFNavigationDelegate *)instance + webView:(WKWebView *)webView + navigationResponse:(WKNavigationResponse *)navigationResponse + completion: + (void (^)(FWFWKNavigationResponsePolicyEnumBox *, + FlutterError *_Nullable))completion { + NSInteger webViewIdentifier = + [self.instanceManager identifierWithStrongReferenceForInstance:webView]; + FWFWKNavigationResponseData *navigationResponseData = + FWFWKNavigationResponseDataFromNativeNavigationResponse(navigationResponse); + [self + decidePolicyForNavigationResponseForDelegateWithIdentifier:[self + identifierForDelegate:instance] + webViewIdentifier:webViewIdentifier + navigationResponse:navigationResponseData + completion:completion]; +} + - (void)didFailNavigationForDelegate:(FWFNavigationDelegate *)instance webView:(WKWebView *)webView error:(NSError *)error @@ -190,6 +208,26 @@ - (void)webView:(WKWebView *)webView }]; } +- (void)webView:(WKWebView *)webView + decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse + decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler { + [self.navigationDelegateAPI + decidePolicyForNavigationResponseForDelegate:self + webView:webView + navigationResponse:navigationResponse + completion:^(FWFWKNavigationResponsePolicyEnumBox *policy, + FlutterError *error) { + NSAssert(!error, @"%@", error); + if (!error) { + decisionHandler( + FWFNativeWKNavigationResponsePolicyFromEnum( + policy.value)); + } else { + decisionHandler(WKNavigationResponsePolicyCancel); + } + }]; +} + - (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error { diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.g.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.g.dart index 6e1162a97ca..65f55dbbe3f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.g.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.g.dart @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v13.1.2), do not edit directly. +// Autogenerated from Pigeon (v13.0.0), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import @@ -11,13 +11,6 @@ import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; -PlatformException _createConnectionError(String channelName) { - return PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel: "$channelName".', - ); -} - List wrapResponse( {Object? result, PlatformException? error, bool empty = false}) { if (empty) { @@ -101,6 +94,14 @@ enum WKNavigationActionPolicyEnum { cancel, } +/// Mirror of WKNavigationResponsePolicy. +/// +/// See https://developer.apple.com/documentation/webkit/wknavigationactionpolicy?language=objc. +enum WKNavigationResponsePolicyEnum { + allow, + cancel, +} + /// Mirror of NSHTTPCookiePropertyKey. /// /// See https://developer.apple.com/documentation/foundation/nshttpcookiepropertykey. @@ -490,6 +491,30 @@ class NSUrlRequestData { } } +/// Mirror of NSURLResponse. +/// +/// See https://developer.apple.com/documentation/foundation/nshttpurlresponse?language=objc. +class NSHttpUrlResponseData { + NSHttpUrlResponseData({ + required this.statusCode, + }); + + int statusCode; + + Object encode() { + return [ + statusCode, + ]; + } + + static NSHttpUrlResponseData decode(Object result) { + result as List; + return NSHttpUrlResponseData( + statusCode: result[0]! as int, + ); + } +} + /// Mirror of WKUserScript. /// /// See https://developer.apple.com/documentation/webkit/wkuserscript?language=objc. @@ -561,6 +586,35 @@ class WKNavigationActionData { } } +/// Mirror of WKNavigationResponse. +/// +/// See https://developer.apple.com/documentation/webkit/wknavigationresponse. +class WKNavigationResponseData { + WKNavigationResponseData({ + required this.response, + required this.forMainFrame, + }); + + NSHttpUrlResponseData response; + + bool forMainFrame; + + Object encode() { + return [ + response.encode(), + forMainFrame, + ]; + } + + static WKNavigationResponseData decode(Object result) { + result as List; + return WKNavigationResponseData( + response: NSHttpUrlResponseData.decode(result[0]! as List), + forMainFrame: result[1]! as bool, + ); + } +} + /// Mirror of WKFrameInfo. /// /// See https://developer.apple.com/documentation/webkit/wkframeinfo?language=objc. @@ -813,18 +867,18 @@ class WKWebsiteDataStoreHostApi { Future createFromWebViewConfiguration( int arg_identifier, int arg_configurationIdentifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_configurationIdentifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -837,17 +891,17 @@ class WKWebsiteDataStoreHostApi { } Future createDefaultDataStore(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebsiteDataStoreHostApi.createDefaultDataStore'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebsiteDataStoreHostApi.createDefaultDataStore', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -863,20 +917,20 @@ class WKWebsiteDataStoreHostApi { int arg_identifier, List arg_dataTypes, double arg_modificationTimeInSecondsSinceEpoch) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebsiteDataStoreHostApi.removeDataOfTypes'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebsiteDataStoreHostApi.removeDataOfTypes', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([ arg_identifier, arg_dataTypes, arg_modificationTimeInSecondsSinceEpoch ]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -908,17 +962,17 @@ class UIViewHostApi { static const MessageCodec codec = StandardMessageCodec(); Future setBackgroundColor(int arg_identifier, int? arg_value) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.UIViewHostApi.setBackgroundColor'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.UIViewHostApi.setBackgroundColor', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_value]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -931,17 +985,17 @@ class UIViewHostApi { } Future setOpaque(int arg_identifier, bool arg_opaque) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.UIViewHostApi.setOpaque'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.UIViewHostApi.setOpaque', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_opaque]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -969,18 +1023,18 @@ class UIScrollViewHostApi { Future createFromWebView( int arg_identifier, int arg_webViewIdentifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewHostApi.createFromWebView'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewHostApi.createFromWebView', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier, arg_webViewIdentifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -993,17 +1047,17 @@ class UIScrollViewHostApi { } Future> getContentOffset(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewHostApi.getContentOffset'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewHostApi.getContentOffset', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1021,17 +1075,17 @@ class UIScrollViewHostApi { } Future scrollBy(int arg_identifier, double arg_x, double arg_y) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewHostApi.scrollBy'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewHostApi.scrollBy', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_x, arg_y]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1045,17 +1099,17 @@ class UIScrollViewHostApi { Future setContentOffset( int arg_identifier, double arg_x, double arg_y) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewHostApi.setContentOffset'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewHostApi.setContentOffset', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_x, arg_y]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1069,18 +1123,18 @@ class UIScrollViewHostApi { Future setDelegate( int arg_identifier, int? arg_uiScrollViewDelegateIdentifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewHostApi.setDelegate'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewHostApi.setDelegate', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_uiScrollViewDelegateIdentifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1131,17 +1185,17 @@ class WKWebViewConfigurationHostApi { _WKWebViewConfigurationHostApiCodec(); Future create(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfigurationHostApi.create'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfigurationHostApi.create', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1155,18 +1209,18 @@ class WKWebViewConfigurationHostApi { Future createFromWebView( int arg_identifier, int arg_webViewIdentifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfigurationHostApi.createFromWebView'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfigurationHostApi.createFromWebView', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier, arg_webViewIdentifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1180,17 +1234,17 @@ class WKWebViewConfigurationHostApi { Future setAllowsInlineMediaPlayback( int arg_identifier, bool arg_allow) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_allow]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1204,17 +1258,17 @@ class WKWebViewConfigurationHostApi { Future setLimitsNavigationsToAppBoundDomains( int arg_identifier, bool arg_limit) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfigurationHostApi.setLimitsNavigationsToAppBoundDomains'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfigurationHostApi.setLimitsNavigationsToAppBoundDomains', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_limit]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1228,17 +1282,17 @@ class WKWebViewConfigurationHostApi { Future setMediaTypesRequiringUserActionForPlayback(int arg_identifier, List arg_types) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_types]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1335,18 +1389,18 @@ class WKUserContentControllerHostApi { Future createFromWebViewConfiguration( int arg_identifier, int arg_configurationIdentifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKUserContentControllerHostApi.createFromWebViewConfiguration'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKUserContentControllerHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_configurationIdentifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1360,18 +1414,18 @@ class WKUserContentControllerHostApi { Future addScriptMessageHandler( int arg_identifier, int arg_handlerIdentifier, String arg_name) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKUserContentControllerHostApi.addScriptMessageHandler'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKUserContentControllerHostApi.addScriptMessageHandler', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_handlerIdentifier, arg_name]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1385,17 +1439,17 @@ class WKUserContentControllerHostApi { Future removeScriptMessageHandler( int arg_identifier, String arg_name) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKUserContentControllerHostApi.removeScriptMessageHandler'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKUserContentControllerHostApi.removeScriptMessageHandler', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_name]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1408,17 +1462,17 @@ class WKUserContentControllerHostApi { } Future removeAllScriptMessageHandlers(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKUserContentControllerHostApi.removeAllScriptMessageHandlers'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKUserContentControllerHostApi.removeAllScriptMessageHandlers', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1432,17 +1486,17 @@ class WKUserContentControllerHostApi { Future addUserScript( int arg_identifier, WKUserScriptData arg_userScript) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKUserContentControllerHostApi.addUserScript'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKUserContentControllerHostApi.addUserScript', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_userScript]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1455,17 +1509,17 @@ class WKUserContentControllerHostApi { } Future removeAllUserScripts(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKUserContentControllerHostApi.removeAllUserScripts'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKUserContentControllerHostApi.removeAllUserScripts', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1493,18 +1547,18 @@ class WKPreferencesHostApi { Future createFromWebViewConfiguration( int arg_identifier, int arg_configurationIdentifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKPreferencesHostApi.createFromWebViewConfiguration'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKPreferencesHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_configurationIdentifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1518,17 +1572,17 @@ class WKPreferencesHostApi { Future setJavaScriptEnabled( int arg_identifier, bool arg_enabled) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKPreferencesHostApi.setJavaScriptEnabled'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKPreferencesHostApi.setJavaScriptEnabled', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_enabled]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1555,17 +1609,17 @@ class WKScriptMessageHandlerHostApi { static const MessageCodec codec = StandardMessageCodec(); Future create(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKScriptMessageHandlerHostApi.create'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKScriptMessageHandlerHostApi.create', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1665,17 +1719,17 @@ class WKNavigationDelegateHostApi { static const MessageCodec codec = StandardMessageCodec(); Future create(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegateHostApi.create'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegateHostApi.create', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -1698,18 +1752,24 @@ class _WKNavigationDelegateFlutterApiCodec extends StandardMessageCodec { } else if (value is NSErrorData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else if (value is NSUrlRequestData) { + } else if (value is NSHttpUrlResponseData) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else if (value is WKFrameInfoData) { + } else if (value is NSUrlRequestData) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else if (value is WKNavigationActionData) { + } else if (value is WKFrameInfoData) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else if (value is WKNavigationActionPolicyEnumData) { + } else if (value is WKNavigationActionData) { buffer.putUint8(133); writeValue(buffer, value.encode()); + } else if (value is WKNavigationActionPolicyEnumData) { + buffer.putUint8(134); + writeValue(buffer, value.encode()); + } else if (value is WKNavigationResponseData) { + buffer.putUint8(135); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -1723,13 +1783,17 @@ class _WKNavigationDelegateFlutterApiCodec extends StandardMessageCodec { case 129: return NSErrorData.decode(readValue(buffer)!); case 130: - return NSUrlRequestData.decode(readValue(buffer)!); + return NSHttpUrlResponseData.decode(readValue(buffer)!); case 131: - return WKFrameInfoData.decode(readValue(buffer)!); + return NSUrlRequestData.decode(readValue(buffer)!); case 132: - return WKNavigationActionData.decode(readValue(buffer)!); + return WKFrameInfoData.decode(readValue(buffer)!); case 133: + return WKNavigationActionData.decode(readValue(buffer)!); + case 134: return WKNavigationActionPolicyEnumData.decode(readValue(buffer)!); + case 135: + return WKNavigationResponseData.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); } @@ -1753,6 +1817,11 @@ abstract class WKNavigationDelegateFlutterApi { int webViewIdentifier, WKNavigationActionData navigationAction); + Future decidePolicyForNavigationResponse( + int identifier, + int webViewIdentifier, + WKNavigationResponseData navigationResponse); + void didFailNavigation( int identifier, int webViewIdentifier, NSErrorData error); @@ -1867,6 +1936,42 @@ abstract class WKNavigationDelegateFlutterApi { }); } } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegateFlutterApi.decidePolicyForNavigationResponse', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + channel.setMessageHandler(null); + } else { + channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegateFlutterApi.decidePolicyForNavigationResponse was null.'); + final List args = (message as List?)!; + final int? arg_identifier = (args[0] as int?); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegateFlutterApi.decidePolicyForNavigationResponse was null, expected non-null int.'); + final int? arg_webViewIdentifier = (args[1] as int?); + assert(arg_webViewIdentifier != null, + 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegateFlutterApi.decidePolicyForNavigationResponse was null, expected non-null int.'); + final WKNavigationResponseData? arg_navigationResponse = + (args[2] as WKNavigationResponseData?); + assert(arg_navigationResponse != null, + 'Argument for dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegateFlutterApi.decidePolicyForNavigationResponse was null, expected non-null WKNavigationResponseData.'); + try { + final WKNavigationResponsePolicyEnum output = + await api.decidePolicyForNavigationResponse(arg_identifier!, + arg_webViewIdentifier!, arg_navigationResponse!); + return wrapResponse(result: output.index); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.webview_flutter_wkwebview.WKNavigationDelegateFlutterApi.didFailNavigation', @@ -2041,17 +2146,17 @@ class NSObjectHostApi { static const MessageCodec codec = _NSObjectHostApiCodec(); Future dispose(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.NSObjectHostApi.dispose'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.NSObjectHostApi.dispose', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2068,13 +2173,10 @@ class NSObjectHostApi { int arg_observerIdentifier, String arg_keyPath, List arg_options) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.NSObjectHostApi.addObserver'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.NSObjectHostApi.addObserver', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([ arg_identifier, arg_observerIdentifier, @@ -2082,7 +2184,10 @@ class NSObjectHostApi { arg_options ]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2096,18 +2201,18 @@ class NSObjectHostApi { Future removeObserver(int arg_identifier, int arg_observerIdentifier, String arg_keyPath) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.NSObjectHostApi.removeObserver'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.NSObjectHostApi.removeObserver', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send( [arg_identifier, arg_observerIdentifier, arg_keyPath]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2253,51 +2358,57 @@ class _WKWebViewHostApiCodec extends StandardMessageCodec { } else if (value is NSHttpCookiePropertyKeyEnumData) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else if (value is NSKeyValueChangeKeyEnumData) { + } else if (value is NSHttpUrlResponseData) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else if (value is NSKeyValueObservingOptionsEnumData) { + } else if (value is NSKeyValueChangeKeyEnumData) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is NSUrlRequestData) { + } else if (value is NSKeyValueObservingOptionsEnumData) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is ObjectOrIdentifier) { + } else if (value is NSUrlRequestData) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is WKAudiovisualMediaTypeEnumData) { + } else if (value is ObjectOrIdentifier) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is WKFrameInfoData) { + } else if (value is WKAudiovisualMediaTypeEnumData) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is WKMediaCaptureTypeData) { + } else if (value is WKFrameInfoData) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is WKNavigationActionData) { + } else if (value is WKMediaCaptureTypeData) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is WKNavigationActionPolicyEnumData) { + } else if (value is WKNavigationActionData) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is WKPermissionDecisionData) { + } else if (value is WKNavigationActionPolicyEnumData) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is WKScriptMessageData) { + } else if (value is WKNavigationResponseData) { buffer.putUint8(142); writeValue(buffer, value.encode()); - } else if (value is WKSecurityOriginData) { + } else if (value is WKPermissionDecisionData) { buffer.putUint8(143); writeValue(buffer, value.encode()); - } else if (value is WKUserScriptData) { + } else if (value is WKScriptMessageData) { buffer.putUint8(144); writeValue(buffer, value.encode()); - } else if (value is WKUserScriptInjectionTimeEnumData) { + } else if (value is WKSecurityOriginData) { buffer.putUint8(145); writeValue(buffer, value.encode()); - } else if (value is WKWebsiteDataTypeEnumData) { + } else if (value is WKUserScriptData) { buffer.putUint8(146); writeValue(buffer, value.encode()); + } else if (value is WKUserScriptInjectionTimeEnumData) { + buffer.putUint8(147); + writeValue(buffer, value.encode()); + } else if (value is WKWebsiteDataTypeEnumData) { + buffer.putUint8(148); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -2315,34 +2426,38 @@ class _WKWebViewHostApiCodec extends StandardMessageCodec { case 131: return NSHttpCookiePropertyKeyEnumData.decode(readValue(buffer)!); case 132: - return NSKeyValueChangeKeyEnumData.decode(readValue(buffer)!); + return NSHttpUrlResponseData.decode(readValue(buffer)!); case 133: - return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); + return NSKeyValueChangeKeyEnumData.decode(readValue(buffer)!); case 134: - return NSUrlRequestData.decode(readValue(buffer)!); + return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); case 135: - return ObjectOrIdentifier.decode(readValue(buffer)!); + return NSUrlRequestData.decode(readValue(buffer)!); case 136: - return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); + return ObjectOrIdentifier.decode(readValue(buffer)!); case 137: - return WKFrameInfoData.decode(readValue(buffer)!); + return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); case 138: - return WKMediaCaptureTypeData.decode(readValue(buffer)!); + return WKFrameInfoData.decode(readValue(buffer)!); case 139: - return WKNavigationActionData.decode(readValue(buffer)!); + return WKMediaCaptureTypeData.decode(readValue(buffer)!); case 140: - return WKNavigationActionPolicyEnumData.decode(readValue(buffer)!); + return WKNavigationActionData.decode(readValue(buffer)!); case 141: - return WKPermissionDecisionData.decode(readValue(buffer)!); + return WKNavigationActionPolicyEnumData.decode(readValue(buffer)!); case 142: - return WKScriptMessageData.decode(readValue(buffer)!); + return WKNavigationResponseData.decode(readValue(buffer)!); case 143: - return WKSecurityOriginData.decode(readValue(buffer)!); + return WKPermissionDecisionData.decode(readValue(buffer)!); case 144: - return WKUserScriptData.decode(readValue(buffer)!); + return WKScriptMessageData.decode(readValue(buffer)!); case 145: - return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); + return WKSecurityOriginData.decode(readValue(buffer)!); case 146: + return WKUserScriptData.decode(readValue(buffer)!); + case 147: + return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); + case 148: return WKWebsiteDataTypeEnumData.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -2365,18 +2480,18 @@ class WKWebViewHostApi { Future create( int arg_identifier, int arg_configurationIdentifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.create'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.create', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_configurationIdentifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2390,18 +2505,18 @@ class WKWebViewHostApi { Future setUIDelegate( int arg_identifier, int? arg_uiDelegateIdentifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.setUIDelegate'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.setUIDelegate', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier, arg_uiDelegateIdentifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2415,18 +2530,18 @@ class WKWebViewHostApi { Future setNavigationDelegate( int arg_identifier, int? arg_navigationDelegateIdentifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.setNavigationDelegate'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.setNavigationDelegate', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_navigationDelegateIdentifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2439,17 +2554,17 @@ class WKWebViewHostApi { } Future getUrl(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.getUrl'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.getUrl', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2462,17 +2577,17 @@ class WKWebViewHostApi { } Future getEstimatedProgress(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.getEstimatedProgress'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.getEstimatedProgress', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2491,17 +2606,17 @@ class WKWebViewHostApi { Future loadRequest( int arg_identifier, NSUrlRequestData arg_request) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.loadRequest'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.loadRequest', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_request]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2515,18 +2630,18 @@ class WKWebViewHostApi { Future loadHtmlString( int arg_identifier, String arg_string, String? arg_baseUrl) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.loadHtmlString'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.loadHtmlString', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier, arg_string, arg_baseUrl]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2540,18 +2655,18 @@ class WKWebViewHostApi { Future loadFileUrl( int arg_identifier, String arg_url, String arg_readAccessUrl) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.loadFileUrl'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.loadFileUrl', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_url, arg_readAccessUrl]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2564,17 +2679,17 @@ class WKWebViewHostApi { } Future loadFlutterAsset(int arg_identifier, String arg_key) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.loadFlutterAsset'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.loadFlutterAsset', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_key]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2587,17 +2702,17 @@ class WKWebViewHostApi { } Future canGoBack(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.canGoBack'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.canGoBack', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2615,17 +2730,17 @@ class WKWebViewHostApi { } Future canGoForward(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.canGoForward'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.canGoForward', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2643,17 +2758,17 @@ class WKWebViewHostApi { } Future goBack(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.goBack'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.goBack', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2666,17 +2781,17 @@ class WKWebViewHostApi { } Future goForward(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.goForward'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.goForward', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2689,17 +2804,17 @@ class WKWebViewHostApi { } Future reload(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.reload'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.reload', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2712,17 +2827,17 @@ class WKWebViewHostApi { } Future getTitle(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.getTitle'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.getTitle', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2736,17 +2851,17 @@ class WKWebViewHostApi { Future setAllowsBackForwardNavigationGestures( int arg_identifier, bool arg_allow) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.setAllowsBackForwardNavigationGestures'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.setAllowsBackForwardNavigationGestures', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_allow]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2760,17 +2875,17 @@ class WKWebViewHostApi { Future setCustomUserAgent( int arg_identifier, String? arg_userAgent) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.setCustomUserAgent'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.setCustomUserAgent', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_userAgent]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2784,18 +2899,18 @@ class WKWebViewHostApi { Future evaluateJavaScript( int arg_identifier, String arg_javaScriptString) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.evaluateJavaScript'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.evaluateJavaScript', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier, arg_javaScriptString]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2808,17 +2923,17 @@ class WKWebViewHostApi { } Future setInspectable(int arg_identifier, bool arg_inspectable) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.setInspectable'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.setInspectable', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_inspectable]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2831,17 +2946,17 @@ class WKWebViewHostApi { } Future getCustomUserAgent(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.getCustomUserAgent'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKWebViewHostApi.getCustomUserAgent', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -2868,17 +2983,17 @@ class WKUIDelegateHostApi { static const MessageCodec codec = StandardMessageCodec(); Future create(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegateHostApi.create'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKUIDelegateHostApi.create', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -3202,18 +3317,18 @@ class WKHttpCookieStoreHostApi { Future createFromWebsiteDataStore( int arg_identifier, int arg_websiteDataStoreIdentifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKHttpCookieStoreHostApi.createFromWebsiteDataStore'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKHttpCookieStoreHostApi.createFromWebsiteDataStore', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_websiteDataStoreIdentifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -3227,17 +3342,17 @@ class WKHttpCookieStoreHostApi { Future setCookie( int arg_identifier, NSHttpCookieData arg_cookie) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.WKHttpCookieStoreHostApi.setCookie'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.WKHttpCookieStoreHostApi.setCookie', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel .send([arg_identifier, arg_cookie]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -3268,17 +3383,17 @@ class NSUrlHostApi { static const MessageCodec codec = StandardMessageCodec(); Future getAbsoluteString(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.NSUrlHostApi.getAbsoluteString'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.NSUrlHostApi.getAbsoluteString', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -3352,17 +3467,17 @@ class UIScrollViewDelegateHostApi { static const MessageCodec codec = StandardMessageCodec(); Future create(int arg_identifier) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewDelegateHostApi.create'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.UIScrollViewDelegateHostApi.create', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, @@ -3446,13 +3561,10 @@ class NSUrlCredentialHostApi { /// Create a new native instance and add it to the `InstanceManager`. Future createWithUser(int arg_identifier, String arg_user, String arg_password, NSUrlCredentialPersistence arg_persistence) async { - const String channelName = - 'dev.flutter.pigeon.webview_flutter_wkwebview.NSUrlCredentialHostApi.createWithUser'; final BasicMessageChannel channel = BasicMessageChannel( - channelName, - codec, - binaryMessenger: _binaryMessenger, - ); + 'dev.flutter.pigeon.webview_flutter_wkwebview.NSUrlCredentialHostApi.createWithUser', + codec, + binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([ arg_identifier, arg_user, @@ -3460,7 +3572,10 @@ class NSUrlCredentialHostApi { arg_persistence.index ]) as List?; if (replyList == null) { - throw _createConnectionError(channelName); + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); } else if (replyList.length > 1) { throw PlatformException( code: replyList[0]! as String, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart index 5c6d61aa8f7..1dabbd0c24a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart @@ -221,6 +221,21 @@ class NSErrorUserInfoKey { 'NSErrorFailingURLStringKey'; } +/// The metadata associated with the response to an HTTP protocol URL load +/// request. +/// +/// Wraps [NSHttpUrlResponse](https://developer.apple.com/documentation/foundation/nshttpurlresponse?language=objc). +@immutable +class NSHttpUrlResponse { + /// Constructs an [NSHttpUrlResponse]. + const NSHttpUrlResponse({ + required this.statusCode, + }); + + /// The response’s HTTP status code. + final int statusCode; +} + /// Information about an error condition. /// /// Wraps [NSError](https://developer.apple.com/documentation/foundation/nserror?language=objc). diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart index fb99be0940e..11065ad0805 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart @@ -97,6 +97,21 @@ enum WKNavigationActionPolicy { cancel, } +/// Indicate whether to allow or cancel navigation to a webpage. +/// +/// Wraps [WKNavigationResponsePolicy](https://developer.apple.com/documentation/webkit/wknavigationresponsepolicy?language=objc). +enum WKNavigationResponsePolicy { + /// Allow navigation to continue. + /// + /// See https://developer.apple.com/documentation/webkit/wknavigationresponsepolicy/wknavigationresponsepolicyallow?language=objc. + allow, + + /// Cancel navigation. + /// + /// See https://developer.apple.com/documentation/webkit/wknavigationresponsepolicy/wknavigationresponsepolicycancel?language=objc. + cancel, +} + /// Possible error values that WebKit APIs can return. /// /// See https://developer.apple.com/documentation/webkit/wkerrorcode. @@ -163,6 +178,24 @@ class WKNavigationAction { final WKNavigationType navigationType; } +/// An object that contains information about a response to a navigation request. +/// +/// Wraps [WKNavigationResponse](https://developer.apple.com/documentation/webkit/wknavigationresponse?language=objc). +@immutable +class WKNavigationResponse { + /// Constructs a [WKNavigationResponse]. + const WKNavigationResponse({ + required this.response, + required this.forMainFrame, + }); + + /// The URL request object associated with the navigation action. + final NSHttpUrlResponse response; + + /// The frame in which to display the new content. + final bool forMainFrame; +} + /// An object that contains information about a frame on a webpage. /// /// An instance of this class is a transient, data-only object; it does not @@ -858,6 +891,7 @@ class WKNavigationDelegate extends NSObject { this.didFinishNavigation, this.didStartProvisionalNavigation, this.decidePolicyForNavigationAction, + this.decidePolicyForNavigationResponse, this.didFailNavigation, this.didFailProvisionalNavigation, this.webViewWebContentProcessDidTerminate, @@ -884,6 +918,7 @@ class WKNavigationDelegate extends NSObject { this.didFinishNavigation, this.didStartProvisionalNavigation, this.decidePolicyForNavigationAction, + this.decidePolicyForNavigationResponse, this.didFailNavigation, this.didFailProvisionalNavigation, this.webViewWebContentProcessDidTerminate, @@ -918,6 +953,14 @@ class WKNavigationDelegate extends NSObject { WKNavigationAction navigationAction, )? decidePolicyForNavigationAction; + /// Called when permission is needed to navigate to new content. + /// + /// {@macro webview_flutter_wkwebview.foundation.callbacks} + final Future Function( + WKWebView webView, + WKNavigationResponse navigationResponse, + )? decidePolicyForNavigationResponse; + /// Called when an error occurred during navigation. /// /// {@macro webview_flutter_wkwebview.foundation.callbacks} @@ -950,6 +993,7 @@ class WKNavigationDelegate extends NSObject { didFinishNavigation: didFinishNavigation, didStartProvisionalNavigation: didStartProvisionalNavigation, decidePolicyForNavigationAction: decidePolicyForNavigationAction, + decidePolicyForNavigationResponse: decidePolicyForNavigationResponse, didFailNavigation: didFailNavigation, didFailProvisionalNavigation: didFailProvisionalNavigation, webViewWebContentProcessDidTerminate: diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart index ac3bfc83f13..bdcc19eafd6 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart @@ -70,6 +70,14 @@ extension _WKNavigationActionPolicyConverter on WKNavigationActionPolicy { } } +extension _WKNavigationResponsePolicyConverter on WKNavigationResponsePolicy { + WKNavigationResponsePolicyEnum toWKNavigationResponsePolicyEnumData() { + return WKNavigationResponsePolicyEnum.values.firstWhere( + (WKNavigationResponsePolicyEnum element) => element.name == name, + ); + } +} + extension _NSHttpCookiePropertyKeyConverter on NSHttpCookiePropertyKey { NSHttpCookiePropertyKeyEnumData toNSHttpCookiePropertyKeyEnumData() { late final NSHttpCookiePropertyKeyEnum value; @@ -153,6 +161,13 @@ extension _NavigationActionDataConverter on WKNavigationActionData { } } +extension _NavigationResponseDataConverter on WKNavigationResponseData { + WKNavigationResponse toNavigationResponse() { + return WKNavigationResponse( + response: response.toNSUrlResponse(), forMainFrame: forMainFrame); + } +} + extension _WKFrameInfoDataConverter on WKFrameInfoData { WKFrameInfo toWKFrameInfo() { return WKFrameInfo( @@ -173,6 +188,12 @@ extension _NSUrlRequestDataConverter on NSUrlRequestData { } } +extension _NSUrlResponseDataConverter on NSHttpUrlResponseData { + NSHttpUrlResponse toNSUrlResponse() { + return NSHttpUrlResponse(statusCode: statusCode); + } +} + extension _WKNSErrorDataConverter on NSErrorData { NSError toNSError() { return NSError( @@ -907,6 +928,29 @@ class WKNavigationDelegateFlutterApiImpl ); } + @override + Future decidePolicyForNavigationResponse( + int identifier, + int webViewIdentifier, + WKNavigationResponseData navigationResponse, + ) async { + final Future Function( + WKWebView, + WKNavigationResponse navigationResponse, + )? function = _getDelegate(identifier).decidePolicyForNavigationResponse; + + if (function == null) { + return WKNavigationResponsePolicyEnum.allow; + } + + final WKNavigationResponsePolicy policy = await function( + instanceManager.getInstanceWithWeakReference(webViewIdentifier)! + as WKWebView, + navigationResponse.toNavigationResponse(), + ); + return policy.toWKNavigationResponsePolicyEnumData(); + } + @override void webViewWebContentProcessDidTerminate( int identifier, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_proxy.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_proxy.dart index e4793d7e0ed..ffd9b845eab 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_proxy.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_proxy.dart @@ -69,6 +69,10 @@ class WebKitProxy { WKWebView webView, WKNavigationAction navigationAction, )? decidePolicyForNavigationAction, + Future Function( + WKWebView webView, + WKNavigationResponse navigationResponse, + )? decidePolicyForNavigationResponse, void Function(WKWebView webView, NSError error)? didFailNavigation, void Function(WKWebView webView, NSError error)? didFailProvisionalNavigation, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_webview_controller.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_webview_controller.dart index c4e38230de8..b9e9386239e 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_webview_controller.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_webview_controller.dart @@ -986,6 +986,22 @@ class WebKitNavigationDelegate extends PlatformNavigationDelegate { weakThis.target!._onPageStarted!(url ?? ''); } }, + decidePolicyForNavigationResponse: + (WKWebView webView, WKNavigationResponse response) async { + if (weakThis.target?._onHttpError != null && + response.response.statusCode >= 400) { + weakThis.target!._onHttpError!( + HttpResponseError( + response: WebResourceResponse( + uri: null, + statusCode: response.response.statusCode, + ), + ), + ); + } + + return WKNavigationResponsePolicy.allow; + }, decidePolicyForNavigationAction: ( WKWebView webView, WKNavigationAction action, @@ -1100,6 +1116,7 @@ class WebKitNavigationDelegate extends PlatformNavigationDelegate { PageEventCallback? _onPageFinished; PageEventCallback? _onPageStarted; + HttpResponseErrorCallback? _onHttpError; ProgressCallback? _onProgress; WebResourceErrorCallback? _onWebResourceError; NavigationRequestCallback? _onNavigationRequest; @@ -1116,6 +1133,11 @@ class WebKitNavigationDelegate extends PlatformNavigationDelegate { _onPageStarted = onPageStarted; } + @override + Future setOnHttpError(HttpResponseErrorCallback onHttpError) async { + _onHttpError = onHttpError; + } + @override Future setOnProgress(ProgressCallback onProgress) async { _onProgress = onProgress; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart index 5b0ea12db51..e660db3ef89 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart @@ -28,7 +28,7 @@ enum NSKeyValueObservingOptionsEnum { priorNotification, } -// TODO(bparrishMines): Enums need be wrapped in a data class because thay can't +// TODO(bparrishMines): Enums need be wrapped in a data class because they can't // be used as primitive arguments. See https://github.com/flutter/flutter/issues/87307 class NSKeyValueObservingOptionsEnumData { late NSKeyValueObservingOptionsEnum value; @@ -44,7 +44,7 @@ enum NSKeyValueChangeEnum { replacement, } -// TODO(bparrishMines): Enums need be wrapped in a data class because thay can't +// TODO(bparrishMines): Enums need be wrapped in a data class because they can't // be used as primitive arguments. See https://github.com/flutter/flutter/issues/87307 class NSKeyValueChangeEnumData { late NSKeyValueChangeEnum value; @@ -62,7 +62,7 @@ enum NSKeyValueChangeKeyEnum { unknown, } -// TODO(bparrishMines): Enums need be wrapped in a data class because thay can't +// TODO(bparrishMines): Enums need be wrapped in a data class because they can't // be used as primitive arguments. See https://github.com/flutter/flutter/issues/87307 class NSKeyValueChangeKeyEnumData { late NSKeyValueChangeKeyEnum value; @@ -76,7 +76,7 @@ enum WKUserScriptInjectionTimeEnum { atDocumentEnd, } -// TODO(bparrishMines): Enums need be wrapped in a data class because thay can't +// TODO(bparrishMines): Enums need be wrapped in a data class because they can't // be used as primitive arguments. See https://github.com/flutter/flutter/issues/87307 class WKUserScriptInjectionTimeEnumData { late WKUserScriptInjectionTimeEnum value; @@ -92,7 +92,7 @@ enum WKAudiovisualMediaTypeEnum { all, } -// TODO(bparrishMines): Enums need be wrapped in a data class because thay can't +// TODO(bparrishMines): Enums need be wrapped in a data class because they can't // be used as primitive arguments. See https://github.com/flutter/flutter/issues/87307 class WKAudiovisualMediaTypeEnumData { late WKAudiovisualMediaTypeEnum value; @@ -112,7 +112,7 @@ enum WKWebsiteDataTypeEnum { indexedDBDatabases, } -// TODO(bparrishMines): Enums need be wrapped in a data class because thay can't +// TODO(bparrishMines): Enums need be wrapped in a data class because they can't // be used as primitive arguments. See https://github.com/flutter/flutter/issues/87307 class WKWebsiteDataTypeEnumData { late WKWebsiteDataTypeEnum value; @@ -126,12 +126,20 @@ enum WKNavigationActionPolicyEnum { cancel, } -// TODO(bparrishMines): Enums need be wrapped in a data class because thay can't +// TODO(bparrishMines): Enums need be wrapped in a data class because they can't // be used as primitive arguments. See https://github.com/flutter/flutter/issues/87307 class WKNavigationActionPolicyEnumData { late WKNavigationActionPolicyEnum value; } +/// Mirror of WKNavigationResponsePolicy. +/// +/// See https://developer.apple.com/documentation/webkit/wknavigationactionpolicy?language=objc. +enum WKNavigationResponsePolicyEnum { + allow, + cancel, +} + /// Mirror of NSHTTPCookiePropertyKey. /// /// See https://developer.apple.com/documentation/foundation/nshttpcookiepropertykey. @@ -152,7 +160,7 @@ enum NSHttpCookiePropertyKeyEnum { version, } -// TODO(bparrishMines): Enums need be wrapped in a data class because thay can't +// TODO(bparrishMines): Enums need be wrapped in a data class because they can't // be used as primitive arguments. See https://github.com/flutter/flutter/issues/87307 class NSHttpCookiePropertyKeyEnumData { late NSHttpCookiePropertyKeyEnum value; @@ -220,7 +228,7 @@ enum WKPermissionDecision { prompt, } -// TODO(bparrishMines): Enums need be wrapped in a data class because thay can't +// TODO(bparrishMines): Enums need be wrapped in a data class because they can't // be used as primitive arguments. See https://github.com/flutter/flutter/issues/87307 class WKPermissionDecisionData { late WKPermissionDecision value; @@ -252,7 +260,7 @@ enum WKMediaCaptureType { unknown, } -// TODO(bparrishMines): Enums need be wrapped in a data class because thay can't +// TODO(bparrishMines): Enums need be wrapped in a data class because they can't // be used as primitive arguments. See https://github.com/flutter/flutter/issues/87307 class WKMediaCaptureTypeData { late WKMediaCaptureType value; @@ -320,6 +328,13 @@ class NSUrlRequestData { late Map allHttpHeaderFields; } +/// Mirror of NSURLResponse. +/// +/// See https://developer.apple.com/documentation/foundation/nshttpurlresponse?language=objc. +class NSHttpUrlResponseData { + late int statusCode; +} + /// Mirror of WKUserScript. /// /// See https://developer.apple.com/documentation/webkit/wkuserscript?language=objc. @@ -338,6 +353,14 @@ class WKNavigationActionData { late WKNavigationType navigationType; } +/// Mirror of WKNavigationResponse. +/// +/// See https://developer.apple.com/documentation/webkit/wknavigationresponse. +class WKNavigationResponseData { + late NSHttpUrlResponseData response; + late bool forMainFrame; +} + /// Mirror of WKFrameInfo. /// /// See https://developer.apple.com/documentation/webkit/wkframeinfo?language=objc. @@ -619,6 +642,16 @@ abstract class WKNavigationDelegateFlutterApi { WKNavigationActionData navigationAction, ); + @ObjCSelector( + 'decidePolicyForNavigationResponseForDelegateWithIdentifier:webViewIdentifier:navigationResponse:', + ) + @async + WKNavigationResponsePolicyEnum decidePolicyForNavigationResponse( + int identifier, + int webViewIdentifier, + WKNavigationResponseData navigationResponse, + ); + @ObjCSelector( 'didFailNavigationForDelegateWithIdentifier:webViewIdentifier:error:', ) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml b/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml index 18a0cef72e8..bffa7eaf66a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml +++ b/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml @@ -2,7 +2,7 @@ name: webview_flutter_wkwebview description: A Flutter plugin that provides a WebView widget based on Apple's WKWebView control. repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_wkwebview issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22 -version: 3.12.0 +version: 3.13.0 environment: sdk: ^3.2.3 @@ -20,7 +20,7 @@ dependencies: flutter: sdk: flutter path: ^1.8.0 - webview_flutter_platform_interface: ^2.9.0 + webview_flutter_platform_interface: ^2.10.0 dev_dependencies: build_runner: ^2.1.5 diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_cookie_manager_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_cookie_manager_test.mocks.dart index fe13a87048e..eb58b7eb11e 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_cookie_manager_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_cookie_manager_test.mocks.dart @@ -63,7 +63,6 @@ class MockWKHttpCookieStore extends _i1.Mock implements _i2.WKHttpCookieStore { returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); - @override _i2.WKHttpCookieStore copy() => (super.noSuchMethod( Invocation.method( @@ -78,7 +77,6 @@ class MockWKHttpCookieStore extends _i1.Mock implements _i2.WKHttpCookieStore { ), ), ) as _i2.WKHttpCookieStore); - @override _i3.Future addObserver( _i4.NSObject? observer, { @@ -97,7 +95,6 @@ class MockWKHttpCookieStore extends _i1.Mock implements _i2.WKHttpCookieStore { returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); - @override _i3.Future removeObserver( _i4.NSObject? observer, { @@ -132,7 +129,6 @@ class MockWKWebsiteDataStore extends _i1.Mock Invocation.getter(#httpCookieStore), ), ) as _i2.WKHttpCookieStore); - @override _i3.Future removeDataOfTypes( Set<_i2.WKWebsiteDataType>? dataTypes, @@ -148,7 +144,6 @@ class MockWKWebsiteDataStore extends _i1.Mock ), returnValue: _i3.Future.value(false), ) as _i3.Future); - @override _i2.WKWebsiteDataStore copy() => (super.noSuchMethod( Invocation.method( @@ -163,7 +158,6 @@ class MockWKWebsiteDataStore extends _i1.Mock ), ), ) as _i2.WKWebsiteDataStore); - @override _i3.Future addObserver( _i4.NSObject? observer, { @@ -182,7 +176,6 @@ class MockWKWebsiteDataStore extends _i1.Mock returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); - @override _i3.Future removeObserver( _i4.NSObject? observer, { diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_webview_widget_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_webview_widget_test.mocks.dart index 411002e479e..a33d5ac5830 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_webview_widget_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/legacy/web_kit_webview_widget_test.mocks.dart @@ -174,7 +174,6 @@ class MockUIScrollView extends _i1.Mock implements _i3.UIScrollView { ), )), ) as _i5.Future<_i2.Point>); - @override _i5.Future scrollBy(_i2.Point? offset) => (super.noSuchMethod( Invocation.method( @@ -184,7 +183,6 @@ class MockUIScrollView extends _i1.Mock implements _i3.UIScrollView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future setContentOffset(_i2.Point? offset) => (super.noSuchMethod( @@ -195,7 +193,6 @@ class MockUIScrollView extends _i1.Mock implements _i3.UIScrollView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future setDelegate(_i3.UIScrollViewDelegate? delegate) => (super.noSuchMethod( @@ -206,7 +203,6 @@ class MockUIScrollView extends _i1.Mock implements _i3.UIScrollView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i3.UIScrollView copy() => (super.noSuchMethod( Invocation.method( @@ -221,7 +217,6 @@ class MockUIScrollView extends _i1.Mock implements _i3.UIScrollView { ), ), ) as _i3.UIScrollView); - @override _i5.Future setBackgroundColor(_i6.Color? color) => (super.noSuchMethod( Invocation.method( @@ -231,7 +226,6 @@ class MockUIScrollView extends _i1.Mock implements _i3.UIScrollView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future setOpaque(bool? opaque) => (super.noSuchMethod( Invocation.method( @@ -241,7 +235,6 @@ class MockUIScrollView extends _i1.Mock implements _i3.UIScrollView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future addObserver( _i7.NSObject? observer, { @@ -260,7 +253,6 @@ class MockUIScrollView extends _i1.Mock implements _i3.UIScrollView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future removeObserver( _i7.NSObject? observer, { @@ -301,7 +293,6 @@ class MockWKNavigationDelegate extends _i1.Mock ), ), ) as _i4.WKNavigationDelegate); - @override _i5.Future addObserver( _i7.NSObject? observer, { @@ -320,7 +311,6 @@ class MockWKNavigationDelegate extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future removeObserver( _i7.NSObject? observer, { @@ -355,7 +345,6 @@ class MockWKPreferences extends _i1.Mock implements _i4.WKPreferences { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i4.WKPreferences copy() => (super.noSuchMethod( Invocation.method( @@ -370,7 +359,6 @@ class MockWKPreferences extends _i1.Mock implements _i4.WKPreferences { ), ), ) as _i4.WKPreferences); - @override _i5.Future addObserver( _i7.NSObject? observer, { @@ -389,7 +377,6 @@ class MockWKPreferences extends _i1.Mock implements _i4.WKPreferences { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future removeObserver( _i7.NSObject? observer, { @@ -430,7 +417,6 @@ class MockWKScriptMessageHandler extends _i1.Mock _i4.WKUserContentController, _i4.WKScriptMessage, )); - @override _i4.WKScriptMessageHandler copy() => (super.noSuchMethod( Invocation.method( @@ -445,7 +431,6 @@ class MockWKScriptMessageHandler extends _i1.Mock ), ), ) as _i4.WKScriptMessageHandler); - @override _i5.Future addObserver( _i7.NSObject? observer, { @@ -464,7 +449,6 @@ class MockWKScriptMessageHandler extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future removeObserver( _i7.NSObject? observer, { @@ -498,7 +482,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { Invocation.getter(#configuration), ), ) as _i4.WKWebViewConfiguration); - @override _i3.UIScrollView get scrollView => (super.noSuchMethod( Invocation.getter(#scrollView), @@ -507,7 +490,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { Invocation.getter(#scrollView), ), ) as _i3.UIScrollView); - @override _i5.Future setUIDelegate(_i4.WKUIDelegate? delegate) => (super.noSuchMethod( @@ -518,7 +500,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future setNavigationDelegate(_i4.WKNavigationDelegate? delegate) => (super.noSuchMethod( @@ -529,7 +510,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future getUrl() => (super.noSuchMethod( Invocation.method( @@ -538,7 +518,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { ), returnValue: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future getEstimatedProgress() => (super.noSuchMethod( Invocation.method( @@ -547,7 +526,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { ), returnValue: _i5.Future.value(0.0), ) as _i5.Future); - @override _i5.Future loadRequest(_i7.NSUrlRequest? request) => (super.noSuchMethod( @@ -558,7 +536,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future loadHtmlString( String? string, { @@ -573,7 +550,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future loadFileUrl( String? url, { @@ -588,7 +564,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future loadFlutterAsset(String? key) => (super.noSuchMethod( Invocation.method( @@ -598,7 +573,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future canGoBack() => (super.noSuchMethod( Invocation.method( @@ -607,7 +581,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { ), returnValue: _i5.Future.value(false), ) as _i5.Future); - @override _i5.Future canGoForward() => (super.noSuchMethod( Invocation.method( @@ -616,7 +589,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { ), returnValue: _i5.Future.value(false), ) as _i5.Future); - @override _i5.Future goBack() => (super.noSuchMethod( Invocation.method( @@ -626,7 +598,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future goForward() => (super.noSuchMethod( Invocation.method( @@ -636,7 +607,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future reload() => (super.noSuchMethod( Invocation.method( @@ -646,7 +616,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future getTitle() => (super.noSuchMethod( Invocation.method( @@ -655,7 +624,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { ), returnValue: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future setAllowsBackForwardNavigationGestures(bool? allow) => (super.noSuchMethod( @@ -666,7 +634,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future setCustomUserAgent(String? userAgent) => (super.noSuchMethod( Invocation.method( @@ -676,7 +643,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future evaluateJavaScript(String? javaScriptString) => (super.noSuchMethod( @@ -686,7 +652,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { ), returnValue: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future setInspectable(bool? inspectable) => (super.noSuchMethod( Invocation.method( @@ -696,7 +661,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future getCustomUserAgent() => (super.noSuchMethod( Invocation.method( @@ -705,7 +669,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { ), returnValue: _i5.Future.value(), ) as _i5.Future); - @override _i4.WKWebView copy() => (super.noSuchMethod( Invocation.method( @@ -720,7 +683,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { ), ), ) as _i4.WKWebView); - @override _i5.Future setBackgroundColor(_i6.Color? color) => (super.noSuchMethod( Invocation.method( @@ -730,7 +692,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future setOpaque(bool? opaque) => (super.noSuchMethod( Invocation.method( @@ -740,7 +701,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future addObserver( _i7.NSObject? observer, { @@ -759,7 +719,6 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future removeObserver( _i7.NSObject? observer, { @@ -794,7 +753,6 @@ class MockWKWebViewConfiguration extends _i1.Mock Invocation.getter(#userContentController), ), ) as _i4.WKUserContentController); - @override _i4.WKPreferences get preferences => (super.noSuchMethod( Invocation.getter(#preferences), @@ -803,7 +761,6 @@ class MockWKWebViewConfiguration extends _i1.Mock Invocation.getter(#preferences), ), ) as _i4.WKPreferences); - @override _i4.WKWebsiteDataStore get websiteDataStore => (super.noSuchMethod( Invocation.getter(#websiteDataStore), @@ -812,7 +769,6 @@ class MockWKWebViewConfiguration extends _i1.Mock Invocation.getter(#websiteDataStore), ), ) as _i4.WKWebsiteDataStore); - @override _i5.Future setAllowsInlineMediaPlayback(bool? allow) => (super.noSuchMethod( @@ -823,7 +779,6 @@ class MockWKWebViewConfiguration extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future setLimitsNavigationsToAppBoundDomains(bool? limit) => (super.noSuchMethod( @@ -834,7 +789,6 @@ class MockWKWebViewConfiguration extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future setMediaTypesRequiringUserActionForPlayback( Set<_i4.WKAudiovisualMediaType>? types) => @@ -846,7 +800,6 @@ class MockWKWebViewConfiguration extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i4.WKWebViewConfiguration copy() => (super.noSuchMethod( Invocation.method( @@ -861,7 +814,6 @@ class MockWKWebViewConfiguration extends _i1.Mock ), ), ) as _i4.WKWebViewConfiguration); - @override _i5.Future addObserver( _i7.NSObject? observer, { @@ -880,7 +832,6 @@ class MockWKWebViewConfiguration extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future removeObserver( _i7.NSObject? observer, { @@ -915,7 +866,6 @@ class MockWKWebsiteDataStore extends _i1.Mock Invocation.getter(#httpCookieStore), ), ) as _i4.WKHttpCookieStore); - @override _i5.Future removeDataOfTypes( Set<_i4.WKWebsiteDataType>? dataTypes, @@ -931,7 +881,6 @@ class MockWKWebsiteDataStore extends _i1.Mock ), returnValue: _i5.Future.value(false), ) as _i5.Future); - @override _i4.WKWebsiteDataStore copy() => (super.noSuchMethod( Invocation.method( @@ -946,7 +895,6 @@ class MockWKWebsiteDataStore extends _i1.Mock ), ), ) as _i4.WKWebsiteDataStore); - @override _i5.Future addObserver( _i7.NSObject? observer, { @@ -965,7 +913,6 @@ class MockWKWebsiteDataStore extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future removeObserver( _i7.NSObject? observer, { @@ -1005,7 +952,6 @@ class MockWKUIDelegate extends _i1.Mock implements _i4.WKUIDelegate { ), ), ) as _i4.WKUIDelegate); - @override _i5.Future addObserver( _i7.NSObject? observer, { @@ -1024,7 +970,6 @@ class MockWKUIDelegate extends _i1.Mock implements _i4.WKUIDelegate { returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future removeObserver( _i7.NSObject? observer, { @@ -1067,7 +1012,6 @@ class MockWKUserContentController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future removeScriptMessageHandler(String? name) => (super.noSuchMethod( @@ -1078,7 +1022,6 @@ class MockWKUserContentController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future removeAllScriptMessageHandlers() => (super.noSuchMethod( Invocation.method( @@ -1088,7 +1031,6 @@ class MockWKUserContentController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future addUserScript(_i4.WKUserScript? userScript) => (super.noSuchMethod( @@ -1099,7 +1041,6 @@ class MockWKUserContentController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future removeAllUserScripts() => (super.noSuchMethod( Invocation.method( @@ -1109,7 +1050,6 @@ class MockWKUserContentController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i4.WKUserContentController copy() => (super.noSuchMethod( Invocation.method( @@ -1124,7 +1064,6 @@ class MockWKUserContentController extends _i1.Mock ), ), ) as _i4.WKUserContentController); - @override _i5.Future addObserver( _i7.NSObject? observer, { @@ -1143,7 +1082,6 @@ class MockWKUserContentController extends _i1.Mock returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); - @override _i5.Future removeObserver( _i7.NSObject? observer, { @@ -1174,7 +1112,6 @@ class MockJavascriptChannelRegistry extends _i1.Mock Invocation.getter(#channels), returnValue: {}, ) as Map); - @override void onJavascriptChannelMessage( String? channel, @@ -1190,7 +1127,6 @@ class MockJavascriptChannelRegistry extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void updateJavascriptChannelsFromSet(Set<_i9.JavascriptChannel>? channels) => super.noSuchMethod( @@ -1227,7 +1163,6 @@ class MockWebViewPlatformCallbacksHandler extends _i1.Mock ), returnValue: _i5.Future.value(false), ) as _i5.FutureOr); - @override void onPageStarted(String? url) => super.noSuchMethod( Invocation.method( @@ -1236,7 +1171,6 @@ class MockWebViewPlatformCallbacksHandler extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void onPageFinished(String? url) => super.noSuchMethod( Invocation.method( @@ -1245,7 +1179,6 @@ class MockWebViewPlatformCallbacksHandler extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void onProgress(int? progress) => super.noSuchMethod( Invocation.method( @@ -1254,7 +1187,6 @@ class MockWebViewPlatformCallbacksHandler extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void onWebResourceError(_i10.WebResourceError? error) => super.noSuchMethod( Invocation.method( @@ -1298,7 +1230,6 @@ class MockWebViewWidgetProxy extends _i1.Mock ), ), ) as _i4.WKWebView); - @override _i4.WKScriptMessageHandler createScriptMessageHandler( {required void Function( @@ -1320,7 +1251,6 @@ class MockWebViewWidgetProxy extends _i1.Mock ), ), ) as _i4.WKScriptMessageHandler); - @override _i4.WKUIDelegate createUIDelgate( {void Function( @@ -1343,7 +1273,6 @@ class MockWebViewWidgetProxy extends _i1.Mock ), ), ) as _i4.WKUIDelegate); - @override _i4.WKNavigationDelegate createNavigationDelegate({ void Function( diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.g.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.g.dart index 82f754af224..982b50810e6 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.g.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.g.dart @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v13.1.2), do not edit directly. +// Autogenerated from Pigeon (v13.0.0), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import // ignore_for_file: avoid_relative_lib_imports @@ -1245,51 +1245,57 @@ class _TestWKWebViewHostApiCodec extends StandardMessageCodec { } else if (value is NSHttpCookiePropertyKeyEnumData) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else if (value is NSKeyValueChangeKeyEnumData) { + } else if (value is NSHttpUrlResponseData) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else if (value is NSKeyValueObservingOptionsEnumData) { + } else if (value is NSKeyValueChangeKeyEnumData) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is NSUrlRequestData) { + } else if (value is NSKeyValueObservingOptionsEnumData) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is ObjectOrIdentifier) { + } else if (value is NSUrlRequestData) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is WKAudiovisualMediaTypeEnumData) { + } else if (value is ObjectOrIdentifier) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is WKFrameInfoData) { + } else if (value is WKAudiovisualMediaTypeEnumData) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is WKMediaCaptureTypeData) { + } else if (value is WKFrameInfoData) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is WKNavigationActionData) { + } else if (value is WKMediaCaptureTypeData) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is WKNavigationActionPolicyEnumData) { + } else if (value is WKNavigationActionData) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is WKPermissionDecisionData) { + } else if (value is WKNavigationActionPolicyEnumData) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is WKScriptMessageData) { + } else if (value is WKNavigationResponseData) { buffer.putUint8(142); writeValue(buffer, value.encode()); - } else if (value is WKSecurityOriginData) { + } else if (value is WKPermissionDecisionData) { buffer.putUint8(143); writeValue(buffer, value.encode()); - } else if (value is WKUserScriptData) { + } else if (value is WKScriptMessageData) { buffer.putUint8(144); writeValue(buffer, value.encode()); - } else if (value is WKUserScriptInjectionTimeEnumData) { + } else if (value is WKSecurityOriginData) { buffer.putUint8(145); writeValue(buffer, value.encode()); - } else if (value is WKWebsiteDataTypeEnumData) { + } else if (value is WKUserScriptData) { buffer.putUint8(146); writeValue(buffer, value.encode()); + } else if (value is WKUserScriptInjectionTimeEnumData) { + buffer.putUint8(147); + writeValue(buffer, value.encode()); + } else if (value is WKWebsiteDataTypeEnumData) { + buffer.putUint8(148); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -1307,34 +1313,38 @@ class _TestWKWebViewHostApiCodec extends StandardMessageCodec { case 131: return NSHttpCookiePropertyKeyEnumData.decode(readValue(buffer)!); case 132: - return NSKeyValueChangeKeyEnumData.decode(readValue(buffer)!); + return NSHttpUrlResponseData.decode(readValue(buffer)!); case 133: - return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); + return NSKeyValueChangeKeyEnumData.decode(readValue(buffer)!); case 134: - return NSUrlRequestData.decode(readValue(buffer)!); + return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); case 135: - return ObjectOrIdentifier.decode(readValue(buffer)!); + return NSUrlRequestData.decode(readValue(buffer)!); case 136: - return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); + return ObjectOrIdentifier.decode(readValue(buffer)!); case 137: - return WKFrameInfoData.decode(readValue(buffer)!); + return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); case 138: - return WKMediaCaptureTypeData.decode(readValue(buffer)!); + return WKFrameInfoData.decode(readValue(buffer)!); case 139: - return WKNavigationActionData.decode(readValue(buffer)!); + return WKMediaCaptureTypeData.decode(readValue(buffer)!); case 140: - return WKNavigationActionPolicyEnumData.decode(readValue(buffer)!); + return WKNavigationActionData.decode(readValue(buffer)!); case 141: - return WKPermissionDecisionData.decode(readValue(buffer)!); + return WKNavigationActionPolicyEnumData.decode(readValue(buffer)!); case 142: - return WKScriptMessageData.decode(readValue(buffer)!); + return WKNavigationResponseData.decode(readValue(buffer)!); case 143: - return WKSecurityOriginData.decode(readValue(buffer)!); + return WKPermissionDecisionData.decode(readValue(buffer)!); case 144: - return WKUserScriptData.decode(readValue(buffer)!); + return WKScriptMessageData.decode(readValue(buffer)!); case 145: - return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); + return WKSecurityOriginData.decode(readValue(buffer)!); case 146: + return WKUserScriptData.decode(readValue(buffer)!); + case 147: + return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); + case 148: return WKWebsiteDataTypeEnumData.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.mocks.dart index df4e12e6082..a34a190ac49 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.mocks.dart @@ -38,7 +38,6 @@ class MockTestNSObjectHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void addObserver( int? identifier, @@ -58,7 +57,6 @@ class MockTestNSObjectHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void removeObserver( int? identifier, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.mocks.dart index 66bbc7275e6..54e91efb6a6 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.mocks.dart @@ -40,7 +40,6 @@ class MockTestWKWebViewConfigurationHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void createFromWebView( int? identifier, @@ -56,7 +55,6 @@ class MockTestWKWebViewConfigurationHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setAllowsInlineMediaPlayback( int? identifier, @@ -72,7 +70,6 @@ class MockTestWKWebViewConfigurationHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setLimitsNavigationsToAppBoundDomains( int? identifier, @@ -88,7 +85,6 @@ class MockTestWKWebViewConfigurationHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setMediaTypesRequiringUserActionForPlayback( int? identifier, @@ -130,7 +126,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setUIDelegate( int? identifier, @@ -146,7 +141,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setNavigationDelegate( int? identifier, @@ -162,13 +156,11 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override String? getUrl(int? identifier) => (super.noSuchMethod(Invocation.method( #getUrl, [identifier], )) as String?); - @override double getEstimatedProgress(int? identifier) => (super.noSuchMethod( Invocation.method( @@ -177,7 +169,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValue: 0.0, ) as double); - @override void loadRequest( int? identifier, @@ -193,7 +184,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void loadHtmlString( int? identifier, @@ -211,7 +201,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void loadFileUrl( int? identifier, @@ -229,7 +218,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void loadFlutterAsset( int? identifier, @@ -245,7 +233,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override bool canGoBack(int? identifier) => (super.noSuchMethod( Invocation.method( @@ -254,7 +241,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValue: false, ) as bool); - @override bool canGoForward(int? identifier) => (super.noSuchMethod( Invocation.method( @@ -263,7 +249,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValue: false, ) as bool); - @override void goBack(int? identifier) => super.noSuchMethod( Invocation.method( @@ -272,7 +257,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void goForward(int? identifier) => super.noSuchMethod( Invocation.method( @@ -281,7 +265,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void reload(int? identifier) => super.noSuchMethod( Invocation.method( @@ -290,13 +273,11 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override String? getTitle(int? identifier) => (super.noSuchMethod(Invocation.method( #getTitle, [identifier], )) as String?); - @override void setAllowsBackForwardNavigationGestures( int? identifier, @@ -312,7 +293,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setCustomUserAgent( int? identifier, @@ -328,7 +308,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override _i4.Future evaluateJavaScript( int? identifier, @@ -344,7 +323,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValue: _i4.Future.value(), ) as _i4.Future); - @override void setInspectable( int? identifier, @@ -360,7 +338,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override String? getCustomUserAgent(int? identifier) => (super.noSuchMethod(Invocation.method( @@ -393,7 +370,6 @@ class MockTestUIScrollViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override List getContentOffset(int? identifier) => (super.noSuchMethod( Invocation.method( @@ -402,7 +378,6 @@ class MockTestUIScrollViewHostApi extends _i1.Mock ), returnValue: [], ) as List); - @override void scrollBy( int? identifier, @@ -420,7 +395,6 @@ class MockTestUIScrollViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setContentOffset( int? identifier, @@ -438,7 +412,6 @@ class MockTestUIScrollViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setDelegate( int? identifier, @@ -498,7 +471,6 @@ class MockTestUIViewHostApi extends _i1.Mock implements _i2.TestUIViewHostApi { ), returnValueForMissingStub: null, ); - @override void setOpaque( int? identifier, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart index e0eeb941cce..d838bf99614 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart @@ -598,6 +598,34 @@ void main() { expect(policyData.value, WKNavigationActionPolicyEnum.cancel); }); + test('decidePolicyForNavigationResponse', () async { + WebKitFlutterApis.instance = WebKitFlutterApis( + instanceManager: instanceManager, + ); + + navigationDelegate = WKNavigationDelegate( + instanceManager: instanceManager, + decidePolicyForNavigationResponse: ( + WKWebView webView, + WKNavigationResponse navigationAction, + ) async { + return WKNavigationResponsePolicy.cancel; + }, + ); + + final WKNavigationResponsePolicyEnum policy = await WebKitFlutterApis + .instance.navigationDelegate + .decidePolicyForNavigationResponse( + instanceManager.getIdentifier(navigationDelegate)!, + instanceManager.getIdentifier(webView)!, + WKNavigationResponseData( + response: NSHttpUrlResponseData(statusCode: 401), + forMainFrame: true), + ); + + expect(policy, WKNavigationResponsePolicyEnum.cancel); + }); + test('didFailNavigation', () async { final Completer> argsCompleter = Completer>(); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart index d9a0ed01d50..99aedf1659f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart @@ -47,7 +47,6 @@ class MockTestWKHttpCookieStoreHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override _i3.Future setCookie( int? identifier, @@ -109,7 +108,6 @@ class MockTestWKPreferencesHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setJavaScriptEnabled( int? identifier, @@ -189,7 +187,6 @@ class MockTestWKUserContentControllerHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void addScriptMessageHandler( int? identifier, @@ -207,7 +204,6 @@ class MockTestWKUserContentControllerHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void removeScriptMessageHandler( int? identifier, @@ -223,7 +219,6 @@ class MockTestWKUserContentControllerHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void removeAllScriptMessageHandlers(int? identifier) => super.noSuchMethod( Invocation.method( @@ -232,7 +227,6 @@ class MockTestWKUserContentControllerHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void addUserScript( int? identifier, @@ -248,7 +242,6 @@ class MockTestWKUserContentControllerHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void removeAllUserScripts(int? identifier) => super.noSuchMethod( Invocation.method( @@ -276,7 +269,6 @@ class MockTestWKWebViewConfigurationHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void createFromWebView( int? identifier, @@ -292,7 +284,6 @@ class MockTestWKWebViewConfigurationHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setAllowsInlineMediaPlayback( int? identifier, @@ -308,7 +299,6 @@ class MockTestWKWebViewConfigurationHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setLimitsNavigationsToAppBoundDomains( int? identifier, @@ -324,7 +314,6 @@ class MockTestWKWebViewConfigurationHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setMediaTypesRequiringUserActionForPlayback( int? identifier, @@ -366,7 +355,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setUIDelegate( int? identifier, @@ -382,7 +370,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setNavigationDelegate( int? identifier, @@ -398,13 +385,11 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override String? getUrl(int? identifier) => (super.noSuchMethod(Invocation.method( #getUrl, [identifier], )) as String?); - @override double getEstimatedProgress(int? identifier) => (super.noSuchMethod( Invocation.method( @@ -413,7 +398,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValue: 0.0, ) as double); - @override void loadRequest( int? identifier, @@ -429,7 +413,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void loadHtmlString( int? identifier, @@ -447,7 +430,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void loadFileUrl( int? identifier, @@ -465,7 +447,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void loadFlutterAsset( int? identifier, @@ -481,7 +462,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override bool canGoBack(int? identifier) => (super.noSuchMethod( Invocation.method( @@ -490,7 +470,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValue: false, ) as bool); - @override bool canGoForward(int? identifier) => (super.noSuchMethod( Invocation.method( @@ -499,7 +478,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValue: false, ) as bool); - @override void goBack(int? identifier) => super.noSuchMethod( Invocation.method( @@ -508,7 +486,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void goForward(int? identifier) => super.noSuchMethod( Invocation.method( @@ -517,7 +494,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void reload(int? identifier) => super.noSuchMethod( Invocation.method( @@ -526,13 +502,11 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override String? getTitle(int? identifier) => (super.noSuchMethod(Invocation.method( #getTitle, [identifier], )) as String?); - @override void setAllowsBackForwardNavigationGestures( int? identifier, @@ -548,7 +522,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void setCustomUserAgent( int? identifier, @@ -564,7 +537,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override _i3.Future evaluateJavaScript( int? identifier, @@ -580,7 +552,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValue: _i3.Future.value(), ) as _i3.Future); - @override void setInspectable( int? identifier, @@ -596,7 +567,6 @@ class MockTestWKWebViewHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override String? getCustomUserAgent(int? identifier) => (super.noSuchMethod(Invocation.method( @@ -629,7 +599,6 @@ class MockTestWKWebsiteDataStoreHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override void createDefaultDataStore(int? identifier) => super.noSuchMethod( Invocation.method( @@ -638,7 +607,6 @@ class MockTestWKWebsiteDataStoreHostApi extends _i1.Mock ), returnValueForMissingStub: null, ); - @override _i3.Future removeDataOfTypes( int? identifier, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_navigation_delegate_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_navigation_delegate_test.dart index 171e4056fee..da8675886f7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_navigation_delegate_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_navigation_delegate_test.dart @@ -71,6 +71,60 @@ void main() { expect(callbackUrl, 'https://www.google.com'); }); + test('setOnHttpError from decidePolicyForNavigationResponse', () { + final WebKitNavigationDelegate webKitDelegate = WebKitNavigationDelegate( + const WebKitNavigationDelegateCreationParams( + webKitProxy: WebKitProxy( + createNavigationDelegate: CapturingNavigationDelegate.new, + createUIDelegate: CapturingUIDelegate.new, + ), + ), + ); + + late final HttpResponseError callbackError; + void onHttpError(HttpResponseError error) { + callbackError = error; + } + + webKitDelegate.setOnHttpError(onHttpError); + + CapturingNavigationDelegate + .lastCreatedDelegate.decidePolicyForNavigationResponse!( + WKWebView.detached(), + const WKNavigationResponse( + response: NSHttpUrlResponse(statusCode: 401), forMainFrame: true), + ); + + expect(callbackError.response?.statusCode, 401); + }); + + test('setOnHttpError is not called for error codes < 400', () { + final WebKitNavigationDelegate webKitDelegate = WebKitNavigationDelegate( + const WebKitNavigationDelegateCreationParams( + webKitProxy: WebKitProxy( + createNavigationDelegate: CapturingNavigationDelegate.new, + createUIDelegate: CapturingUIDelegate.new, + ), + ), + ); + + HttpResponseError? callbackError; + void onHttpError(HttpResponseError error) { + callbackError = error; + } + + webKitDelegate.setOnHttpError(onHttpError); + + CapturingNavigationDelegate + .lastCreatedDelegate.decidePolicyForNavigationResponse!( + WKWebView.detached(), + const WKNavigationResponse( + response: NSHttpUrlResponse(statusCode: 399), forMainFrame: true), + ); + + expect(callbackError, isNull); + }); + test('onWebResourceError from didFailNavigation', () { final WebKitNavigationDelegate webKitDelegate = WebKitNavigationDelegate( const WebKitNavigationDelegateCreationParams( @@ -263,6 +317,7 @@ class CapturingNavigationDelegate extends WKNavigationDelegate { CapturingNavigationDelegate({ super.didFinishNavigation, super.didStartProvisionalNavigation, + super.decidePolicyForNavigationResponse, super.didFailNavigation, super.didFailProvisionalNavigation, super.decidePolicyForNavigationAction, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.dart index a23eef8d8fb..a28eca241ad 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.dart @@ -1538,6 +1538,7 @@ class CapturingNavigationDelegate extends WKNavigationDelegate { super.didFailNavigation, super.didFailProvisionalNavigation, super.decidePolicyForNavigationAction, + super.decidePolicyForNavigationResponse, super.webViewWebContentProcessDidTerminate, super.didReceiveAuthenticationChallenge, }) : super.detached() { diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.mocks.dart index cc7b6932f66..932c567fb1e 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_controller_test.mocks.dart @@ -159,7 +159,6 @@ class MockNSUrl extends _i1.Mock implements _i2.NSUrl { ), returnValue: _i6.Future.value(), ) as _i6.Future); - @override _i2.NSObject copy() => (super.noSuchMethod( Invocation.method( @@ -174,7 +173,6 @@ class MockNSUrl extends _i1.Mock implements _i2.NSUrl { ), ), ) as _i2.NSObject); - @override _i6.Future addObserver( _i2.NSObject? observer, { @@ -193,7 +191,6 @@ class MockNSUrl extends _i1.Mock implements _i2.NSUrl { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future removeObserver( _i2.NSObject? observer, { @@ -233,7 +230,6 @@ class MockUIScrollView extends _i1.Mock implements _i4.UIScrollView { ), )), ) as _i6.Future<_i3.Point>); - @override _i6.Future scrollBy(_i3.Point? offset) => (super.noSuchMethod( Invocation.method( @@ -243,7 +239,6 @@ class MockUIScrollView extends _i1.Mock implements _i4.UIScrollView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future setContentOffset(_i3.Point? offset) => (super.noSuchMethod( @@ -254,7 +249,6 @@ class MockUIScrollView extends _i1.Mock implements _i4.UIScrollView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future setDelegate(_i4.UIScrollViewDelegate? delegate) => (super.noSuchMethod( @@ -265,7 +259,6 @@ class MockUIScrollView extends _i1.Mock implements _i4.UIScrollView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i4.UIScrollView copy() => (super.noSuchMethod( Invocation.method( @@ -280,7 +273,6 @@ class MockUIScrollView extends _i1.Mock implements _i4.UIScrollView { ), ), ) as _i4.UIScrollView); - @override _i6.Future setBackgroundColor(_i7.Color? color) => (super.noSuchMethod( Invocation.method( @@ -290,7 +282,6 @@ class MockUIScrollView extends _i1.Mock implements _i4.UIScrollView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future setOpaque(bool? opaque) => (super.noSuchMethod( Invocation.method( @@ -300,7 +291,6 @@ class MockUIScrollView extends _i1.Mock implements _i4.UIScrollView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future addObserver( _i2.NSObject? observer, { @@ -319,7 +309,6 @@ class MockUIScrollView extends _i1.Mock implements _i4.UIScrollView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future removeObserver( _i2.NSObject? observer, { @@ -360,7 +349,6 @@ class MockUIScrollViewDelegate extends _i1.Mock ), ), ) as _i4.UIScrollViewDelegate); - @override _i6.Future addObserver( _i2.NSObject? observer, { @@ -379,7 +367,6 @@ class MockUIScrollViewDelegate extends _i1.Mock returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future removeObserver( _i2.NSObject? observer, { @@ -414,7 +401,6 @@ class MockWKPreferences extends _i1.Mock implements _i5.WKPreferences { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i5.WKPreferences copy() => (super.noSuchMethod( Invocation.method( @@ -429,7 +415,6 @@ class MockWKPreferences extends _i1.Mock implements _i5.WKPreferences { ), ), ) as _i5.WKPreferences); - @override _i6.Future addObserver( _i2.NSObject? observer, { @@ -448,7 +433,6 @@ class MockWKPreferences extends _i1.Mock implements _i5.WKPreferences { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future removeObserver( _i2.NSObject? observer, { @@ -491,7 +475,6 @@ class MockWKUserContentController extends _i1.Mock returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future removeScriptMessageHandler(String? name) => (super.noSuchMethod( @@ -502,7 +485,6 @@ class MockWKUserContentController extends _i1.Mock returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future removeAllScriptMessageHandlers() => (super.noSuchMethod( Invocation.method( @@ -512,7 +494,6 @@ class MockWKUserContentController extends _i1.Mock returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future addUserScript(_i5.WKUserScript? userScript) => (super.noSuchMethod( @@ -523,7 +504,6 @@ class MockWKUserContentController extends _i1.Mock returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future removeAllUserScripts() => (super.noSuchMethod( Invocation.method( @@ -533,7 +513,6 @@ class MockWKUserContentController extends _i1.Mock returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i5.WKUserContentController copy() => (super.noSuchMethod( Invocation.method( @@ -548,7 +527,6 @@ class MockWKUserContentController extends _i1.Mock ), ), ) as _i5.WKUserContentController); - @override _i6.Future addObserver( _i2.NSObject? observer, { @@ -567,7 +545,6 @@ class MockWKUserContentController extends _i1.Mock returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future removeObserver( _i2.NSObject? observer, { @@ -602,7 +579,6 @@ class MockWKWebsiteDataStore extends _i1.Mock Invocation.getter(#httpCookieStore), ), ) as _i5.WKHttpCookieStore); - @override _i6.Future removeDataOfTypes( Set<_i5.WKWebsiteDataType>? dataTypes, @@ -618,7 +594,6 @@ class MockWKWebsiteDataStore extends _i1.Mock ), returnValue: _i6.Future.value(false), ) as _i6.Future); - @override _i5.WKWebsiteDataStore copy() => (super.noSuchMethod( Invocation.method( @@ -633,7 +608,6 @@ class MockWKWebsiteDataStore extends _i1.Mock ), ), ) as _i5.WKWebsiteDataStore); - @override _i6.Future addObserver( _i2.NSObject? observer, { @@ -652,7 +626,6 @@ class MockWKWebsiteDataStore extends _i1.Mock returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future removeObserver( _i2.NSObject? observer, { @@ -686,7 +659,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { Invocation.getter(#configuration), ), ) as _i5.WKWebViewConfiguration); - @override _i4.UIScrollView get scrollView => (super.noSuchMethod( Invocation.getter(#scrollView), @@ -695,7 +667,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { Invocation.getter(#scrollView), ), ) as _i4.UIScrollView); - @override _i6.Future setUIDelegate(_i5.WKUIDelegate? delegate) => (super.noSuchMethod( @@ -706,7 +677,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future setNavigationDelegate(_i5.WKNavigationDelegate? delegate) => (super.noSuchMethod( @@ -717,7 +687,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future getUrl() => (super.noSuchMethod( Invocation.method( @@ -726,7 +695,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { ), returnValue: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future getEstimatedProgress() => (super.noSuchMethod( Invocation.method( @@ -735,7 +703,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { ), returnValue: _i6.Future.value(0.0), ) as _i6.Future); - @override _i6.Future loadRequest(_i2.NSUrlRequest? request) => (super.noSuchMethod( @@ -746,7 +713,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future loadHtmlString( String? string, { @@ -761,7 +727,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future loadFileUrl( String? url, { @@ -776,7 +741,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future loadFlutterAsset(String? key) => (super.noSuchMethod( Invocation.method( @@ -786,7 +750,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future canGoBack() => (super.noSuchMethod( Invocation.method( @@ -795,7 +758,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { ), returnValue: _i6.Future.value(false), ) as _i6.Future); - @override _i6.Future canGoForward() => (super.noSuchMethod( Invocation.method( @@ -804,7 +766,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { ), returnValue: _i6.Future.value(false), ) as _i6.Future); - @override _i6.Future goBack() => (super.noSuchMethod( Invocation.method( @@ -814,7 +775,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future goForward() => (super.noSuchMethod( Invocation.method( @@ -824,7 +784,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future reload() => (super.noSuchMethod( Invocation.method( @@ -834,7 +793,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future getTitle() => (super.noSuchMethod( Invocation.method( @@ -843,7 +801,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { ), returnValue: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future setAllowsBackForwardNavigationGestures(bool? allow) => (super.noSuchMethod( @@ -854,7 +811,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future setCustomUserAgent(String? userAgent) => (super.noSuchMethod( Invocation.method( @@ -864,7 +820,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future evaluateJavaScript(String? javaScriptString) => (super.noSuchMethod( @@ -874,7 +829,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { ), returnValue: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future setInspectable(bool? inspectable) => (super.noSuchMethod( Invocation.method( @@ -884,7 +838,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future getCustomUserAgent() => (super.noSuchMethod( Invocation.method( @@ -893,7 +846,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { ), returnValue: _i6.Future.value(), ) as _i6.Future); - @override _i5.WKWebView copy() => (super.noSuchMethod( Invocation.method( @@ -908,7 +860,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { ), ), ) as _i5.WKWebView); - @override _i6.Future setBackgroundColor(_i7.Color? color) => (super.noSuchMethod( Invocation.method( @@ -918,7 +869,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future setOpaque(bool? opaque) => (super.noSuchMethod( Invocation.method( @@ -928,7 +878,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future addObserver( _i2.NSObject? observer, { @@ -947,7 +896,6 @@ class MockWKWebView extends _i1.Mock implements _i5.WKWebView { returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future removeObserver( _i2.NSObject? observer, { @@ -982,7 +930,6 @@ class MockWKWebViewConfiguration extends _i1.Mock Invocation.getter(#userContentController), ), ) as _i5.WKUserContentController); - @override _i5.WKPreferences get preferences => (super.noSuchMethod( Invocation.getter(#preferences), @@ -991,7 +938,6 @@ class MockWKWebViewConfiguration extends _i1.Mock Invocation.getter(#preferences), ), ) as _i5.WKPreferences); - @override _i5.WKWebsiteDataStore get websiteDataStore => (super.noSuchMethod( Invocation.getter(#websiteDataStore), @@ -1000,7 +946,6 @@ class MockWKWebViewConfiguration extends _i1.Mock Invocation.getter(#websiteDataStore), ), ) as _i5.WKWebsiteDataStore); - @override _i6.Future setAllowsInlineMediaPlayback(bool? allow) => (super.noSuchMethod( @@ -1011,7 +956,6 @@ class MockWKWebViewConfiguration extends _i1.Mock returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future setLimitsNavigationsToAppBoundDomains(bool? limit) => (super.noSuchMethod( @@ -1022,7 +966,6 @@ class MockWKWebViewConfiguration extends _i1.Mock returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future setMediaTypesRequiringUserActionForPlayback( Set<_i5.WKAudiovisualMediaType>? types) => @@ -1034,7 +977,6 @@ class MockWKWebViewConfiguration extends _i1.Mock returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i5.WKWebViewConfiguration copy() => (super.noSuchMethod( Invocation.method( @@ -1049,7 +991,6 @@ class MockWKWebViewConfiguration extends _i1.Mock ), ), ) as _i5.WKWebViewConfiguration); - @override _i6.Future addObserver( _i2.NSObject? observer, { @@ -1068,7 +1009,6 @@ class MockWKWebViewConfiguration extends _i1.Mock returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future removeObserver( _i2.NSObject? observer, { @@ -1109,7 +1049,6 @@ class MockWKScriptMessageHandler extends _i1.Mock _i5.WKUserContentController, _i5.WKScriptMessage, )); - @override _i5.WKScriptMessageHandler copy() => (super.noSuchMethod( Invocation.method( @@ -1124,7 +1063,6 @@ class MockWKScriptMessageHandler extends _i1.Mock ), ), ) as _i5.WKScriptMessageHandler); - @override _i6.Future addObserver( _i2.NSObject? observer, { @@ -1143,7 +1081,6 @@ class MockWKScriptMessageHandler extends _i1.Mock returnValue: _i6.Future.value(), returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); - @override _i6.Future removeObserver( _i2.NSObject? observer, { diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_cookie_manager_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_cookie_manager_test.mocks.dart index bda15f7cec7..d9d21dab8db 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_cookie_manager_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_cookie_manager_test.mocks.dart @@ -63,7 +63,6 @@ class MockWKWebsiteDataStore extends _i1.Mock Invocation.getter(#httpCookieStore), ), ) as _i2.WKHttpCookieStore); - @override _i3.Future removeDataOfTypes( Set<_i2.WKWebsiteDataType>? dataTypes, @@ -79,7 +78,6 @@ class MockWKWebsiteDataStore extends _i1.Mock ), returnValue: _i3.Future.value(false), ) as _i3.Future); - @override _i2.WKWebsiteDataStore copy() => (super.noSuchMethod( Invocation.method( @@ -94,7 +92,6 @@ class MockWKWebsiteDataStore extends _i1.Mock ), ), ) as _i2.WKWebsiteDataStore); - @override _i3.Future addObserver( _i4.NSObject? observer, { @@ -113,7 +110,6 @@ class MockWKWebsiteDataStore extends _i1.Mock returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); - @override _i3.Future removeObserver( _i4.NSObject? observer, { @@ -148,7 +144,6 @@ class MockWKHttpCookieStore extends _i1.Mock implements _i2.WKHttpCookieStore { returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); - @override _i2.WKHttpCookieStore copy() => (super.noSuchMethod( Invocation.method( @@ -163,7 +158,6 @@ class MockWKHttpCookieStore extends _i1.Mock implements _i2.WKHttpCookieStore { ), ), ) as _i2.WKHttpCookieStore); - @override _i3.Future addObserver( _i4.NSObject? observer, { @@ -182,7 +176,6 @@ class MockWKHttpCookieStore extends _i1.Mock implements _i2.WKHttpCookieStore { returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); - @override _i3.Future removeObserver( _i4.NSObject? observer, { diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_widget_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_widget_test.mocks.dart index 2aff8e964b6..8c511d9f802 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_widget_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/webkit_webview_widget_test.mocks.dart @@ -99,7 +99,6 @@ class MockWKUIDelegate extends _i1.Mock implements _i2.WKUIDelegate { ), ), ) as _i2.WKUIDelegate); - @override _i3.Future addObserver( _i4.NSObject? observer, { @@ -118,7 +117,6 @@ class MockWKUIDelegate extends _i1.Mock implements _i2.WKUIDelegate { returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); - @override _i3.Future removeObserver( _i4.NSObject? observer, { @@ -153,7 +151,6 @@ class MockWKWebViewConfiguration extends _i1.Mock Invocation.getter(#userContentController), ), ) as _i2.WKUserContentController); - @override _i2.WKPreferences get preferences => (super.noSuchMethod( Invocation.getter(#preferences), @@ -162,7 +159,6 @@ class MockWKWebViewConfiguration extends _i1.Mock Invocation.getter(#preferences), ), ) as _i2.WKPreferences); - @override _i2.WKWebsiteDataStore get websiteDataStore => (super.noSuchMethod( Invocation.getter(#websiteDataStore), @@ -171,7 +167,6 @@ class MockWKWebViewConfiguration extends _i1.Mock Invocation.getter(#websiteDataStore), ), ) as _i2.WKWebsiteDataStore); - @override _i3.Future setAllowsInlineMediaPlayback(bool? allow) => (super.noSuchMethod( @@ -182,7 +177,6 @@ class MockWKWebViewConfiguration extends _i1.Mock returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); - @override _i3.Future setLimitsNavigationsToAppBoundDomains(bool? limit) => (super.noSuchMethod( @@ -193,7 +187,6 @@ class MockWKWebViewConfiguration extends _i1.Mock returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); - @override _i3.Future setMediaTypesRequiringUserActionForPlayback( Set<_i2.WKAudiovisualMediaType>? types) => @@ -205,7 +198,6 @@ class MockWKWebViewConfiguration extends _i1.Mock returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); - @override _i2.WKWebViewConfiguration copy() => (super.noSuchMethod( Invocation.method( @@ -220,7 +212,6 @@ class MockWKWebViewConfiguration extends _i1.Mock ), ), ) as _i2.WKWebViewConfiguration); - @override _i3.Future addObserver( _i4.NSObject? observer, { @@ -239,7 +230,6 @@ class MockWKWebViewConfiguration extends _i1.Mock returnValue: _i3.Future.value(), returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); - @override _i3.Future removeObserver( _i4.NSObject? observer, {