@@ -573,6 +573,12 @@ abstract class AndroidWebkitLibraryPigeonProxyApiRegistrar(val binaryMessenger:
573
573
*/
574
574
abstract fun getPigeonApiWebSettingsCompat (): PigeonApiWebSettingsCompat
575
575
576
+ /* *
577
+ * An implementation of [PigeonApiWebViewFeature] used to add a new Dart instance of
578
+ * `WebViewFeature` to the Dart `InstanceManager`.
579
+ */
580
+ abstract fun getPigeonApiWebViewFeature (): PigeonApiWebViewFeature
581
+
576
582
fun setUp () {
577
583
AndroidWebkitLibraryPigeonInstanceManagerApi .setUpMessageHandlers(
578
584
binaryMessenger, instanceManager)
@@ -606,6 +612,7 @@ abstract class AndroidWebkitLibraryPigeonProxyApiRegistrar(val binaryMessenger:
606
612
PigeonApiCertificate .setUpMessageHandlers(binaryMessenger, getPigeonApiCertificate())
607
613
PigeonApiWebSettingsCompat .setUpMessageHandlers(
608
614
binaryMessenger, getPigeonApiWebSettingsCompat())
615
+ PigeonApiWebViewFeature .setUpMessageHandlers(binaryMessenger, getPigeonApiWebViewFeature())
609
616
}
610
617
611
618
fun tearDown () {
@@ -632,6 +639,7 @@ abstract class AndroidWebkitLibraryPigeonProxyApiRegistrar(val binaryMessenger:
632
639
PigeonApiSslCertificate .setUpMessageHandlers(binaryMessenger, null )
633
640
PigeonApiCertificate .setUpMessageHandlers(binaryMessenger, null )
634
641
PigeonApiWebSettingsCompat .setUpMessageHandlers(binaryMessenger, null )
642
+ PigeonApiWebViewFeature .setUpMessageHandlers(binaryMessenger, null )
635
643
}
636
644
}
637
645
@@ -738,6 +746,8 @@ private class AndroidWebkitLibraryPigeonProxyApiBaseCodec(
738
746
registrar.getPigeonApiCertificate().pigeon_newInstance(value) {}
739
747
} else if (value is androidx.webkit.WebSettingsCompat ) {
740
748
registrar.getPigeonApiWebSettingsCompat().pigeon_newInstance(value) {}
749
+ } else if (value is androidx.webkit.WebViewFeature ) {
750
+ registrar.getPigeonApiWebViewFeature().pigeon_newInstance(value) {}
741
751
}
742
752
743
753
when {
@@ -6397,3 +6407,75 @@ abstract class PigeonApiWebSettingsCompat(
6397
6407
}
6398
6408
}
6399
6409
6410
+ @Suppress(" UNCHECKED_CAST" )
6411
+ abstract class PigeonApiWebViewFeature (
6412
+ open val pigeonRegistrar : AndroidWebkitLibraryPigeonProxyApiRegistrar
6413
+ ) {
6414
+ abstract fun isFeatureSupported (feature : String ): Boolean
6415
+
6416
+ companion object {
6417
+ @Suppress(" LocalVariableName" )
6418
+ fun setUpMessageHandlers (binaryMessenger : BinaryMessenger , api : PigeonApiWebViewFeature ? ) {
6419
+ val codec = api?.pigeonRegistrar?.codec ? : AndroidWebkitLibraryPigeonCodec ()
6420
+ run {
6421
+ val channel =
6422
+ BasicMessageChannel <Any ?>(
6423
+ binaryMessenger,
6424
+ " dev.flutter.pigeon.webview_flutter_android.WebViewFeature.isFeatureSupported" ,
6425
+ codec)
6426
+ if (api != null ) {
6427
+ channel.setMessageHandler { message, reply ->
6428
+ val args = message as List <Any ?>
6429
+ val featureArg = args[0 ] as String
6430
+ val wrapped: List <Any ?> =
6431
+ try {
6432
+ listOf (api.isFeatureSupported(featureArg))
6433
+ } catch (exception: Throwable ) {
6434
+ AndroidWebkitLibraryPigeonUtils .wrapError(exception)
6435
+ }
6436
+ reply.reply(wrapped)
6437
+ }
6438
+ } else {
6439
+ channel.setMessageHandler(null )
6440
+ }
6441
+ }
6442
+ }
6443
+ }
6444
+
6445
+ @Suppress(" LocalVariableName" , " FunctionName" )
6446
+ /* * Creates a Dart instance of WebViewFeature and attaches it to [pigeon_instanceArg]. */
6447
+ fun pigeon_newInstance (
6448
+ pigeon_instanceArg : androidx.webkit.WebViewFeature ,
6449
+ callback : (Result <Unit >) -> Unit
6450
+ ) {
6451
+ if (pigeonRegistrar.ignoreCallsToDart) {
6452
+ callback(
6453
+ Result .failure(
6454
+ AndroidWebKitError (" ignore-calls-error" , " Calls to Dart are being ignored." , " " )))
6455
+ } else if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) {
6456
+ callback(Result .success(Unit ))
6457
+ } else {
6458
+ val pigeon_identifierArg =
6459
+ pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg)
6460
+ val binaryMessenger = pigeonRegistrar.binaryMessenger
6461
+ val codec = pigeonRegistrar.codec
6462
+ val channelName =
6463
+ " dev.flutter.pigeon.webview_flutter_android.WebViewFeature.pigeon_newInstance"
6464
+ val channel = BasicMessageChannel <Any ?>(binaryMessenger, channelName, codec)
6465
+ channel.send(listOf (pigeon_identifierArg)) {
6466
+ if (it is List <* >) {
6467
+ if (it.size > 1 ) {
6468
+ callback(
6469
+ Result .failure(
6470
+ AndroidWebKitError (it[0 ] as String , it[1 ] as String , it[2 ] as String? )))
6471
+ } else {
6472
+ callback(Result .success(Unit ))
6473
+ }
6474
+ } else {
6475
+ callback(
6476
+ Result .failure(AndroidWebkitLibraryPigeonUtils .createConnectionError(channelName)))
6477
+ }
6478
+ }
6479
+ }
6480
+ }
6481
+ }
0 commit comments