Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2d07746
Add wrapper for androidx.webkit.WebSettingsCompat
mataku Jul 26, 2025
1a01f13
Add wrapper for androidx.webkit.WebViewFeature
mataku Jul 26, 2025
d098b47
Expose wrappers
mataku Jul 26, 2025
8fa5fe1
Add native unit tests for payment request feature
mataku Jul 26, 2025
381ae6f
Add sample menu for payment request
mataku Jul 26, 2025
5eee7b3
Prepare CHANGELOG
mataku Jul 26, 2025
d43bde1
Run auto-formatter
mataku Jul 26, 2025
a20f0fb
Simplify method description
mataku Jul 26, 2025
103e29f
Specify details with added methods
mataku Jul 26, 2025
8c73517
Fix RequiresFeature lint: setPaymentRequestEnabled should only be cal…
mataku Jul 26, 2025
5ed43ab
Fix format
mataku Jul 26, 2025
28f8889
Fix doc comments to correspond to the method
mataku Aug 1, 2025
3f68c0e
Remove sample for WebSettingsCompat and WebViewFeature.
mataku Aug 1, 2025
878fd38
Update generated files according to comment update
mataku Aug 1, 2025
b0388bc
Specify collect type
mataku Aug 2, 2025
5f7f689
Merge main into feature/expose-payment-request-enabled
mataku Aug 2, 2025
ddea6d4
Client should use setPaymentRequestEnabled if only WebViewFeatureProx…
mataku Aug 8, 2025
2b06e3d
Add Payment Request section for webview_flutter_android
mataku Aug 8, 2025
69c8a3e
Merge branch upstream/main into feature/expose-payment-request-enabled
mataku Aug 8, 2025
7337199
Fix tests according to SuppressLint
mataku Aug 8, 2025
47b6b6f
Address code-excerpt
mataku Aug 8, 2025
1cb2a20
Run update-excerpts
mataku Aug 8, 2025
5575248
Minor README wording changes
stuartmorgan-g Aug 14, 2025
8ab4499
Merge remote-tracking branch 'remotes/upstream/main' into feature/exp…
mataku Aug 15, 2025
74e8aa4
Create readme_excerpts.dart for snippets in README
mataku Aug 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add wrapper for androidx.webkit.WebViewFeature
  • Loading branch information
