Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[webview_flutter_wkwebview] Adds the dispose method to NSObjectFlutterApi #5970

Merged
merged 3 commits into from Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v3.1.4), do not edit directly.
// Autogenerated from Pigeon (v3.1.5), do not edit directly.
// See also: https://pub.dev/packages/pigeon
#import <Foundation/Foundation.h>
@protocol FlutterBinaryMessenger;
Expand Down Expand Up @@ -443,6 +443,8 @@ NSObject<FlutterMessageCodec> *FWFNSObjectFlutterApiGetCodec(void);
changeKeys:(NSArray<FWFNSKeyValueChangeKeyEnumData *> *)changeKeys
changeValues:(NSArray<id> *)changeValues
completion:(void (^)(NSError *_Nullable))completion;
- (void)disposeObjectWithIdentifier:(NSNumber *)identifier
completion:(void (^)(NSError *_Nullable))completion;
@end
/// The codec used by FWFWKWebViewHostApi.
NSObject<FlutterMessageCodec> *FWFWKWebViewHostApiGetCodec(void);
Expand Down
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v3.1.4), do not edit directly.
// Autogenerated from Pigeon (v3.1.5), do not edit directly.
// See also: https://pub.dev/packages/pigeon
#import "FWFGeneratedWebKitApis.h"
#import <Flutter/Flutter.h>
Expand Down Expand Up @@ -35,58 +35,72 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {

@interface FWFNSKeyValueObservingOptionsEnumData ()
+ (FWFNSKeyValueObservingOptionsEnumData *)fromMap:(NSDictionary *)dict;
+ (nullable FWFNSKeyValueObservingOptionsEnumData *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface FWFNSKeyValueChangeKeyEnumData ()
+ (FWFNSKeyValueChangeKeyEnumData *)fromMap:(NSDictionary *)dict;
+ (nullable FWFNSKeyValueChangeKeyEnumData *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface FWFWKUserScriptInjectionTimeEnumData ()
+ (FWFWKUserScriptInjectionTimeEnumData *)fromMap:(NSDictionary *)dict;
+ (nullable FWFWKUserScriptInjectionTimeEnumData *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface FWFWKAudiovisualMediaTypeEnumData ()
+ (FWFWKAudiovisualMediaTypeEnumData *)fromMap:(NSDictionary *)dict;
+ (nullable FWFWKAudiovisualMediaTypeEnumData *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface FWFWKWebsiteDataTypeEnumData ()
+ (FWFWKWebsiteDataTypeEnumData *)fromMap:(NSDictionary *)dict;
+ (nullable FWFWKWebsiteDataTypeEnumData *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface FWFWKNavigationActionPolicyEnumData ()
+ (FWFWKNavigationActionPolicyEnumData *)fromMap:(NSDictionary *)dict;
+ (nullable FWFWKNavigationActionPolicyEnumData *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface FWFNSHttpCookiePropertyKeyEnumData ()
+ (FWFNSHttpCookiePropertyKeyEnumData *)fromMap:(NSDictionary *)dict;
+ (nullable FWFNSHttpCookiePropertyKeyEnumData *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface FWFNSUrlRequestData ()
+ (FWFNSUrlRequestData *)fromMap:(NSDictionary *)dict;
+ (nullable FWFNSUrlRequestData *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface FWFWKUserScriptData ()
+ (FWFWKUserScriptData *)fromMap:(NSDictionary *)dict;
+ (nullable FWFWKUserScriptData *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface FWFWKNavigationActionData ()
+ (FWFWKNavigationActionData *)fromMap:(NSDictionary *)dict;
+ (nullable FWFWKNavigationActionData *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface FWFWKFrameInfoData ()
+ (FWFWKFrameInfoData *)fromMap:(NSDictionary *)dict;
+ (nullable FWFWKFrameInfoData *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface FWFNSErrorData ()
+ (FWFNSErrorData *)fromMap:(NSDictionary *)dict;
+ (nullable FWFNSErrorData *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface FWFWKScriptMessageData ()
+ (FWFWKScriptMessageData *)fromMap:(NSDictionary *)dict;
+ (nullable FWFWKScriptMessageData *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface FWFNSHttpCookieData ()
+ (FWFNSHttpCookieData *)fromMap:(NSDictionary *)dict;
+ (nullable FWFNSHttpCookieData *)nullableFromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end

Expand All @@ -103,6 +117,9 @@ + (FWFNSKeyValueObservingOptionsEnumData *)fromMap:(NSDictionary *)dict {
pigeonResult.value = [GetNullableObject(dict, @"value") integerValue];
return pigeonResult;
}
+ (nullable FWFNSKeyValueObservingOptionsEnumData *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FWFNSKeyValueObservingOptionsEnumData fromMap:dict] : nil;
}
- (NSDictionary *)toMap {
return @{
@"value" : @(self.value),
Expand All @@ -121,6 +138,9 @@ + (FWFNSKeyValueChangeKeyEnumData *)fromMap:(NSDictionary *)dict {
pigeonResult.value = [GetNullableObject(dict, @"value") integerValue];
return pigeonResult;
}
+ (nullable FWFNSKeyValueChangeKeyEnumData *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FWFNSKeyValueChangeKeyEnumData fromMap:dict] : nil;
}
- (NSDictionary *)toMap {
return @{
@"value" : @(self.value),
Expand All @@ -141,6 +161,9 @@ + (FWFWKUserScriptInjectionTimeEnumData *)fromMap:(NSDictionary *)dict {
pigeonResult.value = [GetNullableObject(dict, @"value") integerValue];
return pigeonResult;
}
+ (nullable FWFWKUserScriptInjectionTimeEnumData *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FWFWKUserScriptInjectionTimeEnumData fromMap:dict] : nil;
}
- (NSDictionary *)toMap {
return @{
@"value" : @(self.value),
Expand All @@ -161,6 +184,9 @@ + (FWFWKAudiovisualMediaTypeEnumData *)fromMap:(NSDictionary *)dict {
pigeonResult.value = [GetNullableObject(dict, @"value") integerValue];
return pigeonResult;
}
+ (nullable FWFWKAudiovisualMediaTypeEnumData *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FWFWKAudiovisualMediaTypeEnumData fromMap:dict] : nil;
}
- (NSDictionary *)toMap {
return @{
@"value" : @(self.value),
Expand All @@ -179,6 +205,9 @@ + (FWFWKWebsiteDataTypeEnumData *)fromMap:(NSDictionary *)dict {
pigeonResult.value = [GetNullableObject(dict, @"value") integerValue];
return pigeonResult;
}
+ (nullable FWFWKWebsiteDataTypeEnumData *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FWFWKWebsiteDataTypeEnumData fromMap:dict] : nil;
}
- (NSDictionary *)toMap {
return @{
@"value" : @(self.value),
Expand All @@ -199,6 +228,9 @@ + (FWFWKNavigationActionPolicyEnumData *)fromMap:(NSDictionary *)dict {
pigeonResult.value = [GetNullableObject(dict, @"value") integerValue];
return pigeonResult;
}
+ (nullable FWFWKNavigationActionPolicyEnumData *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FWFWKNavigationActionPolicyEnumData fromMap:dict] : nil;
}
- (NSDictionary *)toMap {
return @{
@"value" : @(self.value),
Expand All @@ -219,6 +251,9 @@ + (FWFNSHttpCookiePropertyKeyEnumData *)fromMap:(NSDictionary *)dict {
pigeonResult.value = [GetNullableObject(dict, @"value") integerValue];
return pigeonResult;
}
+ (nullable FWFNSHttpCookiePropertyKeyEnumData *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FWFNSHttpCookiePropertyKeyEnumData fromMap:dict] : nil;
}
- (NSDictionary *)toMap {
return @{
@"value" : @(self.value),
Expand Down Expand Up @@ -248,6 +283,9 @@ + (FWFNSUrlRequestData *)fromMap:(NSDictionary *)dict {
NSAssert(pigeonResult.allHttpHeaderFields != nil, @"");
return pigeonResult;
}
+ (nullable FWFNSUrlRequestData *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FWFNSUrlRequestData fromMap:dict] : nil;
}
- (NSDictionary *)toMap {
return @{
@"url" : (self.url ?: [NSNull null]),
Expand All @@ -272,12 +310,15 @@ + (FWFWKUserScriptData *)fromMap:(NSDictionary *)dict {
FWFWKUserScriptData *pigeonResult = [[FWFWKUserScriptData alloc] init];
pigeonResult.source = GetNullableObject(dict, @"source");
NSAssert(pigeonResult.source != nil, @"");
pigeonResult.injectionTime =
[FWFWKUserScriptInjectionTimeEnumData fromMap:GetNullableObject(dict, @"injectionTime")];
pigeonResult.injectionTime = [FWFWKUserScriptInjectionTimeEnumData
nullableFromMap:GetNullableObject(dict, @"injectionTime")];
pigeonResult.isMainFrameOnly = GetNullableObject(dict, @"isMainFrameOnly");
NSAssert(pigeonResult.isMainFrameOnly != nil, @"");
return pigeonResult;
}
+ (nullable FWFWKUserScriptData *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FWFWKUserScriptData fromMap:dict] : nil;
}
- (NSDictionary *)toMap {
return @{
@"source" : (self.source ?: [NSNull null]),
Expand All @@ -297,12 +338,16 @@ + (instancetype)makeWithRequest:(FWFNSUrlRequestData *)request
}
+ (FWFWKNavigationActionData *)fromMap:(NSDictionary *)dict {
FWFWKNavigationActionData *pigeonResult = [[FWFWKNavigationActionData alloc] init];
pigeonResult.request = [FWFNSUrlRequestData fromMap:GetNullableObject(dict, @"request")];
pigeonResult.request = [FWFNSUrlRequestData nullableFromMap:GetNullableObject(dict, @"request")];
NSAssert(pigeonResult.request != nil, @"");
pigeonResult.targetFrame = [FWFWKFrameInfoData fromMap:GetNullableObject(dict, @"targetFrame")];
pigeonResult.targetFrame =
[FWFWKFrameInfoData nullableFromMap:GetNullableObject(dict, @"targetFrame")];
NSAssert(pigeonResult.targetFrame != nil, @"");
return pigeonResult;
}
+ (nullable FWFWKNavigationActionData *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FWFWKNavigationActionData fromMap:dict] : nil;
}
- (NSDictionary *)toMap {
return @{
@"request" : (self.request ? [self.request toMap] : [NSNull null]),
Expand All @@ -323,6 +368,9 @@ + (FWFWKFrameInfoData *)fromMap:(NSDictionary *)dict {
NSAssert(pigeonResult.isMainFrame != nil, @"");
return pigeonResult;
}
+ (nullable FWFWKFrameInfoData *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FWFWKFrameInfoData fromMap:dict] : nil;
}
- (NSDictionary *)toMap {
return @{
@"isMainFrame" : (self.isMainFrame ?: [NSNull null]),
Expand Down Expand Up @@ -350,6 +398,9 @@ + (FWFNSErrorData *)fromMap:(NSDictionary *)dict {
NSAssert(pigeonResult.localizedDescription != nil, @"");
return pigeonResult;
}
+ (nullable FWFNSErrorData *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FWFNSErrorData fromMap:dict] : nil;
}
- (NSDictionary *)toMap {
return @{
@"code" : (self.code ?: [NSNull null]),
Expand All @@ -373,6 +424,9 @@ + (FWFWKScriptMessageData *)fromMap:(NSDictionary *)dict {
pigeonResult.body = GetNullableObject(dict, @"body");
return pigeonResult;
}
+ (nullable FWFWKScriptMessageData *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FWFWKScriptMessageData fromMap:dict] : nil;
}
- (NSDictionary *)toMap {
return @{
@"name" : (self.name ?: [NSNull null]),
Expand All @@ -397,6 +451,9 @@ + (FWFNSHttpCookieData *)fromMap:(NSDictionary *)dict {
NSAssert(pigeonResult.propertyValues != nil, @"");
return pigeonResult;
}
+ (nullable FWFNSHttpCookieData *)nullableFromMap:(NSDictionary *)dict {
return (dict) ? [FWFNSHttpCookieData fromMap:dict] : nil;
}
- (NSDictionary *)toMap {
return @{
@"propertyKeys" : (self.propertyKeys ?: [NSNull null]),
Expand Down Expand Up @@ -1875,6 +1932,17 @@ - (void)observeValueForObjectWithIdentifier:(NSNumber *)arg_identifier
completion(nil);
}];
}
- (void)disposeObjectWithIdentifier:(NSNumber *)arg_identifier
completion:(void (^)(NSError *_Nullable))completion {
FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
messageChannelWithName:@"dev.flutter.pigeon.NSObjectFlutterApi.dispose"
binaryMessenger:self.binaryMessenger
codec:FWFNSObjectFlutterApiGetCodec()];
[channel sendMessage:@[ arg_identifier ?: [NSNull null] ]
reply:^(id reply) {
completion(nil);
}];
}
@end
@interface FWFWKWebViewHostApiCodecReader : FlutterStandardReader
@end
Expand Down
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v3.1.4), do not edit directly.
// Autogenerated from Pigeon (v3.1.5), 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
// @dart = 2.12
Expand Down Expand Up @@ -1737,6 +1737,7 @@ abstract class NSObjectFlutterApi {
int objectIdentifier,
List<NSKeyValueChangeKeyEnumData?> changeKeys,
List<Object?> changeValues);
void dispose(int identifier);
static void setup(NSObjectFlutterApi? api,
{BinaryMessenger? binaryMessenger}) {
{
Expand Down Expand Up @@ -1773,6 +1774,25 @@ abstract class NSObjectFlutterApi {
});
}
}
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.NSObjectFlutterApi.dispose', codec,
binaryMessenger: binaryMessenger);
if (api == null) {
channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.NSObjectFlutterApi.dispose was null.');
final List<Object?> args = (message as List<Object?>?)!;
final int? arg_identifier = (args[0] as int?);
assert(arg_identifier != null,
'Argument for dev.flutter.pigeon.NSObjectFlutterApi.dispose was null, expected non-null int.');
api.dispose(arg_identifier!);
return;
});
}
}
}
}

Expand Down
Expand Up @@ -183,4 +183,9 @@ class NSObjectFlutterApiImpl extends NSObjectFlutterApi {
), changeValues),
);
}

@override
void dispose(int identifier) {
instanceManager.remove(identifier);
}
}
Expand Up @@ -501,6 +501,9 @@ abstract class NSObjectFlutterApi {
List<NSKeyValueChangeKeyEnumData?> changeKeys,
List<Object?> changeValues,
);

@ObjCSelector('disposeObjectWithIdentifier:')
void dispose(int identifier);
}

/// Mirror of WKWebView.
Expand Down
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v3.1.4), do not edit directly.
// Autogenerated from Pigeon (v3.1.5), 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
// ignore_for_file: avoid_relative_lib_imports
Expand Down
Expand Up @@ -90,7 +90,7 @@ void main() {
));
});

test('dispose', () async {
test('NSObjectHostApi.dispose', () async {
int? callbackIdentifier;
final InstanceManager instanceManager =
InstanceManager(onWeakReferenceRemoved: (int identifier) {
Expand Down Expand Up @@ -145,6 +145,20 @@ void main() {
]),
);
});

test('NSObjectFlutterApi.dispose', () {
FoundationFlutterApis.instance = FoundationFlutterApis(
instanceManager: instanceManager,
);

object = NSObject(instanceManager: instanceManager);
instanceManager.addHostCreatedInstance(object, 1);

instanceManager.removeWeakReference(object);
FoundationFlutterApis.instance.object.dispose(1);

expect(instanceManager.containsIdentifier(1), isFalse);
});
});
});
}
@@ -1,5 +1,5 @@
// Mocks generated by Mockito 5.2.0 from annotations
// in webview_flutter_wkwebview/test/src/foundation/foundation_test.dart.
// in webview_flutter_wkwebview/example/ios/.symlinks/plugins/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart.
// Do not manually edit this file.

import 'package:mockito/mockito.dart' as _i1;
Expand Down
@@ -1,5 +1,5 @@
// Mocks generated by Mockito 5.2.0 from annotations
// in webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart.
// in webview_flutter_wkwebview/example/ios/.symlinks/plugins/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart.
// Do not manually edit this file.

import 'dart:async' as _i4;
Expand Down
@@ -1,5 +1,5 @@
// Mocks generated by Mockito 5.2.0 from annotations
// in webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart.
// in webview_flutter_wkwebview/example/ios/.symlinks/plugins/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart.
// Do not manually edit this file.

import 'dart:async' as _i3;
Expand Down