From 35fcae3ed7a747f42ce9f81310b646976afe258e Mon Sep 17 00:00:00 2001 From: Fabian Freund Date: Mon, 5 May 2025 14:34:47 +0200 Subject: [PATCH] add install addon functionality --- .../domain/services/browser_addon.dart | 50 + .../domain/services/browser_addon.g.dart | 28 + .../api/GeckoAddonsApiImpl.kt | 12 + .../pigeons/Gecko.g.kt | 702 +++++++++++--- .../lib/src/domain/services/gecko_addon.dart | 4 + .../lib/src/pigeons/gecko.g.dart | 897 +++++++++++++++++- .../pigeons/gecko.dart | 3 + 7 files changed, 1526 insertions(+), 170 deletions(-) create mode 100644 app/lib/features/geckoview/features/browser/domain/services/browser_addon.dart create mode 100644 app/lib/features/geckoview/features/browser/domain/services/browser_addon.g.dart diff --git a/app/lib/features/geckoview/features/browser/domain/services/browser_addon.dart b/app/lib/features/geckoview/features/browser/domain/services/browser_addon.dart new file mode 100644 index 00000000..c8e58372 --- /dev/null +++ b/app/lib/features/geckoview/features/browser/domain/services/browser_addon.dart @@ -0,0 +1,50 @@ +import 'dart:convert'; + +import 'package:http/http.dart' as http; +import 'package:lensai/core/logger.dart'; +import 'package:lensai/features/geckoview/domain/providers.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; + +part 'browser_addon.g.dart'; + +@Riverpod() +class BrowserAddonService extends _$BrowserAddonService { + Future getAddonXpiUrl(String guid) async { + final url = 'https://addons.mozilla.org/api/v5/addons/addon/$guid/'; + + try { + final response = await http.get(Uri.parse(url)); + + if (response.statusCode == 200) { + final data = jsonDecode(response.body) as Map; + + // ignore: avoid_dynamic_calls + final xpiUrl = data['current_version']['file']['url'] as String; + + return Uri.parse(xpiUrl); + } else { + throw Exception('Failed to load addon data: ${response.statusCode}'); + } + } catch (e) { + throw Exception('Error fetching addon data: $e'); + } + } + + Future install(String addonGuid) async { + try { + final xpiUrl = await getAddonXpiUrl(addonGuid); + await ref.read(addonServiceProvider).installAddon(xpiUrl); + + return true; + } catch (e, s) { + logger.e('Failed installing $addonGuid', error: e, stackTrace: s); + + return false; + } + } + + @override + void build() { + return; + } +} diff --git a/app/lib/features/geckoview/features/browser/domain/services/browser_addon.g.dart b/app/lib/features/geckoview/features/browser/domain/services/browser_addon.g.dart new file mode 100644 index 00000000..efdd138e --- /dev/null +++ b/app/lib/features/geckoview/features/browser/domain/services/browser_addon.g.dart @@ -0,0 +1,28 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'browser_addon.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +String _$browserAddonServiceHash() => + r'1dd73c322e712e1492d74f1af844d5b5cc8f81bb'; + +/// See also [BrowserAddonService]. +@ProviderFor(BrowserAddonService) +final browserAddonServiceProvider = + AutoDisposeNotifierProvider.internal( + BrowserAddonService.new, + name: r'browserAddonServiceProvider', + debugGetCreateSourceHash: + const bool.fromEnvironment('dart.vm.product') + ? null + : _$browserAddonServiceHash, + dependencies: null, + allTransitiveDependencies: null, + ); + +typedef _$BrowserAddonService = AutoDisposeNotifier; +// ignore_for_file: type=lint +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/packages/flutter_mozilla_components/android/src/main/kotlin/eu/lensai/flutter_mozilla_components/api/GeckoAddonsApiImpl.kt b/packages/flutter_mozilla_components/android/src/main/kotlin/eu/lensai/flutter_mozilla_components/api/GeckoAddonsApiImpl.kt index 50c67b17..ef8c7529 100644 --- a/packages/flutter_mozilla_components/android/src/main/kotlin/eu/lensai/flutter_mozilla_components/api/GeckoAddonsApiImpl.kt +++ b/packages/flutter_mozilla_components/android/src/main/kotlin/eu/lensai/flutter_mozilla_components/api/GeckoAddonsApiImpl.kt @@ -24,4 +24,16 @@ class GeckoAddonsApiImpl(private val context: Context) : GeckoAddonsApi { WebExtensionActionType.PAGE -> components.features.webExtensionToolbarFeature.invokeAddonPageAction(extensionId) } } + + override fun installAddon(url: String, callback: (Result) -> Unit) { + components.core.addonManager.installAddon( + url = url, + onSuccess = { _ -> + callback(Result.success(Unit)) + }, + onError = { e -> + callback(Result.failure(e)) + } + ) + } } \ No newline at end of file diff --git a/packages/flutter_mozilla_components/android/src/main/kotlin/eu/lensai/flutter_mozilla_components/pigeons/Gecko.g.kt b/packages/flutter_mozilla_components/android/src/main/kotlin/eu/lensai/flutter_mozilla_components/pigeons/Gecko.g.kt index a36a5a28..82574621 100644 --- a/packages/flutter_mozilla_components/android/src/main/kotlin/eu/lensai/flutter_mozilla_components/pigeons/Gecko.g.kt +++ b/packages/flutter_mozilla_components/android/src/main/kotlin/eu/lensai/flutter_mozilla_components/pigeons/Gecko.g.kt @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v24.2.2), do not edit directly. +// Autogenerated from Pigeon (v25.3.1), do not edit directly. // See also: https://pub.dev/packages/pigeon @file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") @@ -13,29 +13,61 @@ import io.flutter.plugin.common.StandardMethodCodec import io.flutter.plugin.common.StandardMessageCodec import java.io.ByteArrayOutputStream import java.nio.ByteBuffer +private object GeckoPigeonUtils { -private fun wrapResult(result: Any?): List { - return listOf(result) -} + fun createConnectionError(channelName: String): FlutterError { + return FlutterError("channel-error", "Unable to establish connection on channel: '$channelName'.", "") } -private fun wrapError(exception: Throwable): List { - return if (exception is FlutterError) { - listOf( - exception.code, - exception.message, - exception.details - ) - } else { - listOf( - exception.javaClass.simpleName, - exception.toString(), - "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) - ) + fun wrapResult(result: Any?): List { + return listOf(result) } -} -private fun createConnectionError(channelName: String): FlutterError { - return FlutterError("channel-error", "Unable to establish connection on channel: '$channelName'.", "")} + fun wrapError(exception: Throwable): List { + return if (exception is FlutterError) { + listOf( + exception.code, + exception.message, + exception.details + ) + } else { + listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) + } + } + fun deepEquals(a: Any?, b: Any?): Boolean { + if (a is ByteArray && b is ByteArray) { + return a.contentEquals(b) + } + if (a is IntArray && b is IntArray) { + return a.contentEquals(b) + } + if (a is LongArray && b is LongArray) { + return a.contentEquals(b) + } + if (a is DoubleArray && b is DoubleArray) { + return a.contentEquals(b) + } + if (a is Array<*> && b is Array<*>) { + return a.size == b.size && + a.indices.all{ deepEquals(a[it], b[it]) } + } + if (a is List<*> && b is List<*>) { + return a.size == b.size && + a.indices.all{ deepEquals(a[it], b[it]) } + } + if (a is Map<*, *> && b is Map<*, *>) { + return a.size == b.size && a.all { + (b as Map).containsKey(it.key) && + deepEquals(it.value, b[it.key]) + } + } + return a == b + } + +} /** * Error class for passing custom error details to Flutter via a thrown PlatformException. @@ -277,6 +309,16 @@ data class TranslationOptions ( downloadModel, ) } + override fun equals(other: Any?): Boolean { + if (other !is TranslationOptions) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -336,6 +378,16 @@ data class ReaderState ( scrollY, ) } + override fun equals(other: Any?): Boolean { + if (other !is ReaderState) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -382,6 +434,16 @@ data class LastMediaAccessState ( mediaSessionActive, ) } + override fun equals(other: Any?): Boolean { + if (other !is LastMediaAccessState) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -423,6 +485,16 @@ data class HistoryMetadataKey ( referrerUrl, ) } + override fun equals(other: Any?): Boolean { + if (other !is HistoryMetadataKey) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -441,6 +513,16 @@ data class PackageCategoryValue ( value, ) } + override fun equals(other: Any?): Boolean { + if (other !is PackageCategoryValue) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -468,6 +550,16 @@ data class ExternalPackage ( category, ) } + override fun equals(other: Any?): Boolean { + if (other !is ExternalPackage) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -486,6 +578,16 @@ data class LoadUrlFlagsValue ( value, ) } + override fun equals(other: Any?): Boolean { + if (other !is LoadUrlFlagsValue) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -507,6 +609,16 @@ data class SourceValue ( caller, ) } + override fun equals(other: Any?): Boolean { + if (other !is SourceValue) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -596,6 +708,16 @@ data class TabState ( hasFormData, ) } + override fun equals(other: Any?): Boolean { + if (other !is TabState) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -623,6 +745,16 @@ data class RecoverableTab ( state, ) } + override fun equals(other: Any?): Boolean { + if (other !is RecoverableTab) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -650,6 +782,16 @@ data class RecoverableBrowserState ( selectedTabId, ) } + override fun equals(other: Any?): Boolean { + if (other !is RecoverableBrowserState) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -687,6 +829,16 @@ data class IconRequest ( waitOnNetworkLoad, ) } + override fun equals(other: Any?): Boolean { + if (other !is IconRequest) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -708,6 +860,16 @@ data class ResourceSize ( width, ) } + override fun equals(other: Any?): Boolean { + if (other !is ResourceSize) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -742,6 +904,16 @@ data class Resource ( maskable, ) } + override fun equals(other: Any?): Boolean { + if (other !is Resource) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -777,6 +949,16 @@ data class IconResult ( maskable, ) } + override fun equals(other: Any?): Boolean { + if (other !is IconResult) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -795,6 +977,16 @@ data class CookiePartitionKey ( topLevelSite, ) } + override fun equals(other: Any?): Boolean { + if (other !is CookiePartitionKey) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -849,6 +1041,16 @@ data class Cookie ( value, ) } + override fun equals(other: Any?): Boolean { + if (other !is Cookie) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -870,6 +1072,16 @@ data class HistoryItem ( title, ) } + override fun equals(other: Any?): Boolean { + if (other !is HistoryItem) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -897,6 +1109,16 @@ data class HistoryState ( canGoForward, ) } + override fun equals(other: Any?): Boolean { + if (other !is HistoryState) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -923,6 +1145,16 @@ data class ReaderableState ( active, ) } + override fun equals(other: Any?): Boolean { + if (other !is ReaderableState) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -947,6 +1179,16 @@ data class SecurityInfoState ( issuer, ) } + override fun equals(other: Any?): Boolean { + if (other !is SecurityInfoState) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -986,6 +1228,16 @@ data class TabContentState ( isLoading, ) } + override fun equals(other: Any?): Boolean { + if (other !is TabContentState) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -1010,6 +1262,16 @@ data class FindResultState ( isDoneCounting, ) } + override fun equals(other: Any?): Boolean { + if (other !is FindResultState) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -1034,6 +1296,16 @@ data class CustomSelectionAction ( pattern, ) } + override fun equals(other: Any?): Boolean { + if (other !is CustomSelectionAction) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -1067,6 +1339,16 @@ data class WebExtensionData ( badgeBackgroundColor, ) } + override fun equals(other: Any?): Boolean { + if (other !is WebExtensionData) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -1103,6 +1385,16 @@ data class GeckoSuggestion ( icon, ) } + override fun equals(other: Any?): Boolean { + if (other !is GeckoSuggestion) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -1136,6 +1428,16 @@ data class TabContent ( extractedContentPlain, ) } + override fun equals(other: Any?): Boolean { + if (other !is TabContent) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -1181,6 +1483,16 @@ data class GeckoEngineSettings ( webContentIsolationStrategy, ) } + override fun equals(other: Any?): Boolean { + if (other !is GeckoEngineSettings) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -1211,6 +1523,16 @@ data class AutocompleteResult ( totalItems, ) } + override fun equals(other: Any?): Boolean { + if (other !is AutocompleteResult) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -1241,6 +1563,16 @@ data class UnknownHitResult ( src, ) } + override fun equals(other: Any?): Boolean { + if (other !is UnknownHitResult) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -1266,6 +1598,16 @@ data class ImageHitResult ( title, ) } + override fun equals(other: Any?): Boolean { + if (other !is ImageHitResult) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -1291,6 +1633,16 @@ data class VideoHitResult ( title, ) } + override fun equals(other: Any?): Boolean { + if (other !is VideoHitResult) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -1316,6 +1668,16 @@ data class AudioHitResult ( title, ) } + override fun equals(other: Any?): Boolean { + if (other !is AudioHitResult) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -1341,6 +1703,16 @@ data class ImageSrcHitResult ( uri, ) } + override fun equals(other: Any?): Boolean { + if (other !is ImageSrcHitResult) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -1363,6 +1735,16 @@ data class PhoneHitResult ( src, ) } + override fun equals(other: Any?): Boolean { + if (other !is PhoneHitResult) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -1385,6 +1767,16 @@ data class EmailHitResult ( src, ) } + override fun equals(other: Any?): Boolean { + if (other !is EmailHitResult) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** @@ -1407,6 +1799,16 @@ data class GeoHitResult ( src, ) } + override fun equals(other: Any?): Boolean { + if (other !is GeoHitResult) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -1473,6 +1875,16 @@ data class DownloadState ( notificationId, ) } + override fun equals(other: Any?): Boolean { + if (other !is DownloadState) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } /** Generated class from Pigeon that represents data sent in messages. */ @@ -1500,6 +1912,16 @@ data class ShareInternetResourceState ( referrerUrl, ) } + override fun equals(other: Any?): Boolean { + if (other !is ShareInternetResourceState) { + return false + } + if (this === other) { + return true + } + return GeckoPigeonUtils.deepEquals(toList(), other.toList()) } + + override fun hashCode(): Int = toList().hashCode() } private open class GeckoPigeonCodec : StandardMessageCodec() { override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { @@ -2015,7 +2437,7 @@ interface GeckoBrowserApi { api.initialize() listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2030,7 +2452,7 @@ interface GeckoBrowserApi { val wrapped: List = try { listOf(api.showNativeFragment()) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2048,7 +2470,7 @@ interface GeckoBrowserApi { api.onTrimMemory(levelArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2083,7 +2505,7 @@ interface GeckoEngineSettingsApi { api.setDefaultSettings(settingsArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2101,7 +2523,7 @@ interface GeckoEngineSettingsApi { api.updateRuntimeSettings(settingsArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2154,7 +2576,7 @@ interface GeckoSessionApi { api.loadUrl(tabIdArg, urlArg, flagsArg, additionalHeadersArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2175,7 +2597,7 @@ interface GeckoSessionApi { api.loadData(tabIdArg, dataArg, mimeTypeArg, encodingArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2194,7 +2616,7 @@ interface GeckoSessionApi { api.reload(tabIdArg, flagsArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2212,7 +2634,7 @@ interface GeckoSessionApi { api.stopLoading(tabIdArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2231,7 +2653,7 @@ interface GeckoSessionApi { api.goBack(tabIdArg, userInteractionArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2250,7 +2672,7 @@ interface GeckoSessionApi { api.goForward(tabIdArg, userInteractionArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2269,7 +2691,7 @@ interface GeckoSessionApi { api.goToHistoryIndex(indexArg, tabIdArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2288,7 +2710,7 @@ interface GeckoSessionApi { api.requestDesktopSite(tabIdArg, enableArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2306,7 +2728,7 @@ interface GeckoSessionApi { api.exitFullscreen(tabIdArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2324,7 +2746,7 @@ interface GeckoSessionApi { api.saveToPdf(tabIdArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2342,7 +2764,7 @@ interface GeckoSessionApi { api.printContent(tabIdArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2363,7 +2785,7 @@ interface GeckoSessionApi { api.translate(tabIdArg, fromLanguageArg, toLanguageArg, optionsArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2381,7 +2803,7 @@ interface GeckoSessionApi { api.translateRestore(tabIdArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2399,7 +2821,7 @@ interface GeckoSessionApi { api.crashRecovery(tabIdsArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2415,7 +2837,7 @@ interface GeckoSessionApi { api.purgeHistory() listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2434,7 +2856,7 @@ interface GeckoSessionApi { api.updateLastAccess(tabIdArg, lastAccessArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2451,10 +2873,10 @@ interface GeckoSessionApi { api.requestScreenshot(sendBackArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { val data = result.getOrNull() - reply.reply(wrapResult(data)) + reply.reply(GeckoPigeonUtils.wrapResult(data)) } } } @@ -2516,7 +2938,7 @@ interface GeckoTabsApi { api.syncEvents(onSelectedTabChangeArg, onTabListChangeArg, onTabContentStateChangeArg, onIconChangeArg, onSecurityInfoStateChangeArg, onReaderableStateChangeArg, onHistoryStateChangeArg, onFindResultsArg, onThumbnailChangeArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2534,7 +2956,7 @@ interface GeckoTabsApi { api.selectTab(tabIdArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2552,7 +2974,7 @@ interface GeckoTabsApi { api.removeTab(tabIdArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2578,7 +3000,7 @@ interface GeckoTabsApi { val wrapped: List = try { listOf(api.addTab(urlArg, selectTabArg, startLoadingArg, parentIdArg, flagsArg, contextIdArg, sourceArg, privateArg, historyMetadataArg, additionalHeadersArg)) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2596,7 +3018,7 @@ interface GeckoTabsApi { api.removeAllTabs(recoverableArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2614,7 +3036,7 @@ interface GeckoTabsApi { api.removeTabs(idsArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2630,7 +3052,7 @@ interface GeckoTabsApi { api.removeNormalTabs() listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2646,7 +3068,7 @@ interface GeckoTabsApi { api.removePrivateTabs() listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2662,7 +3084,7 @@ interface GeckoTabsApi { api.undo() listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2682,7 +3104,7 @@ interface GeckoTabsApi { api.restoreTabsByList(tabsArg, selectTabIdArg, restoreLocationArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2701,7 +3123,7 @@ interface GeckoTabsApi { api.restoreTabsByBrowserState(stateArg, restoreLocationArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2719,7 +3141,7 @@ interface GeckoTabsApi { val wrapped: List = try { listOf(api.selectOrAddTabByHistory(urlArg, historyMetadataArg)) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2740,7 +3162,7 @@ interface GeckoTabsApi { val wrapped: List = try { listOf(api.selectOrAddTabByUrl(urlArg, privateArg, sourceArg, flagsArg, ignoreFragmentArg)) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2759,7 +3181,7 @@ interface GeckoTabsApi { val wrapped: List = try { listOf(api.duplicateTab(selectTabIdArg, selectNewTabArg, newContextIdArg)) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2779,7 +3201,7 @@ interface GeckoTabsApi { api.moveTabs(tabIdsArg, targetTabIdArg, placeAfterArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2797,7 +3219,7 @@ interface GeckoTabsApi { val wrapped: List = try { listOf(api.migratePrivateTabUseCase(tabIdArg, alternativeUrlArg)) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2834,7 +3256,7 @@ interface GeckoFindApi { api.findAll(tabIdArg, textArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2853,7 +3275,7 @@ interface GeckoFindApi { api.findNext(tabIdArg, forwardArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2871,7 +3293,7 @@ interface GeckoFindApi { api.clearMatches(tabIdArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -2904,10 +3326,10 @@ interface GeckoIconsApi { api.loadIcon(requestArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { val data = result.getOrNull() - reply.reply(wrapResult(data)) + reply.reply(GeckoPigeonUtils.wrapResult(data)) } } } @@ -2942,10 +3364,10 @@ interface GeckoPrefApi { api.getPrefs(preferenceFilterArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { val data = result.getOrNull() - reply.reply(wrapResult(data)) + reply.reply(GeckoPigeonUtils.wrapResult(data)) } } } @@ -2962,10 +3384,10 @@ interface GeckoPrefApi { api.applyPrefs(prefBufferArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { val data = result.getOrNull() - reply.reply(wrapResult(data)) + reply.reply(GeckoPigeonUtils.wrapResult(data)) } } } @@ -2982,9 +3404,9 @@ interface GeckoPrefApi { api.resetPrefs(preferenceNamesArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { - reply.reply(wrapResult(null)) + reply.reply(GeckoPigeonUtils.wrapResult(null)) } } } @@ -3017,10 +3439,10 @@ interface GeckoBrowserExtensionApi { api.getMarkdown(htmlListArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { val data = result.getOrNull() - reply.reply(wrapResult(data)) + reply.reply(GeckoPigeonUtils.wrapResult(data)) } } } @@ -3057,7 +3479,7 @@ interface GeckoContainerProxyApi { api.setProxyPort(portArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -3075,7 +3497,7 @@ interface GeckoContainerProxyApi { api.addContainerProxy(contextIdArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -3093,7 +3515,7 @@ interface GeckoContainerProxyApi { api.removeContainerProxy(contextIdArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -3108,10 +3530,10 @@ interface GeckoContainerProxyApi { api.healthcheck{ result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { val data = result.getOrNull() - reply.reply(wrapResult(data)) + reply.reply(GeckoPigeonUtils.wrapResult(data)) } } } @@ -3151,10 +3573,10 @@ interface GeckoCookieApi { api.getCookie(firstPartyDomainArg, nameArg, partitionKeyArg, storeIdArg, urlArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { val data = result.getOrNull() - reply.reply(wrapResult(data)) + reply.reply(GeckoPigeonUtils.wrapResult(data)) } } } @@ -3176,10 +3598,10 @@ interface GeckoCookieApi { api.getAllCookies(domainArg, firstPartyDomainArg, nameArg, partitionKeyArg, storeIdArg, urlArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { val data = result.getOrNull() - reply.reply(wrapResult(data)) + reply.reply(GeckoPigeonUtils.wrapResult(data)) } } } @@ -3207,9 +3629,9 @@ interface GeckoCookieApi { api.setCookie(domainArg, expirationDateArg, firstPartyDomainArg, httpOnlyArg, nameArg, partitionKeyArg, pathArg, sameSiteArg, secureArg, storeIdArg, urlArg, valueArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { - reply.reply(wrapResult(null)) + reply.reply(GeckoPigeonUtils.wrapResult(null)) } } } @@ -3230,9 +3652,9 @@ interface GeckoCookieApi { api.removeCookie(firstPartyDomainArg, nameArg, partitionKeyArg, storeIdArg, urlArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { - reply.reply(wrapResult(null)) + reply.reply(GeckoPigeonUtils.wrapResult(null)) } } } @@ -3264,7 +3686,7 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3281,7 +3703,7 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3298,7 +3720,7 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3315,7 +3737,7 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3332,7 +3754,7 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3349,7 +3771,7 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3366,7 +3788,7 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3383,7 +3805,7 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3400,7 +3822,7 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3417,7 +3839,7 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3434,7 +3856,7 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3451,7 +3873,7 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3468,7 +3890,7 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3485,7 +3907,7 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3514,7 +3936,7 @@ interface ReaderViewEvents { api.onToggleReaderView(enableArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -3530,7 +3952,7 @@ interface ReaderViewEvents { api.onAppearanceButtonTap() listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -3562,7 +3984,7 @@ class ReaderViewController(private val binaryMessenger: BinaryMessenger, private callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3590,7 +4012,7 @@ interface GeckoSelectionActionController { api.setActions(actionsArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -3622,7 +4044,7 @@ class GeckoSelectionActionEvents(private val binaryMessenger: BinaryMessenger, p callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3631,6 +4053,7 @@ class GeckoSelectionActionEvents(private val binaryMessenger: BinaryMessenger, p interface GeckoAddonsApi { fun startAddonManagerActivity() fun invokeAddonAction(extensionId: String, actionType: WebExtensionActionType) + fun installAddon(url: String, callback: (Result) -> Unit) companion object { /** The codec used by GeckoAddonsApi. */ @@ -3649,7 +4072,7 @@ interface GeckoAddonsApi { api.startAddonManagerActivity() listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -3668,7 +4091,7 @@ interface GeckoAddonsApi { api.invokeAddonAction(extensionIdArg, actionTypeArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -3676,6 +4099,25 @@ interface GeckoAddonsApi { channel.setMessageHandler(null) } } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoAddonsApi.installAddon$separatedMessageChannelSuffix", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val urlArg = args[0] as String + api.installAddon(urlArg) { result: Result -> + val error = result.exceptionOrNull() + if (error != null) { + reply.reply(GeckoPigeonUtils.wrapError(error)) + } else { + reply.reply(GeckoPigeonUtils.wrapResult(null)) + } + } + } + } else { + channel.setMessageHandler(null) + } + } } } } @@ -3700,7 +4142,7 @@ class GeckoAddonEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3717,7 +4159,7 @@ class GeckoAddonEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3734,7 +4176,7 @@ class GeckoAddonEvents(private val binaryMessenger: BinaryMessenger, private val callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3762,10 +4204,10 @@ interface GeckoSuggestionApi { api.getAutocompleteSuggestion(queryArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { val data = result.getOrNull() - reply.reply(wrapResult(data)) + reply.reply(GeckoPigeonUtils.wrapResult(data)) } } } @@ -3784,7 +4226,7 @@ interface GeckoSuggestionApi { api.querySuggestions(textArg, providersArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -3816,7 +4258,7 @@ class GeckoSuggestionEvents(private val binaryMessenger: BinaryMessenger, privat callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3842,7 +4284,7 @@ class GeckoTabContentEvents(private val binaryMessenger: BinaryMessenger, privat callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } @@ -3872,9 +4314,9 @@ interface GeckoDeleteBrowsingDataController { api.deleteTabs{ result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { - reply.reply(wrapResult(null)) + reply.reply(GeckoPigeonUtils.wrapResult(null)) } } } @@ -3889,9 +4331,9 @@ interface GeckoDeleteBrowsingDataController { api.deleteBrowsingHistory{ result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { - reply.reply(wrapResult(null)) + reply.reply(GeckoPigeonUtils.wrapResult(null)) } } } @@ -3906,9 +4348,9 @@ interface GeckoDeleteBrowsingDataController { api.deleteCookiesAndSiteData{ result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { - reply.reply(wrapResult(null)) + reply.reply(GeckoPigeonUtils.wrapResult(null)) } } } @@ -3923,9 +4365,9 @@ interface GeckoDeleteBrowsingDataController { api.deleteCachedFiles{ result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { - reply.reply(wrapResult(null)) + reply.reply(GeckoPigeonUtils.wrapResult(null)) } } } @@ -3940,9 +4382,9 @@ interface GeckoDeleteBrowsingDataController { api.deleteSitePermissions{ result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { - reply.reply(wrapResult(null)) + reply.reply(GeckoPigeonUtils.wrapResult(null)) } } } @@ -3957,9 +4399,9 @@ interface GeckoDeleteBrowsingDataController { api.deleteDownloads{ result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(wrapError(error)) + reply.reply(GeckoPigeonUtils.wrapError(error)) } else { - reply.reply(wrapResult(null)) + reply.reply(GeckoPigeonUtils.wrapResult(null)) } } } @@ -3996,7 +4438,7 @@ interface GeckoDownloadsApi { api.requestDownload(tabIdArg, stateArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -4015,7 +4457,7 @@ interface GeckoDownloadsApi { api.copyInternetResource(tabIdArg, stateArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -4034,7 +4476,7 @@ interface GeckoDownloadsApi { api.shareInternetResource(tabIdArg, stateArg) listOf(null) } catch (exception: Throwable) { - wrapError(exception) + GeckoPigeonUtils.wrapError(exception) } reply.reply(wrapped) } @@ -4066,7 +4508,7 @@ class BrowserExtensionEvents(private val binaryMessenger: BinaryMessenger, priva callback(Result.success(Unit)) } } else { - callback(Result.failure(createConnectionError(channelName))) + callback(Result.failure(GeckoPigeonUtils.createConnectionError(channelName))) } } } diff --git a/packages/flutter_mozilla_components/lib/src/domain/services/gecko_addon.dart b/packages/flutter_mozilla_components/lib/src/domain/services/gecko_addon.dart index dd70a489..44fd8c21 100644 --- a/packages/flutter_mozilla_components/lib/src/domain/services/gecko_addon.dart +++ b/packages/flutter_mozilla_components/lib/src/domain/services/gecko_addon.dart @@ -39,6 +39,10 @@ class GeckoAddonService extends GeckoAddonEvents { return _api.invokeAddonAction(extensionId, actionType); } + Future installAddon(Uri url) { + return _api.installAddon(url.toString()); + } + @override void onRemoveWebExtensionAction( int timestamp, diff --git a/packages/flutter_mozilla_components/lib/src/pigeons/gecko.g.dart b/packages/flutter_mozilla_components/lib/src/pigeons/gecko.g.dart index 779dc0b7..392cb39d 100644 --- a/packages/flutter_mozilla_components/lib/src/pigeons/gecko.g.dart +++ b/packages/flutter_mozilla_components/lib/src/pigeons/gecko.g.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v24.2.2), do not edit directly. +// Autogenerated from Pigeon (v25.3.1), 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, no_leading_underscores_for_local_identifiers @@ -24,6 +24,20 @@ List wrapResponse({Object? result, PlatformException? error, bool empty } return [error.code, error.message, error.details]; } +bool _deepEquals(Object? a, Object? b) { + if (a is List && b is List) { + return a.length == b.length && + a.indexed + .every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1])); + } + if (a is Map && b is Map) { + return a.length == b.length && a.entries.every((MapEntry entry) => + (b as Map).containsKey(entry.key) && + _deepEquals(entry.value, b[entry.key])); + } + return a == b; +} + /// Indicates what location the tabs should be restored at enum RestoreLocation { @@ -153,18 +167,38 @@ class TranslationOptions { bool downloadModel; - Object encode() { + List _toList() { return [ downloadModel, ]; } + Object encode() { + return _toList(); } + static TranslationOptions decode(Object result) { result as List; return TranslationOptions( downloadModel: result[0]! as bool, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! TranslationOptions || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// Value type that represents the state of reader mode/view. @@ -204,7 +238,7 @@ class ReaderState { /// displayed in reader view. int? scrollY; - Object encode() { + List _toList() { return [ readerable, active, @@ -216,6 +250,9 @@ class ReaderState { ]; } + Object encode() { + return _toList(); } + static ReaderState decode(Object result) { result as List; return ReaderState( @@ -228,6 +265,23 @@ class ReaderState { scrollY: result[6] as int?, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! ReaderState || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// Details about the last playing media in this tab. @@ -256,7 +310,7 @@ class LastMediaAccessState { /// even when the users accesses another page (with another URL) in that same HTML document. bool mediaSessionActive; - Object encode() { + List _toList() { return [ lastMediaUrl, lastMediaAccess, @@ -264,6 +318,9 @@ class LastMediaAccessState { ]; } + Object encode() { + return _toList(); } + static LastMediaAccessState decode(Object result) { result as List; return LastMediaAccessState( @@ -272,6 +329,23 @@ class LastMediaAccessState { mediaSessionActive: result[2]! as bool, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! LastMediaAccessState || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// Represents a set of history metadata values that uniquely identify a record. Note that @@ -297,7 +371,7 @@ class HistoryMetadataKey { /// a page in a new tab. String? referrerUrl; - Object encode() { + List _toList() { return [ url, searchTerm, @@ -305,6 +379,9 @@ class HistoryMetadataKey { ]; } + Object encode() { + return _toList(); } + static HistoryMetadataKey decode(Object result) { result as List; return HistoryMetadataKey( @@ -313,6 +390,23 @@ class HistoryMetadataKey { referrerUrl: result[2] as String?, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! HistoryMetadataKey || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class PackageCategoryValue { @@ -322,18 +416,38 @@ class PackageCategoryValue { int value; - Object encode() { + List _toList() { return [ value, ]; } + Object encode() { + return _toList(); } + static PackageCategoryValue decode(Object result) { result as List; return PackageCategoryValue( value: result[0]! as int, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! PackageCategoryValue || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// Describes an external package. @@ -349,13 +463,16 @@ class ExternalPackage { /// A [PackageCategory] as defined by the application. PackageCategoryValue category; - Object encode() { + List _toList() { return [ packageId, category, ]; } + Object encode() { + return _toList(); } + static ExternalPackage decode(Object result) { result as List; return ExternalPackage( @@ -363,6 +480,23 @@ class ExternalPackage { category: result[1]! as PackageCategoryValue, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! ExternalPackage || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class LoadUrlFlagsValue { @@ -372,18 +506,38 @@ class LoadUrlFlagsValue { int value; - Object encode() { + List _toList() { return [ value, ]; } + Object encode() { + return _toList(); } + static LoadUrlFlagsValue decode(Object result) { result as List; return LoadUrlFlagsValue( value: result[0]! as int, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! LoadUrlFlagsValue || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class SourceValue { @@ -396,13 +550,16 @@ class SourceValue { ExternalPackage? caller; - Object encode() { + List _toList() { return [ id, caller, ]; } + Object encode() { + return _toList(); } + static SourceValue decode(Object result) { result as List; return SourceValue( @@ -410,6 +567,23 @@ class SourceValue { caller: result[1] as ExternalPackage?, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! SourceValue || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// A tab that is no longer open and in the list of tabs, but that can be restored (recovered) at @@ -483,7 +657,7 @@ class TabState { /// Whether the tab has form data. bool hasFormData; - Object encode() { + List _toList() { return [ id, url, @@ -503,6 +677,9 @@ class TabState { ]; } + Object encode() { + return _toList(); } + static TabState decode(Object result) { result as List; return TabState( @@ -523,6 +700,23 @@ class TabState { hasFormData: result[14]! as bool, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! TabState || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// A recoverable version of [TabState]. @@ -538,13 +732,16 @@ class RecoverableTab { /// A [TabState] instance containing basic tab state. TabState state; - Object encode() { + List _toList() { return [ engineSessionStateJson, state, ]; } + Object encode() { + return _toList(); } + static RecoverableTab decode(Object result) { result as List; return RecoverableTab( @@ -552,6 +749,23 @@ class RecoverableTab { state: result[1]! as TabState, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! RecoverableTab || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// A restored browser state, read from disk. @@ -567,13 +781,16 @@ class RecoverableBrowserState { /// The ID of the selected tab in [tabs]. Or `null` if no selection was restored. String? selectedTabId; - Object encode() { + List _toList() { return [ tabs, selectedTabId, ]; } + Object encode() { + return _toList(); } + static RecoverableBrowserState decode(Object result) { result as List; return RecoverableBrowserState( @@ -581,6 +798,23 @@ class RecoverableBrowserState { selectedTabId: result[1] as String?, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! RecoverableBrowserState || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// A request to load an [Icon]. @@ -606,7 +840,7 @@ class IconRequest { bool waitOnNetworkLoad; - Object encode() { + List _toList() { return [ url, size, @@ -617,6 +851,9 @@ class IconRequest { ]; } + Object encode() { + return _toList(); } + static IconRequest decode(Object result) { result as List; return IconRequest( @@ -628,6 +865,23 @@ class IconRequest { waitOnNetworkLoad: result[5]! as bool, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! IconRequest || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class ResourceSize { @@ -640,13 +894,16 @@ class ResourceSize { int width; - Object encode() { + List _toList() { return [ height, width, ]; } + Object encode() { + return _toList(); } + static ResourceSize decode(Object result) { result as List; return ResourceSize( @@ -654,6 +911,23 @@ class ResourceSize { width: result[1]! as int, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! ResourceSize || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// An icon resource that can be loaded. @@ -676,7 +950,7 @@ class Resource { bool maskable; - Object encode() { + List _toList() { return [ url, type, @@ -686,6 +960,9 @@ class Resource { ]; } + Object encode() { + return _toList(); } + static Resource decode(Object result) { result as List; return Resource( @@ -696,6 +973,23 @@ class Resource { maskable: result[4]! as bool, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! Resource || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// An [Icon] returned by [BrowserIcons] after processing an [IconRequest] @@ -719,7 +1013,7 @@ class IconResult { /// True if the icon represents as full-bleed icon that can be cropped to other shapes. bool maskable; - Object encode() { + List _toList() { return [ image, color, @@ -728,6 +1022,9 @@ class IconResult { ]; } + Object encode() { + return _toList(); } + static IconResult decode(Object result) { result as List; return IconResult( @@ -737,6 +1034,23 @@ class IconResult { maskable: result[3]! as bool, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! IconResult || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class CookiePartitionKey { @@ -746,18 +1060,38 @@ class CookiePartitionKey { String topLevelSite; - Object encode() { + List _toList() { return [ topLevelSite, ]; } + Object encode() { + return _toList(); } + static CookiePartitionKey decode(Object result) { result as List; return CookiePartitionKey( topLevelSite: result[0]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! CookiePartitionKey || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class Cookie { @@ -803,7 +1137,7 @@ class Cookie { String value; - Object encode() { + List _toList() { return [ domain, expirationDate, @@ -821,6 +1155,9 @@ class Cookie { ]; } + Object encode() { + return _toList(); } + static Cookie decode(Object result) { result as List; return Cookie( @@ -839,6 +1176,23 @@ class Cookie { value: result[12]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! Cookie || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class HistoryItem { @@ -851,13 +1205,16 @@ class HistoryItem { String title; - Object encode() { + List _toList() { return [ url, title, ]; } + Object encode() { + return _toList(); } + static HistoryItem decode(Object result) { result as List; return HistoryItem( @@ -865,6 +1222,23 @@ class HistoryItem { title: result[1]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! HistoryItem || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class HistoryState { @@ -883,7 +1257,7 @@ class HistoryState { bool canGoForward; - Object encode() { + List _toList() { return [ items, currentIndex, @@ -892,6 +1266,9 @@ class HistoryState { ]; } + Object encode() { + return _toList(); } + static HistoryState decode(Object result) { result as List; return HistoryState( @@ -901,6 +1278,23 @@ class HistoryState { canGoForward: result[3]! as bool, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! HistoryState || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class ReaderableState { @@ -916,13 +1310,16 @@ class ReaderableState { /// Whether or not reader view is active. bool active; - Object encode() { + List _toList() { return [ readerable, active, ]; } + Object encode() { + return _toList(); } + static ReaderableState decode(Object result) { result as List; return ReaderableState( @@ -930,6 +1327,23 @@ class ReaderableState { active: result[1]! as bool, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! ReaderableState || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class SecurityInfoState { @@ -945,7 +1359,7 @@ class SecurityInfoState { String issuer; - Object encode() { + List _toList() { return [ secure, host, @@ -953,6 +1367,9 @@ class SecurityInfoState { ]; } + Object encode() { + return _toList(); } + static SecurityInfoState decode(Object result) { result as List; return SecurityInfoState( @@ -961,6 +1378,23 @@ class SecurityInfoState { issuer: result[2]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! SecurityInfoState || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class TabContentState { @@ -991,7 +1425,7 @@ class TabContentState { bool isLoading; - Object encode() { + List _toList() { return [ id, contextId, @@ -1004,6 +1438,9 @@ class TabContentState { ]; } + Object encode() { + return _toList(); } + static TabContentState decode(Object result) { result as List; return TabContentState( @@ -1017,6 +1454,23 @@ class TabContentState { isLoading: result[7]! as bool, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! TabContentState || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class FindResultState { @@ -1032,7 +1486,7 @@ class FindResultState { bool isDoneCounting; - Object encode() { + List _toList() { return [ activeMatchOrdinal, numberOfMatches, @@ -1040,6 +1494,9 @@ class FindResultState { ]; } + Object encode() { + return _toList(); } + static FindResultState decode(Object result) { result as List; return FindResultState( @@ -1048,6 +1505,23 @@ class FindResultState { isDoneCounting: result[2]! as bool, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! FindResultState || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class CustomSelectionAction { @@ -1063,7 +1537,7 @@ class CustomSelectionAction { SelectionPattern? pattern; - Object encode() { + List _toList() { return [ id, title, @@ -1071,6 +1545,9 @@ class CustomSelectionAction { ]; } + Object encode() { + return _toList(); } + static CustomSelectionAction decode(Object result) { result as List; return CustomSelectionAction( @@ -1079,6 +1556,23 @@ class CustomSelectionAction { pattern: result[2] as SelectionPattern?, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! CustomSelectionAction || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class WebExtensionData { @@ -1103,7 +1597,7 @@ class WebExtensionData { int? badgeBackgroundColor; - Object encode() { + List _toList() { return [ extensionId, title, @@ -1114,6 +1608,9 @@ class WebExtensionData { ]; } + Object encode() { + return _toList(); } + static WebExtensionData decode(Object result) { result as List; return WebExtensionData( @@ -1125,6 +1622,23 @@ class WebExtensionData { badgeBackgroundColor: result[5] as int?, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! WebExtensionData || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class GeckoSuggestion { @@ -1152,7 +1666,7 @@ class GeckoSuggestion { Uint8List? icon; - Object encode() { + List _toList() { return [ id, type, @@ -1164,6 +1678,9 @@ class GeckoSuggestion { ]; } + Object encode() { + return _toList(); } + static GeckoSuggestion decode(Object result) { result as List; return GeckoSuggestion( @@ -1176,6 +1693,23 @@ class GeckoSuggestion { icon: result[6] as Uint8List?, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! GeckoSuggestion || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class TabContent { @@ -1200,7 +1734,7 @@ class TabContent { String? extractedContentPlain; - Object encode() { + List _toList() { return [ tabId, fullContentMarkdown, @@ -1211,6 +1745,9 @@ class TabContent { ]; } + Object encode() { + return _toList(); } + static TabContent decode(Object result) { result as List; return TabContent( @@ -1222,6 +1759,23 @@ class TabContent { extractedContentPlain: result[5] as String?, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! TabContent || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class GeckoEngineSettings { @@ -1258,7 +1812,7 @@ class GeckoEngineSettings { WebContentIsolationStrategy? webContentIsolationStrategy; - Object encode() { + List _toList() { return [ javascriptEnabled, trackingProtectionPolicy, @@ -1273,6 +1827,9 @@ class GeckoEngineSettings { ]; } + Object encode() { + return _toList(); } + static GeckoEngineSettings decode(Object result) { result as List; return GeckoEngineSettings( @@ -1288,6 +1845,23 @@ class GeckoEngineSettings { webContentIsolationStrategy: result[9] as WebContentIsolationStrategy?, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! GeckoEngineSettings || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class AutocompleteResult { @@ -1309,7 +1883,7 @@ class AutocompleteResult { int totalItems; - Object encode() { + List _toList() { return [ input, text, @@ -1319,6 +1893,9 @@ class AutocompleteResult { ]; } + Object encode() { + return _toList(); } + static AutocompleteResult decode(Object result) { result as List; return AutocompleteResult( @@ -1329,6 +1906,23 @@ class AutocompleteResult { totalItems: result[4]! as int, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! AutocompleteResult || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// Represents all the different supported types of data that can be found from long clicking @@ -1344,18 +1938,38 @@ class UnknownHitResult extends HitResult { String src; - Object encode() { + List _toList() { return [ src, ]; } + Object encode() { + return _toList(); } + static UnknownHitResult decode(Object result) { result as List; return UnknownHitResult( src: result[0]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! UnknownHitResult || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// If the HTML element was of type 'HTMLImageElement'. @@ -1369,13 +1983,16 @@ class ImageHitResult extends HitResult { String? title; - Object encode() { + List _toList() { return [ src, title, ]; } + Object encode() { + return _toList(); } + static ImageHitResult decode(Object result) { result as List; return ImageHitResult( @@ -1383,6 +2000,23 @@ class ImageHitResult extends HitResult { title: result[1] as String?, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! ImageHitResult || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// If the HTML element was of type 'HTMLVideoElement'. @@ -1396,13 +2030,16 @@ class VideoHitResult extends HitResult { String? title; - Object encode() { + List _toList() { return [ src, title, ]; } + Object encode() { + return _toList(); } + static VideoHitResult decode(Object result) { result as List; return VideoHitResult( @@ -1410,6 +2047,23 @@ class VideoHitResult extends HitResult { title: result[1] as String?, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! VideoHitResult || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// If the HTML element was of type 'HTMLAudioElement'. @@ -1423,13 +2077,16 @@ class AudioHitResult extends HitResult { String? title; - Object encode() { + List _toList() { return [ src, title, ]; } + Object encode() { + return _toList(); } + static AudioHitResult decode(Object result) { result as List; return AudioHitResult( @@ -1437,6 +2094,23 @@ class AudioHitResult extends HitResult { title: result[1] as String?, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! AudioHitResult || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// If the HTML element was of type 'HTMLImageElement' and contained a URI. @@ -1450,13 +2124,16 @@ class ImageSrcHitResult extends HitResult { String uri; - Object encode() { + List _toList() { return [ src, uri, ]; } + Object encode() { + return _toList(); } + static ImageSrcHitResult decode(Object result) { result as List; return ImageSrcHitResult( @@ -1464,6 +2141,23 @@ class ImageSrcHitResult extends HitResult { uri: result[1]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! ImageSrcHitResult || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// The type used if the URI is prepended with 'tel:'. @@ -1474,18 +2168,38 @@ class PhoneHitResult extends HitResult { String src; - Object encode() { + List _toList() { return [ src, ]; } + Object encode() { + return _toList(); } + static PhoneHitResult decode(Object result) { result as List; return PhoneHitResult( src: result[0]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! PhoneHitResult || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// The type used if the URI is prepended with 'mailto:'. @@ -1496,18 +2210,38 @@ class EmailHitResult extends HitResult { String src; - Object encode() { + List _toList() { return [ src, ]; } + Object encode() { + return _toList(); } + static EmailHitResult decode(Object result) { result as List; return EmailHitResult( src: result[0]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! EmailHitResult || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } /// The type used if the URI is prepended with 'geo:'. @@ -1518,18 +2252,38 @@ class GeoHitResult extends HitResult { String src; - Object encode() { + List _toList() { return [ src, ]; } + Object encode() { + return _toList(); } + static GeoHitResult decode(Object result) { result as List; return GeoHitResult( src: result[0]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! GeoHitResult || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class DownloadState { @@ -1587,7 +2341,7 @@ class DownloadState { int? notificationId; - Object encode() { + List _toList() { return [ url, fileName, @@ -1609,6 +2363,9 @@ class DownloadState { ]; } + Object encode() { + return _toList(); } + static DownloadState decode(Object result) { result as List; return DownloadState( @@ -1631,6 +2388,23 @@ class DownloadState { notificationId: result[16] as int?, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! DownloadState || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } class ShareInternetResourceState { @@ -1649,7 +2423,7 @@ class ShareInternetResourceState { String? referrerUrl; - Object encode() { + List _toList() { return [ url, contentType, @@ -1658,6 +2432,9 @@ class ShareInternetResourceState { ]; } + Object encode() { + return _toList(); } + static ShareInternetResourceState decode(Object result) { result as List; return ShareInternetResourceState( @@ -1667,6 +2444,23 @@ class ShareInternetResourceState { referrerUrl: result[3] as String?, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! ShareInternetResourceState || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; } @@ -4097,6 +4891,29 @@ class GeckoAddonsApi { return; } } + + Future installAddon(String url) async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoAddonsApi.installAddon$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([url]); + final List? pigeonVar_replyList = + await pigeonVar_sendFuture 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; + } + } } abstract class GeckoAddonEvents { diff --git a/packages/flutter_mozilla_components/pigeons/gecko.dart b/packages/flutter_mozilla_components/pigeons/gecko.dart index 5b8f8439..e8e82aab 100644 --- a/packages/flutter_mozilla_components/pigeons/gecko.dart +++ b/packages/flutter_mozilla_components/pigeons/gecko.dart @@ -1058,6 +1058,9 @@ abstract class GeckoAddonsApi { void startAddonManagerActivity(); void invokeAddonAction(String extensionId, WebExtensionActionType actionType); + + @async + void installAddon(String url); } @FlutterApi()