mataku committed Jul 26, 2025
commit 1a01f138ac3075b599cd243de53969db85b29b50
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,12 @@ abstract class AndroidWebkitLibraryPigeonProxyApiRegistrar(val binaryMessenger:
*/
abstract fun getPigeonApiWebSettingsCompat(): PigeonApiWebSettingsCompat

/**
* An implementation of [PigeonApiWebViewFeature] used to add a new Dart instance of
* `WebViewFeature` to the Dart `InstanceManager`.
*/
abstract fun getPigeonApiWebViewFeature(): PigeonApiWebViewFeature

fun setUp() {
AndroidWebkitLibraryPigeonInstanceManagerApi.setUpMessageHandlers(
binaryMessenger, instanceManager)
Expand Down Expand Up @@ -606,6 +612,7 @@ abstract class AndroidWebkitLibraryPigeonProxyApiRegistrar(val binaryMessenger:
PigeonApiCertificate.setUpMessageHandlers(binaryMessenger, getPigeonApiCertificate())
PigeonApiWebSettingsCompat.setUpMessageHandlers(
binaryMessenger, getPigeonApiWebSettingsCompat())
PigeonApiWebViewFeature.setUpMessageHandlers(binaryMessenger, getPigeonApiWebViewFeature())
}

fun tearDown() {
Expand All @@ -632,6 +639,7 @@ abstract class AndroidWebkitLibraryPigeonProxyApiRegistrar(val binaryMessenger:
PigeonApiSslCertificate.setUpMessageHandlers(binaryMessenger, null)
PigeonApiCertificate.setUpMessageHandlers(binaryMessenger, null)
PigeonApiWebSettingsCompat.setUpMessageHandlers(binaryMessenger, null)
PigeonApiWebViewFeature.setUpMessageHandlers(binaryMessenger, null)
}
}

Expand Down Expand Up @@ -738,6 +746,8 @@ private class AndroidWebkitLibraryPigeonProxyApiBaseCodec(
registrar.getPigeonApiCertificate().pigeon_newInstance(value) {}
} else if (value is androidx.webkit.WebSettingsCompat) {
registrar.getPigeonApiWebSettingsCompat().pigeon_newInstance(value) {}
} else if (value is androidx.webkit.WebViewFeature) {
registrar.getPigeonApiWebViewFeature().pigeon_newInstance(value) {}
}

when {
Expand Down Expand Up @@ -6397,3 +6407,75 @@ abstract class PigeonApiWebSettingsCompat(
}
}

@Suppress("UNCHECKED_CAST")
abstract class PigeonApiWebViewFeature(
open val pigeonRegistrar: AndroidWebkitLibraryPigeonProxyApiRegistrar
) {
abstract fun isFeatureSupported(feature: String): Boolean

companion object {
@Suppress("LocalVariableName")
fun setUpMessageHandlers(binaryMessenger: BinaryMessenger, api: PigeonApiWebViewFeature?) {
val codec = api?.pigeonRegistrar?.codec ?: AndroidWebkitLibraryPigeonCodec()
run {
val channel =
BasicMessageChannel<Any?>(
binaryMessenger,
"dev.flutter.pigeon.webview_flutter_android.WebViewFeature.isFeatureSupported",
codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val args = message as List<Any?>
val featureArg = args[0] as String
val wrapped: List<Any?> =
try {
listOf(api.isFeatureSupported(featureArg))
} catch (exception: Throwable) {
AndroidWebkitLibraryPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
} else {
channel.setMessageHandler(null)
}
}
}
}

@Suppress("LocalVariableName", "FunctionName")
/** Creates a Dart instance of WebViewFeature and attaches it to [pigeon_instanceArg]. */
fun pigeon_newInstance(
pigeon_instanceArg: androidx.webkit.WebViewFeature,
callback: (Result<Unit>) -> Unit
) {
if (pigeonRegistrar.ignoreCallsToDart) {
callback(
Result.failure(
AndroidWebKitError("ignore-calls-error", "Calls to Dart are being ignored.", "")))
} else if (pigeonRegistrar.instanceManager.containsInstance(pigeon_instanceArg)) {
callback(Result.success(Unit))
} else {
val pigeon_identifierArg =
pigeonRegistrar.instanceManager.addHostCreatedInstance(pigeon_instanceArg)
val binaryMessenger = pigeonRegistrar.binaryMessenger
val codec = pigeonRegistrar.codec
val channelName =
"dev.flutter.pigeon.webview_flutter_android.WebViewFeature.pigeon_newInstance"
val channel = BasicMessageChannel<Any?>(binaryMessenger, channelName, codec)
channel.send(listOf(pigeon_identifierArg)) {
if (it is List<*>) {
if (it.size > 1) {
callback(
Result.failure(
AndroidWebKitError(it[0] as String, it[1] as String, it[2] as String?)))
} else {
callback(Result.success(Unit))
}
} else {
callback(
Result.failure(AndroidWebkitLibraryPigeonUtils.createConnectionError(channelName)))
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ public FlutterAssetManager getFlutterAssetManager() {
return flutterAssetManager;
}

@NonNull
@Override
public PigeonApiWebViewFeature getPigeonApiWebViewFeature() {
return new WebViewFeatureProxyApi(this);
}

@NonNull
@Override
public PigeonApiWebSettingsCompat getPigeonApiWebSettingsCompat() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1104,3 +1104,13 @@ abstract class WebSettingsCompat {
bool enabled,
);
}

@ProxyApi(
kotlinOptions: KotlinProxyApiOptions(
fullClassName: 'androidx.webkit.WebViewFeature',
),
)
abstract class WebViewFeature {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for here

@static
bool isFeatureSupported(String feature);
}