pref observer and fixator
This commit is contained in:
@@ -42,7 +42,7 @@ export 'src/pigeons/gecko.g.dart'
|
||||
DohSettingsMode,
|
||||
EmailHitResult,
|
||||
GeckoEngineSettings,
|
||||
GeckoPrefValue,
|
||||
GeckoPref,
|
||||
GeckoSuggestion,
|
||||
GeckoSuggestionType,
|
||||
GeoHitResult,
|
||||
|
||||
@@ -39,6 +39,7 @@ class GeckoEventService extends GeckoStateEvents {
|
||||
final _findResultsSubject = PublishSubject<FindResultsEvent>();
|
||||
final _longPressSubject = PublishSubject<LongPressEvent>();
|
||||
final _scrollEventSubject = PublishSubject<ScrollEvent>();
|
||||
final _prefUpdateSubject = PublishSubject<GeckoPref>();
|
||||
|
||||
final _tabAddedSubject = PublishSubject<String>();
|
||||
|
||||
@@ -59,6 +60,7 @@ class GeckoEventService extends GeckoStateEvents {
|
||||
Stream<FindResultsEvent> get findResultsEvent => _findResultsSubject.stream;
|
||||
Stream<LongPressEvent> get longPressEvent => _longPressSubject.stream;
|
||||
Stream<ScrollEvent> get scrollEvent => _scrollEventSubject.stream;
|
||||
Stream<GeckoPref> get prefUpdateEvent => _prefUpdateSubject.stream;
|
||||
|
||||
Stream<String> get tabAddedStream => _tabAddedSubject.stream;
|
||||
|
||||
@@ -177,6 +179,11 @@ class GeckoEventService extends GeckoStateEvents {
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
void onPreferenceChange(int timestamp, GeckoPref value) {
|
||||
_prefUpdateSubject.addWhenMoreRecent(timestamp, value.name, value);
|
||||
}
|
||||
|
||||
GeckoEventService.setUp({
|
||||
BinaryMessenger? binaryMessenger,
|
||||
String messageChannelSuffix = '',
|
||||
@@ -189,6 +196,8 @@ class GeckoEventService extends GeckoStateEvents {
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
unawaited(_viewStateSubject.close());
|
||||
unawaited(_engineStateSubject.close());
|
||||
unawaited(_tabListSubject.close());
|
||||
unawaited(_selectedTabSubject.close());
|
||||
unawaited(_tabContentSubject.close());
|
||||
@@ -196,10 +205,12 @@ class GeckoEventService extends GeckoStateEvents {
|
||||
unawaited(_readerableSubject.close());
|
||||
unawaited(_securityInfoSubject.close());
|
||||
unawaited(_iconChangeSubject.close());
|
||||
unawaited(_iconUpdateSubject.close());
|
||||
unawaited(_thumbnailSubject.close());
|
||||
unawaited(_findResultsSubject.close());
|
||||
unawaited(_longPressSubject.close());
|
||||
unawaited(_scrollEventSubject.close());
|
||||
unawaited(_tabAddedSubject.close());
|
||||
unawaited(_prefUpdateSubject.close());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,19 +13,35 @@ class GeckoPrefService {
|
||||
return _apiInstance.getPrefList();
|
||||
}
|
||||
|
||||
Future<Map<String, GeckoPrefValue>> getAllPrefs() async {
|
||||
Future<Map<String, GeckoPref>> getAllPrefs() async {
|
||||
return _apiInstance.getPrefs(await getPrefList());
|
||||
}
|
||||
|
||||
Future<Map<String, GeckoPrefValue>> getPrefs(List<String> prefs) {
|
||||
Future<Map<String, GeckoPref>> getPrefs(List<String> prefs) {
|
||||
return _apiInstance.getPrefs(prefs);
|
||||
}
|
||||
|
||||
Future<Map<String, GeckoPrefValue>> applyPrefs(Map<String, Object> prefs) {
|
||||
Future<Map<String, GeckoPref>> applyPrefs(Map<String, Object> prefs) {
|
||||
return _apiInstance.applyPrefs(prefs);
|
||||
}
|
||||
|
||||
Future<void> resetPrefs(List<String> prefs) {
|
||||
return _apiInstance.resetPrefs(prefs);
|
||||
}
|
||||
|
||||
Future<void> startObserveChanges() {
|
||||
return _apiInstance.startObserveChanges();
|
||||
}
|
||||
|
||||
Future<void> stopObserveChanges() {
|
||||
return _apiInstance.stopObserveChanges();
|
||||
}
|
||||
|
||||
Future<void> registerPrefForObservation(String name) {
|
||||
return _apiInstance.registerPrefForObservation(name);
|
||||
}
|
||||
|
||||
Future<void> unregisterPrefForObservation(String name) {
|
||||
return _apiInstance.unregisterPrefForObservation(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2788,14 +2788,17 @@ class AddonCollection {
|
||||
;
|
||||
}
|
||||
|
||||
class GeckoPrefValue {
|
||||
GeckoPrefValue({
|
||||
class GeckoPref {
|
||||
GeckoPref({
|
||||
required this.name,
|
||||
this.value,
|
||||
this.defaultValue,
|
||||
this.userValue,
|
||||
required this.hasUserChangedValue,
|
||||
});
|
||||
|
||||
String name;
|
||||
|
||||
Object? value;
|
||||
|
||||
Object? defaultValue;
|
||||
@@ -2806,6 +2809,7 @@ class GeckoPrefValue {
|
||||
|
||||
List<Object?> _toList() {
|
||||
return <Object?>[
|
||||
name,
|
||||
value,
|
||||
defaultValue,
|
||||
userValue,
|
||||
@@ -2816,20 +2820,21 @@ class GeckoPrefValue {
|
||||
Object encode() {
|
||||
return _toList(); }
|
||||
|
||||
static GeckoPrefValue decode(Object result) {
|
||||
static GeckoPref decode(Object result) {
|
||||
result as List<Object?>;
|
||||
return GeckoPrefValue(
|
||||
value: result[0],
|
||||
defaultValue: result[1],
|
||||
userValue: result[2],
|
||||
hasUserChangedValue: result[3]! as bool,
|
||||
return GeckoPref(
|
||||
name: result[0]! as String,
|
||||
value: result[1],
|
||||
defaultValue: result[2],
|
||||
userValue: result[3],
|
||||
hasUserChangedValue: result[4]! as bool,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
||||
bool operator ==(Object other) {
|
||||
if (other is! GeckoPrefValue || other.runtimeType != runtimeType) {
|
||||
if (other is! GeckoPref || other.runtimeType != runtimeType) {
|
||||
return false;
|
||||
}
|
||||
if (identical(this, other)) {
|
||||
@@ -3038,7 +3043,7 @@ class _PigeonCodec extends StandardMessageCodec {
|
||||
} else if (value is AddonCollection) {
|
||||
buffer.putUint8(190);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is GeckoPrefValue) {
|
||||
} else if (value is GeckoPref) {
|
||||
buffer.putUint8(191);
|
||||
writeValue(buffer, value.encode());
|
||||
} else {
|
||||
@@ -3193,7 +3198,7 @@ class _PigeonCodec extends StandardMessageCodec {
|
||||
case 190:
|
||||
return AddonCollection.decode(readValue(buffer)!);
|
||||
case 191:
|
||||
return GeckoPrefValue.decode(readValue(buffer)!);
|
||||
return GeckoPref.decode(readValue(buffer)!);
|
||||
default:
|
||||
return super.readValueOfType(type, buffer);
|
||||
}
|
||||
@@ -4357,7 +4362,7 @@ class GeckoPrefApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, GeckoPrefValue>> getPrefs(List<String> preferenceFilter) async {
|
||||
Future<Map<String, GeckoPref>> getPrefs(List<String> preferenceFilter) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoPrefApi.getPrefs$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
@@ -4381,11 +4386,11 @@ class GeckoPrefApi {
|
||||
message: 'Host platform returned null value for non-null return value.',
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as Map<Object?, Object?>?)!.cast<String, GeckoPrefValue>();
|
||||
return (pigeonVar_replyList[0] as Map<Object?, Object?>?)!.cast<String, GeckoPref>();
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, GeckoPrefValue>> applyPrefs(Map<String, Object> prefs) async {
|
||||
Future<Map<String, GeckoPref>> applyPrefs(Map<String, Object> prefs) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoPrefApi.applyPrefs$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
@@ -4409,7 +4414,7 @@ class GeckoPrefApi {
|
||||
message: 'Host platform returned null value for non-null return value.',
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as Map<Object?, Object?>?)!.cast<String, GeckoPrefValue>();
|
||||
return (pigeonVar_replyList[0] as Map<Object?, Object?>?)!.cast<String, GeckoPref>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4435,6 +4440,98 @@ class GeckoPrefApi {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> startObserveChanges() async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoPrefApi.startObserveChanges$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> stopObserveChanges() async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoPrefApi.stopObserveChanges$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> registerPrefForObservation(String name) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoPrefApi.registerPrefForObservation$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[name]);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> unregisterPrefForObservation(String name) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoPrefApi.unregisterPrefForObservation$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[name]);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_sendFuture as List<Object?>?;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GeckoMlApi {
|
||||
@@ -4809,6 +4906,8 @@ abstract class GeckoStateEvents {
|
||||
|
||||
void onScrollChange(int timestamp, String tabId, int scrollY);
|
||||
|
||||
void onPreferenceChange(int timestamp, GeckoPref value);
|
||||
|
||||
static void setUp(GeckoStateEvents? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) {
|
||||
messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
||||
{
|
||||
@@ -5252,6 +5351,34 @@ abstract class GeckoStateEvents {
|
||||
});
|
||||
}
|
||||
}
|
||||
{
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.flutter_mozilla_components.GeckoStateEvents.onPreferenceChange$messageChannelSuffix', pigeonChannelCodec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
pigeonVar_channel.setMessageHandler(null);
|
||||
} else {
|
||||
pigeonVar_channel.setMessageHandler((Object? message) async {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.GeckoStateEvents.onPreferenceChange was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final int? arg_timestamp = (args[0] as int?);
|
||||
assert(arg_timestamp != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.GeckoStateEvents.onPreferenceChange was null, expected non-null int.');
|
||||
final GeckoPref? arg_value = (args[1] as GeckoPref?);
|
||||
assert(arg_value != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.GeckoStateEvents.onPreferenceChange was null, expected non-null GeckoPref.');
|
||||
try {
|
||||
api.onPreferenceChange(arg_timestamp!, arg_value!);
|
||||
return wrapResponse(empty: true);
|
||||
} on PlatformException catch (e) {
|
||||
return wrapResponse(error: e);
|
||||
} catch (e) {
|
||||
return wrapResponse(error: PlatformException(code: 'error', message: e.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user