From ac78c15e973ff681854b2f0c62564cd271fa8c0d Mon Sep 17 00:00:00 2001 From: Igor Kharakhordin Date: Wed, 11 Dec 2024 09:17:02 +0100 Subject: [PATCH] [webview_flutter_android] Add WebSettings methods setAllowFileAccess, setAllowContentAccess, setGeolocationEnabled, setCacheMode --- .../webview_flutter_android/CHANGELOG.md | 4 + .../webviewflutter/AndroidWebkitLibrary.g.kt | 128 ++++++++++++++++++ .../webviewflutter/WebSettingsProxyApi.java | 30 ++++ .../lib/src/android_webkit.g.dart | 116 ++++++++++++++++ .../lib/src/android_webview_controller.dart | 27 ++++ .../pigeons/android_webkit.dart | 35 +++++ .../webview_flutter_android/pubspec.yaml | 2 +- .../test/android_webview_controller_test.dart | 50 +++++++ ...android_webview_controller_test.mocks.dart | 70 ++++++++++ ...oid_webview_cookie_manager_test.mocks.dart | 40 ++++++ .../webview_android_widget_test.mocks.dart | 30 ++++ 11 files changed, 531 insertions(+), 1 deletion(-) diff --git a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md index 16dcfd07e48c..bb3f781b64cc 100644 --- a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md +++ b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.2.0 + +* Adds WebSettings methods: `AndroidWebViewController.setAllowFileAccess`, `AndroidWebViewController.setAllowContentAccess`, `AndroidWebViewController.setGeolocationEnabled` and `AndroidWebViewController.setCacheMode`. + ## 4.1.0 * Updates internal API wrapper to use `ProxyApi`s. diff --git a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/AndroidWebkitLibrary.g.kt b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/AndroidWebkitLibrary.g.kt index f28082725487..a1c1ca9864af 100644 --- a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/AndroidWebkitLibrary.g.kt +++ b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/AndroidWebkitLibrary.g.kt @@ -571,6 +571,7 @@ private class AndroidWebkitLibraryPigeonProxyApiBaseCodec( value is String || value is FileChooserMode || value is ConsoleMessageLevel || + value is CacheMode || value == null) { super.writeValue(stream, value) return @@ -726,6 +727,45 @@ enum class ConsoleMessageLevel(val raw: Int) { } } +/** + * Describes the way the cache is used. + * + * See https://developer.android.com/reference/android/webkit/WebSettings#setCacheMode(int). + */ +enum class CacheMode(val raw: Int) { + /** + * Normal cache usage mode. + * + * See https://developer.android.com/reference/android/webkit/WebSettings#LOAD_DEFAULT + */ + LOAD_DEFAULT(0), + /** + * Use cached resources when they are available, even if they have expired. Otherwise load + * resources from the network. + * + * See https://developer.android.com/reference/android/webkit/WebSettings#LOAD_CACHE_ELSE_NETWORK + */ + LOAD_CACHE_ELSE_NETWORK(1), + /** + * Don't use the cache, load from the network. + * + * See https://developer.android.com/reference/android/webkit/WebSettings#LOAD_CACHE_ELSE_NETWORK + */ + LOAD_NO_CACHE(2), + /** + * Don't use the network, load from the cache. + * + * See https://developer.android.com/reference/android/webkit/WebSettings#LOAD_CACHE_ONLY + */ + LOAD_CACHE_ONLY(3); + + companion object { + fun ofRaw(raw: Int): CacheMode? { + return values().firstOrNull { it.raw == raw } + } + } +} + private open class AndroidWebkitLibraryPigeonCodec : StandardMessageCodec() { override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { return when (type) { @@ -735,6 +775,9 @@ private open class AndroidWebkitLibraryPigeonCodec : StandardMessageCodec() { 130.toByte() -> { return (readValue(buffer) as Long?)?.let { ConsoleMessageLevel.ofRaw(it.toInt()) } } + 131.toByte() -> { + return (readValue(buffer) as Long?)?.let { CacheMode.ofRaw(it.toInt()) } + } else -> super.readValueOfType(type, buffer) } } @@ -749,6 +792,10 @@ private open class AndroidWebkitLibraryPigeonCodec : StandardMessageCodec() { stream.write(130) writeValue(stream, value.raw) } + is CacheMode -> { + stream.write(131) + writeValue(stream, value.raw) + } else -> super.writeValue(stream, value) } } @@ -2104,6 +2151,15 @@ abstract class PigeonApiWebSettings( /** Enables or disables file access within WebView. */ abstract fun setAllowFileAccess(pigeon_instance: android.webkit.WebSettings, enabled: Boolean) + /** Enables or disables content URL access within WebView. */ + abstract fun setAllowContentAccess(pigeon_instance: android.webkit.WebSettings, enabled: Boolean) + + /** Sets whether Geolocation is enabled within WebView. */ + abstract fun setGeolocationEnabled(pigeon_instance: android.webkit.WebSettings, enabled: Boolean) + + /** Overrides the way the cache is used. */ + abstract fun setCacheMode(pigeon_instance: android.webkit.WebSettings, mode: CacheMode) + /** Sets the text zoom of the page in percent. */ abstract fun setTextZoom(pigeon_instance: android.webkit.WebSettings, textZoom: Long) @@ -2402,6 +2458,78 @@ abstract class PigeonApiWebSettings( channel.setMessageHandler(null) } } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.webview_flutter_android.WebSettings.setAllowContentAccess", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as android.webkit.WebSettings + val enabledArg = args[1] as Boolean + val wrapped: List = + try { + api.setAllowContentAccess(pigeon_instanceArg, enabledArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.webview_flutter_android.WebSettings.setGeolocationEnabled", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as android.webkit.WebSettings + val enabledArg = args[1] as Boolean + val wrapped: List = + try { + api.setGeolocationEnabled(pigeon_instanceArg, enabledArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.webview_flutter_android.WebSettings.setCacheMode", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val pigeon_instanceArg = args[0] as android.webkit.WebSettings + val modeArg = args[1] as CacheMode + val wrapped: List = + try { + api.setCacheMode(pigeon_instanceArg, modeArg) + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } run { val channel = BasicMessageChannel( diff --git a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebSettingsProxyApi.java b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebSettingsProxyApi.java index 82fa32b8150e..bf167907b921 100644 --- a/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebSettingsProxyApi.java +++ b/packages/webview_flutter/webview_flutter_android/android/src/main/java/io/flutter/plugins/webviewflutter/WebSettingsProxyApi.java @@ -18,6 +18,21 @@ public WebSettingsProxyApi(@NonNull ProxyApiRegistrar pigeonRegistrar) { super(pigeonRegistrar); } + private static int mapCacheMode(CacheMode pigeonMode) { + switch (pigeonMode) { + case LOAD_DEFAULT: + return WebSettings.LOAD_DEFAULT; + case LOAD_CACHE_ELSE_NETWORK: + return WebSettings.LOAD_CACHE_ELSE_NETWORK; + case LOAD_NO_CACHE: + return WebSettings.LOAD_NO_CACHE; + case LOAD_CACHE_ONLY: + return WebSettings.LOAD_CACHE_ONLY; + } + + return WebSettings.LOAD_DEFAULT; + } + @Override public void setDomStorageEnabled(@NonNull WebSettings pigeon_instance, boolean flag) { pigeon_instance.setDomStorageEnabled(flag); @@ -81,6 +96,21 @@ public void setAllowFileAccess(@NonNull WebSettings pigeon_instance, boolean ena pigeon_instance.setAllowFileAccess(enabled); } + @Override + public void setAllowContentAccess(@NonNull WebSettings pigeon_instance, boolean enabled) { + pigeon_instance.setAllowContentAccess(enabled); + } + + @Override + public void setGeolocationEnabled(@NonNull WebSettings pigeon_instance, boolean enabled) { + pigeon_instance.setGeolocationEnabled(enabled); + } + + @Override + public void setCacheMode(@NonNull WebSettings pigeon_instance, @NonNull CacheMode mode) { + pigeon_instance.setCacheMode(mapCacheMode(mode)); + } + @Override public void setTextZoom(@NonNull WebSettings pigeon_instance, long textZoom) { pigeon_instance.setTextZoom((int) textZoom); diff --git a/packages/webview_flutter/webview_flutter_android/lib/src/android_webkit.g.dart b/packages/webview_flutter/webview_flutter_android/lib/src/android_webkit.g.dart index fc7174a27d08..e7dbd7a09829 100644 --- a/packages/webview_flutter/webview_flutter_android/lib/src/android_webkit.g.dart +++ b/packages/webview_flutter/webview_flutter_android/lib/src/android_webkit.g.dart @@ -503,6 +503,32 @@ enum ConsoleMessageLevel { unknown, } +/// Describes the way the cache is used. +/// +/// See https://developer.android.com/reference/android/webkit/WebSettings#setCacheMode(int). +enum CacheMode { + /// Normal cache usage mode. + /// + /// See https://developer.android.com/reference/android/webkit/WebSettings#LOAD_DEFAULT + loadDefault, + + /// Use cached resources when they are available, even if they have expired. + /// Otherwise load resources from the network. + /// + /// See https://developer.android.com/reference/android/webkit/WebSettings#LOAD_CACHE_ELSE_NETWORK + loadCacheElseNetwork, + + /// Don't use the cache, load from the network. + /// + /// See https://developer.android.com/reference/android/webkit/WebSettings#LOAD_CACHE_ELSE_NETWORK + loadNoCache, + + /// Don't use the network, load from the cache. + /// + /// See https://developer.android.com/reference/android/webkit/WebSettings#LOAD_CACHE_ONLY + loadCacheOnly, +} + class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -516,6 +542,9 @@ class _PigeonCodec extends StandardMessageCodec { } else if (value is ConsoleMessageLevel) { buffer.putUint8(130); writeValue(buffer, value.index); + } else if (value is CacheMode) { + buffer.putUint8(131); + writeValue(buffer, value.index); } else { super.writeValue(buffer, value); } @@ -530,6 +559,9 @@ class _PigeonCodec extends StandardMessageCodec { case 130: final int? value = readValue(buffer) as int?; return value == null ? null : ConsoleMessageLevel.values[value]; + case 131: + final int? value = readValue(buffer) as int?; + return value == null ? null : CacheMode.values[value]; default: return super.readValueOfType(type, buffer); } @@ -2615,6 +2647,90 @@ class WebSettings extends PigeonInternalProxyApiBaseClass { } } + /// Enables or disables content URL access within WebView. + Future setAllowContentAccess(bool enabled) async { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecWebSettings; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = + 'dev.flutter.pigeon.webview_flutter_android.WebSettings.setAllowContentAccess'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = await pigeonVar_channel + .send([this, enabled]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + + /// Sets whether Geolocation is enabled within WebView. + Future setGeolocationEnabled(bool enabled) async { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecWebSettings; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = + 'dev.flutter.pigeon.webview_flutter_android.WebSettings.setGeolocationEnabled'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = await pigeonVar_channel + .send([this, enabled]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + + /// Overrides the way the cache is used. + Future setCacheMode(CacheMode mode) async { + final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = + _pigeonVar_codecWebSettings; + final BinaryMessenger? pigeonVar_binaryMessenger = pigeon_binaryMessenger; + const String pigeonVar_channelName = + 'dev.flutter.pigeon.webview_flutter_android.WebSettings.setCacheMode'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([this, mode]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + /// Sets the text zoom of the page in percent. Future setTextZoom(int textZoom) async { final _PigeonInternalProxyApiBaseCodec pigeonChannelCodec = 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 c250a87d36a9..f0aacc942177 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 @@ -17,6 +17,8 @@ import 'android_webkit_constants.dart'; import 'platform_views_service_proxy.dart'; import 'weak_reference_utils.dart'; +export 'android_webkit.g.dart' show CacheMode; + /// Object specifying creation parameters for creating a [AndroidWebViewController]. /// /// When adding additional fields make sure they can be null or have a default @@ -592,6 +594,31 @@ class AndroidWebViewController extends PlatformWebViewController { Future setTextZoom(int textZoom) => _webView.settings.setTextZoom(textZoom); + /// Enables or disables file access. + /// + /// The default is false. + Future setAllowFileAccess(bool enabled) => + _webView.settings.setAllowFileAccess(enabled); + + /// Enables or disables content URL access. + /// + /// The default is true. + Future setAllowContentAccess(bool enabled) => + _webView.settings.setAllowContentAccess(enabled); + + /// Sets whether Geolocation is enabled. + /// + /// The default is true. + Future setGeolocationEnabled(bool enabled) => + _webView.settings.setGeolocationEnabled(enabled); + + /// Allows the client to override the way the cache is used + /// by specifying one of [android_webview.CacheMode] values. + /// + /// The default is [android_webview.CacheMode.loadDefault]. + Future setCacheMode(android_webview.CacheMode mode) => + _webView.settings.setCacheMode(mode); + /// Sets the callback that is invoked when the client should show a file /// selector. Future setOnShowFileSelector( diff --git a/packages/webview_flutter/webview_flutter_android/pigeons/android_webkit.dart b/packages/webview_flutter/webview_flutter_android/pigeons/android_webkit.dart index 22435d5b97d2..2f154c81f37b 100644 --- a/packages/webview_flutter/webview_flutter_android/pigeons/android_webkit.dart +++ b/packages/webview_flutter/webview_flutter_android/pigeons/android_webkit.dart @@ -80,6 +80,32 @@ enum ConsoleMessageLevel { unknown, } +/// Describes the way the cache is used. +/// +/// See https://developer.android.com/reference/android/webkit/WebSettings#setCacheMode(int). +enum CacheMode { + /// Normal cache usage mode. + /// + /// See https://developer.android.com/reference/android/webkit/WebSettings#LOAD_DEFAULT + loadDefault, + + /// Use cached resources when they are available, even if they have expired. + /// Otherwise load resources from the network. + /// + /// See https://developer.android.com/reference/android/webkit/WebSettings#LOAD_CACHE_ELSE_NETWORK + loadCacheElseNetwork, + + /// Don't use the cache, load from the network. + /// + /// See https://developer.android.com/reference/android/webkit/WebSettings#LOAD_CACHE_ELSE_NETWORK + loadNoCache, + + /// Don't use the network, load from the cache. + /// + /// See https://developer.android.com/reference/android/webkit/WebSettings#LOAD_CACHE_ONLY + loadCacheOnly; +} + /// Encompasses parameters to the `WebViewClient.shouldInterceptRequest` method. /// /// See https://developer.android.com/reference/android/webkit/WebResourceRequest. @@ -354,6 +380,15 @@ abstract class WebSettings { /// Enables or disables file access within WebView. void setAllowFileAccess(bool enabled); + /// Enables or disables content URL access within WebView. + void setAllowContentAccess(bool enabled); + + /// Sets whether Geolocation is enabled within WebView. + void setGeolocationEnabled(bool enabled); + + /// Overrides the way the cache is used. + void setCacheMode(CacheMode mode); + /// Sets the text zoom of the page in percent. void setTextZoom(int textZoom); diff --git a/packages/webview_flutter/webview_flutter_android/pubspec.yaml b/packages/webview_flutter/webview_flutter_android/pubspec.yaml index 4ff9b6166a6d..44f19b2af19c 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: 4.1.0 +version: 4.2.0 environment: sdk: ^3.5.0 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 6879c33253e7..b1778441bbb8 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 @@ -1510,6 +1510,56 @@ void main() { verify(mockSettings.setMediaPlaybackRequiresUserGesture(true)).called(1); }); + test('setAllowContentAccess', () async { + final MockWebView mockWebView = MockWebView(); + final MockWebSettings mockSettings = MockWebSettings(); + final AndroidWebViewController controller = createControllerWithMocks( + mockWebView: mockWebView, + mockSettings: mockSettings, + ); + + clearInteractions(mockWebView); + + await controller.setAllowContentAccess(false); + + verify(mockWebView.settings).called(1); + verify(mockSettings.setAllowContentAccess(false)).called(1); + }); + + test('setGeolocationEnabled', () async { + final MockWebView mockWebView = MockWebView(); + final MockWebSettings mockSettings = MockWebSettings(); + final AndroidWebViewController controller = createControllerWithMocks( + mockWebView: mockWebView, + mockSettings: mockSettings, + ); + + clearInteractions(mockWebView); + + await controller.setGeolocationEnabled(false); + + verify(mockWebView.settings).called(1); + verify(mockSettings.setGeolocationEnabled(false)).called(1); + }); + + test('setCacheMode', () async { + final MockWebView mockWebView = MockWebView(); + final MockWebSettings mockSettings = MockWebSettings(); + final AndroidWebViewController controller = createControllerWithMocks( + mockWebView: mockWebView, + mockSettings: mockSettings, + ); + + clearInteractions(mockWebView); + + const android_webview.CacheMode value = + android_webview.CacheMode.loadCacheElseNetwork; + await controller.setCacheMode(value); + + verify(mockWebView.settings).called(1); + verify(mockSettings.setCacheMode(value)).called(1); + }); + test('setTextZoom', () async { final MockWebView mockWebView = MockWebView(); final MockWebSettings mockSettings = MockWebSettings(); 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 d0254f2bd801..68817a47434d 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 @@ -789,6 +789,46 @@ class MockAndroidWebViewController extends _i1.Mock returnValueForMissingStub: _i8.Future.value(), ) as _i8.Future); + @override + _i8.Future setAllowFileAccess(bool? enabled) => (super.noSuchMethod( + Invocation.method( + #setAllowFileAccess, + [enabled], + ), + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); + + @override + _i8.Future setAllowContentAccess(bool? enabled) => (super.noSuchMethod( + Invocation.method( + #setAllowContentAccess, + [enabled], + ), + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); + + @override + _i8.Future setGeolocationEnabled(bool? enabled) => (super.noSuchMethod( + Invocation.method( + #setGeolocationEnabled, + [enabled], + ), + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); + + @override + _i8.Future setCacheMode(_i2.CacheMode? mode) => (super.noSuchMethod( + Invocation.method( + #setCacheMode, + [mode], + ), + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); + @override _i8.Future setOnShowFileSelector( _i8.Future> Function(_i7.FileSelectorParams)? @@ -2638,6 +2678,36 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValueForMissingStub: _i8.Future.value(), ) as _i8.Future); + @override + _i8.Future setAllowContentAccess(bool? enabled) => (super.noSuchMethod( + Invocation.method( + #setAllowContentAccess, + [enabled], + ), + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); + + @override + _i8.Future setGeolocationEnabled(bool? enabled) => (super.noSuchMethod( + Invocation.method( + #setGeolocationEnabled, + [enabled], + ), + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); + + @override + _i8.Future setCacheMode(_i2.CacheMode? mode) => (super.noSuchMethod( + Invocation.method( + #setCacheMode, + [mode], + ), + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); + @override _i8.Future setTextZoom(int? textZoom) => (super.noSuchMethod( Invocation.method( diff --git a/packages/webview_flutter/webview_flutter_android/test/android_webview_cookie_manager_test.mocks.dart b/packages/webview_flutter/webview_flutter_android/test/android_webview_cookie_manager_test.mocks.dart index 303f54d46f64..50895d862ec5 100644 --- a/packages/webview_flutter/webview_flutter_android/test/android_webview_cookie_manager_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_android/test/android_webview_cookie_manager_test.mocks.dart @@ -494,6 +494,46 @@ class MockAndroidWebViewController extends _i1.Mock returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); + @override + _i5.Future setAllowFileAccess(bool? enabled) => (super.noSuchMethod( + Invocation.method( + #setAllowFileAccess, + [enabled], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + + @override + _i5.Future setAllowContentAccess(bool? enabled) => (super.noSuchMethod( + Invocation.method( + #setAllowContentAccess, + [enabled], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + + @override + _i5.Future setGeolocationEnabled(bool? enabled) => (super.noSuchMethod( + Invocation.method( + #setGeolocationEnabled, + [enabled], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + + @override + _i5.Future setCacheMode(_i2.CacheMode? mode) => (super.noSuchMethod( + Invocation.method( + #setCacheMode, + [mode], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override _i5.Future setOnShowFileSelector( _i5.Future> Function(_i6.FileSelectorParams)? 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 44c8b8adb47f..8d4fe7742b37 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 @@ -355,6 +355,36 @@ class MockWebSettings extends _i1.Mock implements _i2.WebSettings { returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); + @override + _i4.Future setAllowContentAccess(bool? enabled) => (super.noSuchMethod( + Invocation.method( + #setAllowContentAccess, + [enabled], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future setGeolocationEnabled(bool? enabled) => (super.noSuchMethod( + Invocation.method( + #setGeolocationEnabled, + [enabled], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future setCacheMode(_i2.CacheMode? mode) => (super.noSuchMethod( + Invocation.method( + #setCacheMode, + [mode], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + @override _i4.Future setTextZoom(int? textZoom) => (super.noSuchMethod( Invocation.method(