From 7c363fd7216f399444b4c62123486e9b26b6858c Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 11 May 2022 12:54:45 -0700 Subject: [PATCH 01/40] dart side of implementation --- .../ios/Classes/FWFGeneratedWebKitApis.h | 270 +--- .../ios/Classes/FWFGeneratedWebKitApis.m | 1302 +++++++---------- .../lib/src/common/web_kit.pigeon.dart | 781 ++++------ .../lib/src/web_kit/web_kit.dart | 19 +- .../lib/src/web_kit/web_kit_api_impls.dart | 36 +- .../lib/src/web_kit_webview_widget.dart | 19 +- .../pigeons/web_kit.dart | 11 +- .../test/src/common/test_web_kit.pigeon.dart | 841 ++++------- .../test/src/web_kit/web_kit_test.dart | 15 +- .../test/src/web_kit/web_kit_test.mocks.dart | 12 +- .../test/src/web_kit_webview_widget_test.dart | 11 +- .../web_kit_webview_widget_test.mocks.dart | 17 +- 12 files changed, 1273 insertions(+), 2061 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h index 7d2bd44050ea..2edf781f451b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h @@ -126,166 +126,104 @@ typedef NS_ENUM(NSUInteger, FWFNSHttpCookiePropertyKeyEnum) { /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithUrl:(NSString *)url - httpMethod:(nullable NSString *)httpMethod - httpBody:(nullable FlutterStandardTypedData *)httpBody - allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields; -@property(nonatomic, copy) NSString *url; -@property(nonatomic, copy, nullable) NSString *httpMethod; -@property(nonatomic, strong, nullable) FlutterStandardTypedData *httpBody; -@property(nonatomic, strong) NSDictionary *allHttpHeaderFields; + httpMethod:(nullable NSString *)httpMethod + httpBody:(nullable FlutterStandardTypedData *)httpBody + allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields; +@property(nonatomic, copy) NSString * url; +@property(nonatomic, copy, nullable) NSString * httpMethod; +@property(nonatomic, strong, nullable) FlutterStandardTypedData * httpBody; +@property(nonatomic, strong) NSDictionary * allHttpHeaderFields; @end @interface FWFWKUserScriptData : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithSource:(NSString *)source - injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime - isMainFrameOnly:(NSNumber *)isMainFrameOnly; -@property(nonatomic, copy) NSString *source; -@property(nonatomic, strong, nullable) FWFWKUserScriptInjectionTimeEnumData *injectionTime; -@property(nonatomic, strong) NSNumber *isMainFrameOnly; + injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime + isMainFrameOnly:(NSNumber *)isMainFrameOnly; +@property(nonatomic, copy) NSString * source; +@property(nonatomic, strong, nullable) FWFWKUserScriptInjectionTimeEnumData * injectionTime; +@property(nonatomic, strong) NSNumber * isMainFrameOnly; @end @interface FWFNSHttpCookieData : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithPropertyKeys:(NSArray *)propertyKeys - propertyValues:(NSArray *)propertyValues; -@property(nonatomic, strong) NSArray *propertyKeys; -@property(nonatomic, strong) NSArray *propertyValues; + propertyValues:(NSArray *)propertyValues; +@property(nonatomic, strong) NSArray * propertyKeys; +@property(nonatomic, strong) NSArray * propertyValues; @end /// The codec used by FWFWKWebsiteDataStoreHostApi. NSObject *FWFWKWebsiteDataStoreHostApiGetCodec(void); @protocol FWFWKWebsiteDataStoreHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId - configurationIdentifier:(NSNumber *)configurationInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)createDefaultDataStoreWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeDataFromDataStoreWithIdentifier:(NSNumber *)instanceId - ofTypes:(NSArray *)dataTypes - modifiedSince:(NSNumber *)modificationTimeInSecondsSinceEpoch - completion:(void (^)(NSNumber *_Nullable, - FlutterError *_Nullable))completion; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createDefaultDataStoreWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeDataFromDataStoreWithIdentifier:(NSNumber *)instanceId ofTypes:(NSArray *)dataTypes modifiedSince:(NSNumber *)modificationTimeInSecondsSinceEpoch completion:(void(^)(NSNumber *_Nullable, FlutterError *_Nullable))completion; @end -extern void FWFWKWebsiteDataStoreHostApiSetup( - id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFUIViewHostApi. NSObject *FWFUIViewHostApiGetCodec(void); @protocol FWFUIViewHostApi -- (void)setBackgroundColorForViewWithIdentifier:(NSNumber *)instanceId - toValue:(nullable NSNumber *)value - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setOpaqueForViewWithIdentifier:(NSNumber *)instanceId - isOpaque:(NSNumber *)opaque - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setBackgroundColorForViewWithIdentifier:(NSNumber *)instanceId toValue:(nullable NSNumber *)value error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setOpaqueForViewWithIdentifier:(NSNumber *)instanceId isOpaque:(NSNumber *)opaque error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFUIViewHostApiSetup(id binaryMessenger, - NSObject *_Nullable api); +extern void FWFUIViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFUIScrollViewHostApi. NSObject *FWFUIScrollViewHostApiGetCodec(void); @protocol FWFUIScrollViewHostApi -- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId - webViewIdentifier:(NSNumber *)webViewInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId webViewIdentifier:(NSNumber *)webViewInstanceId error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSArray *) - contentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)scrollByForScrollViewWithIdentifier:(NSNumber *)instanceId - x:(NSNumber *)x - y:(NSNumber *)y - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setContentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId - toX:(NSNumber *)x - y:(NSNumber *)y - error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSArray *)contentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)scrollByForScrollViewWithIdentifier:(NSNumber *)instanceId x:(NSNumber *)x y:(NSNumber *)y error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setContentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId toX:(NSNumber *)x y:(NSNumber *)y error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFUIScrollViewHostApiSetup(id binaryMessenger, - NSObject *_Nullable api); +extern void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKWebViewConfigurationHostApi. NSObject *FWFWKWebViewConfigurationHostApiGetCodec(void); @protocol FWFWKWebViewConfigurationHostApi - (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId - webViewIdentifier:(NSNumber *)webViewInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:(NSNumber *)instanceId - isAllowed:(NSNumber *)allow - error: - (FlutterError *_Nullable *_Nonnull) - error; -- (void) - setMediaTypesRequiresUserActionForConfigurationWithIdentifier:(NSNumber *)instanceId - forTypes: - (NSArray< - FWFWKAudiovisualMediaTypeEnumData - *> *)types - error: - (FlutterError *_Nullable *_Nonnull) - error; +- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId webViewIdentifier:(NSNumber *)webViewInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:(NSNumber *)instanceId isAllowed:(NSNumber *)allow error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setMediaTypesRequiresUserActionForConfigurationWithIdentifier:(NSNumber *)instanceId forTypes:(NSArray *)types error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKWebViewConfigurationHostApiSetup( - id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKUserContentControllerHostApi. NSObject *FWFWKUserContentControllerHostApiGetCodec(void); @protocol FWFWKUserContentControllerHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId - configurationIdentifier:(NSNumber *)configurationInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)addScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId - handlerIdentifier:(NSNumber *)handlerInstanceid - ofName:(NSString *)name - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId - name:(NSString *)name - error:(FlutterError *_Nullable *_Nonnull) - error; -- (void)removeAllScriptMessageHandlersForControllerWithIdentifier:(NSNumber *)instanceId - error: - (FlutterError *_Nullable *_Nonnull) - error; -- (void)addUserScriptForControllerWithIdentifier:(NSNumber *)instanceId - userScript:(FWFWKUserScriptData *)userScript - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeAllUserScriptsForControllerWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)addScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId handlerIdentifier:(NSNumber *)handlerInstanceid ofName:(NSString *)name error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId name:(NSString *)name error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeAllScriptMessageHandlersForControllerWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)addUserScriptForControllerWithIdentifier:(NSNumber *)instanceId userScript:(FWFWKUserScriptData *)userScript error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeAllUserScriptsForControllerWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKUserContentControllerHostApiSetup( - id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKPreferencesHostApi. NSObject *FWFWKPreferencesHostApiGetCodec(void); @protocol FWFWKPreferencesHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId - configurationIdentifier:(NSNumber *)configurationInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setJavaScriptEnabledForPreferencesWithIdentifier:(NSNumber *)instanceId - isEnabled:(NSNumber *)enabled - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setJavaScriptEnabledForPreferencesWithIdentifier:(NSNumber *)instanceId isEnabled:(NSNumber *)enabled error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKPreferencesHostApiSetup(id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKPreferencesHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKScriptMessageHandlerHostApi. NSObject *FWFWKScriptMessageHandlerHostApiGetCodec(void); @@ -294,126 +232,70 @@ NSObject *FWFWKScriptMessageHandlerHostApiGetCodec(void); - (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKScriptMessageHandlerHostApiSetup( - id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKNavigationDelegateHostApi. NSObject *FWFWKNavigationDelegateHostApiGetCodec(void); @protocol FWFWKNavigationDelegateHostApi -- (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setDidFinishNavigationForDelegateWithIdentifier:(NSNumber *)instanceId - functionIdentifier:(nullable NSNumber *)functionInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createWithIdentifier:(NSNumber *)instanceId didFinishNavigationIdentifier:(nullable NSNumber *)didFinishNavigationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKNavigationDelegateHostApiSetup( - id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKNavigationDelegateFlutterApi. NSObject *FWFWKNavigationDelegateFlutterApiGetCodec(void); @interface FWFWKNavigationDelegateFlutterApi : NSObject - (instancetype)initWithBinaryMessenger:(id)binaryMessenger; -- (void)didFinishNavigationForDelegateWithIdentifier:(NSNumber *)functionInstanceId - webViewIdentifier:(NSNumber *)webViewInstanceId - URL:(nullable NSString *)url - completion:(void (^)(NSError *_Nullable))completion; +- (void)didFinishNavigationFunctionWithIdentifier:(NSNumber *)functionInstanceId webViewIdentifier:(NSNumber *)webViewInstanceId URL:(nullable NSString *)url completion:(void(^)(NSError *_Nullable))completion; @end /// The codec used by FWFNSObjectHostApi. NSObject *FWFNSObjectHostApiGetCodec(void); @protocol FWFNSObjectHostApi -- (void)disposeObjectWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)addObserverForObjectWithIdentifier:(NSNumber *)instanceId - observerIdentifier:(NSNumber *)observerInstanceId - keyPath:(NSString *)keyPath - options: - (NSArray *)options - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeObserverForObjectWithIdentifier:(NSNumber *)instanceId - observerIdentifier:(NSNumber *)observerInstanceId - keyPath:(NSString *)keyPath - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)disposeObjectWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)addObserverForObjectWithIdentifier:(NSNumber *)instanceId observerIdentifier:(NSNumber *)observerInstanceId keyPath:(NSString *)keyPath options:(NSArray *)options error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeObserverForObjectWithIdentifier:(NSNumber *)instanceId observerIdentifier:(NSNumber *)observerInstanceId keyPath:(NSString *)keyPath error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFNSObjectHostApiSetup(id binaryMessenger, - NSObject *_Nullable api); +extern void FWFNSObjectHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFFunctionFlutterApi. NSObject *FWFFunctionFlutterApiGetCodec(void); @interface FWFFunctionFlutterApi : NSObject - (instancetype)initWithBinaryMessenger:(id)binaryMessenger; -- (void)disposeFunctionWithIdentifier:(NSNumber *)instanceId - completion:(void (^)(NSError *_Nullable))completion; +- (void)disposeFunctionWithIdentifier:(NSNumber *)instanceId completion:(void(^)(NSError *_Nullable))completion; @end /// The codec used by FWFWKWebViewHostApi. NSObject *FWFWKWebViewHostApiGetCodec(void); @protocol FWFWKWebViewHostApi -- (void)createWithIdentifier:(NSNumber *)instanceId - configurationIdentifier:(NSNumber *)configurationInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setUIDelegateForWebViewWithIdentifier:(NSNumber *)instanceId - delegateIdentifier:(nullable NSNumber *)uiDelegateInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setNavigationDelegateForWebViewWithIdentifier:(NSNumber *)instanceId - delegateIdentifier: - (nullable NSNumber *)navigationDelegateInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (nullable NSString *)URLForWebViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setUIDelegateForWebViewWithIdentifier:(NSNumber *)instanceId delegateIdentifier:(nullable NSNumber *)uiDelegateInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setNavigationDelegateForWebViewWithIdentifier:(NSNumber *)instanceId delegateIdentifier:(nullable NSNumber *)navigationDelegateInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSString *)URLForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)estimatedProgressForWebViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull) - error; -- (void)loadRequestForWebViewWithIdentifier:(NSNumber *)instanceId - request:(FWFNSUrlRequestData *)request - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadHTMLForWebViewWithIdentifier:(NSNumber *)instanceId - HTMLString:(NSString *)string - baseURL:(nullable NSString *)baseUrl - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadFileForWebViewWithIdentifier:(NSNumber *)instanceId - fileURL:(NSString *)url - readAccessURL:(NSString *)readAccessUrl - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadAssetForWebViewWithIdentifier:(NSNumber *)instanceId - assetKey:(NSString *)key - error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSNumber *)estimatedProgressForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadRequestForWebViewWithIdentifier:(NSNumber *)instanceId request:(FWFNSUrlRequestData *)request error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadHTMLForWebViewWithIdentifier:(NSNumber *)instanceId HTMLString:(NSString *)string baseURL:(nullable NSString *)baseUrl error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadFileForWebViewWithIdentifier:(NSNumber *)instanceId fileURL:(NSString *)url readAccessURL:(NSString *)readAccessUrl error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadAssetForWebViewWithIdentifier:(NSNumber *)instanceId assetKey:(NSString *)key error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)canGoBackForWebViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSNumber *)canGoBackForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)canGoForwardForWebViewWithIdentifier:(NSNumber *)instanceId - error: - (FlutterError *_Nullable *_Nonnull)error; -- (void)goBackForWebViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)goForwardForWebViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)reloadWebViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (nullable NSString *)titleForWebViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setAllowsBackForwardForWebViewWithIdentifier:(NSNumber *)instanceId - isAllowed:(NSNumber *)allow - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setUserAgentForWebViewWithIdentifier:(NSNumber *)instanceId - userAgent:(nullable NSString *)userAgent - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)evaluateJavaScriptForWebViewWithIdentifier:(NSNumber *)instanceId - javaScriptString:(NSString *)javaScriptString - completion:(void (^)(id _Nullable, - FlutterError *_Nullable))completion; +- (nullable NSNumber *)canGoForwardForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)goBackForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)goForwardForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)reloadWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSString *)titleForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setAllowsBackForwardForWebViewWithIdentifier:(NSNumber *)instanceId isAllowed:(NSNumber *)allow error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setUserAgentForWebViewWithIdentifier:(NSNumber *)instanceId userAgent:(nullable NSString *)userAgent error:(FlutterError *_Nullable *_Nonnull)error; +- (void)evaluateJavaScriptForWebViewWithIdentifier:(NSNumber *)instanceId javaScriptString:(NSString *)javaScriptString completion:(void(^)(id _Nullable, FlutterError *_Nullable))completion; @end -extern void FWFWKWebViewHostApiSetup(id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKUIDelegateHostApi. NSObject *FWFWKUIDelegateHostApiGetCodec(void); @@ -422,22 +304,16 @@ NSObject *FWFWKUIDelegateHostApiGetCodec(void); - (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKUIDelegateHostApiSetup(id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKHttpCookieStoreHostApi. NSObject *FWFWKHttpCookieStoreHostApiGetCodec(void); @protocol FWFWKHttpCookieStoreHostApi -- (void)createFromWebsiteDataStoreWithIdentifier:(NSNumber *)instanceId - dataStoreIdentifier:(NSNumber *)websiteDataStoreInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setCookieForStoreWithIdentifier:(NSNumber *)instanceId - cookie:(FWFNSHttpCookieData *)cookie - completion:(void (^)(FlutterError *_Nullable))completion; +- (void)createFromWebsiteDataStoreWithIdentifier:(NSNumber *)instanceId dataStoreIdentifier:(NSNumber *)websiteDataStoreInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setCookieForStoreWithIdentifier:(NSNumber *)instanceId cookie:(FWFNSHttpCookieData *)cookie completion:(void(^)(FlutterError *_Nullable))completion; @end -extern void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, NSObject *_Nullable api); NS_ASSUME_NONNULL_END diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m index aaeccc5cc1b0..41908dbe0f6f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m @@ -14,25 +14,26 @@ NSDictionary *errorDict = (NSDictionary *)[NSNull null]; if (error) { errorDict = @{ - @"code" : (error.code ? error.code : [NSNull null]), - @"message" : (error.message ? error.message : [NSNull null]), - @"details" : (error.details ? error.details : [NSNull null]), - }; + @"code": (error.code ? error.code : [NSNull null]), + @"message": (error.message ? error.message : [NSNull null]), + @"details": (error.details ? error.details : [NSNull null]), + }; } return @{ - @"result" : (result ? result : [NSNull null]), - @"error" : errorDict, - }; + @"result": (result ? result : [NSNull null]), + @"error": errorDict, + }; } -static id GetNullableObject(NSDictionary *dict, id key) { +static id GetNullableObject(NSDictionary* dict, id key) { id result = dict[key]; return (result == [NSNull null]) ? nil : result; } -static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { +static id GetNullableObjectAtIndex(NSArray* array, NSInteger key) { id result = array[key]; return (result == [NSNull null]) ? nil : result; } + @interface FWFNSKeyValueObservingOptionsEnumData () + (FWFNSKeyValueObservingOptionsEnumData *)fromMap:(NSDictionary *)dict; - (NSDictionary *)toMap; @@ -68,14 +69,12 @@ - (NSDictionary *)toMap; @implementation FWFNSKeyValueObservingOptionsEnumData + (instancetype)makeWithValue:(FWFNSKeyValueObservingOptionsEnum)value { - FWFNSKeyValueObservingOptionsEnumData *pigeonResult = - [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; + FWFNSKeyValueObservingOptionsEnumData* pigeonResult = [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFNSKeyValueObservingOptionsEnumData *)fromMap:(NSDictionary *)dict { - FWFNSKeyValueObservingOptionsEnumData *pigeonResult = - [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; + FWFNSKeyValueObservingOptionsEnumData *pigeonResult = [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -86,14 +85,12 @@ - (NSDictionary *)toMap { @implementation FWFWKUserScriptInjectionTimeEnumData + (instancetype)makeWithValue:(FWFWKUserScriptInjectionTimeEnum)value { - FWFWKUserScriptInjectionTimeEnumData *pigeonResult = - [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; + FWFWKUserScriptInjectionTimeEnumData* pigeonResult = [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFWKUserScriptInjectionTimeEnumData *)fromMap:(NSDictionary *)dict { - FWFWKUserScriptInjectionTimeEnumData *pigeonResult = - [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; + FWFWKUserScriptInjectionTimeEnumData *pigeonResult = [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -104,14 +101,12 @@ - (NSDictionary *)toMap { @implementation FWFWKAudiovisualMediaTypeEnumData + (instancetype)makeWithValue:(FWFWKAudiovisualMediaTypeEnum)value { - FWFWKAudiovisualMediaTypeEnumData *pigeonResult = - [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; + FWFWKAudiovisualMediaTypeEnumData* pigeonResult = [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFWKAudiovisualMediaTypeEnumData *)fromMap:(NSDictionary *)dict { - FWFWKAudiovisualMediaTypeEnumData *pigeonResult = - [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; + FWFWKAudiovisualMediaTypeEnumData *pigeonResult = [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -122,7 +117,7 @@ - (NSDictionary *)toMap { @implementation FWFWKWebsiteDataTypeEnumData + (instancetype)makeWithValue:(FWFWKWebsiteDataTypeEnum)value { - FWFWKWebsiteDataTypeEnumData *pigeonResult = [[FWFWKWebsiteDataTypeEnumData alloc] init]; + FWFWKWebsiteDataTypeEnumData* pigeonResult = [[FWFWKWebsiteDataTypeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } @@ -138,14 +133,12 @@ - (NSDictionary *)toMap { @implementation FWFNSHttpCookiePropertyKeyEnumData + (instancetype)makeWithValue:(FWFNSHttpCookiePropertyKeyEnum)value { - FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = - [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; + FWFNSHttpCookiePropertyKeyEnumData* pigeonResult = [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFNSHttpCookiePropertyKeyEnumData *)fromMap:(NSDictionary *)dict { - FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = - [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; + FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -156,10 +149,10 @@ - (NSDictionary *)toMap { @implementation FWFNSUrlRequestData + (instancetype)makeWithUrl:(NSString *)url - httpMethod:(nullable NSString *)httpMethod - httpBody:(nullable FlutterStandardTypedData *)httpBody - allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields { - FWFNSUrlRequestData *pigeonResult = [[FWFNSUrlRequestData alloc] init]; + httpMethod:(nullable NSString *)httpMethod + httpBody:(nullable FlutterStandardTypedData *)httpBody + allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields { + FWFNSUrlRequestData* pigeonResult = [[FWFNSUrlRequestData alloc] init]; pigeonResult.url = url; pigeonResult.httpMethod = httpMethod; pigeonResult.httpBody = httpBody; @@ -177,22 +170,15 @@ + (FWFNSUrlRequestData *)fromMap:(NSDictionary *)dict { return pigeonResult; } - (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.url ? self.url : [NSNull null]), @"url", - (self.httpMethod ? self.httpMethod : [NSNull null]), - @"httpMethod", (self.httpBody ? self.httpBody : [NSNull null]), - @"httpBody", - (self.allHttpHeaderFields ? self.allHttpHeaderFields - : [NSNull null]), - @"allHttpHeaderFields", nil]; + return [NSDictionary dictionaryWithObjectsAndKeys:(self.url ? self.url : [NSNull null]), @"url", (self.httpMethod ? self.httpMethod : [NSNull null]), @"httpMethod", (self.httpBody ? self.httpBody : [NSNull null]), @"httpBody", (self.allHttpHeaderFields ? self.allHttpHeaderFields : [NSNull null]), @"allHttpHeaderFields", nil]; } @end @implementation FWFWKUserScriptData + (instancetype)makeWithSource:(NSString *)source - injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime - isMainFrameOnly:(NSNumber *)isMainFrameOnly { - FWFWKUserScriptData *pigeonResult = [[FWFWKUserScriptData alloc] init]; + injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime + isMainFrameOnly:(NSNumber *)isMainFrameOnly { + FWFWKUserScriptData* pigeonResult = [[FWFWKUserScriptData alloc] init]; pigeonResult.source = source; pigeonResult.injectionTime = injectionTime; pigeonResult.isMainFrameOnly = isMainFrameOnly; @@ -202,27 +188,20 @@ + (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 fromMap:GetNullableObject(dict, @"injectionTime")]; pigeonResult.isMainFrameOnly = GetNullableObject(dict, @"isMainFrameOnly"); NSAssert(pigeonResult.isMainFrameOnly != nil, @""); return pigeonResult; } - (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.source ? self.source : [NSNull null]), @"source", - (self.injectionTime ? [self.injectionTime toMap] - : [NSNull null]), - @"injectionTime", - (self.isMainFrameOnly ? self.isMainFrameOnly : [NSNull null]), - @"isMainFrameOnly", nil]; + return [NSDictionary dictionaryWithObjectsAndKeys:(self.source ? self.source : [NSNull null]), @"source", (self.injectionTime ? [self.injectionTime toMap] : [NSNull null]), @"injectionTime", (self.isMainFrameOnly ? self.isMainFrameOnly : [NSNull null]), @"isMainFrameOnly", nil]; } @end @implementation FWFNSHttpCookieData + (instancetype)makeWithPropertyKeys:(NSArray *)propertyKeys - propertyValues:(NSArray *)propertyValues { - FWFNSHttpCookieData *pigeonResult = [[FWFNSHttpCookieData alloc] init]; + propertyValues:(NSArray *)propertyValues { + FWFNSHttpCookieData* pigeonResult = [[FWFNSHttpCookieData alloc] init]; pigeonResult.propertyKeys = propertyKeys; pigeonResult.propertyValues = propertyValues; return pigeonResult; @@ -236,24 +215,22 @@ + (FWFNSHttpCookieData *)fromMap:(NSDictionary *)dict { return pigeonResult; } - (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.propertyKeys ? self.propertyKeys : [NSNull null]), - @"propertyKeys", - (self.propertyValues ? self.propertyValues : [NSNull null]), - @"propertyValues", nil]; + return [NSDictionary dictionaryWithObjectsAndKeys:(self.propertyKeys ? self.propertyKeys : [NSNull null]), @"propertyKeys", (self.propertyValues ? self.propertyValues : [NSNull null]), @"propertyValues", nil]; } @end @interface FWFWKWebsiteDataStoreHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebsiteDataStoreHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type { +- (nullable id)readValueOfType:(UInt8)type +{ switch (type) { - case 128: + case 128: return [FWFWKWebsiteDataTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; + } } @end @@ -261,11 +238,13 @@ - (nullable id)readValueOfType:(UInt8)type { @interface FWFWKWebsiteDataStoreHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebsiteDataStoreHostApiCodecWriter -- (void)writeValue:(id)value { +- (void)writeValue:(id)value +{ if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else { + } else +{ [super writeValue:value]; } } @@ -286,52 +265,43 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebsiteDataStoreHostApiCodecReaderWriter *readerWriter = - [[FWFWKWebsiteDataStoreHostApiCodecReaderWriter alloc] init]; + FWFWKWebsiteDataStoreHostApiCodecReaderWriter *readerWriter = [[FWFWKWebsiteDataStoreHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: - configurationIdentifier:error:)], - @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " - @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_instanceId - configurationIdentifier:arg_configurationInstanceId - error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createDefaultDataStoreWithIdentifier:error:)], - @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " - @"@selector(createDefaultDataStoreWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createDefaultDataStoreWithIdentifier:error:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(createDefaultDataStoreWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -339,36 +309,30 @@ void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenge [api createDefaultDataStoreWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector - (removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)], - @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " - @"@selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)", - api); + NSCAssert([api respondsToSelector:@selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSArray *arg_dataTypes = GetNullableObjectAtIndex(args, 1); NSNumber *arg_modificationTimeInSecondsSinceEpoch = GetNullableObjectAtIndex(args, 2); - [api removeDataFromDataStoreWithIdentifier:arg_instanceId - ofTypes:arg_dataTypes - modifiedSince:arg_modificationTimeInSecondsSinceEpoch - completion:^(NSNumber *_Nullable output, - FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; + [api removeDataFromDataStoreWithIdentifier:arg_instanceId ofTypes:arg_dataTypes modifiedSince:arg_modificationTimeInSecondsSinceEpoch completion:^(NSNumber *_Nullable output, FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -398,26 +362,22 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFUIViewHostApiCodecReaderWriter *readerWriter = - [[FWFUIViewHostApiCodecReaderWriter alloc] init]; + FWFUIViewHostApiCodecReaderWriter *readerWriter = [[FWFUIViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFUIViewHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFUIViewHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIViewHostApi.setBackgroundColor" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIViewHostApi.setBackgroundColor" binaryMessenger:binaryMessenger - codec:FWFUIViewHostApiGetCodec()]; + codec:FWFUIViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(setBackgroundColorForViewWithIdentifier: - toValue:error:)], - @"FWFUIViewHostApi api (%@) doesn't respond to " - @"@selector(setBackgroundColorForViewWithIdentifier:toValue:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setBackgroundColorForViewWithIdentifier:toValue:error:)], @"FWFUIViewHostApi api (%@) doesn't respond to @selector(setBackgroundColorForViewWithIdentifier:toValue:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -426,20 +386,19 @@ void FWFUIViewHostApiSetup(id binaryMessenger, [api setBackgroundColorForViewWithIdentifier:arg_instanceId toValue:arg_value error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIViewHostApi.setOpaque" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIViewHostApi.setOpaque" binaryMessenger:binaryMessenger - codec:FWFUIViewHostApiGetCodec()]; + codec:FWFUIViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)], - @"FWFUIViewHostApi api (%@) doesn't respond to " - @"@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)], @"FWFUIViewHostApi api (%@) doesn't respond to @selector(setOpaqueForViewWithIdentifier:isOpaque:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -448,7 +407,8 @@ void FWFUIViewHostApiSetup(id binaryMessenger, [api setOpaqueForViewWithIdentifier:arg_instanceId isOpaque:arg_opaque error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -478,72 +438,63 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFUIScrollViewHostApiCodecReaderWriter *readerWriter = - [[FWFUIScrollViewHostApiCodecReaderWriter alloc] init]; + FWFUIScrollViewHostApiCodecReaderWriter *readerWriter = [[FWFUIScrollViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFUIScrollViewHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec()]; + codec:FWFUIScrollViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier: - webViewIdentifier:error:)], - @"FWFUIScrollViewHostApi api (%@) doesn't respond to " - @"@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_webViewInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewWithIdentifier:arg_instanceId - webViewIdentifier:arg_webViewInstanceId - error:&error]; + [api createFromWebViewWithIdentifier:arg_instanceId webViewIdentifier:arg_webViewInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec()]; + codec:FWFUIScrollViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(contentOffsetForScrollViewWithIdentifier:error:)], - @"FWFUIScrollViewHostApi api (%@) doesn't respond to " - @"@selector(contentOffsetForScrollViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(contentOffsetForScrollViewWithIdentifier:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(contentOffsetForScrollViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FlutterError *error; - NSArray *output = [api contentOffsetForScrollViewWithIdentifier:arg_instanceId - error:&error]; + NSArray *output = [api contentOffsetForScrollViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.scrollBy" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.scrollBy" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec()]; + codec:FWFUIScrollViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(scrollByForScrollViewWithIdentifier:x:y:error:)], - @"FWFUIScrollViewHostApi api (%@) doesn't respond to " - @"@selector(scrollByForScrollViewWithIdentifier:x:y:error:)", - api); + NSCAssert([api respondsToSelector:@selector(scrollByForScrollViewWithIdentifier:x:y:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(scrollByForScrollViewWithIdentifier:x:y:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -553,34 +504,30 @@ void FWFUIScrollViewHostApiSetup(id binaryMessenger, [api scrollByForScrollViewWithIdentifier:arg_instanceId x:arg_x y:arg_y error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec()]; + codec:FWFUIScrollViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (setContentOffsetForScrollViewWithIdentifier:toX:y:error:)], - @"FWFUIScrollViewHostApi api (%@) doesn't respond to " - @"@selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_x = GetNullableObjectAtIndex(args, 1); NSNumber *arg_y = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api setContentOffsetForScrollViewWithIdentifier:arg_instanceId - toX:arg_x - y:arg_y - error:&error]; + [api setContentOffsetForScrollViewWithIdentifier:arg_instanceId toX:arg_x y:arg_y error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -588,13 +535,15 @@ void FWFUIScrollViewHostApiSetup(id binaryMessenger, @interface FWFWKWebViewConfigurationHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebViewConfigurationHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type { +- (nullable id)readValueOfType:(UInt8)type +{ switch (type) { - case 128: + case 128: return [FWFWKAudiovisualMediaTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; + } } @end @@ -602,11 +551,13 @@ - (nullable id)readValueOfType:(UInt8)type { @interface FWFWKWebViewConfigurationHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebViewConfigurationHostApiCodecWriter -- (void)writeValue:(id)value { +- (void)writeValue:(id)value +{ if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else { + } else +{ [super writeValue:value]; } } @@ -627,25 +578,22 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebViewConfigurationHostApiCodecReaderWriter *readerWriter = - [[FWFWKWebViewConfigurationHostApiCodecReaderWriter alloc] init]; + FWFWKWebViewConfigurationHostApiCodecReaderWriter *readerWriter = [[FWFWKWebViewConfigurationHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.create" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec()]; + codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], - @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " - @"@selector(createWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -653,87 +601,71 @@ void FWFWKWebViewConfigurationHostApiSetup(id binaryMess [api createWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec()]; + codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier: - webViewIdentifier:error:)], - @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " - @"@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_webViewInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewWithIdentifier:arg_instanceId - webViewIdentifier:arg_webViewInstanceId - error:&error]; + [api createFromWebViewWithIdentifier:arg_instanceId webViewIdentifier:arg_webViewInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec()]; + codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector - (setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)], - @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " - @"@selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_allow = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:arg_instanceId - isAllowed:arg_allow - error:&error]; + [api setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:arg_instanceId isAllowed:arg_allow error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi." - @"setMediaTypesRequiringUserActionForPlayback" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec()]; + codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (setMediaTypesRequiresUserActionForConfigurationWithIdentifier: - forTypes:error:)], - @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " - @"@selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:" - @"error:)", - api); + NSCAssert([api respondsToSelector:@selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSArray *arg_types = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setMediaTypesRequiresUserActionForConfigurationWithIdentifier:arg_instanceId - forTypes:arg_types - error:&error]; + [api setMediaTypesRequiresUserActionForConfigurationWithIdentifier:arg_instanceId forTypes:arg_types error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -741,16 +673,18 @@ void FWFWKWebViewConfigurationHostApiSetup(id binaryMess @interface FWFWKUserContentControllerHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKUserContentControllerHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type { +- (nullable id)readValueOfType:(UInt8)type +{ switch (type) { - case 128: + case 128: return [FWFWKUserScriptData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFWKUserScriptInjectionTimeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; + } } @end @@ -758,14 +692,17 @@ - (nullable id)readValueOfType:(UInt8)type { @interface FWFWKUserContentControllerHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKUserContentControllerHostApiCodecWriter -- (void)writeValue:(id)value { +- (void)writeValue:(id)value +{ if ([value isKindOfClass:[FWFWKUserScriptData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { + } else + if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else { + } else +{ [super writeValue:value]; } } @@ -786,109 +723,86 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKUserContentControllerHostApiCodecReaderWriter *readerWriter = - [[FWFWKUserContentControllerHostApiCodecReaderWriter alloc] init]; + FWFWKUserContentControllerHostApiCodecReaderWriter *readerWriter = [[FWFWKUserContentControllerHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec()]; + codec:FWFWKUserContentControllerHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: - configurationIdentifier:error:)], - @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " - @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_instanceId - configurationIdentifier:arg_configurationInstanceId - error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec()]; + codec:FWFWKUserContentControllerHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (addScriptMessageHandlerForControllerWithIdentifier: - handlerIdentifier:ofName:error:)], - @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " - @"@selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:" - @"ofName:error:)", - api); + NSCAssert([api respondsToSelector:@selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:ofName:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:ofName:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_handlerInstanceid = GetNullableObjectAtIndex(args, 1); NSString *arg_name = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api addScriptMessageHandlerForControllerWithIdentifier:arg_instanceId - handlerIdentifier:arg_handlerInstanceid - ofName:arg_name - error:&error]; + [api addScriptMessageHandlerForControllerWithIdentifier:arg_instanceId handlerIdentifier:arg_handlerInstanceid ofName:arg_name error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec()]; + codec:FWFWKUserContentControllerHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (removeScriptMessageHandlerForControllerWithIdentifier:name:error:)], - @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " - @"@selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)", - api); + NSCAssert([api respondsToSelector:@selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_name = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api removeScriptMessageHandlerForControllerWithIdentifier:arg_instanceId - name:arg_name - error:&error]; + [api removeScriptMessageHandlerForControllerWithIdentifier:arg_instanceId name:arg_name error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec()]; + codec:FWFWKUserContentControllerHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (removeAllScriptMessageHandlersForControllerWithIdentifier:error:)], - @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " - @"@selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -896,46 +810,40 @@ void FWFWKUserContentControllerHostApiSetup(id binaryMes [api removeAllScriptMessageHandlersForControllerWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec()]; + codec:FWFWKUserContentControllerHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(addUserScriptForControllerWithIdentifier: - userScript:error:)], - @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " - @"@selector(addUserScriptForControllerWithIdentifier:userScript:error:)", - api); + NSCAssert([api respondsToSelector:@selector(addUserScriptForControllerWithIdentifier:userScript:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(addUserScriptForControllerWithIdentifier:userScript:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FWFWKUserScriptData *arg_userScript = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api addUserScriptForControllerWithIdentifier:arg_instanceId - userScript:arg_userScript - error:&error]; + [api addUserScriptForControllerWithIdentifier:arg_instanceId userScript:arg_userScript error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec()]; + codec:FWFWKUserContentControllerHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (removeAllUserScriptsForControllerWithIdentifier:error:)], - @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " - @"@selector(removeAllUserScriptsForControllerWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(removeAllUserScriptsForControllerWithIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeAllUserScriptsForControllerWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -943,7 +851,8 @@ void FWFWKUserContentControllerHostApiSetup(id binaryMes [api removeAllUserScriptsForControllerWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -973,63 +882,53 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKPreferencesHostApiCodecReaderWriter *readerWriter = - [[FWFWKPreferencesHostApiCodecReaderWriter alloc] init]; + FWFWKPreferencesHostApiCodecReaderWriter *readerWriter = [[FWFWKPreferencesHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKPreferencesHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKPreferencesHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKPreferencesHostApiGetCodec()]; + codec:FWFWKPreferencesHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: - configurationIdentifier:error:)], - @"FWFWKPreferencesHostApi api (%@) doesn't respond to " - @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKPreferencesHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_instanceId - configurationIdentifier:arg_configurationInstanceId - error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled" binaryMessenger:binaryMessenger - codec:FWFWKPreferencesHostApiGetCodec()]; + codec:FWFWKPreferencesHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)], - @"FWFWKPreferencesHostApi api (%@) doesn't respond to " - @"@selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)], @"FWFWKPreferencesHostApi api (%@) doesn't respond to @selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_enabled = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setJavaScriptEnabledForPreferencesWithIdentifier:arg_instanceId - isEnabled:arg_enabled - error:&error]; + [api setJavaScriptEnabledForPreferencesWithIdentifier:arg_instanceId isEnabled:arg_enabled error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -1059,25 +958,22 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKScriptMessageHandlerHostApiCodecReaderWriter *readerWriter = - [[FWFWKScriptMessageHandlerHostApiCodecReaderWriter alloc] init]; + FWFWKScriptMessageHandlerHostApiCodecReaderWriter *readerWriter = [[FWFWKScriptMessageHandlerHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKScriptMessageHandlerHostApiGetCodec()]; + codec:FWFWKScriptMessageHandlerHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], - @"FWFWKScriptMessageHandlerHostApi api (%@) doesn't respond to " - @"@selector(createWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKScriptMessageHandlerHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1085,7 +981,8 @@ void FWFWKScriptMessageHandlerHostApiSetup(id binaryMess [api createWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -1115,59 +1012,32 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKNavigationDelegateHostApiCodecReaderWriter *readerWriter = - [[FWFWKNavigationDelegateHostApiCodecReaderWriter alloc] init]; + FWFWKNavigationDelegateHostApiCodecReaderWriter *readerWriter = [[FWFWKNavigationDelegateHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKNavigationDelegateHostApi.create" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKNavigationDelegateHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKNavigationDelegateHostApiGetCodec()]; + codec:FWFWKNavigationDelegateHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], - @"FWFWKNavigationDelegateHostApi api (%@) doesn't respond to " - @"@selector(createWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:didFinishNavigationIdentifier:error:)], @"FWFWKNavigationDelegateHostApi api (%@) doesn't respond to @selector(createWithIdentifier:didFinishNavigationIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); + NSNumber *arg_didFinishNavigationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createWithIdentifier:arg_instanceId error:&error]; + [api createWithIdentifier:arg_instanceId didFinishNavigationIdentifier:arg_didFinishNavigationInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { - [channel setMessageHandler:nil]; } - } - { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKNavigationDelegateHostApi.setDidFinishNavigation" - binaryMessenger:binaryMessenger - codec:FWFWKNavigationDelegateHostApiGetCodec()]; - if (api) { - NSCAssert( - [api respondsToSelector:@selector - (setDidFinishNavigationForDelegateWithIdentifier:functionIdentifier:error:)], - @"FWFWKNavigationDelegateHostApi api (%@) doesn't respond to " - @"@selector(setDidFinishNavigationForDelegateWithIdentifier:functionIdentifier:error:)", - api); - [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; - NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); - NSNumber *arg_functionInstanceId = GetNullableObjectAtIndex(args, 1); - FlutterError *error; - [api setDidFinishNavigationForDelegateWithIdentifier:arg_instanceId - functionIdentifier:arg_functionInstanceId - error:&error]; - callback(wrapResult(nil, error)); - }]; - } else { + else { [channel setMessageHandler:nil]; } } @@ -1197,15 +1067,15 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKNavigationDelegateFlutterApiCodecReaderWriter *readerWriter = - [[FWFWKNavigationDelegateFlutterApiCodecReaderWriter alloc] init]; + FWFWKNavigationDelegateFlutterApiCodecReaderWriter *readerWriter = [[FWFWKNavigationDelegateFlutterApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } + @interface FWFWKNavigationDelegateFlutterApi () -@property(nonatomic, strong) NSObject *binaryMessenger; +@property (nonatomic, strong) NSObject *binaryMessenger; @end @implementation FWFWKNavigationDelegateFlutterApi @@ -1217,35 +1087,29 @@ - (instancetype)initWithBinaryMessenger:(NSObject *)bina } return self; } -- (void)didFinishNavigationForDelegateWithIdentifier:(NSNumber *)arg_functionInstanceId - webViewIdentifier:(NSNumber *)arg_webViewInstanceId - URL:(nullable NSString *)arg_url - completion:(void (^)(NSError *_Nullable))completion { - FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName: - @"dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation" - binaryMessenger:self.binaryMessenger - codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; - [channel sendMessage:@[ - (arg_functionInstanceId == nil) ? [NSNull null] : arg_functionInstanceId, - (arg_webViewInstanceId == nil) ? [NSNull null] : arg_webViewInstanceId, - (arg_url == nil) ? [NSNull null] : arg_url - ] - reply:^(id reply) { - completion(nil); - }]; +- (void)didFinishNavigationFunctionWithIdentifier:(NSNumber *)arg_functionInstanceId webViewIdentifier:(NSNumber *)arg_webViewInstanceId URL:(nullable NSString *)arg_url completion:(void(^)(NSError *_Nullable))completion { + FlutterBasicMessageChannel *channel = + [FlutterBasicMessageChannel + messageChannelWithName:@"dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation" + binaryMessenger:self.binaryMessenger + codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; + [channel sendMessage:@[(arg_functionInstanceId == nil) ? [NSNull null] : arg_functionInstanceId, (arg_webViewInstanceId == nil) ? [NSNull null] : arg_webViewInstanceId, (arg_url == nil) ? [NSNull null] : arg_url] reply:^(id reply) { + completion(nil); + }]; } @end @interface FWFNSObjectHostApiCodecReader : FlutterStandardReader @end @implementation FWFNSObjectHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type { +- (nullable id)readValueOfType:(UInt8)type +{ switch (type) { - case 128: + case 128: return [FWFNSKeyValueObservingOptionsEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; + } } @end @@ -1253,11 +1117,13 @@ - (nullable id)readValueOfType:(UInt8)type { @interface FWFNSObjectHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFNSObjectHostApiCodecWriter -- (void)writeValue:(id)value { +- (void)writeValue:(id)value +{ if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else { + } else +{ [super writeValue:value]; } } @@ -1278,25 +1144,22 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFNSObjectHostApiCodecReaderWriter *readerWriter = - [[FWFNSObjectHostApiCodecReaderWriter alloc] init]; + FWFNSObjectHostApiCodecReaderWriter *readerWriter = [[FWFNSObjectHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFNSObjectHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFNSObjectHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.dispose" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.dispose" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec()]; + codec:FWFNSObjectHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(disposeObjectWithIdentifier:error:)], - @"FWFNSObjectHostApi api (%@) doesn't respond to " - @"@selector(disposeObjectWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(disposeObjectWithIdentifier:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(disposeObjectWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1304,67 +1167,53 @@ void FWFNSObjectHostApiSetup(id binaryMessenger, [api disposeObjectWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.addObserver" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.addObserver" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec()]; + codec:FWFNSObjectHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (addObserverForObjectWithIdentifier: - observerIdentifier:keyPath:options:error:)], - @"FWFNSObjectHostApi api (%@) doesn't respond to " - @"@selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:" - @"error:)", - api); + NSCAssert([api respondsToSelector:@selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_observerInstanceId = GetNullableObjectAtIndex(args, 1); NSString *arg_keyPath = GetNullableObjectAtIndex(args, 2); - NSArray *arg_options = - GetNullableObjectAtIndex(args, 3); + NSArray *arg_options = GetNullableObjectAtIndex(args, 3); FlutterError *error; - [api addObserverForObjectWithIdentifier:arg_instanceId - observerIdentifier:arg_observerInstanceId - keyPath:arg_keyPath - options:arg_options - error:&error]; + [api addObserverForObjectWithIdentifier:arg_instanceId observerIdentifier:arg_observerInstanceId keyPath:arg_keyPath options:arg_options error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.removeObserver" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.removeObserver" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec()]; + codec:FWFNSObjectHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(removeObserverForObjectWithIdentifier: - observerIdentifier:keyPath:error:)], - @"FWFNSObjectHostApi api (%@) doesn't respond to " - @"@selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)", - api); + NSCAssert([api respondsToSelector:@selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_observerInstanceId = GetNullableObjectAtIndex(args, 1); NSString *arg_keyPath = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api removeObserverForObjectWithIdentifier:arg_instanceId - observerIdentifier:arg_observerInstanceId - keyPath:arg_keyPath - error:&error]; + [api removeObserverForObjectWithIdentifier:arg_instanceId observerIdentifier:arg_observerInstanceId keyPath:arg_keyPath error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -1394,15 +1243,15 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFFunctionFlutterApiCodecReaderWriter *readerWriter = - [[FWFFunctionFlutterApiCodecReaderWriter alloc] init]; + FWFFunctionFlutterApiCodecReaderWriter *readerWriter = [[FWFFunctionFlutterApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } + @interface FWFFunctionFlutterApi () -@property(nonatomic, strong) NSObject *binaryMessenger; +@property (nonatomic, strong) NSObject *binaryMessenger; @end @implementation FWFFunctionFlutterApi @@ -1414,49 +1263,50 @@ - (instancetype)initWithBinaryMessenger:(NSObject *)bina } return self; } -- (void)disposeFunctionWithIdentifier:(NSNumber *)arg_instanceId - completion:(void (^)(NSError *_Nullable))completion { - FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel +- (void)disposeFunctionWithIdentifier:(NSNumber *)arg_instanceId completion:(void(^)(NSError *_Nullable))completion { + FlutterBasicMessageChannel *channel = + [FlutterBasicMessageChannel messageChannelWithName:@"dev.flutter.pigeon.FunctionFlutterApi.dispose" - binaryMessenger:self.binaryMessenger - codec:FWFFunctionFlutterApiGetCodec()]; - [channel sendMessage:@[ (arg_instanceId == nil) ? [NSNull null] : arg_instanceId ] - reply:^(id reply) { - completion(nil); - }]; + binaryMessenger:self.binaryMessenger + codec:FWFFunctionFlutterApiGetCodec()]; + [channel sendMessage:@[(arg_instanceId == nil) ? [NSNull null] : arg_instanceId] reply:^(id reply) { + completion(nil); + }]; } @end @interface FWFWKWebViewHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebViewHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type { +- (nullable id)readValueOfType:(UInt8)type +{ switch (type) { - case 128: + case 128: return [FWFNSHttpCookieData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFNSHttpCookiePropertyKeyEnumData fromMap:[self readValue]]; - - case 130: + + case 130: return [FWFNSKeyValueObservingOptionsEnumData fromMap:[self readValue]]; - - case 131: + + case 131: return [FWFNSUrlRequestData fromMap:[self readValue]]; - - case 132: + + case 132: return [FWFWKAudiovisualMediaTypeEnumData fromMap:[self readValue]]; - - case 133: + + case 133: return [FWFWKUserScriptData fromMap:[self readValue]]; - - case 134: + + case 134: return [FWFWKUserScriptInjectionTimeEnumData fromMap:[self readValue]]; - - case 135: + + case 135: return [FWFWKWebsiteDataTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; + } } @end @@ -1464,32 +1314,41 @@ - (nullable id)readValueOfType:(UInt8)type { @interface FWFWKWebViewHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebViewHostApiCodecWriter -- (void)writeValue:(id)value { +- (void)writeValue:(id)value +{ if ([value isKindOfClass:[FWFNSHttpCookieData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { + } else + if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { + } else + if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { [self writeByte:130]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFNSUrlRequestData class]]) { + } else + if ([value isKindOfClass:[FWFNSUrlRequestData class]]) { [self writeByte:131]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { + } else + if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { [self writeByte:132]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFWKUserScriptData class]]) { + } else + if ([value isKindOfClass:[FWFWKUserScriptData class]]) { [self writeByte:133]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { + } else + if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { [self writeByte:134]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { + } else + if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { [self writeByte:135]; [self writeValue:[value toMap]]; - } else { + } else +{ [super writeValue:value]; } } @@ -1510,101 +1369,85 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebViewHostApiCodecReaderWriter *readerWriter = - [[FWFWKWebViewHostApiCodecReaderWriter alloc] init]; + FWFWKWebViewHostApiCodecReaderWriter *readerWriter = [[FWFWKWebViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKWebViewHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.create" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier: - configurationIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(createWithIdentifier:configurationIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:configurationIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(createWithIdentifier:configurationIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createWithIdentifier:arg_instanceId - configurationIdentifier:arg_configurationInstanceId - error:&error]; + [api createWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(setUIDelegateForWebViewWithIdentifier: - delegateIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_uiDelegateInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setUIDelegateForWebViewWithIdentifier:arg_instanceId - delegateIdentifier:arg_uiDelegateInstanceId - error:&error]; + [api setUIDelegateForWebViewWithIdentifier:arg_instanceId delegateIdentifier:arg_uiDelegateInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(setNavigationDelegateForWebViewWithIdentifier: - delegateIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_navigationDelegateInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setNavigationDelegateForWebViewWithIdentifier:arg_instanceId - delegateIdentifier:arg_navigationDelegateInstanceId - error:&error]; + [api setNavigationDelegateForWebViewWithIdentifier:arg_instanceId delegateIdentifier:arg_navigationDelegateInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getUrl" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getUrl" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(URLForWebViewWithIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(URLForWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(URLForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(URLForWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1612,44 +1455,39 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSString *output = [api URLForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(estimatedProgressForWebViewWithIdentifier: - error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(estimatedProgressForWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(estimatedProgressForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(estimatedProgressForWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FlutterError *error; - NSNumber *output = [api estimatedProgressForWebViewWithIdentifier:arg_instanceId - error:&error]; + NSNumber *output = [api estimatedProgressForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadRequest" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadRequest" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadRequestForWebViewWithIdentifier: - request:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(loadRequestForWebViewWithIdentifier:request:error:)", - api); + NSCAssert([api respondsToSelector:@selector(loadRequestForWebViewWithIdentifier:request:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadRequestForWebViewWithIdentifier:request:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1658,75 +1496,63 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, [api loadRequestForWebViewWithIdentifier:arg_instanceId request:arg_request error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadHTMLForWebViewWithIdentifier: - HTMLString:baseURL:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)", - api); + NSCAssert([api respondsToSelector:@selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_string = GetNullableObjectAtIndex(args, 1); NSString *arg_baseUrl = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api loadHTMLForWebViewWithIdentifier:arg_instanceId - HTMLString:arg_string - baseURL:arg_baseUrl - error:&error]; + [api loadHTMLForWebViewWithIdentifier:arg_instanceId HTMLString:arg_string baseURL:arg_baseUrl error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)", - api); + NSCAssert([api respondsToSelector:@selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_url = GetNullableObjectAtIndex(args, 1); NSString *arg_readAccessUrl = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api loadFileForWebViewWithIdentifier:arg_instanceId - fileURL:arg_url - readAccessURL:arg_readAccessUrl - error:&error]; + [api loadFileForWebViewWithIdentifier:arg_instanceId fileURL:arg_url readAccessURL:arg_readAccessUrl error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadAssetForWebViewWithIdentifier: - assetKey:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(loadAssetForWebViewWithIdentifier:assetKey:error:)", - api); + NSCAssert([api respondsToSelector:@selector(loadAssetForWebViewWithIdentifier:assetKey:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadAssetForWebViewWithIdentifier:assetKey:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1735,20 +1561,19 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, [api loadAssetForWebViewWithIdentifier:arg_instanceId assetKey:arg_key error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoBack" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoBack" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(canGoBackForWebViewWithIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(canGoBackForWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(canGoBackForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(canGoBackForWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1756,20 +1581,19 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSNumber *output = [api canGoBackForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoForward" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoForward" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(canGoForwardForWebViewWithIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(canGoForwardForWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(canGoForwardForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(canGoForwardForWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1777,20 +1601,19 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSNumber *output = [api canGoForwardForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goBack" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goBack" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(goBackForWebViewWithIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(goBackForWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(goBackForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(goBackForWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1798,20 +1621,19 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, [api goBackForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goForward" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goForward" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(goForwardForWebViewWithIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(goForwardForWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(goForwardForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(goForwardForWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1819,20 +1641,19 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, [api goForwardForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.reload" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.reload" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(reloadWebViewWithIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(reloadWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(reloadWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(reloadWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1840,20 +1661,19 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, [api reloadWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getTitle" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getTitle" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(titleForWebViewWithIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(titleForWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(titleForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(titleForWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1861,85 +1681,71 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSString *output = [api titleForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_allow = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setAllowsBackForwardForWebViewWithIdentifier:arg_instanceId - isAllowed:arg_allow - error:&error]; + [api setAllowsBackForwardForWebViewWithIdentifier:arg_instanceId isAllowed:arg_allow error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(setUserAgentForWebViewWithIdentifier: - userAgent:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_userAgent = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setUserAgentForWebViewWithIdentifier:arg_instanceId - userAgent:arg_userAgent - error:&error]; + [api setUserAgentForWebViewWithIdentifier:arg_instanceId userAgent:arg_userAgent error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector - (evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)", - api); + NSCAssert([api respondsToSelector:@selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_javaScriptString = GetNullableObjectAtIndex(args, 1); - [api evaluateJavaScriptForWebViewWithIdentifier:arg_instanceId - javaScriptString:arg_javaScriptString - completion:^(id _Nullable output, - FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; + [api evaluateJavaScriptForWebViewWithIdentifier:arg_instanceId javaScriptString:arg_javaScriptString completion:^(id _Nullable output, FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -1969,25 +1775,22 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKUIDelegateHostApiCodecReaderWriter *readerWriter = - [[FWFWKUIDelegateHostApiCodecReaderWriter alloc] init]; + FWFWKUIDelegateHostApiCodecReaderWriter *readerWriter = [[FWFWKUIDelegateHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKUIDelegateHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUIDelegateHostApi.create" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUIDelegateHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKUIDelegateHostApiGetCodec()]; + codec:FWFWKUIDelegateHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], - @"FWFWKUIDelegateHostApi api (%@) doesn't respond to " - @"@selector(createWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKUIDelegateHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1995,7 +1798,8 @@ void FWFWKUIDelegateHostApiSetup(id binaryMessenger, [api createWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -2003,16 +1807,18 @@ void FWFWKUIDelegateHostApiSetup(id binaryMessenger, @interface FWFWKHttpCookieStoreHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKHttpCookieStoreHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type { +- (nullable id)readValueOfType:(UInt8)type +{ switch (type) { - case 128: + case 128: return [FWFNSHttpCookieData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFNSHttpCookiePropertyKeyEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; + } } @end @@ -2020,14 +1826,17 @@ - (nullable id)readValueOfType:(UInt8)type { @interface FWFWKHttpCookieStoreHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKHttpCookieStoreHostApiCodecWriter -- (void)writeValue:(id)value { +- (void)writeValue:(id)value +{ if ([value isKindOfClass:[FWFNSHttpCookieData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { + } else + if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else { + } else +{ [super writeValue:value]; } } @@ -2048,62 +1857,53 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKHttpCookieStoreHostApiCodecReaderWriter *readerWriter = - [[FWFWKHttpCookieStoreHostApiCodecReaderWriter alloc] init]; + FWFWKHttpCookieStoreHostApiCodecReaderWriter *readerWriter = [[FWFWKHttpCookieStoreHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore" binaryMessenger:binaryMessenger - codec:FWFWKHttpCookieStoreHostApiGetCodec()]; + codec:FWFWKHttpCookieStoreHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebsiteDataStoreWithIdentifier: - dataStoreIdentifier:error:)], - @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to " - @"@selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)], @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to @selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_websiteDataStoreInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebsiteDataStoreWithIdentifier:arg_instanceId - dataStoreIdentifier:arg_websiteDataStoreInstanceId - error:&error]; + [api createFromWebsiteDataStoreWithIdentifier:arg_instanceId dataStoreIdentifier:arg_websiteDataStoreInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie" binaryMessenger:binaryMessenger - codec:FWFWKHttpCookieStoreHostApiGetCodec()]; + codec:FWFWKHttpCookieStoreHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(setCookieForStoreWithIdentifier: - cookie:completion:)], - @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to " - @"@selector(setCookieForStoreWithIdentifier:cookie:completion:)", - api); + NSCAssert([api respondsToSelector:@selector(setCookieForStoreWithIdentifier:cookie:completion:)], @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to @selector(setCookieForStoreWithIdentifier:cookie:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FWFNSHttpCookieData *arg_cookie = GetNullableObjectAtIndex(args, 1); - [api setCookieForStoreWithIdentifier:arg_instanceId - cookie:arg_cookie - completion:^(FlutterError *_Nullable error) { - callback(wrapResult(nil, error)); - }]; + [api setCookieForStoreWithIdentifier:arg_instanceId cookie:arg_cookie completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; }]; - } else { + } + else { [channel setMessageHandler:nil]; } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart index f84ba68bfbc1..a6e881e29d0b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart @@ -94,7 +94,8 @@ class NSKeyValueObservingOptionsEnumData { static NSKeyValueObservingOptionsEnumData decode(Object message) { final Map pigeonMap = message as Map; return NSKeyValueObservingOptionsEnumData( - value: NSKeyValueObservingOptionsEnum.values[pigeonMap['value']! as int], + value: NSKeyValueObservingOptionsEnum.values[pigeonMap['value']! as int] +, ); } } @@ -115,7 +116,8 @@ class WKUserScriptInjectionTimeEnumData { static WKUserScriptInjectionTimeEnumData decode(Object message) { final Map pigeonMap = message as Map; return WKUserScriptInjectionTimeEnumData( - value: WKUserScriptInjectionTimeEnum.values[pigeonMap['value']! as int], + value: WKUserScriptInjectionTimeEnum.values[pigeonMap['value']! as int] +, ); } } @@ -136,7 +138,8 @@ class WKAudiovisualMediaTypeEnumData { static WKAudiovisualMediaTypeEnumData decode(Object message) { final Map pigeonMap = message as Map; return WKAudiovisualMediaTypeEnumData( - value: WKAudiovisualMediaTypeEnum.values[pigeonMap['value']! as int], + value: WKAudiovisualMediaTypeEnum.values[pigeonMap['value']! as int] +, ); } } @@ -157,7 +160,8 @@ class WKWebsiteDataTypeEnumData { static WKWebsiteDataTypeEnumData decode(Object message) { final Map pigeonMap = message as Map; return WKWebsiteDataTypeEnumData( - value: WKWebsiteDataTypeEnum.values[pigeonMap['value']! as int], + value: WKWebsiteDataTypeEnum.values[pigeonMap['value']! as int] +, ); } } @@ -178,7 +182,8 @@ class NSHttpCookiePropertyKeyEnumData { static NSHttpCookiePropertyKeyEnumData decode(Object message) { final Map pigeonMap = message as Map; return NSHttpCookiePropertyKeyEnumData( - value: NSHttpCookiePropertyKeyEnum.values[pigeonMap['value']! as int], + value: NSHttpCookiePropertyKeyEnum.values[pigeonMap['value']! as int] +, ); } } @@ -211,9 +216,7 @@ class NSUrlRequestData { url: pigeonMap['url']! as String, httpMethod: pigeonMap['httpMethod'] as String?, httpBody: pigeonMap['httpBody'] as Uint8List?, - allHttpHeaderFields: - (pigeonMap['allHttpHeaderFields'] as Map?)! - .cast(), + allHttpHeaderFields: (pigeonMap['allHttpHeaderFields'] as Map?)!.cast(), ); } } @@ -242,8 +245,7 @@ class WKUserScriptData { return WKUserScriptData( source: pigeonMap['source']! as String, injectionTime: pigeonMap['injectionTime'] != null - ? WKUserScriptInjectionTimeEnumData.decode( - pigeonMap['injectionTime']!) + ? WKUserScriptInjectionTimeEnumData.decode(pigeonMap['injectionTime']!) : null, isMainFrameOnly: pigeonMap['isMainFrameOnly']! as bool, ); @@ -269,10 +271,8 @@ class NSHttpCookieData { static NSHttpCookieData decode(Object message) { final Map pigeonMap = message as Map; return NSHttpCookieData( - propertyKeys: (pigeonMap['propertyKeys'] as List?)! - .cast(), - propertyValues: - (pigeonMap['propertyValues'] as List?)!.cast(), + propertyKeys: (pigeonMap['propertyKeys'] as List?)!.cast(), + propertyValues: (pigeonMap['propertyValues'] as List?)!.cast(), ); } } @@ -284,19 +284,20 @@ class _WKWebsiteDataStoreHostApiCodec extends StandardMessageCodec { if (value is WKWebsiteDataTypeEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else { + } else +{ super.writeValue(buffer, value); } } - @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKWebsiteDataTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); + } } } @@ -305,30 +306,24 @@ class WKWebsiteDataStoreHostApi { /// Constructor for [WKWebsiteDataStoreHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKWebsiteDataStoreHostApi({BinaryMessenger? binaryMessenger}) - : _binaryMessenger = binaryMessenger; + WKWebsiteDataStoreHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _WKWebsiteDataStoreHostApiCodec(); - Future createFromWebViewConfiguration( - int arg_instanceId, int arg_configurationInstanceId) async { + Future createFromWebViewConfiguration(int arg_instanceId, int arg_configurationInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration', - codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_configurationInstanceId]) - as Map?; + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_configurationInstanceId]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -341,9 +336,7 @@ class WKWebsiteDataStoreHostApi { Future createDefaultDataStore(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore', - codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -352,8 +345,7 @@ class WKWebsiteDataStoreHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -364,26 +356,18 @@ class WKWebsiteDataStoreHostApi { } } - Future removeDataOfTypes( - int arg_instanceId, - List arg_dataTypes, - double arg_modificationTimeInSecondsSinceEpoch) async { + Future removeDataOfTypes(int arg_instanceId, List arg_dataTypes, double arg_modificationTimeInSecondsSinceEpoch) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes', codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel.send([ - arg_instanceId, - arg_dataTypes, - arg_modificationTimeInSecondsSinceEpoch - ]) as Map?; + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_dataTypes, arg_modificationTimeInSecondsSinceEpoch]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -408,8 +392,7 @@ class UIViewHostApi { /// Constructor for [UIViewHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - UIViewHostApi({BinaryMessenger? binaryMessenger}) - : _binaryMessenger = binaryMessenger; + UIViewHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; @@ -417,18 +400,16 @@ class UIViewHostApi { Future setBackgroundColor(int arg_instanceId, int? arg_value) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIViewHostApi.setBackgroundColor', codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_value]) as Map?; + 'dev.flutter.pigeon.UIViewHostApi.setBackgroundColor', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_value]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -441,18 +422,16 @@ class UIViewHostApi { Future setOpaque(int arg_instanceId, bool arg_opaque) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIViewHostApi.setOpaque', codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_opaque]) as Map?; + 'dev.flutter.pigeon.UIViewHostApi.setOpaque', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_opaque]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -472,29 +451,24 @@ class UIScrollViewHostApi { /// Constructor for [UIScrollViewHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - UIScrollViewHostApi({BinaryMessenger? binaryMessenger}) - : _binaryMessenger = binaryMessenger; + UIScrollViewHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _UIScrollViewHostApiCodec(); - Future createFromWebView( - int arg_instanceId, int arg_webViewInstanceId) async { + Future createFromWebView(int arg_instanceId, int arg_webViewInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_webViewInstanceId]) - as Map?; + await channel.send([arg_instanceId, arg_webViewInstanceId]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -507,8 +481,7 @@ class UIScrollViewHostApi { Future> getContentOffset(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -517,8 +490,7 @@ class UIScrollViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -536,19 +508,16 @@ class UIScrollViewHostApi { Future scrollBy(int arg_instanceId, double arg_x, double arg_y) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.scrollBy', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.scrollBy', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_x, arg_y]) - as Map?; + await channel.send([arg_instanceId, arg_x, arg_y]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -559,22 +528,18 @@ class UIScrollViewHostApi { } } - Future setContentOffset( - int arg_instanceId, double arg_x, double arg_y) async { + Future setContentOffset(int arg_instanceId, double arg_x, double arg_y) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_x, arg_y]) - as Map?; + await channel.send([arg_instanceId, arg_x, arg_y]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -593,19 +558,20 @@ class _WKWebViewConfigurationHostApiCodec extends StandardMessageCodec { if (value is WKAudiovisualMediaTypeEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else { + } else +{ super.writeValue(buffer, value); } } - @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); + } } } @@ -614,18 +580,15 @@ class WKWebViewConfigurationHostApi { /// Constructor for [WKWebViewConfigurationHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKWebViewConfigurationHostApi({BinaryMessenger? binaryMessenger}) - : _binaryMessenger = binaryMessenger; + WKWebViewConfigurationHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; - static const MessageCodec codec = - _WKWebViewConfigurationHostApiCodec(); + static const MessageCodec codec = _WKWebViewConfigurationHostApiCodec(); Future create(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.create', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.create', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -634,8 +597,7 @@ class WKWebViewConfigurationHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -646,23 +608,18 @@ class WKWebViewConfigurationHostApi { } } - Future createFromWebView( - int arg_instanceId, int arg_webViewInstanceId) async { + Future createFromWebView(int arg_instanceId, int arg_webViewInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView', - codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_webViewInstanceId]) - as Map?; + await channel.send([arg_instanceId, arg_webViewInstanceId]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -673,22 +630,18 @@ class WKWebViewConfigurationHostApi { } } - Future setAllowsInlineMediaPlayback( - int arg_instanceId, bool arg_allow) async { + Future setAllowsInlineMediaPlayback(int arg_instanceId, bool arg_allow) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback', - codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_allow]) as Map?; + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_allow]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -699,22 +652,18 @@ class WKWebViewConfigurationHostApi { } } - Future setMediaTypesRequiringUserActionForPlayback(int arg_instanceId, - List arg_types) async { + Future setMediaTypesRequiringUserActionForPlayback(int arg_instanceId, List arg_types) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback', - codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_types]) as Map?; + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_types]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -733,25 +682,27 @@ class _WKUserContentControllerHostApiCodec extends StandardMessageCodec { if (value is WKUserScriptData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else if (value is WKUserScriptInjectionTimeEnumData) { + } else + if (value is WKUserScriptInjectionTimeEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else { + } else +{ super.writeValue(buffer, value); } } - @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKUserScriptData.decode(readValue(buffer)!); - - case 129: + + case 129: return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); + } } } @@ -760,31 +711,24 @@ class WKUserContentControllerHostApi { /// Constructor for [WKUserContentControllerHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKUserContentControllerHostApi({BinaryMessenger? binaryMessenger}) - : _binaryMessenger = binaryMessenger; + WKUserContentControllerHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; - static const MessageCodec codec = - _WKUserContentControllerHostApiCodec(); + static const MessageCodec codec = _WKUserContentControllerHostApiCodec(); - Future createFromWebViewConfiguration( - int arg_instanceId, int arg_configurationInstanceId) async { + Future createFromWebViewConfiguration(int arg_instanceId, int arg_configurationInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration', - codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_configurationInstanceId]) - as Map?; + 'dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_configurationInstanceId]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -795,23 +739,18 @@ class WKUserContentControllerHostApi { } } - Future addScriptMessageHandler( - int arg_instanceId, int arg_handlerInstanceid, String arg_name) async { + Future addScriptMessageHandler(int arg_instanceId, int arg_handlerInstanceid, String arg_name) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler', - codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_handlerInstanceid, arg_name]) - as Map?; + 'dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_handlerInstanceid, arg_name]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -822,22 +761,18 @@ class WKUserContentControllerHostApi { } } - Future removeScriptMessageHandler( - int arg_instanceId, String arg_name) async { + Future removeScriptMessageHandler(int arg_instanceId, String arg_name) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler', - codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_name]) as Map?; + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_name]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -850,9 +785,7 @@ class WKUserContentControllerHostApi { Future removeAllScriptMessageHandlers(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers', - codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -861,8 +794,7 @@ class WKUserContentControllerHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -873,23 +805,18 @@ class WKUserContentControllerHostApi { } } - Future addUserScript( - int arg_instanceId, WKUserScriptData arg_userScript) async { + Future addUserScript(int arg_instanceId, WKUserScriptData arg_userScript) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript', - codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_userScript]) - as Map?; + await channel.send([arg_instanceId, arg_userScript]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -902,9 +829,7 @@ class WKUserContentControllerHostApi { Future removeAllUserScripts(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts', - codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -913,8 +838,7 @@ class WKUserContentControllerHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -934,30 +858,24 @@ class WKPreferencesHostApi { /// Constructor for [WKPreferencesHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKPreferencesHostApi({BinaryMessenger? binaryMessenger}) - : _binaryMessenger = binaryMessenger; + WKPreferencesHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _WKPreferencesHostApiCodec(); - Future createFromWebViewConfiguration( - int arg_instanceId, int arg_configurationInstanceId) async { + Future createFromWebViewConfiguration(int arg_instanceId, int arg_configurationInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration', - codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_configurationInstanceId]) - as Map?; + 'dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_configurationInstanceId]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -968,21 +886,18 @@ class WKPreferencesHostApi { } } - Future setJavaScriptEnabled( - int arg_instanceId, bool arg_enabled) async { + Future setJavaScriptEnabled(int arg_instanceId, bool arg_enabled) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled', codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_enabled]) as Map?; + 'dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_enabled]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1002,18 +917,15 @@ class WKScriptMessageHandlerHostApi { /// Constructor for [WKScriptMessageHandlerHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKScriptMessageHandlerHostApi({BinaryMessenger? binaryMessenger}) - : _binaryMessenger = binaryMessenger; + WKScriptMessageHandlerHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; - static const MessageCodec codec = - _WKScriptMessageHandlerHostApiCodec(); + static const MessageCodec codec = _WKScriptMessageHandlerHostApiCodec(); Future create(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1022,8 +934,7 @@ class WKScriptMessageHandlerHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1043,55 +954,24 @@ class WKNavigationDelegateHostApi { /// Constructor for [WKNavigationDelegateHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKNavigationDelegateHostApi({BinaryMessenger? binaryMessenger}) - : _binaryMessenger = binaryMessenger; + WKNavigationDelegateHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; - static const MessageCodec codec = - _WKNavigationDelegateHostApiCodec(); - - Future create(int arg_instanceId) async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKNavigationDelegateHostApi.create', codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId]) as Map?; - if (replyMap == null) { - throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - ); - } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; - throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], - ); - } else { - return; - } - } + static const MessageCodec codec = _WKNavigationDelegateHostApiCodec(); - Future setDidFinishNavigation( - int arg_instanceId, int? arg_functionInstanceId) async { + Future create(int arg_instanceId, int? arg_didFinishNavigationInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKNavigationDelegateHostApi.setDidFinishNavigation', - codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKNavigationDelegateHostApi.create', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_functionInstanceId]) - as Map?; + await channel.send([arg_instanceId, arg_didFinishNavigationInstanceId]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1106,36 +986,26 @@ class WKNavigationDelegateHostApi { class _WKNavigationDelegateFlutterApiCodec extends StandardMessageCodec { const _WKNavigationDelegateFlutterApiCodec(); } - abstract class WKNavigationDelegateFlutterApi { - static const MessageCodec codec = - _WKNavigationDelegateFlutterApiCodec(); + static const MessageCodec codec = _WKNavigationDelegateFlutterApiCodec(); - void didFinishNavigation( - int functionInstanceId, int webViewInstanceId, String? url); - static void setup(WKNavigationDelegateFlutterApi? api, - {BinaryMessenger? binaryMessenger}) { + void didFinishNavigation(int functionInstanceId, int webViewInstanceId, String? url); + static void setup(WKNavigationDelegateFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMessageHandler(null); } else { channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null.'); final List args = (message as List?)!; final int? arg_functionInstanceId = (args[0] as int?); - assert(arg_functionInstanceId != null, - 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null, expected non-null int.'); + assert(arg_functionInstanceId != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null, expected non-null int.'); final int? arg_webViewInstanceId = (args[1] as int?); - assert(arg_webViewInstanceId != null, - 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null, expected non-null int.'); + assert(arg_webViewInstanceId != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null, expected non-null int.'); final String? arg_url = (args[2] as String?); - api.didFinishNavigation( - arg_functionInstanceId!, arg_webViewInstanceId!, arg_url); + api.didFinishNavigation(arg_functionInstanceId!, arg_webViewInstanceId!, arg_url); return; }); } @@ -1150,19 +1020,20 @@ class _NSObjectHostApiCodec extends StandardMessageCodec { if (value is NSKeyValueObservingOptionsEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else { + } else +{ super.writeValue(buffer, value); } } - @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); + } } } @@ -1171,8 +1042,7 @@ class NSObjectHostApi { /// Constructor for [NSObjectHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - NSObjectHostApi({BinaryMessenger? binaryMessenger}) - : _binaryMessenger = binaryMessenger; + NSObjectHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; @@ -1180,8 +1050,7 @@ class NSObjectHostApi { Future dispose(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.dispose', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.NSObjectHostApi.dispose', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1190,8 +1059,7 @@ class NSObjectHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1202,28 +1070,18 @@ class NSObjectHostApi { } } - Future addObserver( - int arg_instanceId, - int arg_observerInstanceId, - String arg_keyPath, - List arg_options) async { + Future addObserver(int arg_instanceId, int arg_observerInstanceId, String arg_keyPath, List arg_options) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.addObserver', codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel.send([ - arg_instanceId, - arg_observerInstanceId, - arg_keyPath, - arg_options - ]) as Map?; + 'dev.flutter.pigeon.NSObjectHostApi.addObserver', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_observerInstanceId, arg_keyPath, arg_options]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1234,22 +1092,18 @@ class NSObjectHostApi { } } - Future removeObserver(int arg_instanceId, int arg_observerInstanceId, - String arg_keyPath) async { + Future removeObserver(int arg_instanceId, int arg_observerInstanceId, String arg_keyPath) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.removeObserver', codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel.send( - [arg_instanceId, arg_observerInstanceId, arg_keyPath]) - as Map?; + 'dev.flutter.pigeon.NSObjectHostApi.removeObserver', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_observerInstanceId, arg_keyPath]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1264,27 +1118,22 @@ class NSObjectHostApi { class _FunctionFlutterApiCodec extends StandardMessageCodec { const _FunctionFlutterApiCodec(); } - abstract class FunctionFlutterApi { static const MessageCodec codec = _FunctionFlutterApiCodec(); void dispose(int instanceId); - static void setup(FunctionFlutterApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(FunctionFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.FunctionFlutterApi.dispose', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.FunctionFlutterApi.dispose', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMessageHandler(null); } else { channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.FunctionFlutterApi.dispose was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.FunctionFlutterApi.dispose was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.FunctionFlutterApi.dispose was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.FunctionFlutterApi.dispose was null, expected non-null int.'); api.dispose(arg_instanceId!); return; }); @@ -1300,61 +1149,69 @@ class _WKWebViewHostApiCodec extends StandardMessageCodec { if (value is NSHttpCookieData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else if (value is NSHttpCookiePropertyKeyEnumData) { + } else + if (value is NSHttpCookiePropertyKeyEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else if (value is NSKeyValueObservingOptionsEnumData) { + } else + if (value is NSKeyValueObservingOptionsEnumData) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else if (value is NSUrlRequestData) { + } else + if (value is NSUrlRequestData) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else if (value is WKAudiovisualMediaTypeEnumData) { + } else + if (value is WKAudiovisualMediaTypeEnumData) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else if (value is WKUserScriptData) { + } else + if (value is WKUserScriptData) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is WKUserScriptInjectionTimeEnumData) { + } else + if (value is WKUserScriptInjectionTimeEnumData) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is WKWebsiteDataTypeEnumData) { + } else + if (value is WKWebsiteDataTypeEnumData) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else { + } else +{ super.writeValue(buffer, value); } } - @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSHttpCookieData.decode(readValue(buffer)!); - - case 129: + + case 129: return NSHttpCookiePropertyKeyEnumData.decode(readValue(buffer)!); - - case 130: + + case 130: return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); - - case 131: + + case 131: return NSUrlRequestData.decode(readValue(buffer)!); - - case 132: + + case 132: return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); - - case 133: + + case 133: return WKUserScriptData.decode(readValue(buffer)!); - - case 134: + + case 134: return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); - - case 135: + + case 135: return WKWebsiteDataTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); + } } } @@ -1363,29 +1220,24 @@ class WKWebViewHostApi { /// Constructor for [WKWebViewHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKWebViewHostApi({BinaryMessenger? binaryMessenger}) - : _binaryMessenger = binaryMessenger; + WKWebViewHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _WKWebViewHostApiCodec(); - Future create( - int arg_instanceId, int arg_configurationInstanceId) async { + Future create(int arg_instanceId, int arg_configurationInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.create', codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_configurationInstanceId]) - as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.create', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_configurationInstanceId]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1396,22 +1248,18 @@ class WKWebViewHostApi { } } - Future setUIDelegate( - int arg_instanceId, int? arg_uiDelegateInstanceId) async { + Future setUIDelegate(int arg_instanceId, int? arg_uiDelegateInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_uiDelegateInstanceId]) - as Map?; + await channel.send([arg_instanceId, arg_uiDelegateInstanceId]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1422,22 +1270,18 @@ class WKWebViewHostApi { } } - Future setNavigationDelegate( - int arg_instanceId, int? arg_navigationDelegateInstanceId) async { + Future setNavigationDelegate(int arg_instanceId, int? arg_navigationDelegateInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate', codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_navigationDelegateInstanceId]) - as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_navigationDelegateInstanceId]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1450,8 +1294,7 @@ class WKWebViewHostApi { Future getUrl(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getUrl', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getUrl', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1460,8 +1303,7 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1474,8 +1316,7 @@ class WKWebViewHostApi { Future getEstimatedProgress(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1484,8 +1325,7 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1501,21 +1341,18 @@ class WKWebViewHostApi { } } - Future loadRequest( - int arg_instanceId, NSUrlRequestData arg_request) async { + Future loadRequest(int arg_instanceId, NSUrlRequestData arg_request) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadRequest', codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_request]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.loadRequest', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_request]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1526,22 +1363,18 @@ class WKWebViewHostApi { } } - Future loadHtmlString( - int arg_instanceId, String arg_string, String? arg_baseUrl) async { + Future loadHtmlString(int arg_instanceId, String arg_string, String? arg_baseUrl) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_string, arg_baseUrl]) - as Map?; + await channel.send([arg_instanceId, arg_string, arg_baseUrl]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1552,22 +1385,18 @@ class WKWebViewHostApi { } } - Future loadFileUrl( - int arg_instanceId, String arg_url, String arg_readAccessUrl) async { + Future loadFileUrl(int arg_instanceId, String arg_url, String arg_readAccessUrl) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl', codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_url, arg_readAccessUrl]) - as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_url, arg_readAccessUrl]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1580,18 +1409,16 @@ class WKWebViewHostApi { Future loadFlutterAsset(int arg_instanceId, String arg_key) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset', codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_key]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_key]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1604,8 +1431,7 @@ class WKWebViewHostApi { Future canGoBack(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.canGoBack', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.canGoBack', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1614,8 +1440,7 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1633,8 +1458,7 @@ class WKWebViewHostApi { Future canGoForward(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.canGoForward', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.canGoForward', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1643,8 +1467,7 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1662,8 +1485,7 @@ class WKWebViewHostApi { Future goBack(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.goBack', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.goBack', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1672,8 +1494,7 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1686,8 +1507,7 @@ class WKWebViewHostApi { Future goForward(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.goForward', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.goForward', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1696,8 +1516,7 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1710,8 +1529,7 @@ class WKWebViewHostApi { Future reload(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.reload', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.reload', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1720,8 +1538,7 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1734,8 +1551,7 @@ class WKWebViewHostApi { Future getTitle(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getTitle', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getTitle', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1744,8 +1560,7 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1756,22 +1571,18 @@ class WKWebViewHostApi { } } - Future setAllowsBackForwardNavigationGestures( - int arg_instanceId, bool arg_allow) async { + Future setAllowsBackForwardNavigationGestures(int arg_instanceId, bool arg_allow) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures', - codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_allow]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_allow]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1782,22 +1593,18 @@ class WKWebViewHostApi { } } - Future setCustomUserAgent( - int arg_instanceId, String? arg_userAgent) async { + Future setCustomUserAgent(int arg_instanceId, String? arg_userAgent) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_userAgent]) - as Map?; + await channel.send([arg_instanceId, arg_userAgent]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1808,22 +1615,18 @@ class WKWebViewHostApi { } } - Future evaluateJavaScript( - int arg_instanceId, String arg_javaScriptString) async { + Future evaluateJavaScript(int arg_instanceId, String arg_javaScriptString) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_javaScriptString]) - as Map?; + await channel.send([arg_instanceId, arg_javaScriptString]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1843,8 +1646,7 @@ class WKUIDelegateHostApi { /// Constructor for [WKUIDelegateHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKUIDelegateHostApi({BinaryMessenger? binaryMessenger}) - : _binaryMessenger = binaryMessenger; + WKUIDelegateHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; @@ -1852,8 +1654,7 @@ class WKUIDelegateHostApi { Future create(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUIDelegateHostApi.create', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKUIDelegateHostApi.create', codec, binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1862,8 +1663,7 @@ class WKUIDelegateHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1882,25 +1682,27 @@ class _WKHttpCookieStoreHostApiCodec extends StandardMessageCodec { if (value is NSHttpCookieData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else if (value is NSHttpCookiePropertyKeyEnumData) { + } else + if (value is NSHttpCookiePropertyKeyEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else { + } else +{ super.writeValue(buffer, value); } } - @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSHttpCookieData.decode(readValue(buffer)!); - - case 129: + + case 129: return NSHttpCookiePropertyKeyEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); + } } } @@ -1909,30 +1711,24 @@ class WKHttpCookieStoreHostApi { /// Constructor for [WKHttpCookieStoreHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKHttpCookieStoreHostApi({BinaryMessenger? binaryMessenger}) - : _binaryMessenger = binaryMessenger; + WKHttpCookieStoreHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _WKHttpCookieStoreHostApiCodec(); - Future createFromWebsiteDataStore( - int arg_instanceId, int arg_websiteDataStoreInstanceId) async { + Future createFromWebsiteDataStore(int arg_instanceId, int arg_websiteDataStoreInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore', - codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_websiteDataStoreInstanceId]) - as Map?; + 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_websiteDataStoreInstanceId]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1943,21 +1739,18 @@ class WKHttpCookieStoreHostApi { } } - Future setCookie( - int arg_instanceId, NSHttpCookieData arg_cookie) async { + Future setCookie(int arg_instanceId, NSHttpCookieData arg_cookie) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie', codec, - binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_cookie]) as Map?; + 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie', codec, binaryMessenger: _binaryMessenger); + final Map? replyMap = + await channel.send([arg_instanceId, arg_cookie]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + final Map error = (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart index 88f763fe6ba3..cc26ca5d7608 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart @@ -600,6 +600,7 @@ class WKUIDelegate { class WKNavigationDelegate extends NSObject { /// Constructs a [WKNavigationDelegate]. WKNavigationDelegate({ + this.didFinishNavigation, BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, }) : _navigationDelegateApi = WKNavigationDelegateHostApiImpl( @@ -611,11 +612,17 @@ class WKNavigationDelegate extends NSObject { instanceManager: instanceManager, ) { WebKitFlutterApis.instance.ensureSetUp(); - _navigationDelegateApi.createForInstances(this); + _navigationDelegateApi.createForInstances(this, didFinishNavigation); } final WKNavigationDelegateHostApiImpl _navigationDelegateApi; + /// Called when navigation is complete. + final void Function( + WKWebView webView, + String? url, + )? didFinishNavigation; + /// Called when navigation from the main frame has started. Future setDidStartProvisionalNavigation( void Function(WKWebView webView, String? url)? @@ -624,16 +631,6 @@ class WKNavigationDelegate extends NSObject { throw UnimplementedError(); } - /// Called when navigation is complete. - Future setDidFinishNavigation( - void Function(WKWebView webView, String? url)? didFinishNavigation, - ) { - return _navigationDelegateApi.setDidFinishNavigationFromInstance( - this, - didFinishNavigation, - ); - } - /// Called when permission is needed to navigate to new content. Future setDecidePolicyForNavigationAction( Future Function( diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart index 8bf29308371e..bc7dedfefe28 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart @@ -537,27 +537,19 @@ class WKNavigationDelegateHostApiImpl extends WKNavigationDelegateHostApi { final InstanceManager instanceManager; /// Calls [create] with the ids of the provided object instances. - Future createForInstances(WKNavigationDelegate instance) async { + Future createForInstances( + WKNavigationDelegate instance, + void Function(WKWebView webView, String? url)? didFinishNavigation, + ) async { final int? instanceId = instanceManager.tryAddInstance(instance); if (instanceId != null) { - await create(instanceId); - } - } - - /// Calls [setDidFinishNavigation] with the ids of the provided object instances. - Future setDidFinishNavigationFromInstance( - WKNavigationDelegate instance, - void Function(WKWebView, String?)? didFinishNavigation, - ) { - int? functionInstanceId; - if (didFinishNavigation != null) { - functionInstanceId = instanceManager.getInstanceId(didFinishNavigation) ?? - instanceManager.tryAddInstance(didFinishNavigation)!; + await create( + instanceId, + didFinishNavigation != null + ? _getOrAddFunctionInstanceId(instanceManager, didFinishNavigation) + : null, + ); } - return setDidFinishNavigation( - instanceManager.getInstanceId(instance)!, - functionInstanceId, - ); } } @@ -750,3 +742,11 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { ); } } + +int _getOrAddFunctionInstanceId( + InstanceManager instanceManager, + Function function, +) { + return instanceManager.getInstanceId(function) ?? + instanceManager.tryAddInstance(function)!; +} diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit_webview_widget.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit_webview_widget.dart index 0a177d854bc2..49300a5c5120 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit_webview_widget.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit_webview_widget.dart @@ -117,13 +117,14 @@ class WebKitWebViewPlatformController extends WebViewPlatformController { /// Methods for handling navigation changes and tracking navigation requests. @visibleForTesting late final WKNavigationDelegate navigationDelegate = - webViewProxy.createNavigationDelegate() + webViewProxy.createNavigationDelegate( + didFinishNavigation: (WKWebView webView, String? url) { + callbacksHandler.onPageFinished(url ?? ''); + }, + ) ..setDidStartProvisionalNavigation((WKWebView webView, String? url) { callbacksHandler.onPageStarted(url ?? ''); }) - ..setDidFinishNavigation((WKWebView webView, String? url) { - callbacksHandler.onPageFinished(url ?? ''); - }) ..setDidFailNavigation((WKWebView webView, NSError error) { callbacksHandler.onWebResourceError(_toWebResourceError(error)); }) @@ -619,7 +620,13 @@ class WebViewWidgetProxy { } /// Constructs a [WKNavigationDelegate]. - WKNavigationDelegate createNavigationDelegate() { - return WKNavigationDelegate(); + WKNavigationDelegate createNavigationDelegate({ + void Function( + WKWebView webView, + String? url, + )? + didFinishNavigation, + }) { + return WKNavigationDelegate(didFinishNavigation: didFinishNavigation); } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart index 6844a5fa67ad..9251a993d58a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart @@ -378,13 +378,8 @@ abstract class WKScriptMessageHandlerHostApi { /// See https://developer.apple.com/documentation/webkit/wknavigationdelegate?language=objc. @HostApi(dartHostTestHandler: 'TestWKNavigationDelegateHostApi') abstract class WKNavigationDelegateHostApi { - @ObjCSelector('createWithIdentifier:') - void create(int instanceId); - - @ObjCSelector( - 'setDidFinishNavigationForDelegateWithIdentifier:functionIdentifier:', - ) - void setDidFinishNavigation(int instanceId, int? functionInstanceId); + @ObjCSelector('createWithIdentifier:didFinishNavigationIdentifier:') + void create(int instanceId, int? didFinishNavigationInstanceId); } /// Mirror of WKNavigationDelegate. @@ -393,7 +388,7 @@ abstract class WKNavigationDelegateHostApi { @FlutterApi() abstract class WKNavigationDelegateFlutterApi { @ObjCSelector( - 'didFinishNavigationForDelegateWithIdentifier:webViewIdentifier:URL:', + 'didFinishNavigationFunctionWithIdentifier:webViewIdentifier:URL:', ) void didFinishNavigation( int functionInstanceId, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart index 1f963b4d9bc3..00412761b287 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart @@ -21,75 +21,59 @@ class _TestWKWebsiteDataStoreHostApiCodec extends StandardMessageCodec { if (value is WKWebsiteDataTypeEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else { + } else +{ super.writeValue(buffer, value); } } - @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKWebsiteDataTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); + } } } - abstract class TestWKWebsiteDataStoreHostApi { - static const MessageCodec codec = - _TestWKWebsiteDataStoreHostApiCodec(); + static const MessageCodec codec = _TestWKWebsiteDataStoreHostApiCodec(); - void createFromWebViewConfiguration( - int instanceId, int configurationInstanceId); + void createFromWebViewConfiguration(int instanceId, int configurationInstanceId); void createDefaultDataStore(int instanceId); - Future removeDataOfTypes( - int instanceId, - List dataTypes, - double modificationTimeInSecondsSinceEpoch); - static void setup(TestWKWebsiteDataStoreHostApi? api, - {BinaryMessenger? binaryMessenger}) { + Future removeDataOfTypes(int instanceId, List dataTypes, double modificationTimeInSecondsSinceEpoch); + static void setup(TestWKWebsiteDataStoreHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null, expected non-null int.'); final int? arg_configurationInstanceId = (args[1] as int?); - assert(arg_configurationInstanceId != null, - 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null, expected non-null int.'); - api.createFromWebViewConfiguration( - arg_instanceId!, arg_configurationInstanceId!); + assert(arg_configurationInstanceId != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + api.createFromWebViewConfiguration(arg_instanceId!, arg_configurationInstanceId!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore was null, expected non-null int.'); api.createDefaultDataStore(arg_instanceId!); return {}; }); @@ -97,29 +81,20 @@ abstract class TestWKWebsiteDataStoreHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null int.'); - final List? arg_dataTypes = - (args[1] as List?)?.cast(); - assert(arg_dataTypes != null, - 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null List.'); - final double? arg_modificationTimeInSecondsSinceEpoch = - (args[2] as double?); - assert(arg_modificationTimeInSecondsSinceEpoch != null, - 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null double.'); - final bool output = await api.removeDataOfTypes(arg_instanceId!, - arg_dataTypes!, arg_modificationTimeInSecondsSinceEpoch!); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null int.'); + final List? arg_dataTypes = (args[1] as List?)?.cast(); + assert(arg_dataTypes != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null List.'); + final double? arg_modificationTimeInSecondsSinceEpoch = (args[2] as double?); + assert(arg_modificationTimeInSecondsSinceEpoch != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null double.'); + final bool output = await api.removeDataOfTypes(arg_instanceId!, arg_dataTypes!, arg_modificationTimeInSecondsSinceEpoch!); return {'result': output}; }); } @@ -130,28 +105,23 @@ abstract class TestWKWebsiteDataStoreHostApi { class _TestUIViewHostApiCodec extends StandardMessageCodec { const _TestUIViewHostApiCodec(); } - abstract class TestUIViewHostApi { static const MessageCodec codec = _TestUIViewHostApiCodec(); void setBackgroundColor(int instanceId, int? value); void setOpaque(int instanceId, bool opaque); - static void setup(TestUIViewHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestUIViewHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIViewHostApi.setBackgroundColor', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIViewHostApi.setBackgroundColor', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.UIViewHostApi.setBackgroundColor was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setBackgroundColor was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.UIViewHostApi.setBackgroundColor was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setBackgroundColor was null, expected non-null int.'); final int? arg_value = (args[1] as int?); api.setBackgroundColor(arg_instanceId!, arg_value); return {}; @@ -160,21 +130,17 @@ abstract class TestUIViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIViewHostApi.setOpaque', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIViewHostApi.setOpaque', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null, expected non-null int.'); final bool? arg_opaque = (args[1] as bool?); - assert(arg_opaque != null, - 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null, expected non-null bool.'); + assert(arg_opaque != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null, expected non-null bool.'); api.setOpaque(arg_instanceId!, arg_opaque!); return {}; }); @@ -186,7 +152,6 @@ abstract class TestUIViewHostApi { class _TestUIScrollViewHostApiCodec extends StandardMessageCodec { const _TestUIScrollViewHostApiCodec(); } - abstract class TestUIScrollViewHostApi { static const MessageCodec codec = _TestUIScrollViewHostApiCodec(); @@ -194,25 +159,20 @@ abstract class TestUIScrollViewHostApi { List getContentOffset(int instanceId); void scrollBy(int instanceId, double x, double y); void setContentOffset(int instanceId, double x, double y); - static void setup(TestUIScrollViewHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestUIScrollViewHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null, expected non-null int.'); final int? arg_webViewInstanceId = (args[1] as int?); - assert(arg_webViewInstanceId != null, - 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null, expected non-null int.'); + assert(arg_webViewInstanceId != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null, expected non-null int.'); api.createFromWebView(arg_instanceId!, arg_webViewInstanceId!); return {}; }); @@ -220,18 +180,15 @@ abstract class TestUIScrollViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset was null, expected non-null int.'); final List output = api.getContentOffset(arg_instanceId!); return {'result': output}; }); @@ -239,24 +196,19 @@ abstract class TestUIScrollViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.scrollBy', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.scrollBy', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null int.'); final double? arg_x = (args[1] as double?); - assert(arg_x != null, - 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null double.'); + assert(arg_x != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null double.'); final double? arg_y = (args[2] as double?); - assert(arg_y != null, - 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null double.'); + assert(arg_y != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null double.'); api.scrollBy(arg_instanceId!, arg_x!, arg_y!); return {}; }); @@ -264,24 +216,19 @@ abstract class TestUIScrollViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null int.'); final double? arg_x = (args[1] as double?); - assert(arg_x != null, - 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null double.'); + assert(arg_x != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null double.'); final double? arg_y = (args[2] as double?); - assert(arg_y != null, - 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null double.'); + assert(arg_y != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null double.'); api.setContentOffset(arg_instanceId!, arg_x!, arg_y!); return {}; }); @@ -297,48 +244,42 @@ class _TestWKWebViewConfigurationHostApiCodec extends StandardMessageCodec { if (value is WKAudiovisualMediaTypeEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else { + } else +{ super.writeValue(buffer, value); } } - @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); + } } } - abstract class TestWKWebViewConfigurationHostApi { - static const MessageCodec codec = - _TestWKWebViewConfigurationHostApiCodec(); + static const MessageCodec codec = _TestWKWebViewConfigurationHostApiCodec(); void create(int instanceId); void createFromWebView(int instanceId, int webViewInstanceId); void setAllowsInlineMediaPlayback(int instanceId, bool allow); - void setMediaTypesRequiringUserActionForPlayback( - int instanceId, List types); - static void setup(TestWKWebViewConfigurationHostApi? api, - {BinaryMessenger? binaryMessenger}) { + void setMediaTypesRequiringUserActionForPlayback(int instanceId, List types); + static void setup(TestWKWebViewConfigurationHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.create', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.create was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.create was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.create was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.create was null, expected non-null int.'); api.create(arg_instanceId!); return {}; }); @@ -346,22 +287,17 @@ abstract class TestWKWebViewConfigurationHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null, expected non-null int.'); final int? arg_webViewInstanceId = (args[1] as int?); - assert(arg_webViewInstanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null, expected non-null int.'); + assert(arg_webViewInstanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null, expected non-null int.'); api.createFromWebView(arg_instanceId!, arg_webViewInstanceId!); return {}; }); @@ -369,22 +305,17 @@ abstract class TestWKWebViewConfigurationHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null, expected non-null int.'); final bool? arg_allow = (args[1] as bool?); - assert(arg_allow != null, - 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null, expected non-null bool.'); + assert(arg_allow != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null, expected non-null bool.'); api.setAllowsInlineMediaPlayback(arg_instanceId!, arg_allow!); return {}; }); @@ -392,26 +323,18 @@ abstract class TestWKWebViewConfigurationHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null, expected non-null int.'); - final List? arg_types = - (args[1] as List?) - ?.cast(); - assert(arg_types != null, - 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null, expected non-null List.'); - api.setMediaTypesRequiringUserActionForPlayback( - arg_instanceId!, arg_types!); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null, expected non-null int.'); + final List? arg_types = (args[1] as List?)?.cast(); + assert(arg_types != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null, expected non-null List.'); + api.setMediaTypesRequiringUserActionForPlayback(arg_instanceId!, arg_types!); return {}; }); } @@ -426,112 +349,91 @@ class _TestWKUserContentControllerHostApiCodec extends StandardMessageCodec { if (value is WKUserScriptData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else if (value is WKUserScriptInjectionTimeEnumData) { + } else + if (value is WKUserScriptInjectionTimeEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else { + } else +{ super.writeValue(buffer, value); } } - @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKUserScriptData.decode(readValue(buffer)!); - - case 129: + + case 129: return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); + } } } - abstract class TestWKUserContentControllerHostApi { - static const MessageCodec codec = - _TestWKUserContentControllerHostApiCodec(); + static const MessageCodec codec = _TestWKUserContentControllerHostApiCodec(); - void createFromWebViewConfiguration( - int instanceId, int configurationInstanceId); - void addScriptMessageHandler( - int instanceId, int handlerInstanceid, String name); + void createFromWebViewConfiguration(int instanceId, int configurationInstanceId); + void addScriptMessageHandler(int instanceId, int handlerInstanceid, String name); void removeScriptMessageHandler(int instanceId, String name); void removeAllScriptMessageHandlers(int instanceId); void addUserScript(int instanceId, WKUserScriptData userScript); void removeAllUserScripts(int instanceId); - static void setup(TestWKUserContentControllerHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKUserContentControllerHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null, expected non-null int.'); final int? arg_configurationInstanceId = (args[1] as int?); - assert(arg_configurationInstanceId != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null, expected non-null int.'); - api.createFromWebViewConfiguration( - arg_instanceId!, arg_configurationInstanceId!); + assert(arg_configurationInstanceId != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + api.createFromWebViewConfiguration(arg_instanceId!, arg_configurationInstanceId!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null int.'); final int? arg_handlerInstanceid = (args[1] as int?); - assert(arg_handlerInstanceid != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null int.'); + assert(arg_handlerInstanceid != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null int.'); final String? arg_name = (args[2] as String?); - assert(arg_name != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null String.'); - api.addScriptMessageHandler( - arg_instanceId!, arg_handlerInstanceid!, arg_name!); + assert(arg_name != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null String.'); + api.addScriptMessageHandler(arg_instanceId!, arg_handlerInstanceid!, arg_name!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null, expected non-null int.'); final String? arg_name = (args[1] as String?); - assert(arg_name != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null, expected non-null String.'); + assert(arg_name != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null, expected non-null String.'); api.removeScriptMessageHandler(arg_instanceId!, arg_name!); return {}; }); @@ -539,19 +441,15 @@ abstract class TestWKUserContentControllerHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers was null, expected non-null int.'); api.removeAllScriptMessageHandlers(arg_instanceId!); return {}; }); @@ -559,23 +457,17 @@ abstract class TestWKUserContentControllerHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null, expected non-null int.'); - final WKUserScriptData? arg_userScript = - (args[1] as WKUserScriptData?); - assert(arg_userScript != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null, expected non-null WKUserScriptData.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null, expected non-null int.'); + final WKUserScriptData? arg_userScript = (args[1] as WKUserScriptData?); + assert(arg_userScript != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null, expected non-null WKUserScriptData.'); api.addUserScript(arg_instanceId!, arg_userScript!); return {}; }); @@ -583,19 +475,15 @@ abstract class TestWKUserContentControllerHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts was null, expected non-null int.'); api.removeAllUserScripts(arg_instanceId!); return {}; }); @@ -607,56 +495,43 @@ abstract class TestWKUserContentControllerHostApi { class _TestWKPreferencesHostApiCodec extends StandardMessageCodec { const _TestWKPreferencesHostApiCodec(); } - abstract class TestWKPreferencesHostApi { static const MessageCodec codec = _TestWKPreferencesHostApiCodec(); - void createFromWebViewConfiguration( - int instanceId, int configurationInstanceId); + void createFromWebViewConfiguration(int instanceId, int configurationInstanceId); void setJavaScriptEnabled(int instanceId, bool enabled); - static void setup(TestWKPreferencesHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKPreferencesHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null, expected non-null int.'); final int? arg_configurationInstanceId = (args[1] as int?); - assert(arg_configurationInstanceId != null, - 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null, expected non-null int.'); - api.createFromWebViewConfiguration( - arg_instanceId!, arg_configurationInstanceId!); + assert(arg_configurationInstanceId != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + api.createFromWebViewConfiguration(arg_instanceId!, arg_configurationInstanceId!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null, expected non-null int.'); final bool? arg_enabled = (args[1] as bool?); - assert(arg_enabled != null, - 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null, expected non-null bool.'); + assert(arg_enabled != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null, expected non-null bool.'); api.setJavaScriptEnabled(arg_instanceId!, arg_enabled!); return {}; }); @@ -668,28 +543,22 @@ abstract class TestWKPreferencesHostApi { class _TestWKScriptMessageHandlerHostApiCodec extends StandardMessageCodec { const _TestWKScriptMessageHandlerHostApiCodec(); } - abstract class TestWKScriptMessageHandlerHostApi { - static const MessageCodec codec = - _TestWKScriptMessageHandlerHostApiCodec(); + static const MessageCodec codec = _TestWKScriptMessageHandlerHostApiCodec(); void create(int instanceId); - static void setup(TestWKScriptMessageHandlerHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKScriptMessageHandlerHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create was null, expected non-null int.'); api.create(arg_instanceId!); return {}; }); @@ -701,51 +570,24 @@ abstract class TestWKScriptMessageHandlerHostApi { class _TestWKNavigationDelegateHostApiCodec extends StandardMessageCodec { const _TestWKNavigationDelegateHostApiCodec(); } - abstract class TestWKNavigationDelegateHostApi { - static const MessageCodec codec = - _TestWKNavigationDelegateHostApiCodec(); + static const MessageCodec codec = _TestWKNavigationDelegateHostApiCodec(); - void create(int instanceId); - void setDidFinishNavigation(int instanceId, int? functionInstanceId); - static void setup(TestWKNavigationDelegateHostApi? api, - {BinaryMessenger? binaryMessenger}) { + void create(int instanceId, int? didFinishNavigationInstanceId); + static void setup(TestWKNavigationDelegateHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKNavigationDelegateHostApi.create', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKNavigationDelegateHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.create was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.create was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.create was null, expected non-null int.'); - api.create(arg_instanceId!); - return {}; - }); - } - } - { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKNavigationDelegateHostApi.setDidFinishNavigation', - codec, - binaryMessenger: binaryMessenger); - if (api == null) { - channel.setMockMessageHandler(null); - } else { - channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.setDidFinishNavigation was null.'); - final List args = (message as List?)!; - final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.setDidFinishNavigation was null, expected non-null int.'); - final int? arg_functionInstanceId = (args[1] as int?); - api.setDidFinishNavigation(arg_instanceId!, arg_functionInstanceId); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.create was null, expected non-null int.'); + final int? arg_didFinishNavigationInstanceId = (args[1] as int?); + api.create(arg_instanceId!, arg_didFinishNavigationInstanceId); return {}; }); } @@ -760,46 +602,41 @@ class _TestNSObjectHostApiCodec extends StandardMessageCodec { if (value is NSKeyValueObservingOptionsEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else { + } else +{ super.writeValue(buffer, value); } } - @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); + } } } - abstract class TestNSObjectHostApi { static const MessageCodec codec = _TestNSObjectHostApiCodec(); void dispose(int instanceId); - void addObserver(int instanceId, int observerInstanceId, String keyPath, - List options); + void addObserver(int instanceId, int observerInstanceId, String keyPath, List options); void removeObserver(int instanceId, int observerInstanceId, String keyPath); - static void setup(TestNSObjectHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestNSObjectHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.dispose', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.NSObjectHostApi.dispose', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.NSObjectHostApi.dispose was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.dispose was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.NSObjectHostApi.dispose was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.dispose was null, expected non-null int.'); api.dispose(arg_instanceId!); return {}; }); @@ -807,57 +644,42 @@ abstract class TestNSObjectHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.addObserver', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.NSObjectHostApi.addObserver', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null int.'); final int? arg_observerInstanceId = (args[1] as int?); - assert(arg_observerInstanceId != null, - 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null int.'); + assert(arg_observerInstanceId != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null int.'); final String? arg_keyPath = (args[2] as String?); - assert(arg_keyPath != null, - 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null String.'); - final List? arg_options = - (args[3] as List?) - ?.cast(); - assert(arg_options != null, - 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null List.'); - api.addObserver(arg_instanceId!, arg_observerInstanceId!, - arg_keyPath!, arg_options!); + assert(arg_keyPath != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null String.'); + final List? arg_options = (args[3] as List?)?.cast(); + assert(arg_options != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null List.'); + api.addObserver(arg_instanceId!, arg_observerInstanceId!, arg_keyPath!, arg_options!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.removeObserver', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.NSObjectHostApi.removeObserver', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null int.'); final int? arg_observerInstanceId = (args[1] as int?); - assert(arg_observerInstanceId != null, - 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null int.'); + assert(arg_observerInstanceId != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null int.'); final String? arg_keyPath = (args[2] as String?); - assert(arg_keyPath != null, - 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null String.'); - api.removeObserver( - arg_instanceId!, arg_observerInstanceId!, arg_keyPath!); + assert(arg_keyPath != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null String.'); + api.removeObserver(arg_instanceId!, arg_observerInstanceId!, arg_keyPath!); return {}; }); } @@ -872,65 +694,72 @@ class _TestWKWebViewHostApiCodec extends StandardMessageCodec { if (value is NSHttpCookieData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else if (value is NSHttpCookiePropertyKeyEnumData) { + } else + if (value is NSHttpCookiePropertyKeyEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else if (value is NSKeyValueObservingOptionsEnumData) { + } else + if (value is NSKeyValueObservingOptionsEnumData) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else if (value is NSUrlRequestData) { + } else + if (value is NSUrlRequestData) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else if (value is WKAudiovisualMediaTypeEnumData) { + } else + if (value is WKAudiovisualMediaTypeEnumData) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else if (value is WKUserScriptData) { + } else + if (value is WKUserScriptData) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is WKUserScriptInjectionTimeEnumData) { + } else + if (value is WKUserScriptInjectionTimeEnumData) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is WKWebsiteDataTypeEnumData) { + } else + if (value is WKWebsiteDataTypeEnumData) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else { + } else +{ super.writeValue(buffer, value); } } - @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSHttpCookieData.decode(readValue(buffer)!); - - case 129: + + case 129: return NSHttpCookiePropertyKeyEnumData.decode(readValue(buffer)!); - - case 130: + + case 130: return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); - - case 131: + + case 131: return NSUrlRequestData.decode(readValue(buffer)!); - - case 132: + + case 132: return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); - - case 133: + + case 133: return WKUserScriptData.decode(readValue(buffer)!); - - case 134: + + case 134: return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); - - case 135: + + case 135: return WKWebsiteDataTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); + } } } - abstract class TestWKWebViewHostApi { static const MessageCodec codec = _TestWKWebViewHostApiCodec(); @@ -952,25 +781,20 @@ abstract class TestWKWebViewHostApi { void setAllowsBackForwardNavigationGestures(int instanceId, bool allow); void setCustomUserAgent(int instanceId, String? userAgent); Future evaluateJavaScript(int instanceId, String javaScriptString); - static void setup(TestWKWebViewHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKWebViewHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.create', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null, expected non-null int.'); final int? arg_configurationInstanceId = (args[1] as int?); - assert(arg_configurationInstanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null, expected non-null int.'); + assert(arg_configurationInstanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null, expected non-null int.'); api.create(arg_instanceId!, arg_configurationInstanceId!); return {}; }); @@ -978,18 +802,15 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate was null, expected non-null int.'); final int? arg_uiDelegateInstanceId = (args[1] as int?); api.setUIDelegate(arg_instanceId!, arg_uiDelegateInstanceId); return {}; @@ -998,39 +819,32 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate was null, expected non-null int.'); final int? arg_navigationDelegateInstanceId = (args[1] as int?); - api.setNavigationDelegate( - arg_instanceId!, arg_navigationDelegateInstanceId); + api.setNavigationDelegate(arg_instanceId!, arg_navigationDelegateInstanceId); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getUrl', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getUrl', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getUrl was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getUrl was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getUrl was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getUrl was null, expected non-null int.'); final String? output = api.getUrl(arg_instanceId!); return {'result': output}; }); @@ -1038,18 +852,15 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress was null, expected non-null int.'); final double output = api.getEstimatedProgress(arg_instanceId!); return {'result': output}; }); @@ -1057,21 +868,17 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadRequest', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadRequest', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null, expected non-null int.'); final NSUrlRequestData? arg_request = (args[1] as NSUrlRequestData?); - assert(arg_request != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null, expected non-null NSUrlRequestData.'); + assert(arg_request != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null, expected non-null NSUrlRequestData.'); api.loadRequest(arg_instanceId!, arg_request!); return {}; }); @@ -1079,21 +886,17 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null, expected non-null int.'); final String? arg_string = (args[1] as String?); - assert(arg_string != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null, expected non-null String.'); + assert(arg_string != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null, expected non-null String.'); final String? arg_baseUrl = (args[2] as String?); api.loadHtmlString(arg_instanceId!, arg_string!, arg_baseUrl); return {}; @@ -1102,24 +905,19 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null int.'); final String? arg_url = (args[1] as String?); - assert(arg_url != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null String.'); + assert(arg_url != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null String.'); final String? arg_readAccessUrl = (args[2] as String?); - assert(arg_readAccessUrl != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null String.'); + assert(arg_readAccessUrl != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null String.'); api.loadFileUrl(arg_instanceId!, arg_url!, arg_readAccessUrl!); return {}; }); @@ -1127,21 +925,17 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null, expected non-null int.'); final String? arg_key = (args[1] as String?); - assert(arg_key != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null, expected non-null String.'); + assert(arg_key != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null, expected non-null String.'); api.loadFlutterAsset(arg_instanceId!, arg_key!); return {}; }); @@ -1149,18 +943,15 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.canGoBack', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.canGoBack', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoBack was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoBack was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoBack was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoBack was null, expected non-null int.'); final bool output = api.canGoBack(arg_instanceId!); return {'result': output}; }); @@ -1168,18 +959,15 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.canGoForward', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.canGoForward', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoForward was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoForward was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoForward was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoForward was null, expected non-null int.'); final bool output = api.canGoForward(arg_instanceId!); return {'result': output}; }); @@ -1187,18 +975,15 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.goBack', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.goBack', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goBack was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goBack was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goBack was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goBack was null, expected non-null int.'); api.goBack(arg_instanceId!); return {}; }); @@ -1206,18 +991,15 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.goForward', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.goForward', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goForward was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goForward was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goForward was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goForward was null, expected non-null int.'); api.goForward(arg_instanceId!); return {}; }); @@ -1225,18 +1007,15 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.reload', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.reload', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.reload was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.reload was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.reload was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.reload was null, expected non-null int.'); api.reload(arg_instanceId!); return {}; }); @@ -1244,18 +1023,15 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getTitle', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getTitle', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getTitle was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getTitle was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getTitle was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getTitle was null, expected non-null int.'); final String? output = api.getTitle(arg_instanceId!); return {'result': output}; }); @@ -1263,42 +1039,33 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null, expected non-null int.'); final bool? arg_allow = (args[1] as bool?); - assert(arg_allow != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null, expected non-null bool.'); - api.setAllowsBackForwardNavigationGestures( - arg_instanceId!, arg_allow!); + assert(arg_allow != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null, expected non-null bool.'); + api.setAllowsBackForwardNavigationGestures(arg_instanceId!, arg_allow!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent was null, expected non-null int.'); final String? arg_userAgent = (args[1] as String?); api.setCustomUserAgent(arg_instanceId!, arg_userAgent); return {}; @@ -1307,23 +1074,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null, expected non-null int.'); final String? arg_javaScriptString = (args[1] as String?); - assert(arg_javaScriptString != null, - 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null, expected non-null String.'); - final Object? output = await api.evaluateJavaScript( - arg_instanceId!, arg_javaScriptString!); + assert(arg_javaScriptString != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null, expected non-null String.'); + final Object? output = await api.evaluateJavaScript(arg_instanceId!, arg_javaScriptString!); return {'result': output}; }); } @@ -1334,27 +1096,22 @@ abstract class TestWKWebViewHostApi { class _TestWKUIDelegateHostApiCodec extends StandardMessageCodec { const _TestWKUIDelegateHostApiCodec(); } - abstract class TestWKUIDelegateHostApi { static const MessageCodec codec = _TestWKUIDelegateHostApiCodec(); void create(int instanceId); - static void setup(TestWKUIDelegateHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKUIDelegateHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUIDelegateHostApi.create', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUIDelegateHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKUIDelegateHostApi.create was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKUIDelegateHostApi.create was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKUIDelegateHostApi.create was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKUIDelegateHostApi.create was null, expected non-null int.'); api.create(arg_instanceId!); return {}; }); @@ -1370,79 +1127,67 @@ class _TestWKHttpCookieStoreHostApiCodec extends StandardMessageCodec { if (value is NSHttpCookieData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else if (value is NSHttpCookiePropertyKeyEnumData) { + } else + if (value is NSHttpCookiePropertyKeyEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else { + } else +{ super.writeValue(buffer, value); } } - @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSHttpCookieData.decode(readValue(buffer)!); - - case 129: + + case 129: return NSHttpCookiePropertyKeyEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); + } } } - abstract class TestWKHttpCookieStoreHostApi { - static const MessageCodec codec = - _TestWKHttpCookieStoreHostApiCodec(); + static const MessageCodec codec = _TestWKHttpCookieStoreHostApiCodec(); - void createFromWebsiteDataStore( - int instanceId, int websiteDataStoreInstanceId); + void createFromWebsiteDataStore(int instanceId, int websiteDataStoreInstanceId); Future setCookie(int instanceId, NSHttpCookieData cookie); - static void setup(TestWKHttpCookieStoreHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKHttpCookieStoreHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore', - codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null, expected non-null int.'); final int? arg_websiteDataStoreInstanceId = (args[1] as int?); - assert(arg_websiteDataStoreInstanceId != null, - 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null, expected non-null int.'); - api.createFromWebsiteDataStore( - arg_instanceId!, arg_websiteDataStoreInstanceId!); + assert(arg_websiteDataStoreInstanceId != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null, expected non-null int.'); + api.createFromWebsiteDataStore(arg_instanceId!, arg_websiteDataStoreInstanceId!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie', codec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null.'); + assert(message != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null, expected non-null int.'); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null, expected non-null int.'); final NSHttpCookieData? arg_cookie = (args[1] as NSHttpCookieData?); - assert(arg_cookie != null, - 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null, expected non-null NSHttpCookieData.'); + assert(arg_cookie != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null, expected non-null NSHttpCookieData.'); await api.setCookie(arg_instanceId!, arg_cookie!); return {}; }); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart index ae13ca9e6b6d..f7b927ba679b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart @@ -438,23 +438,28 @@ void main() { }); test('create', () async { + navigationDelegate = WKNavigationDelegate( + instanceManager: instanceManager, + ); + verify(mockPlatformHostApi.create( instanceManager.getInstanceId(navigationDelegate), + null, )); }); - test('setDidFinishNavigation', () async { + test('didFinishNavigation', () async { final Completer> argsCompleter = Completer>(); - navigationDelegate.setDidFinishNavigation( - (WKWebView webView, String? url) { + navigationDelegate = WKNavigationDelegate( + instanceManager: instanceManager, + didFinishNavigation: (WKWebView webView, String? url) { argsCompleter.complete([webView, url]); }, ); - final int functionInstanceId = - verify(mockPlatformHostApi.setDidFinishNavigation( + final int functionInstanceId = verify(mockPlatformHostApi.create( instanceManager.getInstanceId(navigationDelegate), captureAny, )).captured.single as int; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart index 4ffb7d4c19d3..6ab12064d48e 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart @@ -53,14 +53,10 @@ class MockTestWKNavigationDelegateHostApi extends _i1.Mock } @override - void create(int? instanceId) => - super.noSuchMethod(Invocation.method(#create, [instanceId]), - returnValueForMissingStub: null); - @override - void setDidFinishNavigation(int? instanceId, int? functionInstanceId) => + void create(int? instanceId, int? didFinishNavigationInstanceId) => super.noSuchMethod( Invocation.method( - #setDidFinishNavigation, [instanceId, functionInstanceId]), + #create, [instanceId, didFinishNavigationInstanceId]), returnValueForMissingStub: null); } @@ -311,9 +307,9 @@ class MockTestWKWebsiteDataStoreHostApi extends _i1.Mock _i3.Future removeDataOfTypes( int? instanceId, List<_i4.WKWebsiteDataTypeEnumData?>? dataTypes, - double? secondsModifiedSinceEpoch) => + double? modificationTimeInSecondsSinceEpoch) => (super.noSuchMethod( Invocation.method(#removeDataOfTypes, - [instanceId, dataTypes, secondsModifiedSinceEpoch]), + [instanceId, dataTypes, modificationTimeInSecondsSinceEpoch]), returnValue: Future.value(false)) as _i3.Future); } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.dart index d77feee22dd1..0c6d83bdc64b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.dart @@ -64,8 +64,9 @@ void main() { when(mockWebViewWidgetProxy.createWebView(any)).thenReturn(mockWebView); when(mockWebViewWidgetProxy.createUIDelgate()).thenReturn(mockUIDelegate); - when(mockWebViewWidgetProxy.createNavigationDelegate()) - .thenReturn(mockNavigationDelegate); + when(mockWebViewWidgetProxy.createNavigationDelegate( + didFinishNavigation: anyNamed('didFinishNavigation'), + )).thenReturn(mockNavigationDelegate); when(mockWebView.configuration).thenReturn(mockWebViewConfiguration); when(mockWebViewConfiguration.userContentController).thenReturn( mockUserContentController, @@ -919,9 +920,9 @@ void main() { await buildWidget(tester); final dynamic didFinishNavigation = - verify(mockNavigationDelegate.setDidFinishNavigation(captureAny)) - .captured - .single as void Function(WKWebView, String); + verify(mockWebViewWidgetProxy.createNavigationDelegate( + didFinishNavigation: captureAnyNamed('didFinishNavigation'), + )).captured.single as void Function(WKWebView, String); didFinishNavigation(mockWebView, 'https://google.com'); verify(mockCallbacksHandler.onPageFinished('https://google.com')); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.mocks.dart index 066f33a9774e..fb467ec5518c 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.mocks.dart @@ -139,13 +139,6 @@ class MockWKNavigationDelegate extends _i1.Mock returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i5.Future); @override - _i5.Future setDidFinishNavigation( - void Function(_i3.WKWebView, String?)? didFinishNavigation) => - (super.noSuchMethod( - Invocation.method(#setDidFinishNavigation, [didFinishNavigation]), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); - @override _i5.Future setDecidePolicyForNavigationAction( _i5.Future<_i3.WKNavigationActionPolicy> Function( _i3.WKWebView, _i3.WKNavigationAction)? @@ -578,7 +571,11 @@ class MockWebViewWidgetProxy extends _i1.Mock (super.noSuchMethod(Invocation.method(#createUIDelgate, []), returnValue: _FakeWKUIDelegate_9()) as _i3.WKUIDelegate); @override - _i3.WKNavigationDelegate createNavigationDelegate() => (super.noSuchMethod( - Invocation.method(#createNavigationDelegate, []), - returnValue: _FakeWKNavigationDelegate_10()) as _i3.WKNavigationDelegate); + _i3.WKNavigationDelegate createNavigationDelegate( + {void Function(_i3.WKWebView, String?)? didFinishNavigation}) => + (super.noSuchMethod( + Invocation.method(#createNavigationDelegate, [], + {#didFinishNavigation: didFinishNavigation}), + returnValue: _FakeWKNavigationDelegate_10()) + as _i3.WKNavigationDelegate); } From 2e552661ee89066b71c07d9876838dfd8325e45f Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 11 May 2022 17:16:01 -0700 Subject: [PATCH 02/40] objc side of callback impl --- .../FWFNavigationDelegateHostApiTests.m | 53 +- .../ios/Classes/FWFGeneratedWebKitApis.h | 275 +++- .../ios/Classes/FWFGeneratedWebKitApis.m | 1326 ++++++++++------- .../Classes/FWFNavigationDelegateHostApi.h | 12 +- .../Classes/FWFNavigationDelegateHostApi.m | 82 +- .../ios/Classes/FWFObjectHostApi.h | 11 + .../ios/Classes/FWFObjectHostApi.m | 29 +- .../lib/src/common/web_kit.pigeon.dart | 769 ++++++---- .../pigeons/web_kit.dart | 6 + .../test/src/common/test_web_kit.pigeon.dart | 814 ++++++---- 10 files changed, 2158 insertions(+), 1219 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m index 02e473f8b795..ebf10572abfe 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m @@ -14,15 +14,62 @@ @interface FWFNavigationDelegateHostApiTests : XCTestCase @implementation FWFNavigationDelegateHostApiTests - (void)testCreateWithIdentifier { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - FWFNavigationDelegateHostApiImpl *hostApi = - [[FWFNavigationDelegateHostApiImpl alloc] initWithInstanceManager:instanceManager]; + FWFNavigationDelegateHostApiImpl *hostApi = [[FWFNavigationDelegateHostApiImpl alloc] + initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) + instanceManager:instanceManager]; FlutterError *error; - [hostApi createWithIdentifier:@0 error:&error]; + [hostApi createWithIdentifier:@0 didFinishNavigationIdentifier:nil error:&error]; FWFNavigationDelegate *navigationDelegate = (FWFNavigationDelegate *)[instanceManager instanceForIdentifier:0]; XCTAssertTrue([navigationDelegate conformsToProtocol:@protocol(WKNavigationDelegate)]); XCTAssertNil(error); } + +- (void)testDidFinishNavigation { + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFNavigationDelegateHostApiImpl *hostApi = [[FWFNavigationDelegateHostApiImpl alloc] + initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) + instanceManager:instanceManager]; + + FlutterError *error; + [hostApi createWithIdentifier:@0 didFinishNavigationIdentifier:@1 error:&error]; + FWFNavigationDelegate *navigationDelegate = + (FWFNavigationDelegate *)[instanceManager instanceForIdentifier:0]; + id mockDelegate = OCMPartialMock(navigationDelegate); + + FWFNavigationDelegateFlutterApiImpl *flutterApi = [[FWFNavigationDelegateFlutterApiImpl alloc] + initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) + instanceManager:instanceManager]; + id mockFlutterApi = OCMPartialMock(flutterApi); + + OCMStub([mockDelegate navigationDelegateApi]).andReturn(mockFlutterApi); + + WKWebView *mockWebView = OCMClassMock([WKWebView class]); + OCMStub([mockWebView URL]).andReturn([NSURL URLWithString:@"https://flutter.dev/"]); + [instanceManager addInstance:mockWebView withIdentifier:2]; + + [mockDelegate webView:mockWebView didFinishNavigation:OCMClassMock([WKNavigation class])]; + OCMVerify([mockFlutterApi didFinishNavigationFunctionWithIdentifier:@1 + webViewIdentifier:@2 + URL:@"https://flutter.dev/" + completion:OCMOCK_ANY]); +} + +- (void)testInstanceCanBeReleasedWhenInstanceManagerIsReleased { + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFNavigationDelegateHostApiImpl *hostApi = [[FWFNavigationDelegateHostApiImpl alloc] + initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) + instanceManager:instanceManager]; + + FlutterError *error; + [hostApi createWithIdentifier:@0 didFinishNavigationIdentifier:nil error:&error]; + FWFNavigationDelegate __weak *navigationDelegate = + (FWFNavigationDelegate *)[instanceManager instanceForIdentifier:0]; + + XCTAssertNotNil(navigationDelegate); + instanceManager = nil; + XCTAssertNil(navigationDelegate); +} @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h index 2edf781f451b..824aae90f68d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h @@ -126,104 +126,166 @@ typedef NS_ENUM(NSUInteger, FWFNSHttpCookiePropertyKeyEnum) { /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithUrl:(NSString *)url - httpMethod:(nullable NSString *)httpMethod - httpBody:(nullable FlutterStandardTypedData *)httpBody - allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields; -@property(nonatomic, copy) NSString * url; -@property(nonatomic, copy, nullable) NSString * httpMethod; -@property(nonatomic, strong, nullable) FlutterStandardTypedData * httpBody; -@property(nonatomic, strong) NSDictionary * allHttpHeaderFields; + httpMethod:(nullable NSString *)httpMethod + httpBody:(nullable FlutterStandardTypedData *)httpBody + allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields; +@property(nonatomic, copy) NSString *url; +@property(nonatomic, copy, nullable) NSString *httpMethod; +@property(nonatomic, strong, nullable) FlutterStandardTypedData *httpBody; +@property(nonatomic, strong) NSDictionary *allHttpHeaderFields; @end @interface FWFWKUserScriptData : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithSource:(NSString *)source - injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime - isMainFrameOnly:(NSNumber *)isMainFrameOnly; -@property(nonatomic, copy) NSString * source; -@property(nonatomic, strong, nullable) FWFWKUserScriptInjectionTimeEnumData * injectionTime; -@property(nonatomic, strong) NSNumber * isMainFrameOnly; + injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime + isMainFrameOnly:(NSNumber *)isMainFrameOnly; +@property(nonatomic, copy) NSString *source; +@property(nonatomic, strong, nullable) FWFWKUserScriptInjectionTimeEnumData *injectionTime; +@property(nonatomic, strong) NSNumber *isMainFrameOnly; @end @interface FWFNSHttpCookieData : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithPropertyKeys:(NSArray *)propertyKeys - propertyValues:(NSArray *)propertyValues; -@property(nonatomic, strong) NSArray * propertyKeys; -@property(nonatomic, strong) NSArray * propertyValues; + propertyValues:(NSArray *)propertyValues; +@property(nonatomic, strong) NSArray *propertyKeys; +@property(nonatomic, strong) NSArray *propertyValues; @end /// The codec used by FWFWKWebsiteDataStoreHostApi. NSObject *FWFWKWebsiteDataStoreHostApiGetCodec(void); @protocol FWFWKWebsiteDataStoreHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)createDefaultDataStoreWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeDataFromDataStoreWithIdentifier:(NSNumber *)instanceId ofTypes:(NSArray *)dataTypes modifiedSince:(NSNumber *)modificationTimeInSecondsSinceEpoch completion:(void(^)(NSNumber *_Nullable, FlutterError *_Nullable))completion; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId + configurationIdentifier:(NSNumber *)configurationInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createDefaultDataStoreWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeDataFromDataStoreWithIdentifier:(NSNumber *)instanceId + ofTypes:(NSArray *)dataTypes + modifiedSince:(NSNumber *)modificationTimeInSecondsSinceEpoch + completion:(void (^)(NSNumber *_Nullable, + FlutterError *_Nullable))completion; @end -extern void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKWebsiteDataStoreHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFUIViewHostApi. NSObject *FWFUIViewHostApiGetCodec(void); @protocol FWFUIViewHostApi -- (void)setBackgroundColorForViewWithIdentifier:(NSNumber *)instanceId toValue:(nullable NSNumber *)value error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setOpaqueForViewWithIdentifier:(NSNumber *)instanceId isOpaque:(NSNumber *)opaque error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setBackgroundColorForViewWithIdentifier:(NSNumber *)instanceId + toValue:(nullable NSNumber *)value + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setOpaqueForViewWithIdentifier:(NSNumber *)instanceId + isOpaque:(NSNumber *)opaque + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFUIViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFUIViewHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFUIScrollViewHostApi. NSObject *FWFUIScrollViewHostApiGetCodec(void); @protocol FWFUIScrollViewHostApi -- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId webViewIdentifier:(NSNumber *)webViewInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId + webViewIdentifier:(NSNumber *)webViewInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSArray *)contentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)scrollByForScrollViewWithIdentifier:(NSNumber *)instanceId x:(NSNumber *)x y:(NSNumber *)y error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setContentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId toX:(NSNumber *)x y:(NSNumber *)y error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSArray *) + contentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)scrollByForScrollViewWithIdentifier:(NSNumber *)instanceId + x:(NSNumber *)x + y:(NSNumber *)y + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setContentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId + toX:(NSNumber *)x + y:(NSNumber *)y + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFUIScrollViewHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKWebViewConfigurationHostApi. NSObject *FWFWKWebViewConfigurationHostApiGetCodec(void); @protocol FWFWKWebViewConfigurationHostApi - (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId webViewIdentifier:(NSNumber *)webViewInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:(NSNumber *)instanceId isAllowed:(NSNumber *)allow error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setMediaTypesRequiresUserActionForConfigurationWithIdentifier:(NSNumber *)instanceId forTypes:(NSArray *)types error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId + webViewIdentifier:(NSNumber *)webViewInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:(NSNumber *)instanceId + isAllowed:(NSNumber *)allow + error: + (FlutterError *_Nullable *_Nonnull) + error; +- (void) + setMediaTypesRequiresUserActionForConfigurationWithIdentifier:(NSNumber *)instanceId + forTypes: + (NSArray< + FWFWKAudiovisualMediaTypeEnumData + *> *)types + error: + (FlutterError *_Nullable *_Nonnull) + error; @end -extern void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKWebViewConfigurationHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKUserContentControllerHostApi. NSObject *FWFWKUserContentControllerHostApiGetCodec(void); @protocol FWFWKUserContentControllerHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)addScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId handlerIdentifier:(NSNumber *)handlerInstanceid ofName:(NSString *)name error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId name:(NSString *)name error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeAllScriptMessageHandlersForControllerWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)addUserScriptForControllerWithIdentifier:(NSNumber *)instanceId userScript:(FWFWKUserScriptData *)userScript error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeAllUserScriptsForControllerWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId + configurationIdentifier:(NSNumber *)configurationInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)addScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId + handlerIdentifier:(NSNumber *)handlerInstanceid + ofName:(NSString *)name + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId + name:(NSString *)name + error:(FlutterError *_Nullable *_Nonnull) + error; +- (void)removeAllScriptMessageHandlersForControllerWithIdentifier:(NSNumber *)instanceId + error: + (FlutterError *_Nullable *_Nonnull) + error; +- (void)addUserScriptForControllerWithIdentifier:(NSNumber *)instanceId + userScript:(FWFWKUserScriptData *)userScript + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeAllUserScriptsForControllerWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKUserContentControllerHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKPreferencesHostApi. NSObject *FWFWKPreferencesHostApiGetCodec(void); @protocol FWFWKPreferencesHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setJavaScriptEnabledForPreferencesWithIdentifier:(NSNumber *)instanceId isEnabled:(NSNumber *)enabled error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId + configurationIdentifier:(NSNumber *)configurationInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setJavaScriptEnabledForPreferencesWithIdentifier:(NSNumber *)instanceId + isEnabled:(NSNumber *)enabled + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKPreferencesHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKPreferencesHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKScriptMessageHandlerHostApi. NSObject *FWFWKScriptMessageHandlerHostApiGetCodec(void); @@ -232,70 +294,131 @@ NSObject *FWFWKScriptMessageHandlerHostApiGetCodec(void); - (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKScriptMessageHandlerHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKNavigationDelegateHostApi. NSObject *FWFWKNavigationDelegateHostApiGetCodec(void); @protocol FWFWKNavigationDelegateHostApi -- (void)createWithIdentifier:(NSNumber *)instanceId didFinishNavigationIdentifier:(nullable NSNumber *)didFinishNavigationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createWithIdentifier:(NSNumber *)instanceId + didFinishNavigationIdentifier:(nullable NSNumber *)didFinishNavigationInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKNavigationDelegateHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKNavigationDelegateFlutterApi. NSObject *FWFWKNavigationDelegateFlutterApiGetCodec(void); @interface FWFWKNavigationDelegateFlutterApi : NSObject - (instancetype)initWithBinaryMessenger:(id)binaryMessenger; -- (void)didFinishNavigationFunctionWithIdentifier:(NSNumber *)functionInstanceId webViewIdentifier:(NSNumber *)webViewInstanceId URL:(nullable NSString *)url completion:(void(^)(NSError *_Nullable))completion; +- (void)didFinishNavigationFunctionWithIdentifier:(NSNumber *)functionInstanceId + webViewIdentifier:(NSNumber *)webViewInstanceId + URL:(nullable NSString *)url + completion:(void (^)(NSError *_Nullable))completion; @end /// The codec used by FWFNSObjectHostApi. NSObject *FWFNSObjectHostApiGetCodec(void); @protocol FWFNSObjectHostApi -- (void)disposeObjectWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)addObserverForObjectWithIdentifier:(NSNumber *)instanceId observerIdentifier:(NSNumber *)observerInstanceId keyPath:(NSString *)keyPath options:(NSArray *)options error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeObserverForObjectWithIdentifier:(NSNumber *)instanceId observerIdentifier:(NSNumber *)observerInstanceId keyPath:(NSString *)keyPath error:(FlutterError *_Nullable *_Nonnull)error; +- (void)disposeObjectWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)addObserverForObjectWithIdentifier:(NSNumber *)instanceId + observerIdentifier:(NSNumber *)observerInstanceId + keyPath:(NSString *)keyPath + options: + (NSArray *)options + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeObserverForObjectWithIdentifier:(NSNumber *)instanceId + observerIdentifier:(NSNumber *)observerInstanceId + keyPath:(NSString *)keyPath + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFNSObjectHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFNSObjectHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); +/// The codec used by FWFNSObjectFlutterApi. +NSObject *FWFNSObjectFlutterApiGetCodec(void); + +@interface FWFNSObjectFlutterApi : NSObject +- (instancetype)initWithBinaryMessenger:(id)binaryMessenger; +@end /// The codec used by FWFFunctionFlutterApi. NSObject *FWFFunctionFlutterApiGetCodec(void); @interface FWFFunctionFlutterApi : NSObject - (instancetype)initWithBinaryMessenger:(id)binaryMessenger; -- (void)disposeFunctionWithIdentifier:(NSNumber *)instanceId completion:(void(^)(NSError *_Nullable))completion; +- (void)disposeFunctionWithIdentifier:(NSNumber *)instanceId + completion:(void (^)(NSError *_Nullable))completion; @end /// The codec used by FWFWKWebViewHostApi. NSObject *FWFWKWebViewHostApiGetCodec(void); @protocol FWFWKWebViewHostApi -- (void)createWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setUIDelegateForWebViewWithIdentifier:(NSNumber *)instanceId delegateIdentifier:(nullable NSNumber *)uiDelegateInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setNavigationDelegateForWebViewWithIdentifier:(NSNumber *)instanceId delegateIdentifier:(nullable NSNumber *)navigationDelegateInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (nullable NSString *)URLForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createWithIdentifier:(NSNumber *)instanceId + configurationIdentifier:(NSNumber *)configurationInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setUIDelegateForWebViewWithIdentifier:(NSNumber *)instanceId + delegateIdentifier:(nullable NSNumber *)uiDelegateInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setNavigationDelegateForWebViewWithIdentifier:(NSNumber *)instanceId + delegateIdentifier: + (nullable NSNumber *)navigationDelegateInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSString *)URLForWebViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)estimatedProgressForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadRequestForWebViewWithIdentifier:(NSNumber *)instanceId request:(FWFNSUrlRequestData *)request error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadHTMLForWebViewWithIdentifier:(NSNumber *)instanceId HTMLString:(NSString *)string baseURL:(nullable NSString *)baseUrl error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadFileForWebViewWithIdentifier:(NSNumber *)instanceId fileURL:(NSString *)url readAccessURL:(NSString *)readAccessUrl error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadAssetForWebViewWithIdentifier:(NSNumber *)instanceId assetKey:(NSString *)key error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSNumber *)estimatedProgressForWebViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull) + error; +- (void)loadRequestForWebViewWithIdentifier:(NSNumber *)instanceId + request:(FWFNSUrlRequestData *)request + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadHTMLForWebViewWithIdentifier:(NSNumber *)instanceId + HTMLString:(NSString *)string + baseURL:(nullable NSString *)baseUrl + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadFileForWebViewWithIdentifier:(NSNumber *)instanceId + fileURL:(NSString *)url + readAccessURL:(NSString *)readAccessUrl + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadAssetForWebViewWithIdentifier:(NSNumber *)instanceId + assetKey:(NSString *)key + error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)canGoBackForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSNumber *)canGoBackForWebViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)canGoForwardForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)goBackForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)goForwardForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)reloadWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (nullable NSString *)titleForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setAllowsBackForwardForWebViewWithIdentifier:(NSNumber *)instanceId isAllowed:(NSNumber *)allow error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setUserAgentForWebViewWithIdentifier:(NSNumber *)instanceId userAgent:(nullable NSString *)userAgent error:(FlutterError *_Nullable *_Nonnull)error; -- (void)evaluateJavaScriptForWebViewWithIdentifier:(NSNumber *)instanceId javaScriptString:(NSString *)javaScriptString completion:(void(^)(id _Nullable, FlutterError *_Nullable))completion; +- (nullable NSNumber *)canGoForwardForWebViewWithIdentifier:(NSNumber *)instanceId + error: + (FlutterError *_Nullable *_Nonnull)error; +- (void)goBackForWebViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)goForwardForWebViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)reloadWebViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSString *)titleForWebViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setAllowsBackForwardForWebViewWithIdentifier:(NSNumber *)instanceId + isAllowed:(NSNumber *)allow + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setUserAgentForWebViewWithIdentifier:(NSNumber *)instanceId + userAgent:(nullable NSString *)userAgent + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)evaluateJavaScriptForWebViewWithIdentifier:(NSNumber *)instanceId + javaScriptString:(NSString *)javaScriptString + completion:(void (^)(id _Nullable, + FlutterError *_Nullable))completion; @end -extern void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKWebViewHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKUIDelegateHostApi. NSObject *FWFWKUIDelegateHostApiGetCodec(void); @@ -304,16 +427,22 @@ NSObject *FWFWKUIDelegateHostApiGetCodec(void); - (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKUIDelegateHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKHttpCookieStoreHostApi. NSObject *FWFWKHttpCookieStoreHostApiGetCodec(void); @protocol FWFWKHttpCookieStoreHostApi -- (void)createFromWebsiteDataStoreWithIdentifier:(NSNumber *)instanceId dataStoreIdentifier:(NSNumber *)websiteDataStoreInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setCookieForStoreWithIdentifier:(NSNumber *)instanceId cookie:(FWFNSHttpCookieData *)cookie completion:(void(^)(FlutterError *_Nullable))completion; +- (void)createFromWebsiteDataStoreWithIdentifier:(NSNumber *)instanceId + dataStoreIdentifier:(NSNumber *)websiteDataStoreInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setCookieForStoreWithIdentifier:(NSNumber *)instanceId + cookie:(FWFNSHttpCookieData *)cookie + completion:(void (^)(FlutterError *_Nullable))completion; @end -extern void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); NS_ASSUME_NONNULL_END diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m index 41908dbe0f6f..e18f2040bfca 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m @@ -14,26 +14,25 @@ NSDictionary *errorDict = (NSDictionary *)[NSNull null]; if (error) { errorDict = @{ - @"code": (error.code ? error.code : [NSNull null]), - @"message": (error.message ? error.message : [NSNull null]), - @"details": (error.details ? error.details : [NSNull null]), - }; + @"code" : (error.code ? error.code : [NSNull null]), + @"message" : (error.message ? error.message : [NSNull null]), + @"details" : (error.details ? error.details : [NSNull null]), + }; } return @{ - @"result": (result ? result : [NSNull null]), - @"error": errorDict, - }; + @"result" : (result ? result : [NSNull null]), + @"error" : errorDict, + }; } -static id GetNullableObject(NSDictionary* dict, id key) { +static id GetNullableObject(NSDictionary *dict, id key) { id result = dict[key]; return (result == [NSNull null]) ? nil : result; } -static id GetNullableObjectAtIndex(NSArray* array, NSInteger key) { +static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { id result = array[key]; return (result == [NSNull null]) ? nil : result; } - @interface FWFNSKeyValueObservingOptionsEnumData () + (FWFNSKeyValueObservingOptionsEnumData *)fromMap:(NSDictionary *)dict; - (NSDictionary *)toMap; @@ -69,12 +68,14 @@ - (NSDictionary *)toMap; @implementation FWFNSKeyValueObservingOptionsEnumData + (instancetype)makeWithValue:(FWFNSKeyValueObservingOptionsEnum)value { - FWFNSKeyValueObservingOptionsEnumData* pigeonResult = [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; + FWFNSKeyValueObservingOptionsEnumData *pigeonResult = + [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFNSKeyValueObservingOptionsEnumData *)fromMap:(NSDictionary *)dict { - FWFNSKeyValueObservingOptionsEnumData *pigeonResult = [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; + FWFNSKeyValueObservingOptionsEnumData *pigeonResult = + [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -85,12 +86,14 @@ - (NSDictionary *)toMap { @implementation FWFWKUserScriptInjectionTimeEnumData + (instancetype)makeWithValue:(FWFWKUserScriptInjectionTimeEnum)value { - FWFWKUserScriptInjectionTimeEnumData* pigeonResult = [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; + FWFWKUserScriptInjectionTimeEnumData *pigeonResult = + [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFWKUserScriptInjectionTimeEnumData *)fromMap:(NSDictionary *)dict { - FWFWKUserScriptInjectionTimeEnumData *pigeonResult = [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; + FWFWKUserScriptInjectionTimeEnumData *pigeonResult = + [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -101,12 +104,14 @@ - (NSDictionary *)toMap { @implementation FWFWKAudiovisualMediaTypeEnumData + (instancetype)makeWithValue:(FWFWKAudiovisualMediaTypeEnum)value { - FWFWKAudiovisualMediaTypeEnumData* pigeonResult = [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; + FWFWKAudiovisualMediaTypeEnumData *pigeonResult = + [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFWKAudiovisualMediaTypeEnumData *)fromMap:(NSDictionary *)dict { - FWFWKAudiovisualMediaTypeEnumData *pigeonResult = [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; + FWFWKAudiovisualMediaTypeEnumData *pigeonResult = + [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -117,7 +122,7 @@ - (NSDictionary *)toMap { @implementation FWFWKWebsiteDataTypeEnumData + (instancetype)makeWithValue:(FWFWKWebsiteDataTypeEnum)value { - FWFWKWebsiteDataTypeEnumData* pigeonResult = [[FWFWKWebsiteDataTypeEnumData alloc] init]; + FWFWKWebsiteDataTypeEnumData *pigeonResult = [[FWFWKWebsiteDataTypeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } @@ -133,12 +138,14 @@ - (NSDictionary *)toMap { @implementation FWFNSHttpCookiePropertyKeyEnumData + (instancetype)makeWithValue:(FWFNSHttpCookiePropertyKeyEnum)value { - FWFNSHttpCookiePropertyKeyEnumData* pigeonResult = [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; + FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = + [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFNSHttpCookiePropertyKeyEnumData *)fromMap:(NSDictionary *)dict { - FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; + FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = + [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -149,10 +156,10 @@ - (NSDictionary *)toMap { @implementation FWFNSUrlRequestData + (instancetype)makeWithUrl:(NSString *)url - httpMethod:(nullable NSString *)httpMethod - httpBody:(nullable FlutterStandardTypedData *)httpBody - allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields { - FWFNSUrlRequestData* pigeonResult = [[FWFNSUrlRequestData alloc] init]; + httpMethod:(nullable NSString *)httpMethod + httpBody:(nullable FlutterStandardTypedData *)httpBody + allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields { + FWFNSUrlRequestData *pigeonResult = [[FWFNSUrlRequestData alloc] init]; pigeonResult.url = url; pigeonResult.httpMethod = httpMethod; pigeonResult.httpBody = httpBody; @@ -170,15 +177,22 @@ + (FWFNSUrlRequestData *)fromMap:(NSDictionary *)dict { return pigeonResult; } - (NSDictionary *)toMap { - return [NSDictionary dictionaryWithObjectsAndKeys:(self.url ? self.url : [NSNull null]), @"url", (self.httpMethod ? self.httpMethod : [NSNull null]), @"httpMethod", (self.httpBody ? self.httpBody : [NSNull null]), @"httpBody", (self.allHttpHeaderFields ? self.allHttpHeaderFields : [NSNull null]), @"allHttpHeaderFields", nil]; + return [NSDictionary + dictionaryWithObjectsAndKeys:(self.url ? self.url : [NSNull null]), @"url", + (self.httpMethod ? self.httpMethod : [NSNull null]), + @"httpMethod", (self.httpBody ? self.httpBody : [NSNull null]), + @"httpBody", + (self.allHttpHeaderFields ? self.allHttpHeaderFields + : [NSNull null]), + @"allHttpHeaderFields", nil]; } @end @implementation FWFWKUserScriptData + (instancetype)makeWithSource:(NSString *)source - injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime - isMainFrameOnly:(NSNumber *)isMainFrameOnly { - FWFWKUserScriptData* pigeonResult = [[FWFWKUserScriptData alloc] init]; + injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime + isMainFrameOnly:(NSNumber *)isMainFrameOnly { + FWFWKUserScriptData *pigeonResult = [[FWFWKUserScriptData alloc] init]; pigeonResult.source = source; pigeonResult.injectionTime = injectionTime; pigeonResult.isMainFrameOnly = isMainFrameOnly; @@ -188,20 +202,27 @@ + (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 fromMap:GetNullableObject(dict, @"injectionTime")]; pigeonResult.isMainFrameOnly = GetNullableObject(dict, @"isMainFrameOnly"); NSAssert(pigeonResult.isMainFrameOnly != nil, @""); return pigeonResult; } - (NSDictionary *)toMap { - return [NSDictionary dictionaryWithObjectsAndKeys:(self.source ? self.source : [NSNull null]), @"source", (self.injectionTime ? [self.injectionTime toMap] : [NSNull null]), @"injectionTime", (self.isMainFrameOnly ? self.isMainFrameOnly : [NSNull null]), @"isMainFrameOnly", nil]; + return [NSDictionary + dictionaryWithObjectsAndKeys:(self.source ? self.source : [NSNull null]), @"source", + (self.injectionTime ? [self.injectionTime toMap] + : [NSNull null]), + @"injectionTime", + (self.isMainFrameOnly ? self.isMainFrameOnly : [NSNull null]), + @"isMainFrameOnly", nil]; } @end @implementation FWFNSHttpCookieData + (instancetype)makeWithPropertyKeys:(NSArray *)propertyKeys - propertyValues:(NSArray *)propertyValues { - FWFNSHttpCookieData* pigeonResult = [[FWFNSHttpCookieData alloc] init]; + propertyValues:(NSArray *)propertyValues { + FWFNSHttpCookieData *pigeonResult = [[FWFNSHttpCookieData alloc] init]; pigeonResult.propertyKeys = propertyKeys; pigeonResult.propertyValues = propertyValues; return pigeonResult; @@ -215,22 +236,24 @@ + (FWFNSHttpCookieData *)fromMap:(NSDictionary *)dict { return pigeonResult; } - (NSDictionary *)toMap { - return [NSDictionary dictionaryWithObjectsAndKeys:(self.propertyKeys ? self.propertyKeys : [NSNull null]), @"propertyKeys", (self.propertyValues ? self.propertyValues : [NSNull null]), @"propertyValues", nil]; + return [NSDictionary + dictionaryWithObjectsAndKeys:(self.propertyKeys ? self.propertyKeys : [NSNull null]), + @"propertyKeys", + (self.propertyValues ? self.propertyValues : [NSNull null]), + @"propertyValues", nil]; } @end @interface FWFWKWebsiteDataStoreHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebsiteDataStoreHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFWKWebsiteDataTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -238,13 +261,11 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKWebsiteDataStoreHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebsiteDataStoreHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -265,43 +286,52 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebsiteDataStoreHostApiCodecReaderWriter *readerWriter = [[FWFWKWebsiteDataStoreHostApiCodecReaderWriter alloc] init]; + FWFWKWebsiteDataStoreHostApiCodecReaderWriter *readerWriter = + [[FWFWKWebsiteDataStoreHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: + configurationIdentifier:error:)], + @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_instanceId + configurationIdentifier:arg_configurationInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createDefaultDataStoreWithIdentifier:error:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(createDefaultDataStoreWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createDefaultDataStoreWithIdentifier:error:)], + @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " + @"@selector(createDefaultDataStoreWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -309,30 +339,36 @@ void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenge [api createDefaultDataStoreWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)", api); + NSCAssert( + [api respondsToSelector:@selector + (removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)], + @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " + @"@selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSArray *arg_dataTypes = GetNullableObjectAtIndex(args, 1); NSNumber *arg_modificationTimeInSecondsSinceEpoch = GetNullableObjectAtIndex(args, 2); - [api removeDataFromDataStoreWithIdentifier:arg_instanceId ofTypes:arg_dataTypes modifiedSince:arg_modificationTimeInSecondsSinceEpoch completion:^(NSNumber *_Nullable output, FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; + [api removeDataFromDataStoreWithIdentifier:arg_instanceId + ofTypes:arg_dataTypes + modifiedSince:arg_modificationTimeInSecondsSinceEpoch + completion:^(NSNumber *_Nullable output, + FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -362,22 +398,26 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFUIViewHostApiCodecReaderWriter *readerWriter = [[FWFUIViewHostApiCodecReaderWriter alloc] init]; + FWFUIViewHostApiCodecReaderWriter *readerWriter = + [[FWFUIViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFUIViewHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFUIViewHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIViewHostApi.setBackgroundColor" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIViewHostApi.setBackgroundColor" binaryMessenger:binaryMessenger - codec:FWFUIViewHostApiGetCodec() ]; + codec:FWFUIViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setBackgroundColorForViewWithIdentifier:toValue:error:)], @"FWFUIViewHostApi api (%@) doesn't respond to @selector(setBackgroundColorForViewWithIdentifier:toValue:error:)", api); + NSCAssert([api respondsToSelector:@selector(setBackgroundColorForViewWithIdentifier: + toValue:error:)], + @"FWFUIViewHostApi api (%@) doesn't respond to " + @"@selector(setBackgroundColorForViewWithIdentifier:toValue:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -386,19 +426,20 @@ void FWFUIViewHostApiSetup(id binaryMessenger, NSObject< [api setBackgroundColorForViewWithIdentifier:arg_instanceId toValue:arg_value error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIViewHostApi.setOpaque" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIViewHostApi.setOpaque" binaryMessenger:binaryMessenger - codec:FWFUIViewHostApiGetCodec() ]; + codec:FWFUIViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)], @"FWFUIViewHostApi api (%@) doesn't respond to @selector(setOpaqueForViewWithIdentifier:isOpaque:error:)", api); + NSCAssert([api respondsToSelector:@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)], + @"FWFUIViewHostApi api (%@) doesn't respond to " + @"@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -407,8 +448,7 @@ void FWFUIViewHostApiSetup(id binaryMessenger, NSObject< [api setOpaqueForViewWithIdentifier:arg_instanceId isOpaque:arg_opaque error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -438,63 +478,72 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFUIScrollViewHostApiCodecReaderWriter *readerWriter = [[FWFUIScrollViewHostApiCodecReaderWriter alloc] init]; + FWFUIScrollViewHostApiCodecReaderWriter *readerWriter = + [[FWFUIScrollViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFUIScrollViewHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec() ]; + codec:FWFUIScrollViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier: + webViewIdentifier:error:)], + @"FWFUIScrollViewHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_webViewInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewWithIdentifier:arg_instanceId webViewIdentifier:arg_webViewInstanceId error:&error]; + [api createFromWebViewWithIdentifier:arg_instanceId + webViewIdentifier:arg_webViewInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec() ]; + codec:FWFUIScrollViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(contentOffsetForScrollViewWithIdentifier:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(contentOffsetForScrollViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(contentOffsetForScrollViewWithIdentifier:error:)], + @"FWFUIScrollViewHostApi api (%@) doesn't respond to " + @"@selector(contentOffsetForScrollViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FlutterError *error; - NSArray *output = [api contentOffsetForScrollViewWithIdentifier:arg_instanceId error:&error]; + NSArray *output = [api contentOffsetForScrollViewWithIdentifier:arg_instanceId + error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.scrollBy" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.scrollBy" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec() ]; + codec:FWFUIScrollViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(scrollByForScrollViewWithIdentifier:x:y:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(scrollByForScrollViewWithIdentifier:x:y:error:)", api); + NSCAssert([api respondsToSelector:@selector(scrollByForScrollViewWithIdentifier:x:y:error:)], + @"FWFUIScrollViewHostApi api (%@) doesn't respond to " + @"@selector(scrollByForScrollViewWithIdentifier:x:y:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -504,30 +553,34 @@ void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSO [api scrollByForScrollViewWithIdentifier:arg_instanceId x:arg_x y:arg_y error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec() ]; + codec:FWFUIScrollViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)", api); + NSCAssert([api respondsToSelector:@selector + (setContentOffsetForScrollViewWithIdentifier:toX:y:error:)], + @"FWFUIScrollViewHostApi api (%@) doesn't respond to " + @"@selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_x = GetNullableObjectAtIndex(args, 1); NSNumber *arg_y = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api setContentOffsetForScrollViewWithIdentifier:arg_instanceId toX:arg_x y:arg_y error:&error]; + [api setContentOffsetForScrollViewWithIdentifier:arg_instanceId + toX:arg_x + y:arg_y + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -535,15 +588,13 @@ void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSO @interface FWFWKWebViewConfigurationHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebViewConfigurationHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFWKAudiovisualMediaTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -551,13 +602,11 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKWebViewConfigurationHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebViewConfigurationHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -578,22 +627,25 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebViewConfigurationHostApiCodecReaderWriter *readerWriter = [[FWFWKWebViewConfigurationHostApiCodecReaderWriter alloc] init]; + FWFWKWebViewConfigurationHostApiCodecReaderWriter *readerWriter = + [[FWFWKWebViewConfigurationHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; + codec:FWFWKWebViewConfigurationHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], + @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -601,71 +653,87 @@ void FWFWKWebViewConfigurationHostApiSetup(id binaryMess [api createWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; + codec:FWFWKWebViewConfigurationHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier: + webViewIdentifier:error:)], + @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_webViewInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewWithIdentifier:arg_instanceId webViewIdentifier:arg_webViewInstanceId error:&error]; + [api createFromWebViewWithIdentifier:arg_instanceId + webViewIdentifier:arg_webViewInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; + codec:FWFWKWebViewConfigurationHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)", api); + NSCAssert( + [api respondsToSelector:@selector + (setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)], + @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " + @"@selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_allow = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:arg_instanceId isAllowed:arg_allow error:&error]; + [api setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:arg_instanceId + isAllowed:arg_allow + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi." + @"setMediaTypesRequiringUserActionForPlayback" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; + codec:FWFWKWebViewConfigurationHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:error:)", api); + NSCAssert([api respondsToSelector:@selector + (setMediaTypesRequiresUserActionForConfigurationWithIdentifier: + forTypes:error:)], + @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " + @"@selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:" + @"error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSArray *arg_types = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setMediaTypesRequiresUserActionForConfigurationWithIdentifier:arg_instanceId forTypes:arg_types error:&error]; + [api setMediaTypesRequiresUserActionForConfigurationWithIdentifier:arg_instanceId + forTypes:arg_types + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -673,18 +741,16 @@ void FWFWKWebViewConfigurationHostApiSetup(id binaryMess @interface FWFWKUserContentControllerHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKUserContentControllerHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFWKUserScriptData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFWKUserScriptInjectionTimeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -692,17 +758,14 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKUserContentControllerHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKUserContentControllerHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFWKUserScriptData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -723,86 +786,109 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKUserContentControllerHostApiCodecReaderWriter *readerWriter = [[FWFWKUserContentControllerHostApiCodecReaderWriter alloc] init]; + FWFWKUserContentControllerHostApiCodecReaderWriter *readerWriter = + [[FWFWKUserContentControllerHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: + configurationIdentifier:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_instanceId + configurationIdentifier:arg_configurationInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:ofName:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:ofName:error:)", api); + NSCAssert([api respondsToSelector:@selector + (addScriptMessageHandlerForControllerWithIdentifier: + handlerIdentifier:ofName:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:" + @"ofName:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_handlerInstanceid = GetNullableObjectAtIndex(args, 1); NSString *arg_name = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api addScriptMessageHandlerForControllerWithIdentifier:arg_instanceId handlerIdentifier:arg_handlerInstanceid ofName:arg_name error:&error]; + [api addScriptMessageHandlerForControllerWithIdentifier:arg_instanceId + handlerIdentifier:arg_handlerInstanceid + ofName:arg_name + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)", api); + NSCAssert([api respondsToSelector:@selector + (removeScriptMessageHandlerForControllerWithIdentifier:name:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_name = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api removeScriptMessageHandlerForControllerWithIdentifier:arg_instanceId name:arg_name error:&error]; + [api removeScriptMessageHandlerForControllerWithIdentifier:arg_instanceId + name:arg_name + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector + (removeAllScriptMessageHandlersForControllerWithIdentifier:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -810,40 +896,46 @@ void FWFWKUserContentControllerHostApiSetup(id binaryMes [api removeAllScriptMessageHandlersForControllerWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(addUserScriptForControllerWithIdentifier:userScript:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(addUserScriptForControllerWithIdentifier:userScript:error:)", api); + NSCAssert([api respondsToSelector:@selector(addUserScriptForControllerWithIdentifier: + userScript:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(addUserScriptForControllerWithIdentifier:userScript:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FWFWKUserScriptData *arg_userScript = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api addUserScriptForControllerWithIdentifier:arg_instanceId userScript:arg_userScript error:&error]; + [api addUserScriptForControllerWithIdentifier:arg_instanceId + userScript:arg_userScript + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeAllUserScriptsForControllerWithIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeAllUserScriptsForControllerWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector + (removeAllUserScriptsForControllerWithIdentifier:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(removeAllUserScriptsForControllerWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -851,8 +943,7 @@ void FWFWKUserContentControllerHostApiSetup(id binaryMes [api removeAllUserScriptsForControllerWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -882,53 +973,63 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKPreferencesHostApiCodecReaderWriter *readerWriter = [[FWFWKPreferencesHostApiCodecReaderWriter alloc] init]; + FWFWKPreferencesHostApiCodecReaderWriter *readerWriter = + [[FWFWKPreferencesHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKPreferencesHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKPreferencesHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKPreferencesHostApiGetCodec() ]; + codec:FWFWKPreferencesHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKPreferencesHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: + configurationIdentifier:error:)], + @"FWFWKPreferencesHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_instanceId + configurationIdentifier:arg_configurationInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled" binaryMessenger:binaryMessenger - codec:FWFWKPreferencesHostApiGetCodec() ]; + codec:FWFWKPreferencesHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)], @"FWFWKPreferencesHostApi api (%@) doesn't respond to @selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)", api); + NSCAssert([api respondsToSelector:@selector + (setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)], + @"FWFWKPreferencesHostApi api (%@) doesn't respond to " + @"@selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_enabled = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setJavaScriptEnabledForPreferencesWithIdentifier:arg_instanceId isEnabled:arg_enabled error:&error]; + [api setJavaScriptEnabledForPreferencesWithIdentifier:arg_instanceId + isEnabled:arg_enabled + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -958,22 +1059,25 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKScriptMessageHandlerHostApiCodecReaderWriter *readerWriter = [[FWFWKScriptMessageHandlerHostApiCodecReaderWriter alloc] init]; + FWFWKScriptMessageHandlerHostApiCodecReaderWriter *readerWriter = + [[FWFWKScriptMessageHandlerHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKScriptMessageHandlerHostApiGetCodec() ]; + codec:FWFWKScriptMessageHandlerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKScriptMessageHandlerHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], + @"FWFWKScriptMessageHandlerHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -981,8 +1085,7 @@ void FWFWKScriptMessageHandlerHostApiSetup(id binaryMess [api createWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -1012,32 +1115,37 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKNavigationDelegateHostApiCodecReaderWriter *readerWriter = [[FWFWKNavigationDelegateHostApiCodecReaderWriter alloc] init]; + FWFWKNavigationDelegateHostApiCodecReaderWriter *readerWriter = + [[FWFWKNavigationDelegateHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKNavigationDelegateHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKNavigationDelegateHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKNavigationDelegateHostApiGetCodec() ]; + codec:FWFWKNavigationDelegateHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:didFinishNavigationIdentifier:error:)], @"FWFWKNavigationDelegateHostApi api (%@) doesn't respond to @selector(createWithIdentifier:didFinishNavigationIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier: + didFinishNavigationIdentifier:error:)], + @"FWFWKNavigationDelegateHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:didFinishNavigationIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_didFinishNavigationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createWithIdentifier:arg_instanceId didFinishNavigationIdentifier:arg_didFinishNavigationInstanceId error:&error]; + [api createWithIdentifier:arg_instanceId + didFinishNavigationIdentifier:arg_didFinishNavigationInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -1067,15 +1175,15 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKNavigationDelegateFlutterApiCodecReaderWriter *readerWriter = [[FWFWKNavigationDelegateFlutterApiCodecReaderWriter alloc] init]; + FWFWKNavigationDelegateFlutterApiCodecReaderWriter *readerWriter = + [[FWFWKNavigationDelegateFlutterApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - @interface FWFWKNavigationDelegateFlutterApi () -@property (nonatomic, strong) NSObject *binaryMessenger; +@property(nonatomic, strong) NSObject *binaryMessenger; @end @implementation FWFWKNavigationDelegateFlutterApi @@ -1087,29 +1195,35 @@ - (instancetype)initWithBinaryMessenger:(NSObject *)bina } return self; } -- (void)didFinishNavigationFunctionWithIdentifier:(NSNumber *)arg_functionInstanceId webViewIdentifier:(NSNumber *)arg_webViewInstanceId URL:(nullable NSString *)arg_url completion:(void(^)(NSError *_Nullable))completion { - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel - messageChannelWithName:@"dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation" - binaryMessenger:self.binaryMessenger - codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; - [channel sendMessage:@[(arg_functionInstanceId == nil) ? [NSNull null] : arg_functionInstanceId, (arg_webViewInstanceId == nil) ? [NSNull null] : arg_webViewInstanceId, (arg_url == nil) ? [NSNull null] : arg_url] reply:^(id reply) { - completion(nil); - }]; +- (void)didFinishNavigationFunctionWithIdentifier:(NSNumber *)arg_functionInstanceId + webViewIdentifier:(NSNumber *)arg_webViewInstanceId + URL:(nullable NSString *)arg_url + completion:(void (^)(NSError *_Nullable))completion { + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel + messageChannelWithName: + @"dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation" + binaryMessenger:self.binaryMessenger + codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; + [channel sendMessage:@[ + (arg_functionInstanceId == nil) ? [NSNull null] : arg_functionInstanceId, + (arg_webViewInstanceId == nil) ? [NSNull null] : arg_webViewInstanceId, + (arg_url == nil) ? [NSNull null] : arg_url + ] + reply:^(id reply) { + completion(nil); + }]; } @end @interface FWFNSObjectHostApiCodecReader : FlutterStandardReader @end @implementation FWFNSObjectHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFNSKeyValueObservingOptionsEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -1117,13 +1231,11 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFNSObjectHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFNSObjectHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -1144,22 +1256,25 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFNSObjectHostApiCodecReaderWriter *readerWriter = [[FWFNSObjectHostApiCodecReaderWriter alloc] init]; + FWFNSObjectHostApiCodecReaderWriter *readerWriter = + [[FWFNSObjectHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFNSObjectHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFNSObjectHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.dispose" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.dispose" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec() ]; + codec:FWFNSObjectHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(disposeObjectWithIdentifier:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(disposeObjectWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(disposeObjectWithIdentifier:error:)], + @"FWFNSObjectHostApi api (%@) doesn't respond to " + @"@selector(disposeObjectWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1167,57 +1282,117 @@ void FWFNSObjectHostApiSetup(id binaryMessenger, NSObjec [api disposeObjectWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.addObserver" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.addObserver" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec() ]; + codec:FWFNSObjectHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:error:)", api); + NSCAssert([api respondsToSelector:@selector + (addObserverForObjectWithIdentifier: + observerIdentifier:keyPath:options:error:)], + @"FWFNSObjectHostApi api (%@) doesn't respond to " + @"@selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:" + @"error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_observerInstanceId = GetNullableObjectAtIndex(args, 1); NSString *arg_keyPath = GetNullableObjectAtIndex(args, 2); - NSArray *arg_options = GetNullableObjectAtIndex(args, 3); + NSArray *arg_options = + GetNullableObjectAtIndex(args, 3); FlutterError *error; - [api addObserverForObjectWithIdentifier:arg_instanceId observerIdentifier:arg_observerInstanceId keyPath:arg_keyPath options:arg_options error:&error]; + [api addObserverForObjectWithIdentifier:arg_instanceId + observerIdentifier:arg_observerInstanceId + keyPath:arg_keyPath + options:arg_options + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.removeObserver" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.removeObserver" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec() ]; + codec:FWFNSObjectHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(removeObserverForObjectWithIdentifier: + observerIdentifier:keyPath:error:)], + @"FWFNSObjectHostApi api (%@) doesn't respond to " + @"@selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_observerInstanceId = GetNullableObjectAtIndex(args, 1); NSString *arg_keyPath = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api removeObserverForObjectWithIdentifier:arg_instanceId observerIdentifier:arg_observerInstanceId keyPath:arg_keyPath error:&error]; + [api removeObserverForObjectWithIdentifier:arg_instanceId + observerIdentifier:arg_observerInstanceId + keyPath:arg_keyPath + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } } +@interface FWFNSObjectFlutterApiCodecReader : FlutterStandardReader +@end +@implementation FWFNSObjectFlutterApiCodecReader +@end + +@interface FWFNSObjectFlutterApiCodecWriter : FlutterStandardWriter +@end +@implementation FWFNSObjectFlutterApiCodecWriter +@end + +@interface FWFNSObjectFlutterApiCodecReaderWriter : FlutterStandardReaderWriter +@end +@implementation FWFNSObjectFlutterApiCodecReaderWriter +- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data { + return [[FWFNSObjectFlutterApiCodecWriter alloc] initWithData:data]; +} +- (FlutterStandardReader *)readerWithData:(NSData *)data { + return [[FWFNSObjectFlutterApiCodecReader alloc] initWithData:data]; +} +@end + +NSObject *FWFNSObjectFlutterApiGetCodec() { + static dispatch_once_t sPred = 0; + static FlutterStandardMessageCodec *sSharedObject = nil; + dispatch_once(&sPred, ^{ + FWFNSObjectFlutterApiCodecReaderWriter *readerWriter = + [[FWFNSObjectFlutterApiCodecReaderWriter alloc] init]; + sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; + }); + return sSharedObject; +} + +@interface FWFNSObjectFlutterApi () +@property(nonatomic, strong) NSObject *binaryMessenger; +@end + +@implementation FWFNSObjectFlutterApi + +- (instancetype)initWithBinaryMessenger:(NSObject *)binaryMessenger { + self = [super init]; + if (self) { + _binaryMessenger = binaryMessenger; + } + return self; +} +@end @interface FWFFunctionFlutterApiCodecReader : FlutterStandardReader @end @implementation FWFFunctionFlutterApiCodecReader @@ -1243,15 +1418,15 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFFunctionFlutterApiCodecReaderWriter *readerWriter = [[FWFFunctionFlutterApiCodecReaderWriter alloc] init]; + FWFFunctionFlutterApiCodecReaderWriter *readerWriter = + [[FWFFunctionFlutterApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - @interface FWFFunctionFlutterApi () -@property (nonatomic, strong) NSObject *binaryMessenger; +@property(nonatomic, strong) NSObject *binaryMessenger; @end @implementation FWFFunctionFlutterApi @@ -1263,50 +1438,49 @@ - (instancetype)initWithBinaryMessenger:(NSObject *)bina } return self; } -- (void)disposeFunctionWithIdentifier:(NSNumber *)arg_instanceId completion:(void(^)(NSError *_Nullable))completion { - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel +- (void)disposeFunctionWithIdentifier:(NSNumber *)arg_instanceId + completion:(void (^)(NSError *_Nullable))completion { + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel messageChannelWithName:@"dev.flutter.pigeon.FunctionFlutterApi.dispose" - binaryMessenger:self.binaryMessenger - codec:FWFFunctionFlutterApiGetCodec()]; - [channel sendMessage:@[(arg_instanceId == nil) ? [NSNull null] : arg_instanceId] reply:^(id reply) { - completion(nil); - }]; + binaryMessenger:self.binaryMessenger + codec:FWFFunctionFlutterApiGetCodec()]; + [channel sendMessage:@[ (arg_instanceId == nil) ? [NSNull null] : arg_instanceId ] + reply:^(id reply) { + completion(nil); + }]; } @end @interface FWFWKWebViewHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebViewHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFNSHttpCookieData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFNSHttpCookiePropertyKeyEnumData fromMap:[self readValue]]; - - case 130: + + case 130: return [FWFNSKeyValueObservingOptionsEnumData fromMap:[self readValue]]; - - case 131: + + case 131: return [FWFNSUrlRequestData fromMap:[self readValue]]; - - case 132: + + case 132: return [FWFWKAudiovisualMediaTypeEnumData fromMap:[self readValue]]; - - case 133: + + case 133: return [FWFWKUserScriptData fromMap:[self readValue]]; - - case 134: + + case 134: return [FWFWKUserScriptInjectionTimeEnumData fromMap:[self readValue]]; - - case 135: + + case 135: return [FWFWKWebsiteDataTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -1314,41 +1488,32 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKWebViewHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebViewHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFNSHttpCookieData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { + } else if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { + } else if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { [self writeByte:130]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFNSUrlRequestData class]]) { + } else if ([value isKindOfClass:[FWFNSUrlRequestData class]]) { [self writeByte:131]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { [self writeByte:132]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKUserScriptData class]]) { + } else if ([value isKindOfClass:[FWFWKUserScriptData class]]) { [self writeByte:133]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { [self writeByte:134]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { [self writeByte:135]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -1369,85 +1534,101 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebViewHostApiCodecReaderWriter *readerWriter = [[FWFWKWebViewHostApiCodecReaderWriter alloc] init]; + FWFWKWebViewHostApiCodecReaderWriter *readerWriter = + [[FWFWKWebViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKWebViewHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:configurationIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(createWithIdentifier:configurationIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier: + configurationIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:configurationIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; + [api createWithIdentifier:arg_instanceId + configurationIdentifier:arg_configurationInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(setUIDelegateForWebViewWithIdentifier: + delegateIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_uiDelegateInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setUIDelegateForWebViewWithIdentifier:arg_instanceId delegateIdentifier:arg_uiDelegateInstanceId error:&error]; + [api setUIDelegateForWebViewWithIdentifier:arg_instanceId + delegateIdentifier:arg_uiDelegateInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(setNavigationDelegateForWebViewWithIdentifier: + delegateIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_navigationDelegateInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setNavigationDelegateForWebViewWithIdentifier:arg_instanceId delegateIdentifier:arg_navigationDelegateInstanceId error:&error]; + [api setNavigationDelegateForWebViewWithIdentifier:arg_instanceId + delegateIdentifier:arg_navigationDelegateInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getUrl" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getUrl" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(URLForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(URLForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(URLForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(URLForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1455,39 +1636,44 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje NSString *output = [api URLForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(estimatedProgressForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(estimatedProgressForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(estimatedProgressForWebViewWithIdentifier: + error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(estimatedProgressForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FlutterError *error; - NSNumber *output = [api estimatedProgressForWebViewWithIdentifier:arg_instanceId error:&error]; + NSNumber *output = [api estimatedProgressForWebViewWithIdentifier:arg_instanceId + error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadRequest" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadRequest" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadRequestForWebViewWithIdentifier:request:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadRequestForWebViewWithIdentifier:request:error:)", api); + NSCAssert([api respondsToSelector:@selector(loadRequestForWebViewWithIdentifier: + request:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(loadRequestForWebViewWithIdentifier:request:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1496,63 +1682,75 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api loadRequestForWebViewWithIdentifier:arg_instanceId request:arg_request error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)", api); + NSCAssert([api respondsToSelector:@selector(loadHTMLForWebViewWithIdentifier: + HTMLString:baseURL:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_string = GetNullableObjectAtIndex(args, 1); NSString *arg_baseUrl = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api loadHTMLForWebViewWithIdentifier:arg_instanceId HTMLString:arg_string baseURL:arg_baseUrl error:&error]; + [api loadHTMLForWebViewWithIdentifier:arg_instanceId + HTMLString:arg_string + baseURL:arg_baseUrl + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)", api); + NSCAssert([api respondsToSelector:@selector + (loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_url = GetNullableObjectAtIndex(args, 1); NSString *arg_readAccessUrl = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api loadFileForWebViewWithIdentifier:arg_instanceId fileURL:arg_url readAccessURL:arg_readAccessUrl error:&error]; + [api loadFileForWebViewWithIdentifier:arg_instanceId + fileURL:arg_url + readAccessURL:arg_readAccessUrl + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadAssetForWebViewWithIdentifier:assetKey:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadAssetForWebViewWithIdentifier:assetKey:error:)", api); + NSCAssert([api respondsToSelector:@selector(loadAssetForWebViewWithIdentifier: + assetKey:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(loadAssetForWebViewWithIdentifier:assetKey:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1561,19 +1759,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api loadAssetForWebViewWithIdentifier:arg_instanceId assetKey:arg_key error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoBack" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoBack" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(canGoBackForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(canGoBackForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(canGoBackForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(canGoBackForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1581,19 +1780,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje NSNumber *output = [api canGoBackForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoForward" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoForward" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(canGoForwardForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(canGoForwardForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(canGoForwardForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(canGoForwardForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1601,19 +1801,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje NSNumber *output = [api canGoForwardForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goBack" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goBack" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(goBackForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(goBackForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(goBackForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(goBackForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1621,19 +1822,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api goBackForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goForward" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goForward" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(goForwardForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(goForwardForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(goForwardForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(goForwardForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1641,19 +1843,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api goForwardForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.reload" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.reload" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(reloadWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(reloadWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(reloadWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(reloadWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1661,19 +1864,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api reloadWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getTitle" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getTitle" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(titleForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(titleForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(titleForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(titleForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1681,71 +1885,85 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje NSString *output = [api titleForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)", api); + NSCAssert([api respondsToSelector:@selector + (setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_allow = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setAllowsBackForwardForWebViewWithIdentifier:arg_instanceId isAllowed:arg_allow error:&error]; + [api setAllowsBackForwardForWebViewWithIdentifier:arg_instanceId + isAllowed:arg_allow + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)", api); + NSCAssert([api respondsToSelector:@selector(setUserAgentForWebViewWithIdentifier: + userAgent:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_userAgent = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setUserAgentForWebViewWithIdentifier:arg_instanceId userAgent:arg_userAgent error:&error]; + [api setUserAgentForWebViewWithIdentifier:arg_instanceId + userAgent:arg_userAgent + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)", api); + NSCAssert( + [api respondsToSelector:@selector + (evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_javaScriptString = GetNullableObjectAtIndex(args, 1); - [api evaluateJavaScriptForWebViewWithIdentifier:arg_instanceId javaScriptString:arg_javaScriptString completion:^(id _Nullable output, FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; + [api evaluateJavaScriptForWebViewWithIdentifier:arg_instanceId + javaScriptString:arg_javaScriptString + completion:^(id _Nullable output, + FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -1775,22 +1993,25 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKUIDelegateHostApiCodecReaderWriter *readerWriter = [[FWFWKUIDelegateHostApiCodecReaderWriter alloc] init]; + FWFWKUIDelegateHostApiCodecReaderWriter *readerWriter = + [[FWFWKUIDelegateHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKUIDelegateHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUIDelegateHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUIDelegateHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKUIDelegateHostApiGetCodec() ]; + codec:FWFWKUIDelegateHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKUIDelegateHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], + @"FWFWKUIDelegateHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1798,8 +2019,7 @@ void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSO [api createWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -1807,18 +2027,16 @@ void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSO @interface FWFWKHttpCookieStoreHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKHttpCookieStoreHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFNSHttpCookieData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFNSHttpCookiePropertyKeyEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -1826,17 +2044,14 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKHttpCookieStoreHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKHttpCookieStoreHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFNSHttpCookieData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { + } else if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -1857,53 +2072,62 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKHttpCookieStoreHostApiCodecReaderWriter *readerWriter = [[FWFWKHttpCookieStoreHostApiCodecReaderWriter alloc] init]; + FWFWKHttpCookieStoreHostApiCodecReaderWriter *readerWriter = + [[FWFWKHttpCookieStoreHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore" binaryMessenger:binaryMessenger - codec:FWFWKHttpCookieStoreHostApiGetCodec() ]; + codec:FWFWKHttpCookieStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)], @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to @selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createFromWebsiteDataStoreWithIdentifier: + dataStoreIdentifier:error:)], + @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to " + @"@selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_websiteDataStoreInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebsiteDataStoreWithIdentifier:arg_instanceId dataStoreIdentifier:arg_websiteDataStoreInstanceId error:&error]; + [api createFromWebsiteDataStoreWithIdentifier:arg_instanceId + dataStoreIdentifier:arg_websiteDataStoreInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie" binaryMessenger:binaryMessenger - codec:FWFWKHttpCookieStoreHostApiGetCodec() ]; + codec:FWFWKHttpCookieStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setCookieForStoreWithIdentifier:cookie:completion:)], @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to @selector(setCookieForStoreWithIdentifier:cookie:completion:)", api); + NSCAssert([api respondsToSelector:@selector(setCookieForStoreWithIdentifier: + cookie:completion:)], + @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to " + @"@selector(setCookieForStoreWithIdentifier:cookie:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FWFNSHttpCookieData *arg_cookie = GetNullableObjectAtIndex(args, 1); - [api setCookieForStoreWithIdentifier:arg_instanceId cookie:arg_cookie completion:^(FlutterError *_Nullable error) { - callback(wrapResult(nil, error)); - }]; + [api setCookieForStoreWithIdentifier:arg_instanceId + cookie:arg_cookie + completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; }]; - } - else { + } else { [channel setMessageHandler:nil]; } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h index fca1e83c86e0..fd197b11a100 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h @@ -7,13 +7,20 @@ #import "FWFGeneratedWebKitApis.h" #import "FWFInstanceManager.h" +#import "FWFObjectHostApi.h" NS_ASSUME_NONNULL_BEGIN +@interface FWFNavigationDelegateFlutterApiImpl : FWFWKNavigationDelegateFlutterApi +- (instancetype)initWithBinaryMessenger:(id)binaryMessenger + instanceManager:(FWFInstanceManager *)instanceManager; +@end + /** * Implementation of WKNavigationDelegate for FWFNavigationDelegateHostApiImpl. */ -@interface FWFNavigationDelegate : NSObject +@interface FWFNavigationDelegate : FWFObject +@property(readonly, nonnull) FWFNavigationDelegateFlutterApiImpl *navigationDelegateApi; @end /** @@ -22,7 +29,8 @@ NS_ASSUME_NONNULL_BEGIN * Handles creating WKNavigationDelegate that intercommunicate with a paired Dart object. */ @interface FWFNavigationDelegateHostApiImpl : NSObject -- (instancetype)initWithInstanceManager:(FWFInstanceManager *)instanceManager; +- (instancetype)initWithBinaryMessenger:(id)binaryMessenger + instanceManager:(FWFInstanceManager *)instanceManager; @end NS_ASSUME_NONNULL_END diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m index 188d83ff81b6..609c40aac991 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m @@ -5,17 +5,77 @@ #import "FWFNavigationDelegateHostApi.h" #import "FWFWebViewConfigurationHostApi.h" +@interface FWFNavigationDelegateFlutterApiImpl () +@property(nonatomic, weak) FWFInstanceManager *instanceManager; +@end + +@implementation FWFNavigationDelegateFlutterApiImpl +- (instancetype)initWithBinaryMessenger:(id)binaryMessenger + instanceManager:(FWFInstanceManager *)instanceManager { + self = [self initWithBinaryMessenger:binaryMessenger]; + if (self) { + _instanceManager = instanceManager; + } + return self; +} + +- (void)didFinishNavigationFunction:(void (^)(WKWebView *, NSString *))function + webView:(WKWebView *)webView + URL:(NSString *)URL { + long functionIdentifier = [self.instanceManager identifierForInstance:function]; + if (functionIdentifier != NSNotFound) { + [self didFinishNavigationFunctionWithIdentifier:@(functionIdentifier) + webViewIdentifier:@([self.instanceManager + identifierForInstance:webView]) + URL:URL + completion:^(NSError *error) { + if (error) { + NSLog(@"%@", error.description); + } + }]; + } +} +@end + +@interface FWFNavigationDelegate () +@property void (^didFinishNavigation)(WKWebView *, NSString *); +@end + @implementation FWFNavigationDelegate +- (instancetype)initWithBinaryMessenger:(id)binaryMessenger + instanceManager:(FWFInstanceManager *)instanceManager { + self = [super initWithBinaryMessenger:binaryMessenger instanceManager:instanceManager]; + if (self) { + _navigationDelegateApi = + [[FWFNavigationDelegateFlutterApiImpl alloc] initWithBinaryMessenger:binaryMessenger + instanceManager:instanceManager]; + + FWFNavigationDelegate __weak __block *weakSelf = self; + _didFinishNavigation = ^(WKWebView *webView, NSString *URL) { + [weakSelf.navigationDelegateApi didFinishNavigationFunction:weakSelf.didFinishNavigation + webView:webView + URL:URL]; + }; + } + return self; +} + +- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { + self.didFinishNavigation(webView, webView.URL.absoluteString); +} @end @interface FWFNavigationDelegateHostApiImpl () -@property(nonatomic) FWFInstanceManager *instanceManager; +@property(weak) id binaryMessenger; +@property(nonatomic, weak) FWFInstanceManager *instanceManager; @end @implementation FWFNavigationDelegateHostApiImpl -- (instancetype)initWithInstanceManager:(FWFInstanceManager *)instanceManager { +- (instancetype)initWithBinaryMessenger:(id)binaryMessenger + instanceManager:(FWFInstanceManager *)instanceManager { self = [self init]; if (self) { + _binaryMessenger = binaryMessenger; _instanceManager = instanceManager; } return self; @@ -26,15 +86,15 @@ - (FWFNavigationDelegate *)navigationDelegateForIdentifier:(NSNumber *)instanceI } - (void)createWithIdentifier:(nonnull NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error { - FWFNavigationDelegate *navigationDelegate = [[FWFNavigationDelegate alloc] init]; + didFinishNavigationIdentifier:(nullable NSNumber *)didFinishNavigationInstanceId + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + FWFNavigationDelegate *navigationDelegate = + [[FWFNavigationDelegate alloc] initWithBinaryMessenger:self.binaryMessenger + instanceManager:self.instanceManager]; [self.instanceManager addInstance:navigationDelegate withIdentifier:instanceId.longValue]; -} - -- (void)setDidFinishNavigationForDelegateWithIdentifier:(nonnull NSNumber *)instanceId - functionIdentifier:(nullable NSNumber *)functionInstanceId - error:(FlutterError *_Nullable __autoreleasing - *_Nonnull)error { - // TODO(bparrishMines): Implement when callback method design is finalized. + if (didFinishNavigationInstanceId) { + [self.instanceManager addInstance:navigationDelegate.didFinishNavigation + withIdentifier:didFinishNavigationInstanceId.longValue]; + } } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.h index 23c38fbe482d..c1cf6ed62ce9 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.h @@ -9,6 +9,17 @@ NS_ASSUME_NONNULL_BEGIN +@interface FWFObjectFlutterApi : FWFNSObjectFlutterApi +- (instancetype)initWithBinaryMessenger:(id)binaryMessenger + instanceManager:(FWFInstanceManager *)instanceManager; +@end + +@interface FWFObject : NSObject +@property(readonly, nonnull) FWFObjectFlutterApi *objectApi; +- (instancetype)initWithBinaryMessenger:(id)binaryMessenger + instanceManager:(FWFInstanceManager *)instanceManager; +@end + /** * Host api implementation for NSObject. * diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m index b229c2e819a9..6065d382c646 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m @@ -5,8 +5,35 @@ #import "FWFObjectHostApi.h" #import "FWFDataConverters.h" +@interface FWFObjectFlutterApi () +@property(nonatomic, weak) FWFInstanceManager *instanceManager; +@end + +@implementation FWFObjectFlutterApi +- (instancetype)initWithBinaryMessenger:(id)binaryMessenger + instanceManager:(FWFInstanceManager *)instanceManager { + self = [self initWithBinaryMessenger:binaryMessenger]; + if (self) { + _instanceManager = instanceManager; + } + return self; +} +@end + +@implementation FWFObject +- (instancetype)initWithBinaryMessenger:(id)binaryMessenger + instanceManager:(FWFInstanceManager *)instanceManager { + self = [self init]; + if (self) { + _objectApi = [[FWFObjectFlutterApi alloc] initWithBinaryMessenger:binaryMessenger + instanceManager:instanceManager]; + } + return self; +} +@end + @interface FWFObjectHostApiImpl () -@property(nonatomic) FWFInstanceManager *instanceManager; +@property(nonatomic, weak) FWFInstanceManager *instanceManager; @end @implementation FWFObjectHostApiImpl diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart index a6e881e29d0b..fae0096a0f43 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart @@ -94,8 +94,7 @@ class NSKeyValueObservingOptionsEnumData { static NSKeyValueObservingOptionsEnumData decode(Object message) { final Map pigeonMap = message as Map; return NSKeyValueObservingOptionsEnumData( - value: NSKeyValueObservingOptionsEnum.values[pigeonMap['value']! as int] -, + value: NSKeyValueObservingOptionsEnum.values[pigeonMap['value']! as int], ); } } @@ -116,8 +115,7 @@ class WKUserScriptInjectionTimeEnumData { static WKUserScriptInjectionTimeEnumData decode(Object message) { final Map pigeonMap = message as Map; return WKUserScriptInjectionTimeEnumData( - value: WKUserScriptInjectionTimeEnum.values[pigeonMap['value']! as int] -, + value: WKUserScriptInjectionTimeEnum.values[pigeonMap['value']! as int], ); } } @@ -138,8 +136,7 @@ class WKAudiovisualMediaTypeEnumData { static WKAudiovisualMediaTypeEnumData decode(Object message) { final Map pigeonMap = message as Map; return WKAudiovisualMediaTypeEnumData( - value: WKAudiovisualMediaTypeEnum.values[pigeonMap['value']! as int] -, + value: WKAudiovisualMediaTypeEnum.values[pigeonMap['value']! as int], ); } } @@ -160,8 +157,7 @@ class WKWebsiteDataTypeEnumData { static WKWebsiteDataTypeEnumData decode(Object message) { final Map pigeonMap = message as Map; return WKWebsiteDataTypeEnumData( - value: WKWebsiteDataTypeEnum.values[pigeonMap['value']! as int] -, + value: WKWebsiteDataTypeEnum.values[pigeonMap['value']! as int], ); } } @@ -182,8 +178,7 @@ class NSHttpCookiePropertyKeyEnumData { static NSHttpCookiePropertyKeyEnumData decode(Object message) { final Map pigeonMap = message as Map; return NSHttpCookiePropertyKeyEnumData( - value: NSHttpCookiePropertyKeyEnum.values[pigeonMap['value']! as int] -, + value: NSHttpCookiePropertyKeyEnum.values[pigeonMap['value']! as int], ); } } @@ -216,7 +211,9 @@ class NSUrlRequestData { url: pigeonMap['url']! as String, httpMethod: pigeonMap['httpMethod'] as String?, httpBody: pigeonMap['httpBody'] as Uint8List?, - allHttpHeaderFields: (pigeonMap['allHttpHeaderFields'] as Map?)!.cast(), + allHttpHeaderFields: + (pigeonMap['allHttpHeaderFields'] as Map?)! + .cast(), ); } } @@ -245,7 +242,8 @@ class WKUserScriptData { return WKUserScriptData( source: pigeonMap['source']! as String, injectionTime: pigeonMap['injectionTime'] != null - ? WKUserScriptInjectionTimeEnumData.decode(pigeonMap['injectionTime']!) + ? WKUserScriptInjectionTimeEnumData.decode( + pigeonMap['injectionTime']!) : null, isMainFrameOnly: pigeonMap['isMainFrameOnly']! as bool, ); @@ -271,8 +269,10 @@ class NSHttpCookieData { static NSHttpCookieData decode(Object message) { final Map pigeonMap = message as Map; return NSHttpCookieData( - propertyKeys: (pigeonMap['propertyKeys'] as List?)!.cast(), - propertyValues: (pigeonMap['propertyValues'] as List?)!.cast(), + propertyKeys: (pigeonMap['propertyKeys'] as List?)! + .cast(), + propertyValues: + (pigeonMap['propertyValues'] as List?)!.cast(), ); } } @@ -284,20 +284,19 @@ class _WKWebsiteDataStoreHostApiCodec extends StandardMessageCodec { if (value is WKWebsiteDataTypeEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKWebsiteDataTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } @@ -306,24 +305,30 @@ class WKWebsiteDataStoreHostApi { /// Constructor for [WKWebsiteDataStoreHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKWebsiteDataStoreHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKWebsiteDataStoreHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _WKWebsiteDataStoreHostApiCodec(); - Future createFromWebViewConfiguration(int arg_instanceId, int arg_configurationInstanceId) async { + Future createFromWebViewConfiguration( + int arg_instanceId, int arg_configurationInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_configurationInstanceId]) as Map?; + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_configurationInstanceId]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -336,7 +341,9 @@ class WKWebsiteDataStoreHostApi { Future createDefaultDataStore(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore', + codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -345,7 +352,8 @@ class WKWebsiteDataStoreHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -356,18 +364,26 @@ class WKWebsiteDataStoreHostApi { } } - Future removeDataOfTypes(int arg_instanceId, List arg_dataTypes, double arg_modificationTimeInSecondsSinceEpoch) async { + Future removeDataOfTypes( + int arg_instanceId, + List arg_dataTypes, + double arg_modificationTimeInSecondsSinceEpoch) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_dataTypes, arg_modificationTimeInSecondsSinceEpoch]) as Map?; + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel.send([ + arg_instanceId, + arg_dataTypes, + arg_modificationTimeInSecondsSinceEpoch + ]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -392,7 +408,8 @@ class UIViewHostApi { /// Constructor for [UIViewHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - UIViewHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + UIViewHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; @@ -400,16 +417,18 @@ class UIViewHostApi { Future setBackgroundColor(int arg_instanceId, int? arg_value) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIViewHostApi.setBackgroundColor', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_value]) as Map?; + 'dev.flutter.pigeon.UIViewHostApi.setBackgroundColor', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_value]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -422,16 +441,18 @@ class UIViewHostApi { Future setOpaque(int arg_instanceId, bool arg_opaque) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIViewHostApi.setOpaque', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_opaque]) as Map?; + 'dev.flutter.pigeon.UIViewHostApi.setOpaque', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_opaque]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -451,24 +472,29 @@ class UIScrollViewHostApi { /// Constructor for [UIScrollViewHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - UIScrollViewHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + UIScrollViewHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _UIScrollViewHostApiCodec(); - Future createFromWebView(int arg_instanceId, int arg_webViewInstanceId) async { + Future createFromWebView( + int arg_instanceId, int arg_webViewInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_webViewInstanceId]) as Map?; + await channel.send([arg_instanceId, arg_webViewInstanceId]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -481,7 +507,8 @@ class UIScrollViewHostApi { Future> getContentOffset(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -490,7 +517,8 @@ class UIScrollViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -508,16 +536,19 @@ class UIScrollViewHostApi { Future scrollBy(int arg_instanceId, double arg_x, double arg_y) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.scrollBy', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.scrollBy', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_x, arg_y]) as Map?; + await channel.send([arg_instanceId, arg_x, arg_y]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -528,18 +559,22 @@ class UIScrollViewHostApi { } } - Future setContentOffset(int arg_instanceId, double arg_x, double arg_y) async { + Future setContentOffset( + int arg_instanceId, double arg_x, double arg_y) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_x, arg_y]) as Map?; + await channel.send([arg_instanceId, arg_x, arg_y]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -558,20 +593,19 @@ class _WKWebViewConfigurationHostApiCodec extends StandardMessageCodec { if (value is WKAudiovisualMediaTypeEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } @@ -580,15 +614,18 @@ class WKWebViewConfigurationHostApi { /// Constructor for [WKWebViewConfigurationHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKWebViewConfigurationHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKWebViewConfigurationHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; - static const MessageCodec codec = _WKWebViewConfigurationHostApiCodec(); + static const MessageCodec codec = + _WKWebViewConfigurationHostApiCodec(); Future create(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.create', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.create', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -597,7 +634,8 @@ class WKWebViewConfigurationHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -608,18 +646,23 @@ class WKWebViewConfigurationHostApi { } } - Future createFromWebView(int arg_instanceId, int arg_webViewInstanceId) async { + Future createFromWebView( + int arg_instanceId, int arg_webViewInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView', + codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_webViewInstanceId]) as Map?; + await channel.send([arg_instanceId, arg_webViewInstanceId]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -630,18 +673,22 @@ class WKWebViewConfigurationHostApi { } } - Future setAllowsInlineMediaPlayback(int arg_instanceId, bool arg_allow) async { + Future setAllowsInlineMediaPlayback( + int arg_instanceId, bool arg_allow) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_allow]) as Map?; + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_allow]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -652,18 +699,22 @@ class WKWebViewConfigurationHostApi { } } - Future setMediaTypesRequiringUserActionForPlayback(int arg_instanceId, List arg_types) async { + Future setMediaTypesRequiringUserActionForPlayback(int arg_instanceId, + List arg_types) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_types]) as Map?; + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_types]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -682,27 +733,25 @@ class _WKUserContentControllerHostApiCodec extends StandardMessageCodec { if (value is WKUserScriptData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else - if (value is WKUserScriptInjectionTimeEnumData) { + } else if (value is WKUserScriptInjectionTimeEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKUserScriptData.decode(readValue(buffer)!); - - case 129: + + case 129: return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } @@ -711,24 +760,31 @@ class WKUserContentControllerHostApi { /// Constructor for [WKUserContentControllerHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKUserContentControllerHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKUserContentControllerHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; - static const MessageCodec codec = _WKUserContentControllerHostApiCodec(); + static const MessageCodec codec = + _WKUserContentControllerHostApiCodec(); - Future createFromWebViewConfiguration(int arg_instanceId, int arg_configurationInstanceId) async { + Future createFromWebViewConfiguration( + int arg_instanceId, int arg_configurationInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_configurationInstanceId]) as Map?; + 'dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_configurationInstanceId]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -739,18 +795,23 @@ class WKUserContentControllerHostApi { } } - Future addScriptMessageHandler(int arg_instanceId, int arg_handlerInstanceid, String arg_name) async { + Future addScriptMessageHandler( + int arg_instanceId, int arg_handlerInstanceid, String arg_name) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_handlerInstanceid, arg_name]) as Map?; + 'dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_handlerInstanceid, arg_name]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -761,18 +822,22 @@ class WKUserContentControllerHostApi { } } - Future removeScriptMessageHandler(int arg_instanceId, String arg_name) async { + Future removeScriptMessageHandler( + int arg_instanceId, String arg_name) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_name]) as Map?; + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_name]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -785,7 +850,9 @@ class WKUserContentControllerHostApi { Future removeAllScriptMessageHandlers(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers', + codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -794,7 +861,8 @@ class WKUserContentControllerHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -805,18 +873,23 @@ class WKUserContentControllerHostApi { } } - Future addUserScript(int arg_instanceId, WKUserScriptData arg_userScript) async { + Future addUserScript( + int arg_instanceId, WKUserScriptData arg_userScript) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript', + codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_userScript]) as Map?; + await channel.send([arg_instanceId, arg_userScript]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -829,7 +902,9 @@ class WKUserContentControllerHostApi { Future removeAllUserScripts(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts', + codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -838,7 +913,8 @@ class WKUserContentControllerHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -858,24 +934,30 @@ class WKPreferencesHostApi { /// Constructor for [WKPreferencesHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKPreferencesHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKPreferencesHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _WKPreferencesHostApiCodec(); - Future createFromWebViewConfiguration(int arg_instanceId, int arg_configurationInstanceId) async { + Future createFromWebViewConfiguration( + int arg_instanceId, int arg_configurationInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_configurationInstanceId]) as Map?; + 'dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_configurationInstanceId]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -886,18 +968,21 @@ class WKPreferencesHostApi { } } - Future setJavaScriptEnabled(int arg_instanceId, bool arg_enabled) async { + Future setJavaScriptEnabled( + int arg_instanceId, bool arg_enabled) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_enabled]) as Map?; + 'dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_enabled]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -917,15 +1002,18 @@ class WKScriptMessageHandlerHostApi { /// Constructor for [WKScriptMessageHandlerHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKScriptMessageHandlerHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKScriptMessageHandlerHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; - static const MessageCodec codec = _WKScriptMessageHandlerHostApiCodec(); + static const MessageCodec codec = + _WKScriptMessageHandlerHostApiCodec(); Future create(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -934,7 +1022,8 @@ class WKScriptMessageHandlerHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -954,24 +1043,30 @@ class WKNavigationDelegateHostApi { /// Constructor for [WKNavigationDelegateHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKNavigationDelegateHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKNavigationDelegateHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; - static const MessageCodec codec = _WKNavigationDelegateHostApiCodec(); + static const MessageCodec codec = + _WKNavigationDelegateHostApiCodec(); - Future create(int arg_instanceId, int? arg_didFinishNavigationInstanceId) async { + Future create( + int arg_instanceId, int? arg_didFinishNavigationInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKNavigationDelegateHostApi.create', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_didFinishNavigationInstanceId]) as Map?; + 'dev.flutter.pigeon.WKNavigationDelegateHostApi.create', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_didFinishNavigationInstanceId]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -986,26 +1081,36 @@ class WKNavigationDelegateHostApi { class _WKNavigationDelegateFlutterApiCodec extends StandardMessageCodec { const _WKNavigationDelegateFlutterApiCodec(); } + abstract class WKNavigationDelegateFlutterApi { - static const MessageCodec codec = _WKNavigationDelegateFlutterApiCodec(); + static const MessageCodec codec = + _WKNavigationDelegateFlutterApiCodec(); - void didFinishNavigation(int functionInstanceId, int webViewInstanceId, String? url); - static void setup(WKNavigationDelegateFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + void didFinishNavigation( + int functionInstanceId, int webViewInstanceId, String? url); + static void setup(WKNavigationDelegateFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMessageHandler(null); } else { channel.setMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null.'); final List args = (message as List?)!; final int? arg_functionInstanceId = (args[0] as int?); - assert(arg_functionInstanceId != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null, expected non-null int.'); + assert(arg_functionInstanceId != null, + 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null, expected non-null int.'); final int? arg_webViewInstanceId = (args[1] as int?); - assert(arg_webViewInstanceId != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null, expected non-null int.'); + assert(arg_webViewInstanceId != null, + 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null, expected non-null int.'); final String? arg_url = (args[2] as String?); - api.didFinishNavigation(arg_functionInstanceId!, arg_webViewInstanceId!, arg_url); + api.didFinishNavigation( + arg_functionInstanceId!, arg_webViewInstanceId!, arg_url); return; }); } @@ -1020,20 +1125,19 @@ class _NSObjectHostApiCodec extends StandardMessageCodec { if (value is NSKeyValueObservingOptionsEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } @@ -1042,7 +1146,8 @@ class NSObjectHostApi { /// Constructor for [NSObjectHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - NSObjectHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + NSObjectHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; @@ -1050,7 +1155,8 @@ class NSObjectHostApi { Future dispose(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.dispose', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.NSObjectHostApi.dispose', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1059,7 +1165,8 @@ class NSObjectHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1070,18 +1177,28 @@ class NSObjectHostApi { } } - Future addObserver(int arg_instanceId, int arg_observerInstanceId, String arg_keyPath, List arg_options) async { + Future addObserver( + int arg_instanceId, + int arg_observerInstanceId, + String arg_keyPath, + List arg_options) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.addObserver', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_observerInstanceId, arg_keyPath, arg_options]) as Map?; + 'dev.flutter.pigeon.NSObjectHostApi.addObserver', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel.send([ + arg_instanceId, + arg_observerInstanceId, + arg_keyPath, + arg_options + ]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1092,18 +1209,22 @@ class NSObjectHostApi { } } - Future removeObserver(int arg_instanceId, int arg_observerInstanceId, String arg_keyPath) async { + Future removeObserver(int arg_instanceId, int arg_observerInstanceId, + String arg_keyPath) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.removeObserver', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_observerInstanceId, arg_keyPath]) as Map?; + 'dev.flutter.pigeon.NSObjectHostApi.removeObserver', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel.send( + [arg_instanceId, arg_observerInstanceId, arg_keyPath]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1115,25 +1236,41 @@ class NSObjectHostApi { } } +class _NSObjectFlutterApiCodec extends StandardMessageCodec { + const _NSObjectFlutterApiCodec(); +} + +abstract class NSObjectFlutterApi { + static const MessageCodec codec = _NSObjectFlutterApiCodec(); + + static void setup(NSObjectFlutterApi? api, + {BinaryMessenger? binaryMessenger}) {} +} + class _FunctionFlutterApiCodec extends StandardMessageCodec { const _FunctionFlutterApiCodec(); } + abstract class FunctionFlutterApi { static const MessageCodec codec = _FunctionFlutterApiCodec(); void dispose(int instanceId); - static void setup(FunctionFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(FunctionFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.FunctionFlutterApi.dispose', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.FunctionFlutterApi.dispose', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMessageHandler(null); } else { channel.setMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.FunctionFlutterApi.dispose was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.FunctionFlutterApi.dispose was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.FunctionFlutterApi.dispose was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.FunctionFlutterApi.dispose was null, expected non-null int.'); api.dispose(arg_instanceId!); return; }); @@ -1149,69 +1286,61 @@ class _WKWebViewHostApiCodec extends StandardMessageCodec { if (value is NSHttpCookieData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else - if (value is NSHttpCookiePropertyKeyEnumData) { + } else if (value is NSHttpCookiePropertyKeyEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else - if (value is NSKeyValueObservingOptionsEnumData) { + } else if (value is NSKeyValueObservingOptionsEnumData) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else - if (value is NSUrlRequestData) { + } else if (value is NSUrlRequestData) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else - if (value is WKAudiovisualMediaTypeEnumData) { + } else if (value is WKAudiovisualMediaTypeEnumData) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else - if (value is WKUserScriptData) { + } else if (value is WKUserScriptData) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else - if (value is WKUserScriptInjectionTimeEnumData) { + } else if (value is WKUserScriptInjectionTimeEnumData) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else - if (value is WKWebsiteDataTypeEnumData) { + } else if (value is WKWebsiteDataTypeEnumData) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSHttpCookieData.decode(readValue(buffer)!); - - case 129: + + case 129: return NSHttpCookiePropertyKeyEnumData.decode(readValue(buffer)!); - - case 130: + + case 130: return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); - - case 131: + + case 131: return NSUrlRequestData.decode(readValue(buffer)!); - - case 132: + + case 132: return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); - - case 133: + + case 133: return WKUserScriptData.decode(readValue(buffer)!); - - case 134: + + case 134: return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); - - case 135: + + case 135: return WKWebsiteDataTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } @@ -1220,24 +1349,29 @@ class WKWebViewHostApi { /// Constructor for [WKWebViewHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKWebViewHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKWebViewHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _WKWebViewHostApiCodec(); - Future create(int arg_instanceId, int arg_configurationInstanceId) async { + Future create( + int arg_instanceId, int arg_configurationInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.create', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_configurationInstanceId]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.create', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_configurationInstanceId]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1248,18 +1382,22 @@ class WKWebViewHostApi { } } - Future setUIDelegate(int arg_instanceId, int? arg_uiDelegateInstanceId) async { + Future setUIDelegate( + int arg_instanceId, int? arg_uiDelegateInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_uiDelegateInstanceId]) as Map?; + await channel.send([arg_instanceId, arg_uiDelegateInstanceId]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1270,18 +1408,22 @@ class WKWebViewHostApi { } } - Future setNavigationDelegate(int arg_instanceId, int? arg_navigationDelegateInstanceId) async { + Future setNavigationDelegate( + int arg_instanceId, int? arg_navigationDelegateInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_navigationDelegateInstanceId]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_navigationDelegateInstanceId]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1294,7 +1436,8 @@ class WKWebViewHostApi { Future getUrl(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getUrl', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getUrl', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1303,7 +1446,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1316,7 +1460,8 @@ class WKWebViewHostApi { Future getEstimatedProgress(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1325,7 +1470,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1341,18 +1487,21 @@ class WKWebViewHostApi { } } - Future loadRequest(int arg_instanceId, NSUrlRequestData arg_request) async { + Future loadRequest( + int arg_instanceId, NSUrlRequestData arg_request) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadRequest', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_request]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.loadRequest', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_request]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1363,18 +1512,22 @@ class WKWebViewHostApi { } } - Future loadHtmlString(int arg_instanceId, String arg_string, String? arg_baseUrl) async { + Future loadHtmlString( + int arg_instanceId, String arg_string, String? arg_baseUrl) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_string, arg_baseUrl]) as Map?; + await channel.send([arg_instanceId, arg_string, arg_baseUrl]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1385,18 +1538,22 @@ class WKWebViewHostApi { } } - Future loadFileUrl(int arg_instanceId, String arg_url, String arg_readAccessUrl) async { + Future loadFileUrl( + int arg_instanceId, String arg_url, String arg_readAccessUrl) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_url, arg_readAccessUrl]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_url, arg_readAccessUrl]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1409,16 +1566,18 @@ class WKWebViewHostApi { Future loadFlutterAsset(int arg_instanceId, String arg_key) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_key]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_key]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1431,7 +1590,8 @@ class WKWebViewHostApi { Future canGoBack(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.canGoBack', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.canGoBack', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1440,7 +1600,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1458,7 +1619,8 @@ class WKWebViewHostApi { Future canGoForward(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.canGoForward', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.canGoForward', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1467,7 +1629,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1485,7 +1648,8 @@ class WKWebViewHostApi { Future goBack(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.goBack', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.goBack', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1494,7 +1658,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1507,7 +1672,8 @@ class WKWebViewHostApi { Future goForward(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.goForward', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.goForward', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1516,7 +1682,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1529,7 +1696,8 @@ class WKWebViewHostApi { Future reload(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.reload', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.reload', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1538,7 +1706,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1551,7 +1720,8 @@ class WKWebViewHostApi { Future getTitle(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getTitle', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getTitle', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1560,7 +1730,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1571,18 +1742,22 @@ class WKWebViewHostApi { } } - Future setAllowsBackForwardNavigationGestures(int arg_instanceId, bool arg_allow) async { + Future setAllowsBackForwardNavigationGestures( + int arg_instanceId, bool arg_allow) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_allow]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_allow]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1593,18 +1768,22 @@ class WKWebViewHostApi { } } - Future setCustomUserAgent(int arg_instanceId, String? arg_userAgent) async { + Future setCustomUserAgent( + int arg_instanceId, String? arg_userAgent) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_userAgent]) as Map?; + await channel.send([arg_instanceId, arg_userAgent]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1615,18 +1794,22 @@ class WKWebViewHostApi { } } - Future evaluateJavaScript(int arg_instanceId, String arg_javaScriptString) async { + Future evaluateJavaScript( + int arg_instanceId, String arg_javaScriptString) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_instanceId, arg_javaScriptString]) as Map?; + await channel.send([arg_instanceId, arg_javaScriptString]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1646,7 +1829,8 @@ class WKUIDelegateHostApi { /// Constructor for [WKUIDelegateHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKUIDelegateHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKUIDelegateHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; @@ -1654,7 +1838,8 @@ class WKUIDelegateHostApi { Future create(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUIDelegateHostApi.create', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKUIDelegateHostApi.create', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { @@ -1663,7 +1848,8 @@ class WKUIDelegateHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1682,27 +1868,25 @@ class _WKHttpCookieStoreHostApiCodec extends StandardMessageCodec { if (value is NSHttpCookieData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else - if (value is NSHttpCookiePropertyKeyEnumData) { + } else if (value is NSHttpCookiePropertyKeyEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSHttpCookieData.decode(readValue(buffer)!); - - case 129: + + case 129: return NSHttpCookiePropertyKeyEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } @@ -1711,24 +1895,30 @@ class WKHttpCookieStoreHostApi { /// Constructor for [WKHttpCookieStoreHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKHttpCookieStoreHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKHttpCookieStoreHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _WKHttpCookieStoreHostApiCodec(); - Future createFromWebsiteDataStore(int arg_instanceId, int arg_websiteDataStoreInstanceId) async { + Future createFromWebsiteDataStore( + int arg_instanceId, int arg_websiteDataStoreInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_websiteDataStoreInstanceId]) as Map?; + 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_websiteDataStoreInstanceId]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1739,18 +1929,21 @@ class WKHttpCookieStoreHostApi { } } - Future setCookie(int arg_instanceId, NSHttpCookieData arg_cookie) async { + Future setCookie( + int arg_instanceId, NSHttpCookieData arg_cookie) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_instanceId, arg_cookie]) as Map?; + 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_instanceId, arg_cookie]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart index 9251a993d58a..33f553f9e938 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart @@ -421,6 +421,12 @@ abstract class NSObjectHostApi { void removeObserver(int instanceId, int observerInstanceId, String keyPath); } +/// FlutterApi for NSObject. +/// +/// See https://developer.apple.com/documentation/webkit/wknavigationdelegate?language=objc. +@FlutterApi() +abstract class NSObjectFlutterApi {} + /// Disposes references to functions. @FlutterApi() abstract class FunctionFlutterApi { diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart index 00412761b287..fd934119fe9f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart @@ -21,59 +21,75 @@ class _TestWKWebsiteDataStoreHostApiCodec extends StandardMessageCodec { if (value is WKWebsiteDataTypeEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKWebsiteDataTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } + abstract class TestWKWebsiteDataStoreHostApi { - static const MessageCodec codec = _TestWKWebsiteDataStoreHostApiCodec(); + static const MessageCodec codec = + _TestWKWebsiteDataStoreHostApiCodec(); - void createFromWebViewConfiguration(int instanceId, int configurationInstanceId); + void createFromWebViewConfiguration( + int instanceId, int configurationInstanceId); void createDefaultDataStore(int instanceId); - Future removeDataOfTypes(int instanceId, List dataTypes, double modificationTimeInSecondsSinceEpoch); - static void setup(TestWKWebsiteDataStoreHostApi? api, {BinaryMessenger? binaryMessenger}) { + Future removeDataOfTypes( + int instanceId, + List dataTypes, + double modificationTimeInSecondsSinceEpoch); + static void setup(TestWKWebsiteDataStoreHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null, expected non-null int.'); final int? arg_configurationInstanceId = (args[1] as int?); - assert(arg_configurationInstanceId != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null, expected non-null int.'); - api.createFromWebViewConfiguration(arg_instanceId!, arg_configurationInstanceId!); + assert(arg_configurationInstanceId != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + api.createFromWebViewConfiguration( + arg_instanceId!, arg_configurationInstanceId!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore was null, expected non-null int.'); api.createDefaultDataStore(arg_instanceId!); return {}; }); @@ -81,20 +97,29 @@ abstract class TestWKWebsiteDataStoreHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null int.'); - final List? arg_dataTypes = (args[1] as List?)?.cast(); - assert(arg_dataTypes != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null List.'); - final double? arg_modificationTimeInSecondsSinceEpoch = (args[2] as double?); - assert(arg_modificationTimeInSecondsSinceEpoch != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null double.'); - final bool output = await api.removeDataOfTypes(arg_instanceId!, arg_dataTypes!, arg_modificationTimeInSecondsSinceEpoch!); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null int.'); + final List? arg_dataTypes = + (args[1] as List?)?.cast(); + assert(arg_dataTypes != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null List.'); + final double? arg_modificationTimeInSecondsSinceEpoch = + (args[2] as double?); + assert(arg_modificationTimeInSecondsSinceEpoch != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null double.'); + final bool output = await api.removeDataOfTypes(arg_instanceId!, + arg_dataTypes!, arg_modificationTimeInSecondsSinceEpoch!); return {'result': output}; }); } @@ -105,23 +130,28 @@ abstract class TestWKWebsiteDataStoreHostApi { class _TestUIViewHostApiCodec extends StandardMessageCodec { const _TestUIViewHostApiCodec(); } + abstract class TestUIViewHostApi { static const MessageCodec codec = _TestUIViewHostApiCodec(); void setBackgroundColor(int instanceId, int? value); void setOpaque(int instanceId, bool opaque); - static void setup(TestUIViewHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestUIViewHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIViewHostApi.setBackgroundColor', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIViewHostApi.setBackgroundColor', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setBackgroundColor was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.UIViewHostApi.setBackgroundColor was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setBackgroundColor was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.UIViewHostApi.setBackgroundColor was null, expected non-null int.'); final int? arg_value = (args[1] as int?); api.setBackgroundColor(arg_instanceId!, arg_value); return {}; @@ -130,17 +160,21 @@ abstract class TestUIViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIViewHostApi.setOpaque', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIViewHostApi.setOpaque', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null, expected non-null int.'); final bool? arg_opaque = (args[1] as bool?); - assert(arg_opaque != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null, expected non-null bool.'); + assert(arg_opaque != null, + 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null, expected non-null bool.'); api.setOpaque(arg_instanceId!, arg_opaque!); return {}; }); @@ -152,6 +186,7 @@ abstract class TestUIViewHostApi { class _TestUIScrollViewHostApiCodec extends StandardMessageCodec { const _TestUIScrollViewHostApiCodec(); } + abstract class TestUIScrollViewHostApi { static const MessageCodec codec = _TestUIScrollViewHostApiCodec(); @@ -159,20 +194,25 @@ abstract class TestUIScrollViewHostApi { List getContentOffset(int instanceId); void scrollBy(int instanceId, double x, double y); void setContentOffset(int instanceId, double x, double y); - static void setup(TestUIScrollViewHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestUIScrollViewHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null, expected non-null int.'); final int? arg_webViewInstanceId = (args[1] as int?); - assert(arg_webViewInstanceId != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null, expected non-null int.'); + assert(arg_webViewInstanceId != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null, expected non-null int.'); api.createFromWebView(arg_instanceId!, arg_webViewInstanceId!); return {}; }); @@ -180,15 +220,18 @@ abstract class TestUIScrollViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset was null, expected non-null int.'); final List output = api.getContentOffset(arg_instanceId!); return {'result': output}; }); @@ -196,19 +239,24 @@ abstract class TestUIScrollViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.scrollBy', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.scrollBy', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null int.'); final double? arg_x = (args[1] as double?); - assert(arg_x != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null double.'); + assert(arg_x != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null double.'); final double? arg_y = (args[2] as double?); - assert(arg_y != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null double.'); + assert(arg_y != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null double.'); api.scrollBy(arg_instanceId!, arg_x!, arg_y!); return {}; }); @@ -216,19 +264,24 @@ abstract class TestUIScrollViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null int.'); final double? arg_x = (args[1] as double?); - assert(arg_x != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null double.'); + assert(arg_x != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null double.'); final double? arg_y = (args[2] as double?); - assert(arg_y != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null double.'); + assert(arg_y != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null double.'); api.setContentOffset(arg_instanceId!, arg_x!, arg_y!); return {}; }); @@ -244,42 +297,48 @@ class _TestWKWebViewConfigurationHostApiCodec extends StandardMessageCodec { if (value is WKAudiovisualMediaTypeEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } + abstract class TestWKWebViewConfigurationHostApi { - static const MessageCodec codec = _TestWKWebViewConfigurationHostApiCodec(); + static const MessageCodec codec = + _TestWKWebViewConfigurationHostApiCodec(); void create(int instanceId); void createFromWebView(int instanceId, int webViewInstanceId); void setAllowsInlineMediaPlayback(int instanceId, bool allow); - void setMediaTypesRequiringUserActionForPlayback(int instanceId, List types); - static void setup(TestWKWebViewConfigurationHostApi? api, {BinaryMessenger? binaryMessenger}) { + void setMediaTypesRequiringUserActionForPlayback( + int instanceId, List types); + static void setup(TestWKWebViewConfigurationHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.create', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.create', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.create was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.create was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.create was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.create was null, expected non-null int.'); api.create(arg_instanceId!); return {}; }); @@ -287,17 +346,22 @@ abstract class TestWKWebViewConfigurationHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null, expected non-null int.'); final int? arg_webViewInstanceId = (args[1] as int?); - assert(arg_webViewInstanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null, expected non-null int.'); + assert(arg_webViewInstanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null, expected non-null int.'); api.createFromWebView(arg_instanceId!, arg_webViewInstanceId!); return {}; }); @@ -305,17 +369,22 @@ abstract class TestWKWebViewConfigurationHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null, expected non-null int.'); final bool? arg_allow = (args[1] as bool?); - assert(arg_allow != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null, expected non-null bool.'); + assert(arg_allow != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null, expected non-null bool.'); api.setAllowsInlineMediaPlayback(arg_instanceId!, arg_allow!); return {}; }); @@ -323,18 +392,26 @@ abstract class TestWKWebViewConfigurationHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null, expected non-null int.'); - final List? arg_types = (args[1] as List?)?.cast(); - assert(arg_types != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null, expected non-null List.'); - api.setMediaTypesRequiringUserActionForPlayback(arg_instanceId!, arg_types!); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null, expected non-null int.'); + final List? arg_types = + (args[1] as List?) + ?.cast(); + assert(arg_types != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null, expected non-null List.'); + api.setMediaTypesRequiringUserActionForPlayback( + arg_instanceId!, arg_types!); return {}; }); } @@ -349,91 +426,112 @@ class _TestWKUserContentControllerHostApiCodec extends StandardMessageCodec { if (value is WKUserScriptData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else - if (value is WKUserScriptInjectionTimeEnumData) { + } else if (value is WKUserScriptInjectionTimeEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKUserScriptData.decode(readValue(buffer)!); - - case 129: + + case 129: return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } + abstract class TestWKUserContentControllerHostApi { - static const MessageCodec codec = _TestWKUserContentControllerHostApiCodec(); + static const MessageCodec codec = + _TestWKUserContentControllerHostApiCodec(); - void createFromWebViewConfiguration(int instanceId, int configurationInstanceId); - void addScriptMessageHandler(int instanceId, int handlerInstanceid, String name); + void createFromWebViewConfiguration( + int instanceId, int configurationInstanceId); + void addScriptMessageHandler( + int instanceId, int handlerInstanceid, String name); void removeScriptMessageHandler(int instanceId, String name); void removeAllScriptMessageHandlers(int instanceId); void addUserScript(int instanceId, WKUserScriptData userScript); void removeAllUserScripts(int instanceId); - static void setup(TestWKUserContentControllerHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKUserContentControllerHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null, expected non-null int.'); final int? arg_configurationInstanceId = (args[1] as int?); - assert(arg_configurationInstanceId != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null, expected non-null int.'); - api.createFromWebViewConfiguration(arg_instanceId!, arg_configurationInstanceId!); + assert(arg_configurationInstanceId != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + api.createFromWebViewConfiguration( + arg_instanceId!, arg_configurationInstanceId!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null int.'); final int? arg_handlerInstanceid = (args[1] as int?); - assert(arg_handlerInstanceid != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null int.'); + assert(arg_handlerInstanceid != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null int.'); final String? arg_name = (args[2] as String?); - assert(arg_name != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null String.'); - api.addScriptMessageHandler(arg_instanceId!, arg_handlerInstanceid!, arg_name!); + assert(arg_name != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null String.'); + api.addScriptMessageHandler( + arg_instanceId!, arg_handlerInstanceid!, arg_name!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null, expected non-null int.'); final String? arg_name = (args[1] as String?); - assert(arg_name != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null, expected non-null String.'); + assert(arg_name != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null, expected non-null String.'); api.removeScriptMessageHandler(arg_instanceId!, arg_name!); return {}; }); @@ -441,15 +539,19 @@ abstract class TestWKUserContentControllerHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers was null, expected non-null int.'); api.removeAllScriptMessageHandlers(arg_instanceId!); return {}; }); @@ -457,17 +559,23 @@ abstract class TestWKUserContentControllerHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null, expected non-null int.'); - final WKUserScriptData? arg_userScript = (args[1] as WKUserScriptData?); - assert(arg_userScript != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null, expected non-null WKUserScriptData.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null, expected non-null int.'); + final WKUserScriptData? arg_userScript = + (args[1] as WKUserScriptData?); + assert(arg_userScript != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null, expected non-null WKUserScriptData.'); api.addUserScript(arg_instanceId!, arg_userScript!); return {}; }); @@ -475,15 +583,19 @@ abstract class TestWKUserContentControllerHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts was null, expected non-null int.'); api.removeAllUserScripts(arg_instanceId!); return {}; }); @@ -495,43 +607,56 @@ abstract class TestWKUserContentControllerHostApi { class _TestWKPreferencesHostApiCodec extends StandardMessageCodec { const _TestWKPreferencesHostApiCodec(); } + abstract class TestWKPreferencesHostApi { static const MessageCodec codec = _TestWKPreferencesHostApiCodec(); - void createFromWebViewConfiguration(int instanceId, int configurationInstanceId); + void createFromWebViewConfiguration( + int instanceId, int configurationInstanceId); void setJavaScriptEnabled(int instanceId, bool enabled); - static void setup(TestWKPreferencesHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKPreferencesHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null, expected non-null int.'); final int? arg_configurationInstanceId = (args[1] as int?); - assert(arg_configurationInstanceId != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null, expected non-null int.'); - api.createFromWebViewConfiguration(arg_instanceId!, arg_configurationInstanceId!); + assert(arg_configurationInstanceId != null, + 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + api.createFromWebViewConfiguration( + arg_instanceId!, arg_configurationInstanceId!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null, expected non-null int.'); final bool? arg_enabled = (args[1] as bool?); - assert(arg_enabled != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null, expected non-null bool.'); + assert(arg_enabled != null, + 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null, expected non-null bool.'); api.setJavaScriptEnabled(arg_instanceId!, arg_enabled!); return {}; }); @@ -543,22 +668,28 @@ abstract class TestWKPreferencesHostApi { class _TestWKScriptMessageHandlerHostApiCodec extends StandardMessageCodec { const _TestWKScriptMessageHandlerHostApiCodec(); } + abstract class TestWKScriptMessageHandlerHostApi { - static const MessageCodec codec = _TestWKScriptMessageHandlerHostApiCodec(); + static const MessageCodec codec = + _TestWKScriptMessageHandlerHostApiCodec(); void create(int instanceId); - static void setup(TestWKScriptMessageHandlerHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKScriptMessageHandlerHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create was null, expected non-null int.'); api.create(arg_instanceId!); return {}; }); @@ -570,22 +701,28 @@ abstract class TestWKScriptMessageHandlerHostApi { class _TestWKNavigationDelegateHostApiCodec extends StandardMessageCodec { const _TestWKNavigationDelegateHostApiCodec(); } + abstract class TestWKNavigationDelegateHostApi { - static const MessageCodec codec = _TestWKNavigationDelegateHostApiCodec(); + static const MessageCodec codec = + _TestWKNavigationDelegateHostApiCodec(); void create(int instanceId, int? didFinishNavigationInstanceId); - static void setup(TestWKNavigationDelegateHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKNavigationDelegateHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKNavigationDelegateHostApi.create', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKNavigationDelegateHostApi.create', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.create was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.create was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.create was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.create was null, expected non-null int.'); final int? arg_didFinishNavigationInstanceId = (args[1] as int?); api.create(arg_instanceId!, arg_didFinishNavigationInstanceId); return {}; @@ -602,41 +739,46 @@ class _TestNSObjectHostApiCodec extends StandardMessageCodec { if (value is NSKeyValueObservingOptionsEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } + abstract class TestNSObjectHostApi { static const MessageCodec codec = _TestNSObjectHostApiCodec(); void dispose(int instanceId); - void addObserver(int instanceId, int observerInstanceId, String keyPath, List options); + void addObserver(int instanceId, int observerInstanceId, String keyPath, + List options); void removeObserver(int instanceId, int observerInstanceId, String keyPath); - static void setup(TestNSObjectHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestNSObjectHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.dispose', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.NSObjectHostApi.dispose', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.dispose was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.dispose was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.dispose was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.dispose was null, expected non-null int.'); api.dispose(arg_instanceId!); return {}; }); @@ -644,42 +786,57 @@ abstract class TestNSObjectHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.addObserver', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.NSObjectHostApi.addObserver', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null int.'); final int? arg_observerInstanceId = (args[1] as int?); - assert(arg_observerInstanceId != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null int.'); + assert(arg_observerInstanceId != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null int.'); final String? arg_keyPath = (args[2] as String?); - assert(arg_keyPath != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null String.'); - final List? arg_options = (args[3] as List?)?.cast(); - assert(arg_options != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null List.'); - api.addObserver(arg_instanceId!, arg_observerInstanceId!, arg_keyPath!, arg_options!); + assert(arg_keyPath != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null String.'); + final List? arg_options = + (args[3] as List?) + ?.cast(); + assert(arg_options != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null List.'); + api.addObserver(arg_instanceId!, arg_observerInstanceId!, + arg_keyPath!, arg_options!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.removeObserver', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.NSObjectHostApi.removeObserver', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null int.'); final int? arg_observerInstanceId = (args[1] as int?); - assert(arg_observerInstanceId != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null int.'); + assert(arg_observerInstanceId != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null int.'); final String? arg_keyPath = (args[2] as String?); - assert(arg_keyPath != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null String.'); - api.removeObserver(arg_instanceId!, arg_observerInstanceId!, arg_keyPath!); + assert(arg_keyPath != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null String.'); + api.removeObserver( + arg_instanceId!, arg_observerInstanceId!, arg_keyPath!); return {}; }); } @@ -694,72 +851,65 @@ class _TestWKWebViewHostApiCodec extends StandardMessageCodec { if (value is NSHttpCookieData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else - if (value is NSHttpCookiePropertyKeyEnumData) { + } else if (value is NSHttpCookiePropertyKeyEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else - if (value is NSKeyValueObservingOptionsEnumData) { + } else if (value is NSKeyValueObservingOptionsEnumData) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else - if (value is NSUrlRequestData) { + } else if (value is NSUrlRequestData) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else - if (value is WKAudiovisualMediaTypeEnumData) { + } else if (value is WKAudiovisualMediaTypeEnumData) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else - if (value is WKUserScriptData) { + } else if (value is WKUserScriptData) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else - if (value is WKUserScriptInjectionTimeEnumData) { + } else if (value is WKUserScriptInjectionTimeEnumData) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else - if (value is WKWebsiteDataTypeEnumData) { + } else if (value is WKWebsiteDataTypeEnumData) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSHttpCookieData.decode(readValue(buffer)!); - - case 129: + + case 129: return NSHttpCookiePropertyKeyEnumData.decode(readValue(buffer)!); - - case 130: + + case 130: return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); - - case 131: + + case 131: return NSUrlRequestData.decode(readValue(buffer)!); - - case 132: + + case 132: return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); - - case 133: + + case 133: return WKUserScriptData.decode(readValue(buffer)!); - - case 134: + + case 134: return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); - - case 135: + + case 135: return WKWebsiteDataTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } + abstract class TestWKWebViewHostApi { static const MessageCodec codec = _TestWKWebViewHostApiCodec(); @@ -781,20 +931,25 @@ abstract class TestWKWebViewHostApi { void setAllowsBackForwardNavigationGestures(int instanceId, bool allow); void setCustomUserAgent(int instanceId, String? userAgent); Future evaluateJavaScript(int instanceId, String javaScriptString); - static void setup(TestWKWebViewHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKWebViewHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.create', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.create', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null, expected non-null int.'); final int? arg_configurationInstanceId = (args[1] as int?); - assert(arg_configurationInstanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null, expected non-null int.'); + assert(arg_configurationInstanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null, expected non-null int.'); api.create(arg_instanceId!, arg_configurationInstanceId!); return {}; }); @@ -802,15 +957,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate was null, expected non-null int.'); final int? arg_uiDelegateInstanceId = (args[1] as int?); api.setUIDelegate(arg_instanceId!, arg_uiDelegateInstanceId); return {}; @@ -819,32 +977,39 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate was null, expected non-null int.'); final int? arg_navigationDelegateInstanceId = (args[1] as int?); - api.setNavigationDelegate(arg_instanceId!, arg_navigationDelegateInstanceId); + api.setNavigationDelegate( + arg_instanceId!, arg_navigationDelegateInstanceId); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getUrl', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getUrl', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getUrl was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getUrl was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getUrl was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getUrl was null, expected non-null int.'); final String? output = api.getUrl(arg_instanceId!); return {'result': output}; }); @@ -852,15 +1017,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress was null, expected non-null int.'); final double output = api.getEstimatedProgress(arg_instanceId!); return {'result': output}; }); @@ -868,17 +1036,21 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadRequest', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadRequest', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null, expected non-null int.'); final NSUrlRequestData? arg_request = (args[1] as NSUrlRequestData?); - assert(arg_request != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null, expected non-null NSUrlRequestData.'); + assert(arg_request != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null, expected non-null NSUrlRequestData.'); api.loadRequest(arg_instanceId!, arg_request!); return {}; }); @@ -886,17 +1058,21 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null, expected non-null int.'); final String? arg_string = (args[1] as String?); - assert(arg_string != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null, expected non-null String.'); + assert(arg_string != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null, expected non-null String.'); final String? arg_baseUrl = (args[2] as String?); api.loadHtmlString(arg_instanceId!, arg_string!, arg_baseUrl); return {}; @@ -905,19 +1081,24 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null int.'); final String? arg_url = (args[1] as String?); - assert(arg_url != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null String.'); + assert(arg_url != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null String.'); final String? arg_readAccessUrl = (args[2] as String?); - assert(arg_readAccessUrl != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null String.'); + assert(arg_readAccessUrl != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null String.'); api.loadFileUrl(arg_instanceId!, arg_url!, arg_readAccessUrl!); return {}; }); @@ -925,17 +1106,21 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null, expected non-null int.'); final String? arg_key = (args[1] as String?); - assert(arg_key != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null, expected non-null String.'); + assert(arg_key != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null, expected non-null String.'); api.loadFlutterAsset(arg_instanceId!, arg_key!); return {}; }); @@ -943,15 +1128,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.canGoBack', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.canGoBack', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoBack was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoBack was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoBack was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoBack was null, expected non-null int.'); final bool output = api.canGoBack(arg_instanceId!); return {'result': output}; }); @@ -959,15 +1147,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.canGoForward', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.canGoForward', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoForward was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoForward was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoForward was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoForward was null, expected non-null int.'); final bool output = api.canGoForward(arg_instanceId!); return {'result': output}; }); @@ -975,15 +1166,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.goBack', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.goBack', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goBack was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goBack was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goBack was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goBack was null, expected non-null int.'); api.goBack(arg_instanceId!); return {}; }); @@ -991,15 +1185,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.goForward', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.goForward', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goForward was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goForward was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goForward was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goForward was null, expected non-null int.'); api.goForward(arg_instanceId!); return {}; }); @@ -1007,15 +1204,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.reload', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.reload', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.reload was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.reload was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.reload was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.reload was null, expected non-null int.'); api.reload(arg_instanceId!); return {}; }); @@ -1023,15 +1223,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getTitle', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getTitle', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getTitle was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getTitle was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getTitle was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getTitle was null, expected non-null int.'); final String? output = api.getTitle(arg_instanceId!); return {'result': output}; }); @@ -1039,33 +1242,42 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null, expected non-null int.'); final bool? arg_allow = (args[1] as bool?); - assert(arg_allow != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null, expected non-null bool.'); - api.setAllowsBackForwardNavigationGestures(arg_instanceId!, arg_allow!); + assert(arg_allow != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null, expected non-null bool.'); + api.setAllowsBackForwardNavigationGestures( + arg_instanceId!, arg_allow!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent was null, expected non-null int.'); final String? arg_userAgent = (args[1] as String?); api.setCustomUserAgent(arg_instanceId!, arg_userAgent); return {}; @@ -1074,18 +1286,23 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null, expected non-null int.'); final String? arg_javaScriptString = (args[1] as String?); - assert(arg_javaScriptString != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null, expected non-null String.'); - final Object? output = await api.evaluateJavaScript(arg_instanceId!, arg_javaScriptString!); + assert(arg_javaScriptString != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null, expected non-null String.'); + final Object? output = await api.evaluateJavaScript( + arg_instanceId!, arg_javaScriptString!); return {'result': output}; }); } @@ -1096,22 +1313,27 @@ abstract class TestWKWebViewHostApi { class _TestWKUIDelegateHostApiCodec extends StandardMessageCodec { const _TestWKUIDelegateHostApiCodec(); } + abstract class TestWKUIDelegateHostApi { static const MessageCodec codec = _TestWKUIDelegateHostApiCodec(); void create(int instanceId); - static void setup(TestWKUIDelegateHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKUIDelegateHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUIDelegateHostApi.create', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUIDelegateHostApi.create', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKUIDelegateHostApi.create was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKUIDelegateHostApi.create was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKUIDelegateHostApi.create was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKUIDelegateHostApi.create was null, expected non-null int.'); api.create(arg_instanceId!); return {}; }); @@ -1127,67 +1349,79 @@ class _TestWKHttpCookieStoreHostApiCodec extends StandardMessageCodec { if (value is NSHttpCookieData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else - if (value is NSHttpCookiePropertyKeyEnumData) { + } else if (value is NSHttpCookiePropertyKeyEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSHttpCookieData.decode(readValue(buffer)!); - - case 129: + + case 129: return NSHttpCookiePropertyKeyEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } + abstract class TestWKHttpCookieStoreHostApi { - static const MessageCodec codec = _TestWKHttpCookieStoreHostApiCodec(); + static const MessageCodec codec = + _TestWKHttpCookieStoreHostApiCodec(); - void createFromWebsiteDataStore(int instanceId, int websiteDataStoreInstanceId); + void createFromWebsiteDataStore( + int instanceId, int websiteDataStoreInstanceId); Future setCookie(int instanceId, NSHttpCookieData cookie); - static void setup(TestWKHttpCookieStoreHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKHttpCookieStoreHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null, expected non-null int.'); final int? arg_websiteDataStoreInstanceId = (args[1] as int?); - assert(arg_websiteDataStoreInstanceId != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null, expected non-null int.'); - api.createFromWebsiteDataStore(arg_instanceId!, arg_websiteDataStoreInstanceId!); + assert(arg_websiteDataStoreInstanceId != null, + 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null, expected non-null int.'); + api.createFromWebsiteDataStore( + arg_instanceId!, arg_websiteDataStoreInstanceId!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null.'); final List args = (message as List?)!; final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null, expected non-null int.'); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null, expected non-null int.'); final NSHttpCookieData? arg_cookie = (args[1] as NSHttpCookieData?); - assert(arg_cookie != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null, expected non-null NSHttpCookieData.'); + assert(arg_cookie != null, + 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null, expected non-null NSHttpCookieData.'); await api.setCookie(arg_instanceId!, arg_cookie!); return {}; }); From 4a12eaabfdc7231ec0c78989fb9311492ff4d71e Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 11 May 2022 17:39:06 -0700 Subject: [PATCH 03/40] documentation and a test messenger --- .../FWFNavigationDelegateHostApiTests.m | 34 +++++++++++++++++-- .../Classes/FWFNavigationDelegateHostApi.h | 5 +++ .../ios/Classes/FWFObjectHostApi.h | 8 +++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m index ebf10572abfe..131f60329c8a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m @@ -8,6 +8,31 @@ #import +// Used to test that a FlutterBinaryMessenger with a strong reference to a host api won't +// lead to a circular reference. +@interface FWFTestMessenger : NSObject +@property(strong, nullable) id hostApi; +@end + +@implementation FWFTestMessenger +- (void)cleanUpConnection:(FlutterBinaryMessengerConnection)connection { +} + +- (void)sendOnChannel:(nonnull NSString *)channel message:(NSData *_Nullable)message { +} + +- (void)sendOnChannel:(nonnull NSString *)channel + message:(NSData *_Nullable)message + binaryReply:(FlutterBinaryReply _Nullable)callback { +} + +- (FlutterBinaryMessengerConnection)setMessageHandlerOnChannel:(nonnull NSString *)channel + binaryMessageHandler: + (FlutterBinaryMessageHandler _Nullable)handler { + return 0; +} +@end + @interface FWFNavigationDelegateHostApiTests : XCTestCase @end @@ -58,10 +83,13 @@ - (void)testDidFinishNavigation { } - (void)testInstanceCanBeReleasedWhenInstanceManagerIsReleased { + FWFTestMessenger *testMessenger = [[FWFTestMessenger alloc] init]; FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - FWFNavigationDelegateHostApiImpl *hostApi = [[FWFNavigationDelegateHostApiImpl alloc] - initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) - instanceManager:instanceManager]; + FWFNavigationDelegateHostApiImpl *hostApi = + [[FWFNavigationDelegateHostApiImpl alloc] initWithBinaryMessenger:testMessenger + instanceManager:instanceManager]; + + testMessenger.hostApi = hostApi; FlutterError *error; [hostApi createWithIdentifier:@0 didFinishNavigationIdentifier:nil error:&error]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h index fd197b11a100..cb7f08a7f220 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h @@ -11,6 +11,11 @@ NS_ASSUME_NONNULL_BEGIN +/** + * Flutter api implementation for WKNavigationDelegate. + * + * Handles making callbacks to Dart for a WKNavigationDelegate. + */ @interface FWFNavigationDelegateFlutterApiImpl : FWFWKNavigationDelegateFlutterApi - (instancetype)initWithBinaryMessenger:(id)binaryMessenger instanceManager:(FWFInstanceManager *)instanceManager; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.h index c1cf6ed62ce9..f1dbdbb20776 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.h @@ -9,11 +9,19 @@ NS_ASSUME_NONNULL_BEGIN +/** + * Flutter api implementation for NSObject. + * + * Handles making callbacks to Dart for an NSObject. + */ @interface FWFObjectFlutterApi : FWFNSObjectFlutterApi - (instancetype)initWithBinaryMessenger:(id)binaryMessenger instanceManager:(FWFInstanceManager *)instanceManager; @end +/** + * Implementation of NSObject for FWFObjectHostApiImpl. + */ @interface FWFObject : NSObject @property(readonly, nonnull) FWFObjectFlutterApi *objectApi; - (instancetype)initWithBinaryMessenger:(id)binaryMessenger From 6bc048b3d9bbcbe0b33e54eb0029190dc44bbe44 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Mon, 16 May 2022 14:02:51 -0700 Subject: [PATCH 04/40] dart side update --- .../ios/Classes/FWFGeneratedWebKitApis.h | 274 +--- .../ios/Classes/FWFGeneratedWebKitApis.m | 1321 +++++++---------- .../Classes/FWFNavigationDelegateHostApi.m | 2 +- .../common/function_flutter_api_impls.dart | 25 - .../lib/src/common/instance_manager.dart | 17 +- .../lib/src/common/web_kit.pigeon.dart | 49 +- .../lib/src/foundation/foundation.dart | 33 +- .../src/foundation/foundation_api_impls.dart | 41 +- .../lib/src/web_kit/web_kit.dart | 27 + .../lib/src/web_kit/web_kit_api_impls.dart | 51 +- .../pigeons/web_kit.dart | 21 +- .../src/common/function_flutter_api_test.dart | 33 - .../test/src/common/test_web_kit.pigeon.dart | 5 +- .../test/src/foundation/foundation_test.dart | 4 + .../test/src/web_kit/web_kit_test.dart | 19 +- .../test/src/web_kit/web_kit_test.mocks.dart | 6 +- .../web_kit_cookie_manager_test.mocks.dart | 53 +- .../web_kit_webview_widget_test.mocks.dart | 368 ++--- 18 files changed, 992 insertions(+), 1357 deletions(-) delete mode 100644 packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/function_flutter_api_impls.dart delete mode 100644 packages/webview_flutter/webview_flutter_wkwebview/test/src/common/function_flutter_api_test.dart diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h index 824aae90f68d..d7a755db09bf 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h @@ -126,166 +126,104 @@ typedef NS_ENUM(NSUInteger, FWFNSHttpCookiePropertyKeyEnum) { /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithUrl:(NSString *)url - httpMethod:(nullable NSString *)httpMethod - httpBody:(nullable FlutterStandardTypedData *)httpBody - allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields; -@property(nonatomic, copy) NSString *url; -@property(nonatomic, copy, nullable) NSString *httpMethod; -@property(nonatomic, strong, nullable) FlutterStandardTypedData *httpBody; -@property(nonatomic, strong) NSDictionary *allHttpHeaderFields; + httpMethod:(nullable NSString *)httpMethod + httpBody:(nullable FlutterStandardTypedData *)httpBody + allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields; +@property(nonatomic, copy) NSString * url; +@property(nonatomic, copy, nullable) NSString * httpMethod; +@property(nonatomic, strong, nullable) FlutterStandardTypedData * httpBody; +@property(nonatomic, strong) NSDictionary * allHttpHeaderFields; @end @interface FWFWKUserScriptData : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithSource:(NSString *)source - injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime - isMainFrameOnly:(NSNumber *)isMainFrameOnly; -@property(nonatomic, copy) NSString *source; -@property(nonatomic, strong, nullable) FWFWKUserScriptInjectionTimeEnumData *injectionTime; -@property(nonatomic, strong) NSNumber *isMainFrameOnly; + injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime + isMainFrameOnly:(NSNumber *)isMainFrameOnly; +@property(nonatomic, copy) NSString * source; +@property(nonatomic, strong, nullable) FWFWKUserScriptInjectionTimeEnumData * injectionTime; +@property(nonatomic, strong) NSNumber * isMainFrameOnly; @end @interface FWFNSHttpCookieData : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithPropertyKeys:(NSArray *)propertyKeys - propertyValues:(NSArray *)propertyValues; -@property(nonatomic, strong) NSArray *propertyKeys; -@property(nonatomic, strong) NSArray *propertyValues; + propertyValues:(NSArray *)propertyValues; +@property(nonatomic, strong) NSArray * propertyKeys; +@property(nonatomic, strong) NSArray * propertyValues; @end /// The codec used by FWFWKWebsiteDataStoreHostApi. NSObject *FWFWKWebsiteDataStoreHostApiGetCodec(void); @protocol FWFWKWebsiteDataStoreHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId - configurationIdentifier:(NSNumber *)configurationInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)createDefaultDataStoreWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeDataFromDataStoreWithIdentifier:(NSNumber *)instanceId - ofTypes:(NSArray *)dataTypes - modifiedSince:(NSNumber *)modificationTimeInSecondsSinceEpoch - completion:(void (^)(NSNumber *_Nullable, - FlutterError *_Nullable))completion; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createDefaultDataStoreWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeDataFromDataStoreWithIdentifier:(NSNumber *)instanceId ofTypes:(NSArray *)dataTypes modifiedSince:(NSNumber *)modificationTimeInSecondsSinceEpoch completion:(void(^)(NSNumber *_Nullable, FlutterError *_Nullable))completion; @end -extern void FWFWKWebsiteDataStoreHostApiSetup( - id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFUIViewHostApi. NSObject *FWFUIViewHostApiGetCodec(void); @protocol FWFUIViewHostApi -- (void)setBackgroundColorForViewWithIdentifier:(NSNumber *)instanceId - toValue:(nullable NSNumber *)value - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setOpaqueForViewWithIdentifier:(NSNumber *)instanceId - isOpaque:(NSNumber *)opaque - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setBackgroundColorForViewWithIdentifier:(NSNumber *)instanceId toValue:(nullable NSNumber *)value error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setOpaqueForViewWithIdentifier:(NSNumber *)instanceId isOpaque:(NSNumber *)opaque error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFUIViewHostApiSetup(id binaryMessenger, - NSObject *_Nullable api); +extern void FWFUIViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFUIScrollViewHostApi. NSObject *FWFUIScrollViewHostApiGetCodec(void); @protocol FWFUIScrollViewHostApi -- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId - webViewIdentifier:(NSNumber *)webViewInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId webViewIdentifier:(NSNumber *)webViewInstanceId error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSArray *) - contentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)scrollByForScrollViewWithIdentifier:(NSNumber *)instanceId - x:(NSNumber *)x - y:(NSNumber *)y - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setContentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId - toX:(NSNumber *)x - y:(NSNumber *)y - error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSArray *)contentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)scrollByForScrollViewWithIdentifier:(NSNumber *)instanceId x:(NSNumber *)x y:(NSNumber *)y error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setContentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId toX:(NSNumber *)x y:(NSNumber *)y error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFUIScrollViewHostApiSetup(id binaryMessenger, - NSObject *_Nullable api); +extern void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKWebViewConfigurationHostApi. NSObject *FWFWKWebViewConfigurationHostApiGetCodec(void); @protocol FWFWKWebViewConfigurationHostApi - (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId - webViewIdentifier:(NSNumber *)webViewInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:(NSNumber *)instanceId - isAllowed:(NSNumber *)allow - error: - (FlutterError *_Nullable *_Nonnull) - error; -- (void) - setMediaTypesRequiresUserActionForConfigurationWithIdentifier:(NSNumber *)instanceId - forTypes: - (NSArray< - FWFWKAudiovisualMediaTypeEnumData - *> *)types - error: - (FlutterError *_Nullable *_Nonnull) - error; +- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId webViewIdentifier:(NSNumber *)webViewInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:(NSNumber *)instanceId isAllowed:(NSNumber *)allow error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setMediaTypesRequiresUserActionForConfigurationWithIdentifier:(NSNumber *)instanceId forTypes:(NSArray *)types error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKWebViewConfigurationHostApiSetup( - id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKUserContentControllerHostApi. NSObject *FWFWKUserContentControllerHostApiGetCodec(void); @protocol FWFWKUserContentControllerHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId - configurationIdentifier:(NSNumber *)configurationInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)addScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId - handlerIdentifier:(NSNumber *)handlerInstanceid - ofName:(NSString *)name - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId - name:(NSString *)name - error:(FlutterError *_Nullable *_Nonnull) - error; -- (void)removeAllScriptMessageHandlersForControllerWithIdentifier:(NSNumber *)instanceId - error: - (FlutterError *_Nullable *_Nonnull) - error; -- (void)addUserScriptForControllerWithIdentifier:(NSNumber *)instanceId - userScript:(FWFWKUserScriptData *)userScript - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeAllUserScriptsForControllerWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)addScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId handlerIdentifier:(NSNumber *)handlerInstanceid ofName:(NSString *)name error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId name:(NSString *)name error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeAllScriptMessageHandlersForControllerWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)addUserScriptForControllerWithIdentifier:(NSNumber *)instanceId userScript:(FWFWKUserScriptData *)userScript error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeAllUserScriptsForControllerWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKUserContentControllerHostApiSetup( - id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKPreferencesHostApi. NSObject *FWFWKPreferencesHostApiGetCodec(void); @protocol FWFWKPreferencesHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId - configurationIdentifier:(NSNumber *)configurationInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setJavaScriptEnabledForPreferencesWithIdentifier:(NSNumber *)instanceId - isEnabled:(NSNumber *)enabled - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setJavaScriptEnabledForPreferencesWithIdentifier:(NSNumber *)instanceId isEnabled:(NSNumber *)enabled error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKPreferencesHostApiSetup(id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKPreferencesHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKScriptMessageHandlerHostApi. NSObject *FWFWKScriptMessageHandlerHostApiGetCodec(void); @@ -294,53 +232,34 @@ NSObject *FWFWKScriptMessageHandlerHostApiGetCodec(void); - (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKScriptMessageHandlerHostApiSetup( - id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKNavigationDelegateHostApi. NSObject *FWFWKNavigationDelegateHostApiGetCodec(void); @protocol FWFWKNavigationDelegateHostApi -- (void)createWithIdentifier:(NSNumber *)instanceId - didFinishNavigationIdentifier:(nullable NSNumber *)didFinishNavigationInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKNavigationDelegateHostApiSetup( - id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKNavigationDelegateFlutterApi. NSObject *FWFWKNavigationDelegateFlutterApiGetCodec(void); @interface FWFWKNavigationDelegateFlutterApi : NSObject - (instancetype)initWithBinaryMessenger:(id)binaryMessenger; -- (void)didFinishNavigationFunctionWithIdentifier:(NSNumber *)functionInstanceId - webViewIdentifier:(NSNumber *)webViewInstanceId - URL:(nullable NSString *)url - completion:(void (^)(NSError *_Nullable))completion; +- (void)didFinishNavigationForDelegateWithIdentifier:(NSNumber *)instanceId webViewIdentifier:(NSNumber *)webViewInstanceId URL:(nullable NSString *)url completion:(void(^)(NSError *_Nullable))completion; @end /// The codec used by FWFNSObjectHostApi. NSObject *FWFNSObjectHostApiGetCodec(void); @protocol FWFNSObjectHostApi -- (void)disposeObjectWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)addObserverForObjectWithIdentifier:(NSNumber *)instanceId - observerIdentifier:(NSNumber *)observerInstanceId - keyPath:(NSString *)keyPath - options: - (NSArray *)options - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeObserverForObjectWithIdentifier:(NSNumber *)instanceId - observerIdentifier:(NSNumber *)observerInstanceId - keyPath:(NSString *)keyPath - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)disposeObjectWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)addObserverForObjectWithIdentifier:(NSNumber *)instanceId observerIdentifier:(NSNumber *)observerInstanceId keyPath:(NSString *)keyPath options:(NSArray *)options error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeObserverForObjectWithIdentifier:(NSNumber *)instanceId observerIdentifier:(NSNumber *)observerInstanceId keyPath:(NSString *)keyPath error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFNSObjectHostApiSetup(id binaryMessenger, - NSObject *_Nullable api); +extern void FWFNSObjectHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFNSObjectFlutterApi. NSObject *FWFNSObjectFlutterApiGetCodec(void); @@ -348,77 +267,34 @@ NSObject *FWFNSObjectFlutterApiGetCodec(void); @interface FWFNSObjectFlutterApi : NSObject - (instancetype)initWithBinaryMessenger:(id)binaryMessenger; @end -/// The codec used by FWFFunctionFlutterApi. -NSObject *FWFFunctionFlutterApiGetCodec(void); - -@interface FWFFunctionFlutterApi : NSObject -- (instancetype)initWithBinaryMessenger:(id)binaryMessenger; -- (void)disposeFunctionWithIdentifier:(NSNumber *)instanceId - completion:(void (^)(NSError *_Nullable))completion; -@end /// The codec used by FWFWKWebViewHostApi. NSObject *FWFWKWebViewHostApiGetCodec(void); @protocol FWFWKWebViewHostApi -- (void)createWithIdentifier:(NSNumber *)instanceId - configurationIdentifier:(NSNumber *)configurationInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setUIDelegateForWebViewWithIdentifier:(NSNumber *)instanceId - delegateIdentifier:(nullable NSNumber *)uiDelegateInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setNavigationDelegateForWebViewWithIdentifier:(NSNumber *)instanceId - delegateIdentifier: - (nullable NSNumber *)navigationDelegateInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (nullable NSString *)URLForWebViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setUIDelegateForWebViewWithIdentifier:(NSNumber *)instanceId delegateIdentifier:(nullable NSNumber *)uiDelegateInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setNavigationDelegateForWebViewWithIdentifier:(NSNumber *)instanceId delegateIdentifier:(nullable NSNumber *)navigationDelegateInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSString *)URLForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)estimatedProgressForWebViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull) - error; -- (void)loadRequestForWebViewWithIdentifier:(NSNumber *)instanceId - request:(FWFNSUrlRequestData *)request - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadHTMLForWebViewWithIdentifier:(NSNumber *)instanceId - HTMLString:(NSString *)string - baseURL:(nullable NSString *)baseUrl - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadFileForWebViewWithIdentifier:(NSNumber *)instanceId - fileURL:(NSString *)url - readAccessURL:(NSString *)readAccessUrl - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadAssetForWebViewWithIdentifier:(NSNumber *)instanceId - assetKey:(NSString *)key - error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSNumber *)estimatedProgressForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadRequestForWebViewWithIdentifier:(NSNumber *)instanceId request:(FWFNSUrlRequestData *)request error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadHTMLForWebViewWithIdentifier:(NSNumber *)instanceId HTMLString:(NSString *)string baseURL:(nullable NSString *)baseUrl error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadFileForWebViewWithIdentifier:(NSNumber *)instanceId fileURL:(NSString *)url readAccessURL:(NSString *)readAccessUrl error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadAssetForWebViewWithIdentifier:(NSNumber *)instanceId assetKey:(NSString *)key error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)canGoBackForWebViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSNumber *)canGoBackForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)canGoForwardForWebViewWithIdentifier:(NSNumber *)instanceId - error: - (FlutterError *_Nullable *_Nonnull)error; -- (void)goBackForWebViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)goForwardForWebViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)reloadWebViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (nullable NSString *)titleForWebViewWithIdentifier:(NSNumber *)instanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setAllowsBackForwardForWebViewWithIdentifier:(NSNumber *)instanceId - isAllowed:(NSNumber *)allow - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setUserAgentForWebViewWithIdentifier:(NSNumber *)instanceId - userAgent:(nullable NSString *)userAgent - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)evaluateJavaScriptForWebViewWithIdentifier:(NSNumber *)instanceId - javaScriptString:(NSString *)javaScriptString - completion:(void (^)(id _Nullable, - FlutterError *_Nullable))completion; +- (nullable NSNumber *)canGoForwardForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)goBackForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)goForwardForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)reloadWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSString *)titleForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setAllowsBackForwardForWebViewWithIdentifier:(NSNumber *)instanceId isAllowed:(NSNumber *)allow error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setUserAgentForWebViewWithIdentifier:(NSNumber *)instanceId userAgent:(nullable NSString *)userAgent error:(FlutterError *_Nullable *_Nonnull)error; +- (void)evaluateJavaScriptForWebViewWithIdentifier:(NSNumber *)instanceId javaScriptString:(NSString *)javaScriptString completion:(void(^)(id _Nullable, FlutterError *_Nullable))completion; @end -extern void FWFWKWebViewHostApiSetup(id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKUIDelegateHostApi. NSObject *FWFWKUIDelegateHostApiGetCodec(void); @@ -427,22 +303,16 @@ NSObject *FWFWKUIDelegateHostApiGetCodec(void); - (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKUIDelegateHostApiSetup(id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSObject *_Nullable api); /// The codec used by FWFWKHttpCookieStoreHostApi. NSObject *FWFWKHttpCookieStoreHostApiGetCodec(void); @protocol FWFWKHttpCookieStoreHostApi -- (void)createFromWebsiteDataStoreWithIdentifier:(NSNumber *)instanceId - dataStoreIdentifier:(NSNumber *)websiteDataStoreInstanceId - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setCookieForStoreWithIdentifier:(NSNumber *)instanceId - cookie:(FWFNSHttpCookieData *)cookie - completion:(void (^)(FlutterError *_Nullable))completion; +- (void)createFromWebsiteDataStoreWithIdentifier:(NSNumber *)instanceId dataStoreIdentifier:(NSNumber *)websiteDataStoreInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setCookieForStoreWithIdentifier:(NSNumber *)instanceId cookie:(FWFNSHttpCookieData *)cookie completion:(void(^)(FlutterError *_Nullable))completion; @end -extern void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, - NSObject *_Nullable api); +extern void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, NSObject *_Nullable api); NS_ASSUME_NONNULL_END diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m index e18f2040bfca..8a4ef78f2c91 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m @@ -14,25 +14,26 @@ NSDictionary *errorDict = (NSDictionary *)[NSNull null]; if (error) { errorDict = @{ - @"code" : (error.code ? error.code : [NSNull null]), - @"message" : (error.message ? error.message : [NSNull null]), - @"details" : (error.details ? error.details : [NSNull null]), - }; + @"code": (error.code ? error.code : [NSNull null]), + @"message": (error.message ? error.message : [NSNull null]), + @"details": (error.details ? error.details : [NSNull null]), + }; } return @{ - @"result" : (result ? result : [NSNull null]), - @"error" : errorDict, - }; + @"result": (result ? result : [NSNull null]), + @"error": errorDict, + }; } -static id GetNullableObject(NSDictionary *dict, id key) { +static id GetNullableObject(NSDictionary* dict, id key) { id result = dict[key]; return (result == [NSNull null]) ? nil : result; } -static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { +static id GetNullableObjectAtIndex(NSArray* array, NSInteger key) { id result = array[key]; return (result == [NSNull null]) ? nil : result; } + @interface FWFNSKeyValueObservingOptionsEnumData () + (FWFNSKeyValueObservingOptionsEnumData *)fromMap:(NSDictionary *)dict; - (NSDictionary *)toMap; @@ -68,14 +69,12 @@ - (NSDictionary *)toMap; @implementation FWFNSKeyValueObservingOptionsEnumData + (instancetype)makeWithValue:(FWFNSKeyValueObservingOptionsEnum)value { - FWFNSKeyValueObservingOptionsEnumData *pigeonResult = - [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; + FWFNSKeyValueObservingOptionsEnumData* pigeonResult = [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFNSKeyValueObservingOptionsEnumData *)fromMap:(NSDictionary *)dict { - FWFNSKeyValueObservingOptionsEnumData *pigeonResult = - [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; + FWFNSKeyValueObservingOptionsEnumData *pigeonResult = [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -86,14 +85,12 @@ - (NSDictionary *)toMap { @implementation FWFWKUserScriptInjectionTimeEnumData + (instancetype)makeWithValue:(FWFWKUserScriptInjectionTimeEnum)value { - FWFWKUserScriptInjectionTimeEnumData *pigeonResult = - [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; + FWFWKUserScriptInjectionTimeEnumData* pigeonResult = [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFWKUserScriptInjectionTimeEnumData *)fromMap:(NSDictionary *)dict { - FWFWKUserScriptInjectionTimeEnumData *pigeonResult = - [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; + FWFWKUserScriptInjectionTimeEnumData *pigeonResult = [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -104,14 +101,12 @@ - (NSDictionary *)toMap { @implementation FWFWKAudiovisualMediaTypeEnumData + (instancetype)makeWithValue:(FWFWKAudiovisualMediaTypeEnum)value { - FWFWKAudiovisualMediaTypeEnumData *pigeonResult = - [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; + FWFWKAudiovisualMediaTypeEnumData* pigeonResult = [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFWKAudiovisualMediaTypeEnumData *)fromMap:(NSDictionary *)dict { - FWFWKAudiovisualMediaTypeEnumData *pigeonResult = - [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; + FWFWKAudiovisualMediaTypeEnumData *pigeonResult = [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -122,7 +117,7 @@ - (NSDictionary *)toMap { @implementation FWFWKWebsiteDataTypeEnumData + (instancetype)makeWithValue:(FWFWKWebsiteDataTypeEnum)value { - FWFWKWebsiteDataTypeEnumData *pigeonResult = [[FWFWKWebsiteDataTypeEnumData alloc] init]; + FWFWKWebsiteDataTypeEnumData* pigeonResult = [[FWFWKWebsiteDataTypeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } @@ -138,14 +133,12 @@ - (NSDictionary *)toMap { @implementation FWFNSHttpCookiePropertyKeyEnumData + (instancetype)makeWithValue:(FWFNSHttpCookiePropertyKeyEnum)value { - FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = - [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; + FWFNSHttpCookiePropertyKeyEnumData* pigeonResult = [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFNSHttpCookiePropertyKeyEnumData *)fromMap:(NSDictionary *)dict { - FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = - [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; + FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -156,10 +149,10 @@ - (NSDictionary *)toMap { @implementation FWFNSUrlRequestData + (instancetype)makeWithUrl:(NSString *)url - httpMethod:(nullable NSString *)httpMethod - httpBody:(nullable FlutterStandardTypedData *)httpBody - allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields { - FWFNSUrlRequestData *pigeonResult = [[FWFNSUrlRequestData alloc] init]; + httpMethod:(nullable NSString *)httpMethod + httpBody:(nullable FlutterStandardTypedData *)httpBody + allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields { + FWFNSUrlRequestData* pigeonResult = [[FWFNSUrlRequestData alloc] init]; pigeonResult.url = url; pigeonResult.httpMethod = httpMethod; pigeonResult.httpBody = httpBody; @@ -177,22 +170,15 @@ + (FWFNSUrlRequestData *)fromMap:(NSDictionary *)dict { return pigeonResult; } - (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.url ? self.url : [NSNull null]), @"url", - (self.httpMethod ? self.httpMethod : [NSNull null]), - @"httpMethod", (self.httpBody ? self.httpBody : [NSNull null]), - @"httpBody", - (self.allHttpHeaderFields ? self.allHttpHeaderFields - : [NSNull null]), - @"allHttpHeaderFields", nil]; + return [NSDictionary dictionaryWithObjectsAndKeys:(self.url ? self.url : [NSNull null]), @"url", (self.httpMethod ? self.httpMethod : [NSNull null]), @"httpMethod", (self.httpBody ? self.httpBody : [NSNull null]), @"httpBody", (self.allHttpHeaderFields ? self.allHttpHeaderFields : [NSNull null]), @"allHttpHeaderFields", nil]; } @end @implementation FWFWKUserScriptData + (instancetype)makeWithSource:(NSString *)source - injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime - isMainFrameOnly:(NSNumber *)isMainFrameOnly { - FWFWKUserScriptData *pigeonResult = [[FWFWKUserScriptData alloc] init]; + injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime + isMainFrameOnly:(NSNumber *)isMainFrameOnly { + FWFWKUserScriptData* pigeonResult = [[FWFWKUserScriptData alloc] init]; pigeonResult.source = source; pigeonResult.injectionTime = injectionTime; pigeonResult.isMainFrameOnly = isMainFrameOnly; @@ -202,27 +188,20 @@ + (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 fromMap:GetNullableObject(dict, @"injectionTime")]; pigeonResult.isMainFrameOnly = GetNullableObject(dict, @"isMainFrameOnly"); NSAssert(pigeonResult.isMainFrameOnly != nil, @""); return pigeonResult; } - (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.source ? self.source : [NSNull null]), @"source", - (self.injectionTime ? [self.injectionTime toMap] - : [NSNull null]), - @"injectionTime", - (self.isMainFrameOnly ? self.isMainFrameOnly : [NSNull null]), - @"isMainFrameOnly", nil]; + return [NSDictionary dictionaryWithObjectsAndKeys:(self.source ? self.source : [NSNull null]), @"source", (self.injectionTime ? [self.injectionTime toMap] : [NSNull null]), @"injectionTime", (self.isMainFrameOnly ? self.isMainFrameOnly : [NSNull null]), @"isMainFrameOnly", nil]; } @end @implementation FWFNSHttpCookieData + (instancetype)makeWithPropertyKeys:(NSArray *)propertyKeys - propertyValues:(NSArray *)propertyValues { - FWFNSHttpCookieData *pigeonResult = [[FWFNSHttpCookieData alloc] init]; + propertyValues:(NSArray *)propertyValues { + FWFNSHttpCookieData* pigeonResult = [[FWFNSHttpCookieData alloc] init]; pigeonResult.propertyKeys = propertyKeys; pigeonResult.propertyValues = propertyValues; return pigeonResult; @@ -236,24 +215,22 @@ + (FWFNSHttpCookieData *)fromMap:(NSDictionary *)dict { return pigeonResult; } - (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.propertyKeys ? self.propertyKeys : [NSNull null]), - @"propertyKeys", - (self.propertyValues ? self.propertyValues : [NSNull null]), - @"propertyValues", nil]; + return [NSDictionary dictionaryWithObjectsAndKeys:(self.propertyKeys ? self.propertyKeys : [NSNull null]), @"propertyKeys", (self.propertyValues ? self.propertyValues : [NSNull null]), @"propertyValues", nil]; } @end @interface FWFWKWebsiteDataStoreHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebsiteDataStoreHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type { +- (nullable id)readValueOfType:(UInt8)type +{ switch (type) { - case 128: + case 128: return [FWFWKWebsiteDataTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; + } } @end @@ -261,11 +238,13 @@ - (nullable id)readValueOfType:(UInt8)type { @interface FWFWKWebsiteDataStoreHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebsiteDataStoreHostApiCodecWriter -- (void)writeValue:(id)value { +- (void)writeValue:(id)value +{ if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else { + } else +{ [super writeValue:value]; } } @@ -286,52 +265,43 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebsiteDataStoreHostApiCodecReaderWriter *readerWriter = - [[FWFWKWebsiteDataStoreHostApiCodecReaderWriter alloc] init]; + FWFWKWebsiteDataStoreHostApiCodecReaderWriter *readerWriter = [[FWFWKWebsiteDataStoreHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: - configurationIdentifier:error:)], - @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " - @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_instanceId - configurationIdentifier:arg_configurationInstanceId - error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createDefaultDataStoreWithIdentifier:error:)], - @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " - @"@selector(createDefaultDataStoreWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createDefaultDataStoreWithIdentifier:error:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(createDefaultDataStoreWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -339,36 +309,30 @@ void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenge [api createDefaultDataStoreWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector - (removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)], - @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " - @"@selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)", - api); + NSCAssert([api respondsToSelector:@selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSArray *arg_dataTypes = GetNullableObjectAtIndex(args, 1); NSNumber *arg_modificationTimeInSecondsSinceEpoch = GetNullableObjectAtIndex(args, 2); - [api removeDataFromDataStoreWithIdentifier:arg_instanceId - ofTypes:arg_dataTypes - modifiedSince:arg_modificationTimeInSecondsSinceEpoch - completion:^(NSNumber *_Nullable output, - FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; + [api removeDataFromDataStoreWithIdentifier:arg_instanceId ofTypes:arg_dataTypes modifiedSince:arg_modificationTimeInSecondsSinceEpoch completion:^(NSNumber *_Nullable output, FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -398,26 +362,22 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFUIViewHostApiCodecReaderWriter *readerWriter = - [[FWFUIViewHostApiCodecReaderWriter alloc] init]; + FWFUIViewHostApiCodecReaderWriter *readerWriter = [[FWFUIViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFUIViewHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFUIViewHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIViewHostApi.setBackgroundColor" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIViewHostApi.setBackgroundColor" binaryMessenger:binaryMessenger - codec:FWFUIViewHostApiGetCodec()]; + codec:FWFUIViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(setBackgroundColorForViewWithIdentifier: - toValue:error:)], - @"FWFUIViewHostApi api (%@) doesn't respond to " - @"@selector(setBackgroundColorForViewWithIdentifier:toValue:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setBackgroundColorForViewWithIdentifier:toValue:error:)], @"FWFUIViewHostApi api (%@) doesn't respond to @selector(setBackgroundColorForViewWithIdentifier:toValue:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -426,20 +386,19 @@ void FWFUIViewHostApiSetup(id binaryMessenger, [api setBackgroundColorForViewWithIdentifier:arg_instanceId toValue:arg_value error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIViewHostApi.setOpaque" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIViewHostApi.setOpaque" binaryMessenger:binaryMessenger - codec:FWFUIViewHostApiGetCodec()]; + codec:FWFUIViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)], - @"FWFUIViewHostApi api (%@) doesn't respond to " - @"@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)], @"FWFUIViewHostApi api (%@) doesn't respond to @selector(setOpaqueForViewWithIdentifier:isOpaque:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -448,7 +407,8 @@ void FWFUIViewHostApiSetup(id binaryMessenger, [api setOpaqueForViewWithIdentifier:arg_instanceId isOpaque:arg_opaque error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -478,72 +438,63 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFUIScrollViewHostApiCodecReaderWriter *readerWriter = - [[FWFUIScrollViewHostApiCodecReaderWriter alloc] init]; + FWFUIScrollViewHostApiCodecReaderWriter *readerWriter = [[FWFUIScrollViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFUIScrollViewHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec()]; + codec:FWFUIScrollViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier: - webViewIdentifier:error:)], - @"FWFUIScrollViewHostApi api (%@) doesn't respond to " - @"@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_webViewInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewWithIdentifier:arg_instanceId - webViewIdentifier:arg_webViewInstanceId - error:&error]; + [api createFromWebViewWithIdentifier:arg_instanceId webViewIdentifier:arg_webViewInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec()]; + codec:FWFUIScrollViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(contentOffsetForScrollViewWithIdentifier:error:)], - @"FWFUIScrollViewHostApi api (%@) doesn't respond to " - @"@selector(contentOffsetForScrollViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(contentOffsetForScrollViewWithIdentifier:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(contentOffsetForScrollViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FlutterError *error; - NSArray *output = [api contentOffsetForScrollViewWithIdentifier:arg_instanceId - error:&error]; + NSArray *output = [api contentOffsetForScrollViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.scrollBy" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.scrollBy" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec()]; + codec:FWFUIScrollViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(scrollByForScrollViewWithIdentifier:x:y:error:)], - @"FWFUIScrollViewHostApi api (%@) doesn't respond to " - @"@selector(scrollByForScrollViewWithIdentifier:x:y:error:)", - api); + NSCAssert([api respondsToSelector:@selector(scrollByForScrollViewWithIdentifier:x:y:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(scrollByForScrollViewWithIdentifier:x:y:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -553,34 +504,30 @@ void FWFUIScrollViewHostApiSetup(id binaryMessenger, [api scrollByForScrollViewWithIdentifier:arg_instanceId x:arg_x y:arg_y error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec()]; + codec:FWFUIScrollViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (setContentOffsetForScrollViewWithIdentifier:toX:y:error:)], - @"FWFUIScrollViewHostApi api (%@) doesn't respond to " - @"@selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_x = GetNullableObjectAtIndex(args, 1); NSNumber *arg_y = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api setContentOffsetForScrollViewWithIdentifier:arg_instanceId - toX:arg_x - y:arg_y - error:&error]; + [api setContentOffsetForScrollViewWithIdentifier:arg_instanceId toX:arg_x y:arg_y error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -588,13 +535,15 @@ void FWFUIScrollViewHostApiSetup(id binaryMessenger, @interface FWFWKWebViewConfigurationHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebViewConfigurationHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type { +- (nullable id)readValueOfType:(UInt8)type +{ switch (type) { - case 128: + case 128: return [FWFWKAudiovisualMediaTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; + } } @end @@ -602,11 +551,13 @@ - (nullable id)readValueOfType:(UInt8)type { @interface FWFWKWebViewConfigurationHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebViewConfigurationHostApiCodecWriter -- (void)writeValue:(id)value { +- (void)writeValue:(id)value +{ if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else { + } else +{ [super writeValue:value]; } } @@ -627,25 +578,22 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebViewConfigurationHostApiCodecReaderWriter *readerWriter = - [[FWFWKWebViewConfigurationHostApiCodecReaderWriter alloc] init]; + FWFWKWebViewConfigurationHostApiCodecReaderWriter *readerWriter = [[FWFWKWebViewConfigurationHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.create" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec()]; + codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], - @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " - @"@selector(createWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -653,87 +601,71 @@ void FWFWKWebViewConfigurationHostApiSetup(id binaryMess [api createWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec()]; + codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier: - webViewIdentifier:error:)], - @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " - @"@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_webViewInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewWithIdentifier:arg_instanceId - webViewIdentifier:arg_webViewInstanceId - error:&error]; + [api createFromWebViewWithIdentifier:arg_instanceId webViewIdentifier:arg_webViewInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec()]; + codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector - (setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)], - @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " - @"@selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_allow = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:arg_instanceId - isAllowed:arg_allow - error:&error]; + [api setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:arg_instanceId isAllowed:arg_allow error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi." - @"setMediaTypesRequiringUserActionForPlayback" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec()]; + codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (setMediaTypesRequiresUserActionForConfigurationWithIdentifier: - forTypes:error:)], - @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " - @"@selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:" - @"error:)", - api); + NSCAssert([api respondsToSelector:@selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSArray *arg_types = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setMediaTypesRequiresUserActionForConfigurationWithIdentifier:arg_instanceId - forTypes:arg_types - error:&error]; + [api setMediaTypesRequiresUserActionForConfigurationWithIdentifier:arg_instanceId forTypes:arg_types error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -741,16 +673,18 @@ void FWFWKWebViewConfigurationHostApiSetup(id binaryMess @interface FWFWKUserContentControllerHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKUserContentControllerHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type { +- (nullable id)readValueOfType:(UInt8)type +{ switch (type) { - case 128: + case 128: return [FWFWKUserScriptData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFWKUserScriptInjectionTimeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; + } } @end @@ -758,14 +692,17 @@ - (nullable id)readValueOfType:(UInt8)type { @interface FWFWKUserContentControllerHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKUserContentControllerHostApiCodecWriter -- (void)writeValue:(id)value { +- (void)writeValue:(id)value +{ if ([value isKindOfClass:[FWFWKUserScriptData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { + } else + if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else { + } else +{ [super writeValue:value]; } } @@ -786,109 +723,86 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKUserContentControllerHostApiCodecReaderWriter *readerWriter = - [[FWFWKUserContentControllerHostApiCodecReaderWriter alloc] init]; + FWFWKUserContentControllerHostApiCodecReaderWriter *readerWriter = [[FWFWKUserContentControllerHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec()]; + codec:FWFWKUserContentControllerHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: - configurationIdentifier:error:)], - @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " - @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_instanceId - configurationIdentifier:arg_configurationInstanceId - error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec()]; + codec:FWFWKUserContentControllerHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (addScriptMessageHandlerForControllerWithIdentifier: - handlerIdentifier:ofName:error:)], - @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " - @"@selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:" - @"ofName:error:)", - api); + NSCAssert([api respondsToSelector:@selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:ofName:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:ofName:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_handlerInstanceid = GetNullableObjectAtIndex(args, 1); NSString *arg_name = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api addScriptMessageHandlerForControllerWithIdentifier:arg_instanceId - handlerIdentifier:arg_handlerInstanceid - ofName:arg_name - error:&error]; + [api addScriptMessageHandlerForControllerWithIdentifier:arg_instanceId handlerIdentifier:arg_handlerInstanceid ofName:arg_name error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec()]; + codec:FWFWKUserContentControllerHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (removeScriptMessageHandlerForControllerWithIdentifier:name:error:)], - @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " - @"@selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)", - api); + NSCAssert([api respondsToSelector:@selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_name = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api removeScriptMessageHandlerForControllerWithIdentifier:arg_instanceId - name:arg_name - error:&error]; + [api removeScriptMessageHandlerForControllerWithIdentifier:arg_instanceId name:arg_name error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec()]; + codec:FWFWKUserContentControllerHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (removeAllScriptMessageHandlersForControllerWithIdentifier:error:)], - @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " - @"@selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -896,46 +810,40 @@ void FWFWKUserContentControllerHostApiSetup(id binaryMes [api removeAllScriptMessageHandlersForControllerWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec()]; + codec:FWFWKUserContentControllerHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(addUserScriptForControllerWithIdentifier: - userScript:error:)], - @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " - @"@selector(addUserScriptForControllerWithIdentifier:userScript:error:)", - api); + NSCAssert([api respondsToSelector:@selector(addUserScriptForControllerWithIdentifier:userScript:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(addUserScriptForControllerWithIdentifier:userScript:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FWFWKUserScriptData *arg_userScript = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api addUserScriptForControllerWithIdentifier:arg_instanceId - userScript:arg_userScript - error:&error]; + [api addUserScriptForControllerWithIdentifier:arg_instanceId userScript:arg_userScript error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec()]; + codec:FWFWKUserContentControllerHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (removeAllUserScriptsForControllerWithIdentifier:error:)], - @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " - @"@selector(removeAllUserScriptsForControllerWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(removeAllUserScriptsForControllerWithIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeAllUserScriptsForControllerWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -943,7 +851,8 @@ void FWFWKUserContentControllerHostApiSetup(id binaryMes [api removeAllUserScriptsForControllerWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -973,63 +882,53 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKPreferencesHostApiCodecReaderWriter *readerWriter = - [[FWFWKPreferencesHostApiCodecReaderWriter alloc] init]; + FWFWKPreferencesHostApiCodecReaderWriter *readerWriter = [[FWFWKPreferencesHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKPreferencesHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKPreferencesHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKPreferencesHostApiGetCodec()]; + codec:FWFWKPreferencesHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: - configurationIdentifier:error:)], - @"FWFWKPreferencesHostApi api (%@) doesn't respond to " - @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKPreferencesHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_instanceId - configurationIdentifier:arg_configurationInstanceId - error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled" binaryMessenger:binaryMessenger - codec:FWFWKPreferencesHostApiGetCodec()]; + codec:FWFWKPreferencesHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)], - @"FWFWKPreferencesHostApi api (%@) doesn't respond to " - @"@selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)], @"FWFWKPreferencesHostApi api (%@) doesn't respond to @selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_enabled = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setJavaScriptEnabledForPreferencesWithIdentifier:arg_instanceId - isEnabled:arg_enabled - error:&error]; + [api setJavaScriptEnabledForPreferencesWithIdentifier:arg_instanceId isEnabled:arg_enabled error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -1059,25 +958,22 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKScriptMessageHandlerHostApiCodecReaderWriter *readerWriter = - [[FWFWKScriptMessageHandlerHostApiCodecReaderWriter alloc] init]; + FWFWKScriptMessageHandlerHostApiCodecReaderWriter *readerWriter = [[FWFWKScriptMessageHandlerHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKScriptMessageHandlerHostApiGetCodec()]; + codec:FWFWKScriptMessageHandlerHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], - @"FWFWKScriptMessageHandlerHostApi api (%@) doesn't respond to " - @"@selector(createWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKScriptMessageHandlerHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1085,7 +981,8 @@ void FWFWKScriptMessageHandlerHostApiSetup(id binaryMess [api createWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -1115,37 +1012,31 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKNavigationDelegateHostApiCodecReaderWriter *readerWriter = - [[FWFWKNavigationDelegateHostApiCodecReaderWriter alloc] init]; + FWFWKNavigationDelegateHostApiCodecReaderWriter *readerWriter = [[FWFWKNavigationDelegateHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKNavigationDelegateHostApi.create" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKNavigationDelegateHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKNavigationDelegateHostApiGetCodec()]; + codec:FWFWKNavigationDelegateHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier: - didFinishNavigationIdentifier:error:)], - @"FWFWKNavigationDelegateHostApi api (%@) doesn't respond to " - @"@selector(createWithIdentifier:didFinishNavigationIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKNavigationDelegateHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); - NSNumber *arg_didFinishNavigationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createWithIdentifier:arg_instanceId - didFinishNavigationIdentifier:arg_didFinishNavigationInstanceId - error:&error]; + [api createWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -1175,15 +1066,15 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKNavigationDelegateFlutterApiCodecReaderWriter *readerWriter = - [[FWFWKNavigationDelegateFlutterApiCodecReaderWriter alloc] init]; + FWFWKNavigationDelegateFlutterApiCodecReaderWriter *readerWriter = [[FWFWKNavigationDelegateFlutterApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } + @interface FWFWKNavigationDelegateFlutterApi () -@property(nonatomic, strong) NSObject *binaryMessenger; +@property (nonatomic, strong) NSObject *binaryMessenger; @end @implementation FWFWKNavigationDelegateFlutterApi @@ -1195,35 +1086,29 @@ - (instancetype)initWithBinaryMessenger:(NSObject *)bina } return self; } -- (void)didFinishNavigationFunctionWithIdentifier:(NSNumber *)arg_functionInstanceId - webViewIdentifier:(NSNumber *)arg_webViewInstanceId - URL:(nullable NSString *)arg_url - completion:(void (^)(NSError *_Nullable))completion { - FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName: - @"dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation" - binaryMessenger:self.binaryMessenger - codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; - [channel sendMessage:@[ - (arg_functionInstanceId == nil) ? [NSNull null] : arg_functionInstanceId, - (arg_webViewInstanceId == nil) ? [NSNull null] : arg_webViewInstanceId, - (arg_url == nil) ? [NSNull null] : arg_url - ] - reply:^(id reply) { - completion(nil); - }]; +- (void)didFinishNavigationForDelegateWithIdentifier:(NSNumber *)arg_instanceId webViewIdentifier:(NSNumber *)arg_webViewInstanceId URL:(nullable NSString *)arg_url completion:(void(^)(NSError *_Nullable))completion { + FlutterBasicMessageChannel *channel = + [FlutterBasicMessageChannel + messageChannelWithName:@"dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation" + binaryMessenger:self.binaryMessenger + codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; + [channel sendMessage:@[(arg_instanceId == nil) ? [NSNull null] : arg_instanceId, (arg_webViewInstanceId == nil) ? [NSNull null] : arg_webViewInstanceId, (arg_url == nil) ? [NSNull null] : arg_url] reply:^(id reply) { + completion(nil); + }]; } @end @interface FWFNSObjectHostApiCodecReader : FlutterStandardReader @end @implementation FWFNSObjectHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type { +- (nullable id)readValueOfType:(UInt8)type +{ switch (type) { - case 128: + case 128: return [FWFNSKeyValueObservingOptionsEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; + } } @end @@ -1231,11 +1116,13 @@ - (nullable id)readValueOfType:(UInt8)type { @interface FWFNSObjectHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFNSObjectHostApiCodecWriter -- (void)writeValue:(id)value { +- (void)writeValue:(id)value +{ if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else { + } else +{ [super writeValue:value]; } } @@ -1256,25 +1143,22 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFNSObjectHostApiCodecReaderWriter *readerWriter = - [[FWFNSObjectHostApiCodecReaderWriter alloc] init]; + FWFNSObjectHostApiCodecReaderWriter *readerWriter = [[FWFNSObjectHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFNSObjectHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFNSObjectHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.dispose" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.dispose" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec()]; + codec:FWFNSObjectHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(disposeObjectWithIdentifier:error:)], - @"FWFNSObjectHostApi api (%@) doesn't respond to " - @"@selector(disposeObjectWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(disposeObjectWithIdentifier:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(disposeObjectWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1282,67 +1166,53 @@ void FWFNSObjectHostApiSetup(id binaryMessenger, [api disposeObjectWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.addObserver" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.addObserver" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec()]; + codec:FWFNSObjectHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (addObserverForObjectWithIdentifier: - observerIdentifier:keyPath:options:error:)], - @"FWFNSObjectHostApi api (%@) doesn't respond to " - @"@selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:" - @"error:)", - api); + NSCAssert([api respondsToSelector:@selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_observerInstanceId = GetNullableObjectAtIndex(args, 1); NSString *arg_keyPath = GetNullableObjectAtIndex(args, 2); - NSArray *arg_options = - GetNullableObjectAtIndex(args, 3); + NSArray *arg_options = GetNullableObjectAtIndex(args, 3); FlutterError *error; - [api addObserverForObjectWithIdentifier:arg_instanceId - observerIdentifier:arg_observerInstanceId - keyPath:arg_keyPath - options:arg_options - error:&error]; + [api addObserverForObjectWithIdentifier:arg_instanceId observerIdentifier:arg_observerInstanceId keyPath:arg_keyPath options:arg_options error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.removeObserver" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.removeObserver" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec()]; + codec:FWFNSObjectHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(removeObserverForObjectWithIdentifier: - observerIdentifier:keyPath:error:)], - @"FWFNSObjectHostApi api (%@) doesn't respond to " - @"@selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)", - api); + NSCAssert([api respondsToSelector:@selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_observerInstanceId = GetNullableObjectAtIndex(args, 1); NSString *arg_keyPath = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api removeObserverForObjectWithIdentifier:arg_instanceId - observerIdentifier:arg_observerInstanceId - keyPath:arg_keyPath - error:&error]; + [api removeObserverForObjectWithIdentifier:arg_instanceId observerIdentifier:arg_observerInstanceId keyPath:arg_keyPath error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -1372,15 +1242,15 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFNSObjectFlutterApiCodecReaderWriter *readerWriter = - [[FWFNSObjectFlutterApiCodecReaderWriter alloc] init]; + FWFNSObjectFlutterApiCodecReaderWriter *readerWriter = [[FWFNSObjectFlutterApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } + @interface FWFNSObjectFlutterApi () -@property(nonatomic, strong) NSObject *binaryMessenger; +@property (nonatomic, strong) NSObject *binaryMessenger; @end @implementation FWFNSObjectFlutterApi @@ -1393,94 +1263,39 @@ - (instancetype)initWithBinaryMessenger:(NSObject *)bina return self; } @end -@interface FWFFunctionFlutterApiCodecReader : FlutterStandardReader -@end -@implementation FWFFunctionFlutterApiCodecReader -@end - -@interface FWFFunctionFlutterApiCodecWriter : FlutterStandardWriter -@end -@implementation FWFFunctionFlutterApiCodecWriter -@end - -@interface FWFFunctionFlutterApiCodecReaderWriter : FlutterStandardReaderWriter -@end -@implementation FWFFunctionFlutterApiCodecReaderWriter -- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data { - return [[FWFFunctionFlutterApiCodecWriter alloc] initWithData:data]; -} -- (FlutterStandardReader *)readerWithData:(NSData *)data { - return [[FWFFunctionFlutterApiCodecReader alloc] initWithData:data]; -} -@end - -NSObject *FWFFunctionFlutterApiGetCodec() { - static dispatch_once_t sPred = 0; - static FlutterStandardMessageCodec *sSharedObject = nil; - dispatch_once(&sPred, ^{ - FWFFunctionFlutterApiCodecReaderWriter *readerWriter = - [[FWFFunctionFlutterApiCodecReaderWriter alloc] init]; - sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; - }); - return sSharedObject; -} - -@interface FWFFunctionFlutterApi () -@property(nonatomic, strong) NSObject *binaryMessenger; -@end - -@implementation FWFFunctionFlutterApi - -- (instancetype)initWithBinaryMessenger:(NSObject *)binaryMessenger { - self = [super init]; - if (self) { - _binaryMessenger = binaryMessenger; - } - return self; -} -- (void)disposeFunctionWithIdentifier:(NSNumber *)arg_instanceId - completion:(void (^)(NSError *_Nullable))completion { - FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel - messageChannelWithName:@"dev.flutter.pigeon.FunctionFlutterApi.dispose" - binaryMessenger:self.binaryMessenger - codec:FWFFunctionFlutterApiGetCodec()]; - [channel sendMessage:@[ (arg_instanceId == nil) ? [NSNull null] : arg_instanceId ] - reply:^(id reply) { - completion(nil); - }]; -} -@end @interface FWFWKWebViewHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebViewHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type { +- (nullable id)readValueOfType:(UInt8)type +{ switch (type) { - case 128: + case 128: return [FWFNSHttpCookieData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFNSHttpCookiePropertyKeyEnumData fromMap:[self readValue]]; - - case 130: + + case 130: return [FWFNSKeyValueObservingOptionsEnumData fromMap:[self readValue]]; - - case 131: + + case 131: return [FWFNSUrlRequestData fromMap:[self readValue]]; - - case 132: + + case 132: return [FWFWKAudiovisualMediaTypeEnumData fromMap:[self readValue]]; - - case 133: + + case 133: return [FWFWKUserScriptData fromMap:[self readValue]]; - - case 134: + + case 134: return [FWFWKUserScriptInjectionTimeEnumData fromMap:[self readValue]]; - - case 135: + + case 135: return [FWFWKWebsiteDataTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; + } } @end @@ -1488,32 +1303,41 @@ - (nullable id)readValueOfType:(UInt8)type { @interface FWFWKWebViewHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebViewHostApiCodecWriter -- (void)writeValue:(id)value { +- (void)writeValue:(id)value +{ if ([value isKindOfClass:[FWFNSHttpCookieData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { + } else + if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { + } else + if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { [self writeByte:130]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFNSUrlRequestData class]]) { + } else + if ([value isKindOfClass:[FWFNSUrlRequestData class]]) { [self writeByte:131]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { + } else + if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { [self writeByte:132]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFWKUserScriptData class]]) { + } else + if ([value isKindOfClass:[FWFWKUserScriptData class]]) { [self writeByte:133]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { + } else + if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { [self writeByte:134]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { + } else + if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { [self writeByte:135]; [self writeValue:[value toMap]]; - } else { + } else +{ [super writeValue:value]; } } @@ -1534,101 +1358,85 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebViewHostApiCodecReaderWriter *readerWriter = - [[FWFWKWebViewHostApiCodecReaderWriter alloc] init]; + FWFWKWebViewHostApiCodecReaderWriter *readerWriter = [[FWFWKWebViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKWebViewHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.create" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier: - configurationIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(createWithIdentifier:configurationIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:configurationIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(createWithIdentifier:configurationIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createWithIdentifier:arg_instanceId - configurationIdentifier:arg_configurationInstanceId - error:&error]; + [api createWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(setUIDelegateForWebViewWithIdentifier: - delegateIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_uiDelegateInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setUIDelegateForWebViewWithIdentifier:arg_instanceId - delegateIdentifier:arg_uiDelegateInstanceId - error:&error]; + [api setUIDelegateForWebViewWithIdentifier:arg_instanceId delegateIdentifier:arg_uiDelegateInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(setNavigationDelegateForWebViewWithIdentifier: - delegateIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_navigationDelegateInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setNavigationDelegateForWebViewWithIdentifier:arg_instanceId - delegateIdentifier:arg_navigationDelegateInstanceId - error:&error]; + [api setNavigationDelegateForWebViewWithIdentifier:arg_instanceId delegateIdentifier:arg_navigationDelegateInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getUrl" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getUrl" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(URLForWebViewWithIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(URLForWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(URLForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(URLForWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1636,44 +1444,39 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSString *output = [api URLForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(estimatedProgressForWebViewWithIdentifier: - error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(estimatedProgressForWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(estimatedProgressForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(estimatedProgressForWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FlutterError *error; - NSNumber *output = [api estimatedProgressForWebViewWithIdentifier:arg_instanceId - error:&error]; + NSNumber *output = [api estimatedProgressForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadRequest" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadRequest" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadRequestForWebViewWithIdentifier: - request:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(loadRequestForWebViewWithIdentifier:request:error:)", - api); + NSCAssert([api respondsToSelector:@selector(loadRequestForWebViewWithIdentifier:request:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadRequestForWebViewWithIdentifier:request:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1682,75 +1485,63 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, [api loadRequestForWebViewWithIdentifier:arg_instanceId request:arg_request error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadHTMLForWebViewWithIdentifier: - HTMLString:baseURL:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)", - api); + NSCAssert([api respondsToSelector:@selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_string = GetNullableObjectAtIndex(args, 1); NSString *arg_baseUrl = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api loadHTMLForWebViewWithIdentifier:arg_instanceId - HTMLString:arg_string - baseURL:arg_baseUrl - error:&error]; + [api loadHTMLForWebViewWithIdentifier:arg_instanceId HTMLString:arg_string baseURL:arg_baseUrl error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)", - api); + NSCAssert([api respondsToSelector:@selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_url = GetNullableObjectAtIndex(args, 1); NSString *arg_readAccessUrl = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api loadFileForWebViewWithIdentifier:arg_instanceId - fileURL:arg_url - readAccessURL:arg_readAccessUrl - error:&error]; + [api loadFileForWebViewWithIdentifier:arg_instanceId fileURL:arg_url readAccessURL:arg_readAccessUrl error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadAssetForWebViewWithIdentifier: - assetKey:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(loadAssetForWebViewWithIdentifier:assetKey:error:)", - api); + NSCAssert([api respondsToSelector:@selector(loadAssetForWebViewWithIdentifier:assetKey:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadAssetForWebViewWithIdentifier:assetKey:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1759,20 +1550,19 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, [api loadAssetForWebViewWithIdentifier:arg_instanceId assetKey:arg_key error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoBack" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoBack" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(canGoBackForWebViewWithIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(canGoBackForWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(canGoBackForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(canGoBackForWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1780,20 +1570,19 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSNumber *output = [api canGoBackForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoForward" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoForward" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(canGoForwardForWebViewWithIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(canGoForwardForWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(canGoForwardForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(canGoForwardForWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1801,20 +1590,19 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSNumber *output = [api canGoForwardForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goBack" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goBack" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(goBackForWebViewWithIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(goBackForWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(goBackForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(goBackForWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1822,20 +1610,19 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, [api goBackForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goForward" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goForward" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(goForwardForWebViewWithIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(goForwardForWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(goForwardForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(goForwardForWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1843,20 +1630,19 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, [api goForwardForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.reload" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.reload" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(reloadWebViewWithIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(reloadWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(reloadWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(reloadWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1864,20 +1650,19 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, [api reloadWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getTitle" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getTitle" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(titleForWebViewWithIdentifier:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(titleForWebViewWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(titleForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(titleForWebViewWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1885,85 +1670,71 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSString *output = [api titleForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector - (setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_allow = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setAllowsBackForwardForWebViewWithIdentifier:arg_instanceId - isAllowed:arg_allow - error:&error]; + [api setAllowsBackForwardForWebViewWithIdentifier:arg_instanceId isAllowed:arg_allow error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(setUserAgentForWebViewWithIdentifier: - userAgent:error:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)", - api); + NSCAssert([api respondsToSelector:@selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_userAgent = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setUserAgentForWebViewWithIdentifier:arg_instanceId - userAgent:arg_userAgent - error:&error]; + [api setUserAgentForWebViewWithIdentifier:arg_instanceId userAgent:arg_userAgent error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec()]; + codec:FWFWKWebViewHostApiGetCodec() ]; if (api) { - NSCAssert( - [api respondsToSelector:@selector - (evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)], - @"FWFWKWebViewHostApi api (%@) doesn't respond to " - @"@selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)", - api); + NSCAssert([api respondsToSelector:@selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_javaScriptString = GetNullableObjectAtIndex(args, 1); - [api evaluateJavaScriptForWebViewWithIdentifier:arg_instanceId - javaScriptString:arg_javaScriptString - completion:^(id _Nullable output, - FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; + [api evaluateJavaScriptForWebViewWithIdentifier:arg_instanceId javaScriptString:arg_javaScriptString completion:^(id _Nullable output, FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -1993,25 +1764,22 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKUIDelegateHostApiCodecReaderWriter *readerWriter = - [[FWFWKUIDelegateHostApiCodecReaderWriter alloc] init]; + FWFWKUIDelegateHostApiCodecReaderWriter *readerWriter = [[FWFWKUIDelegateHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKUIDelegateHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUIDelegateHostApi.create" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUIDelegateHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKUIDelegateHostApiGetCodec()]; + codec:FWFWKUIDelegateHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], - @"FWFWKUIDelegateHostApi api (%@) doesn't respond to " - @"@selector(createWithIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKUIDelegateHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -2019,7 +1787,8 @@ void FWFWKUIDelegateHostApiSetup(id binaryMessenger, [api createWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } @@ -2027,16 +1796,18 @@ void FWFWKUIDelegateHostApiSetup(id binaryMessenger, @interface FWFWKHttpCookieStoreHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKHttpCookieStoreHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type { +- (nullable id)readValueOfType:(UInt8)type +{ switch (type) { - case 128: + case 128: return [FWFNSHttpCookieData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFNSHttpCookiePropertyKeyEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; + } } @end @@ -2044,14 +1815,17 @@ - (nullable id)readValueOfType:(UInt8)type { @interface FWFWKHttpCookieStoreHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKHttpCookieStoreHostApiCodecWriter -- (void)writeValue:(id)value { +- (void)writeValue:(id)value +{ if ([value isKindOfClass:[FWFNSHttpCookieData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { + } else + if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else { + } else +{ [super writeValue:value]; } } @@ -2072,62 +1846,53 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKHttpCookieStoreHostApiCodecReaderWriter *readerWriter = - [[FWFWKHttpCookieStoreHostApiCodecReaderWriter alloc] init]; + FWFWKHttpCookieStoreHostApiCodecReaderWriter *readerWriter = [[FWFWKHttpCookieStoreHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, - NSObject *api) { + +void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, NSObject *api) { { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore" binaryMessenger:binaryMessenger - codec:FWFWKHttpCookieStoreHostApiGetCodec()]; + codec:FWFWKHttpCookieStoreHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebsiteDataStoreWithIdentifier: - dataStoreIdentifier:error:)], - @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to " - @"@selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)", - api); + NSCAssert([api respondsToSelector:@selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)], @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to @selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_websiteDataStoreInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebsiteDataStoreWithIdentifier:arg_instanceId - dataStoreIdentifier:arg_websiteDataStoreInstanceId - error:&error]; + [api createFromWebsiteDataStoreWithIdentifier:arg_instanceId dataStoreIdentifier:arg_websiteDataStoreInstanceId error:&error]; callback(wrapResult(nil, error)); }]; - } else { + } + else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie" + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie" binaryMessenger:binaryMessenger - codec:FWFWKHttpCookieStoreHostApiGetCodec()]; + codec:FWFWKHttpCookieStoreHostApiGetCodec() ]; if (api) { - NSCAssert([api respondsToSelector:@selector(setCookieForStoreWithIdentifier: - cookie:completion:)], - @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to " - @"@selector(setCookieForStoreWithIdentifier:cookie:completion:)", - api); + NSCAssert([api respondsToSelector:@selector(setCookieForStoreWithIdentifier:cookie:completion:)], @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to @selector(setCookieForStoreWithIdentifier:cookie:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FWFNSHttpCookieData *arg_cookie = GetNullableObjectAtIndex(args, 1); - [api setCookieForStoreWithIdentifier:arg_instanceId - cookie:arg_cookie - completion:^(FlutterError *_Nullable error) { - callback(wrapResult(nil, error)); - }]; + [api setCookieForStoreWithIdentifier:arg_instanceId cookie:arg_cookie completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; }]; - } else { + } + else { [channel setMessageHandler:nil]; } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m index 609c40aac991..52609a5a6ba0 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m @@ -50,7 +50,7 @@ - (instancetype)initWithBinaryMessenger:(id)binaryMessen [[FWFNavigationDelegateFlutterApiImpl alloc] initWithBinaryMessenger:binaryMessenger instanceManager:instanceManager]; - FWFNavigationDelegate __weak __block *weakSelf = self; + FWFNavigationDelegate __weak *weakSelf = self; _didFinishNavigation = ^(WKWebView *webView, NSString *URL) { [weakSelf.navigationDelegateApi didFinishNavigationFunction:weakSelf.didFinishNavigation webView:webView diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/function_flutter_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/function_flutter_api_impls.dart deleted file mode 100644 index c6eb711513d2..000000000000 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/function_flutter_api_impls.dart +++ /dev/null @@ -1,25 +0,0 @@ -// 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. - -import 'instance_manager.dart'; -import 'web_kit.pigeon.dart'; - -/// Flutter api to dispose functions. -class FunctionFlutterApiImpl extends FunctionFlutterApi { - /// Constructs a [FunctionFlutterApiImpl]. - FunctionFlutterApiImpl({InstanceManager? instanceManager}) { - this.instanceManager = instanceManager ?? InstanceManager.instance; - } - - /// Maintains instances stored to communicate with native language objects. - late final InstanceManager instanceManager; - - @override - void dispose(int instanceId) { - final Function? function = instanceManager.getInstance(instanceId); - if (function != null) { - instanceManager.removeInstance(function); - } - } -} diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 830ba2e94935..11c894cf704c 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -5,7 +5,7 @@ /// Maintains instances stored to communicate with Objective-C objects. class InstanceManager { final Map _instanceIdsToInstances = {}; - final Map _instancesToInstanceIds = {}; + final Expando _instancesToInstanceIds = Expando(); int _nextInstanceId = 0; @@ -17,7 +17,7 @@ class InstanceManager { /// Returns new if [instance] has already been added. Otherwise, it is added /// with a new instance id. int? tryAddInstance(Object instance) { - if (_instancesToInstanceIds.containsKey(instance)) { + if (getInstanceId(instance) != null) { return null; } @@ -27,14 +27,21 @@ class InstanceManager { return instanceId; } + /// Store a copy of an instance with the same instance id. + void addCopy(Object original, Object copy) { + assert(original.runtimeType == copy.runtimeType); + _instancesToInstanceIds[copy] = _instancesToInstanceIds[original]; + assert(original == copy); + } + /// Remove the instance from the manager. /// /// Returns null if the instance is removed. Otherwise, return the instanceId /// of the removed instance. int? removeInstance(T instance) { - final int? instanceId = _instancesToInstanceIds[instance]; + final int? instanceId = _instancesToInstanceIds[instance] as int?; if (instanceId != null) { - _instancesToInstanceIds.remove(instance); + _instancesToInstanceIds[instance] = null; _instanceIdsToInstances.remove(instanceId); } return instanceId; @@ -47,6 +54,6 @@ class InstanceManager { /// Retrieve the instanceId paired with instance. int? getInstanceId(Object instance) { - return _instancesToInstanceIds[instance]; + return _instancesToInstanceIds[instance] as int?; } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart index fae0096a0f43..c57665fa6908 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart @@ -1051,14 +1051,12 @@ class WKNavigationDelegateHostApi { static const MessageCodec codec = _WKNavigationDelegateHostApiCodec(); - Future create( - int arg_instanceId, int? arg_didFinishNavigationInstanceId) async { + Future create(int arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.WKNavigationDelegateHostApi.create', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = await channel - .send([arg_instanceId, arg_didFinishNavigationInstanceId]) - as Map?; + final Map? replyMap = + await channel.send([arg_instanceId]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -1086,8 +1084,7 @@ abstract class WKNavigationDelegateFlutterApi { static const MessageCodec codec = _WKNavigationDelegateFlutterApiCodec(); - void didFinishNavigation( - int functionInstanceId, int webViewInstanceId, String? url); + void didFinishNavigation(int instanceId, int webViewInstanceId, String? url); static void setup(WKNavigationDelegateFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { @@ -1102,15 +1099,15 @@ abstract class WKNavigationDelegateFlutterApi { assert(message != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null.'); final List args = (message as List?)!; - final int? arg_functionInstanceId = (args[0] as int?); - assert(arg_functionInstanceId != null, + final int? arg_instanceId = (args[0] as int?); + assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null, expected non-null int.'); final int? arg_webViewInstanceId = (args[1] as int?); assert(arg_webViewInstanceId != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null, expected non-null int.'); final String? arg_url = (args[2] as String?); api.didFinishNavigation( - arg_functionInstanceId!, arg_webViewInstanceId!, arg_url); + arg_instanceId!, arg_webViewInstanceId!, arg_url); return; }); } @@ -1247,38 +1244,6 @@ abstract class NSObjectFlutterApi { {BinaryMessenger? binaryMessenger}) {} } -class _FunctionFlutterApiCodec extends StandardMessageCodec { - const _FunctionFlutterApiCodec(); -} - -abstract class FunctionFlutterApi { - static const MessageCodec codec = _FunctionFlutterApiCodec(); - - void dispose(int instanceId); - static void setup(FunctionFlutterApi? api, - {BinaryMessenger? binaryMessenger}) { - { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.FunctionFlutterApi.dispose', codec, - binaryMessenger: binaryMessenger); - if (api == null) { - channel.setMessageHandler(null); - } else { - channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.FunctionFlutterApi.dispose was null.'); - final List args = (message as List?)!; - final int? arg_instanceId = (args[0] as int?); - assert(arg_instanceId != null, - 'Argument for dev.flutter.pigeon.FunctionFlutterApi.dispose was null, expected non-null int.'); - api.dispose(arg_instanceId!); - return; - }); - } - } - } -} - class _WKWebViewHostApiCodec extends StandardMessageCodec { const _WKWebViewHostApiCodec(); @override diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart index 5c127c5654c6..e5a875e23412 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart @@ -232,8 +232,16 @@ class NSHttpCookie { final Map properties; } +/// An object that can provide functional copies of themselves. +@immutable +mixin Copyable { + /// Instantiates and returns a functionally identical object to oneself. + Copyable copy(); +} + /// The root class of most Objective-C class hierarchies. -class NSObject { +@immutable +class NSObject with Copyable { /// Constructs an [NSObject]. NSObject({BinaryMessenger? binaryMessenger, InstanceManager? instanceManager}) : _api = NSObjectHostApiImpl( @@ -283,4 +291,27 @@ class NSObject { ) { throw UnimplementedError(); } + + @override + Copyable copy() { + final NSObject copy = NSObject( + binaryMessenger: _api.binaryMessenger, + instanceManager: _api.instanceManager, + ); + _api.instanceManager.addCopy(this, copy); + return copy; + } + + @override + int get hashCode { + return Object.hash(_api, _api.instanceManager.getInstanceId(this)); + } + + @override + bool operator ==(Object other) { + return other is NSObject && + _api == other._api && + _api.instanceManager.getInstanceId(this) == + other._api.instanceManager.getInstanceId(other); + } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart index b007d1a8312c..a2995c6b1452 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart @@ -5,7 +5,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; -import '../common/function_flutter_api_impls.dart'; import '../common/instance_manager.dart'; import '../common/web_kit.pigeon.dart'; import 'foundation.dart'; @@ -43,11 +42,9 @@ class FoundationFlutterApis { @visibleForTesting FoundationFlutterApis({ BinaryMessenger? binaryMessenger, + // ignore: avoid_unused_constructor_parameters InstanceManager? instanceManager, - }) : _binaryMessenger = binaryMessenger { - functionFlutterApi = - FunctionFlutterApiImpl(instanceManager: instanceManager); - } + }) : _binaryMessenger = binaryMessenger; static FoundationFlutterApis _instance = FoundationFlutterApis(); @@ -62,38 +59,34 @@ class FoundationFlutterApis { return _instance; } + // ignore: unused_field final BinaryMessenger? _binaryMessenger; bool _hasBeenSetUp = false; - /// Flutter Api for disposing functions. - /// - /// This FlutterApi is placed here because [FoundationFlutterApis.ensureSetUp] - /// is called inside [NSObject] and [NSObject] is the parent class of all - /// objects. - @visibleForTesting - late final FunctionFlutterApiImpl functionFlutterApi; - /// Ensures all the Flutter APIs have been set up to receive calls from native code. void ensureSetUp() { if (!_hasBeenSetUp) { - FunctionFlutterApi.setup( - functionFlutterApi, - binaryMessenger: _binaryMessenger, - ); _hasBeenSetUp = true; } } } /// Host api implementation for [NSObject]. +@immutable class NSObjectHostApiImpl extends NSObjectHostApi { /// Constructs an [NSObjectHostApiImpl]. NSObjectHostApiImpl({ - BinaryMessenger? binaryMessenger, + this.binaryMessenger, InstanceManager? instanceManager, }) : instanceManager = instanceManager ?? InstanceManager.instance, super(binaryMessenger: binaryMessenger); + /// Sends binary data across the Flutter platform barrier. + /// + /// If it is null, the default BinaryMessenger will be used which routes to + /// the host platform. + final BinaryMessenger? binaryMessenger; + /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -132,4 +125,16 @@ class NSObjectHostApiImpl extends NSObjectHostApi { await dispose(instanceId); } } + + @override + int get hashCode { + return Object.hash(binaryMessenger, instanceManager); + } + + @override + bool operator ==(Object other) { + return other is NSObjectHostApiImpl && + binaryMessenger == other.binaryMessenger && + instanceManager == other.instanceManager; + } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart index cc26ca5d7608..f74c7464ab0f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart @@ -597,6 +597,7 @@ class WKUIDelegate { /// coordinate changes in your web view’s main frame. /// /// Wraps [WKNavigationDelegate](https://developer.apple.com/documentation/webkit/wknavigationdelegate?language=objc). +@immutable class WKNavigationDelegate extends NSObject { /// Constructs a [WKNavigationDelegate]. WKNavigationDelegate({ @@ -662,6 +663,32 @@ class WKNavigationDelegate extends NSObject { ) { throw UnimplementedError(); } + + @override + Copyable copy() { + final WKNavigationDelegate copy = WKNavigationDelegate( + didFinishNavigation: didFinishNavigation, + binaryMessenger: _navigationDelegateApi.binaryMessenger, + instanceManager: _navigationDelegateApi.instanceManager, + ); + _navigationDelegateApi.instanceManager.addCopy(this, copy); + return copy; + } + + @override + int get hashCode { + return Object.hash(didFinishNavigation, _navigationDelegateApi, + _navigationDelegateApi.instanceManager.getInstanceId(this)); + } + + @override + bool operator ==(Object other) { + return other is WKNavigationDelegate && + didFinishNavigation == other.didFinishNavigation && + _navigationDelegateApi == other._navigationDelegateApi && + _navigationDelegateApi.instanceManager.getInstanceId(this) == + other._navigationDelegateApi.instanceManager.getInstanceId(other); + } } /// Object that displays interactive web content, such as for an in-app browser. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart index bc7dedfefe28..7f613b51c60b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart @@ -525,14 +525,21 @@ class WKUIDelegateHostApiImpl extends WKUIDelegateHostApi { } /// Host api implementation for [WKNavigationDelegate]. +@immutable class WKNavigationDelegateHostApiImpl extends WKNavigationDelegateHostApi { /// Constructs a [WKNavigationDelegateHostApiImpl]. WKNavigationDelegateHostApiImpl({ - BinaryMessenger? binaryMessenger, + this.binaryMessenger, InstanceManager? instanceManager, }) : instanceManager = instanceManager ?? InstanceManager.instance, super(binaryMessenger: binaryMessenger); + /// Sends binary data across the Flutter platform barrier. + /// + /// If it is null, the default BinaryMessenger will be used which routes to + /// the host platform. + final BinaryMessenger? binaryMessenger; + /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -543,14 +550,21 @@ class WKNavigationDelegateHostApiImpl extends WKNavigationDelegateHostApi { ) async { final int? instanceId = instanceManager.tryAddInstance(instance); if (instanceId != null) { - await create( - instanceId, - didFinishNavigation != null - ? _getOrAddFunctionInstanceId(instanceManager, didFinishNavigation) - : null, - ); + await create(instanceId); } } + + @override + int get hashCode { + return Object.hash(binaryMessenger, instanceManager); + } + + @override + bool operator ==(Object other) { + return other is WKNavigationDelegateHostApiImpl && + binaryMessenger == other.binaryMessenger && + instanceManager == other.instanceManager; + } } /// Flutter api implementation for [WKNavigationDelegate]. @@ -564,17 +578,20 @@ class WKNavigationDelegateFlutterApiImpl /// Maintains instances stored to communicate with native language objects. late final InstanceManager instanceManager; + WKNavigationDelegate _getDelegate(int instanceId) { + return instanceManager.getInstance(instanceId)!; + } + @override void didFinishNavigation( - int functionInstanceId, + int instanceId, int webViewInstanceId, String? url, ) { - final void Function( - WKWebView webView, - String? url, - ) function = instanceManager.getInstance(functionInstanceId)!; - function(instanceManager.getInstance(webViewInstanceId)!, url); + _getDelegate(instanceId).didFinishNavigation!( + instanceManager.getInstance(webViewInstanceId)!, + url, + ); } } @@ -742,11 +759,3 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { ); } } - -int _getOrAddFunctionInstanceId( - InstanceManager instanceManager, - Function function, -) { - return instanceManager.getInstanceId(function) ?? - instanceManager.tryAddInstance(function)!; -} diff --git a/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart index 33f553f9e938..755a85bccacf 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart @@ -378,20 +378,20 @@ abstract class WKScriptMessageHandlerHostApi { /// See https://developer.apple.com/documentation/webkit/wknavigationdelegate?language=objc. @HostApi(dartHostTestHandler: 'TestWKNavigationDelegateHostApi') abstract class WKNavigationDelegateHostApi { - @ObjCSelector('createWithIdentifier:didFinishNavigationIdentifier:') - void create(int instanceId, int? didFinishNavigationInstanceId); + @ObjCSelector('createWithIdentifier:') + void create(int instanceId); } -/// Mirror of WKNavigationDelegate. +/// Handling callbacks from an WKNavigationDelegate. /// /// See https://developer.apple.com/documentation/webkit/wknavigationdelegate?language=objc. @FlutterApi() abstract class WKNavigationDelegateFlutterApi { @ObjCSelector( - 'didFinishNavigationFunctionWithIdentifier:webViewIdentifier:URL:', + 'didFinishNavigationForDelegateWithIdentifier:webViewIdentifier:URL:', ) void didFinishNavigation( - int functionInstanceId, + int instanceId, int webViewInstanceId, String? url, ); @@ -421,19 +421,12 @@ abstract class NSObjectHostApi { void removeObserver(int instanceId, int observerInstanceId, String keyPath); } -/// FlutterApi for NSObject. +/// Handling callbacks from an NSObject. /// -/// See https://developer.apple.com/documentation/webkit/wknavigationdelegate?language=objc. +/// See https://developer.apple.com/documentation/objectivec/nsobject. @FlutterApi() abstract class NSObjectFlutterApi {} -/// Disposes references to functions. -@FlutterApi() -abstract class FunctionFlutterApi { - @ObjCSelector('disposeFunctionWithIdentifier:') - void dispose(int instanceId); -} - /// Mirror of WKWebView. /// /// See https://developer.apple.com/documentation/webkit/wkwebview?language=objc. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/function_flutter_api_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/function_flutter_api_test.dart deleted file mode 100644 index 63e59386ceaf..000000000000 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/function_flutter_api_test.dart +++ /dev/null @@ -1,33 +0,0 @@ -// 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. - -import 'package:flutter_test/flutter_test.dart'; -import 'package:webview_flutter_wkwebview/src/common/instance_manager.dart'; -import 'package:webview_flutter_wkwebview/src/common/web_kit.pigeon.dart'; -import 'package:webview_flutter_wkwebview/src/foundation/foundation_api_impls.dart'; - -void main() { - TestWidgetsFlutterBinding.ensureInitialized(); - - group('$FunctionFlutterApi', () { - late InstanceManager instanceManager; - - setUp(() { - instanceManager = InstanceManager(); - }); - - test('dispose', () { - final Function function = () {}; - final int functionInstanceId = instanceManager.tryAddInstance(function)!; - - FoundationFlutterApis.instance = FoundationFlutterApis( - instanceManager: instanceManager, - )..ensureSetUp(); - - FoundationFlutterApis.instance.functionFlutterApi - .dispose(functionInstanceId); - expect(instanceManager.getInstanceId(function), isNull); - }); - }); -} diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart index fd934119fe9f..ca950520b26a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart @@ -706,7 +706,7 @@ abstract class TestWKNavigationDelegateHostApi { static const MessageCodec codec = _TestWKNavigationDelegateHostApiCodec(); - void create(int instanceId, int? didFinishNavigationInstanceId); + void create(int instanceId); static void setup(TestWKNavigationDelegateHostApi? api, {BinaryMessenger? binaryMessenger}) { { @@ -723,8 +723,7 @@ abstract class TestWKNavigationDelegateHostApi { final int? arg_instanceId = (args[0] as int?); assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.create was null, expected non-null int.'); - final int? arg_didFinishNavigationInstanceId = (args[1] as int?); - api.create(arg_instanceId!, arg_didFinishNavigationInstanceId); + api.create(arg_instanceId!); return {}; }); } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart index 007c2bc32252..0ed9fc26025a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart @@ -42,6 +42,10 @@ void main() { TestNSObjectHostApi.setup(null); }); + test('copy', () { + expect(object, equals(object.copy())); + }); + test('addObserver', () async { final NSObject observer = NSObject(instanceManager: instanceManager); instanceManager.tryAddInstance(observer); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart index f7b927ba679b..ba8be26e144d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart @@ -437,6 +437,10 @@ void main() { TestWKWebViewHostApi.setup(null); }); + test('copy', () { + expect(navigationDelegate, equals(navigationDelegate.copy())); + }); + test('create', () async { navigationDelegate = WKNavigationDelegate( instanceManager: instanceManager, @@ -444,7 +448,6 @@ void main() { verify(mockPlatformHostApi.create( instanceManager.getInstanceId(navigationDelegate), - null, )); }); @@ -452,6 +455,10 @@ void main() { final Completer> argsCompleter = Completer>(); + WebKitFlutterApis.instance = WebKitFlutterApis( + instanceManager: instanceManager, + ); + navigationDelegate = WKNavigationDelegate( instanceManager: instanceManager, didFinishNavigation: (WKWebView webView, String? url) { @@ -459,13 +466,9 @@ void main() { }, ); - final int functionInstanceId = verify(mockPlatformHostApi.create( - instanceManager.getInstanceId(navigationDelegate), - captureAny, - )).captured.single as int; - - flutterApis.navigationDelegateFlutterApi.didFinishNavigation( - functionInstanceId, + WebKitFlutterApis.instance.navigationDelegateFlutterApi + .didFinishNavigation( + instanceManager.getInstanceId(navigationDelegate)!, instanceManager.getInstanceId(webView)!, 'url', ); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart index 6ab12064d48e..16d80b22c22b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.mocks.dart @@ -53,10 +53,8 @@ class MockTestWKNavigationDelegateHostApi extends _i1.Mock } @override - void create(int? instanceId, int? didFinishNavigationInstanceId) => - super.noSuchMethod( - Invocation.method( - #create, [instanceId, didFinishNavigationInstanceId]), + void create(int? instanceId) => + super.noSuchMethod(Invocation.method(#create, [instanceId]), returnValueForMissingStub: null); } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_cookie_manager_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_cookie_manager_test.mocks.dart index 8d7751da785f..c7b309005768 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_cookie_manager_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_cookie_manager_test.mocks.dart @@ -2,12 +2,12 @@ // in webview_flutter_wkwebview/example/ios/.symlinks/plugins/webview_flutter_wkwebview/test/src/web_kit_cookie_manager_test.dart. // Do not manually edit this file. -import 'dart:async' as _i3; +import 'dart:async' as _i4; import 'package:mockito/mockito.dart' as _i1; import 'package:webview_flutter_wkwebview/src/foundation/foundation.dart' - as _i4; -import 'package:webview_flutter_wkwebview/src/web_kit/web_kit.dart' as _i2; + as _i2; +import 'package:webview_flutter_wkwebview/src/web_kit/web_kit.dart' as _i3; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -19,68 +19,73 @@ import 'package:webview_flutter_wkwebview/src/web_kit/web_kit.dart' as _i2; // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types -class _FakeWKHttpCookieStore_0 extends _i1.Fake - implements _i2.WKHttpCookieStore {} +class _FakeCopyable_0 extends _i1.Fake implements _i2.Copyable {} + +class _FakeWKHttpCookieStore_1 extends _i1.Fake + implements _i3.WKHttpCookieStore {} /// A class which mocks [WKHttpCookieStore]. /// /// See the documentation for Mockito's code generation for more information. -class MockWKHttpCookieStore extends _i1.Mock implements _i2.WKHttpCookieStore { +class MockWKHttpCookieStore extends _i1.Mock implements _i3.WKHttpCookieStore { MockWKHttpCookieStore() { _i1.throwOnMissingStub(this); } @override - _i3.Future setCookie(_i4.NSHttpCookie? cookie) => + _i4.Future setCookie(_i2.NSHttpCookie? cookie) => (super.noSuchMethod(Invocation.method(#setCookie, [cookie]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i3.Future); + returnValueForMissingStub: Future.value()) as _i4.Future); @override - _i3.Future addObserver(_i4.NSObject? observer, - {String? keyPath, Set<_i4.NSKeyValueObservingOptions>? options}) => + _i4.Future addObserver(_i2.NSObject? observer, + {String? keyPath, Set<_i2.NSKeyValueObservingOptions>? options}) => (super.noSuchMethod( Invocation.method( #addObserver, [observer], {#keyPath: keyPath, #options: options}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i3.Future); + returnValueForMissingStub: Future.value()) as _i4.Future); @override - _i3.Future removeObserver(_i4.NSObject? observer, {String? keyPath}) => + _i4.Future removeObserver(_i2.NSObject? observer, {String? keyPath}) => (super.noSuchMethod( Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i3.Future); + returnValueForMissingStub: Future.value()) as _i4.Future); @override - _i3.Future dispose() => + _i4.Future dispose() => (super.noSuchMethod(Invocation.method(#dispose, []), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i3.Future); + returnValueForMissingStub: Future.value()) as _i4.Future); @override - _i3.Future setObserveValue( + _i4.Future setObserveValue( void Function( - String, _i4.NSObject, Map<_i4.NSKeyValueChangeKey, Object?>)? + String, _i2.NSObject, Map<_i2.NSKeyValueChangeKey, Object?>)? observeValue) => (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i3.Future); + returnValueForMissingStub: Future.value()) as _i4.Future); + @override + _i2.Copyable copy() => (super.noSuchMethod(Invocation.method(#copy, []), + returnValue: _FakeCopyable_0()) as _i2.Copyable); } /// A class which mocks [WKWebsiteDataStore]. /// /// See the documentation for Mockito's code generation for more information. class MockWKWebsiteDataStore extends _i1.Mock - implements _i2.WKWebsiteDataStore { + implements _i3.WKWebsiteDataStore { MockWKWebsiteDataStore() { _i1.throwOnMissingStub(this); } @override - _i2.WKHttpCookieStore get httpCookieStore => + _i3.WKHttpCookieStore get httpCookieStore => (super.noSuchMethod(Invocation.getter(#httpCookieStore), - returnValue: _FakeWKHttpCookieStore_0()) as _i2.WKHttpCookieStore); + returnValue: _FakeWKHttpCookieStore_1()) as _i3.WKHttpCookieStore); @override - _i3.Future removeDataOfTypes( - Set<_i2.WKWebsiteDataType>? dataTypes, DateTime? since) => + _i4.Future removeDataOfTypes( + Set<_i3.WKWebsiteDataType>? dataTypes, DateTime? since) => (super.noSuchMethod( Invocation.method(#removeDataOfTypes, [dataTypes, since]), - returnValue: Future.value(false)) as _i3.Future); + returnValue: Future.value(false)) as _i4.Future); } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.mocks.dart index fb467ec5518c..66341ab08036 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.mocks.dart @@ -2,9 +2,9 @@ // in webview_flutter_wkwebview/example/ios/.symlinks/plugins/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.dart. // Do not manually edit this file. -import 'dart:async' as _i5; +import 'dart:async' as _i6; import 'dart:math' as _i2; -import 'dart:ui' as _i6; +import 'dart:ui' as _i7; import 'package:mockito/mockito.dart' as _i1; import 'package:webview_flutter_platform_interface/src/types/javascript_channel.dart' @@ -14,9 +14,9 @@ import 'package:webview_flutter_platform_interface/src/types/types.dart' import 'package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart' as _i8; import 'package:webview_flutter_wkwebview/src/foundation/foundation.dart' - as _i7; -import 'package:webview_flutter_wkwebview/src/ui_kit/ui_kit.dart' as _i4; -import 'package:webview_flutter_wkwebview/src/web_kit/web_kit.dart' as _i3; + as _i3; +import 'package:webview_flutter_wkwebview/src/ui_kit/ui_kit.dart' as _i5; +import 'package:webview_flutter_wkwebview/src/web_kit/web_kit.dart' as _i4; import 'package:webview_flutter_wkwebview/src/web_kit_webview_widget.dart' as _i11; @@ -32,461 +32,473 @@ import 'package:webview_flutter_wkwebview/src/web_kit_webview_widget.dart' class _FakePoint_0 extends _i1.Fake implements _i2.Point {} -class _FakeWKWebViewConfiguration_1 extends _i1.Fake - implements _i3.WKWebViewConfiguration {} +class _FakeCopyable_1 extends _i1.Fake implements _i3.Copyable {} -class _FakeUIScrollView_2 extends _i1.Fake implements _i4.UIScrollView {} +class _FakeWKWebViewConfiguration_2 extends _i1.Fake + implements _i4.WKWebViewConfiguration {} -class _FakeWKUserContentController_3 extends _i1.Fake - implements _i3.WKUserContentController {} +class _FakeUIScrollView_3 extends _i1.Fake implements _i5.UIScrollView {} -class _FakeWKPreferences_4 extends _i1.Fake implements _i3.WKPreferences {} +class _FakeWKUserContentController_4 extends _i1.Fake + implements _i4.WKUserContentController {} -class _FakeWKWebsiteDataStore_5 extends _i1.Fake - implements _i3.WKWebsiteDataStore {} +class _FakeWKPreferences_5 extends _i1.Fake implements _i4.WKPreferences {} -class _FakeWKHttpCookieStore_6 extends _i1.Fake - implements _i3.WKHttpCookieStore {} +class _FakeWKWebsiteDataStore_6 extends _i1.Fake + implements _i4.WKWebsiteDataStore {} -class _FakeWKWebView_7 extends _i1.Fake implements _i3.WKWebView {} +class _FakeWKHttpCookieStore_7 extends _i1.Fake + implements _i4.WKHttpCookieStore {} -class _FakeWKScriptMessageHandler_8 extends _i1.Fake - implements _i3.WKScriptMessageHandler {} +class _FakeWKWebView_8 extends _i1.Fake implements _i4.WKWebView {} -class _FakeWKUIDelegate_9 extends _i1.Fake implements _i3.WKUIDelegate {} +class _FakeWKScriptMessageHandler_9 extends _i1.Fake + implements _i4.WKScriptMessageHandler {} -class _FakeWKNavigationDelegate_10 extends _i1.Fake - implements _i3.WKNavigationDelegate {} +class _FakeWKUIDelegate_10 extends _i1.Fake implements _i4.WKUIDelegate {} + +class _FakeWKNavigationDelegate_11 extends _i1.Fake + implements _i4.WKNavigationDelegate {} /// A class which mocks [UIScrollView]. /// /// See the documentation for Mockito's code generation for more information. -class MockUIScrollView extends _i1.Mock implements _i4.UIScrollView { +class MockUIScrollView extends _i1.Mock implements _i5.UIScrollView { MockUIScrollView() { _i1.throwOnMissingStub(this); } @override - _i5.Future<_i2.Point> getContentOffset() => (super.noSuchMethod( + _i6.Future<_i2.Point> getContentOffset() => (super.noSuchMethod( Invocation.method(#getContentOffset, []), returnValue: Future<_i2.Point>.value(_FakePoint_0())) - as _i5.Future<_i2.Point>); + as _i6.Future<_i2.Point>); @override - _i5.Future scrollBy(_i2.Point? offset) => + _i6.Future scrollBy(_i2.Point? offset) => (super.noSuchMethod(Invocation.method(#scrollBy, [offset]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future setContentOffset(_i2.Point? offset) => + _i6.Future setContentOffset(_i2.Point? offset) => (super.noSuchMethod(Invocation.method(#setContentOffset, [offset]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future setBackgroundColor(_i6.Color? color) => + _i6.Future setBackgroundColor(_i7.Color? color) => (super.noSuchMethod(Invocation.method(#setBackgroundColor, [color]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future setOpaque(bool? opaque) => + _i6.Future setOpaque(bool? opaque) => (super.noSuchMethod(Invocation.method(#setOpaque, [opaque]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future addObserver(_i7.NSObject? observer, - {String? keyPath, Set<_i7.NSKeyValueObservingOptions>? options}) => + _i6.Future addObserver(_i3.NSObject? observer, + {String? keyPath, Set<_i3.NSKeyValueObservingOptions>? options}) => (super.noSuchMethod( Invocation.method( #addObserver, [observer], {#keyPath: keyPath, #options: options}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future removeObserver(_i7.NSObject? observer, {String? keyPath}) => + _i6.Future removeObserver(_i3.NSObject? observer, {String? keyPath}) => (super.noSuchMethod( Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future dispose() => + _i6.Future dispose() => (super.noSuchMethod(Invocation.method(#dispose, []), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future setObserveValue( + _i6.Future setObserveValue( void Function( - String, _i7.NSObject, Map<_i7.NSKeyValueChangeKey, Object?>)? + String, _i3.NSObject, Map<_i3.NSKeyValueChangeKey, Object?>)? observeValue) => (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i3.Copyable copy() => (super.noSuchMethod(Invocation.method(#copy, []), + returnValue: _FakeCopyable_1()) as _i3.Copyable); } /// A class which mocks [WKNavigationDelegate]. /// /// See the documentation for Mockito's code generation for more information. +// ignore: must_be_immutable class MockWKNavigationDelegate extends _i1.Mock - implements _i3.WKNavigationDelegate { + implements _i4.WKNavigationDelegate { MockWKNavigationDelegate() { _i1.throwOnMissingStub(this); } @override - _i5.Future setDidStartProvisionalNavigation( - void Function(_i3.WKWebView, String?)? + _i6.Future setDidStartProvisionalNavigation( + void Function(_i4.WKWebView, String?)? didStartProvisionalNavigation) => (super.noSuchMethod( Invocation.method(#setDidStartProvisionalNavigation, [didStartProvisionalNavigation]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future setDecidePolicyForNavigationAction( - _i5.Future<_i3.WKNavigationActionPolicy> Function( - _i3.WKWebView, _i3.WKNavigationAction)? + _i6.Future setDecidePolicyForNavigationAction( + _i6.Future<_i4.WKNavigationActionPolicy> Function( + _i4.WKWebView, _i4.WKNavigationAction)? decidePolicyForNavigationAction) => (super.noSuchMethod( Invocation.method(#setDecidePolicyForNavigationAction, [decidePolicyForNavigationAction]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future setDidFailNavigation( - void Function(_i3.WKWebView, _i7.NSError)? didFailNavigation) => + _i6.Future setDidFailNavigation( + void Function(_i4.WKWebView, _i3.NSError)? didFailNavigation) => (super.noSuchMethod( Invocation.method(#setDidFailNavigation, [didFailNavigation]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future setDidFailProvisionalNavigation( - void Function(_i3.WKWebView, _i7.NSError)? + _i6.Future setDidFailProvisionalNavigation( + void Function(_i4.WKWebView, _i3.NSError)? didFailProvisionalNavigation) => (super.noSuchMethod( Invocation.method( #setDidFailProvisionalNavigation, [didFailProvisionalNavigation]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future setWebViewWebContentProcessDidTerminate( - void Function(_i3.WKWebView)? webViewWebContentProcessDidTerminate) => + _i6.Future setWebViewWebContentProcessDidTerminate( + void Function(_i4.WKWebView)? webViewWebContentProcessDidTerminate) => (super.noSuchMethod( Invocation.method(#setWebViewWebContentProcessDidTerminate, [webViewWebContentProcessDidTerminate]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future addObserver(_i7.NSObject? observer, - {String? keyPath, Set<_i7.NSKeyValueObservingOptions>? options}) => + _i3.Copyable copy() => (super.noSuchMethod(Invocation.method(#copy, []), + returnValue: _FakeCopyable_1()) as _i3.Copyable); + @override + _i6.Future addObserver(_i3.NSObject? observer, + {String? keyPath, Set<_i3.NSKeyValueObservingOptions>? options}) => (super.noSuchMethod( Invocation.method( #addObserver, [observer], {#keyPath: keyPath, #options: options}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future removeObserver(_i7.NSObject? observer, {String? keyPath}) => + _i6.Future removeObserver(_i3.NSObject? observer, {String? keyPath}) => (super.noSuchMethod( Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future dispose() => + _i6.Future dispose() => (super.noSuchMethod(Invocation.method(#dispose, []), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future setObserveValue( + _i6.Future setObserveValue( void Function( - String, _i7.NSObject, Map<_i7.NSKeyValueChangeKey, Object?>)? + String, _i3.NSObject, Map<_i3.NSKeyValueChangeKey, Object?>)? observeValue) => (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); } /// A class which mocks [WKPreferences]. /// /// See the documentation for Mockito's code generation for more information. -class MockWKPreferences extends _i1.Mock implements _i3.WKPreferences { +class MockWKPreferences extends _i1.Mock implements _i4.WKPreferences { MockWKPreferences() { _i1.throwOnMissingStub(this); } @override - _i5.Future setJavaScriptEnabled(bool? enabled) => + _i6.Future setJavaScriptEnabled(bool? enabled) => (super.noSuchMethod(Invocation.method(#setJavaScriptEnabled, [enabled]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); } /// A class which mocks [WKScriptMessageHandler]. /// /// See the documentation for Mockito's code generation for more information. class MockWKScriptMessageHandler extends _i1.Mock - implements _i3.WKScriptMessageHandler { + implements _i4.WKScriptMessageHandler { MockWKScriptMessageHandler() { _i1.throwOnMissingStub(this); } @override - _i5.Future setDidReceiveScriptMessage( - void Function(_i3.WKUserContentController, _i3.WKScriptMessage)? + _i6.Future setDidReceiveScriptMessage( + void Function(_i4.WKUserContentController, _i4.WKScriptMessage)? didReceiveScriptMessage) => (super.noSuchMethod( Invocation.method( #setDidReceiveScriptMessage, [didReceiveScriptMessage]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); } /// A class which mocks [WKWebView]. /// /// See the documentation for Mockito's code generation for more information. -class MockWKWebView extends _i1.Mock implements _i3.WKWebView { +class MockWKWebView extends _i1.Mock implements _i4.WKWebView { MockWKWebView() { _i1.throwOnMissingStub(this); } @override - _i3.WKWebViewConfiguration get configuration => + _i4.WKWebViewConfiguration get configuration => (super.noSuchMethod(Invocation.getter(#configuration), - returnValue: _FakeWKWebViewConfiguration_1()) - as _i3.WKWebViewConfiguration); + returnValue: _FakeWKWebViewConfiguration_2()) + as _i4.WKWebViewConfiguration); @override - _i4.UIScrollView get scrollView => + _i5.UIScrollView get scrollView => (super.noSuchMethod(Invocation.getter(#scrollView), - returnValue: _FakeUIScrollView_2()) as _i4.UIScrollView); + returnValue: _FakeUIScrollView_3()) as _i5.UIScrollView); @override - _i5.Future setUIDelegate(_i3.WKUIDelegate? delegate) => + _i6.Future setUIDelegate(_i4.WKUIDelegate? delegate) => (super.noSuchMethod(Invocation.method(#setUIDelegate, [delegate]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future setNavigationDelegate(_i3.WKNavigationDelegate? delegate) => + _i6.Future setNavigationDelegate(_i4.WKNavigationDelegate? delegate) => (super.noSuchMethod(Invocation.method(#setNavigationDelegate, [delegate]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future getUrl() => + _i6.Future getUrl() => (super.noSuchMethod(Invocation.method(#getUrl, []), - returnValue: Future.value()) as _i5.Future); + returnValue: Future.value()) as _i6.Future); @override - _i5.Future getEstimatedProgress() => + _i6.Future getEstimatedProgress() => (super.noSuchMethod(Invocation.method(#getEstimatedProgress, []), - returnValue: Future.value(0.0)) as _i5.Future); + returnValue: Future.value(0.0)) as _i6.Future); @override - _i5.Future loadRequest(_i7.NSUrlRequest? request) => + _i6.Future loadRequest(_i3.NSUrlRequest? request) => (super.noSuchMethod(Invocation.method(#loadRequest, [request]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future loadHtmlString(String? string, {String? baseUrl}) => + _i6.Future loadHtmlString(String? string, {String? baseUrl}) => (super.noSuchMethod( Invocation.method(#loadHtmlString, [string], {#baseUrl: baseUrl}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future loadFileUrl(String? url, {String? readAccessUrl}) => + _i6.Future loadFileUrl(String? url, {String? readAccessUrl}) => (super.noSuchMethod( Invocation.method( #loadFileUrl, [url], {#readAccessUrl: readAccessUrl}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future loadFlutterAsset(String? key) => + _i6.Future loadFlutterAsset(String? key) => (super.noSuchMethod(Invocation.method(#loadFlutterAsset, [key]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future canGoBack() => + _i6.Future canGoBack() => (super.noSuchMethod(Invocation.method(#canGoBack, []), - returnValue: Future.value(false)) as _i5.Future); + returnValue: Future.value(false)) as _i6.Future); @override - _i5.Future canGoForward() => + _i6.Future canGoForward() => (super.noSuchMethod(Invocation.method(#canGoForward, []), - returnValue: Future.value(false)) as _i5.Future); + returnValue: Future.value(false)) as _i6.Future); @override - _i5.Future goBack() => + _i6.Future goBack() => (super.noSuchMethod(Invocation.method(#goBack, []), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future goForward() => + _i6.Future goForward() => (super.noSuchMethod(Invocation.method(#goForward, []), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future reload() => + _i6.Future reload() => (super.noSuchMethod(Invocation.method(#reload, []), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future getTitle() => + _i6.Future getTitle() => (super.noSuchMethod(Invocation.method(#getTitle, []), - returnValue: Future.value()) as _i5.Future); + returnValue: Future.value()) as _i6.Future); @override - _i5.Future setAllowsBackForwardNavigationGestures(bool? allow) => + _i6.Future setAllowsBackForwardNavigationGestures(bool? allow) => (super.noSuchMethod( Invocation.method(#setAllowsBackForwardNavigationGestures, [allow]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future setCustomUserAgent(String? userAgent) => + _i6.Future setCustomUserAgent(String? userAgent) => (super.noSuchMethod(Invocation.method(#setCustomUserAgent, [userAgent]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future evaluateJavaScript(String? javaScriptString) => (super + _i6.Future evaluateJavaScript(String? javaScriptString) => (super .noSuchMethod(Invocation.method(#evaluateJavaScript, [javaScriptString]), - returnValue: Future.value()) as _i5.Future); + returnValue: Future.value()) as _i6.Future); @override - _i5.Future setBackgroundColor(_i6.Color? color) => + _i6.Future setBackgroundColor(_i7.Color? color) => (super.noSuchMethod(Invocation.method(#setBackgroundColor, [color]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future setOpaque(bool? opaque) => + _i6.Future setOpaque(bool? opaque) => (super.noSuchMethod(Invocation.method(#setOpaque, [opaque]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future addObserver(_i7.NSObject? observer, - {String? keyPath, Set<_i7.NSKeyValueObservingOptions>? options}) => + _i6.Future addObserver(_i3.NSObject? observer, + {String? keyPath, Set<_i3.NSKeyValueObservingOptions>? options}) => (super.noSuchMethod( Invocation.method( #addObserver, [observer], {#keyPath: keyPath, #options: options}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future removeObserver(_i7.NSObject? observer, {String? keyPath}) => + _i6.Future removeObserver(_i3.NSObject? observer, {String? keyPath}) => (super.noSuchMethod( Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future dispose() => + _i6.Future dispose() => (super.noSuchMethod(Invocation.method(#dispose, []), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future setObserveValue( + _i6.Future setObserveValue( void Function( - String, _i7.NSObject, Map<_i7.NSKeyValueChangeKey, Object?>)? + String, _i3.NSObject, Map<_i3.NSKeyValueChangeKey, Object?>)? observeValue) => (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i3.Copyable copy() => (super.noSuchMethod(Invocation.method(#copy, []), + returnValue: _FakeCopyable_1()) as _i3.Copyable); } /// A class which mocks [WKWebViewConfiguration]. /// /// See the documentation for Mockito's code generation for more information. class MockWKWebViewConfiguration extends _i1.Mock - implements _i3.WKWebViewConfiguration { + implements _i4.WKWebViewConfiguration { MockWKWebViewConfiguration() { _i1.throwOnMissingStub(this); } @override - _i3.WKUserContentController get userContentController => + _i4.WKUserContentController get userContentController => (super.noSuchMethod(Invocation.getter(#userContentController), - returnValue: _FakeWKUserContentController_3()) - as _i3.WKUserContentController); + returnValue: _FakeWKUserContentController_4()) + as _i4.WKUserContentController); @override - _i3.WKPreferences get preferences => + _i4.WKPreferences get preferences => (super.noSuchMethod(Invocation.getter(#preferences), - returnValue: _FakeWKPreferences_4()) as _i3.WKPreferences); + returnValue: _FakeWKPreferences_5()) as _i4.WKPreferences); @override - _i3.WKWebsiteDataStore get websiteDataStore => + _i4.WKWebsiteDataStore get websiteDataStore => (super.noSuchMethod(Invocation.getter(#websiteDataStore), - returnValue: _FakeWKWebsiteDataStore_5()) as _i3.WKWebsiteDataStore); + returnValue: _FakeWKWebsiteDataStore_6()) as _i4.WKWebsiteDataStore); @override - _i5.Future setAllowsInlineMediaPlayback(bool? allow) => (super + _i6.Future setAllowsInlineMediaPlayback(bool? allow) => (super .noSuchMethod(Invocation.method(#setAllowsInlineMediaPlayback, [allow]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future setMediaTypesRequiringUserActionForPlayback( - Set<_i3.WKAudiovisualMediaType>? types) => + _i6.Future setMediaTypesRequiringUserActionForPlayback( + Set<_i4.WKAudiovisualMediaType>? types) => (super.noSuchMethod( Invocation.method( #setMediaTypesRequiringUserActionForPlayback, [types]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); } /// A class which mocks [WKWebsiteDataStore]. /// /// See the documentation for Mockito's code generation for more information. class MockWKWebsiteDataStore extends _i1.Mock - implements _i3.WKWebsiteDataStore { + implements _i4.WKWebsiteDataStore { MockWKWebsiteDataStore() { _i1.throwOnMissingStub(this); } @override - _i3.WKHttpCookieStore get httpCookieStore => + _i4.WKHttpCookieStore get httpCookieStore => (super.noSuchMethod(Invocation.getter(#httpCookieStore), - returnValue: _FakeWKHttpCookieStore_6()) as _i3.WKHttpCookieStore); + returnValue: _FakeWKHttpCookieStore_7()) as _i4.WKHttpCookieStore); @override - _i5.Future removeDataOfTypes( - Set<_i3.WKWebsiteDataType>? dataTypes, DateTime? since) => + _i6.Future removeDataOfTypes( + Set<_i4.WKWebsiteDataType>? dataTypes, DateTime? since) => (super.noSuchMethod( Invocation.method(#removeDataOfTypes, [dataTypes, since]), - returnValue: Future.value(false)) as _i5.Future); + returnValue: Future.value(false)) as _i6.Future); } /// A class which mocks [WKUIDelegate]. /// /// See the documentation for Mockito's code generation for more information. -class MockWKUIDelegate extends _i1.Mock implements _i3.WKUIDelegate { +class MockWKUIDelegate extends _i1.Mock implements _i4.WKUIDelegate { MockWKUIDelegate() { _i1.throwOnMissingStub(this); } @override - _i5.Future setOnCreateWebView( - void Function(_i3.WKWebViewConfiguration, _i3.WKNavigationAction)? + _i6.Future setOnCreateWebView( + void Function(_i4.WKWebViewConfiguration, _i4.WKNavigationAction)? onCreateWebView) => (super.noSuchMethod( Invocation.method(#setOnCreateWebView, [onCreateWebView]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); } /// A class which mocks [WKUserContentController]. /// /// See the documentation for Mockito's code generation for more information. class MockWKUserContentController extends _i1.Mock - implements _i3.WKUserContentController { + implements _i4.WKUserContentController { MockWKUserContentController() { _i1.throwOnMissingStub(this); } @override - _i5.Future addScriptMessageHandler( - _i3.WKScriptMessageHandler? handler, String? name) => + _i6.Future addScriptMessageHandler( + _i4.WKScriptMessageHandler? handler, String? name) => (super.noSuchMethod( Invocation.method(#addScriptMessageHandler, [handler, name]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future removeScriptMessageHandler(String? name) => (super + _i6.Future removeScriptMessageHandler(String? name) => (super .noSuchMethod(Invocation.method(#removeScriptMessageHandler, [name]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future removeAllScriptMessageHandlers() => (super.noSuchMethod( + _i6.Future removeAllScriptMessageHandlers() => (super.noSuchMethod( Invocation.method(#removeAllScriptMessageHandlers, []), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future addUserScript(_i3.WKUserScript? userScript) => + _i6.Future addUserScript(_i4.WKUserScript? userScript) => (super.noSuchMethod(Invocation.method(#addUserScript, [userScript]), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i5.Future removeAllUserScripts() => + _i6.Future removeAllUserScripts() => (super.noSuchMethod(Invocation.method(#removeAllUserScripts, []), returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i5.Future); + returnValueForMissingStub: Future.value()) as _i6.Future); } /// A class which mocks [JavascriptChannelRegistry]. @@ -525,11 +537,11 @@ class MockWebViewPlatformCallbacksHandler extends _i1.Mock } @override - _i5.FutureOr onNavigationRequest({String? url, bool? isForMainFrame}) => + _i6.FutureOr onNavigationRequest({String? url, bool? isForMainFrame}) => (super.noSuchMethod( Invocation.method(#onNavigationRequest, [], {#url: url, #isForMainFrame: isForMainFrame}), - returnValue: Future.value(false)) as _i5.FutureOr); + returnValue: Future.value(false)) as _i6.FutureOr); @override void onPageStarted(String? url) => super.noSuchMethod(Invocation.method(#onPageStarted, [url]), @@ -558,24 +570,24 @@ class MockWebViewWidgetProxy extends _i1.Mock } @override - _i3.WKWebView createWebView(_i3.WKWebViewConfiguration? configuration) => + _i4.WKWebView createWebView(_i4.WKWebViewConfiguration? configuration) => (super.noSuchMethod(Invocation.method(#createWebView, [configuration]), - returnValue: _FakeWKWebView_7()) as _i3.WKWebView); + returnValue: _FakeWKWebView_8()) as _i4.WKWebView); @override - _i3.WKScriptMessageHandler createScriptMessageHandler() => + _i4.WKScriptMessageHandler createScriptMessageHandler() => (super.noSuchMethod(Invocation.method(#createScriptMessageHandler, []), - returnValue: _FakeWKScriptMessageHandler_8()) - as _i3.WKScriptMessageHandler); + returnValue: _FakeWKScriptMessageHandler_9()) + as _i4.WKScriptMessageHandler); @override - _i3.WKUIDelegate createUIDelgate() => + _i4.WKUIDelegate createUIDelgate() => (super.noSuchMethod(Invocation.method(#createUIDelgate, []), - returnValue: _FakeWKUIDelegate_9()) as _i3.WKUIDelegate); + returnValue: _FakeWKUIDelegate_10()) as _i4.WKUIDelegate); @override - _i3.WKNavigationDelegate createNavigationDelegate( - {void Function(_i3.WKWebView, String?)? didFinishNavigation}) => + _i4.WKNavigationDelegate createNavigationDelegate( + {void Function(_i4.WKWebView, String?)? didFinishNavigation}) => (super.noSuchMethod( Invocation.method(#createNavigationDelegate, [], {#didFinishNavigation: didFinishNavigation}), - returnValue: _FakeWKNavigationDelegate_10()) - as _i3.WKNavigationDelegate); + returnValue: _FakeWKNavigationDelegate_11()) + as _i4.WKNavigationDelegate); } From 4efa9a1342d0d36b245a971452a572e0999849a7 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Mon, 16 May 2022 14:22:54 -0700 Subject: [PATCH 05/40] objc side --- .../FWFNavigationDelegateHostApiTests.m | 8 ++--- .../Classes/FWFNavigationDelegateHostApi.m | 30 +++++-------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m index 131f60329c8a..bba3350caefb 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m @@ -44,7 +44,7 @@ - (void)testCreateWithIdentifier { instanceManager:instanceManager]; FlutterError *error; - [hostApi createWithIdentifier:@0 didFinishNavigationIdentifier:nil error:&error]; + [hostApi createWithIdentifier:@0 error:&error]; FWFNavigationDelegate *navigationDelegate = (FWFNavigationDelegate *)[instanceManager instanceForIdentifier:0]; @@ -59,7 +59,7 @@ - (void)testDidFinishNavigation { instanceManager:instanceManager]; FlutterError *error; - [hostApi createWithIdentifier:@0 didFinishNavigationIdentifier:@1 error:&error]; + [hostApi createWithIdentifier:@0 error:&error]; FWFNavigationDelegate *navigationDelegate = (FWFNavigationDelegate *)[instanceManager instanceForIdentifier:0]; id mockDelegate = OCMPartialMock(navigationDelegate); @@ -76,7 +76,7 @@ - (void)testDidFinishNavigation { [instanceManager addInstance:mockWebView withIdentifier:2]; [mockDelegate webView:mockWebView didFinishNavigation:OCMClassMock([WKNavigation class])]; - OCMVerify([mockFlutterApi didFinishNavigationFunctionWithIdentifier:@1 + OCMVerify([mockFlutterApi didFinishNavigationForDelegateWithIdentifier:@1 webViewIdentifier:@2 URL:@"https://flutter.dev/" completion:OCMOCK_ANY]); @@ -92,7 +92,7 @@ - (void)testInstanceCanBeReleasedWhenInstanceManagerIsReleased { testMessenger.hostApi = hostApi; FlutterError *error; - [hostApi createWithIdentifier:@0 didFinishNavigationIdentifier:nil error:&error]; + [hostApi createWithIdentifier:@0 error:&error]; FWFNavigationDelegate __weak *navigationDelegate = (FWFNavigationDelegate *)[instanceManager instanceForIdentifier:0]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m index 52609a5a6ba0..a35aa5f7dd26 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m @@ -19,12 +19,15 @@ - (instancetype)initWithBinaryMessenger:(id)binaryMessen return self; } -- (void)didFinishNavigationFunction:(void (^)(WKWebView *, NSString *))function +- (long)identifierForNavigationDelegate:(FWFNavigationDelegate *)instance { + return [self.instanceManager identifierForInstance:instance]; +} + +- (void)didFinishNavigationForDelegate:(FWFNavigationDelegate *)instance webView:(WKWebView *)webView URL:(NSString *)URL { - long functionIdentifier = [self.instanceManager identifierForInstance:function]; - if (functionIdentifier != NSNotFound) { - [self didFinishNavigationFunctionWithIdentifier:@(functionIdentifier) + [self didFinishNavigationForDelegateWithIdentifier:@([self.instanceManager + identifierForInstance:instance]) webViewIdentifier:@([self.instanceManager identifierForInstance:webView]) URL:URL @@ -33,14 +36,9 @@ - (void)didFinishNavigationFunction:(void (^)(WKWebView *, NSString *))function NSLog(@"%@", error.description); } }]; - } } @end -@interface FWFNavigationDelegate () -@property void (^didFinishNavigation)(WKWebView *, NSString *); -@end - @implementation FWFNavigationDelegate - (instancetype)initWithBinaryMessenger:(id)binaryMessenger instanceManager:(FWFInstanceManager *)instanceManager { @@ -49,19 +47,12 @@ - (instancetype)initWithBinaryMessenger:(id)binaryMessen _navigationDelegateApi = [[FWFNavigationDelegateFlutterApiImpl alloc] initWithBinaryMessenger:binaryMessenger instanceManager:instanceManager]; - - FWFNavigationDelegate __weak *weakSelf = self; - _didFinishNavigation = ^(WKWebView *webView, NSString *URL) { - [weakSelf.navigationDelegateApi didFinishNavigationFunction:weakSelf.didFinishNavigation - webView:webView - URL:URL]; - }; } return self; } - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { - self.didFinishNavigation(webView, webView.URL.absoluteString); + [self.navigationDelegateApi didFinishNavigationForDelegate:self webView:webView URL:webView.URL.absoluteString]; } @end @@ -86,15 +77,10 @@ - (FWFNavigationDelegate *)navigationDelegateForIdentifier:(NSNumber *)instanceI } - (void)createWithIdentifier:(nonnull NSNumber *)instanceId - didFinishNavigationIdentifier:(nullable NSNumber *)didFinishNavigationInstanceId error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { FWFNavigationDelegate *navigationDelegate = [[FWFNavigationDelegate alloc] initWithBinaryMessenger:self.binaryMessenger instanceManager:self.instanceManager]; [self.instanceManager addInstance:navigationDelegate withIdentifier:instanceId.longValue]; - if (didFinishNavigationInstanceId) { - [self.instanceManager addInstance:navigationDelegate.didFinishNavigation - withIdentifier:didFinishNavigationInstanceId.longValue]; - } } @end From f9d54e2e41f89ccec765de956e2ef9342219f5d4 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Mon, 16 May 2022 14:24:21 -0700 Subject: [PATCH 06/40] formatting --- .../FWFNavigationDelegateHostApiTests.m | 6 +- .../ios/Classes/FWFGeneratedWebKitApis.h | 262 +++- .../ios/Classes/FWFGeneratedWebKitApis.m | 1258 ++++++++++------- .../Classes/FWFNavigationDelegateHostApi.m | 30 +- 4 files changed, 926 insertions(+), 630 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m index bba3350caefb..8e158652229d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m @@ -77,9 +77,9 @@ - (void)testDidFinishNavigation { [mockDelegate webView:mockWebView didFinishNavigation:OCMClassMock([WKNavigation class])]; OCMVerify([mockFlutterApi didFinishNavigationForDelegateWithIdentifier:@1 - webViewIdentifier:@2 - URL:@"https://flutter.dev/" - completion:OCMOCK_ANY]); + webViewIdentifier:@2 + URL:@"https://flutter.dev/" + completion:OCMOCK_ANY]); } - (void)testInstanceCanBeReleasedWhenInstanceManagerIsReleased { diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h index d7a755db09bf..5f8ff7114fe0 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h @@ -126,104 +126,166 @@ typedef NS_ENUM(NSUInteger, FWFNSHttpCookiePropertyKeyEnum) { /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithUrl:(NSString *)url - httpMethod:(nullable NSString *)httpMethod - httpBody:(nullable FlutterStandardTypedData *)httpBody - allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields; -@property(nonatomic, copy) NSString * url; -@property(nonatomic, copy, nullable) NSString * httpMethod; -@property(nonatomic, strong, nullable) FlutterStandardTypedData * httpBody; -@property(nonatomic, strong) NSDictionary * allHttpHeaderFields; + httpMethod:(nullable NSString *)httpMethod + httpBody:(nullable FlutterStandardTypedData *)httpBody + allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields; +@property(nonatomic, copy) NSString *url; +@property(nonatomic, copy, nullable) NSString *httpMethod; +@property(nonatomic, strong, nullable) FlutterStandardTypedData *httpBody; +@property(nonatomic, strong) NSDictionary *allHttpHeaderFields; @end @interface FWFWKUserScriptData : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithSource:(NSString *)source - injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime - isMainFrameOnly:(NSNumber *)isMainFrameOnly; -@property(nonatomic, copy) NSString * source; -@property(nonatomic, strong, nullable) FWFWKUserScriptInjectionTimeEnumData * injectionTime; -@property(nonatomic, strong) NSNumber * isMainFrameOnly; + injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime + isMainFrameOnly:(NSNumber *)isMainFrameOnly; +@property(nonatomic, copy) NSString *source; +@property(nonatomic, strong, nullable) FWFWKUserScriptInjectionTimeEnumData *injectionTime; +@property(nonatomic, strong) NSNumber *isMainFrameOnly; @end @interface FWFNSHttpCookieData : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithPropertyKeys:(NSArray *)propertyKeys - propertyValues:(NSArray *)propertyValues; -@property(nonatomic, strong) NSArray * propertyKeys; -@property(nonatomic, strong) NSArray * propertyValues; + propertyValues:(NSArray *)propertyValues; +@property(nonatomic, strong) NSArray *propertyKeys; +@property(nonatomic, strong) NSArray *propertyValues; @end /// The codec used by FWFWKWebsiteDataStoreHostApi. NSObject *FWFWKWebsiteDataStoreHostApiGetCodec(void); @protocol FWFWKWebsiteDataStoreHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)createDefaultDataStoreWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeDataFromDataStoreWithIdentifier:(NSNumber *)instanceId ofTypes:(NSArray *)dataTypes modifiedSince:(NSNumber *)modificationTimeInSecondsSinceEpoch completion:(void(^)(NSNumber *_Nullable, FlutterError *_Nullable))completion; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId + configurationIdentifier:(NSNumber *)configurationInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createDefaultDataStoreWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeDataFromDataStoreWithIdentifier:(NSNumber *)instanceId + ofTypes:(NSArray *)dataTypes + modifiedSince:(NSNumber *)modificationTimeInSecondsSinceEpoch + completion:(void (^)(NSNumber *_Nullable, + FlutterError *_Nullable))completion; @end -extern void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKWebsiteDataStoreHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFUIViewHostApi. NSObject *FWFUIViewHostApiGetCodec(void); @protocol FWFUIViewHostApi -- (void)setBackgroundColorForViewWithIdentifier:(NSNumber *)instanceId toValue:(nullable NSNumber *)value error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setOpaqueForViewWithIdentifier:(NSNumber *)instanceId isOpaque:(NSNumber *)opaque error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setBackgroundColorForViewWithIdentifier:(NSNumber *)instanceId + toValue:(nullable NSNumber *)value + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setOpaqueForViewWithIdentifier:(NSNumber *)instanceId + isOpaque:(NSNumber *)opaque + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFUIViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFUIViewHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFUIScrollViewHostApi. NSObject *FWFUIScrollViewHostApiGetCodec(void); @protocol FWFUIScrollViewHostApi -- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId webViewIdentifier:(NSNumber *)webViewInstanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId + webViewIdentifier:(NSNumber *)webViewInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSArray *)contentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)scrollByForScrollViewWithIdentifier:(NSNumber *)instanceId x:(NSNumber *)x y:(NSNumber *)y error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setContentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId toX:(NSNumber *)x y:(NSNumber *)y error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSArray *) + contentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)scrollByForScrollViewWithIdentifier:(NSNumber *)instanceId + x:(NSNumber *)x + y:(NSNumber *)y + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setContentOffsetForScrollViewWithIdentifier:(NSNumber *)instanceId + toX:(NSNumber *)x + y:(NSNumber *)y + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFUIScrollViewHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKWebViewConfigurationHostApi. NSObject *FWFWKWebViewConfigurationHostApiGetCodec(void); @protocol FWFWKWebViewConfigurationHostApi - (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId webViewIdentifier:(NSNumber *)webViewInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:(NSNumber *)instanceId isAllowed:(NSNumber *)allow error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setMediaTypesRequiresUserActionForConfigurationWithIdentifier:(NSNumber *)instanceId forTypes:(NSArray *)types error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewWithIdentifier:(NSNumber *)instanceId + webViewIdentifier:(NSNumber *)webViewInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:(NSNumber *)instanceId + isAllowed:(NSNumber *)allow + error: + (FlutterError *_Nullable *_Nonnull) + error; +- (void) + setMediaTypesRequiresUserActionForConfigurationWithIdentifier:(NSNumber *)instanceId + forTypes: + (NSArray< + FWFWKAudiovisualMediaTypeEnumData + *> *)types + error: + (FlutterError *_Nullable *_Nonnull) + error; @end -extern void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKWebViewConfigurationHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKUserContentControllerHostApi. NSObject *FWFWKUserContentControllerHostApiGetCodec(void); @protocol FWFWKUserContentControllerHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)addScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId handlerIdentifier:(NSNumber *)handlerInstanceid ofName:(NSString *)name error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId name:(NSString *)name error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeAllScriptMessageHandlersForControllerWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)addUserScriptForControllerWithIdentifier:(NSNumber *)instanceId userScript:(FWFWKUserScriptData *)userScript error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeAllUserScriptsForControllerWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId + configurationIdentifier:(NSNumber *)configurationInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)addScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId + handlerIdentifier:(NSNumber *)handlerInstanceid + ofName:(NSString *)name + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)instanceId + name:(NSString *)name + error:(FlutterError *_Nullable *_Nonnull) + error; +- (void)removeAllScriptMessageHandlersForControllerWithIdentifier:(NSNumber *)instanceId + error: + (FlutterError *_Nullable *_Nonnull) + error; +- (void)addUserScriptForControllerWithIdentifier:(NSNumber *)instanceId + userScript:(FWFWKUserScriptData *)userScript + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeAllUserScriptsForControllerWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKUserContentControllerHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKPreferencesHostApi. NSObject *FWFWKPreferencesHostApiGetCodec(void); @protocol FWFWKPreferencesHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setJavaScriptEnabledForPreferencesWithIdentifier:(NSNumber *)instanceId isEnabled:(NSNumber *)enabled error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)instanceId + configurationIdentifier:(NSNumber *)configurationInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setJavaScriptEnabledForPreferencesWithIdentifier:(NSNumber *)instanceId + isEnabled:(NSNumber *)enabled + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKPreferencesHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKPreferencesHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKScriptMessageHandlerHostApi. NSObject *FWFWKScriptMessageHandlerHostApiGetCodec(void); @@ -232,7 +294,9 @@ NSObject *FWFWKScriptMessageHandlerHostApiGetCodec(void); - (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKScriptMessageHandlerHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKNavigationDelegateHostApi. NSObject *FWFWKNavigationDelegateHostApiGetCodec(void); @@ -241,25 +305,40 @@ NSObject *FWFWKNavigationDelegateHostApiGetCodec(void); - (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKNavigationDelegateHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKNavigationDelegateFlutterApi. NSObject *FWFWKNavigationDelegateFlutterApiGetCodec(void); @interface FWFWKNavigationDelegateFlutterApi : NSObject - (instancetype)initWithBinaryMessenger:(id)binaryMessenger; -- (void)didFinishNavigationForDelegateWithIdentifier:(NSNumber *)instanceId webViewIdentifier:(NSNumber *)webViewInstanceId URL:(nullable NSString *)url completion:(void(^)(NSError *_Nullable))completion; +- (void)didFinishNavigationForDelegateWithIdentifier:(NSNumber *)instanceId + webViewIdentifier:(NSNumber *)webViewInstanceId + URL:(nullable NSString *)url + completion:(void (^)(NSError *_Nullable))completion; @end /// The codec used by FWFNSObjectHostApi. NSObject *FWFNSObjectHostApiGetCodec(void); @protocol FWFNSObjectHostApi -- (void)disposeObjectWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)addObserverForObjectWithIdentifier:(NSNumber *)instanceId observerIdentifier:(NSNumber *)observerInstanceId keyPath:(NSString *)keyPath options:(NSArray *)options error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeObserverForObjectWithIdentifier:(NSNumber *)instanceId observerIdentifier:(NSNumber *)observerInstanceId keyPath:(NSString *)keyPath error:(FlutterError *_Nullable *_Nonnull)error; +- (void)disposeObjectWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)addObserverForObjectWithIdentifier:(NSNumber *)instanceId + observerIdentifier:(NSNumber *)observerInstanceId + keyPath:(NSString *)keyPath + options: + (NSArray *)options + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeObserverForObjectWithIdentifier:(NSNumber *)instanceId + observerIdentifier:(NSNumber *)observerInstanceId + keyPath:(NSString *)keyPath + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFNSObjectHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFNSObjectHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFNSObjectFlutterApi. NSObject *FWFNSObjectFlutterApiGetCodec(void); @@ -271,30 +350,65 @@ NSObject *FWFNSObjectFlutterApiGetCodec(void); NSObject *FWFWKWebViewHostApiGetCodec(void); @protocol FWFWKWebViewHostApi -- (void)createWithIdentifier:(NSNumber *)instanceId configurationIdentifier:(NSNumber *)configurationInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setUIDelegateForWebViewWithIdentifier:(NSNumber *)instanceId delegateIdentifier:(nullable NSNumber *)uiDelegateInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setNavigationDelegateForWebViewWithIdentifier:(NSNumber *)instanceId delegateIdentifier:(nullable NSNumber *)navigationDelegateInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (nullable NSString *)URLForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createWithIdentifier:(NSNumber *)instanceId + configurationIdentifier:(NSNumber *)configurationInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setUIDelegateForWebViewWithIdentifier:(NSNumber *)instanceId + delegateIdentifier:(nullable NSNumber *)uiDelegateInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setNavigationDelegateForWebViewWithIdentifier:(NSNumber *)instanceId + delegateIdentifier: + (nullable NSNumber *)navigationDelegateInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSString *)URLForWebViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)estimatedProgressForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadRequestForWebViewWithIdentifier:(NSNumber *)instanceId request:(FWFNSUrlRequestData *)request error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadHTMLForWebViewWithIdentifier:(NSNumber *)instanceId HTMLString:(NSString *)string baseURL:(nullable NSString *)baseUrl error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadFileForWebViewWithIdentifier:(NSNumber *)instanceId fileURL:(NSString *)url readAccessURL:(NSString *)readAccessUrl error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadAssetForWebViewWithIdentifier:(NSNumber *)instanceId assetKey:(NSString *)key error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSNumber *)estimatedProgressForWebViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull) + error; +- (void)loadRequestForWebViewWithIdentifier:(NSNumber *)instanceId + request:(FWFNSUrlRequestData *)request + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadHTMLForWebViewWithIdentifier:(NSNumber *)instanceId + HTMLString:(NSString *)string + baseURL:(nullable NSString *)baseUrl + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadFileForWebViewWithIdentifier:(NSNumber *)instanceId + fileURL:(NSString *)url + readAccessURL:(NSString *)readAccessUrl + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadAssetForWebViewWithIdentifier:(NSNumber *)instanceId + assetKey:(NSString *)key + error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)canGoBackForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSNumber *)canGoBackForWebViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)canGoForwardForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)goBackForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)goForwardForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)reloadWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (nullable NSString *)titleForWebViewWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setAllowsBackForwardForWebViewWithIdentifier:(NSNumber *)instanceId isAllowed:(NSNumber *)allow error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setUserAgentForWebViewWithIdentifier:(NSNumber *)instanceId userAgent:(nullable NSString *)userAgent error:(FlutterError *_Nullable *_Nonnull)error; -- (void)evaluateJavaScriptForWebViewWithIdentifier:(NSNumber *)instanceId javaScriptString:(NSString *)javaScriptString completion:(void(^)(id _Nullable, FlutterError *_Nullable))completion; +- (nullable NSNumber *)canGoForwardForWebViewWithIdentifier:(NSNumber *)instanceId + error: + (FlutterError *_Nullable *_Nonnull)error; +- (void)goBackForWebViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)goForwardForWebViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)reloadWebViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSString *)titleForWebViewWithIdentifier:(NSNumber *)instanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setAllowsBackForwardForWebViewWithIdentifier:(NSNumber *)instanceId + isAllowed:(NSNumber *)allow + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setUserAgentForWebViewWithIdentifier:(NSNumber *)instanceId + userAgent:(nullable NSString *)userAgent + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)evaluateJavaScriptForWebViewWithIdentifier:(NSNumber *)instanceId + javaScriptString:(NSString *)javaScriptString + completion:(void (^)(id _Nullable, + FlutterError *_Nullable))completion; @end -extern void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKWebViewHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKUIDelegateHostApi. NSObject *FWFWKUIDelegateHostApiGetCodec(void); @@ -303,16 +417,22 @@ NSObject *FWFWKUIDelegateHostApiGetCodec(void); - (void)createWithIdentifier:(NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKUIDelegateHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKHttpCookieStoreHostApi. NSObject *FWFWKHttpCookieStoreHostApiGetCodec(void); @protocol FWFWKHttpCookieStoreHostApi -- (void)createFromWebsiteDataStoreWithIdentifier:(NSNumber *)instanceId dataStoreIdentifier:(NSNumber *)websiteDataStoreInstanceId error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setCookieForStoreWithIdentifier:(NSNumber *)instanceId cookie:(FWFNSHttpCookieData *)cookie completion:(void(^)(FlutterError *_Nullable))completion; +- (void)createFromWebsiteDataStoreWithIdentifier:(NSNumber *)instanceId + dataStoreIdentifier:(NSNumber *)websiteDataStoreInstanceId + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setCookieForStoreWithIdentifier:(NSNumber *)instanceId + cookie:(FWFNSHttpCookieData *)cookie + completion:(void (^)(FlutterError *_Nullable))completion; @end -extern void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); NS_ASSUME_NONNULL_END diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m index 8a4ef78f2c91..caf407a2b1a9 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m @@ -14,26 +14,25 @@ NSDictionary *errorDict = (NSDictionary *)[NSNull null]; if (error) { errorDict = @{ - @"code": (error.code ? error.code : [NSNull null]), - @"message": (error.message ? error.message : [NSNull null]), - @"details": (error.details ? error.details : [NSNull null]), - }; + @"code" : (error.code ? error.code : [NSNull null]), + @"message" : (error.message ? error.message : [NSNull null]), + @"details" : (error.details ? error.details : [NSNull null]), + }; } return @{ - @"result": (result ? result : [NSNull null]), - @"error": errorDict, - }; + @"result" : (result ? result : [NSNull null]), + @"error" : errorDict, + }; } -static id GetNullableObject(NSDictionary* dict, id key) { +static id GetNullableObject(NSDictionary *dict, id key) { id result = dict[key]; return (result == [NSNull null]) ? nil : result; } -static id GetNullableObjectAtIndex(NSArray* array, NSInteger key) { +static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { id result = array[key]; return (result == [NSNull null]) ? nil : result; } - @interface FWFNSKeyValueObservingOptionsEnumData () + (FWFNSKeyValueObservingOptionsEnumData *)fromMap:(NSDictionary *)dict; - (NSDictionary *)toMap; @@ -69,12 +68,14 @@ - (NSDictionary *)toMap; @implementation FWFNSKeyValueObservingOptionsEnumData + (instancetype)makeWithValue:(FWFNSKeyValueObservingOptionsEnum)value { - FWFNSKeyValueObservingOptionsEnumData* pigeonResult = [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; + FWFNSKeyValueObservingOptionsEnumData *pigeonResult = + [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFNSKeyValueObservingOptionsEnumData *)fromMap:(NSDictionary *)dict { - FWFNSKeyValueObservingOptionsEnumData *pigeonResult = [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; + FWFNSKeyValueObservingOptionsEnumData *pigeonResult = + [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -85,12 +86,14 @@ - (NSDictionary *)toMap { @implementation FWFWKUserScriptInjectionTimeEnumData + (instancetype)makeWithValue:(FWFWKUserScriptInjectionTimeEnum)value { - FWFWKUserScriptInjectionTimeEnumData* pigeonResult = [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; + FWFWKUserScriptInjectionTimeEnumData *pigeonResult = + [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFWKUserScriptInjectionTimeEnumData *)fromMap:(NSDictionary *)dict { - FWFWKUserScriptInjectionTimeEnumData *pigeonResult = [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; + FWFWKUserScriptInjectionTimeEnumData *pigeonResult = + [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -101,12 +104,14 @@ - (NSDictionary *)toMap { @implementation FWFWKAudiovisualMediaTypeEnumData + (instancetype)makeWithValue:(FWFWKAudiovisualMediaTypeEnum)value { - FWFWKAudiovisualMediaTypeEnumData* pigeonResult = [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; + FWFWKAudiovisualMediaTypeEnumData *pigeonResult = + [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFWKAudiovisualMediaTypeEnumData *)fromMap:(NSDictionary *)dict { - FWFWKAudiovisualMediaTypeEnumData *pigeonResult = [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; + FWFWKAudiovisualMediaTypeEnumData *pigeonResult = + [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -117,7 +122,7 @@ - (NSDictionary *)toMap { @implementation FWFWKWebsiteDataTypeEnumData + (instancetype)makeWithValue:(FWFWKWebsiteDataTypeEnum)value { - FWFWKWebsiteDataTypeEnumData* pigeonResult = [[FWFWKWebsiteDataTypeEnumData alloc] init]; + FWFWKWebsiteDataTypeEnumData *pigeonResult = [[FWFWKWebsiteDataTypeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } @@ -133,12 +138,14 @@ - (NSDictionary *)toMap { @implementation FWFNSHttpCookiePropertyKeyEnumData + (instancetype)makeWithValue:(FWFNSHttpCookiePropertyKeyEnum)value { - FWFNSHttpCookiePropertyKeyEnumData* pigeonResult = [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; + FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = + [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFNSHttpCookiePropertyKeyEnumData *)fromMap:(NSDictionary *)dict { - FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; + FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = + [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -149,10 +156,10 @@ - (NSDictionary *)toMap { @implementation FWFNSUrlRequestData + (instancetype)makeWithUrl:(NSString *)url - httpMethod:(nullable NSString *)httpMethod - httpBody:(nullable FlutterStandardTypedData *)httpBody - allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields { - FWFNSUrlRequestData* pigeonResult = [[FWFNSUrlRequestData alloc] init]; + httpMethod:(nullable NSString *)httpMethod + httpBody:(nullable FlutterStandardTypedData *)httpBody + allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields { + FWFNSUrlRequestData *pigeonResult = [[FWFNSUrlRequestData alloc] init]; pigeonResult.url = url; pigeonResult.httpMethod = httpMethod; pigeonResult.httpBody = httpBody; @@ -170,15 +177,22 @@ + (FWFNSUrlRequestData *)fromMap:(NSDictionary *)dict { return pigeonResult; } - (NSDictionary *)toMap { - return [NSDictionary dictionaryWithObjectsAndKeys:(self.url ? self.url : [NSNull null]), @"url", (self.httpMethod ? self.httpMethod : [NSNull null]), @"httpMethod", (self.httpBody ? self.httpBody : [NSNull null]), @"httpBody", (self.allHttpHeaderFields ? self.allHttpHeaderFields : [NSNull null]), @"allHttpHeaderFields", nil]; + return [NSDictionary + dictionaryWithObjectsAndKeys:(self.url ? self.url : [NSNull null]), @"url", + (self.httpMethod ? self.httpMethod : [NSNull null]), + @"httpMethod", (self.httpBody ? self.httpBody : [NSNull null]), + @"httpBody", + (self.allHttpHeaderFields ? self.allHttpHeaderFields + : [NSNull null]), + @"allHttpHeaderFields", nil]; } @end @implementation FWFWKUserScriptData + (instancetype)makeWithSource:(NSString *)source - injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime - isMainFrameOnly:(NSNumber *)isMainFrameOnly { - FWFWKUserScriptData* pigeonResult = [[FWFWKUserScriptData alloc] init]; + injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime + isMainFrameOnly:(NSNumber *)isMainFrameOnly { + FWFWKUserScriptData *pigeonResult = [[FWFWKUserScriptData alloc] init]; pigeonResult.source = source; pigeonResult.injectionTime = injectionTime; pigeonResult.isMainFrameOnly = isMainFrameOnly; @@ -188,20 +202,27 @@ + (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 fromMap:GetNullableObject(dict, @"injectionTime")]; pigeonResult.isMainFrameOnly = GetNullableObject(dict, @"isMainFrameOnly"); NSAssert(pigeonResult.isMainFrameOnly != nil, @""); return pigeonResult; } - (NSDictionary *)toMap { - return [NSDictionary dictionaryWithObjectsAndKeys:(self.source ? self.source : [NSNull null]), @"source", (self.injectionTime ? [self.injectionTime toMap] : [NSNull null]), @"injectionTime", (self.isMainFrameOnly ? self.isMainFrameOnly : [NSNull null]), @"isMainFrameOnly", nil]; + return [NSDictionary + dictionaryWithObjectsAndKeys:(self.source ? self.source : [NSNull null]), @"source", + (self.injectionTime ? [self.injectionTime toMap] + : [NSNull null]), + @"injectionTime", + (self.isMainFrameOnly ? self.isMainFrameOnly : [NSNull null]), + @"isMainFrameOnly", nil]; } @end @implementation FWFNSHttpCookieData + (instancetype)makeWithPropertyKeys:(NSArray *)propertyKeys - propertyValues:(NSArray *)propertyValues { - FWFNSHttpCookieData* pigeonResult = [[FWFNSHttpCookieData alloc] init]; + propertyValues:(NSArray *)propertyValues { + FWFNSHttpCookieData *pigeonResult = [[FWFNSHttpCookieData alloc] init]; pigeonResult.propertyKeys = propertyKeys; pigeonResult.propertyValues = propertyValues; return pigeonResult; @@ -215,22 +236,24 @@ + (FWFNSHttpCookieData *)fromMap:(NSDictionary *)dict { return pigeonResult; } - (NSDictionary *)toMap { - return [NSDictionary dictionaryWithObjectsAndKeys:(self.propertyKeys ? self.propertyKeys : [NSNull null]), @"propertyKeys", (self.propertyValues ? self.propertyValues : [NSNull null]), @"propertyValues", nil]; + return [NSDictionary + dictionaryWithObjectsAndKeys:(self.propertyKeys ? self.propertyKeys : [NSNull null]), + @"propertyKeys", + (self.propertyValues ? self.propertyValues : [NSNull null]), + @"propertyValues", nil]; } @end @interface FWFWKWebsiteDataStoreHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebsiteDataStoreHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFWKWebsiteDataTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -238,13 +261,11 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKWebsiteDataStoreHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebsiteDataStoreHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -265,43 +286,52 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebsiteDataStoreHostApiCodecReaderWriter *readerWriter = [[FWFWKWebsiteDataStoreHostApiCodecReaderWriter alloc] init]; + FWFWKWebsiteDataStoreHostApiCodecReaderWriter *readerWriter = + [[FWFWKWebsiteDataStoreHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: + configurationIdentifier:error:)], + @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_instanceId + configurationIdentifier:arg_configurationInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createDefaultDataStoreWithIdentifier:error:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(createDefaultDataStoreWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createDefaultDataStoreWithIdentifier:error:)], + @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " + @"@selector(createDefaultDataStoreWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -309,30 +339,36 @@ void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenge [api createDefaultDataStoreWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)", api); + NSCAssert( + [api respondsToSelector:@selector + (removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)], + @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " + @"@selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSArray *arg_dataTypes = GetNullableObjectAtIndex(args, 1); NSNumber *arg_modificationTimeInSecondsSinceEpoch = GetNullableObjectAtIndex(args, 2); - [api removeDataFromDataStoreWithIdentifier:arg_instanceId ofTypes:arg_dataTypes modifiedSince:arg_modificationTimeInSecondsSinceEpoch completion:^(NSNumber *_Nullable output, FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; + [api removeDataFromDataStoreWithIdentifier:arg_instanceId + ofTypes:arg_dataTypes + modifiedSince:arg_modificationTimeInSecondsSinceEpoch + completion:^(NSNumber *_Nullable output, + FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -362,22 +398,26 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFUIViewHostApiCodecReaderWriter *readerWriter = [[FWFUIViewHostApiCodecReaderWriter alloc] init]; + FWFUIViewHostApiCodecReaderWriter *readerWriter = + [[FWFUIViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFUIViewHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFUIViewHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIViewHostApi.setBackgroundColor" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIViewHostApi.setBackgroundColor" binaryMessenger:binaryMessenger - codec:FWFUIViewHostApiGetCodec() ]; + codec:FWFUIViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setBackgroundColorForViewWithIdentifier:toValue:error:)], @"FWFUIViewHostApi api (%@) doesn't respond to @selector(setBackgroundColorForViewWithIdentifier:toValue:error:)", api); + NSCAssert([api respondsToSelector:@selector(setBackgroundColorForViewWithIdentifier: + toValue:error:)], + @"FWFUIViewHostApi api (%@) doesn't respond to " + @"@selector(setBackgroundColorForViewWithIdentifier:toValue:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -386,19 +426,20 @@ void FWFUIViewHostApiSetup(id binaryMessenger, NSObject< [api setBackgroundColorForViewWithIdentifier:arg_instanceId toValue:arg_value error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIViewHostApi.setOpaque" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIViewHostApi.setOpaque" binaryMessenger:binaryMessenger - codec:FWFUIViewHostApiGetCodec() ]; + codec:FWFUIViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)], @"FWFUIViewHostApi api (%@) doesn't respond to @selector(setOpaqueForViewWithIdentifier:isOpaque:error:)", api); + NSCAssert([api respondsToSelector:@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)], + @"FWFUIViewHostApi api (%@) doesn't respond to " + @"@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -407,8 +448,7 @@ void FWFUIViewHostApiSetup(id binaryMessenger, NSObject< [api setOpaqueForViewWithIdentifier:arg_instanceId isOpaque:arg_opaque error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -438,63 +478,72 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFUIScrollViewHostApiCodecReaderWriter *readerWriter = [[FWFUIScrollViewHostApiCodecReaderWriter alloc] init]; + FWFUIScrollViewHostApiCodecReaderWriter *readerWriter = + [[FWFUIScrollViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFUIScrollViewHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec() ]; + codec:FWFUIScrollViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier: + webViewIdentifier:error:)], + @"FWFUIScrollViewHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_webViewInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewWithIdentifier:arg_instanceId webViewIdentifier:arg_webViewInstanceId error:&error]; + [api createFromWebViewWithIdentifier:arg_instanceId + webViewIdentifier:arg_webViewInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec() ]; + codec:FWFUIScrollViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(contentOffsetForScrollViewWithIdentifier:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(contentOffsetForScrollViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(contentOffsetForScrollViewWithIdentifier:error:)], + @"FWFUIScrollViewHostApi api (%@) doesn't respond to " + @"@selector(contentOffsetForScrollViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FlutterError *error; - NSArray *output = [api contentOffsetForScrollViewWithIdentifier:arg_instanceId error:&error]; + NSArray *output = [api contentOffsetForScrollViewWithIdentifier:arg_instanceId + error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.scrollBy" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.scrollBy" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec() ]; + codec:FWFUIScrollViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(scrollByForScrollViewWithIdentifier:x:y:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(scrollByForScrollViewWithIdentifier:x:y:error:)", api); + NSCAssert([api respondsToSelector:@selector(scrollByForScrollViewWithIdentifier:x:y:error:)], + @"FWFUIScrollViewHostApi api (%@) doesn't respond to " + @"@selector(scrollByForScrollViewWithIdentifier:x:y:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -504,30 +553,34 @@ void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSO [api scrollByForScrollViewWithIdentifier:arg_instanceId x:arg_x y:arg_y error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec() ]; + codec:FWFUIScrollViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)", api); + NSCAssert([api respondsToSelector:@selector + (setContentOffsetForScrollViewWithIdentifier:toX:y:error:)], + @"FWFUIScrollViewHostApi api (%@) doesn't respond to " + @"@selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_x = GetNullableObjectAtIndex(args, 1); NSNumber *arg_y = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api setContentOffsetForScrollViewWithIdentifier:arg_instanceId toX:arg_x y:arg_y error:&error]; + [api setContentOffsetForScrollViewWithIdentifier:arg_instanceId + toX:arg_x + y:arg_y + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -535,15 +588,13 @@ void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSO @interface FWFWKWebViewConfigurationHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebViewConfigurationHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFWKAudiovisualMediaTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -551,13 +602,11 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKWebViewConfigurationHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebViewConfigurationHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -578,22 +627,25 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebViewConfigurationHostApiCodecReaderWriter *readerWriter = [[FWFWKWebViewConfigurationHostApiCodecReaderWriter alloc] init]; + FWFWKWebViewConfigurationHostApiCodecReaderWriter *readerWriter = + [[FWFWKWebViewConfigurationHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; + codec:FWFWKWebViewConfigurationHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], + @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -601,71 +653,87 @@ void FWFWKWebViewConfigurationHostApiSetup(id binaryMess [api createWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; + codec:FWFWKWebViewConfigurationHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier: + webViewIdentifier:error:)], + @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_webViewInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewWithIdentifier:arg_instanceId webViewIdentifier:arg_webViewInstanceId error:&error]; + [api createFromWebViewWithIdentifier:arg_instanceId + webViewIdentifier:arg_webViewInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; + codec:FWFWKWebViewConfigurationHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)", api); + NSCAssert( + [api respondsToSelector:@selector + (setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)], + @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " + @"@selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_allow = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:arg_instanceId isAllowed:arg_allow error:&error]; + [api setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:arg_instanceId + isAllowed:arg_allow + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi." + @"setMediaTypesRequiringUserActionForPlayback" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; + codec:FWFWKWebViewConfigurationHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:error:)", api); + NSCAssert([api respondsToSelector:@selector + (setMediaTypesRequiresUserActionForConfigurationWithIdentifier: + forTypes:error:)], + @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " + @"@selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:" + @"error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSArray *arg_types = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setMediaTypesRequiresUserActionForConfigurationWithIdentifier:arg_instanceId forTypes:arg_types error:&error]; + [api setMediaTypesRequiresUserActionForConfigurationWithIdentifier:arg_instanceId + forTypes:arg_types + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -673,18 +741,16 @@ void FWFWKWebViewConfigurationHostApiSetup(id binaryMess @interface FWFWKUserContentControllerHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKUserContentControllerHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFWKUserScriptData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFWKUserScriptInjectionTimeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -692,17 +758,14 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKUserContentControllerHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKUserContentControllerHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFWKUserScriptData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -723,86 +786,109 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKUserContentControllerHostApiCodecReaderWriter *readerWriter = [[FWFWKUserContentControllerHostApiCodecReaderWriter alloc] init]; + FWFWKUserContentControllerHostApiCodecReaderWriter *readerWriter = + [[FWFWKUserContentControllerHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: + configurationIdentifier:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_instanceId + configurationIdentifier:arg_configurationInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:ofName:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:ofName:error:)", api); + NSCAssert([api respondsToSelector:@selector + (addScriptMessageHandlerForControllerWithIdentifier: + handlerIdentifier:ofName:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:" + @"ofName:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_handlerInstanceid = GetNullableObjectAtIndex(args, 1); NSString *arg_name = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api addScriptMessageHandlerForControllerWithIdentifier:arg_instanceId handlerIdentifier:arg_handlerInstanceid ofName:arg_name error:&error]; + [api addScriptMessageHandlerForControllerWithIdentifier:arg_instanceId + handlerIdentifier:arg_handlerInstanceid + ofName:arg_name + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)", api); + NSCAssert([api respondsToSelector:@selector + (removeScriptMessageHandlerForControllerWithIdentifier:name:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_name = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api removeScriptMessageHandlerForControllerWithIdentifier:arg_instanceId name:arg_name error:&error]; + [api removeScriptMessageHandlerForControllerWithIdentifier:arg_instanceId + name:arg_name + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector + (removeAllScriptMessageHandlersForControllerWithIdentifier:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -810,40 +896,46 @@ void FWFWKUserContentControllerHostApiSetup(id binaryMes [api removeAllScriptMessageHandlersForControllerWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(addUserScriptForControllerWithIdentifier:userScript:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(addUserScriptForControllerWithIdentifier:userScript:error:)", api); + NSCAssert([api respondsToSelector:@selector(addUserScriptForControllerWithIdentifier: + userScript:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(addUserScriptForControllerWithIdentifier:userScript:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FWFWKUserScriptData *arg_userScript = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api addUserScriptForControllerWithIdentifier:arg_instanceId userScript:arg_userScript error:&error]; + [api addUserScriptForControllerWithIdentifier:arg_instanceId + userScript:arg_userScript + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeAllUserScriptsForControllerWithIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeAllUserScriptsForControllerWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector + (removeAllUserScriptsForControllerWithIdentifier:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(removeAllUserScriptsForControllerWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -851,8 +943,7 @@ void FWFWKUserContentControllerHostApiSetup(id binaryMes [api removeAllUserScriptsForControllerWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -882,53 +973,63 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKPreferencesHostApiCodecReaderWriter *readerWriter = [[FWFWKPreferencesHostApiCodecReaderWriter alloc] init]; + FWFWKPreferencesHostApiCodecReaderWriter *readerWriter = + [[FWFWKPreferencesHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKPreferencesHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKPreferencesHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKPreferencesHostApiGetCodec() ]; + codec:FWFWKPreferencesHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKPreferencesHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: + configurationIdentifier:error:)], + @"FWFWKPreferencesHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_instanceId + configurationIdentifier:arg_configurationInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled" binaryMessenger:binaryMessenger - codec:FWFWKPreferencesHostApiGetCodec() ]; + codec:FWFWKPreferencesHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)], @"FWFWKPreferencesHostApi api (%@) doesn't respond to @selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)", api); + NSCAssert([api respondsToSelector:@selector + (setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)], + @"FWFWKPreferencesHostApi api (%@) doesn't respond to " + @"@selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_enabled = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setJavaScriptEnabledForPreferencesWithIdentifier:arg_instanceId isEnabled:arg_enabled error:&error]; + [api setJavaScriptEnabledForPreferencesWithIdentifier:arg_instanceId + isEnabled:arg_enabled + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -958,22 +1059,25 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKScriptMessageHandlerHostApiCodecReaderWriter *readerWriter = [[FWFWKScriptMessageHandlerHostApiCodecReaderWriter alloc] init]; + FWFWKScriptMessageHandlerHostApiCodecReaderWriter *readerWriter = + [[FWFWKScriptMessageHandlerHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKScriptMessageHandlerHostApiGetCodec() ]; + codec:FWFWKScriptMessageHandlerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKScriptMessageHandlerHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], + @"FWFWKScriptMessageHandlerHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -981,8 +1085,7 @@ void FWFWKScriptMessageHandlerHostApiSetup(id binaryMess [api createWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -1012,22 +1115,25 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKNavigationDelegateHostApiCodecReaderWriter *readerWriter = [[FWFWKNavigationDelegateHostApiCodecReaderWriter alloc] init]; + FWFWKNavigationDelegateHostApiCodecReaderWriter *readerWriter = + [[FWFWKNavigationDelegateHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKNavigationDelegateHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKNavigationDelegateHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKNavigationDelegateHostApiGetCodec() ]; + codec:FWFWKNavigationDelegateHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKNavigationDelegateHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], + @"FWFWKNavigationDelegateHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1035,8 +1141,7 @@ void FWFWKNavigationDelegateHostApiSetup(id binaryMessen [api createWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -1066,15 +1171,15 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKNavigationDelegateFlutterApiCodecReaderWriter *readerWriter = [[FWFWKNavigationDelegateFlutterApiCodecReaderWriter alloc] init]; + FWFWKNavigationDelegateFlutterApiCodecReaderWriter *readerWriter = + [[FWFWKNavigationDelegateFlutterApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - @interface FWFWKNavigationDelegateFlutterApi () -@property (nonatomic, strong) NSObject *binaryMessenger; +@property(nonatomic, strong) NSObject *binaryMessenger; @end @implementation FWFWKNavigationDelegateFlutterApi @@ -1086,29 +1191,35 @@ - (instancetype)initWithBinaryMessenger:(NSObject *)bina } return self; } -- (void)didFinishNavigationForDelegateWithIdentifier:(NSNumber *)arg_instanceId webViewIdentifier:(NSNumber *)arg_webViewInstanceId URL:(nullable NSString *)arg_url completion:(void(^)(NSError *_Nullable))completion { - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel - messageChannelWithName:@"dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation" - binaryMessenger:self.binaryMessenger - codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; - [channel sendMessage:@[(arg_instanceId == nil) ? [NSNull null] : arg_instanceId, (arg_webViewInstanceId == nil) ? [NSNull null] : arg_webViewInstanceId, (arg_url == nil) ? [NSNull null] : arg_url] reply:^(id reply) { - completion(nil); - }]; +- (void)didFinishNavigationForDelegateWithIdentifier:(NSNumber *)arg_instanceId + webViewIdentifier:(NSNumber *)arg_webViewInstanceId + URL:(nullable NSString *)arg_url + completion:(void (^)(NSError *_Nullable))completion { + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel + messageChannelWithName: + @"dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation" + binaryMessenger:self.binaryMessenger + codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; + [channel sendMessage:@[ + (arg_instanceId == nil) ? [NSNull null] : arg_instanceId, + (arg_webViewInstanceId == nil) ? [NSNull null] : arg_webViewInstanceId, + (arg_url == nil) ? [NSNull null] : arg_url + ] + reply:^(id reply) { + completion(nil); + }]; } @end @interface FWFNSObjectHostApiCodecReader : FlutterStandardReader @end @implementation FWFNSObjectHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFNSKeyValueObservingOptionsEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -1116,13 +1227,11 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFNSObjectHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFNSObjectHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -1143,22 +1252,25 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFNSObjectHostApiCodecReaderWriter *readerWriter = [[FWFNSObjectHostApiCodecReaderWriter alloc] init]; + FWFNSObjectHostApiCodecReaderWriter *readerWriter = + [[FWFNSObjectHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFNSObjectHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFNSObjectHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.dispose" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.dispose" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec() ]; + codec:FWFNSObjectHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(disposeObjectWithIdentifier:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(disposeObjectWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(disposeObjectWithIdentifier:error:)], + @"FWFNSObjectHostApi api (%@) doesn't respond to " + @"@selector(disposeObjectWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1166,53 +1278,67 @@ void FWFNSObjectHostApiSetup(id binaryMessenger, NSObjec [api disposeObjectWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.addObserver" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.addObserver" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec() ]; + codec:FWFNSObjectHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:error:)", api); + NSCAssert([api respondsToSelector:@selector + (addObserverForObjectWithIdentifier: + observerIdentifier:keyPath:options:error:)], + @"FWFNSObjectHostApi api (%@) doesn't respond to " + @"@selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:" + @"error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_observerInstanceId = GetNullableObjectAtIndex(args, 1); NSString *arg_keyPath = GetNullableObjectAtIndex(args, 2); - NSArray *arg_options = GetNullableObjectAtIndex(args, 3); + NSArray *arg_options = + GetNullableObjectAtIndex(args, 3); FlutterError *error; - [api addObserverForObjectWithIdentifier:arg_instanceId observerIdentifier:arg_observerInstanceId keyPath:arg_keyPath options:arg_options error:&error]; + [api addObserverForObjectWithIdentifier:arg_instanceId + observerIdentifier:arg_observerInstanceId + keyPath:arg_keyPath + options:arg_options + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.removeObserver" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.removeObserver" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec() ]; + codec:FWFNSObjectHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(removeObserverForObjectWithIdentifier: + observerIdentifier:keyPath:error:)], + @"FWFNSObjectHostApi api (%@) doesn't respond to " + @"@selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_observerInstanceId = GetNullableObjectAtIndex(args, 1); NSString *arg_keyPath = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api removeObserverForObjectWithIdentifier:arg_instanceId observerIdentifier:arg_observerInstanceId keyPath:arg_keyPath error:&error]; + [api removeObserverForObjectWithIdentifier:arg_instanceId + observerIdentifier:arg_observerInstanceId + keyPath:arg_keyPath + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -1242,15 +1368,15 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFNSObjectFlutterApiCodecReaderWriter *readerWriter = [[FWFNSObjectFlutterApiCodecReaderWriter alloc] init]; + FWFNSObjectFlutterApiCodecReaderWriter *readerWriter = + [[FWFNSObjectFlutterApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - @interface FWFNSObjectFlutterApi () -@property (nonatomic, strong) NSObject *binaryMessenger; +@property(nonatomic, strong) NSObject *binaryMessenger; @end @implementation FWFNSObjectFlutterApi @@ -1266,36 +1392,34 @@ - (instancetype)initWithBinaryMessenger:(NSObject *)bina @interface FWFWKWebViewHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebViewHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFNSHttpCookieData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFNSHttpCookiePropertyKeyEnumData fromMap:[self readValue]]; - - case 130: + + case 130: return [FWFNSKeyValueObservingOptionsEnumData fromMap:[self readValue]]; - - case 131: + + case 131: return [FWFNSUrlRequestData fromMap:[self readValue]]; - - case 132: + + case 132: return [FWFWKAudiovisualMediaTypeEnumData fromMap:[self readValue]]; - - case 133: + + case 133: return [FWFWKUserScriptData fromMap:[self readValue]]; - - case 134: + + case 134: return [FWFWKUserScriptInjectionTimeEnumData fromMap:[self readValue]]; - - case 135: + + case 135: return [FWFWKWebsiteDataTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -1303,41 +1427,32 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKWebViewHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebViewHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFNSHttpCookieData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { + } else if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { + } else if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { [self writeByte:130]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFNSUrlRequestData class]]) { + } else if ([value isKindOfClass:[FWFNSUrlRequestData class]]) { [self writeByte:131]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { [self writeByte:132]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKUserScriptData class]]) { + } else if ([value isKindOfClass:[FWFWKUserScriptData class]]) { [self writeByte:133]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { [self writeByte:134]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { [self writeByte:135]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -1358,85 +1473,101 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebViewHostApiCodecReaderWriter *readerWriter = [[FWFWKWebViewHostApiCodecReaderWriter alloc] init]; + FWFWKWebViewHostApiCodecReaderWriter *readerWriter = + [[FWFWKWebViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKWebViewHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:configurationIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(createWithIdentifier:configurationIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier: + configurationIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:configurationIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createWithIdentifier:arg_instanceId configurationIdentifier:arg_configurationInstanceId error:&error]; + [api createWithIdentifier:arg_instanceId + configurationIdentifier:arg_configurationInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(setUIDelegateForWebViewWithIdentifier: + delegateIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_uiDelegateInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setUIDelegateForWebViewWithIdentifier:arg_instanceId delegateIdentifier:arg_uiDelegateInstanceId error:&error]; + [api setUIDelegateForWebViewWithIdentifier:arg_instanceId + delegateIdentifier:arg_uiDelegateInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(setNavigationDelegateForWebViewWithIdentifier: + delegateIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_navigationDelegateInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setNavigationDelegateForWebViewWithIdentifier:arg_instanceId delegateIdentifier:arg_navigationDelegateInstanceId error:&error]; + [api setNavigationDelegateForWebViewWithIdentifier:arg_instanceId + delegateIdentifier:arg_navigationDelegateInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getUrl" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getUrl" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(URLForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(URLForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(URLForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(URLForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1444,39 +1575,44 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje NSString *output = [api URLForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(estimatedProgressForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(estimatedProgressForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(estimatedProgressForWebViewWithIdentifier: + error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(estimatedProgressForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FlutterError *error; - NSNumber *output = [api estimatedProgressForWebViewWithIdentifier:arg_instanceId error:&error]; + NSNumber *output = [api estimatedProgressForWebViewWithIdentifier:arg_instanceId + error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadRequest" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadRequest" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadRequestForWebViewWithIdentifier:request:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadRequestForWebViewWithIdentifier:request:error:)", api); + NSCAssert([api respondsToSelector:@selector(loadRequestForWebViewWithIdentifier: + request:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(loadRequestForWebViewWithIdentifier:request:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1485,63 +1621,75 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api loadRequestForWebViewWithIdentifier:arg_instanceId request:arg_request error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)", api); + NSCAssert([api respondsToSelector:@selector(loadHTMLForWebViewWithIdentifier: + HTMLString:baseURL:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_string = GetNullableObjectAtIndex(args, 1); NSString *arg_baseUrl = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api loadHTMLForWebViewWithIdentifier:arg_instanceId HTMLString:arg_string baseURL:arg_baseUrl error:&error]; + [api loadHTMLForWebViewWithIdentifier:arg_instanceId + HTMLString:arg_string + baseURL:arg_baseUrl + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)", api); + NSCAssert([api respondsToSelector:@selector + (loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_url = GetNullableObjectAtIndex(args, 1); NSString *arg_readAccessUrl = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api loadFileForWebViewWithIdentifier:arg_instanceId fileURL:arg_url readAccessURL:arg_readAccessUrl error:&error]; + [api loadFileForWebViewWithIdentifier:arg_instanceId + fileURL:arg_url + readAccessURL:arg_readAccessUrl + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadAssetForWebViewWithIdentifier:assetKey:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadAssetForWebViewWithIdentifier:assetKey:error:)", api); + NSCAssert([api respondsToSelector:@selector(loadAssetForWebViewWithIdentifier: + assetKey:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(loadAssetForWebViewWithIdentifier:assetKey:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1550,19 +1698,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api loadAssetForWebViewWithIdentifier:arg_instanceId assetKey:arg_key error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoBack" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoBack" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(canGoBackForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(canGoBackForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(canGoBackForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(canGoBackForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1570,19 +1719,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje NSNumber *output = [api canGoBackForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoForward" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoForward" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(canGoForwardForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(canGoForwardForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(canGoForwardForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(canGoForwardForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1590,19 +1740,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje NSNumber *output = [api canGoForwardForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goBack" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goBack" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(goBackForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(goBackForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(goBackForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(goBackForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1610,19 +1761,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api goBackForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goForward" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goForward" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(goForwardForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(goForwardForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(goForwardForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(goForwardForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1630,19 +1782,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api goForwardForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.reload" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.reload" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(reloadWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(reloadWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(reloadWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(reloadWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1650,19 +1803,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api reloadWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getTitle" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getTitle" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(titleForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(titleForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(titleForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(titleForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1670,71 +1824,85 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje NSString *output = [api titleForWebViewWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)", api); + NSCAssert([api respondsToSelector:@selector + (setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_allow = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setAllowsBackForwardForWebViewWithIdentifier:arg_instanceId isAllowed:arg_allow error:&error]; + [api setAllowsBackForwardForWebViewWithIdentifier:arg_instanceId + isAllowed:arg_allow + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)", api); + NSCAssert([api respondsToSelector:@selector(setUserAgentForWebViewWithIdentifier: + userAgent:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_userAgent = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setUserAgentForWebViewWithIdentifier:arg_instanceId userAgent:arg_userAgent error:&error]; + [api setUserAgentForWebViewWithIdentifier:arg_instanceId + userAgent:arg_userAgent + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)", api); + NSCAssert( + [api respondsToSelector:@selector + (evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSString *arg_javaScriptString = GetNullableObjectAtIndex(args, 1); - [api evaluateJavaScriptForWebViewWithIdentifier:arg_instanceId javaScriptString:arg_javaScriptString completion:^(id _Nullable output, FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; + [api evaluateJavaScriptForWebViewWithIdentifier:arg_instanceId + javaScriptString:arg_javaScriptString + completion:^(id _Nullable output, + FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -1764,22 +1932,25 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKUIDelegateHostApiCodecReaderWriter *readerWriter = [[FWFWKUIDelegateHostApiCodecReaderWriter alloc] init]; + FWFWKUIDelegateHostApiCodecReaderWriter *readerWriter = + [[FWFWKUIDelegateHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKUIDelegateHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUIDelegateHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUIDelegateHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKUIDelegateHostApiGetCodec() ]; + codec:FWFWKUIDelegateHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKUIDelegateHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], + @"FWFWKUIDelegateHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); @@ -1787,8 +1958,7 @@ void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSO [api createWithIdentifier:arg_instanceId error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -1796,18 +1966,16 @@ void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSO @interface FWFWKHttpCookieStoreHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKHttpCookieStoreHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFNSHttpCookieData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFNSHttpCookiePropertyKeyEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -1815,17 +1983,14 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKHttpCookieStoreHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKHttpCookieStoreHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFNSHttpCookieData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { + } else if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -1846,53 +2011,62 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKHttpCookieStoreHostApiCodecReaderWriter *readerWriter = [[FWFWKHttpCookieStoreHostApiCodecReaderWriter alloc] init]; + FWFWKHttpCookieStoreHostApiCodecReaderWriter *readerWriter = + [[FWFWKHttpCookieStoreHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore" binaryMessenger:binaryMessenger - codec:FWFWKHttpCookieStoreHostApiGetCodec() ]; + codec:FWFWKHttpCookieStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)], @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to @selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createFromWebsiteDataStoreWithIdentifier: + dataStoreIdentifier:error:)], + @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to " + @"@selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); NSNumber *arg_websiteDataStoreInstanceId = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebsiteDataStoreWithIdentifier:arg_instanceId dataStoreIdentifier:arg_websiteDataStoreInstanceId error:&error]; + [api createFromWebsiteDataStoreWithIdentifier:arg_instanceId + dataStoreIdentifier:arg_websiteDataStoreInstanceId + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie" binaryMessenger:binaryMessenger - codec:FWFWKHttpCookieStoreHostApiGetCodec() ]; + codec:FWFWKHttpCookieStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setCookieForStoreWithIdentifier:cookie:completion:)], @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to @selector(setCookieForStoreWithIdentifier:cookie:completion:)", api); + NSCAssert([api respondsToSelector:@selector(setCookieForStoreWithIdentifier: + cookie:completion:)], + @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to " + @"@selector(setCookieForStoreWithIdentifier:cookie:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_instanceId = GetNullableObjectAtIndex(args, 0); FWFNSHttpCookieData *arg_cookie = GetNullableObjectAtIndex(args, 1); - [api setCookieForStoreWithIdentifier:arg_instanceId cookie:arg_cookie completion:^(FlutterError *_Nullable error) { - callback(wrapResult(nil, error)); - }]; + [api setCookieForStoreWithIdentifier:arg_instanceId + cookie:arg_cookie + completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; }]; - } - else { + } else { [channel setMessageHandler:nil]; } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m index a35aa5f7dd26..2dc98e8003e7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m @@ -24,18 +24,18 @@ - (long)identifierForNavigationDelegate:(FWFNavigationDelegate *)instance { } - (void)didFinishNavigationForDelegate:(FWFNavigationDelegate *)instance - webView:(WKWebView *)webView - URL:(NSString *)URL { - [self didFinishNavigationForDelegateWithIdentifier:@([self.instanceManager - identifierForInstance:instance]) - webViewIdentifier:@([self.instanceManager - identifierForInstance:webView]) - URL:URL - completion:^(NSError *error) { - if (error) { - NSLog(@"%@", error.description); - } - }]; + webView:(WKWebView *)webView + URL:(NSString *)URL { + [self didFinishNavigationForDelegateWithIdentifier:@([self.instanceManager + identifierForInstance:instance]) + webViewIdentifier:@([self.instanceManager + identifierForInstance:webView]) + URL:URL + completion:^(NSError *error) { + if (error) { + NSLog(@"%@", error.description); + } + }]; } @end @@ -52,7 +52,9 @@ - (instancetype)initWithBinaryMessenger:(id)binaryMessen } - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { - [self.navigationDelegateApi didFinishNavigationForDelegate:self webView:webView URL:webView.URL.absoluteString]; + [self.navigationDelegateApi didFinishNavigationForDelegate:self + webView:webView + URL:webView.URL.absoluteString]; } @end @@ -77,7 +79,7 @@ - (FWFNavigationDelegate *)navigationDelegateForIdentifier:(NSNumber *)instanceI } - (void)createWithIdentifier:(nonnull NSNumber *)instanceId - error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { + error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { FWFNavigationDelegate *navigationDelegate = [[FWFNavigationDelegate alloc] initWithBinaryMessenger:self.binaryMessenger instanceManager:self.instanceManager]; From ddfde5c2640ecae71ef7d0981b08596cf26346b9 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 17 May 2022 11:26:45 -0700 Subject: [PATCH 07/40] handles --- .../webview_flutter_wkwebview/pigeons/web_kit.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart index 755a85bccacf..925e1683cc0a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart @@ -382,7 +382,7 @@ abstract class WKNavigationDelegateHostApi { void create(int instanceId); } -/// Handling callbacks from an WKNavigationDelegate. +/// Handles callbacks from an WKNavigationDelegate instance. /// /// See https://developer.apple.com/documentation/webkit/wknavigationdelegate?language=objc. @FlutterApi() @@ -421,7 +421,7 @@ abstract class NSObjectHostApi { void removeObserver(int instanceId, int observerInstanceId, String keyPath); } -/// Handling callbacks from an NSObject. +/// Handles callbacks from an NSObject instance. /// /// See https://developer.apple.com/documentation/objectivec/nsobject. @FlutterApi() From 96c21aec47ea6bd62272f7f6a03595370d9e0b98 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 18 May 2022 16:04:23 -0700 Subject: [PATCH 08/40] some fixes for PR comments --- .../FWFNavigationDelegateHostApiTests.m | 16 +++++----- .../lib/src/common/instance_manager.dart | 29 ++++++++++++------- .../lib/src/web_kit/web_kit_api_impls.dart | 7 ++--- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m index 2a6132b285eb..fe950e596f5e 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m @@ -11,7 +11,7 @@ // Used to test that a FlutterBinaryMessenger with a strong reference to a host api won't // lead to a circular reference. @interface FWFTestMessenger : NSObject -@property(strong, nullable) id hostApi; +@property(strong, nullable) id hostAPI; @end @implementation FWFTestMessenger @@ -39,12 +39,12 @@ @interface FWFNavigationDelegateHostApiTests : XCTestCase @implementation FWFNavigationDelegateHostApiTests - (void)testCreateWithIdentifier { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - FWFNavigationDelegateHostApiImpl *hostApi = [[FWFNavigationDelegateHostApiImpl alloc] + FWFNavigationDelegateHostApiImpl *hostAPI = [[FWFNavigationDelegateHostApiImpl alloc] initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) instanceManager:instanceManager]; FlutterError *error; - [hostApi createWithIdentifier:@0 error:&error]; + [hostAPI createWithIdentifier:@0 error:&error]; FWFNavigationDelegate *navigationDelegate = (FWFNavigationDelegate *)[instanceManager instanceForIdentifier:0]; @@ -54,12 +54,12 @@ - (void)testCreateWithIdentifier { - (void)testDidFinishNavigation { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - FWFNavigationDelegateHostApiImpl *hostApi = [[FWFNavigationDelegateHostApiImpl alloc] + FWFNavigationDelegateHostApiImpl *hostAPI = [[FWFNavigationDelegateHostApiImpl alloc] initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) instanceManager:instanceManager]; FlutterError *error; - [hostApi createWithIdentifier:@0 error:&error]; + [hostAPI createWithIdentifier:@0 error:&error]; FWFNavigationDelegate *navigationDelegate = (FWFNavigationDelegate *)[instanceManager instanceForIdentifier:0]; id mockDelegate = OCMPartialMock(navigationDelegate); @@ -85,14 +85,14 @@ - (void)testDidFinishNavigation { - (void)testInstanceCanBeReleasedWhenInstanceManagerIsReleased { FWFTestMessenger *testMessenger = [[FWFTestMessenger alloc] init]; FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - FWFNavigationDelegateHostApiImpl *hostApi = + FWFNavigationDelegateHostApiImpl *hostAPI = [[FWFNavigationDelegateHostApiImpl alloc] initWithBinaryMessenger:testMessenger instanceManager:instanceManager]; - testMessenger.hostApi = hostApi; + testMessenger.hostAPI = hostAPI; FlutterError *error; - [hostApi createWithIdentifier:@0 error:&error]; + [hostAPI createWithIdentifier:@0 error:&error]; FWFNavigationDelegate __weak *navigationDelegate = (FWFNavigationDelegate *)[instanceManager instanceForIdentifier:0]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 11c894cf704c..8780cd739ccd 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -4,8 +4,17 @@ /// Maintains instances stored to communicate with Objective-C objects. class InstanceManager { - final Map _instanceIdsToInstances = {}; - final Expando _instancesToInstanceIds = Expando(); + // Instances that the manager wants to maintain a strong reference to. + final Map _strongInstances = {}; + // Expando is used because it doesn't prevent its keys from becoming + // inaccessible. This allows the manager to efficiently retrieve an instance + // id of an object without holding a strong reference to the object. + // + // It also doesn't use `==` to search for instance ids, which would lead to an + // infinite loop when comparing an object to its copy. (i.e. which is caused + // by calling instanceManager.getInstanceId() inside of `==` while this was a + // HashMap). + final Expando _instanceIds = Expando(); int _nextInstanceId = 0; @@ -22,15 +31,15 @@ class InstanceManager { } final int instanceId = _nextInstanceId++; - _instancesToInstanceIds[instance] = instanceId; - _instanceIdsToInstances[instanceId] = instance; + _instanceIds[instance] = instanceId; + _strongInstances[instanceId] = instance; return instanceId; } /// Store a copy of an instance with the same instance id. void addCopy(Object original, Object copy) { assert(original.runtimeType == copy.runtimeType); - _instancesToInstanceIds[copy] = _instancesToInstanceIds[original]; + _instanceIds[copy] = _instanceIds[original]; assert(original == copy); } @@ -39,21 +48,21 @@ class InstanceManager { /// Returns null if the instance is removed. Otherwise, return the instanceId /// of the removed instance. int? removeInstance(T instance) { - final int? instanceId = _instancesToInstanceIds[instance] as int?; + final int? instanceId = _instanceIds[instance]; if (instanceId != null) { - _instancesToInstanceIds[instance] = null; - _instanceIdsToInstances.remove(instanceId); + _instanceIds[instance] = null; + _strongInstances.remove(instanceId); } return instanceId; } /// Retrieve the Object paired with instanceId. T? getInstance(int instanceId) { - return _instanceIdsToInstances[instanceId] as T?; + return _strongInstances[instanceId] as T?; } /// Retrieve the instanceId paired with instance. int? getInstanceId(Object instance) { - return _instancesToInstanceIds[instance] as int?; + return _instanceIds[instance]; } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart index 7f613b51c60b..9fa5a1106679 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart @@ -588,10 +588,9 @@ class WKNavigationDelegateFlutterApiImpl int webViewInstanceId, String? url, ) { - _getDelegate(instanceId).didFinishNavigation!( - instanceManager.getInstance(webViewInstanceId)!, - url, - ); + final void Function(WKWebView, String?)? function = + _getDelegate(instanceId).didFinishNavigation; + function?.call(instanceManager.getInstance(webViewInstanceId)!, url); } } From f2a35044ded6126e504723a8a8c34f046a5e1e61 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 18 May 2022 17:30:01 -0700 Subject: [PATCH 09/40] new instance manager --- .../lib/src/common/instance_manager.dart | 199 ++++++++++++++---- 1 file changed, 159 insertions(+), 40 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 8780cd739ccd..42f9220e9622 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -2,67 +2,186 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -/// Maintains instances stored to communicate with Objective-C objects. +// @dart=2.17 + +import 'dart:math'; + +import 'package:flutter/foundation.dart'; + +/// An immutable object that can provide functional copies of themselves. +@immutable +mixin Copyable { + /// Instantiates and returns a functionally identical object to oneself. + /// + /// This method should only ever be called outside of tests by + /// [InstanceManager]. + /// + /// Subclasses should always override their parent's implementation and all + /// implementers should be immutable. + @protected + Copyable copy(); +} + +/// Maintains instances used to communicate with the native objects they +/// represent. +/// +/// Added instances are stored as weak references and their copies are stored +/// as strong references to maintain access to their variables and callback +/// methods. Both are stored with the same identifier. +/// +/// When a weak referenced instance becomes inaccessible, +/// [onWeakReferenceRemoved] is called with it's associated identifier. +/// +/// If an instance is retrieved and has the possiblity to be used, (e.g. calling +/// [getInstance] with `returnedInstanceMayBeUsed` as `true`) a copy of the +/// strong reference is added as a weak reference with the same identifier. This +/// prevents a scenario where the weak referenced instance was released and then +/// later returned by the host platform. class InstanceManager { - // Instances that the manager wants to maintain a strong reference to. - final Map _strongInstances = {}; + /// Constructs an [InstanceManager]. + InstanceManager({required this.onWeakReferenceRemoved}) + : _finalizer = Finalizer(onWeakReferenceRemoved); + // Expando is used because it doesn't prevent its keys from becoming - // inaccessible. This allows the manager to efficiently retrieve an instance - // id of an object without holding a strong reference to the object. + // inaccessible. This allows the manager to efficiently retrieve an identifier + // of an object without holding a strong reference to the object. // - // It also doesn't use `==` to search for instance ids, which would lead to an - // infinite loop when comparing an object to its copy. (i.e. which is caused + // It also doesn't use `==` to search for identifiers, which would lead to an + // infinite loop when comparing an object to its copy. (i.e. which was caused // by calling instanceManager.getInstanceId() inside of `==` while this was a // HashMap). - final Expando _instanceIds = Expando(); + final Expando _identifiers = Expando(); + final Map> _weakInstances = + >{}; + final Map _strongInstances = {}; + final Finalizer _finalizer; - int _nextInstanceId = 0; + /// Called when a weak referenced instance is removed by [removeWeakReference] + /// or becomes inaccessible. + final void Function(int) onWeakReferenceRemoved; - /// Global instance of [InstanceManager]. - static final InstanceManager instance = InstanceManager(); + /// Adds a new instance that was instantiated by Flutter. + /// + /// In other words, Flutter wants to add a new instance that will represent + /// an object that will be instantied on the host platform. + /// + /// Throws assertion error if the instance has already been added. + /// + /// Returns the randomly generated id of the [instance] added. + int addFlutterCreatedInstance(Copyable instance) { + assert(getIdentifier(instance) == null); - /// Attempt to add a new instance. + final int identifier = _generateNewIdentifier(); + _addInstanceWithIdentifier(instance, identifier); + return identifier; + } + + /// Removes the instance, if present, and call [onWeakReferenceRemoved] with + /// its identifier. + /// + /// Returns the identifier associated with the removed instance. Otherwise, + /// `null` if the instance was not found in this manager. /// - /// Returns new if [instance] has already been added. Otherwise, it is added - /// with a new instance id. - int? tryAddInstance(Object instance) { - if (getInstanceId(instance) != null) { + /// This does not remove the the strong referenced instance associtated with + /// [instance]. This can be done with [removeStrongReference]. + int? removeWeakReference(Copyable instance) { + final int? identifier = getIdentifier(instance); + if (identifier == null) { return null; } - final int instanceId = _nextInstanceId++; - _instanceIds[instance] = instanceId; - _strongInstances[instanceId] = instance; - return instanceId; + _identifiers[instance] = null; + _weakInstances.remove(identifier); + _finalizer.detach(instance); + onWeakReferenceRemoved(identifier); + + return identifier; } - /// Store a copy of an instance with the same instance id. - void addCopy(Object original, Object copy) { - assert(original.runtimeType == copy.runtimeType); - _instanceIds[copy] = _instanceIds[original]; - assert(original == copy); + /// Removes [identifier] and its associated strong referenced instance, if + /// present, from the manager. + /// + /// Returns the strong referenced instance associated with [identifier] before + /// it was removed. Returns `null` if [identifier] was not associated with + /// any strong reference. + /// + /// This does not remove the the weak referenced instance associtated with + /// [identifier]. This can be done with [removeWeakReference]. + Copyable? removeStrongReference(int identifier) { + return _strongInstances.remove(identifier); } - /// Remove the instance from the manager. + /// Retrieve the instance associated with identifier. /// - /// Returns null if the instance is removed. Otherwise, return the instanceId - /// of the removed instance. - int? removeInstance(T instance) { - final int? instanceId = _instanceIds[instance]; - if (instanceId != null) { - _instanceIds[instance] = null; - _strongInstances.remove(instanceId); + /// The value returned is chosen in this order: + /// 1. A weak reference asscociated with identifier. + /// 2. [returnedInstanceMayBeUsed] is set to true and the only instance + /// associated with identifier is a strong referenced instance, a copy of the + /// instance is added as a weak reference with the same instance id. Returning + /// the newly created weak reference copy. + /// 3. [returnedInstanceMayBeUsed] is set to false and the only instance + /// associated with identifier is a strong reference. The strong reference is + /// returned. + /// 4. If no instance is associated with identifier, returns null. + Copyable? getInstance( + int identifier, { + required bool returnedInstanceMayBeUsed, + }) { + final Copyable? weakInstance = _weakInstances[identifier]?.target; + + if (weakInstance == null) { + final Copyable? strongInstance = _strongInstances[identifier]; + if (strongInstance != null && returnedInstanceMayBeUsed) { + final Copyable copy = strongInstance.copy(); + _identifiers[copy] = identifier; + _weakInstances[identifier] = WeakReference(copy); + _finalizer.attach(copy, identifier, detach: copy); + return copy; + } + return strongInstance; } - return instanceId; + + return weakInstance; + } + + /// Retrieve the identifier paired with instance. + int? getIdentifier(Copyable instance) { + return _identifiers[instance]; } - /// Retrieve the Object paired with instanceId. - T? getInstance(int instanceId) { - return _strongInstances[instanceId] as T?; + /// Adds a new instance that was instantiated by the host platform. + /// + /// In other words, the host platform wants to add a new instance that + /// represents an object on the host platform. Stored with [identifier]. + /// + /// Throws assertion error if the instance or its identifier has already been + /// added. + /// + /// Returns the randomly generated id of the [instance] added. + void addHostCreatedInstance(Copyable instance, int identifier) { + assert(getInstance(identifier, returnedInstanceMayBeUsed: false) == null); + assert(getIdentifier(instance) == null); + _addInstanceWithIdentifier(instance, identifier); + } + + void _addInstanceWithIdentifier(Copyable instance, int identifier) { + _identifiers[instance] = identifier; + _weakInstances[identifier] = WeakReference(instance); + _finalizer.attach(instance, identifier, detach: instance); + + final Copyable copy = instance.copy(); + _identifiers[copy] = identifier; + _strongInstances[identifier] = copy; + + assert(instance == copy); } - /// Retrieve the instanceId paired with instance. - int? getInstanceId(Object instance) { - return _instanceIds[instance]; + int _generateNewIdentifier() { + late int identifier; + do { + // Max must be in range 0 < max ≤ 2^32. + identifier = Random().nextInt(4294967296); + } while (getInstance(identifier, returnedInstanceMayBeUsed: false) != null); + return identifier; } } From 77da52f13274df78de14ab3d77e0b6f60166fde2 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 18 May 2022 18:28:52 -0700 Subject: [PATCH 10/40] bunch of work --- .../lib/src/common/instance_manager.dart | 8 +- .../lib/src/foundation/foundation.dart | 30 ++--- .../src/foundation/foundation_api_impls.dart | 17 +-- .../lib/src/ui_kit/ui_kit_api_impls.dart | 19 +-- .../lib/src/web_kit/web_kit.dart | 50 +++++-- .../lib/src/web_kit/web_kit_api_impls.dart | 124 +++++++++--------- .../src/common/instance_manager_test.dart | 111 +++++++++++++--- 7 files changed, 232 insertions(+), 127 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 42f9220e9622..9d794ba68cf0 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -123,7 +123,7 @@ class InstanceManager { /// associated with identifier is a strong reference. The strong reference is /// returned. /// 4. If no instance is associated with identifier, returns null. - Copyable? getInstance( + T? getInstance( int identifier, { required bool returnedInstanceMayBeUsed, }) { @@ -136,12 +136,12 @@ class InstanceManager { _identifiers[copy] = identifier; _weakInstances[identifier] = WeakReference(copy); _finalizer.attach(copy, identifier, detach: copy); - return copy; + return copy as T; } - return strongInstance; + return strongInstance as T?; } - return weakInstance; + return weakInstance as T; } /// Retrieve the identifier paired with instance. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart index e5a875e23412..1629b1b3b9d9 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart @@ -232,13 +232,6 @@ class NSHttpCookie { final Map properties; } -/// An object that can provide functional copies of themselves. -@immutable -mixin Copyable { - /// Instantiates and returns a functionally identical object to oneself. - Copyable copy(); -} - /// The root class of most Objective-C class hierarchies. @immutable class NSObject with Copyable { @@ -248,11 +241,16 @@ class NSObject with Copyable { binaryMessenger: binaryMessenger, instanceManager: instanceManager, ) { - // Ensures FlutterApis for the Foundation library and FunctionFlutterApi are - // set up. + // Ensures FlutterApis for the Foundation library are set up. FoundationFlutterApis.instance.ensureSetUp(); } + /// Global instance of [InstanceManager]. + static final InstanceManager globalInstanceManager = + InstanceManager(onWeakReferenceRemoved: (int instanceId) { + NSObjectHostApiImpl().dispose(instanceId); + }); + final NSObjectHostApiImpl _api; /// Registers the observer object to receive KVO notifications. @@ -276,8 +274,8 @@ class NSObject with Copyable { } /// Release the reference to the Objective-C object. - Future dispose() { - return _api.disposeForInstances(this); + static void dispose(NSObject instance) { + instance._api.instanceManager.removeWeakReference(instance); } /// Informs the observing object when the value at the specified key path has changed. @@ -294,24 +292,22 @@ class NSObject with Copyable { @override Copyable copy() { - final NSObject copy = NSObject( + return NSObject( binaryMessenger: _api.binaryMessenger, instanceManager: _api.instanceManager, ); - _api.instanceManager.addCopy(this, copy); - return copy; } @override int get hashCode { - return Object.hash(_api, _api.instanceManager.getInstanceId(this)); + return Object.hash(_api, _api.instanceManager.getIdentifier(this)); } @override bool operator ==(Object other) { return other is NSObject && _api == other._api && - _api.instanceManager.getInstanceId(this) == - other._api.instanceManager.getInstanceId(other); + _api.instanceManager.getIdentifier(this) == + other._api.instanceManager.getIdentifier(other); } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart index a2995c6b1452..d76f1d6a21d3 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart @@ -78,7 +78,7 @@ class NSObjectHostApiImpl extends NSObjectHostApi { NSObjectHostApiImpl({ this.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? InstanceManager.instance, + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, super(binaryMessenger: binaryMessenger); /// Sends binary data across the Flutter platform barrier. @@ -98,8 +98,8 @@ class NSObjectHostApiImpl extends NSObjectHostApi { Set options, ) { return addObserver( - instanceManager.getInstanceId(instance)!, - instanceManager.getInstanceId(observer)!, + instanceManager.getIdentifier(instance)!, + instanceManager.getIdentifier(observer)!, keyPath, _toNSKeyValueObservingOptionsEnumData(options).toList(), ); @@ -112,17 +112,18 @@ class NSObjectHostApiImpl extends NSObjectHostApi { String keyPath, ) { return removeObserver( - instanceManager.getInstanceId(instance)!, - instanceManager.getInstanceId(observer)!, + instanceManager.getIdentifier(instance)!, + instanceManager.getIdentifier(observer)!, keyPath, ); } /// Calls [dispose] with the ids of the provided object instances. Future disposeForInstances(NSObject instance) async { - final int? instanceId = instanceManager.removeInstance(instance); - if (instanceId != null) { - await dispose(instanceId); + final int? identifier = instanceManager.removeWeakReference(instance); + if (identifier != null) { + instanceManager.removeStrongReference(identifier); + await dispose(identifier); } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart index b2ca5672f8e2..58fd18d8bc36 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart @@ -10,6 +10,7 @@ import 'package:flutter/services.dart'; import '../common/instance_manager.dart'; import '../common/web_kit.pigeon.dart'; +import '../foundation/foundation.dart'; import '../web_kit/web_kit.dart'; import 'ui_kit.dart'; @@ -19,7 +20,7 @@ class UIScrollViewHostApiImpl extends UIScrollViewHostApi { UIScrollViewHostApiImpl({ BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? InstanceManager.instance, + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, super(binaryMessenger: binaryMessenger); /// Maintains instances stored to communicate with Objective-C objects. @@ -30,11 +31,11 @@ class UIScrollViewHostApiImpl extends UIScrollViewHostApi { UIScrollView instance, WKWebView webView, ) async { - final int? instanceId = instanceManager.tryAddInstance(instance); + final int instanceId = instanceManager.addFlutterCreatedInstance(instance); if (instanceId != null) { await createFromWebView( instanceId, - instanceManager.getInstanceId(webView)!, + instanceManager.getIdentifier(webView)!, ); } } @@ -44,7 +45,7 @@ class UIScrollViewHostApiImpl extends UIScrollViewHostApi { UIScrollView instance, ) async { final List point = await getContentOffset( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, ); return Point(point[0]!, point[1]!); } @@ -55,7 +56,7 @@ class UIScrollViewHostApiImpl extends UIScrollViewHostApi { Point offset, ) { return scrollBy( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, offset.x, offset.y, ); @@ -67,7 +68,7 @@ class UIScrollViewHostApiImpl extends UIScrollViewHostApi { Point offset, ) async { return setContentOffset( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, offset.x, offset.y, ); @@ -80,7 +81,7 @@ class UIViewHostApiImpl extends UIViewHostApi { UIViewHostApiImpl({ BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? InstanceManager.instance, + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, super(binaryMessenger: binaryMessenger); /// Maintains instances stored to communicate with Objective-C objects. @@ -92,7 +93,7 @@ class UIViewHostApiImpl extends UIViewHostApi { Color? color, ) async { return setBackgroundColor( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, color?.value, ); } @@ -102,6 +103,6 @@ class UIViewHostApiImpl extends UIViewHostApi { UIView instance, bool opaque, ) async { - return setOpaque(instanceManager.getInstanceId(instance)!, opaque); + return setOpaque(instanceManager.getIdentifier(instance)!, opaque); } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart index f74c7464ab0f..a79c52a06710 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart @@ -10,6 +10,9 @@ import '../foundation/foundation.dart'; import '../ui_kit/ui_kit.dart'; import 'web_kit_api_impls.dart'; +// TODO(bparrishMines): All subclasses of NSObject need to pass their +// InstanceManager and BinaryMessenger to its parent. + /// Times at which to inject script content into a webpage. /// /// Wraps [WKUserScriptInjectionTime](https://developer.apple.com/documentation/webkit/wkuserscriptinjectiontime?language=objc). @@ -210,7 +213,7 @@ class WKScriptMessage { /// Encapsulates the standard behaviors to apply to websites. /// /// Wraps [WKPreferences](https://developer.apple.com/documentation/webkit/wkpreferences?language=objc). -class WKPreferences { +class WKPreferences extends NSObject { /// Constructs a [WKPreferences] that is owned by [configuration]. @visibleForTesting WKPreferences.fromWebViewConfiguration( @@ -241,7 +244,7 @@ class WKPreferences { /// Manages cookies, disk and memory caches, and other types of data for a web view. /// /// Wraps [WKWebsiteDataStore](https://developer.apple.com/documentation/webkit/wkwebsitedatastore?language=objc). -class WKWebsiteDataStore { +class WKWebsiteDataStore extends NSObject { WKWebsiteDataStore._({ BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, @@ -343,7 +346,7 @@ class WKHttpCookieStore extends NSObject { /// An interface for receiving messages from JavaScript code running in a webpage. /// /// Wraps [WKScriptMessageHandler](https://developer.apple.com/documentation/webkit/wkscriptmessagehandler?language=objc) -class WKScriptMessageHandler { +class WKScriptMessageHandler extends NSObject { /// Constructs a [WKScriptMessageHandler]. WKScriptMessageHandler({ BinaryMessenger? binaryMessenger, @@ -382,7 +385,7 @@ class WKScriptMessageHandler { /// code. /// /// Wraps [WKUserContentController](https://developer.apple.com/documentation/webkit/wkusercontentcontroller?language=objc). -class WKUserContentController { +class WKUserContentController extends NSObject { /// Constructs a [WKUserContentController] that is owned by [configuration]. @visibleForTesting WKUserContentController.fromWebViewConfiguration( @@ -465,7 +468,7 @@ class WKUserContentController { /// A collection of properties that you use to initialize a web view. /// /// Wraps [WKWebViewConfiguration](https://developer.apple.com/documentation/webkit/wkwebviewconfiguration?language=objc). -class WKWebViewConfiguration { +class WKWebViewConfiguration extends NSObject { /// Constructs a [WKWebViewConfiguration]. factory WKWebViewConfiguration({ BinaryMessenger? binaryMessenger, @@ -565,7 +568,7 @@ class WKWebViewConfiguration { /// The methods for presenting native user interface elements on behalf of a webpage. /// /// Wraps [WKUIDelegate](https://developer.apple.com/documentation/webkit/wkuidelegate?language=objc). -class WKUIDelegate { +class WKUIDelegate extends NSObject { /// Constructs a [WKUIDelegate]. WKUIDelegate({ BinaryMessenger? binaryMessenger, @@ -600,7 +603,29 @@ class WKUIDelegate { @immutable class WKNavigationDelegate extends NSObject { /// Constructs a [WKNavigationDelegate]. - WKNavigationDelegate({ + factory WKNavigationDelegate({ + void Function( + WKWebView webView, + String? url, + )? + didFinishNavigation, + BinaryMessenger? binaryMessenger, + InstanceManager? instanceManager, + }) { + final WKNavigationDelegate delegate = WKNavigationDelegate._copy( + didFinishNavigation: didFinishNavigation, + binaryMessenger: binaryMessenger, + instanceManager: instanceManager, + ); + delegate._navigationDelegateApi.createForInstances( + delegate, + didFinishNavigation, + ); + return delegate; + } + + // Doesn't create the Objective-C associated object. + WKNavigationDelegate._copy({ this.didFinishNavigation, BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, @@ -613,7 +638,6 @@ class WKNavigationDelegate extends NSObject { instanceManager: instanceManager, ) { WebKitFlutterApis.instance.ensureSetUp(); - _navigationDelegateApi.createForInstances(this, didFinishNavigation); } final WKNavigationDelegateHostApiImpl _navigationDelegateApi; @@ -666,19 +690,17 @@ class WKNavigationDelegate extends NSObject { @override Copyable copy() { - final WKNavigationDelegate copy = WKNavigationDelegate( + return WKNavigationDelegate._copy( didFinishNavigation: didFinishNavigation, binaryMessenger: _navigationDelegateApi.binaryMessenger, instanceManager: _navigationDelegateApi.instanceManager, ); - _navigationDelegateApi.instanceManager.addCopy(this, copy); - return copy; } @override int get hashCode { return Object.hash(didFinishNavigation, _navigationDelegateApi, - _navigationDelegateApi.instanceManager.getInstanceId(this)); + _navigationDelegateApi.instanceManager.getIdentifier(this)); } @override @@ -686,8 +708,8 @@ class WKNavigationDelegate extends NSObject { return other is WKNavigationDelegate && didFinishNavigation == other.didFinishNavigation && _navigationDelegateApi == other._navigationDelegateApi && - _navigationDelegateApi.instanceManager.getInstanceId(this) == - other._navigationDelegateApi.instanceManager.getInstanceId(other); + _navigationDelegateApi.instanceManager.getIdentifier(this) == + other._navigationDelegateApi.instanceManager.getIdentifier(other); } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart index 9fa5a1106679..82e9dd957b81 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart @@ -226,7 +226,7 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { WKWebsiteDataStoreHostApiImpl({ BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? InstanceManager.instance, + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, super(binaryMessenger: binaryMessenger); /// Maintains instances stored to communicate with Objective-C objects. @@ -237,11 +237,11 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { WKWebsiteDataStore instance, WKWebViewConfiguration configuration, ) async { - final int? instanceId = instanceManager.tryAddInstance(instance); + final int instanceId = instanceManager.addFlutterCreatedInstance(instance); if (instanceId != null) { await createFromWebViewConfiguration( instanceId, - instanceManager.getInstanceId(configuration)!, + instanceManager.getIdentifier(configuration)!, ); } } @@ -250,7 +250,7 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { Future createDefaultDataStoreForInstances( WKWebsiteDataStore instance, ) async { - final int? instanceId = instanceManager.tryAddInstance(instance); + final int instanceId = instanceManager.addFlutterCreatedInstance(instance); if (instanceId != null) { await createDefaultDataStore(instanceId); } @@ -263,7 +263,7 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { required double secondsModifiedSinceEpoch, }) { return removeDataOfTypes( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, _toWKWebsiteDataTypeEnumData(dataTypes).toList(), secondsModifiedSinceEpoch, ); @@ -276,7 +276,7 @@ class WKScriptMessageHandlerHostApiImpl extends WKScriptMessageHandlerHostApi { WKScriptMessageHandlerHostApiImpl({ BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? InstanceManager.instance, + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, super(binaryMessenger: binaryMessenger); /// Maintains instances stored to communicate with Objective-C objects. @@ -284,7 +284,7 @@ class WKScriptMessageHandlerHostApiImpl extends WKScriptMessageHandlerHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKScriptMessageHandler instance) async { - final int? instanceId = instanceManager.tryAddInstance(instance); + final int instanceId = instanceManager.addFlutterCreatedInstance(instance); if (instanceId != null) { await create(instanceId); } @@ -297,7 +297,7 @@ class WKPreferencesHostApiImpl extends WKPreferencesHostApi { WKPreferencesHostApiImpl({ BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? InstanceManager.instance, + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, super(binaryMessenger: binaryMessenger); /// Maintains instances stored to communicate with Objective-C objects. @@ -308,11 +308,11 @@ class WKPreferencesHostApiImpl extends WKPreferencesHostApi { WKPreferences instance, WKWebViewConfiguration configuration, ) async { - final int? instanceId = instanceManager.tryAddInstance(instance); + final int instanceId = instanceManager.addFlutterCreatedInstance(instance); if (instanceId != null) { await createFromWebViewConfiguration( instanceId, - instanceManager.getInstanceId(configuration)!, + instanceManager.getIdentifier(configuration)!, ); } } @@ -323,7 +323,7 @@ class WKPreferencesHostApiImpl extends WKPreferencesHostApi { bool enabled, ) { return setJavaScriptEnabled( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, enabled, ); } @@ -335,7 +335,7 @@ class WKHttpCookieStoreHostApiImpl extends WKHttpCookieStoreHostApi { WKHttpCookieStoreHostApiImpl({ BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? InstanceManager.instance, + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, super(binaryMessenger: binaryMessenger); /// Maintains instances stored to communicate with Objective-C objects. @@ -346,11 +346,11 @@ class WKHttpCookieStoreHostApiImpl extends WKHttpCookieStoreHostApi { WKHttpCookieStore instance, WKWebsiteDataStore dataStore, ) async { - final int? instanceId = instanceManager.tryAddInstance(instance); + final int instanceId = instanceManager.addFlutterCreatedInstance(instance); if (instanceId != null) { await createFromWebsiteDataStore( instanceId, - instanceManager.getInstanceId(dataStore)!, + instanceManager.getIdentifier(dataStore)!, ); } } @@ -361,7 +361,7 @@ class WKHttpCookieStoreHostApiImpl extends WKHttpCookieStoreHostApi { NSHttpCookie cookie, ) { return setCookie( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, cookie.toNSHttpCookieData(), ); } @@ -374,7 +374,7 @@ class WKUserContentControllerHostApiImpl WKUserContentControllerHostApiImpl({ BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? InstanceManager.instance, + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, super(binaryMessenger: binaryMessenger); /// Maintains instances stored to communicate with Objective-C objects. @@ -385,11 +385,11 @@ class WKUserContentControllerHostApiImpl WKUserContentController instance, WKWebViewConfiguration configuration, ) async { - final int? instanceId = instanceManager.tryAddInstance(instance); + final int instanceId = instanceManager.addFlutterCreatedInstance(instance); if (instanceId != null) { await createFromWebViewConfiguration( instanceId, - instanceManager.getInstanceId(configuration)!, + instanceManager.getIdentifier(configuration)!, ); } } @@ -401,8 +401,8 @@ class WKUserContentControllerHostApiImpl String name, ) { return addScriptMessageHandler( - instanceManager.getInstanceId(instance)!, - instanceManager.getInstanceId(handler)!, + instanceManager.getIdentifier(instance)!, + instanceManager.getIdentifier(handler)!, name, ); } @@ -413,7 +413,7 @@ class WKUserContentControllerHostApiImpl String name, ) { return removeScriptMessageHandler( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, name, ); } @@ -423,7 +423,7 @@ class WKUserContentControllerHostApiImpl WKUserContentController instance, ) { return removeAllScriptMessageHandlers( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, ); } @@ -433,7 +433,7 @@ class WKUserContentControllerHostApiImpl WKUserScript userScript, ) { return addUserScript( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, userScript.toWKUserScriptData(), ); } @@ -442,7 +442,7 @@ class WKUserContentControllerHostApiImpl Future removeAllUserScriptsForInstances( WKUserContentController instance, ) { - return removeAllUserScripts(instanceManager.getInstanceId(instance)!); + return removeAllUserScripts(instanceManager.getIdentifier(instance)!); } } @@ -452,7 +452,7 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { WKWebViewConfigurationHostApiImpl({ BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? InstanceManager.instance, + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, super(binaryMessenger: binaryMessenger); /// Maintains instances stored to communicate with Objective-C objects. @@ -460,7 +460,7 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKWebViewConfiguration instance) async { - final int? instanceId = instanceManager.tryAddInstance(instance); + final int instanceId = instanceManager.addFlutterCreatedInstance(instance); if (instanceId != null) { await create(instanceId); } @@ -471,11 +471,11 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { WKWebViewConfiguration instance, WKWebView webView, ) async { - final int? instanceId = instanceManager.tryAddInstance(instance); + final int instanceId = instanceManager.addFlutterCreatedInstance(instance); if (instanceId != null) { await createFromWebView( instanceId, - instanceManager.getInstanceId(webView)!, + instanceManager.getIdentifier(webView)!, ); } } @@ -486,7 +486,7 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { bool allow, ) { return setAllowsInlineMediaPlayback( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, allow, ); } @@ -497,7 +497,7 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { Set types, ) { return setMediaTypesRequiringUserActionForPlayback( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, _toWKAudiovisualMediaTypeEnumData(types).toList(), ); } @@ -509,7 +509,7 @@ class WKUIDelegateHostApiImpl extends WKUIDelegateHostApi { WKUIDelegateHostApiImpl({ BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? InstanceManager.instance, + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, super(binaryMessenger: binaryMessenger); /// Maintains instances stored to communicate with Objective-C objects. @@ -517,7 +517,7 @@ class WKUIDelegateHostApiImpl extends WKUIDelegateHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKUIDelegate instance) async { - final int? instanceId = instanceManager.tryAddInstance(instance); + final int instanceId = instanceManager.addFlutterCreatedInstance(instance); if (instanceId != null) { await create(instanceId); } @@ -531,7 +531,7 @@ class WKNavigationDelegateHostApiImpl extends WKNavigationDelegateHostApi { WKNavigationDelegateHostApiImpl({ this.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? InstanceManager.instance, + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, super(binaryMessenger: binaryMessenger); /// Sends binary data across the Flutter platform barrier. @@ -548,7 +548,7 @@ class WKNavigationDelegateHostApiImpl extends WKNavigationDelegateHostApi { WKNavigationDelegate instance, void Function(WKWebView webView, String? url)? didFinishNavigation, ) async { - final int? instanceId = instanceManager.tryAddInstance(instance); + final int instanceId = instanceManager.addFlutterCreatedInstance(instance); if (instanceId != null) { await create(instanceId); } @@ -572,14 +572,17 @@ class WKNavigationDelegateFlutterApiImpl extends WKNavigationDelegateFlutterApi { /// Constructs a [WKNavigationDelegateFlutterApiImpl]. WKNavigationDelegateFlutterApiImpl({InstanceManager? instanceManager}) { - this.instanceManager = instanceManager ?? InstanceManager.instance; + this.instanceManager = instanceManager ?? NSObject.globalInstanceManager; } /// Maintains instances stored to communicate with native language objects. late final InstanceManager instanceManager; WKNavigationDelegate _getDelegate(int instanceId) { - return instanceManager.getInstance(instanceId)!; + return instanceManager.getInstance( + instanceId, + returnedInstanceMayBeUsed: false, + )!; } @override @@ -590,7 +593,10 @@ class WKNavigationDelegateFlutterApiImpl ) { final void Function(WKWebView, String?)? function = _getDelegate(instanceId).didFinishNavigation; - function?.call(instanceManager.getInstance(webViewInstanceId)!, url); + function?.call( + instanceManager.getInstance(instanceId, returnedInstanceMayBeUsed: true)!, + url, + ); } } @@ -600,7 +606,7 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { WKWebViewHostApiImpl({ BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? InstanceManager.instance, + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, super(binaryMessenger: binaryMessenger); /// Maintains instances stored to communicate with Objective-C objects. @@ -611,11 +617,11 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { WKWebView instance, WKWebViewConfiguration configuration, ) async { - final int? instanceId = instanceManager.tryAddInstance(instance); + final int instanceId = instanceManager.addFlutterCreatedInstance(instance); if (instanceId != null) { await create( instanceId, - instanceManager.getInstanceId(configuration)!, + instanceManager.getIdentifier(configuration)!, ); } } @@ -624,7 +630,7 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { Future loadRequestForInstances( WKWebView webView, NSUrlRequest request) { return loadRequest( - instanceManager.getInstanceId(webView)!, + instanceManager.getIdentifier(webView)!, request.toNSUrlRequestData(), ); } @@ -636,7 +642,7 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { String? baseUrl, ) { return loadHtmlString( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, string, baseUrl, ); @@ -649,7 +655,7 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { String readAccessUrl, ) { return loadFileUrl( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, url, readAccessUrl, ); @@ -658,49 +664,49 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { /// Calls [loadFlutterAsset] with the ids of the provided object instances. Future loadFlutterAssetForInstances(WKWebView instance, String key) { return loadFlutterAsset( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, key, ); } /// Calls [canGoBack] with the ids of the provided object instances. Future canGoBackForInstances(WKWebView instance) { - return canGoBack(instanceManager.getInstanceId(instance)!); + return canGoBack(instanceManager.getIdentifier(instance)!); } /// Calls [canGoForward] with the ids of the provided object instances. Future canGoForwardForInstances(WKWebView instance) { - return canGoForward(instanceManager.getInstanceId(instance)!); + return canGoForward(instanceManager.getIdentifier(instance)!); } /// Calls [goBack] with the ids of the provided object instances. Future goBackForInstances(WKWebView instance) { - return goBack(instanceManager.getInstanceId(instance)!); + return goBack(instanceManager.getIdentifier(instance)!); } /// Calls [goForward] with the ids of the provided object instances. Future goForwardForInstances(WKWebView instance) { - return goForward(instanceManager.getInstanceId(instance)!); + return goForward(instanceManager.getIdentifier(instance)!); } /// Calls [reload] with the ids of the provided object instances. Future reloadForInstances(WKWebView instance) { - return reload(instanceManager.getInstanceId(instance)!); + return reload(instanceManager.getIdentifier(instance)!); } /// Calls [getUrl] with the ids of the provided object instances. Future getUrlForInstances(WKWebView instance) { - return getUrl(instanceManager.getInstanceId(instance)!); + return getUrl(instanceManager.getIdentifier(instance)!); } /// Calls [getTitle] with the ids of the provided object instances. Future getTitleForInstances(WKWebView instance) { - return getTitle(instanceManager.getInstanceId(instance)!); + return getTitle(instanceManager.getIdentifier(instance)!); } /// Calls [getEstimatedProgress] with the ids of the provided object instances. Future getEstimatedProgressForInstances(WKWebView instance) { - return getEstimatedProgress(instanceManager.getInstanceId(instance)!); + return getEstimatedProgress(instanceManager.getIdentifier(instance)!); } /// Calls [setAllowsBackForwardNavigationGestures] with the ids of the provided object instances. @@ -709,7 +715,7 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { bool allow, ) { return setAllowsBackForwardNavigationGestures( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, allow, ); } @@ -720,7 +726,7 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { String? userAgent, ) { return setCustomUserAgent( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, userAgent, ); } @@ -731,7 +737,7 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { String javaScriptString, ) { return evaluateJavaScript( - instanceManager.getInstanceId(instance)!, + instanceManager.getIdentifier(instance)!, javaScriptString, ); } @@ -742,8 +748,8 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { WKNavigationDelegate? delegate, ) { return setNavigationDelegate( - instanceManager.getInstanceId(instance)!, - delegate != null ? instanceManager.getInstanceId(delegate)! : null, + instanceManager.getIdentifier(instance)!, + delegate != null ? instanceManager.getIdentifier(delegate)! : null, ); } @@ -753,8 +759,8 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { WKUIDelegate? delegate, ) { return setUIDelegate( - instanceManager.getInstanceId(instance)!, - delegate != null ? instanceManager.getInstanceId(delegate)! : null, + instanceManager.getIdentifier(instance)!, + delegate != null ? instanceManager.getIdentifier(delegate)! : null, ); } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart index 10956c0a4aba..3e028a22611a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart @@ -7,29 +7,108 @@ import 'package:webview_flutter_wkwebview/src/common/instance_manager.dart'; void main() { group('InstanceManager', () { - late InstanceManager testInstanceManager; + test('addHostCreatedInstance', () { + final CopyableObject object = CopyableObject(); - setUp(() { - testInstanceManager = InstanceManager(); + final InstanceManager instanceManager = + InstanceManager(onWeakReferenceRemoved: (_) {}); + + instanceManager.addHostCreatedInstance(object, 0); + + expect(instanceManager.getIdentifier(object), 0); + expect( + instanceManager.getInstance(0, returnedInstanceMayBeUsed: false), + object, + ); + }); + + test('addHostCreatedInstance prevents already used objects and ids', () { + final CopyableObject object = CopyableObject(); + + final InstanceManager instanceManager = + InstanceManager(onWeakReferenceRemoved: (_) {}); + + instanceManager.addHostCreatedInstance(object, 0); + + expect( + () => instanceManager.addHostCreatedInstance(object, 1), + throwsAssertionError, + ); + + expect( + () => instanceManager.addHostCreatedInstance(CopyableObject(), 0), + throwsAssertionError, + ); + }); + + test('addFlutterCreatedInstance', () { + final CopyableObject object = CopyableObject(); + + final InstanceManager instanceManager = + InstanceManager(onWeakReferenceRemoved: (_) {}); + + instanceManager.addFlutterCreatedInstance(object); + + final int? instanceId = instanceManager.getIdentifier(object); + expect(instanceId, isNotNull); + expect( + instanceManager.getInstance( + instanceId!, + returnedInstanceMayBeUsed: false, + ), + object, + ); }); - test('tryAddInstance', () { - final Object object = Object(); + test('removeWeakReference', () { + final CopyableObject object = CopyableObject(); + + int? weakInstanceId; + final InstanceManager instanceManager = + InstanceManager(onWeakReferenceRemoved: (int instanceId) { + weakInstanceId = instanceId; + }); + + instanceManager.addHostCreatedInstance(object, 0); - expect(testInstanceManager.tryAddInstance(object), 0); - expect(testInstanceManager.getInstanceId(object), 0); - expect(testInstanceManager.getInstance(0), object); - expect(testInstanceManager.tryAddInstance(object), null); + expect(instanceManager.removeWeakReference(object), 0); + expect( + instanceManager.getInstance(0, returnedInstanceMayBeUsed: false), + isA(), + ); + expect(weakInstanceId, 0); }); - test('removeInstance', () { - final Object object = Object(); - testInstanceManager.tryAddInstance(object); + test('removeStrongReference', () { + final CopyableObject object = CopyableObject(); - expect(testInstanceManager.removeInstance(object), 0); - expect(testInstanceManager.getInstanceId(object), null); - expect(testInstanceManager.getInstance(0), null); - expect(testInstanceManager.removeInstance(object), null); + final InstanceManager instanceManager = + InstanceManager(onWeakReferenceRemoved: (_) {}); + + instanceManager.addHostCreatedInstance(object, 0); + instanceManager.removeWeakReference(object); + expect(instanceManager.removeStrongReference(0), isA()); + expect( + instanceManager.getInstance(0, returnedInstanceMayBeUsed: false), + isNull, + ); }); }); } + +class CopyableObject with Copyable { + @override + Copyable copy() { + return CopyableObject(); + } + + @override + int get hashCode { + return 0; + } + + @override + bool operator ==(Object other) { + return other is CopyableObject; + } +} From e388090a7e4b93c139e68a8a1732563530a5e5f0 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 18 May 2022 18:36:24 -0700 Subject: [PATCH 11/40] instance manager tests --- .../src/common/instance_manager_test.dart | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart index 3e028a22611a..6baaeec263f3 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart @@ -79,6 +79,22 @@ void main() { expect(weakInstanceId, 0); }); + test('removeWeakReference removes only weak reference', () { + final CopyableObject object = CopyableObject(); + + final InstanceManager instanceManager = + InstanceManager(onWeakReferenceRemoved: (_) {}); + + instanceManager.addHostCreatedInstance(object, 0); + + expect(instanceManager.removeWeakReference(object), 0); + final CopyableObject copy = instanceManager.getInstance( + 0, + returnedInstanceMayBeUsed: false, + )!; + expect(identical(object, copy), isFalse); + }); + test('removeStrongReference', () { final CopyableObject object = CopyableObject(); @@ -93,6 +109,40 @@ void main() { isNull, ); }); + + test('removeStrongReference removes only strong reference', () { + final CopyableObject object = CopyableObject(); + + final InstanceManager instanceManager = + InstanceManager(onWeakReferenceRemoved: (_) {}); + + instanceManager.addHostCreatedInstance(object, 0); + expect(instanceManager.removeStrongReference(0), isA()); + expect( + instanceManager.getInstance(0, returnedInstanceMayBeUsed: false), + object, + ); + }); + + test('getInstance can add a new weak reference', () { + final CopyableObject object = CopyableObject(); + + final InstanceManager instanceManager = + InstanceManager(onWeakReferenceRemoved: (_) {}); + + instanceManager.addHostCreatedInstance(object, 0); + instanceManager.removeWeakReference(object); + + final CopyableObject strongCopy = instanceManager.getInstance( + 0, + returnedInstanceMayBeUsed: false, + )!; + final CopyableObject newWeakCopy = instanceManager.getInstance( + 0, + returnedInstanceMayBeUsed: true, + )!; + expect(identical(strongCopy, newWeakCopy), isFalse); + }); }); } From ac3a2de11ff89654f5d608075527db8186926be2 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 18 May 2022 19:43:32 -0700 Subject: [PATCH 12/40] fix foundation tests --- .../test/src/foundation/foundation_test.dart | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart index 0ed9fc26025a..eb8e2f280deb 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart @@ -22,7 +22,7 @@ void main() { late InstanceManager instanceManager; setUp(() { - instanceManager = InstanceManager(); + instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); }); group('NSObject', () { @@ -35,20 +35,16 @@ void main() { TestNSObjectHostApi.setup(mockPlatformHostApi); object = NSObject(instanceManager: instanceManager); - instanceManager.tryAddInstance(object); + instanceManager.addFlutterCreatedInstance(object); }); tearDown(() { TestNSObjectHostApi.setup(null); }); - test('copy', () { - expect(object, equals(object.copy())); - }); - test('addObserver', () async { final NSObject observer = NSObject(instanceManager: instanceManager); - instanceManager.tryAddInstance(observer); + instanceManager.addFlutterCreatedInstance(observer); await object.addObserver( observer, @@ -61,8 +57,8 @@ void main() { final List optionsData = verify(mockPlatformHostApi.addObserver( - instanceManager.getInstanceId(object), - instanceManager.getInstanceId(observer), + instanceManager.getIdentifier(object), + instanceManager.getIdentifier(observer), 'aKeyPath', captureAny, )).captured.single as List; @@ -80,24 +76,30 @@ void main() { test('removeObserver', () async { final NSObject observer = NSObject(instanceManager: instanceManager); - instanceManager.tryAddInstance(observer); + instanceManager.addFlutterCreatedInstance(observer); await object.removeObserver(observer, keyPath: 'aKeyPath'); verify(mockPlatformHostApi.removeObserver( - instanceManager.getInstanceId(object), - instanceManager.getInstanceId(observer), + instanceManager.getIdentifier(object), + instanceManager.getIdentifier(observer), 'aKeyPath', )); }); test('dispose', () async { - final int instanceId = instanceManager.getInstanceId(object)!; - - await object.dispose(); - verify( - mockPlatformHostApi.dispose(instanceId), - ); + int? callbackIdentifier; + final InstanceManager instanceManager = + InstanceManager(onWeakReferenceRemoved: (int identifier) { + callbackIdentifier = identifier; + }); + + final NSObject object = NSObject(instanceManager: instanceManager); + final int identifier = + instanceManager.addFlutterCreatedInstance(object); + + NSObject.dispose(object); + expect(callbackIdentifier, identifier); }); }); }); From 696c25cf47687b54fb29724ff6256267395eac81 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 18 May 2022 20:23:15 -0700 Subject: [PATCH 13/40] dart touchups --- .../lib/src/web_kit/web_kit_api_impls.dart | 5 +- .../test/src/ui_kit/ui_kit_test.dart | 6 +- .../test/src/web_kit/web_kit_test.dart | 72 +++--- .../web_kit_cookie_manager_test.mocks.dart | 44 +++- .../web_kit_webview_widget_test.mocks.dart | 223 ++++++++++++++---- 5 files changed, 254 insertions(+), 96 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart index 82e9dd957b81..08b7f7f03271 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart @@ -594,7 +594,10 @@ class WKNavigationDelegateFlutterApiImpl final void Function(WKWebView, String?)? function = _getDelegate(instanceId).didFinishNavigation; function?.call( - instanceManager.getInstance(instanceId, returnedInstanceMayBeUsed: true)!, + instanceManager.getInstance( + webViewInstanceId, + returnedInstanceMayBeUsed: true, + )!, url, ); } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart index 7db190f8192c..884d8e2d669f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart @@ -28,7 +28,7 @@ void main() { late InstanceManager instanceManager; setUp(() { - instanceManager = InstanceManager(); + instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); }); group('UIScrollView', () { @@ -54,7 +54,7 @@ void main() { webView, instanceManager: instanceManager, ); - scrollViewInstanceId = instanceManager.getInstanceId(scrollView)!; + scrollViewInstanceId = instanceManager.getIdentifier(scrollView)!; }); tearDown(() { @@ -98,7 +98,7 @@ void main() { TestUIViewHostApi.setup(mockPlatformHostApi); view = UIView(instanceManager: instanceManager); - viewInstanceId = instanceManager.tryAddInstance(view)!; + viewInstanceId = instanceManager.addFlutterCreatedInstance(view); }); tearDown(() { diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart index 740664990de8..f486474b4cfb 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart @@ -35,7 +35,7 @@ void main() { late WebKitFlutterApis flutterApis; setUp(() { - instanceManager = InstanceManager(); + instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); flutterApis = WebKitFlutterApis(instanceManager: instanceManager); WebKitFlutterApis.instance = flutterApis; }); @@ -71,8 +71,8 @@ void main() { test('createFromWebViewConfiguration', () { verify(mockPlatformHostApi.createFromWebViewConfiguration( - instanceManager.getInstanceId(websiteDataStore), - instanceManager.getInstanceId(webViewConfiguration), + instanceManager.getIdentifier(websiteDataStore), + instanceManager.getIdentifier(webViewConfiguration), )); }); @@ -81,7 +81,7 @@ void main() { WKWebsiteDataStore.defaultDataStore; verify( mockPlatformHostApi.createDefaultDataStore( - InstanceManager.instance.getInstanceId(defaultDataStore), + NSObject.globalInstanceManager.getIdentifier(defaultDataStore), ), ); }); @@ -103,7 +103,7 @@ void main() { final List typeData = verify(mockPlatformHostApi.removeDataOfTypes( - instanceManager.getInstanceId(websiteDataStore), + instanceManager.getIdentifier(websiteDataStore), captureAny, 5.0, )).captured.single.cast() @@ -150,8 +150,8 @@ void main() { test('createFromWebsiteDataStore', () { verify(mockPlatformHostApi.createFromWebsiteDataStore( - instanceManager.getInstanceId(httpCookieStore), - instanceManager.getInstanceId(websiteDataStore), + instanceManager.getIdentifier(httpCookieStore), + instanceManager.getIdentifier(websiteDataStore), )); }); @@ -163,7 +163,7 @@ void main() { final NSHttpCookieData cookie = verify( mockPlatformHostApi.setCookie( - instanceManager.getInstanceId(httpCookieStore), + instanceManager.getIdentifier(httpCookieStore), captureAny, ), ).captured.single as NSHttpCookieData; @@ -196,7 +196,7 @@ void main() { test('create', () async { verify(mockPlatformHostApi.create( - instanceManager.getInstanceId(scriptMessageHandler), + instanceManager.getIdentifier(scriptMessageHandler), )); }); }); @@ -232,15 +232,15 @@ void main() { test('createFromWebViewConfiguration', () async { verify(mockPlatformHostApi.createFromWebViewConfiguration( - instanceManager.getInstanceId(preferences), - instanceManager.getInstanceId(webViewConfiguration), + instanceManager.getIdentifier(preferences), + instanceManager.getIdentifier(webViewConfiguration), )); }); test('setJavaScriptEnabled', () async { await preferences.setJavaScriptEnabled(true); verify(mockPlatformHostApi.setJavaScriptEnabled( - instanceManager.getInstanceId(preferences), + instanceManager.getIdentifier(preferences), true, )); }); @@ -278,8 +278,8 @@ void main() { test('createFromWebViewConfiguration', () async { verify(mockPlatformHostApi.createFromWebViewConfiguration( - instanceManager.getInstanceId(userContentController), - instanceManager.getInstanceId(webViewConfiguration), + instanceManager.getIdentifier(userContentController), + instanceManager.getIdentifier(webViewConfiguration), )); }); @@ -293,8 +293,8 @@ void main() { userContentController.addScriptMessageHandler(handler, 'handlerName'); verify(mockPlatformHostApi.addScriptMessageHandler( - instanceManager.getInstanceId(userContentController), - instanceManager.getInstanceId(handler), + instanceManager.getIdentifier(userContentController), + instanceManager.getIdentifier(handler), 'handlerName', )); }); @@ -302,7 +302,7 @@ void main() { test('removeScriptMessageHandler', () async { userContentController.removeScriptMessageHandler('handlerName'); verify(mockPlatformHostApi.removeScriptMessageHandler( - instanceManager.getInstanceId(userContentController), + instanceManager.getIdentifier(userContentController), 'handlerName', )); }); @@ -310,7 +310,7 @@ void main() { test('removeAllScriptMessageHandlers', () async { userContentController.removeAllScriptMessageHandlers(); verify(mockPlatformHostApi.removeAllScriptMessageHandlers( - instanceManager.getInstanceId(userContentController), + instanceManager.getIdentifier(userContentController), )); }); @@ -321,7 +321,7 @@ void main() { isMainFrameOnly: false, )); verify(mockPlatformHostApi.addUserScript( - instanceManager.getInstanceId(userContentController), + instanceManager.getIdentifier(userContentController), argThat(isA()), )); }); @@ -329,7 +329,7 @@ void main() { test('removeAllUserScripts', () { userContentController.removeAllUserScripts(); verify(mockPlatformHostApi.removeAllUserScripts( - instanceManager.getInstanceId(userContentController), + instanceManager.getIdentifier(userContentController), )); }); }); @@ -354,7 +354,7 @@ void main() { test('create', () async { verify( - mockPlatformHostApi.create(instanceManager.getInstanceId( + mockPlatformHostApi.create(instanceManager.getIdentifier( webViewConfiguration, )), ); @@ -373,15 +373,15 @@ void main() { instanceManager: instanceManager, ); verify(mockPlatformHostApi.createFromWebView( - instanceManager.getInstanceId(configurationFromWebView), - instanceManager.getInstanceId(webView), + instanceManager.getIdentifier(configurationFromWebView), + instanceManager.getIdentifier(webView), )); }); test('allowsInlineMediaPlayback', () { webViewConfiguration.setAllowsInlineMediaPlayback(true); verify(mockPlatformHostApi.setAllowsInlineMediaPlayback( - instanceManager.getInstanceId(webViewConfiguration), + instanceManager.getIdentifier(webViewConfiguration), true, )); }); @@ -396,7 +396,7 @@ void main() { final List typeData = verify( mockPlatformHostApi.setMediaTypesRequiringUserActionForPlayback( - instanceManager.getInstanceId(webViewConfiguration), + instanceManager.getIdentifier(webViewConfiguration), captureAny, )).captured.single as List; @@ -437,17 +437,13 @@ void main() { TestWKWebViewHostApi.setup(null); }); - test('copy', () { - expect(navigationDelegate, equals(navigationDelegate.copy())); - }); - test('create', () async { navigationDelegate = WKNavigationDelegate( instanceManager: instanceManager, ); verify(mockPlatformHostApi.create( - instanceManager.getInstanceId(navigationDelegate), + instanceManager.getIdentifier(navigationDelegate), )); }); @@ -468,8 +464,8 @@ void main() { WebKitFlutterApis.instance.navigationDelegateFlutterApi .didFinishNavigation( - instanceManager.getInstanceId(navigationDelegate)!, - instanceManager.getInstanceId(webView)!, + instanceManager.getIdentifier(navigationDelegate)!, + instanceManager.getIdentifier(webView)!, 'url', ); @@ -499,7 +495,7 @@ void main() { webViewConfiguration, instanceManager: instanceManager, ); - webViewInstanceId = instanceManager.getInstanceId(webView)!; + webViewInstanceId = instanceManager.getIdentifier(webView)!; }); tearDown(() { @@ -509,8 +505,8 @@ void main() { test('create', () async { verify(mockPlatformHostApi.create( - instanceManager.getInstanceId(webView), - instanceManager.getInstanceId( + instanceManager.getIdentifier(webView), + instanceManager.getIdentifier( webViewConfiguration, ), )); @@ -525,7 +521,7 @@ void main() { await webView.setUIDelegate(uiDelegate); verify(mockPlatformHostApi.setUIDelegate( webViewInstanceId, - instanceManager.getInstanceId(uiDelegate), + instanceManager.getIdentifier(uiDelegate), )); TestWKUIDelegateHostApi.setup(null); @@ -542,7 +538,7 @@ void main() { await webView.setNavigationDelegate(navigationDelegate); verify(mockPlatformHostApi.setNavigationDelegate( webViewInstanceId, - instanceManager.getInstanceId(navigationDelegate), + instanceManager.getIdentifier(navigationDelegate), )); TestWKNavigationDelegateHostApi.setup(null); @@ -658,7 +654,7 @@ void main() { test('create', () async { verify(mockPlatformHostApi.create( - instanceManager.getInstanceId(uiDelegate), + instanceManager.getIdentifier(uiDelegate), )); }); }); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_cookie_manager_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_cookie_manager_test.mocks.dart index c7b309005768..5989c138ff25 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_cookie_manager_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_cookie_manager_test.mocks.dart @@ -5,8 +5,10 @@ import 'dart:async' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:webview_flutter_wkwebview/src/foundation/foundation.dart' +import 'package:webview_flutter_wkwebview/src/common/instance_manager.dart' as _i2; +import 'package:webview_flutter_wkwebview/src/foundation/foundation.dart' + as _i5; import 'package:webview_flutter_wkwebview/src/web_kit/web_kit.dart' as _i3; // ignore_for_file: type=lint @@ -33,33 +35,28 @@ class MockWKHttpCookieStore extends _i1.Mock implements _i3.WKHttpCookieStore { } @override - _i4.Future setCookie(_i2.NSHttpCookie? cookie) => + _i4.Future setCookie(_i5.NSHttpCookie? cookie) => (super.noSuchMethod(Invocation.method(#setCookie, [cookie]), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i4.Future); @override - _i4.Future addObserver(_i2.NSObject? observer, - {String? keyPath, Set<_i2.NSKeyValueObservingOptions>? options}) => + _i4.Future addObserver(_i5.NSObject? observer, + {String? keyPath, Set<_i5.NSKeyValueObservingOptions>? options}) => (super.noSuchMethod( Invocation.method( #addObserver, [observer], {#keyPath: keyPath, #options: options}), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i4.Future); @override - _i4.Future removeObserver(_i2.NSObject? observer, {String? keyPath}) => + _i4.Future removeObserver(_i5.NSObject? observer, {String? keyPath}) => (super.noSuchMethod( Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i4.Future); @override - _i4.Future dispose() => - (super.noSuchMethod(Invocation.method(#dispose, []), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i4.Future); - @override _i4.Future setObserveValue( void Function( - String, _i2.NSObject, Map<_i2.NSKeyValueChangeKey, Object?>)? + String, _i5.NSObject, Map<_i5.NSKeyValueChangeKey, Object?>)? observeValue) => (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), returnValue: Future.value(), @@ -88,4 +85,29 @@ class MockWKWebsiteDataStore extends _i1.Mock (super.noSuchMethod( Invocation.method(#removeDataOfTypes, [dataTypes, since]), returnValue: Future.value(false)) as _i4.Future); + @override + _i4.Future addObserver(_i5.NSObject? observer, + {String? keyPath, Set<_i5.NSKeyValueObservingOptions>? options}) => + (super.noSuchMethod( + Invocation.method( + #addObserver, [observer], {#keyPath: keyPath, #options: options}), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i4.Future); + @override + _i4.Future removeObserver(_i5.NSObject? observer, {String? keyPath}) => + (super.noSuchMethod( + Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i4.Future); + @override + _i4.Future setObserveValue( + void Function( + String, _i5.NSObject, Map<_i5.NSKeyValueChangeKey, Object?>)? + observeValue) => + (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i4.Future); + @override + _i2.Copyable copy() => (super.noSuchMethod(Invocation.method(#copy, []), + returnValue: _FakeCopyable_0()) as _i2.Copyable); } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.mocks.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.mocks.dart index 66341ab08036..f2a9876a71e4 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.mocks.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit_webview_widget_test.mocks.dart @@ -8,17 +8,19 @@ import 'dart:ui' as _i7; import 'package:mockito/mockito.dart' as _i1; import 'package:webview_flutter_platform_interface/src/types/javascript_channel.dart' - as _i9; -import 'package:webview_flutter_platform_interface/src/types/types.dart' as _i10; +import 'package:webview_flutter_platform_interface/src/types/types.dart' + as _i11; import 'package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart' - as _i8; -import 'package:webview_flutter_wkwebview/src/foundation/foundation.dart' + as _i9; +import 'package:webview_flutter_wkwebview/src/common/instance_manager.dart' as _i3; +import 'package:webview_flutter_wkwebview/src/foundation/foundation.dart' + as _i8; import 'package:webview_flutter_wkwebview/src/ui_kit/ui_kit.dart' as _i5; import 'package:webview_flutter_wkwebview/src/web_kit/web_kit.dart' as _i4; import 'package:webview_flutter_wkwebview/src/web_kit_webview_widget.dart' - as _i11; + as _i12; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -94,28 +96,23 @@ class MockUIScrollView extends _i1.Mock implements _i5.UIScrollView { returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i6.Future addObserver(_i3.NSObject? observer, - {String? keyPath, Set<_i3.NSKeyValueObservingOptions>? options}) => + _i6.Future addObserver(_i8.NSObject? observer, + {String? keyPath, Set<_i8.NSKeyValueObservingOptions>? options}) => (super.noSuchMethod( Invocation.method( #addObserver, [observer], {#keyPath: keyPath, #options: options}), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i6.Future removeObserver(_i3.NSObject? observer, {String? keyPath}) => + _i6.Future removeObserver(_i8.NSObject? observer, {String? keyPath}) => (super.noSuchMethod( Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i6.Future dispose() => - (super.noSuchMethod(Invocation.method(#dispose, []), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); - @override _i6.Future setObserveValue( void Function( - String, _i3.NSObject, Map<_i3.NSKeyValueChangeKey, Object?>)? + String, _i8.NSObject, Map<_i8.NSKeyValueChangeKey, Object?>)? observeValue) => (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), returnValue: Future.value(), @@ -156,14 +153,14 @@ class MockWKNavigationDelegate extends _i1.Mock returnValueForMissingStub: Future.value()) as _i6.Future); @override _i6.Future setDidFailNavigation( - void Function(_i4.WKWebView, _i3.NSError)? didFailNavigation) => + void Function(_i4.WKWebView, _i8.NSError)? didFailNavigation) => (super.noSuchMethod( Invocation.method(#setDidFailNavigation, [didFailNavigation]), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); @override _i6.Future setDidFailProvisionalNavigation( - void Function(_i4.WKWebView, _i3.NSError)? + void Function(_i4.WKWebView, _i8.NSError)? didFailProvisionalNavigation) => (super.noSuchMethod( Invocation.method( @@ -182,28 +179,23 @@ class MockWKNavigationDelegate extends _i1.Mock _i3.Copyable copy() => (super.noSuchMethod(Invocation.method(#copy, []), returnValue: _FakeCopyable_1()) as _i3.Copyable); @override - _i6.Future addObserver(_i3.NSObject? observer, - {String? keyPath, Set<_i3.NSKeyValueObservingOptions>? options}) => + _i6.Future addObserver(_i8.NSObject? observer, + {String? keyPath, Set<_i8.NSKeyValueObservingOptions>? options}) => (super.noSuchMethod( Invocation.method( #addObserver, [observer], {#keyPath: keyPath, #options: options}), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i6.Future removeObserver(_i3.NSObject? observer, {String? keyPath}) => + _i6.Future removeObserver(_i8.NSObject? observer, {String? keyPath}) => (super.noSuchMethod( Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i6.Future dispose() => - (super.noSuchMethod(Invocation.method(#dispose, []), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); - @override _i6.Future setObserveValue( void Function( - String, _i3.NSObject, Map<_i3.NSKeyValueChangeKey, Object?>)? + String, _i8.NSObject, Map<_i8.NSKeyValueChangeKey, Object?>)? observeValue) => (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), returnValue: Future.value(), @@ -223,6 +215,31 @@ class MockWKPreferences extends _i1.Mock implements _i4.WKPreferences { (super.noSuchMethod(Invocation.method(#setJavaScriptEnabled, [enabled]), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future addObserver(_i8.NSObject? observer, + {String? keyPath, Set<_i8.NSKeyValueObservingOptions>? options}) => + (super.noSuchMethod( + Invocation.method( + #addObserver, [observer], {#keyPath: keyPath, #options: options}), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future removeObserver(_i8.NSObject? observer, {String? keyPath}) => + (super.noSuchMethod( + Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future setObserveValue( + void Function( + String, _i8.NSObject, Map<_i8.NSKeyValueChangeKey, Object?>)? + observeValue) => + (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i3.Copyable copy() => (super.noSuchMethod(Invocation.method(#copy, []), + returnValue: _FakeCopyable_1()) as _i3.Copyable); } /// A class which mocks [WKScriptMessageHandler]. @@ -243,6 +260,31 @@ class MockWKScriptMessageHandler extends _i1.Mock #setDidReceiveScriptMessage, [didReceiveScriptMessage]), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future addObserver(_i8.NSObject? observer, + {String? keyPath, Set<_i8.NSKeyValueObservingOptions>? options}) => + (super.noSuchMethod( + Invocation.method( + #addObserver, [observer], {#keyPath: keyPath, #options: options}), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future removeObserver(_i8.NSObject? observer, {String? keyPath}) => + (super.noSuchMethod( + Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future setObserveValue( + void Function( + String, _i8.NSObject, Map<_i8.NSKeyValueChangeKey, Object?>)? + observeValue) => + (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i3.Copyable copy() => (super.noSuchMethod(Invocation.method(#copy, []), + returnValue: _FakeCopyable_1()) as _i3.Copyable); } /// A class which mocks [WKWebView]. @@ -281,7 +323,7 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { (super.noSuchMethod(Invocation.method(#getEstimatedProgress, []), returnValue: Future.value(0.0)) as _i6.Future); @override - _i6.Future loadRequest(_i3.NSUrlRequest? request) => + _i6.Future loadRequest(_i8.NSUrlRequest? request) => (super.noSuchMethod(Invocation.method(#loadRequest, [request]), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); @@ -356,28 +398,23 @@ class MockWKWebView extends _i1.Mock implements _i4.WKWebView { returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i6.Future addObserver(_i3.NSObject? observer, - {String? keyPath, Set<_i3.NSKeyValueObservingOptions>? options}) => + _i6.Future addObserver(_i8.NSObject? observer, + {String? keyPath, Set<_i8.NSKeyValueObservingOptions>? options}) => (super.noSuchMethod( Invocation.method( #addObserver, [observer], {#keyPath: keyPath, #options: options}), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i6.Future removeObserver(_i3.NSObject? observer, {String? keyPath}) => + _i6.Future removeObserver(_i8.NSObject? observer, {String? keyPath}) => (super.noSuchMethod( Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); @override - _i6.Future dispose() => - (super.noSuchMethod(Invocation.method(#dispose, []), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); - @override _i6.Future setObserveValue( void Function( - String, _i3.NSObject, Map<_i3.NSKeyValueChangeKey, Object?>)? + String, _i8.NSObject, Map<_i8.NSKeyValueChangeKey, Object?>)? observeValue) => (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), returnValue: Future.value(), @@ -422,6 +459,31 @@ class MockWKWebViewConfiguration extends _i1.Mock #setMediaTypesRequiringUserActionForPlayback, [types]), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future addObserver(_i8.NSObject? observer, + {String? keyPath, Set<_i8.NSKeyValueObservingOptions>? options}) => + (super.noSuchMethod( + Invocation.method( + #addObserver, [observer], {#keyPath: keyPath, #options: options}), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future removeObserver(_i8.NSObject? observer, {String? keyPath}) => + (super.noSuchMethod( + Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future setObserveValue( + void Function( + String, _i8.NSObject, Map<_i8.NSKeyValueChangeKey, Object?>)? + observeValue) => + (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i3.Copyable copy() => (super.noSuchMethod(Invocation.method(#copy, []), + returnValue: _FakeCopyable_1()) as _i3.Copyable); } /// A class which mocks [WKWebsiteDataStore]. @@ -443,6 +505,31 @@ class MockWKWebsiteDataStore extends _i1.Mock (super.noSuchMethod( Invocation.method(#removeDataOfTypes, [dataTypes, since]), returnValue: Future.value(false)) as _i6.Future); + @override + _i6.Future addObserver(_i8.NSObject? observer, + {String? keyPath, Set<_i8.NSKeyValueObservingOptions>? options}) => + (super.noSuchMethod( + Invocation.method( + #addObserver, [observer], {#keyPath: keyPath, #options: options}), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future removeObserver(_i8.NSObject? observer, {String? keyPath}) => + (super.noSuchMethod( + Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future setObserveValue( + void Function( + String, _i8.NSObject, Map<_i8.NSKeyValueChangeKey, Object?>)? + observeValue) => + (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i3.Copyable copy() => (super.noSuchMethod(Invocation.method(#copy, []), + returnValue: _FakeCopyable_1()) as _i3.Copyable); } /// A class which mocks [WKUIDelegate]. @@ -461,6 +548,31 @@ class MockWKUIDelegate extends _i1.Mock implements _i4.WKUIDelegate { Invocation.method(#setOnCreateWebView, [onCreateWebView]), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future addObserver(_i8.NSObject? observer, + {String? keyPath, Set<_i8.NSKeyValueObservingOptions>? options}) => + (super.noSuchMethod( + Invocation.method( + #addObserver, [observer], {#keyPath: keyPath, #options: options}), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future removeObserver(_i8.NSObject? observer, {String? keyPath}) => + (super.noSuchMethod( + Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future setObserveValue( + void Function( + String, _i8.NSObject, Map<_i8.NSKeyValueChangeKey, Object?>)? + observeValue) => + (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i3.Copyable copy() => (super.noSuchMethod(Invocation.method(#copy, []), + returnValue: _FakeCopyable_1()) as _i3.Copyable); } /// A class which mocks [WKUserContentController]. @@ -499,29 +611,54 @@ class MockWKUserContentController extends _i1.Mock (super.noSuchMethod(Invocation.method(#removeAllUserScripts, []), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future addObserver(_i8.NSObject? observer, + {String? keyPath, Set<_i8.NSKeyValueObservingOptions>? options}) => + (super.noSuchMethod( + Invocation.method( + #addObserver, [observer], {#keyPath: keyPath, #options: options}), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future removeObserver(_i8.NSObject? observer, {String? keyPath}) => + (super.noSuchMethod( + Invocation.method(#removeObserver, [observer], {#keyPath: keyPath}), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i6.Future setObserveValue( + void Function( + String, _i8.NSObject, Map<_i8.NSKeyValueChangeKey, Object?>)? + observeValue) => + (super.noSuchMethod(Invocation.method(#setObserveValue, [observeValue]), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i6.Future); + @override + _i3.Copyable copy() => (super.noSuchMethod(Invocation.method(#copy, []), + returnValue: _FakeCopyable_1()) as _i3.Copyable); } /// A class which mocks [JavascriptChannelRegistry]. /// /// See the documentation for Mockito's code generation for more information. class MockJavascriptChannelRegistry extends _i1.Mock - implements _i8.JavascriptChannelRegistry { + implements _i9.JavascriptChannelRegistry { MockJavascriptChannelRegistry() { _i1.throwOnMissingStub(this); } @override - Map get channels => + Map get channels => (super.noSuchMethod(Invocation.getter(#channels), - returnValue: {}) - as Map); + returnValue: {}) + as Map); @override void onJavascriptChannelMessage(String? channel, String? message) => super.noSuchMethod( Invocation.method(#onJavascriptChannelMessage, [channel, message]), returnValueForMissingStub: null); @override - void updateJavascriptChannelsFromSet(Set<_i9.JavascriptChannel>? channels) => + void updateJavascriptChannelsFromSet(Set<_i10.JavascriptChannel>? channels) => super.noSuchMethod( Invocation.method(#updateJavascriptChannelsFromSet, [channels]), returnValueForMissingStub: null); @@ -531,7 +668,7 @@ class MockJavascriptChannelRegistry extends _i1.Mock /// /// See the documentation for Mockito's code generation for more information. class MockWebViewPlatformCallbacksHandler extends _i1.Mock - implements _i8.WebViewPlatformCallbacksHandler { + implements _i9.WebViewPlatformCallbacksHandler { MockWebViewPlatformCallbacksHandler() { _i1.throwOnMissingStub(this); } @@ -555,7 +692,7 @@ class MockWebViewPlatformCallbacksHandler extends _i1.Mock super.noSuchMethod(Invocation.method(#onProgress, [progress]), returnValueForMissingStub: null); @override - void onWebResourceError(_i10.WebResourceError? error) => + void onWebResourceError(_i11.WebResourceError? error) => super.noSuchMethod(Invocation.method(#onWebResourceError, [error]), returnValueForMissingStub: null); } @@ -564,7 +701,7 @@ class MockWebViewPlatformCallbacksHandler extends _i1.Mock /// /// See the documentation for Mockito's code generation for more information. class MockWebViewWidgetProxy extends _i1.Mock - implements _i11.WebViewWidgetProxy { + implements _i12.WebViewWidgetProxy { MockWebViewWidgetProxy() { _i1.throwOnMissingStub(this); } From 88816c95f93f515b846a36bd740280a62310a548 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 19 May 2022 09:40:32 -0700 Subject: [PATCH 14/40] finish dart standardization and support earlier versions --- .../lib/src/common/instance_manager.dart | 68 +++++++----- .../lib/src/foundation/foundation.dart | 9 +- .../src/foundation/foundation_api_impls.dart | 11 +- .../lib/src/ui_kit/ui_kit.dart | 4 + .../lib/src/ui_kit/ui_kit_api_impls.dart | 18 ++-- .../lib/src/web_kit/web_kit.dart | 46 ++++---- .../lib/src/web_kit/web_kit_api_impls.dart | 100 +++++++----------- 7 files changed, 123 insertions(+), 133 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 9d794ba68cf0..88bc21ec6465 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -2,22 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.17 - import 'dart:math'; import 'package:flutter/foundation.dart'; /// An immutable object that can provide functional copies of themselves. +/// +/// All implementers are expected to be immutable as defined by the annotation. @immutable mixin Copyable { /// Instantiates and returns a functionally identical object to oneself. /// - /// This method should only ever be called outside of tests by + /// Outside of tests, this method should only ever be called by /// [InstanceManager]. /// - /// Subclasses should always override their parent's implementation and all - /// implementers should be immutable. + /// Subclasses should always override their parent's implementation of this + /// method. @protected Copyable copy(); } @@ -37,24 +37,26 @@ mixin Copyable { /// strong reference is added as a weak reference with the same identifier. This /// prevents a scenario where the weak referenced instance was released and then /// later returned by the host platform. +// TODO(bparrishMines): Uncomment code with Finalizers and WeakReferences once +// minimum dart version is bumped to 2.17. class InstanceManager { /// Constructs an [InstanceManager]. - InstanceManager({required this.onWeakReferenceRemoved}) - : _finalizer = Finalizer(onWeakReferenceRemoved); + InstanceManager({required this.onWeakReferenceRemoved}); // Expando is used because it doesn't prevent its keys from becoming // inaccessible. This allows the manager to efficiently retrieve an identifier - // of an object without holding a strong reference to the object. + // of an instance without holding a strong reference to that instance. // // It also doesn't use `==` to search for identifiers, which would lead to an // infinite loop when comparing an object to its copy. (i.e. which was caused // by calling instanceManager.getInstanceId() inside of `==` while this was a // HashMap). final Expando _identifiers = Expando(); - final Map> _weakInstances = - >{}; + final Map _weakInstances = {}; + // final Map> _weakInstances = + // >{}; final Map _strongInstances = {}; - final Finalizer _finalizer; + // final Finalizer _finalizer; /// Called when a weak referenced instance is removed by [removeWeakReference] /// or becomes inaccessible. @@ -92,7 +94,7 @@ class InstanceManager { _identifiers[instance] = null; _weakInstances.remove(identifier); - _finalizer.detach(instance); + //_finalizer.detach(instance); onWeakReferenceRemoved(identifier); return identifier; @@ -114,28 +116,30 @@ class InstanceManager { /// Retrieve the instance associated with identifier. /// /// The value returned is chosen in this order: - /// 1. A weak reference asscociated with identifier. - /// 2. [returnedInstanceMayBeUsed] is set to true and the only instance - /// associated with identifier is a strong referenced instance, a copy of the - /// instance is added as a weak reference with the same instance id. Returning - /// the newly created weak reference copy. - /// 3. [returnedInstanceMayBeUsed] is set to false and the only instance - /// associated with identifier is a strong reference. The strong reference is - /// returned. + /// 1. A weakly referenced instance asscociated with identifier. + /// 2. When [returnedInstanceMayBeUsed] is set to `true` and the only instance + /// associated with identifier is a strongly referenced instance, a copy of the + /// instance is added as a weakly reference with the same instance id. Returning + /// the newly created weakly referenced copy. + /// 3. When [returnedInstanceMayBeUsed] is set to `false` and the only + /// instance associated with identifier has a strong reference. The strongly + /// referenced instance is returned. /// 4. If no instance is associated with identifier, returns null. T? getInstance( int identifier, { required bool returnedInstanceMayBeUsed, }) { - final Copyable? weakInstance = _weakInstances[identifier]?.target; + // final Copyable? weakInstance = _weakInstances[identifier]?.target; + final Copyable? weakInstance = _weakInstances[identifier]; if (weakInstance == null) { final Copyable? strongInstance = _strongInstances[identifier]; if (strongInstance != null && returnedInstanceMayBeUsed) { final Copyable copy = strongInstance.copy(); _identifiers[copy] = identifier; - _weakInstances[identifier] = WeakReference(copy); - _finalizer.attach(copy, identifier, detach: copy); + _weakInstances[identifier] = copy; + // _weakInstances[identifier] = WeakReference(copy); + // _finalizer.attach(copy, identifier, detach: copy); return copy as T; } return strongInstance as T?; @@ -144,7 +148,7 @@ class InstanceManager { return weakInstance as T; } - /// Retrieve the identifier paired with instance. + /// Retrieve the identifier associated with instance. int? getIdentifier(Copyable instance) { return _identifiers[instance]; } @@ -159,15 +163,16 @@ class InstanceManager { /// /// Returns the randomly generated id of the [instance] added. void addHostCreatedInstance(Copyable instance, int identifier) { - assert(getInstance(identifier, returnedInstanceMayBeUsed: false) == null); + assert(!containsIdentifier(identifier)); assert(getIdentifier(instance) == null); _addInstanceWithIdentifier(instance, identifier); } void _addInstanceWithIdentifier(Copyable instance, int identifier) { _identifiers[instance] = identifier; - _weakInstances[identifier] = WeakReference(instance); - _finalizer.attach(instance, identifier, detach: instance); + _weakInstances[identifier] = instance; + // _weakInstances[identifier] = WeakReference(instance); + // _finalizer.attach(instance, identifier, detach: instance); final Copyable copy = instance.copy(); _identifiers[copy] = identifier; @@ -176,12 +181,19 @@ class InstanceManager { assert(instance == copy); } + /// Whether this manager contains the given [identifier]. + bool containsIdentifier(int identifier) { + return getInstance(identifier, returnedInstanceMayBeUsed: false) != null; + } + + // Identifiers are generated randomly to avoid collisions with objects + // created simultaneously by the host platform. int _generateNewIdentifier() { late int identifier; do { // Max must be in range 0 < max ≤ 2^32. identifier = Random().nextInt(4294967296); - } while (getInstance(identifier, returnedInstanceMayBeUsed: false) != null); + } while (containsIdentifier(identifier)); return identifier; } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart index 1629b1b3b9d9..8a24aab994f5 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart @@ -275,7 +275,14 @@ class NSObject with Copyable { /// Release the reference to the Objective-C object. static void dispose(NSObject instance) { - instance._api.instanceManager.removeWeakReference(instance); + final int? identifier = instance._api.instanceManager.removeWeakReference( + instance, + ); + // TODO(bparrishMines): Remove these line once InstanceManager uses + // Finalizers. + if (identifier != null) { + instance._api.instanceManager.removeStrongReference(identifier); + } } /// Informs the observing object when the value at the specified key path has changed. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart index d76f1d6a21d3..9575cb51c648 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart @@ -37,6 +37,8 @@ Iterable } /// Handles initialization of Flutter APIs for the Foundation library. +// TODO(bparrishMines): Add NSObjectFlutterApiImpl once the callback methods +// are added. class FoundationFlutterApis { /// Constructs a [FoundationFlutterApis]. @visibleForTesting @@ -118,15 +120,6 @@ class NSObjectHostApiImpl extends NSObjectHostApi { ); } - /// Calls [dispose] with the ids of the provided object instances. - Future disposeForInstances(NSObject instance) async { - final int? identifier = instanceManager.removeWeakReference(instance); - if (identifier != null) { - instanceManager.removeStrongReference(identifier); - await dispose(identifier); - } - } - @override int get hashCode { return Object.hash(binaryMessenger, instanceManager); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit.dart index 7c1bdd01724c..1d89b18c9f05 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit.dart @@ -12,6 +12,10 @@ import '../foundation/foundation.dart'; import '../web_kit/web_kit.dart'; import 'ui_kit_api_impls.dart'; +// TODO(bparrishMines): All subclasses of NSObject need to pass their +// InstanceManager and BinaryMessenger to its parent. They also need to +// override copy(); + /// A view that allows the scrolling and zooming of its contained views. /// /// Wraps [UIScrollView](https://developer.apple.com/documentation/uikit/uiscrollview?language=objc). diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart index 58fd18d8bc36..f0a0a54f9f3f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart @@ -30,14 +30,12 @@ class UIScrollViewHostApiImpl extends UIScrollViewHostApi { Future createFromWebViewForInstances( UIScrollView instance, WKWebView webView, - ) async { + ) { final int instanceId = instanceManager.addFlutterCreatedInstance(instance); - if (instanceId != null) { - await createFromWebView( - instanceId, - instanceManager.getIdentifier(webView)!, - ); - } + return createFromWebView( + instanceId, + instanceManager.getIdentifier(webView)!, + ); } /// Calls [getContentOffset] with the ids of the provided object instances. @@ -66,7 +64,7 @@ class UIScrollViewHostApiImpl extends UIScrollViewHostApi { Future setContentOffsetForInstances( UIScrollView instance, Point offset, - ) async { + ) { return setContentOffset( instanceManager.getIdentifier(instance)!, offset.x, @@ -91,7 +89,7 @@ class UIViewHostApiImpl extends UIViewHostApi { Future setBackgroundColorForInstances( UIView instance, Color? color, - ) async { + ) { return setBackgroundColor( instanceManager.getIdentifier(instance)!, color?.value, @@ -102,7 +100,7 @@ class UIViewHostApiImpl extends UIViewHostApi { Future setOpaqueForInstances( UIView instance, bool opaque, - ) async { + ) { return setOpaque(instanceManager.getIdentifier(instance)!, opaque); } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart index a79c52a06710..c15f4542f6b6 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart @@ -11,7 +11,8 @@ import '../ui_kit/ui_kit.dart'; import 'web_kit_api_impls.dart'; // TODO(bparrishMines): All subclasses of NSObject need to pass their -// InstanceManager and BinaryMessenger to its parent. +// InstanceManager and BinaryMessenger to its parent. They also need to +// override copy(); /// Times at which to inject script content into a webpage. /// @@ -603,29 +604,28 @@ class WKUIDelegate extends NSObject { @immutable class WKNavigationDelegate extends NSObject { /// Constructs a [WKNavigationDelegate]. - factory WKNavigationDelegate({ - void Function( - WKWebView webView, - String? url, - )? - didFinishNavigation, + WKNavigationDelegate({ + this.didFinishNavigation, BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, - }) { - final WKNavigationDelegate delegate = WKNavigationDelegate._copy( - didFinishNavigation: didFinishNavigation, - binaryMessenger: binaryMessenger, - instanceManager: instanceManager, - ); - delegate._navigationDelegateApi.createForInstances( - delegate, - didFinishNavigation, - ); - return delegate; + }) : _navigationDelegateApi = WKNavigationDelegateHostApiImpl( + binaryMessenger: binaryMessenger, + instanceManager: instanceManager, + ), + super( + binaryMessenger: binaryMessenger, + instanceManager: instanceManager, + ) { + WebKitFlutterApis.instance.ensureSetUp(); + _navigationDelegateApi.createForInstances(this); } - // Doesn't create the Objective-C associated object. - WKNavigationDelegate._copy({ + // Constructs a WKNavigationDelegate with creating the associated Objective-C + // object. + // + // This should only be used by subclasses created by this library and for + // creating copies. + WKNavigationDelegate._implementation({ this.didFinishNavigation, BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, @@ -636,9 +636,7 @@ class WKNavigationDelegate extends NSObject { super( binaryMessenger: binaryMessenger, instanceManager: instanceManager, - ) { - WebKitFlutterApis.instance.ensureSetUp(); - } + ); final WKNavigationDelegateHostApiImpl _navigationDelegateApi; @@ -690,7 +688,7 @@ class WKNavigationDelegate extends NSObject { @override Copyable copy() { - return WKNavigationDelegate._copy( + return WKNavigationDelegate._implementation( didFinishNavigation: didFinishNavigation, binaryMessenger: _navigationDelegateApi.binaryMessenger, instanceManager: _navigationDelegateApi.instanceManager, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart index 08b7f7f03271..1d3ca62b8ce4 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart @@ -236,14 +236,13 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { Future createFromWebViewConfigurationForInstances( WKWebsiteDataStore instance, WKWebViewConfiguration configuration, - ) async { + ) { final int instanceId = instanceManager.addFlutterCreatedInstance(instance); - if (instanceId != null) { - await createFromWebViewConfiguration( - instanceId, - instanceManager.getIdentifier(configuration)!, - ); - } + + return createFromWebViewConfiguration( + instanceId, + instanceManager.getIdentifier(configuration)!, + ); } /// Calls [createDefaultDataStore] with the ids of the provided object instances. @@ -251,9 +250,7 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { WKWebsiteDataStore instance, ) async { final int instanceId = instanceManager.addFlutterCreatedInstance(instance); - if (instanceId != null) { - await createDefaultDataStore(instanceId); - } + return createDefaultDataStore(instanceId); } /// Calls [removeDataOfTypes] with the ids of the provided object instances. @@ -285,9 +282,7 @@ class WKScriptMessageHandlerHostApiImpl extends WKScriptMessageHandlerHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKScriptMessageHandler instance) async { final int instanceId = instanceManager.addFlutterCreatedInstance(instance); - if (instanceId != null) { - await create(instanceId); - } + return create(instanceId); } } @@ -307,14 +302,12 @@ class WKPreferencesHostApiImpl extends WKPreferencesHostApi { Future createFromWebViewConfigurationForInstances( WKPreferences instance, WKWebViewConfiguration configuration, - ) async { + ) { final int instanceId = instanceManager.addFlutterCreatedInstance(instance); - if (instanceId != null) { - await createFromWebViewConfiguration( - instanceId, - instanceManager.getIdentifier(configuration)!, - ); - } + return createFromWebViewConfiguration( + instanceId, + instanceManager.getIdentifier(configuration)!, + ); } /// Calls [setJavaScriptEnabled] with the ids of the provided object instances. @@ -345,14 +338,12 @@ class WKHttpCookieStoreHostApiImpl extends WKHttpCookieStoreHostApi { Future createFromWebsiteDataStoreForInstances( WKHttpCookieStore instance, WKWebsiteDataStore dataStore, - ) async { + ) { final int instanceId = instanceManager.addFlutterCreatedInstance(instance); - if (instanceId != null) { - await createFromWebsiteDataStore( - instanceId, - instanceManager.getIdentifier(dataStore)!, - ); - } + return createFromWebsiteDataStore( + instanceId, + instanceManager.getIdentifier(dataStore)!, + ); } /// Calls [setCookie] with the ids of the provided object instances. @@ -386,12 +377,10 @@ class WKUserContentControllerHostApiImpl WKWebViewConfiguration configuration, ) async { final int instanceId = instanceManager.addFlutterCreatedInstance(instance); - if (instanceId != null) { - await createFromWebViewConfiguration( - instanceId, - instanceManager.getIdentifier(configuration)!, - ); - } + return createFromWebViewConfiguration( + instanceId, + instanceManager.getIdentifier(configuration)!, + ); } /// Calls [addScriptMessageHandler] with the ids of the provided object instances. @@ -459,11 +448,9 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { final InstanceManager instanceManager; /// Calls [create] with the ids of the provided object instances. - Future createForInstances(WKWebViewConfiguration instance) async { + Future createForInstances(WKWebViewConfiguration instance) { final int instanceId = instanceManager.addFlutterCreatedInstance(instance); - if (instanceId != null) { - await create(instanceId); - } + return create(instanceId); } /// Calls [createFromWebView] with the ids of the provided object instances. @@ -472,12 +459,10 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { WKWebView webView, ) async { final int instanceId = instanceManager.addFlutterCreatedInstance(instance); - if (instanceId != null) { - await createFromWebView( - instanceId, - instanceManager.getIdentifier(webView)!, - ); - } + return createFromWebView( + instanceId, + instanceManager.getIdentifier(webView)!, + ); } /// Calls [setAllowsInlineMediaPlayback] with the ids of the provided object instances. @@ -518,9 +503,7 @@ class WKUIDelegateHostApiImpl extends WKUIDelegateHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKUIDelegate instance) async { final int instanceId = instanceManager.addFlutterCreatedInstance(instance); - if (instanceId != null) { - await create(instanceId); - } + return create(instanceId); } } @@ -544,14 +527,9 @@ class WKNavigationDelegateHostApiImpl extends WKNavigationDelegateHostApi { final InstanceManager instanceManager; /// Calls [create] with the ids of the provided object instances. - Future createForInstances( - WKNavigationDelegate instance, - void Function(WKWebView webView, String? url)? didFinishNavigation, - ) async { + Future createForInstances(WKNavigationDelegate instance) async { final int instanceId = instanceManager.addFlutterCreatedInstance(instance); - if (instanceId != null) { - await create(instanceId); - } + return create(instanceId); } @override @@ -619,19 +597,19 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { Future createForInstances( WKWebView instance, WKWebViewConfiguration configuration, - ) async { + ) { final int instanceId = instanceManager.addFlutterCreatedInstance(instance); - if (instanceId != null) { - await create( - instanceId, - instanceManager.getIdentifier(configuration)!, - ); - } + return create( + instanceId, + instanceManager.getIdentifier(configuration)!, + ); } /// Calls [loadRequest] with the ids of the provided object instances. Future loadRequestForInstances( - WKWebView webView, NSUrlRequest request) { + WKWebView webView, + NSUrlRequest request, + ) { return loadRequest( instanceManager.getIdentifier(webView)!, request.toNSUrlRequestData(), From 9d25ab1341a0cc7b1ed55258b63af55c2ac8a017 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 19 May 2022 12:30:05 -0700 Subject: [PATCH 15/40] fix dart instance manager --- .../ios/Classes/FWFInstanceManager.m | 67 +++++++++++-------- .../lib/src/common/instance_manager.dart | 17 +++-- 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index 445ecd3e2cf9..0240de432c3d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -6,67 +6,76 @@ @interface FWFInstanceManager () @property dispatch_queue_t lockQueue; -@property NSMapTable *identifiersToInstances; -@property NSMapTable *instancesToIdentifiers; +@property NSMapTable *identifiers; +@property NSMapTable *weakInstances; +@property NSMapTable *strongInstances; @end @implementation FWFInstanceManager - (instancetype)init { if (self) { _lockQueue = dispatch_queue_create("FWFInstanceManager", DISPATCH_QUEUE_SERIAL); - _identifiersToInstances = [NSMapTable strongToStrongObjectsMapTable]; - _instancesToIdentifiers = [NSMapTable strongToStrongObjectsMapTable]; + _identifiers = [NSMapTable weakToStrongObjectsMapTable]; + _weakInstances = [NSMapTable strongToWeakObjectsMapTable]; + _strongInstances = [NSMapTable strongToStrongObjectsMapTable]; } return self; } -- (void)addInstance:(nonnull NSObject *)instance withIdentifier:(long)instanceIdentifier { - NSAssert(instance && instanceIdentifier >= 0, - @"Instance must be nonnull and identifier must be >= 0."); +- (void)addFlutterCreatedInstance:(NSObject *)instance withIdentifier:(long)instanceIdentifier { + NSParameterAssert(instance); + NSParameterAssert(instanceIdentifier >= 0); dispatch_async(_lockQueue, ^{ - [self.instancesToIdentifiers setObject:@(instanceIdentifier) forKey:instance]; - [self.identifiersToInstances setObject:instance forKey:@(instanceIdentifier)]; + [self addInstance:instance withIdentifier:instanceIdentifier]; }); } -- (nullable NSObject *)removeInstanceWithIdentifier:(long)instanceIdentifier { - NSObject *__block instance = nil; - dispatch_sync(_lockQueue, ^{ - instance = [self.identifiersToInstances objectForKey:@(instanceIdentifier)]; - if (instance) { - [self.identifiersToInstances removeObjectForKey:@(instanceIdentifier)]; - [self.instancesToIdentifiers removeObjectForKey:instance]; - } +- (void)addHostCreatedInstance:(nonnull NSObject *)instance { + NSParameterAssert(instance); + dispatch_async(_lockQueue, ^{ + long identifier; + do { + identifier = arc4random_uniform(65536) + 65536; + // TODO: dfg + } while (YES); + [self addInstance:instance withIdentifier:identifier]; }); - return instance; } -- (long)removeInstance:(NSObject *)instance { - NSAssert(instance, @"Instance must be nonnull."); - NSNumber *__block identifierNumber = nil; +- (nullable NSObject *)removeStrongReferenceWithIdentifier:(long)instanceIdentifier { + NSObject *__block instance = nil; dispatch_sync(_lockQueue, ^{ - identifierNumber = [self.instancesToIdentifiers objectForKey:instance]; - if (identifierNumber) { - [self.identifiersToInstances removeObjectForKey:identifierNumber]; - [self.instancesToIdentifiers removeObjectForKey:instance]; + instance = [self.strongInstances objectForKey:@(instanceIdentifier)]; + if (instance) { + [self.strongInstances removeObjectForKey:@(instanceIdentifier)]; } }); - return identifierNumber ? identifierNumber.longValue : NSNotFound; + return instance; } - (nullable NSObject *)instanceForIdentifier:(long)instanceIdentifier { NSObject *__block instance = nil; dispatch_sync(_lockQueue, ^{ - instance = [self.identifiersToInstances objectForKey:@(instanceIdentifier)]; + instance = [self.weakInstances objectForKey:@(instanceIdentifier)]; }); return instance; } -- (long)identifierForInstance:(nonnull NSObject *)instance { +- (long)identifierForInstance:(nonnull NSObject *)instance identifierWillBePassedToFlutter:(BOOL)willBePassed { NSNumber *__block identifierNumber = nil; dispatch_sync(_lockQueue, ^{ - identifierNumber = [self.instancesToIdentifiers objectForKey:instance]; + identifierNumber = [self.identifiers objectForKey:instance]; + if (identifierNumber && willBePassed) { + [self.strongInstances setObject:instance forKey:identifierNumber]; + } }); return identifierNumber ? identifierNumber.longValue : NSNotFound; } + +- (void)addInstance:(nonnull NSObject *)instance withIdentifier:(long)instanceIdentifier { + [self.identifiers setObject:@(instanceIdentifier) forKey:instance]; + [self.weakInstances setObject:instance forKey:@(instanceIdentifier)]; + [self.strongInstances setObject:instance forKey:@(instanceIdentifier)]; + // TODO: Attach associated object. +} @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 88bc21ec6465..ec98f3b77544 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -41,7 +41,12 @@ mixin Copyable { // minimum dart version is bumped to 2.17. class InstanceManager { /// Constructs an [InstanceManager]. - InstanceManager({required this.onWeakReferenceRemoved}); + InstanceManager({required void Function(int) onWeakReferenceRemoved}) { + this.onWeakReferenceRemoved = (int identifier) { + _weakInstances.remove(identifier); + onWeakReferenceRemoved(identifier); + }; + } // Expando is used because it doesn't prevent its keys from becoming // inaccessible. This allows the manager to efficiently retrieve an identifier @@ -60,7 +65,7 @@ class InstanceManager { /// Called when a weak referenced instance is removed by [removeWeakReference] /// or becomes inaccessible. - final void Function(int) onWeakReferenceRemoved; + late final void Function(int) onWeakReferenceRemoved; /// Adds a new instance that was instantiated by Flutter. /// @@ -93,7 +98,6 @@ class InstanceManager { } _identifiers[instance] = null; - _weakInstances.remove(identifier); //_finalizer.detach(instance); onWeakReferenceRemoved(identifier); @@ -183,7 +187,8 @@ class InstanceManager { /// Whether this manager contains the given [identifier]. bool containsIdentifier(int identifier) { - return getInstance(identifier, returnedInstanceMayBeUsed: false) != null; + return _weakInstances.containsKey(identifier) || + _strongInstances.containsKey(identifier); } // Identifiers are generated randomly to avoid collisions with objects @@ -191,8 +196,8 @@ class InstanceManager { int _generateNewIdentifier() { late int identifier; do { - // Max must be in range 0 < max ≤ 2^32. - identifier = Random().nextInt(4294967296); + // Max must be in range 0 < max ≤ 2^16. + identifier = Random().nextInt(65536); } while (containsIdentifier(identifier)); return identifier; } From 4d7ebc4d61923d195919a2e5261520807f0f8cf0 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 19 May 2022 14:36:35 -0700 Subject: [PATCH 16/40] instance manager ish --- .../ios/Classes/FWFInstanceManager.h | 54 ++++++++++++------- .../ios/Classes/FWFInstanceManager.m | 52 +++++++++++++++--- .../lib/src/common/instance_manager.dart | 4 +- 3 files changed, 82 insertions(+), 28 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h index 79506bf72adc..4b87d3c22eb1 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h @@ -6,17 +6,30 @@ NS_ASSUME_NONNULL_BEGIN +typedef void (^FWFOnDeallocCallback) (long identifier); + /** - * Maintains instances to intercommunicate with Dart objects. + * Maintains instances used to communicate with the Dart objects that represent them in Flutter. * * When an instance is added with an identifier, either can be used to retrieve the other. + * + * Added instances are added as a weak reference and a strong reference. When the strong reference + * is removed with `removeStrongReferenceWithIdentifier:` and the weak reference is deallocated, + * the `deallocCallback` is made with the instance's identifier. However, if the strong reference is + * removed and then the identifier is retrieved with the intention to pass the identifier to Dart + * (e.g. calling `identifierForInstance:identifierWillBePassedToFlutter:` with `identifierWillBePassedToFlutter` + * set to YES), the strong reference to the instance is recreated. The strong reference will then need to be + * removed manually again. + * + * Accessing and inserting to an InstanceManager is thread safe. */ @interface FWFInstanceManager : NSObject +@property (readonly) FWFOnDeallocCallback deallocCallback; +- (instancetype)initWithDeallocCallback:(FWFOnDeallocCallback)callback; // TODO(bparrishMines): Pairs should not be able to be overwritten and this feature -// should be replaced with a call to clear the manager in the event of a hot restart -// instead. +// should be replaced with a call to clear the manager in the event of a hot restart. /** - * Adds a new instance to the manager. + * Adds a new instance that was instantiated by Flutter. * * If an instance or identifier has already been added, it will be replaced by the new values. The * Dart InstanceManager is considered the source of truth and has the capability to overwrite stored @@ -25,34 +38,32 @@ NS_ASSUME_NONNULL_BEGIN * @param instance The instance to be stored. * @param instanceIdentifier The identifier to be paired with instance. This value must be >= 0. */ -- (void)addInstance:(NSObject *)instance withIdentifier:(long)instanceIdentifier; +- (void)addFlutterCreatedInstance:(NSObject *)instance withIdentifier:(long)instanceIdentifier; /** - * Removes the instance paired with a given identifier from the manager. + * Adds a new instance that was instantiated by the host platform. * - * @param instanceIdentifier The identifier paired to an instance. - * - * @return The removed instance if the manager contains the given instanceIdentifier, otherwise - * nil. + * @param instance The instance to be stored. + * @return The randomly generated identifier stored with instance. */ -- (nullable NSObject *)removeInstanceWithIdentifier:(long)instanceIdentifier; +- (long)addHostCreatedInstance:(nonnull NSObject *)instance; /** - * Removes the instance from the manager. + * Removes `instanceIdentifier` and its associated strongly referenced instance, if present, from the manager. * - * @param instance The instance to be removed from the manager. + * @param instanceIdentifier The identifier paired to an instance. * - * @return The identifier of the removed instance if the manager contains the given instance, - * otherwise NSNotFound. + * @return The removed instance if the manager contains the given instanceIdentifier, otherwise + * nil. */ -- (long)removeInstance:(NSObject *)instance; +- (nullable NSObject *)removeStrongReferenceWithIdentifier:(long)instanceIdentifier; /** - * Retrieves the instance paired with identifier. + * Retrieves the instance associated with identifier. * * @param instanceIdentifier The identifier paired to an instance. * - * @return The paired instance if the manager contains the given instanceIdentifier, + * @return The instance associated with `instanceIdentifier` if the manager contains the value, * otherwise nil. */ - (nullable NSObject *)instanceForIdentifier:(long)instanceIdentifier; @@ -60,11 +71,14 @@ NS_ASSUME_NONNULL_BEGIN /** * Retrieves the identifier paired with an instance. * + * * @param instance An instance that may be stored in the manager. + * @param willBePassed Whether the identifier will be passed to Dart. If YES, the strong reference + * to `instance` will be recreated and will need to be removed again by `removeStrongReferenceWithIdentifier:`. * - * @return The paired identifer if the manager contains the given instance, otherwise NSNotFound. + * @return The identifer associated with `instance` if the manager contains the value, otherwise NSNotFound. */ -- (long)identifierForInstance:(NSObject *)instance; +- (long)identifierForInstance:(nonnull NSObject *)instance identifierWillBePassedToFlutter:(BOOL)willBePassed; @end NS_ASSUME_NONNULL_END diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index 0240de432c3d..a4ff28442770 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -3,6 +3,40 @@ // found in the LICENSE file. #import "FWFInstanceManager.h" +#import + +// Attach to an object to track when an object is deallocated. +@interface FWFFinalizer : NSObject +@property (nonatomic) long identifier; +// Callbacks are no longer made once FWFInstanceManager is inaccessible. +@property (nonatomic, weak) FWFOnDeallocCallback callback; ++ (void)attachToInstance:(NSObject *)instance withIdentifier:(long)identifier callback:(FWFOnDeallocCallback)callback; ++ (void)detachInstance:(NSObject *)instance; +@end + +@implementation FWFFinalizer +-(instancetype)initWithIdentifier:(long)identifier callback:(FWFOnDeallocCallback)callback { + self = [self init]; + if (self) { + _identifier = identifier; + _callback = callback; + } + return self; +} + ++ (void)attachToInstance:(NSObject *)instance withIdentifier:(long)identifier callback:(FWFOnDeallocCallback)callback { + FWFFinalizer *finalizer = [[FWFFinalizer alloc] initWithIdentifier:identifier callback:callback]; + objc_setAssociatedObject(instance, _cmd, finalizer, OBJC_ASSOCIATION_RETAIN); +} + ++ (void)detachInstance:(NSObject *)instance { + objc_setAssociatedObject(instance, @selector(attachToInstance:withIdentifier:callback:), nil, OBJC_ASSOCIATION_ASSIGN); +} + +-(void) dealloc { + self.callback(self.identifier); +} +@end @interface FWFInstanceManager () @property dispatch_queue_t lockQueue; @@ -12,8 +46,10 @@ @interface FWFInstanceManager () @end @implementation FWFInstanceManager -- (instancetype)init { +- (instancetype)initWithDeallocCallback:(FWFOnDeallocCallback)callback { + self = [self init]; if (self) { + _deallocCallback = callback; _lockQueue = dispatch_queue_create("FWFInstanceManager", DISPATCH_QUEUE_SERIAL); _identifiers = [NSMapTable weakToStrongObjectsMapTable]; _weakInstances = [NSMapTable strongToWeakObjectsMapTable]; @@ -30,16 +66,20 @@ - (void)addFlutterCreatedInstance:(NSObject *)instance withIdentifier:(long)inst }); } -- (void)addHostCreatedInstance:(nonnull NSObject *)instance { +- (long)addHostCreatedInstance:(nonnull NSObject *)instance { NSParameterAssert(instance); - dispatch_async(_lockQueue, ^{ + long identifier = NSNotFound; + dispatch_sync(_lockQueue, ^{ long identifier; do { + // Identifiers are generated randomly to avoid collisions with objects + // created simultaneously by the Flutter. + // Value must be >= 2^16. identifier = arc4random_uniform(65536) + 65536; - // TODO: dfg - } while (YES); + } while ([self.weakInstances objectForKey:@(identifier)] || [self.strongInstances objectForKey:@(identifier)]); [self addInstance:instance withIdentifier:identifier]; }); + return identifier; } - (nullable NSObject *)removeStrongReferenceWithIdentifier:(long)instanceIdentifier { @@ -76,6 +116,6 @@ - (void)addInstance:(nonnull NSObject *)instance withIdentifier:(long)instanceId [self.identifiers setObject:@(instanceIdentifier) forKey:instance]; [self.weakInstances setObject:instance forKey:@(instanceIdentifier)]; [self.strongInstances setObject:instance forKey:@(instanceIdentifier)]; - // TODO: Attach associated object. + [FWFFinalizer attachToInstance:instance withIdentifier:instanceIdentifier callback:self.deallocCallback]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index ec98f3b77544..ecc9bc7fdea7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -104,7 +104,7 @@ class InstanceManager { return identifier; } - /// Removes [identifier] and its associated strong referenced instance, if + /// Removes [identifier] and its associated strongly referenced instance, if /// present, from the manager. /// /// Returns the strong referenced instance associated with [identifier] before @@ -196,7 +196,7 @@ class InstanceManager { int _generateNewIdentifier() { late int identifier; do { - // Max must be in range 0 < max ≤ 2^16. + // Value must be < 2^16. identifier = Random().nextInt(65536); } while (containsIdentifier(identifier)); return identifier; From 81b201f1cefb84ed5faed223686b3c2528479e6b Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 19 May 2022 15:25:58 -0700 Subject: [PATCH 17/40] most tests passing --- .../FWFHTTPCookieStoreHostApiTests.m | 8 +- .../ios/RunnerTests/FWFInstanceManagerTests.m | 56 ++++++------- .../FWFNavigationDelegateHostApiTests.m | 8 +- .../ios/RunnerTests/FWFObjectHostApiTests.m | 20 ++--- .../RunnerTests/FWFPreferencesHostApiTests.m | 8 +- .../FWFScriptMessageHandlerHostApiTests.m | 2 +- .../RunnerTests/FWFScrollViewHostApiTests.m | 12 +-- .../RunnerTests/FWFUIDelegateHostApiTests.m | 2 +- .../ios/RunnerTests/FWFUIViewHostApiTests.m | 9 +-- .../FWFUserContentControllerHostApiTests.m | 26 +++--- .../FWFWebViewConfigurationHostApiTests.m | 14 ++-- .../ios/RunnerTests/FWFWebViewHostApiTests.m | 80 +++++++++---------- .../FWFWebsiteDataStoreHostApiTests.m | 10 +-- .../ios/Classes/FWFHTTPCookieStoreHostApi.m | 4 +- .../ios/Classes/FWFInstanceManager.m | 4 +- .../Classes/FWFNavigationDelegateHostApi.h | 1 + .../Classes/FWFNavigationDelegateHostApi.m | 12 ++- .../ios/Classes/FWFObjectHostApi.m | 2 +- .../ios/Classes/FWFPreferencesHostApi.m | 6 +- .../Classes/FWFScriptMessageHandlerHostApi.m | 4 +- .../ios/Classes/FWFScrollViewHostApi.m | 4 +- .../ios/Classes/FWFUIDelegateHostApi.m | 4 +- .../ios/Classes/FWFUIViewHostApi.m | 2 +- .../Classes/FWFUserContentControllerHostApi.m | 4 +- .../Classes/FWFWebViewConfigurationHostApi.m | 6 +- .../ios/Classes/FWFWebViewHostApi.m | 2 +- .../ios/Classes/FWFWebsiteDataStoreHostApi.m | 6 +- .../lib/src/foundation/foundation.dart | 13 ++- .../lib/src/web_kit/web_kit.dart | 14 ++-- 29 files changed, 175 insertions(+), 168 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m index 315640a99247..05e348c53155 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m @@ -13,13 +13,13 @@ @interface FWFHTTPCookieStoreHostApiTests : XCTestCase @implementation FWFHTTPCookieStoreHostApiTests - (void)testCreateFromWebsiteDataStoreWithIdentifier API_AVAILABLE(ios(11.0)) { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; FWFHTTPCookieStoreHostApiImpl *hostApi = [[FWFHTTPCookieStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; WKWebsiteDataStore *mockDataStore = OCMClassMock([WKWebsiteDataStore class]); OCMStub([mockDataStore httpCookieStore]).andReturn(OCMClassMock([WKHTTPCookieStore class])); - [instanceManager addInstance:mockDataStore withIdentifier:0]; + [instanceManager addFlutterCreatedInstance:mockDataStore withIdentifier:0]; FlutterError *error; [hostApi createFromWebsiteDataStoreWithIdentifier:@1 dataStoreIdentifier:@0 error:&error]; @@ -31,8 +31,8 @@ - (void)testCreateFromWebsiteDataStoreWithIdentifier API_AVAILABLE(ios(11.0)) { - (void)testSetCookie API_AVAILABLE(ios(11.0)) { WKHTTPCookieStore *mockHttpCookieStore = OCMClassMock([WKHTTPCookieStore class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockHttpCookieStore withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockHttpCookieStore withIdentifier:0]; FWFHTTPCookieStoreHostApiImpl *hostApi = [[FWFHTTPCookieStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m index 7b40da131d23..b32bb90791b5 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m @@ -9,32 +9,32 @@ @interface FWFInstanceManagerTests : XCTestCase @end @implementation FWFInstanceManagerTests -- (void)testAddInstance { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - NSObject *object = [[NSObject alloc] init]; - - [instanceManager addInstance:object withIdentifier:5]; - XCTAssertEqualObjects([instanceManager instanceForIdentifier:5], object); - XCTAssertEqual([instanceManager identifierForInstance:object], 5); -} - -- (void)testRemoveInstance { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - NSObject *object = [[NSObject alloc] init]; - [instanceManager addInstance:object withIdentifier:5]; - - [instanceManager removeInstance:object]; - XCTAssertNil([instanceManager instanceForIdentifier:5]); - XCTAssertEqual([instanceManager identifierForInstance:object], NSNotFound); -} - -- (void)testRemoveInstanceWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - NSObject *object = [[NSObject alloc] init]; - [instanceManager addInstance:object withIdentifier:5]; - - [instanceManager removeInstanceWithIdentifier:5]; - XCTAssertNil([instanceManager instanceForIdentifier:5]); - XCTAssertEqual([instanceManager identifierForInstance:object], NSNotFound); -} +//- (void)testAddInstance { +// FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; +// NSObject *object = [[NSObject alloc] init]; +// +// [instanceManager addInstance:object withIdentifier:5]; +// XCTAssertEqualObjects([instanceManager instanceForIdentifier:5], object); +// XCTAssertEqual([instanceManager identifierForInstance:object], 5); +//} +// +//- (void)testRemoveInstance { +// FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; +// NSObject *object = [[NSObject alloc] init]; +// [instanceManager addInstance:object withIdentifier:5]; +// +// [instanceManager removeInstance:object]; +// XCTAssertNil([instanceManager instanceForIdentifier:5]); +// XCTAssertEqual([instanceManager identifierForInstance:object], NSNotFound); +//} +// +//- (void)testRemoveInstanceWithIdentifier { +// FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; +// NSObject *object = [[NSObject alloc] init]; +// [instanceManager addInstance:object withIdentifier:5]; +// +// [instanceManager removeInstanceWithIdentifier:5]; +// XCTAssertNil([instanceManager instanceForIdentifier:5]); +// XCTAssertEqual([instanceManager identifierForInstance:object], NSNotFound); +//} @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m index fe950e596f5e..8e1af5b40726 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m @@ -38,7 +38,7 @@ @interface FWFNavigationDelegateHostApiTests : XCTestCase @implementation FWFNavigationDelegateHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; FWFNavigationDelegateHostApiImpl *hostAPI = [[FWFNavigationDelegateHostApiImpl alloc] initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) instanceManager:instanceManager]; @@ -53,7 +53,7 @@ - (void)testCreateWithIdentifier { } - (void)testDidFinishNavigation { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; FWFNavigationDelegateHostApiImpl *hostAPI = [[FWFNavigationDelegateHostApiImpl alloc] initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) instanceManager:instanceManager]; @@ -73,7 +73,7 @@ - (void)testDidFinishNavigation { WKWebView *mockWebView = OCMClassMock([WKWebView class]); OCMStub([mockWebView URL]).andReturn([NSURL URLWithString:@"https://flutter.dev/"]); - [instanceManager addInstance:mockWebView withIdentifier:1]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:1]; [mockDelegate webView:mockWebView didFinishNavigation:OCMClassMock([WKNavigation class])]; OCMVerify([mockFlutterApi didFinishNavigationForDelegateWithIdentifier:@0 @@ -84,7 +84,7 @@ - (void)testDidFinishNavigation { - (void)testInstanceCanBeReleasedWhenInstanceManagerIsReleased { FWFTestMessenger *testMessenger = [[FWFTestMessenger alloc] init]; - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; FWFNavigationDelegateHostApiImpl *hostAPI = [[FWFNavigationDelegateHostApiImpl alloc] initWithBinaryMessenger:testMessenger instanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m index 6886c2600e13..d82a82db3286 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m @@ -15,14 +15,14 @@ @implementation FWFObjectHostApiTests - (void)testAddObserver { NSObject *mockObject = OCMClassMock([NSObject class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockObject withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockObject withIdentifier:0]; FWFObjectHostApiImpl *hostApi = [[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager]; NSObject *observerObject = [[NSObject alloc] init]; - [instanceManager addInstance:observerObject withIdentifier:1]; + [instanceManager addFlutterCreatedInstance:observerObject withIdentifier:1]; FlutterError *error; [hostApi @@ -47,14 +47,14 @@ - (void)testAddObserver { - (void)testRemoveObserver { NSObject *mockObject = OCMClassMock([NSObject class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockObject withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockObject withIdentifier:0]; FWFObjectHostApiImpl *hostApi = [[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager]; NSObject *observerObject = [[NSObject alloc] init]; - [instanceManager addInstance:observerObject withIdentifier:1]; + [instanceManager addFlutterCreatedInstance:observerObject withIdentifier:1]; FlutterError *error; [hostApi removeObserverForObjectWithIdentifier:@0 @@ -68,15 +68,17 @@ - (void)testRemoveObserver { - (void)testDispose { NSObject *object = [[NSObject alloc] init]; - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:object withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:object withIdentifier:0]; FWFObjectHostApiImpl *hostApi = [[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; [hostApi disposeObjectWithIdentifier:@0 error:&error]; - XCTAssertEqual([instanceManager identifierForInstance:object], NSNotFound); + // Only the strong reference is removed, so the weak reference will remain until object is set to nil. + object = nil; + XCTAssertEqual([instanceManager identifierForInstance:object identifierWillBePassedToFlutter:NO], NSNotFound); XCTAssertNil(error); } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m index 1837a9373930..9733c3d74cff 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m @@ -13,11 +13,11 @@ @interface FWFPreferencesHostApiTests : XCTestCase @implementation FWFPreferencesHostApiTests - (void)testCreateFromWebViewConfigurationWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; FWFPreferencesHostApiImpl *hostApi = [[FWFPreferencesHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; + [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; [hostApi createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -29,8 +29,8 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { - (void)testSetJavaScriptEnabled { WKPreferences *mockPreferences = OCMClassMock([WKPreferences class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockPreferences withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockPreferences withIdentifier:0]; FWFPreferencesHostApiImpl *hostApi = [[FWFPreferencesHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m index cb8348fc4702..0a29b448f5e5 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m @@ -13,7 +13,7 @@ @interface FWFScriptMessageHandlerHostApiTests : XCTestCase @implementation FWFScriptMessageHandlerHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; FWFScriptMessageHandlerHostApiImpl *hostApi = [[FWFScriptMessageHandlerHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m index 87d17119e5e7..4c532ef13ac7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m @@ -16,8 +16,8 @@ - (void)testGetContentOffset { UIScrollView *mockScrollView = OCMClassMock([UIScrollView class]); OCMStub([mockScrollView contentOffset]).andReturn(CGPointMake(1.0, 2.0)); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockScrollView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockScrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostApi = [[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -33,8 +33,8 @@ - (void)testScrollBy { UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; scrollView.contentOffset = CGPointMake(1, 2); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:scrollView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:scrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostApi = [[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -49,8 +49,8 @@ - (void)testScrollBy { - (void)testSetContentOffset { UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:scrollView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:scrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostApi = [[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m index 2f7838be5aa8..c923b6915349 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m @@ -13,7 +13,7 @@ @interface FWFUIDelegateHostApiTests : XCTestCase @implementation FWFUIDelegateHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; FWFUIDelegateHostApiImpl *hostApi = [[FWFUIDelegateHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m index 8c7c9c9b45b1..ad8464f1ba13 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m @@ -15,8 +15,8 @@ @implementation FWFUIViewHostApiTests - (void)testSetBackgroundColor { UIView *mockUIView = OCMClassMock([UIView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockUIView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockUIView withIdentifier:0]; FWFUIViewHostApiImpl *hostApi = [[FWFUIViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -34,8 +34,8 @@ - (void)testSetBackgroundColor { - (void)testSetOpaque { UIView *mockUIView = OCMClassMock([UIView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockUIView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockUIView withIdentifier:0]; FWFUIViewHostApiImpl *hostApi = [[FWFUIViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -45,5 +45,4 @@ - (void)testSetOpaque { OCMVerify([mockUIView setOpaque:YES]); XCTAssertNil(error); } - @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m index d70341e87890..ac853bf3d1dc 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m @@ -13,11 +13,11 @@ @interface FWFUserContentControllerHostApiTests : XCTestCase @implementation FWFUserContentControllerHostApiTests - (void)testCreateFromWebViewConfigurationWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; FWFUserContentControllerHostApiImpl *hostApi = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; + [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; [hostApi createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -31,15 +31,15 @@ - (void)testAddScriptMessageHandler { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockUserContentController withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostApi = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; id mockMessageHandler = OCMProtocolMock(@protocol(WKScriptMessageHandler)); - [instanceManager addInstance:mockMessageHandler withIdentifier:1]; + [instanceManager addFlutterCreatedInstance:mockMessageHandler withIdentifier:1]; FlutterError *error; [hostApi addScriptMessageHandlerForControllerWithIdentifier:@0 @@ -54,8 +54,8 @@ - (void)testRemoveScriptMessageHandler { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockUserContentController withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostApi = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -70,8 +70,8 @@ - (void)testRemoveAllScriptMessageHandlers API_AVAILABLE(ios(14.0)) { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockUserContentController withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostApi = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -86,8 +86,8 @@ - (void)testAddUserScript { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockUserContentController withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostApi = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -113,8 +113,8 @@ - (void)testRemoveAllUserScripts { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockUserContentController withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostApi = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m index dab10799891b..c21c862ca27c 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m @@ -13,7 +13,7 @@ @interface FWFWebViewConfigurationHostApiTests : XCTestCase @implementation FWFWebViewConfigurationHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; FWFWebViewConfigurationHostApiImpl *hostApi = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -26,13 +26,13 @@ - (void)testCreateWithIdentifier { } - (void)testCreateFromWebViewWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; FWFWebViewConfigurationHostApiImpl *hostApi = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; WKWebView *mockWebView = OCMClassMock([WKWebView class]); OCMStub([mockWebView configuration]).andReturn(OCMClassMock([WKWebViewConfiguration class])); - [instanceManager addInstance:mockWebView withIdentifier:0]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FlutterError *error; [hostApi createFromWebViewWithIdentifier:@1 webViewIdentifier:@0 error:&error]; @@ -45,8 +45,8 @@ - (void)testCreateFromWebViewWithIdentifier { - (void)testSetAllowsInlineMediaPlayback { WKWebViewConfiguration *mockWebViewConfiguration = OCMClassMock([WKWebViewConfiguration class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebViewConfiguration withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebViewConfiguration withIdentifier:0]; FWFWebViewConfigurationHostApiImpl *hostApi = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -62,8 +62,8 @@ - (void)testSetAllowsInlineMediaPlayback { - (void)testSetMediaTypesRequiringUserActionForPlayback { WKWebViewConfiguration *mockWebViewConfiguration = OCMClassMock([WKWebViewConfiguration class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebViewConfiguration withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebViewConfiguration withIdentifier:0]; FWFWebViewConfigurationHostApiImpl *hostApi = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m index 87960c07ee5e..87c98e2914dd 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m @@ -13,11 +13,11 @@ @interface FWFWebViewHostApiTests : XCTestCase @implementation FWFWebViewHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; + [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; [hostApi createWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -29,8 +29,8 @@ - (void)testCreateWithIdentifier { - (void)testLoadRequest { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -54,8 +54,8 @@ - (void)testLoadRequestWithInvalidUrl { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMReject([mockWebView loadRequest:OCMOCK_ANY]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -75,8 +75,8 @@ - (void)testLoadRequestWithInvalidUrl { - (void)testSetCustomUserAgent { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -91,8 +91,8 @@ - (void)testURL { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView URL]).andReturn([NSURL URLWithString:@"https://www.flutter.dev/"]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -107,8 +107,8 @@ - (void)testCanGoBack { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView canGoBack]).andReturn(YES); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -121,14 +121,14 @@ - (void)testCanGoBack { - (void)testSetUIDelegate { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; id mockDelegate = OCMProtocolMock(@protocol(WKUIDelegate)); - [instanceManager addInstance:mockDelegate withIdentifier:1]; + [instanceManager addFlutterCreatedInstance:mockDelegate withIdentifier:1]; FlutterError *error; [hostApi setUIDelegateForWebViewWithIdentifier:@0 delegateIdentifier:@1 error:&error]; @@ -139,14 +139,14 @@ - (void)testSetUIDelegate { - (void)testSetNavigationDelegate { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; id mockDelegate = OCMProtocolMock(@protocol(WKNavigationDelegate)); - [instanceManager addInstance:mockDelegate withIdentifier:1]; + [instanceManager addFlutterCreatedInstance:mockDelegate withIdentifier:1]; FlutterError *error; [hostApi setNavigationDelegateForWebViewWithIdentifier:@0 delegateIdentifier:@1 error:&error]; @@ -158,8 +158,8 @@ - (void)testEstimatedProgress { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView estimatedProgress]).andReturn(34.0); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -172,8 +172,8 @@ - (void)testEstimatedProgress { - (void)testloadHTMLString { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -190,8 +190,8 @@ - (void)testloadHTMLString { - (void)testLoadFileURL { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -211,8 +211,8 @@ - (void)testLoadFileURL { - (void)testLoadFlutterAsset { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFAssetManager *mockAssetManager = OCMClassMock([FWFAssetManager class]); OCMStub([mockAssetManager lookupKeyForAsset:@"assets/index.html"]) @@ -240,8 +240,8 @@ - (void)testCanGoForward { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView canGoForward]).andReturn(NO); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -254,8 +254,8 @@ - (void)testCanGoForward { - (void)testGoBack { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -269,8 +269,8 @@ - (void)testGoBack { - (void)testGoForward { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -284,8 +284,8 @@ - (void)testGoForward { - (void)testReload { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -300,8 +300,8 @@ - (void)testTitle { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView title]).andReturn(@"myTitle"); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -314,8 +314,8 @@ - (void)testTitle { - (void)testSetAllowsBackForwardNavigationGestures { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -333,8 +333,8 @@ - (void)testEvaluateJavaScript { evaluateJavaScript:@"runJavaScript" completionHandler:([OCMArg invokeBlockWithArgs:@"result", [NSNull null], nil])]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebView withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m index c754f78551b9..275355aec997 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m @@ -13,11 +13,11 @@ @interface FWFWebsiteDataStoreHostApiTests : XCTestCase @implementation FWFWebsiteDataStoreHostApiTests - (void)testCreateFromWebViewConfigurationWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; FWFWebsiteDataStoreHostApiImpl *hostApi = [[FWFWebsiteDataStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; + [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; [hostApi createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -27,7 +27,7 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { } - (void)testCreateDefaultDataStoreWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; FWFWebsiteDataStoreHostApiImpl *hostApi = [[FWFWebsiteDataStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -51,8 +51,8 @@ - (void)testRemoveDataOfTypes { modifiedSince:[NSDate dateWithTimeIntervalSince1970:45.0] completionHandler:([OCMArg invokeBlock])]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstance:mockWebsiteDataStore withIdentifier:0]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + [instanceManager addFlutterCreatedInstance:mockWebsiteDataStore withIdentifier:0]; FWFWebsiteDataStoreHostApiImpl *hostApi = [[FWFWebsiteDataStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m index 6ebd60a4ac40..248dabd5803b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m @@ -7,7 +7,7 @@ #import "FWFWebsiteDataStoreHostApi.h" @interface FWFHTTPCookieStoreHostApiImpl () -@property(nonatomic) FWFInstanceManager *instanceManager; +@property(nonatomic, weak) FWFInstanceManager *instanceManager; @end @implementation FWFHTTPCookieStoreHostApiImpl @@ -31,7 +31,7 @@ - (void)createFromWebsiteDataStoreWithIdentifier:(nonnull NSNumber *)instanceId if (@available(iOS 11.0, *)) { WKWebsiteDataStore *dataStore = (WKWebsiteDataStore *)[self.instanceManager instanceForIdentifier:websiteDataStoreInstanceId.longValue]; - [self.instanceManager addInstance:dataStore.httpCookieStore + [self.instanceManager addFlutterCreatedInstance:dataStore.httpCookieStore withIdentifier:instanceId.longValue]; } else { *error = [FlutterError diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index a4ff28442770..0aa855848301 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -11,7 +11,7 @@ @interface FWFFinalizer : NSObject // Callbacks are no longer made once FWFInstanceManager is inaccessible. @property (nonatomic, weak) FWFOnDeallocCallback callback; + (void)attachToInstance:(NSObject *)instance withIdentifier:(long)identifier callback:(FWFOnDeallocCallback)callback; -+ (void)detachInstance:(NSObject *)instance; ++ (void)detachFromInstance:(NSObject *)instance; @end @implementation FWFFinalizer @@ -29,7 +29,7 @@ + (void)attachToInstance:(NSObject *)instance withIdentifier:(long)identifier ca objc_setAssociatedObject(instance, _cmd, finalizer, OBJC_ASSOCIATION_RETAIN); } -+ (void)detachInstance:(NSObject *)instance { ++ (void)detachFromInstance:(NSObject *)instance { objc_setAssociatedObject(instance, @selector(attachToInstance:withIdentifier:callback:), nil, OBJC_ASSOCIATION_ASSIGN); } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h index cb7f08a7f220..34bf2ca7fa5c 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#import #import #import diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m index 2dc98e8003e7..cec821e3eae9 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m @@ -20,21 +20,19 @@ - (instancetype)initWithBinaryMessenger:(id)binaryMessen } - (long)identifierForNavigationDelegate:(FWFNavigationDelegate *)instance { - return [self.instanceManager identifierForInstance:instance]; + return [self.instanceManager identifierForInstance:instance identifierWillBePassedToFlutter:NO]; } - (void)didFinishNavigationForDelegate:(FWFNavigationDelegate *)instance webView:(WKWebView *)webView URL:(NSString *)URL { [self didFinishNavigationForDelegateWithIdentifier:@([self.instanceManager - identifierForInstance:instance]) + identifierForInstance:instance identifierWillBePassedToFlutter:YES]) webViewIdentifier:@([self.instanceManager - identifierForInstance:webView]) + identifierForInstance:webView identifierWillBePassedToFlutter:YES]) URL:URL completion:^(NSError *error) { - if (error) { - NSLog(@"%@", error.description); - } + NSAssert(!error, @"%@", error); }]; } @end @@ -83,6 +81,6 @@ - (void)createWithIdentifier:(nonnull NSNumber *)instanceId FWFNavigationDelegate *navigationDelegate = [[FWFNavigationDelegate alloc] initWithBinaryMessenger:self.binaryMessenger instanceManager:self.instanceManager]; - [self.instanceManager addInstance:navigationDelegate withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:navigationDelegate withIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m index 6065d382c646..10d4b7d8de66 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m @@ -76,6 +76,6 @@ - (void)removeObserverForObjectWithIdentifier:(nonnull NSNumber *)instanceId - (void)disposeObjectWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { - [self.instanceManager removeInstanceWithIdentifier:instanceId.longValue]; + [self.instanceManager removeStrongReferenceWithIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m index f907d211f08e..e0b52449f604 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m @@ -6,7 +6,7 @@ #import "FWFWebViewConfigurationHostApi.h" @interface FWFPreferencesHostApiImpl () -@property(nonatomic) FWFInstanceManager *instanceManager; +@property(nonatomic, weak) FWFInstanceManager *instanceManager; @end @implementation FWFPreferencesHostApiImpl @@ -25,7 +25,7 @@ - (WKPreferences *)preferencesForIdentifier:(NSNumber *)instanceId { - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { WKPreferences *preferences = [[WKPreferences alloc] init]; - [self.instanceManager addInstance:preferences withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:preferences withIdentifier:instanceId.longValue]; } - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanceId @@ -33,7 +33,7 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; - [self.instanceManager addInstance:configuration.preferences withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:configuration.preferences withIdentifier:instanceId.longValue]; } - (void)setJavaScriptEnabledForPreferencesWithIdentifier:(nonnull NSNumber *)instanceId diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m index 37662b5fc9f4..49a46b95229c 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m @@ -12,7 +12,7 @@ - (void)userContentController:(nonnull WKUserContentController *)userContentCont @end @interface FWFScriptMessageHandlerHostApiImpl () -@property(nonatomic) FWFInstanceManager *instanceManager; +@property(nonatomic, weak) FWFInstanceManager *instanceManager; @end @implementation FWFScriptMessageHandlerHostApiImpl @@ -32,6 +32,6 @@ - (FWFScriptMessageHandler *)scriptMessageHandlerForIdentifier:(NSNumber *)insta - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { FWFScriptMessageHandler *scriptMessageHandler = [[FWFScriptMessageHandler alloc] init]; - [self.instanceManager addInstance:scriptMessageHandler withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:scriptMessageHandler withIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m index a7522995e0e1..65a2efafebd1 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m @@ -6,7 +6,7 @@ #import "FWFWebViewHostApi.h" @interface FWFScrollViewHostApiImpl () -@property(nonatomic) FWFInstanceManager *instanceManager; +@property(nonatomic, weak) FWFInstanceManager *instanceManager; @end @implementation FWFScrollViewHostApiImpl @@ -27,7 +27,7 @@ - (void)createFromWebViewWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { WKWebView *webView = (WKWebView *)[self.instanceManager instanceForIdentifier:webViewInstanceId.longValue]; - [self.instanceManager addInstance:webView.scrollView withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:webView.scrollView withIdentifier:instanceId.longValue]; } - (NSArray *) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m index 2621c5dde287..bc738da57195 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m @@ -9,7 +9,7 @@ @implementation FWFUIDelegate @end @interface FWFUIDelegateHostApiImpl () -@property(nonatomic) FWFInstanceManager *instanceManager; +@property(nonatomic, weak) FWFInstanceManager *instanceManager; @end @implementation FWFUIDelegateHostApiImpl @@ -28,6 +28,6 @@ - (FWFUIDelegate *)delegateForIdentifier:(NSNumber *)instanceId { - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { FWFUIDelegate *uIDelegate = [[FWFUIDelegate alloc] init]; - [self.instanceManager addInstance:uIDelegate withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:uIDelegate withIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIViewHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIViewHostApi.m index b2c1f639d1f6..e2486d0cc16b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIViewHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIViewHostApi.m @@ -5,7 +5,7 @@ #import "FWFUIViewHostApi.h" @interface FWFUIViewHostApiImpl () -@property(nonatomic) FWFInstanceManager *instanceManager; +@property(nonatomic, weak) FWFInstanceManager *instanceManager; @end @implementation FWFUIViewHostApiImpl diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m index 2db7cff0b68e..5844c58d5b51 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m @@ -7,7 +7,7 @@ #import "FWFWebViewConfigurationHostApi.h" @interface FWFUserContentControllerHostApiImpl () -@property(nonatomic) FWFInstanceManager *instanceManager; +@property(nonatomic, weak) FWFInstanceManager *instanceManager; @end @implementation FWFUserContentControllerHostApiImpl @@ -29,7 +29,7 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; - [self.instanceManager addInstance:configuration.userContentController + [self.instanceManager addFlutterCreatedInstance:configuration.userContentController withIdentifier:instanceId.longValue]; } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m index 0b239daebf99..addd8e27aee9 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m @@ -7,7 +7,7 @@ #import "FWFWebViewConfigurationHostApi.h" @interface FWFWebViewConfigurationHostApiImpl () -@property(nonatomic) FWFInstanceManager *instanceManager; +@property(nonatomic, weak) FWFInstanceManager *instanceManager; @end @implementation FWFWebViewConfigurationHostApiImpl @@ -27,7 +27,7 @@ - (WKWebViewConfiguration *)webViewConfigurationForIdentifier:(NSNumber *)instan - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *webViewConfiguration = [[WKWebViewConfiguration alloc] init]; - [self.instanceManager addInstance:webViewConfiguration withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:webViewConfiguration withIdentifier:instanceId.longValue]; } - (void)createFromWebViewWithIdentifier:(nonnull NSNumber *)instanceId @@ -35,7 +35,7 @@ - (void)createFromWebViewWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { WKWebView *webView = (WKWebView *)[self.instanceManager instanceForIdentifier:webViewInstanceId.longValue]; - [self.instanceManager addInstance:webView.configuration withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:webView.configuration withIdentifier:instanceId.longValue]; } - (void)setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:(nonnull NSNumber *)instanceId diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m index 35677575dddb..f78527143855 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m @@ -78,7 +78,7 @@ - (void)createWithIdentifier:(nonnull NSNumber *)instanceId instanceForIdentifier:configurationInstanceId.longValue]; FWFWebView *webView = [[FWFWebView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) configuration:configuration]; - [self.instanceManager addInstance:webView withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:webView withIdentifier:instanceId.longValue]; } - (void)loadRequestForWebViewWithIdentifier:(nonnull NSNumber *)instanceId diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m index e052ae03543c..cfd548286f48 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m @@ -7,7 +7,7 @@ #import "FWFWebViewConfigurationHostApi.h" @interface FWFWebsiteDataStoreHostApiImpl () -@property(nonatomic) FWFInstanceManager *instanceManager; +@property(nonatomic, weak) FWFInstanceManager *instanceManager; @end @implementation FWFWebsiteDataStoreHostApiImpl @@ -28,14 +28,14 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; - [self.instanceManager addInstance:configuration.websiteDataStore + [self.instanceManager addFlutterCreatedInstance:configuration.websiteDataStore withIdentifier:instanceId.longValue]; } - (void)createDefaultDataStoreWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable __autoreleasing *_Nonnull) error { - [self.instanceManager addInstance:[WKWebsiteDataStore defaultDataStore] + [self.instanceManager addFlutterCreatedInstance:[WKWebsiteDataStore defaultDataStore] withIdentifier:instanceId.longValue]; } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart index 8a24aab994f5..a014c536654f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart @@ -235,9 +235,16 @@ class NSHttpCookie { /// The root class of most Objective-C class hierarchies. @immutable class NSObject with Copyable { - /// Constructs an [NSObject]. - NSObject({BinaryMessenger? binaryMessenger, InstanceManager? instanceManager}) - : _api = NSObjectHostApiImpl( + // TODO(bparrishMines): Change constructor name to `detached`. + /// Constructs a [NSObject] without creating the associated + /// Objective-C object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies. + NSObject({ + BinaryMessenger? binaryMessenger, + InstanceManager? instanceManager, + }) : _api = NSObjectHostApiImpl( binaryMessenger: binaryMessenger, instanceManager: instanceManager, ) { diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart index c15f4542f6b6..107ae85d1027 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart @@ -620,12 +620,12 @@ class WKNavigationDelegate extends NSObject { _navigationDelegateApi.createForInstances(this); } - // Constructs a WKNavigationDelegate with creating the associated Objective-C - // object. - // - // This should only be used by subclasses created by this library and for - // creating copies. - WKNavigationDelegate._implementation({ + /// Constructs a [WKNavigationDelegate] without creating the associated + /// Objective-C object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies. + WKNavigationDelegate.detached({ this.didFinishNavigation, BinaryMessenger? binaryMessenger, InstanceManager? instanceManager, @@ -688,7 +688,7 @@ class WKNavigationDelegate extends NSObject { @override Copyable copy() { - return WKNavigationDelegate._implementation( + return WKNavigationDelegate.detached( didFinishNavigation: didFinishNavigation, binaryMessenger: _navigationDelegateApi.binaryMessenger, instanceManager: _navigationDelegateApi.instanceManager, From 62581bad1b45de32b6f504fd6c61714c6bb1d250 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 19 May 2022 17:59:08 -0700 Subject: [PATCH 18/40] instance manager tests --- .../ios/RunnerTests/FWFInstanceManagerTests.m | 46 ++++++++----------- .../FWFNavigationDelegateHostApiTests.m | 19 -------- .../ios/Classes/FWFInstanceManager.m | 2 +- 3 files changed, 19 insertions(+), 48 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m index b32bb90791b5..983b03d5ea5a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m @@ -9,32 +9,22 @@ @interface FWFInstanceManagerTests : XCTestCase @end @implementation FWFInstanceManagerTests -//- (void)testAddInstance { -// FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; -// NSObject *object = [[NSObject alloc] init]; -// -// [instanceManager addInstance:object withIdentifier:5]; -// XCTAssertEqualObjects([instanceManager instanceForIdentifier:5], object); -// XCTAssertEqual([instanceManager identifierForInstance:object], 5); -//} -// -//- (void)testRemoveInstance { -// FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; -// NSObject *object = [[NSObject alloc] init]; -// [instanceManager addInstance:object withIdentifier:5]; -// -// [instanceManager removeInstance:object]; -// XCTAssertNil([instanceManager instanceForIdentifier:5]); -// XCTAssertEqual([instanceManager identifierForInstance:object], NSNotFound); -//} -// -//- (void)testRemoveInstanceWithIdentifier { -// FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; -// NSObject *object = [[NSObject alloc] init]; -// [instanceManager addInstance:object withIdentifier:5]; -// -// [instanceManager removeInstanceWithIdentifier:5]; -// XCTAssertNil([instanceManager instanceForIdentifier:5]); -// XCTAssertEqual([instanceManager identifierForInstance:object], NSNotFound); -//} +- (void)testAddFlutterCreatedInstance { + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + NSObject *object = [[NSObject alloc] init]; + + [instanceManager addFlutterCreatedInstance:object withIdentifier:0]; + XCTAssertEqualObjects([instanceManager instanceForIdentifier:0], object); + XCTAssertEqual([instanceManager identifierForInstance:object identifierWillBePassedToFlutter:NO], 0); +} + +- (void)testAddHostIdentifier { + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + NSObject *object = [[NSObject alloc] init]; + [instanceManager addHostCreatedInstance:object]; + + long identifier = [instanceManager identifierForInstance:object identifierWillBePassedToFlutter:NO]; + XCTAssertNotEqual(identifier, NSNotFound); + XCTAssertEqualObjects([instanceManager instanceForIdentifier:identifier], object); +} @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m index 8e1af5b40726..99dbf53666a0 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m @@ -81,23 +81,4 @@ - (void)testDidFinishNavigation { URL:@"https://flutter.dev/" completion:OCMOCK_ANY]); } - -- (void)testInstanceCanBeReleasedWhenInstanceManagerIsReleased { - FWFTestMessenger *testMessenger = [[FWFTestMessenger alloc] init]; - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; - FWFNavigationDelegateHostApiImpl *hostAPI = - [[FWFNavigationDelegateHostApiImpl alloc] initWithBinaryMessenger:testMessenger - instanceManager:instanceManager]; - - testMessenger.hostAPI = hostAPI; - - FlutterError *error; - [hostAPI createWithIdentifier:@0 error:&error]; - FWFNavigationDelegate __weak *navigationDelegate = - (FWFNavigationDelegate *)[instanceManager instanceForIdentifier:0]; - - XCTAssertNotNil(navigationDelegate); - instanceManager = nil; - XCTAssertNil(navigationDelegate); -} @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index 0aa855848301..180304eb3a92 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -76,7 +76,7 @@ - (long)addHostCreatedInstance:(nonnull NSObject *)instance { // created simultaneously by the Flutter. // Value must be >= 2^16. identifier = arc4random_uniform(65536) + 65536; - } while ([self.weakInstances objectForKey:@(identifier)] || [self.strongInstances objectForKey:@(identifier)]); + } while ([self.weakInstances objectForKey:@(identifier)]); [self addInstance:instance withIdentifier:identifier]; }); return identifier; From f0d2498550e01610a8236541b89230f19f74c706 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 19 May 2022 18:22:04 -0700 Subject: [PATCH 19/40] formatting and one last test --- .../FWFHTTPCookieStoreHostApiTests.m | 8 +- .../ios/RunnerTests/FWFInstanceManagerTests.m | 26 +++++- .../FWFNavigationDelegateHostApiTests.m | 8 +- .../ios/RunnerTests/FWFObjectHostApiTests.m | 18 +++-- .../RunnerTests/FWFPreferencesHostApiTests.m | 11 ++- .../FWFScriptMessageHandlerHostApiTests.m | 4 +- .../RunnerTests/FWFScrollViewHostApiTests.m | 12 ++- .../RunnerTests/FWFUIDelegateHostApiTests.m | 4 +- .../ios/RunnerTests/FWFUIViewHostApiTests.m | 8 +- .../FWFUserContentControllerHostApiTests.m | 27 +++++-- .../FWFWebViewConfigurationHostApiTests.m | 16 +++- .../ios/RunnerTests/FWFWebViewHostApiTests.m | 79 ++++++++++++++----- .../FWFWebsiteDataStoreHostApiTests.m | 15 +++- .../ios/Classes/FWFHTTPCookieStoreHostApi.m | 2 +- .../ios/Classes/FWFInstanceManager.h | 37 ++++++--- .../ios/Classes/FWFInstanceManager.m | 46 ++++++++--- .../Classes/FWFNavigationDelegateHostApi.h | 2 +- .../Classes/FWFNavigationDelegateHostApi.m | 11 ++- .../ios/Classes/FWFPreferencesHostApi.m | 3 +- .../Classes/FWFScriptMessageHandlerHostApi.m | 3 +- .../ios/Classes/FWFScrollViewHostApi.m | 3 +- .../Classes/FWFUserContentControllerHostApi.m | 2 +- .../Classes/FWFWebViewConfigurationHostApi.m | 6 +- .../ios/Classes/FWFWebsiteDataStoreHostApi.m | 4 +- 24 files changed, 263 insertions(+), 92 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m index 05e348c53155..85a88f2ead00 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m @@ -13,7 +13,9 @@ @interface FWFHTTPCookieStoreHostApiTests : XCTestCase @implementation FWFHTTPCookieStoreHostApiTests - (void)testCreateFromWebsiteDataStoreWithIdentifier API_AVAILABLE(ios(11.0)) { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; FWFHTTPCookieStoreHostApiImpl *hostApi = [[FWFHTTPCookieStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -31,7 +33,9 @@ - (void)testCreateFromWebsiteDataStoreWithIdentifier API_AVAILABLE(ios(11.0)) { - (void)testSetCookie API_AVAILABLE(ios(11.0)) { WKHTTPCookieStore *mockHttpCookieStore = OCMClassMock([WKHTTPCookieStore class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockHttpCookieStore withIdentifier:0]; FWFHTTPCookieStoreHostApiImpl *hostApi = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m index 983b03d5ea5a..7854b0b2ea82 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m @@ -10,21 +10,39 @@ @interface FWFInstanceManagerTests : XCTestCase @implementation FWFInstanceManagerTests - (void)testAddFlutterCreatedInstance { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; NSObject *object = [[NSObject alloc] init]; [instanceManager addFlutterCreatedInstance:object withIdentifier:0]; XCTAssertEqualObjects([instanceManager instanceForIdentifier:0], object); - XCTAssertEqual([instanceManager identifierForInstance:object identifierWillBePassedToFlutter:NO], 0); + XCTAssertEqual([instanceManager identifierForInstance:object identifierWillBePassedToFlutter:NO], + 0); } - (void)testAddHostIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; NSObject *object = [[NSObject alloc] init]; [instanceManager addHostCreatedInstance:object]; - long identifier = [instanceManager identifierForInstance:object identifierWillBePassedToFlutter:NO]; + long identifier = [instanceManager identifierForInstance:object + identifierWillBePassedToFlutter:NO]; XCTAssertNotEqual(identifier, NSNotFound); XCTAssertEqualObjects([instanceManager instanceForIdentifier:identifier], object); } + +- (void)testRemoveStrongReferenceWithIdentifier { + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; + NSObject *object = [[NSObject alloc] init]; + + [instanceManager addFlutterCreatedInstance:object withIdentifier:0]; + + XCTAssertEqualObjects([instanceManager removeStrongReferenceWithIdentifier:0], object); + XCTAssertEqual([instanceManager strongInstanceCount], 0); +} @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m index 99dbf53666a0..741f100c7d08 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m @@ -38,7 +38,9 @@ @interface FWFNavigationDelegateHostApiTests : XCTestCase @implementation FWFNavigationDelegateHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; FWFNavigationDelegateHostApiImpl *hostAPI = [[FWFNavigationDelegateHostApiImpl alloc] initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) instanceManager:instanceManager]; @@ -53,7 +55,9 @@ - (void)testCreateWithIdentifier { } - (void)testDidFinishNavigation { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; FWFNavigationDelegateHostApiImpl *hostAPI = [[FWFNavigationDelegateHostApiImpl alloc] initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) instanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m index d82a82db3286..ddf950591633 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m @@ -15,7 +15,9 @@ @implementation FWFObjectHostApiTests - (void)testAddObserver { NSObject *mockObject = OCMClassMock([NSObject class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockObject withIdentifier:0]; FWFObjectHostApiImpl *hostApi = @@ -47,7 +49,9 @@ - (void)testAddObserver { - (void)testRemoveObserver { NSObject *mockObject = OCMClassMock([NSObject class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockObject withIdentifier:0]; FWFObjectHostApiImpl *hostApi = @@ -68,7 +72,9 @@ - (void)testRemoveObserver { - (void)testDispose { NSObject *object = [[NSObject alloc] init]; - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:object withIdentifier:0]; FWFObjectHostApiImpl *hostApi = @@ -76,9 +82,11 @@ - (void)testDispose { FlutterError *error; [hostApi disposeObjectWithIdentifier:@0 error:&error]; - // Only the strong reference is removed, so the weak reference will remain until object is set to nil. + // Only the strong reference is removed, so the weak reference will remain until object is set to + // nil. object = nil; - XCTAssertEqual([instanceManager identifierForInstance:object identifierWillBePassedToFlutter:NO], NSNotFound); + XCTAssertEqual([instanceManager identifierForInstance:object identifierWillBePassedToFlutter:NO], + NSNotFound); XCTAssertNil(error); } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m index 9733c3d74cff..5bc5185946d2 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m @@ -13,11 +13,14 @@ @interface FWFPreferencesHostApiTests : XCTestCase @implementation FWFPreferencesHostApiTests - (void)testCreateFromWebViewConfigurationWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; FWFPreferencesHostApiImpl *hostApi = [[FWFPreferencesHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; + [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] + withIdentifier:0]; FlutterError *error; [hostApi createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -29,7 +32,9 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { - (void)testSetJavaScriptEnabled { WKPreferences *mockPreferences = OCMClassMock([WKPreferences class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockPreferences withIdentifier:0]; FWFPreferencesHostApiImpl *hostApi = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m index 0a29b448f5e5..2fb840a8afdb 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m @@ -13,7 +13,9 @@ @interface FWFScriptMessageHandlerHostApiTests : XCTestCase @implementation FWFScriptMessageHandlerHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; FWFScriptMessageHandlerHostApiImpl *hostApi = [[FWFScriptMessageHandlerHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m index 4c532ef13ac7..a4b8ddc8de3d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m @@ -16,7 +16,9 @@ - (void)testGetContentOffset { UIScrollView *mockScrollView = OCMClassMock([UIScrollView class]); OCMStub([mockScrollView contentOffset]).andReturn(CGPointMake(1.0, 2.0)); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockScrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostApi = @@ -33,7 +35,9 @@ - (void)testScrollBy { UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; scrollView.contentOffset = CGPointMake(1, 2); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:scrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostApi = @@ -49,7 +53,9 @@ - (void)testScrollBy { - (void)testSetContentOffset { UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:scrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostApi = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m index c923b6915349..a64a0f632633 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m @@ -13,7 +13,9 @@ @interface FWFUIDelegateHostApiTests : XCTestCase @implementation FWFUIDelegateHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; FWFUIDelegateHostApiImpl *hostApi = [[FWFUIDelegateHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m index ad8464f1ba13..8c43fa9c61de 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m @@ -15,7 +15,9 @@ @implementation FWFUIViewHostApiTests - (void)testSetBackgroundColor { UIView *mockUIView = OCMClassMock([UIView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockUIView withIdentifier:0]; FWFUIViewHostApiImpl *hostApi = @@ -34,7 +36,9 @@ - (void)testSetBackgroundColor { - (void)testSetOpaque { UIView *mockUIView = OCMClassMock([UIView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockUIView withIdentifier:0]; FWFUIViewHostApiImpl *hostApi = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m index ac853bf3d1dc..4231b1071a4e 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m @@ -13,11 +13,14 @@ @interface FWFUserContentControllerHostApiTests : XCTestCase @implementation FWFUserContentControllerHostApiTests - (void)testCreateFromWebViewConfigurationWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; FWFUserContentControllerHostApiImpl *hostApi = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; + [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] + withIdentifier:0]; FlutterError *error; [hostApi createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -31,7 +34,9 @@ - (void)testAddScriptMessageHandler { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostApi = @@ -54,7 +59,9 @@ - (void)testRemoveScriptMessageHandler { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostApi = @@ -70,7 +77,9 @@ - (void)testRemoveAllScriptMessageHandlers API_AVAILABLE(ios(14.0)) { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostApi = @@ -86,7 +95,9 @@ - (void)testAddUserScript { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostApi = @@ -113,7 +124,9 @@ - (void)testRemoveAllUserScripts { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostApi = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m index c21c862ca27c..6ac7ce5e6067 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m @@ -13,7 +13,9 @@ @interface FWFWebViewConfigurationHostApiTests : XCTestCase @implementation FWFWebViewConfigurationHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; FWFWebViewConfigurationHostApiImpl *hostApi = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -26,7 +28,9 @@ - (void)testCreateWithIdentifier { } - (void)testCreateFromWebViewWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; FWFWebViewConfigurationHostApiImpl *hostApi = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -45,7 +49,9 @@ - (void)testCreateFromWebViewWithIdentifier { - (void)testSetAllowsInlineMediaPlayback { WKWebViewConfiguration *mockWebViewConfiguration = OCMClassMock([WKWebViewConfiguration class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebViewConfiguration withIdentifier:0]; FWFWebViewConfigurationHostApiImpl *hostApi = @@ -62,7 +68,9 @@ - (void)testSetAllowsInlineMediaPlayback { - (void)testSetMediaTypesRequiringUserActionForPlayback { WKWebViewConfiguration *mockWebViewConfiguration = OCMClassMock([WKWebViewConfiguration class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebViewConfiguration withIdentifier:0]; FWFWebViewConfigurationHostApiImpl *hostApi = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m index 87c98e2914dd..8bbfb8c367f2 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m @@ -13,11 +13,14 @@ @interface FWFWebViewHostApiTests : XCTestCase @implementation FWFWebViewHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; FWFWebViewHostApiImpl *hostApi = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; + [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] + withIdentifier:0]; FlutterError *error; [hostApi createWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -29,7 +32,9 @@ - (void)testCreateWithIdentifier { - (void)testLoadRequest { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -54,7 +59,9 @@ - (void)testLoadRequestWithInvalidUrl { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMReject([mockWebView loadRequest:OCMOCK_ANY]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -75,7 +82,9 @@ - (void)testLoadRequestWithInvalidUrl { - (void)testSetCustomUserAgent { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -91,7 +100,9 @@ - (void)testURL { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView URL]).andReturn([NSURL URLWithString:@"https://www.flutter.dev/"]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -107,7 +118,9 @@ - (void)testCanGoBack { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView canGoBack]).andReturn(YES); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -121,7 +134,9 @@ - (void)testCanGoBack { - (void)testSetUIDelegate { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -139,7 +154,9 @@ - (void)testSetUIDelegate { - (void)testSetNavigationDelegate { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -158,7 +175,9 @@ - (void)testEstimatedProgress { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView estimatedProgress]).andReturn(34.0); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -172,7 +191,9 @@ - (void)testEstimatedProgress { - (void)testloadHTMLString { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -190,7 +211,9 @@ - (void)testloadHTMLString { - (void)testLoadFileURL { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -211,7 +234,9 @@ - (void)testLoadFileURL { - (void)testLoadFlutterAsset { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFAssetManager *mockAssetManager = OCMClassMock([FWFAssetManager class]); @@ -240,7 +265,9 @@ - (void)testCanGoForward { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView canGoForward]).andReturn(NO); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -254,7 +281,9 @@ - (void)testCanGoForward { - (void)testGoBack { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -269,7 +298,9 @@ - (void)testGoBack { - (void)testGoForward { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -284,7 +315,9 @@ - (void)testGoForward { - (void)testReload { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -300,7 +333,9 @@ - (void)testTitle { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView title]).andReturn(@"myTitle"); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -314,7 +349,9 @@ - (void)testTitle { - (void)testSetAllowsBackForwardNavigationGestures { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = @@ -333,7 +370,9 @@ - (void)testEvaluateJavaScript { evaluateJavaScript:@"runJavaScript" completionHandler:([OCMArg invokeBlockWithArgs:@"result", [NSNull null], nil])]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostApi = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m index 275355aec997..add2dc96d041 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m @@ -13,11 +13,14 @@ @interface FWFWebsiteDataStoreHostApiTests : XCTestCase @implementation FWFWebsiteDataStoreHostApiTests - (void)testCreateFromWebViewConfigurationWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; FWFWebsiteDataStoreHostApiImpl *hostApi = [[FWFWebsiteDataStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; + [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] + withIdentifier:0]; FlutterError *error; [hostApi createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -27,7 +30,9 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { } - (void)testCreateDefaultDataStoreWithIdentifier { - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; FWFWebsiteDataStoreHostApiImpl *hostApi = [[FWFWebsiteDataStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -51,7 +56,9 @@ - (void)testRemoveDataOfTypes { modifiedSince:[NSDate dateWithTimeIntervalSince1970:45.0] completionHandler:([OCMArg invokeBlock])]); - FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier) {}]; + FWFInstanceManager *instanceManager = + [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ + }]; [instanceManager addFlutterCreatedInstance:mockWebsiteDataStore withIdentifier:0]; FWFWebsiteDataStoreHostApiImpl *hostApi = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m index 248dabd5803b..6e1a34facdd4 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m @@ -32,7 +32,7 @@ - (void)createFromWebsiteDataStoreWithIdentifier:(nonnull NSNumber *)instanceId WKWebsiteDataStore *dataStore = (WKWebsiteDataStore *)[self.instanceManager instanceForIdentifier:websiteDataStoreInstanceId.longValue]; [self.instanceManager addFlutterCreatedInstance:dataStore.httpCookieStore - withIdentifier:instanceId.longValue]; + withIdentifier:instanceId.longValue]; } else { *error = [FlutterError errorWithCode:@"FWFUnsupportedVersionError" diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h index 4b87d3c22eb1..2db746752cf3 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h @@ -6,7 +6,7 @@ NS_ASSUME_NONNULL_BEGIN -typedef void (^FWFOnDeallocCallback) (long identifier); +typedef void (^FWFOnDeallocCallback)(long identifier); /** * Maintains instances used to communicate with the Dart objects that represent them in Flutter. @@ -17,14 +17,14 @@ typedef void (^FWFOnDeallocCallback) (long identifier); * is removed with `removeStrongReferenceWithIdentifier:` and the weak reference is deallocated, * the `deallocCallback` is made with the instance's identifier. However, if the strong reference is * removed and then the identifier is retrieved with the intention to pass the identifier to Dart - * (e.g. calling `identifierForInstance:identifierWillBePassedToFlutter:` with `identifierWillBePassedToFlutter` - * set to YES), the strong reference to the instance is recreated. The strong reference will then need to be - * removed manually again. + * (e.g. calling `identifierForInstance:identifierWillBePassedToFlutter:` with + * `identifierWillBePassedToFlutter` set to YES), the strong reference to the instance is recreated. + * The strong reference will then need to be removed manually again. * * Accessing and inserting to an InstanceManager is thread safe. */ @interface FWFInstanceManager : NSObject -@property (readonly) FWFOnDeallocCallback deallocCallback; +@property(readonly) FWFOnDeallocCallback deallocCallback; - (instancetype)initWithDeallocCallback:(FWFOnDeallocCallback)callback; // TODO(bparrishMines): Pairs should not be able to be overwritten and this feature // should be replaced with a call to clear the manager in the event of a hot restart. @@ -49,7 +49,8 @@ typedef void (^FWFOnDeallocCallback) (long identifier); - (long)addHostCreatedInstance:(nonnull NSObject *)instance; /** - * Removes `instanceIdentifier` and its associated strongly referenced instance, if present, from the manager. + * Removes `instanceIdentifier` and its associated strongly referenced instance, if present, from + * the manager. * * @param instanceIdentifier The identifier paired to an instance. * @@ -74,11 +75,29 @@ typedef void (^FWFOnDeallocCallback) (long identifier); * * @param instance An instance that may be stored in the manager. * @param willBePassed Whether the identifier will be passed to Dart. If YES, the strong reference - * to `instance` will be recreated and will need to be removed again by `removeStrongReferenceWithIdentifier:`. + * to `instance` will be recreated and will need to be removed again by + * `removeStrongReferenceWithIdentifier:`. * - * @return The identifer associated with `instance` if the manager contains the value, otherwise NSNotFound. + * @return The identifer associated with `instance` if the manager contains the value, otherwise + * NSNotFound. */ -- (long)identifierForInstance:(nonnull NSObject *)instance identifierWillBePassedToFlutter:(BOOL)willBePassed; +- (long)identifierForInstance:(nonnull NSObject *)instance + identifierWillBePassedToFlutter:(BOOL)willBePassed; + +/** + * The number of instances stored as a strong reference. + * + * Added for debuggingpurposes. + */ +- (NSUInteger)strongInstanceCount; + +/** + * The number of instances stored as a weak reference. + * + * Added for debugging purposes. NSMapTables that store keys or objects as weak reference will be + * reclaimed nondeterministically. + */ +- (NSUInteger)weakInstanceCount; @end NS_ASSUME_NONNULL_END diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index 180304eb3a92..893323d0be24 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -7,15 +7,17 @@ // Attach to an object to track when an object is deallocated. @interface FWFFinalizer : NSObject -@property (nonatomic) long identifier; +@property(nonatomic) long identifier; // Callbacks are no longer made once FWFInstanceManager is inaccessible. -@property (nonatomic, weak) FWFOnDeallocCallback callback; -+ (void)attachToInstance:(NSObject *)instance withIdentifier:(long)identifier callback:(FWFOnDeallocCallback)callback; +@property(nonatomic, weak) FWFOnDeallocCallback callback; ++ (void)attachToInstance:(NSObject *)instance + withIdentifier:(long)identifier + callback:(FWFOnDeallocCallback)callback; + (void)detachFromInstance:(NSObject *)instance; @end @implementation FWFFinalizer --(instancetype)initWithIdentifier:(long)identifier callback:(FWFOnDeallocCallback)callback { +- (instancetype)initWithIdentifier:(long)identifier callback:(FWFOnDeallocCallback)callback { self = [self init]; if (self) { _identifier = identifier; @@ -24,16 +26,19 @@ -(instancetype)initWithIdentifier:(long)identifier callback:(FWFOnDeallocCallbac return self; } -+ (void)attachToInstance:(NSObject *)instance withIdentifier:(long)identifier callback:(FWFOnDeallocCallback)callback { ++ (void)attachToInstance:(NSObject *)instance + withIdentifier:(long)identifier + callback:(FWFOnDeallocCallback)callback { FWFFinalizer *finalizer = [[FWFFinalizer alloc] initWithIdentifier:identifier callback:callback]; objc_setAssociatedObject(instance, _cmd, finalizer, OBJC_ASSOCIATION_RETAIN); } + (void)detachFromInstance:(NSObject *)instance { - objc_setAssociatedObject(instance, @selector(attachToInstance:withIdentifier:callback:), nil, OBJC_ASSOCIATION_ASSIGN); + objc_setAssociatedObject(instance, @selector(attachToInstance:withIdentifier:callback:), nil, + OBJC_ASSOCIATION_ASSIGN); } --(void) dealloc { +- (void)dealloc { self.callback(self.identifier); } @end @@ -62,13 +67,13 @@ - (void)addFlutterCreatedInstance:(NSObject *)instance withIdentifier:(long)inst NSParameterAssert(instance); NSParameterAssert(instanceIdentifier >= 0); dispatch_async(_lockQueue, ^{ - [self addInstance:instance withIdentifier:instanceIdentifier]; + [self addInstance:instance withIdentifier:instanceIdentifier]; }); } - (long)addHostCreatedInstance:(nonnull NSObject *)instance { NSParameterAssert(instance); - long identifier = NSNotFound; + long identifier = -1; dispatch_sync(_lockQueue, ^{ long identifier; do { @@ -101,7 +106,8 @@ - (nullable NSObject *)instanceForIdentifier:(long)instanceIdentifier { return instance; } -- (long)identifierForInstance:(nonnull NSObject *)instance identifierWillBePassedToFlutter:(BOOL)willBePassed { +- (long)identifierForInstance:(nonnull NSObject *)instance + identifierWillBePassedToFlutter:(BOOL)willBePassed { NSNumber *__block identifierNumber = nil; dispatch_sync(_lockQueue, ^{ identifierNumber = [self.identifiers objectForKey:instance]; @@ -116,6 +122,24 @@ - (void)addInstance:(nonnull NSObject *)instance withIdentifier:(long)instanceId [self.identifiers setObject:@(instanceIdentifier) forKey:instance]; [self.weakInstances setObject:instance forKey:@(instanceIdentifier)]; [self.strongInstances setObject:instance forKey:@(instanceIdentifier)]; - [FWFFinalizer attachToInstance:instance withIdentifier:instanceIdentifier callback:self.deallocCallback]; + [FWFFinalizer attachToInstance:instance + withIdentifier:instanceIdentifier + callback:self.deallocCallback]; +} + +- (NSUInteger)strongInstanceCount { + NSUInteger __block count = -1; + dispatch_sync(_lockQueue, ^{ + count = self.strongInstances.count; + }); + return count; +} + +- (NSUInteger)weakInstanceCount { + NSUInteger __block count = -1; + dispatch_sync(_lockQueue, ^{ + count = self.weakInstances.count; + }); + return count; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h index 34bf2ca7fa5c..08865b632834 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import #import +#import #import #import "FWFGeneratedWebKitApis.h" diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m index cec821e3eae9..4afe8abcffbd 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m @@ -27,12 +27,14 @@ - (void)didFinishNavigationForDelegate:(FWFNavigationDelegate *)instance webView:(WKWebView *)webView URL:(NSString *)URL { [self didFinishNavigationForDelegateWithIdentifier:@([self.instanceManager - identifierForInstance:instance identifierWillBePassedToFlutter:YES]) + identifierForInstance:instance + identifierWillBePassedToFlutter:YES]) webViewIdentifier:@([self.instanceManager - identifierForInstance:webView identifierWillBePassedToFlutter:YES]) + identifierForInstance:webView + identifierWillBePassedToFlutter:YES]) URL:URL completion:^(NSError *error) { - NSAssert(!error, @"%@", error); + NSAssert(!error, @"%@", error); }]; } @end @@ -81,6 +83,7 @@ - (void)createWithIdentifier:(nonnull NSNumber *)instanceId FWFNavigationDelegate *navigationDelegate = [[FWFNavigationDelegate alloc] initWithBinaryMessenger:self.binaryMessenger instanceManager:self.instanceManager]; - [self.instanceManager addFlutterCreatedInstance:navigationDelegate withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:navigationDelegate + withIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m index e0b52449f604..b209acf15f0b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m @@ -33,7 +33,8 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; - [self.instanceManager addFlutterCreatedInstance:configuration.preferences withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:configuration.preferences + withIdentifier:instanceId.longValue]; } - (void)setJavaScriptEnabledForPreferencesWithIdentifier:(nonnull NSNumber *)instanceId diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m index 49a46b95229c..d9ea7cce512a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m @@ -32,6 +32,7 @@ - (FWFScriptMessageHandler *)scriptMessageHandlerForIdentifier:(NSNumber *)insta - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { FWFScriptMessageHandler *scriptMessageHandler = [[FWFScriptMessageHandler alloc] init]; - [self.instanceManager addFlutterCreatedInstance:scriptMessageHandler withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:scriptMessageHandler + withIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m index 65a2efafebd1..3d5b5df2fa9e 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m @@ -27,7 +27,8 @@ - (void)createFromWebViewWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { WKWebView *webView = (WKWebView *)[self.instanceManager instanceForIdentifier:webViewInstanceId.longValue]; - [self.instanceManager addFlutterCreatedInstance:webView.scrollView withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:webView.scrollView + withIdentifier:instanceId.longValue]; } - (NSArray *) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m index 5844c58d5b51..74c03aa8b898 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m @@ -30,7 +30,7 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; [self.instanceManager addFlutterCreatedInstance:configuration.userContentController - withIdentifier:instanceId.longValue]; + withIdentifier:instanceId.longValue]; } - (void)addScriptMessageHandlerForControllerWithIdentifier:(nonnull NSNumber *)instanceId diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m index addd8e27aee9..aa753b0769da 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m @@ -27,7 +27,8 @@ - (WKWebViewConfiguration *)webViewConfigurationForIdentifier:(NSNumber *)instan - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *webViewConfiguration = [[WKWebViewConfiguration alloc] init]; - [self.instanceManager addFlutterCreatedInstance:webViewConfiguration withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:webViewConfiguration + withIdentifier:instanceId.longValue]; } - (void)createFromWebViewWithIdentifier:(nonnull NSNumber *)instanceId @@ -35,7 +36,8 @@ - (void)createFromWebViewWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { WKWebView *webView = (WKWebView *)[self.instanceManager instanceForIdentifier:webViewInstanceId.longValue]; - [self.instanceManager addFlutterCreatedInstance:webView.configuration withIdentifier:instanceId.longValue]; + [self.instanceManager addFlutterCreatedInstance:webView.configuration + withIdentifier:instanceId.longValue]; } - (void)setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:(nonnull NSNumber *)instanceId diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m index cfd548286f48..ffcab64d92ff 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m @@ -29,14 +29,14 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; [self.instanceManager addFlutterCreatedInstance:configuration.websiteDataStore - withIdentifier:instanceId.longValue]; + withIdentifier:instanceId.longValue]; } - (void)createDefaultDataStoreWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable __autoreleasing *_Nonnull) error { [self.instanceManager addFlutterCreatedInstance:[WKWebsiteDataStore defaultDataStore] - withIdentifier:instanceId.longValue]; + withIdentifier:instanceId.longValue]; } - (void) From 4bd6d2affff35fb43aaa1bad26acbf0c6bd986f5 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 19 May 2022 18:39:29 -0700 Subject: [PATCH 20/40] formatting --- .../FWFNavigationDelegateHostApiTests.m | 25 ------------------- .../ios/Classes/FWFInstanceManager.h | 1 - .../ios/Classes/FWFInstanceManager.m | 2 +- .../lib/src/common/instance_manager.dart | 2 +- .../lib/src/web_kit/web_kit.dart | 4 +-- 5 files changed, 4 insertions(+), 30 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m index 741f100c7d08..b98d6acac7be 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m @@ -8,31 +8,6 @@ #import -// Used to test that a FlutterBinaryMessenger with a strong reference to a host api won't -// lead to a circular reference. -@interface FWFTestMessenger : NSObject -@property(strong, nullable) id hostAPI; -@end - -@implementation FWFTestMessenger -- (void)cleanUpConnection:(FlutterBinaryMessengerConnection)connection { -} - -- (void)sendOnChannel:(nonnull NSString *)channel message:(NSData *_Nullable)message { -} - -- (void)sendOnChannel:(nonnull NSString *)channel - message:(NSData *_Nullable)message - binaryReply:(FlutterBinaryReply _Nullable)callback { -} - -- (FlutterBinaryMessengerConnection)setMessageHandlerOnChannel:(nonnull NSString *)channel - binaryMessageHandler: - (FlutterBinaryMessageHandler _Nullable)handler { - return 0; -} -@end - @interface FWFNavigationDelegateHostApiTests : XCTestCase @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h index 2db746752cf3..b8b04104ae94 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h @@ -72,7 +72,6 @@ typedef void (^FWFOnDeallocCallback)(long identifier); /** * Retrieves the identifier paired with an instance. * - * * @param instance An instance that may be stored in the manager. * @param willBePassed Whether the identifier will be passed to Dart. If YES, the strong reference * to `instance` will be recreated and will need to be removed again by diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index 893323d0be24..ca7a0de7730e 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -5,7 +5,7 @@ #import "FWFInstanceManager.h" #import -// Attach to an object to track when an object is deallocated. +// Attaches to an object to receive a callback when the object is deallocated. @interface FWFFinalizer : NSObject @property(nonatomic) long identifier; // Callbacks are no longer made once FWFInstanceManager is inaccessible. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index ecc9bc7fdea7..7ec2ac153028 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -89,7 +89,7 @@ class InstanceManager { /// Returns the identifier associated with the removed instance. Otherwise, /// `null` if the instance was not found in this manager. /// - /// This does not remove the the strong referenced instance associtated with + /// This does not remove the the strong referenced instance associated with /// [instance]. This can be done with [removeStrongReference]. int? removeWeakReference(Copyable instance) { final int? identifier = getIdentifier(instance); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart index 107ae85d1027..9e143e8df95e 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart @@ -623,8 +623,8 @@ class WKNavigationDelegate extends NSObject { /// Constructs a [WKNavigationDelegate] without creating the associated /// Objective-C object. /// - /// This should only be used by subclasses created by this library or to - /// create copies. + /// This should only be used by subclasses created by this library or by an + /// InstanceManager creating copies. WKNavigationDelegate.detached({ this.didFinishNavigation, BinaryMessenger? binaryMessenger, From 7974d56d95e4b9fb28f25b83d79d785d9131a521 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 19 May 2022 19:37:01 -0700 Subject: [PATCH 21/40] naming --- .../FWFHTTPCookieStoreHostApiTests.m | 8 +- .../FWFNavigationDelegateHostApiTests.m | 4 +- .../ios/RunnerTests/FWFObjectHostApiTests.m | 12 +-- .../RunnerTests/FWFPreferencesHostApiTests.m | 8 +- .../FWFScriptMessageHandlerHostApiTests.m | 4 +- .../RunnerTests/FWFScrollViewHostApiTests.m | 12 +-- .../RunnerTests/FWFUIDelegateHostApiTests.m | 4 +- .../ios/RunnerTests/FWFUIViewHostApiTests.m | 8 +- .../FWFUserContentControllerHostApiTests.m | 24 +++--- .../FWFWebViewConfigurationHostApiTests.m | 16 ++-- .../ios/RunnerTests/FWFWebViewHostApiTests.m | 76 +++++++++---------- .../FWFWebsiteDataStoreHostApiTests.m | 12 +-- 12 files changed, 94 insertions(+), 94 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m index 85a88f2ead00..cfdf8e9dd3b0 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m @@ -16,7 +16,7 @@ - (void)testCreateFromWebsiteDataStoreWithIdentifier API_AVAILABLE(ios(11.0)) { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - FWFHTTPCookieStoreHostApiImpl *hostApi = + FWFHTTPCookieStoreHostApiImpl *hostAPI = [[FWFHTTPCookieStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; WKWebsiteDataStore *mockDataStore = OCMClassMock([WKWebsiteDataStore class]); @@ -24,7 +24,7 @@ - (void)testCreateFromWebsiteDataStoreWithIdentifier API_AVAILABLE(ios(11.0)) { [instanceManager addFlutterCreatedInstance:mockDataStore withIdentifier:0]; FlutterError *error; - [hostApi createFromWebsiteDataStoreWithIdentifier:@1 dataStoreIdentifier:@0 error:&error]; + [hostAPI createFromWebsiteDataStoreWithIdentifier:@1 dataStoreIdentifier:@0 error:&error]; WKHTTPCookieStore *cookieStore = (WKHTTPCookieStore *)[instanceManager instanceForIdentifier:1]; XCTAssertTrue([cookieStore isKindOfClass:[WKHTTPCookieStore class]]); XCTAssertNil(error); @@ -38,7 +38,7 @@ - (void)testSetCookie API_AVAILABLE(ios(11.0)) { }]; [instanceManager addFlutterCreatedInstance:mockHttpCookieStore withIdentifier:0]; - FWFHTTPCookieStoreHostApiImpl *hostApi = + FWFHTTPCookieStoreHostApiImpl *hostAPI = [[FWFHTTPCookieStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; FWFNSHttpCookieData *cookieData = [FWFNSHttpCookieData @@ -46,7 +46,7 @@ - (void)testSetCookie API_AVAILABLE(ios(11.0)) { makeWithValue:FWFNSHttpCookiePropertyKeyEnumName] ] propertyValues:@[ @"hello" ]]; FlutterError *__block blockError; - [hostApi setCookieForStoreWithIdentifier:@0 + [hostAPI setCookieForStoreWithIdentifier:@0 cookie:cookieData completion:^(FlutterError *error) { blockError = error; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m index b98d6acac7be..b33ccb589207 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m @@ -43,10 +43,10 @@ - (void)testDidFinishNavigation { (FWFNavigationDelegate *)[instanceManager instanceForIdentifier:0]; id mockDelegate = OCMPartialMock(navigationDelegate); - FWFNavigationDelegateFlutterApiImpl *flutterApi = [[FWFNavigationDelegateFlutterApiImpl alloc] + FWFNavigationDelegateFlutterApiImpl *flutterAPI = [[FWFNavigationDelegateFlutterApiImpl alloc] initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) instanceManager:instanceManager]; - id mockFlutterApi = OCMPartialMock(flutterApi); + id mockFlutterApi = OCMPartialMock(flutterAPI); OCMStub([mockDelegate navigationDelegateApi]).andReturn(mockFlutterApi); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m index ddf950591633..44b7517c3c79 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m @@ -20,14 +20,14 @@ - (void)testAddObserver { }]; [instanceManager addFlutterCreatedInstance:mockObject withIdentifier:0]; - FWFObjectHostApiImpl *hostApi = + FWFObjectHostApiImpl *hostAPI = [[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager]; NSObject *observerObject = [[NSObject alloc] init]; [instanceManager addFlutterCreatedInstance:observerObject withIdentifier:1]; FlutterError *error; - [hostApi + [hostAPI addObserverForObjectWithIdentifier:@0 observerIdentifier:@1 keyPath:@"myKey" @@ -54,14 +54,14 @@ - (void)testRemoveObserver { }]; [instanceManager addFlutterCreatedInstance:mockObject withIdentifier:0]; - FWFObjectHostApiImpl *hostApi = + FWFObjectHostApiImpl *hostAPI = [[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager]; NSObject *observerObject = [[NSObject alloc] init]; [instanceManager addFlutterCreatedInstance:observerObject withIdentifier:1]; FlutterError *error; - [hostApi removeObserverForObjectWithIdentifier:@0 + [hostAPI removeObserverForObjectWithIdentifier:@0 observerIdentifier:@1 keyPath:@"myKey" error:&error]; @@ -77,11 +77,11 @@ - (void)testDispose { }]; [instanceManager addFlutterCreatedInstance:object withIdentifier:0]; - FWFObjectHostApiImpl *hostApi = + FWFObjectHostApiImpl *hostAPI = [[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi disposeObjectWithIdentifier:@0 error:&error]; + [hostAPI disposeObjectWithIdentifier:@0 error:&error]; // Only the strong reference is removed, so the weak reference will remain until object is set to // nil. object = nil; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m index 5bc5185946d2..5535f881af69 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m @@ -16,14 +16,14 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - FWFPreferencesHostApiImpl *hostApi = + FWFPreferencesHostApiImpl *hostAPI = [[FWFPreferencesHostApiImpl alloc] initWithInstanceManager:instanceManager]; [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; - [hostApi createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; + [hostAPI createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; WKPreferences *preferences = (WKPreferences *)[instanceManager instanceForIdentifier:1]; XCTAssertTrue([preferences isKindOfClass:[WKPreferences class]]); XCTAssertNil(error); @@ -37,11 +37,11 @@ - (void)testSetJavaScriptEnabled { }]; [instanceManager addFlutterCreatedInstance:mockPreferences withIdentifier:0]; - FWFPreferencesHostApiImpl *hostApi = + FWFPreferencesHostApiImpl *hostAPI = [[FWFPreferencesHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi setJavaScriptEnabledForPreferencesWithIdentifier:@0 isEnabled:@YES error:&error]; + [hostAPI setJavaScriptEnabledForPreferencesWithIdentifier:@0 isEnabled:@YES error:&error]; OCMVerify([mockPreferences setJavaScriptEnabled:YES]); XCTAssertNil(error); } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m index 2fb840a8afdb..df85c1f193bc 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m @@ -16,11 +16,11 @@ - (void)testCreateWithIdentifier { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - FWFScriptMessageHandlerHostApiImpl *hostApi = + FWFScriptMessageHandlerHostApiImpl *hostAPI = [[FWFScriptMessageHandlerHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi createWithIdentifier:@0 error:&error]; + [hostAPI createWithIdentifier:@0 error:&error]; FWFScriptMessageHandler *scriptMessageHandler = (FWFScriptMessageHandler *)[instanceManager instanceForIdentifier:0]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m index a4b8ddc8de3d..173aba1bf40d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m @@ -21,12 +21,12 @@ - (void)testGetContentOffset { }]; [instanceManager addFlutterCreatedInstance:mockScrollView withIdentifier:0]; - FWFScrollViewHostApiImpl *hostApi = + FWFScrollViewHostApiImpl *hostAPI = [[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; NSArray *expectedValue = @[ @1.0, @2.0 ]; - XCTAssertEqualObjects([hostApi contentOffsetForScrollViewWithIdentifier:@0 error:&error], + XCTAssertEqualObjects([hostAPI contentOffsetForScrollViewWithIdentifier:@0 error:&error], expectedValue); XCTAssertNil(error); } @@ -40,11 +40,11 @@ - (void)testScrollBy { }]; [instanceManager addFlutterCreatedInstance:scrollView withIdentifier:0]; - FWFScrollViewHostApiImpl *hostApi = + FWFScrollViewHostApiImpl *hostAPI = [[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi scrollByForScrollViewWithIdentifier:@0 x:@1 y:@2 error:&error]; + [hostAPI scrollByForScrollViewWithIdentifier:@0 x:@1 y:@2 error:&error]; XCTAssertEqual(scrollView.contentOffset.x, 2); XCTAssertEqual(scrollView.contentOffset.y, 4); XCTAssertNil(error); @@ -58,11 +58,11 @@ - (void)testSetContentOffset { }]; [instanceManager addFlutterCreatedInstance:scrollView withIdentifier:0]; - FWFScrollViewHostApiImpl *hostApi = + FWFScrollViewHostApiImpl *hostAPI = [[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi setContentOffsetForScrollViewWithIdentifier:@0 toX:@1 y:@2 error:&error]; + [hostAPI setContentOffsetForScrollViewWithIdentifier:@0 toX:@1 y:@2 error:&error]; XCTAssertEqual(scrollView.contentOffset.x, 1); XCTAssertEqual(scrollView.contentOffset.y, 2); XCTAssertNil(error); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m index a64a0f632633..00bac36375c5 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m @@ -16,11 +16,11 @@ - (void)testCreateWithIdentifier { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - FWFUIDelegateHostApiImpl *hostApi = + FWFUIDelegateHostApiImpl *hostAPI = [[FWFUIDelegateHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi createWithIdentifier:@0 error:&error]; + [hostAPI createWithIdentifier:@0 error:&error]; FWFUIDelegate *delegate = (FWFUIDelegate *)[instanceManager instanceForIdentifier:0]; XCTAssertTrue([delegate conformsToProtocol:@protocol(WKUIDelegate)]); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m index 8c43fa9c61de..a72730025dd3 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m @@ -20,11 +20,11 @@ - (void)testSetBackgroundColor { }]; [instanceManager addFlutterCreatedInstance:mockUIView withIdentifier:0]; - FWFUIViewHostApiImpl *hostApi = + FWFUIViewHostApiImpl *hostAPI = [[FWFUIViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi setBackgroundColorForViewWithIdentifier:@0 toValue:@123 error:&error]; + [hostAPI setBackgroundColorForViewWithIdentifier:@0 toValue:@123 error:&error]; OCMVerify([mockUIView setBackgroundColor:[UIColor colorWithRed:(123 >> 16 & 0xff) / 255.0 green:(123 >> 8 & 0xff) / 255.0 @@ -41,11 +41,11 @@ - (void)testSetOpaque { }]; [instanceManager addFlutterCreatedInstance:mockUIView withIdentifier:0]; - FWFUIViewHostApiImpl *hostApi = + FWFUIViewHostApiImpl *hostAPI = [[FWFUIViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi setOpaqueForViewWithIdentifier:@0 isOpaque:@YES error:&error]; + [hostAPI setOpaqueForViewWithIdentifier:@0 isOpaque:@YES error:&error]; OCMVerify([mockUIView setOpaque:YES]); XCTAssertNil(error); } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m index 4231b1071a4e..cbcf60bf48a7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m @@ -16,14 +16,14 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - FWFUserContentControllerHostApiImpl *hostApi = + FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; - [hostApi createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; + [hostAPI createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; WKUserContentController *userContentController = (WKUserContentController *)[instanceManager instanceForIdentifier:1]; XCTAssertTrue([userContentController isKindOfClass:[WKUserContentController class]]); @@ -39,7 +39,7 @@ - (void)testAddScriptMessageHandler { }]; [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; - FWFUserContentControllerHostApiImpl *hostApi = + FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; id mockMessageHandler = @@ -47,7 +47,7 @@ - (void)testAddScriptMessageHandler { [instanceManager addFlutterCreatedInstance:mockMessageHandler withIdentifier:1]; FlutterError *error; - [hostApi addScriptMessageHandlerForControllerWithIdentifier:@0 + [hostAPI addScriptMessageHandlerForControllerWithIdentifier:@0 handlerIdentifier:@1 ofName:@"apple" error:&error]; @@ -64,11 +64,11 @@ - (void)testRemoveScriptMessageHandler { }]; [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; - FWFUserContentControllerHostApiImpl *hostApi = + FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi removeScriptMessageHandlerForControllerWithIdentifier:@0 name:@"apple" error:&error]; + [hostAPI removeScriptMessageHandlerForControllerWithIdentifier:@0 name:@"apple" error:&error]; OCMVerify([mockUserContentController removeScriptMessageHandlerForName:@"apple"]); XCTAssertNil(error); } @@ -82,11 +82,11 @@ - (void)testRemoveAllScriptMessageHandlers API_AVAILABLE(ios(14.0)) { }]; [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; - FWFUserContentControllerHostApiImpl *hostApi = + FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi removeAllScriptMessageHandlersForControllerWithIdentifier:@0 error:&error]; + [hostAPI removeAllScriptMessageHandlersForControllerWithIdentifier:@0 error:&error]; OCMVerify([mockUserContentController removeAllScriptMessageHandlers]); XCTAssertNil(error); } @@ -100,11 +100,11 @@ - (void)testAddUserScript { }]; [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; - FWFUserContentControllerHostApiImpl *hostApi = + FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi + [hostAPI addUserScriptForControllerWithIdentifier:@0 userScript: [FWFWKUserScriptData @@ -129,11 +129,11 @@ - (void)testRemoveAllUserScripts { }]; [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; - FWFUserContentControllerHostApiImpl *hostApi = + FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi removeAllUserScriptsForControllerWithIdentifier:@0 error:&error]; + [hostAPI removeAllUserScriptsForControllerWithIdentifier:@0 error:&error]; OCMVerify([mockUserContentController removeAllUserScripts]); XCTAssertNil(error); } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m index 6ac7ce5e6067..27a7c63fde83 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m @@ -16,11 +16,11 @@ - (void)testCreateWithIdentifier { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - FWFWebViewConfigurationHostApiImpl *hostApi = + FWFWebViewConfigurationHostApiImpl *hostAPI = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi createWithIdentifier:@0 error:&error]; + [hostAPI createWithIdentifier:@0 error:&error]; WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[instanceManager instanceForIdentifier:0]; XCTAssertTrue([configuration isKindOfClass:[WKWebViewConfiguration class]]); @@ -31,7 +31,7 @@ - (void)testCreateFromWebViewWithIdentifier { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - FWFWebViewConfigurationHostApiImpl *hostApi = + FWFWebViewConfigurationHostApiImpl *hostAPI = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; WKWebView *mockWebView = OCMClassMock([WKWebView class]); @@ -39,7 +39,7 @@ - (void)testCreateFromWebViewWithIdentifier { [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; FlutterError *error; - [hostApi createFromWebViewWithIdentifier:@1 webViewIdentifier:@0 error:&error]; + [hostAPI createFromWebViewWithIdentifier:@1 webViewIdentifier:@0 error:&error]; WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[instanceManager instanceForIdentifier:1]; XCTAssertTrue([configuration isKindOfClass:[WKWebViewConfiguration class]]); @@ -54,11 +54,11 @@ - (void)testSetAllowsInlineMediaPlayback { }]; [instanceManager addFlutterCreatedInstance:mockWebViewConfiguration withIdentifier:0]; - FWFWebViewConfigurationHostApiImpl *hostApi = + FWFWebViewConfigurationHostApiImpl *hostAPI = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:@0 + [hostAPI setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:@0 isAllowed:@NO error:&error]; OCMVerify([mockWebViewConfiguration setAllowsInlineMediaPlayback:NO]); @@ -73,11 +73,11 @@ - (void)testSetMediaTypesRequiringUserActionForPlayback { }]; [instanceManager addFlutterCreatedInstance:mockWebViewConfiguration withIdentifier:0]; - FWFWebViewConfigurationHostApiImpl *hostApi = + FWFWebViewConfigurationHostApiImpl *hostAPI = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi + [hostAPI setMediaTypesRequiresUserActionForConfigurationWithIdentifier:@0 forTypes:@[ [FWFWKAudiovisualMediaTypeEnumData diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m index 8bbfb8c367f2..2e24813317f7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m @@ -16,14 +16,14 @@ - (void)testCreateWithIdentifier { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; - [hostApi createWithIdentifier:@1 configurationIdentifier:@0 error:&error]; + [hostAPI createWithIdentifier:@1 configurationIdentifier:@0 error:&error]; WKWebView *webView = (WKWebView *)[instanceManager instanceForIdentifier:1]; XCTAssertTrue([webView isKindOfClass:[WKWebView class]]); XCTAssertNil(error); @@ -37,7 +37,7 @@ - (void)testLoadRequest { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; @@ -45,7 +45,7 @@ - (void)testLoadRequest { httpMethod:@"get" httpBody:nil allHttpHeaderFields:@{@"a" : @"header"}]; - [hostApi loadRequestForWebViewWithIdentifier:@0 request:requestData error:&error]; + [hostAPI loadRequestForWebViewWithIdentifier:@0 request:requestData error:&error]; NSURL *url = [NSURL URLWithString:@"https://www.flutter.dev"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; @@ -64,7 +64,7 @@ - (void)testLoadRequestWithInvalidUrl { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; @@ -72,7 +72,7 @@ - (void)testLoadRequestWithInvalidUrl { httpMethod:nil httpBody:nil allHttpHeaderFields:@{}]; - [hostApi loadRequestForWebViewWithIdentifier:@0 request:requestData error:&error]; + [hostAPI loadRequestForWebViewWithIdentifier:@0 request:requestData error:&error]; XCTAssertNotNil(error); XCTAssertEqualObjects(error.code, @"FWFURLRequestParsingError"); XCTAssertEqualObjects(error.message, @"Failed instantiating an NSURLRequest."); @@ -87,11 +87,11 @@ - (void)testSetCustomUserAgent { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi setUserAgentForWebViewWithIdentifier:@0 userAgent:@"userA" error:&error]; + [hostAPI setUserAgentForWebViewWithIdentifier:@0 userAgent:@"userA" error:&error]; OCMVerify([mockWebView setCustomUserAgent:@"userA"]); XCTAssertNil(error); } @@ -105,11 +105,11 @@ - (void)testURL { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - XCTAssertEqualObjects([hostApi URLForWebViewWithIdentifier:@0 error:&error], + XCTAssertEqualObjects([hostAPI URLForWebViewWithIdentifier:@0 error:&error], @"https://www.flutter.dev/"); XCTAssertNil(error); } @@ -123,11 +123,11 @@ - (void)testCanGoBack { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - XCTAssertEqualObjects([hostApi canGoBackForWebViewWithIdentifier:@0 error:&error], @YES); + XCTAssertEqualObjects([hostAPI canGoBackForWebViewWithIdentifier:@0 error:&error], @YES); XCTAssertNil(error); } @@ -139,14 +139,14 @@ - (void)testSetUIDelegate { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; id mockDelegate = OCMProtocolMock(@protocol(WKUIDelegate)); [instanceManager addFlutterCreatedInstance:mockDelegate withIdentifier:1]; FlutterError *error; - [hostApi setUIDelegateForWebViewWithIdentifier:@0 delegateIdentifier:@1 error:&error]; + [hostAPI setUIDelegateForWebViewWithIdentifier:@0 delegateIdentifier:@1 error:&error]; OCMVerify([mockWebView setUIDelegate:mockDelegate]); XCTAssertNil(error); } @@ -159,14 +159,14 @@ - (void)testSetNavigationDelegate { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; id mockDelegate = OCMProtocolMock(@protocol(WKNavigationDelegate)); [instanceManager addFlutterCreatedInstance:mockDelegate withIdentifier:1]; FlutterError *error; - [hostApi setNavigationDelegateForWebViewWithIdentifier:@0 delegateIdentifier:@1 error:&error]; + [hostAPI setNavigationDelegateForWebViewWithIdentifier:@0 delegateIdentifier:@1 error:&error]; OCMVerify([mockWebView setNavigationDelegate:mockDelegate]); XCTAssertNil(error); } @@ -180,11 +180,11 @@ - (void)testEstimatedProgress { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - XCTAssertEqualObjects([hostApi estimatedProgressForWebViewWithIdentifier:@0 error:&error], @34.0); + XCTAssertEqualObjects([hostAPI estimatedProgressForWebViewWithIdentifier:@0 error:&error], @34.0); XCTAssertNil(error); } @@ -196,11 +196,11 @@ - (void)testloadHTMLString { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi loadHTMLForWebViewWithIdentifier:@0 + [hostAPI loadHTMLForWebViewWithIdentifier:@0 HTMLString:@"myString" baseURL:@"myBaseUrl" error:&error]; @@ -216,11 +216,11 @@ - (void)testLoadFileURL { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi loadFileForWebViewWithIdentifier:@0 + [hostAPI loadFileForWebViewWithIdentifier:@0 fileURL:@"myFolder/apple.txt" readAccessURL:@"myFolder" error:&error]; @@ -247,13 +247,13 @@ - (void)testLoadFlutterAsset { OCMStub([mockBundle URLForResource:@"myFolder/assets/index" withExtension:@"html"]) .andReturn([NSURL URLWithString:@"webview_flutter/myFolder/assets/index.html"]); - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager bundle:mockBundle assetManager:mockAssetManager]; FlutterError *error; - [hostApi loadAssetForWebViewWithIdentifier:@0 assetKey:@"assets/index.html" error:&error]; + [hostAPI loadAssetForWebViewWithIdentifier:@0 assetKey:@"assets/index.html" error:&error]; XCTAssertNil(error); OCMVerify([mockWebView @@ -270,11 +270,11 @@ - (void)testCanGoForward { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - XCTAssertEqualObjects([hostApi canGoForwardForWebViewWithIdentifier:@0 error:&error], @NO); + XCTAssertEqualObjects([hostAPI canGoForwardForWebViewWithIdentifier:@0 error:&error], @NO); XCTAssertNil(error); } @@ -286,11 +286,11 @@ - (void)testGoBack { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi goBackForWebViewWithIdentifier:@0 error:&error]; + [hostAPI goBackForWebViewWithIdentifier:@0 error:&error]; OCMVerify([mockWebView goBack]); XCTAssertNil(error); } @@ -303,11 +303,11 @@ - (void)testGoForward { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi goForwardForWebViewWithIdentifier:@0 error:&error]; + [hostAPI goForwardForWebViewWithIdentifier:@0 error:&error]; OCMVerify([mockWebView goForward]); XCTAssertNil(error); } @@ -320,11 +320,11 @@ - (void)testReload { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi reloadWebViewWithIdentifier:@0 error:&error]; + [hostAPI reloadWebViewWithIdentifier:@0 error:&error]; OCMVerify([mockWebView reload]); XCTAssertNil(error); } @@ -338,11 +338,11 @@ - (void)testTitle { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - XCTAssertEqualObjects([hostApi titleForWebViewWithIdentifier:@0 error:&error], @"myTitle"); + XCTAssertEqualObjects([hostAPI titleForWebViewWithIdentifier:@0 error:&error], @"myTitle"); XCTAssertNil(error); } @@ -354,11 +354,11 @@ - (void)testSetAllowsBackForwardNavigationGestures { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi setAllowsBackForwardForWebViewWithIdentifier:@0 isAllowed:@YES error:&error]; + [hostAPI setAllowsBackForwardForWebViewWithIdentifier:@0 isAllowed:@YES error:&error]; OCMVerify([mockWebView setAllowsBackForwardNavigationGestures:YES]); XCTAssertNil(error); } @@ -375,12 +375,12 @@ - (void)testEvaluateJavaScript { }]; [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; - FWFWebViewHostApiImpl *hostApi = + FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; NSString __block *returnValue; FlutterError __block *returnError; - [hostApi evaluateJavaScriptForWebViewWithIdentifier:@0 + [hostAPI evaluateJavaScriptForWebViewWithIdentifier:@0 javaScriptString:@"runJavaScript" completion:^(id result, FlutterError *error) { returnValue = result; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m index add2dc96d041..3e26ccf8a161 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m @@ -16,14 +16,14 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - FWFWebsiteDataStoreHostApiImpl *hostApi = + FWFWebsiteDataStoreHostApiImpl *hostAPI = [[FWFWebsiteDataStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; - [hostApi createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; + [hostAPI createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; WKWebsiteDataStore *dataStore = (WKWebsiteDataStore *)[instanceManager instanceForIdentifier:1]; XCTAssertTrue([dataStore isKindOfClass:[WKWebsiteDataStore class]]); XCTAssertNil(error); @@ -33,11 +33,11 @@ - (void)testCreateDefaultDataStoreWithIdentifier { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - FWFWebsiteDataStoreHostApiImpl *hostApi = + FWFWebsiteDataStoreHostApiImpl *hostAPI = [[FWFWebsiteDataStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; FlutterError *error; - [hostApi createDefaultDataStoreWithIdentifier:@0 error:&error]; + [hostAPI createDefaultDataStoreWithIdentifier:@0 error:&error]; WKWebsiteDataStore *dataStore = (WKWebsiteDataStore *)[instanceManager instanceForIdentifier:0]; XCTAssertEqualObjects(dataStore, [WKWebsiteDataStore defaultDataStore]); XCTAssertNil(error); @@ -61,12 +61,12 @@ - (void)testRemoveDataOfTypes { }]; [instanceManager addFlutterCreatedInstance:mockWebsiteDataStore withIdentifier:0]; - FWFWebsiteDataStoreHostApiImpl *hostApi = + FWFWebsiteDataStoreHostApiImpl *hostAPI = [[FWFWebsiteDataStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; NSNumber __block *returnValue; FlutterError *__block blockError; - [hostApi removeDataFromDataStoreWithIdentifier:@0 + [hostAPI removeDataFromDataStoreWithIdentifier:@0 ofTypes:@[ [FWFWKWebsiteDataTypeEnumData makeWithValue:FWFWKWebsiteDataTypeEnumLocalStorage] From ad9b4e60b86d255bd9d3dff33d34c1277e39599b Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 19 May 2022 19:41:12 -0700 Subject: [PATCH 22/40] better comment --- .../webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart index 9e143e8df95e..c83b46abb62a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart @@ -623,8 +623,8 @@ class WKNavigationDelegate extends NSObject { /// Constructs a [WKNavigationDelegate] without creating the associated /// Objective-C object. /// - /// This should only be used by subclasses created by this library or by an - /// InstanceManager creating copies. + /// This should only be used outside of tests by subclasses created by this + /// library or to create a copy for an InstanceManager. WKNavigationDelegate.detached({ this.didFinishNavigation, BinaryMessenger? binaryMessenger, From d8b720e96fb7f401b68fcb5187134fa787ce3967 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Mon, 23 May 2022 16:34:53 -0700 Subject: [PATCH 23/40] update comment with info about platform/flutter --- .../ios/Classes/FWFInstanceManager.m | 4 ++-- .../lib/src/common/instance_manager.dart | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index ca7a0de7730e..d6bb6d543e09 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -78,8 +78,8 @@ - (long)addHostCreatedInstance:(nonnull NSObject *)instance { long identifier; do { // Identifiers are generated randomly to avoid collisions with objects - // created simultaneously by the Flutter. - // Value must be >= 2^16. + // created simultaneously by Flutter. + // Values are >= 2^16 and Flutter is expected to use values < 2^16. identifier = arc4random_uniform(65536) + 65536; } while ([self.weakInstances objectForKey:@(identifier)]); [self addInstance:instance withIdentifier:identifier]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 7ec2ac153028..2dae0b6215c7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -196,7 +196,8 @@ class InstanceManager { int _generateNewIdentifier() { late int identifier; do { - // Value must be < 2^16. + // Values are less than 2^16 while the host platform is expected to use + // values greater than or equal to 2^16. identifier = Random().nextInt(65536); } while (containsIdentifier(identifier)); return identifier; From 3c980048558fd504aedcd4b94acb575e0dd6eaae Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 24 May 2022 15:33:33 -0700 Subject: [PATCH 24/40] fix bug from instance manager identifier --- .../example/ios/RunnerTests/FWFInstanceManagerTests.m | 2 +- .../webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m | 3 +-- .../lib/src/common/instance_manager.dart | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m index 7854b0b2ea82..7cbdc8d6ebb6 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m @@ -21,7 +21,7 @@ - (void)testAddFlutterCreatedInstance { 0); } -- (void)testAddHostIdentifier { +- (void)testAddHostCreatedInstance { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index d6bb6d543e09..bf2e6c74dcf5 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -73,9 +73,8 @@ - (void)addFlutterCreatedInstance:(NSObject *)instance withIdentifier:(long)inst - (long)addHostCreatedInstance:(nonnull NSObject *)instance { NSParameterAssert(instance); - long identifier = -1; + long __block identifier = -1; dispatch_sync(_lockQueue, ^{ - long identifier; do { // Identifiers are generated randomly to avoid collisions with objects // created simultaneously by Flutter. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 2dae0b6215c7..1e3c310efedf 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -169,6 +169,7 @@ class InstanceManager { void addHostCreatedInstance(Copyable instance, int identifier) { assert(!containsIdentifier(identifier)); assert(getIdentifier(instance) == null); + assert(identifier >= 0); _addInstanceWithIdentifier(instance, identifier); } From 368fb30ca423429b83a39107306f4a1dd592be1e Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 24 May 2022 17:57:20 -0700 Subject: [PATCH 25/40] limits on identifiers --- .../ios/Flutter/AppFrameworkInfo.plist | 2 +- .../webview_flutter/example/ios/Podfile | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 8 +-- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../example/ios/Runner/Info.plist | 2 + .../ios/Classes/FWFInstanceManager.m | 15 +++-- .../lib/src/common/instance_manager.dart | 55 ++++++++-------- .../lib/src/ui_kit/ui_kit_api_impls.dart | 13 ++-- .../lib/src/web_kit/web_kit_api_impls.dart | 62 ++++++++----------- .../webview_flutter_wkwebview/pubspec.yaml | 2 +- .../src/common/instance_manager_test.dart | 2 +- .../test/src/foundation/foundation_test.dart | 8 +-- .../test/src/ui_kit/ui_kit_test.dart | 2 +- 13 files changed, 82 insertions(+), 93 deletions(-) diff --git a/packages/webview_flutter/webview_flutter/example/ios/Flutter/AppFrameworkInfo.plist b/packages/webview_flutter/webview_flutter/example/ios/Flutter/AppFrameworkInfo.plist index 8d4492f977ad..9625e105df39 100644 --- a/packages/webview_flutter/webview_flutter/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/webview_flutter/webview_flutter/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/packages/webview_flutter/webview_flutter/example/ios/Podfile b/packages/webview_flutter/webview_flutter/example/ios/Podfile index 66509fcae284..d01e899e347b 100644 --- a/packages/webview_flutter/webview_flutter/example/ios/Podfile +++ b/packages/webview_flutter/webview_flutter/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +# platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/project.pbxproj b/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/project.pbxproj index 0759b31a2f25..0eaa82af7e93 100644 --- a/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -274,7 +274,7 @@ isa = PBXProject; attributes = { DefaultBuildSystemTypeForWorkspace = Original; - LastUpgradeCheck = 1030; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = "The Flutter Authors"; TargetAttributes = { 68BDCAE823C3F7CB00D9C032 = { @@ -552,7 +552,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -602,7 +602,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index d7453a8ce862..cb713d767632 100644 --- a/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index bf2e6c74dcf5..2e89acd7178c 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -48,9 +48,16 @@ @interface FWFInstanceManager () @property NSMapTable *identifiers; @property NSMapTable *weakInstances; @property NSMapTable *strongInstances; +@property long nextIdentifier; @end @implementation FWFInstanceManager +// Identifiers are locked to a specific range to avoid collisions with objects +// created simultaneously by Dart. +// Host uses identifiers >= 2^16 and Dart is expected to use values n where, +// 0 <= n < 2^16. +long const FWFMinHostCreatedIdentifier = 65536; + - (instancetype)initWithDeallocCallback:(FWFOnDeallocCallback)callback { self = [self init]; if (self) { @@ -59,6 +66,7 @@ - (instancetype)initWithDeallocCallback:(FWFOnDeallocCallback)callback { _identifiers = [NSMapTable weakToStrongObjectsMapTable]; _weakInstances = [NSMapTable strongToWeakObjectsMapTable]; _strongInstances = [NSMapTable strongToStrongObjectsMapTable]; + _nextIdentifier = FWFMinHostCreatedIdentifier; } return self; } @@ -75,12 +83,7 @@ - (long)addHostCreatedInstance:(nonnull NSObject *)instance { NSParameterAssert(instance); long __block identifier = -1; dispatch_sync(_lockQueue, ^{ - do { - // Identifiers are generated randomly to avoid collisions with objects - // created simultaneously by Flutter. - // Values are >= 2^16 and Flutter is expected to use values < 2^16. - identifier = arc4random_uniform(65536) + 65536; - } while ([self.weakInstances objectForKey:@(identifier)]); + identifier = self.nextIdentifier++; [self addInstance:instance withIdentifier:identifier]; }); return identifier; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 1e3c310efedf..3e6a33352059 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:math'; - import 'package:flutter/foundation.dart'; /// An immutable object that can provide functional copies of themselves. @@ -37,8 +35,6 @@ mixin Copyable { /// strong reference is added as a weak reference with the same identifier. This /// prevents a scenario where the weak referenced instance was released and then /// later returned by the host platform. -// TODO(bparrishMines): Uncomment code with Finalizers and WeakReferences once -// minimum dart version is bumped to 2.17. class InstanceManager { /// Constructs an [InstanceManager]. InstanceManager({required void Function(int) onWeakReferenceRemoved}) { @@ -46,22 +42,29 @@ class InstanceManager { _weakInstances.remove(identifier); onWeakReferenceRemoved(identifier); }; + _finalizer = Finalizer(this.onWeakReferenceRemoved); } + // Identifiers are locked to a specific range to avoid collisions with objects + // created simultaneously by the host platform. + // Host uses identifiers >= 2^16 and Dart is expected to use values n where, + // 0 <= n < 2^16. + static const int _maxDartCreatedIdentifier = 65536; + // Expando is used because it doesn't prevent its keys from becoming // inaccessible. This allows the manager to efficiently retrieve an identifier // of an instance without holding a strong reference to that instance. // // It also doesn't use `==` to search for identifiers, which would lead to an // infinite loop when comparing an object to its copy. (i.e. which was caused - // by calling instanceManager.getInstanceId() inside of `==` while this was a + // by calling instanceManager.getIdentifier() inside of `==` while this was a // HashMap). final Expando _identifiers = Expando(); - final Map _weakInstances = {}; - // final Map> _weakInstances = - // >{}; + final Map> _weakInstances = + >{}; final Map _strongInstances = {}; - // final Finalizer _finalizer; + late final Finalizer _finalizer; + int _nextIdentifier = 0; /// Called when a weak referenced instance is removed by [removeWeakReference] /// or becomes inaccessible. @@ -75,10 +78,10 @@ class InstanceManager { /// Throws assertion error if the instance has already been added. /// /// Returns the randomly generated id of the [instance] added. - int addFlutterCreatedInstance(Copyable instance) { + int addDartCreatedInstance(Copyable instance) { assert(getIdentifier(instance) == null); - final int identifier = _generateNewIdentifier(); + final int identifier = _nextUniqueIdentifier(); _addInstanceWithIdentifier(instance, identifier); return identifier; } @@ -98,7 +101,7 @@ class InstanceManager { } _identifiers[instance] = null; - //_finalizer.detach(instance); + _finalizer.detach(instance); onWeakReferenceRemoved(identifier); return identifier; @@ -133,17 +136,15 @@ class InstanceManager { int identifier, { required bool returnedInstanceMayBeUsed, }) { - // final Copyable? weakInstance = _weakInstances[identifier]?.target; - final Copyable? weakInstance = _weakInstances[identifier]; + final Copyable? weakInstance = _weakInstances[identifier]?.target; if (weakInstance == null) { final Copyable? strongInstance = _strongInstances[identifier]; if (strongInstance != null && returnedInstanceMayBeUsed) { final Copyable copy = strongInstance.copy(); _identifiers[copy] = identifier; - _weakInstances[identifier] = copy; - // _weakInstances[identifier] = WeakReference(copy); - // _finalizer.attach(copy, identifier, detach: copy); + _weakInstances[identifier] = WeakReference(copy); + _finalizer.attach(copy, identifier, detach: copy); return copy as T; } return strongInstance as T?; @@ -175,9 +176,8 @@ class InstanceManager { void _addInstanceWithIdentifier(Copyable instance, int identifier) { _identifiers[instance] = identifier; - _weakInstances[identifier] = instance; - // _weakInstances[identifier] = WeakReference(instance); - // _finalizer.attach(instance, identifier, detach: instance); + _weakInstances[identifier] = WeakReference(instance); + _finalizer.attach(instance, identifier, detach: instance); final Copyable copy = instance.copy(); _identifiers[copy] = identifier; @@ -192,15 +192,10 @@ class InstanceManager { _strongInstances.containsKey(identifier); } - // Identifiers are generated randomly to avoid collisions with objects - // created simultaneously by the host platform. - int _generateNewIdentifier() { - late int identifier; - do { - // Values are less than 2^16 while the host platform is expected to use - // values greater than or equal to 2^16. - identifier = Random().nextInt(65536); - } while (containsIdentifier(identifier)); - return identifier; + int _nextUniqueIdentifier() { + while (containsIdentifier(_nextIdentifier)) { + _nextIdentifier = (_nextIdentifier + 1) % _maxDartCreatedIdentifier; + } + return _nextIdentifier; } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart index f0a0a54f9f3f..eb6052ccc42a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart @@ -6,7 +6,6 @@ import 'dart:async'; import 'dart:math'; import 'package:flutter/painting.dart' show Color; -import 'package:flutter/services.dart'; import '../common/instance_manager.dart'; import '../common/web_kit.pigeon.dart'; @@ -18,10 +17,9 @@ import 'ui_kit.dart'; class UIScrollViewHostApiImpl extends UIScrollViewHostApi { /// Constructs a [UIScrollViewHostApiImpl]. UIScrollViewHostApiImpl({ - BinaryMessenger? binaryMessenger, + super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, - super(binaryMessenger: binaryMessenger); + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -31,7 +29,7 @@ class UIScrollViewHostApiImpl extends UIScrollViewHostApi { UIScrollView instance, WKWebView webView, ) { - final int instanceId = instanceManager.addFlutterCreatedInstance(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return createFromWebView( instanceId, instanceManager.getIdentifier(webView)!, @@ -77,10 +75,9 @@ class UIScrollViewHostApiImpl extends UIScrollViewHostApi { class UIViewHostApiImpl extends UIViewHostApi { /// Constructs a [UIViewHostApiImpl]. UIViewHostApiImpl({ - BinaryMessenger? binaryMessenger, + super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, - super(binaryMessenger: binaryMessenger); + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart index 1d3ca62b8ce4..85b1a4a1c1b7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart @@ -224,10 +224,9 @@ class WebKitFlutterApis { class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { /// Constructs a [WebsiteDataStoreHostApiImpl]. WKWebsiteDataStoreHostApiImpl({ - BinaryMessenger? binaryMessenger, + super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, - super(binaryMessenger: binaryMessenger); + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -237,7 +236,7 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { WKWebsiteDataStore instance, WKWebViewConfiguration configuration, ) { - final int instanceId = instanceManager.addFlutterCreatedInstance(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return createFromWebViewConfiguration( instanceId, @@ -249,7 +248,7 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { Future createDefaultDataStoreForInstances( WKWebsiteDataStore instance, ) async { - final int instanceId = instanceManager.addFlutterCreatedInstance(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return createDefaultDataStore(instanceId); } @@ -271,17 +270,16 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { class WKScriptMessageHandlerHostApiImpl extends WKScriptMessageHandlerHostApi { /// Constructs a [WKScriptMessageHandlerHostApiImpl]. WKScriptMessageHandlerHostApiImpl({ - BinaryMessenger? binaryMessenger, + super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, - super(binaryMessenger: binaryMessenger); + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKScriptMessageHandler instance) async { - final int instanceId = instanceManager.addFlutterCreatedInstance(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return create(instanceId); } } @@ -290,10 +288,9 @@ class WKScriptMessageHandlerHostApiImpl extends WKScriptMessageHandlerHostApi { class WKPreferencesHostApiImpl extends WKPreferencesHostApi { /// Constructs a [WKPreferencesHostApiImpl]. WKPreferencesHostApiImpl({ - BinaryMessenger? binaryMessenger, + super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, - super(binaryMessenger: binaryMessenger); + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -303,7 +300,7 @@ class WKPreferencesHostApiImpl extends WKPreferencesHostApi { WKPreferences instance, WKWebViewConfiguration configuration, ) { - final int instanceId = instanceManager.addFlutterCreatedInstance(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return createFromWebViewConfiguration( instanceId, instanceManager.getIdentifier(configuration)!, @@ -326,10 +323,9 @@ class WKPreferencesHostApiImpl extends WKPreferencesHostApi { class WKHttpCookieStoreHostApiImpl extends WKHttpCookieStoreHostApi { /// Constructs a [WKHttpCookieStoreHostApiImpl]. WKHttpCookieStoreHostApiImpl({ - BinaryMessenger? binaryMessenger, + super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, - super(binaryMessenger: binaryMessenger); + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -339,7 +335,7 @@ class WKHttpCookieStoreHostApiImpl extends WKHttpCookieStoreHostApi { WKHttpCookieStore instance, WKWebsiteDataStore dataStore, ) { - final int instanceId = instanceManager.addFlutterCreatedInstance(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return createFromWebsiteDataStore( instanceId, instanceManager.getIdentifier(dataStore)!, @@ -363,10 +359,9 @@ class WKUserContentControllerHostApiImpl extends WKUserContentControllerHostApi { /// Constructs a [WKUserContentControllerHostApiImpl]. WKUserContentControllerHostApiImpl({ - BinaryMessenger? binaryMessenger, + super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, - super(binaryMessenger: binaryMessenger); + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -376,7 +371,7 @@ class WKUserContentControllerHostApiImpl WKUserContentController instance, WKWebViewConfiguration configuration, ) async { - final int instanceId = instanceManager.addFlutterCreatedInstance(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return createFromWebViewConfiguration( instanceId, instanceManager.getIdentifier(configuration)!, @@ -439,17 +434,16 @@ class WKUserContentControllerHostApiImpl class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { /// Constructs a [WKWebViewConfigurationHostApiImpl]. WKWebViewConfigurationHostApiImpl({ - BinaryMessenger? binaryMessenger, + super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, - super(binaryMessenger: binaryMessenger); + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKWebViewConfiguration instance) { - final int instanceId = instanceManager.addFlutterCreatedInstance(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return create(instanceId); } @@ -458,7 +452,7 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { WKWebViewConfiguration instance, WKWebView webView, ) async { - final int instanceId = instanceManager.addFlutterCreatedInstance(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return createFromWebView( instanceId, instanceManager.getIdentifier(webView)!, @@ -492,17 +486,16 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { class WKUIDelegateHostApiImpl extends WKUIDelegateHostApi { /// Constructs a [WKUIDelegateHostApiImpl]. WKUIDelegateHostApiImpl({ - BinaryMessenger? binaryMessenger, + super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, - super(binaryMessenger: binaryMessenger); + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKUIDelegate instance) async { - final int instanceId = instanceManager.addFlutterCreatedInstance(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return create(instanceId); } } @@ -528,7 +521,7 @@ class WKNavigationDelegateHostApiImpl extends WKNavigationDelegateHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKNavigationDelegate instance) async { - final int instanceId = instanceManager.addFlutterCreatedInstance(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return create(instanceId); } @@ -585,10 +578,9 @@ class WKNavigationDelegateFlutterApiImpl class WKWebViewHostApiImpl extends WKWebViewHostApi { /// Constructs a [WKWebViewHostApiImpl]. WKWebViewHostApiImpl({ - BinaryMessenger? binaryMessenger, + super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, - super(binaryMessenger: binaryMessenger); + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -598,7 +590,7 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { WKWebView instance, WKWebViewConfiguration configuration, ) { - final int instanceId = instanceManager.addFlutterCreatedInstance(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return create( instanceId, instanceManager.getIdentifier(configuration)!, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml b/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml index d85bf329a58e..7ff89c4ba682 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml +++ b/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml @@ -5,7 +5,7 @@ issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+ version: 2.7.5 environment: - sdk: ">=2.14.0 <3.0.0" + sdk: ">=2.17.0 <3.0.0" flutter: ">=2.5.0" flutter: diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart index 6baaeec263f3..ba576fecf3a7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart @@ -47,7 +47,7 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addFlutterCreatedInstance(object); + instanceManager.addDartCreatedInstance(object); final int? instanceId = instanceManager.getIdentifier(object); expect(instanceId, isNotNull); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart index eb8e2f280deb..58ba0ec1a385 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart @@ -35,7 +35,7 @@ void main() { TestNSObjectHostApi.setup(mockPlatformHostApi); object = NSObject(instanceManager: instanceManager); - instanceManager.addFlutterCreatedInstance(object); + instanceManager.addDartCreatedInstance(object); }); tearDown(() { @@ -44,7 +44,7 @@ void main() { test('addObserver', () async { final NSObject observer = NSObject(instanceManager: instanceManager); - instanceManager.addFlutterCreatedInstance(observer); + instanceManager.addDartCreatedInstance(observer); await object.addObserver( observer, @@ -76,7 +76,7 @@ void main() { test('removeObserver', () async { final NSObject observer = NSObject(instanceManager: instanceManager); - instanceManager.addFlutterCreatedInstance(observer); + instanceManager.addDartCreatedInstance(observer); await object.removeObserver(observer, keyPath: 'aKeyPath'); @@ -96,7 +96,7 @@ void main() { final NSObject object = NSObject(instanceManager: instanceManager); final int identifier = - instanceManager.addFlutterCreatedInstance(object); + instanceManager.addDartCreatedInstance(object); NSObject.dispose(object); expect(callbackIdentifier, identifier); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart index 884d8e2d669f..aeb4e1cc54ce 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart @@ -98,7 +98,7 @@ void main() { TestUIViewHostApi.setup(mockPlatformHostApi); view = UIView(instanceManager: instanceManager); - viewInstanceId = instanceManager.addFlutterCreatedInstance(view); + viewInstanceId = instanceManager.addDartCreatedInstance(view); }); tearDown(() { From a6980c5636340d8c938ae37b4bb7015242657fad Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 24 May 2022 18:07:17 -0700 Subject: [PATCH 26/40] use removeReference name instead --- .../lib/src/common/instance_manager.dart | 4 ++-- .../lib/src/foundation/foundation.dart | 9 +-------- .../test/src/common/instance_manager_test.dart | 4 ++-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 3e6a33352059..760279b8c249 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -93,7 +93,7 @@ class InstanceManager { /// `null` if the instance was not found in this manager. /// /// This does not remove the the strong referenced instance associated with - /// [instance]. This can be done with [removeStrongReference]. + /// [instance]. This can be done with [removeReference]. int? removeWeakReference(Copyable instance) { final int? identifier = getIdentifier(instance); if (identifier == null) { @@ -116,7 +116,7 @@ class InstanceManager { /// /// This does not remove the the weak referenced instance associtated with /// [identifier]. This can be done with [removeWeakReference]. - Copyable? removeStrongReference(int identifier) { + Copyable? removeReference(int identifier) { return _strongInstances.remove(identifier); } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart index a014c536654f..ca3ba780435c 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart @@ -282,14 +282,7 @@ class NSObject with Copyable { /// Release the reference to the Objective-C object. static void dispose(NSObject instance) { - final int? identifier = instance._api.instanceManager.removeWeakReference( - instance, - ); - // TODO(bparrishMines): Remove these line once InstanceManager uses - // Finalizers. - if (identifier != null) { - instance._api.instanceManager.removeStrongReference(identifier); - } + instance._api.instanceManager.removeWeakReference(instance); } /// Informs the observing object when the value at the specified key path has changed. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart index ba576fecf3a7..bd02efaf2542 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart @@ -103,7 +103,7 @@ void main() { instanceManager.addHostCreatedInstance(object, 0); instanceManager.removeWeakReference(object); - expect(instanceManager.removeStrongReference(0), isA()); + expect(instanceManager.removeReference(0), isA()); expect( instanceManager.getInstance(0, returnedInstanceMayBeUsed: false), isNull, @@ -117,7 +117,7 @@ void main() { InstanceManager(onWeakReferenceRemoved: (_) {}); instanceManager.addHostCreatedInstance(object, 0); - expect(instanceManager.removeStrongReference(0), isA()); + expect(instanceManager.removeReference(0), isA()); expect( instanceManager.getInstance(0, returnedInstanceMayBeUsed: false), object, From 179f109d7aa8567f6605278571118c209f7fd2c1 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 24 May 2022 18:31:20 -0700 Subject: [PATCH 27/40] maybe an even better name? --- .../FWFHTTPCookieStoreHostApiTests.m | 4 +- .../ios/RunnerTests/FWFInstanceManagerTests.m | 8 ++-- .../FWFNavigationDelegateHostApiTests.m | 4 +- .../ios/RunnerTests/FWFObjectHostApiTests.m | 10 ++--- .../RunnerTests/FWFPreferencesHostApiTests.m | 4 +- .../RunnerTests/FWFScrollViewHostApiTests.m | 6 +-- .../ios/RunnerTests/FWFUIViewHostApiTests.m | 4 +- .../FWFUserContentControllerHostApiTests.m | 14 +++---- .../FWFWebViewConfigurationHostApiTests.m | 6 +-- .../ios/RunnerTests/FWFWebViewHostApiTests.m | 42 +++++++++---------- .../FWFWebsiteDataStoreHostApiTests.m | 4 +- .../ios/Classes/FWFHTTPCookieStoreHostApi.m | 2 +- .../ios/Classes/FWFInstanceManager.h | 16 +++---- .../ios/Classes/FWFInstanceManager.m | 23 +++++----- .../Classes/FWFNavigationDelegateHostApi.h | 2 +- .../Classes/FWFNavigationDelegateHostApi.m | 6 +-- .../ios/Classes/FWFObjectHostApi.m | 2 +- .../ios/Classes/FWFPreferencesHostApi.m | 4 +- .../Classes/FWFScriptMessageHandlerHostApi.m | 2 +- .../ios/Classes/FWFScrollViewHostApi.m | 2 +- .../ios/Classes/FWFUIDelegateHostApi.m | 2 +- .../Classes/FWFUserContentControllerHostApi.m | 2 +- .../Classes/FWFWebViewConfigurationHostApi.m | 4 +- .../ios/Classes/FWFWebViewHostApi.m | 2 +- .../ios/Classes/FWFWebsiteDataStoreHostApi.m | 4 +- .../lib/src/common/instance_manager.dart | 20 ++++----- .../lib/src/ui_kit/ui_kit_api_impls.dart | 2 +- .../lib/src/web_kit/web_kit_api_impls.dart | 22 +++++----- .../src/common/instance_manager_test.dart | 20 ++++----- .../test/src/foundation/foundation_test.dart | 8 ++-- .../test/src/ui_kit/ui_kit_test.dart | 2 +- 31 files changed, 126 insertions(+), 127 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m index cfdf8e9dd3b0..3b2456e5621b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m @@ -21,7 +21,7 @@ - (void)testCreateFromWebsiteDataStoreWithIdentifier API_AVAILABLE(ios(11.0)) { WKWebsiteDataStore *mockDataStore = OCMClassMock([WKWebsiteDataStore class]); OCMStub([mockDataStore httpCookieStore]).andReturn(OCMClassMock([WKHTTPCookieStore class])); - [instanceManager addFlutterCreatedInstance:mockDataStore withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockDataStore withIdentifier:0]; FlutterError *error; [hostAPI createFromWebsiteDataStoreWithIdentifier:@1 dataStoreIdentifier:@0 error:&error]; @@ -36,7 +36,7 @@ - (void)testSetCookie API_AVAILABLE(ios(11.0)) { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockHttpCookieStore withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockHttpCookieStore withIdentifier:0]; FWFHTTPCookieStoreHostApiImpl *hostAPI = [[FWFHTTPCookieStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m index 7cbdc8d6ebb6..25d35393b062 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m @@ -15,7 +15,7 @@ - (void)testAddFlutterCreatedInstance { }]; NSObject *object = [[NSObject alloc] init]; - [instanceManager addFlutterCreatedInstance:object withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:object withIdentifier:0]; XCTAssertEqualObjects([instanceManager instanceForIdentifier:0], object); XCTAssertEqual([instanceManager identifierForInstance:object identifierWillBePassedToFlutter:NO], 0); @@ -26,7 +26,7 @@ - (void)testAddHostCreatedInstance { [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; NSObject *object = [[NSObject alloc] init]; - [instanceManager addHostCreatedInstance:object]; + [instanceManager addInstanceCreatedFromHost:object]; long identifier = [instanceManager identifierForInstance:object identifierWillBePassedToFlutter:NO]; @@ -40,9 +40,9 @@ - (void)testRemoveStrongReferenceWithIdentifier { }]; NSObject *object = [[NSObject alloc] init]; - [instanceManager addFlutterCreatedInstance:object withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:object withIdentifier:0]; - XCTAssertEqualObjects([instanceManager removeStrongReferenceWithIdentifier:0], object); + XCTAssertEqualObjects([instanceManager removeInstanceWithIdentifier:0], object); XCTAssertEqual([instanceManager strongInstanceCount], 0); } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m index b33ccb589207..c5cf8899e8ee 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m @@ -48,11 +48,11 @@ - (void)testDidFinishNavigation { instanceManager:instanceManager]; id mockFlutterApi = OCMPartialMock(flutterAPI); - OCMStub([mockDelegate navigationDelegateApi]).andReturn(mockFlutterApi); + OCMStub([mockDelegate navigationDelegateAPI]).andReturn(mockFlutterApi); WKWebView *mockWebView = OCMClassMock([WKWebView class]); OCMStub([mockWebView URL]).andReturn([NSURL URLWithString:@"https://flutter.dev/"]); - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:1]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:1]; [mockDelegate webView:mockWebView didFinishNavigation:OCMClassMock([WKNavigation class])]; OCMVerify([mockFlutterApi didFinishNavigationForDelegateWithIdentifier:@0 diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m index 44b7517c3c79..f923a64e8f9f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m @@ -18,13 +18,13 @@ - (void)testAddObserver { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockObject withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockObject withIdentifier:0]; FWFObjectHostApiImpl *hostAPI = [[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager]; NSObject *observerObject = [[NSObject alloc] init]; - [instanceManager addFlutterCreatedInstance:observerObject withIdentifier:1]; + [instanceManager addInstanceCreatedFromDart:observerObject withIdentifier:1]; FlutterError *error; [hostAPI @@ -52,13 +52,13 @@ - (void)testRemoveObserver { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockObject withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockObject withIdentifier:0]; FWFObjectHostApiImpl *hostAPI = [[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager]; NSObject *observerObject = [[NSObject alloc] init]; - [instanceManager addFlutterCreatedInstance:observerObject withIdentifier:1]; + [instanceManager addInstanceCreatedFromDart:observerObject withIdentifier:1]; FlutterError *error; [hostAPI removeObserverForObjectWithIdentifier:@0 @@ -75,7 +75,7 @@ - (void)testDispose { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:object withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:object withIdentifier:0]; FWFObjectHostApiImpl *hostAPI = [[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m index 5535f881af69..f84ec5a1519f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m @@ -19,7 +19,7 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { FWFPreferencesHostApiImpl *hostAPI = [[FWFPreferencesHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] + [instanceManager addInstanceCreatedFromDart:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; @@ -35,7 +35,7 @@ - (void)testSetJavaScriptEnabled { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockPreferences withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockPreferences withIdentifier:0]; FWFPreferencesHostApiImpl *hostAPI = [[FWFPreferencesHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m index 173aba1bf40d..b0af406f7c0b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m @@ -19,7 +19,7 @@ - (void)testGetContentOffset { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockScrollView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockScrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostAPI = [[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -38,7 +38,7 @@ - (void)testScrollBy { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:scrollView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:scrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostAPI = [[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -56,7 +56,7 @@ - (void)testSetContentOffset { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:scrollView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:scrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostAPI = [[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m index a72730025dd3..0c94dcb15312 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m @@ -18,7 +18,7 @@ - (void)testSetBackgroundColor { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockUIView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockUIView withIdentifier:0]; FWFUIViewHostApiImpl *hostAPI = [[FWFUIViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -39,7 +39,7 @@ - (void)testSetOpaque { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockUIView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockUIView withIdentifier:0]; FWFUIViewHostApiImpl *hostAPI = [[FWFUIViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m index cbcf60bf48a7..1b726d476734 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m @@ -19,7 +19,7 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] + [instanceManager addInstanceCreatedFromDart:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; @@ -37,14 +37,14 @@ - (void)testAddScriptMessageHandler { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; id mockMessageHandler = OCMProtocolMock(@protocol(WKScriptMessageHandler)); - [instanceManager addFlutterCreatedInstance:mockMessageHandler withIdentifier:1]; + [instanceManager addInstanceCreatedFromDart:mockMessageHandler withIdentifier:1]; FlutterError *error; [hostAPI addScriptMessageHandlerForControllerWithIdentifier:@0 @@ -62,7 +62,7 @@ - (void)testRemoveScriptMessageHandler { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -80,7 +80,7 @@ - (void)testRemoveAllScriptMessageHandlers API_AVAILABLE(ios(14.0)) { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -98,7 +98,7 @@ - (void)testAddUserScript { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -127,7 +127,7 @@ - (void)testRemoveAllUserScripts { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockUserContentController withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m index 27a7c63fde83..6fa2e428cc73 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m @@ -36,7 +36,7 @@ - (void)testCreateFromWebViewWithIdentifier { WKWebView *mockWebView = OCMClassMock([WKWebView class]); OCMStub([mockWebView configuration]).andReturn(OCMClassMock([WKWebViewConfiguration class])); - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FlutterError *error; [hostAPI createFromWebViewWithIdentifier:@1 webViewIdentifier:@0 error:&error]; @@ -52,7 +52,7 @@ - (void)testSetAllowsInlineMediaPlayback { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebViewConfiguration withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebViewConfiguration withIdentifier:0]; FWFWebViewConfigurationHostApiImpl *hostAPI = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -71,7 +71,7 @@ - (void)testSetMediaTypesRequiringUserActionForPlayback { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebViewConfiguration withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebViewConfiguration withIdentifier:0]; FWFWebViewConfigurationHostApiImpl *hostAPI = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m index 2e24813317f7..065c489c09aa 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m @@ -19,7 +19,7 @@ - (void)testCreateWithIdentifier { FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] + [instanceManager addInstanceCreatedFromDart:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; @@ -35,7 +35,7 @@ - (void)testLoadRequest { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -62,7 +62,7 @@ - (void)testLoadRequestWithInvalidUrl { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -85,7 +85,7 @@ - (void)testSetCustomUserAgent { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -103,7 +103,7 @@ - (void)testURL { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -121,7 +121,7 @@ - (void)testCanGoBack { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -137,13 +137,13 @@ - (void)testSetUIDelegate { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; id mockDelegate = OCMProtocolMock(@protocol(WKUIDelegate)); - [instanceManager addFlutterCreatedInstance:mockDelegate withIdentifier:1]; + [instanceManager addInstanceCreatedFromDart:mockDelegate withIdentifier:1]; FlutterError *error; [hostAPI setUIDelegateForWebViewWithIdentifier:@0 delegateIdentifier:@1 error:&error]; @@ -157,13 +157,13 @@ - (void)testSetNavigationDelegate { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; id mockDelegate = OCMProtocolMock(@protocol(WKNavigationDelegate)); - [instanceManager addFlutterCreatedInstance:mockDelegate withIdentifier:1]; + [instanceManager addInstanceCreatedFromDart:mockDelegate withIdentifier:1]; FlutterError *error; [hostAPI setNavigationDelegateForWebViewWithIdentifier:@0 delegateIdentifier:@1 error:&error]; @@ -178,7 +178,7 @@ - (void)testEstimatedProgress { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -194,7 +194,7 @@ - (void)testloadHTMLString { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -214,7 +214,7 @@ - (void)testLoadFileURL { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -237,7 +237,7 @@ - (void)testLoadFlutterAsset { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFAssetManager *mockAssetManager = OCMClassMock([FWFAssetManager class]); OCMStub([mockAssetManager lookupKeyForAsset:@"assets/index.html"]) @@ -268,7 +268,7 @@ - (void)testCanGoForward { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -284,7 +284,7 @@ - (void)testGoBack { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -301,7 +301,7 @@ - (void)testGoForward { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -318,7 +318,7 @@ - (void)testReload { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -336,7 +336,7 @@ - (void)testTitle { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -352,7 +352,7 @@ - (void)testSetAllowsBackForwardNavigationGestures { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -373,7 +373,7 @@ - (void)testEvaluateJavaScript { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebView withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m index 3e26ccf8a161..c43eda460446 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m @@ -19,7 +19,7 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { FWFWebsiteDataStoreHostApiImpl *hostAPI = [[FWFWebsiteDataStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addFlutterCreatedInstance:[[WKWebViewConfiguration alloc] init] + [instanceManager addInstanceCreatedFromDart:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; @@ -59,7 +59,7 @@ - (void)testRemoveDataOfTypes { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ }]; - [instanceManager addFlutterCreatedInstance:mockWebsiteDataStore withIdentifier:0]; + [instanceManager addInstanceCreatedFromDart:mockWebsiteDataStore withIdentifier:0]; FWFWebsiteDataStoreHostApiImpl *hostAPI = [[FWFWebsiteDataStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m index 6e1a34facdd4..6af59cfe2654 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m @@ -31,7 +31,7 @@ - (void)createFromWebsiteDataStoreWithIdentifier:(nonnull NSNumber *)instanceId if (@available(iOS 11.0, *)) { WKWebsiteDataStore *dataStore = (WKWebsiteDataStore *)[self.instanceManager instanceForIdentifier:websiteDataStoreInstanceId.longValue]; - [self.instanceManager addFlutterCreatedInstance:dataStore.httpCookieStore + [self.instanceManager addInstanceCreatedFromDart:dataStore.httpCookieStore withIdentifier:instanceId.longValue]; } else { *error = [FlutterError diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h index b8b04104ae94..9af4ab527a07 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h @@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN typedef void (^FWFOnDeallocCallback)(long identifier); /** - * Maintains instances used to communicate with the Dart objects that represent them in Flutter. + * Maintains instances used to communicate with the corresponding objects in Dart. * * When an instance is added with an identifier, either can be used to retrieve the other. * @@ -29,7 +29,7 @@ typedef void (^FWFOnDeallocCallback)(long identifier); // TODO(bparrishMines): Pairs should not be able to be overwritten and this feature // should be replaced with a call to clear the manager in the event of a hot restart. /** - * Adds a new instance that was instantiated by Flutter. + * Adds a new instance that was instantiated from Dart. * * If an instance or identifier has already been added, it will be replaced by the new values. The * Dart InstanceManager is considered the source of truth and has the capability to overwrite stored @@ -38,15 +38,15 @@ typedef void (^FWFOnDeallocCallback)(long identifier); * @param instance The instance to be stored. * @param instanceIdentifier The identifier to be paired with instance. This value must be >= 0. */ -- (void)addFlutterCreatedInstance:(NSObject *)instance withIdentifier:(long)instanceIdentifier; +- (void)addInstanceCreatedFromDart:(NSObject *)instance withIdentifier:(long)instanceIdentifier; /** - * Adds a new instance that was instantiated by the host platform. + * Adds a new instance that was instantiated from the host platform. * * @param instance The instance to be stored. - * @return The randomly generated identifier stored with instance. + * @return The unique identifier stored with instance. */ -- (long)addHostCreatedInstance:(nonnull NSObject *)instance; +- (long)addInstanceCreatedFromHost:(nonnull NSObject *)instance; /** * Removes `instanceIdentifier` and its associated strongly referenced instance, if present, from @@ -57,7 +57,7 @@ typedef void (^FWFOnDeallocCallback)(long identifier); * @return The removed instance if the manager contains the given instanceIdentifier, otherwise * nil. */ -- (nullable NSObject *)removeStrongReferenceWithIdentifier:(long)instanceIdentifier; +- (nullable NSObject *)removeInstanceWithIdentifier:(long)instanceIdentifier; /** * Retrieves the instance associated with identifier. @@ -86,7 +86,7 @@ typedef void (^FWFOnDeallocCallback)(long identifier); /** * The number of instances stored as a strong reference. * - * Added for debuggingpurposes. + * Added for debugging purposes. */ - (NSUInteger)strongInstanceCount; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index 2e89acd7178c..fceeeba1c0d3 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -7,16 +7,15 @@ // Attaches to an object to receive a callback when the object is deallocated. @interface FWFFinalizer : NSObject -@property(nonatomic) long identifier; -// Callbacks are no longer made once FWFInstanceManager is inaccessible. -@property(nonatomic, weak) FWFOnDeallocCallback callback; -+ (void)attachToInstance:(NSObject *)instance - withIdentifier:(long)identifier - callback:(FWFOnDeallocCallback)callback; -+ (void)detachFromInstance:(NSObject *)instance; @end -@implementation FWFFinalizer +// Attaches to an object to receive a callback when the object is deallocated. +@implementation FWFFinalizer { + long _identifier; + // Callbacks are no longer made once FWFInstanceManager is inaccessible. + FWFOnDeallocCallback __weak _callback; +} + - (instancetype)initWithIdentifier:(long)identifier callback:(FWFOnDeallocCallback)callback { self = [self init]; if (self) { @@ -39,7 +38,7 @@ + (void)detachFromInstance:(NSObject *)instance { } - (void)dealloc { - self.callback(self.identifier); + _callback(_identifier); } @end @@ -71,7 +70,7 @@ - (instancetype)initWithDeallocCallback:(FWFOnDeallocCallback)callback { return self; } -- (void)addFlutterCreatedInstance:(NSObject *)instance withIdentifier:(long)instanceIdentifier { +- (void)addInstanceCreatedFromDart:(NSObject *)instance withIdentifier:(long)instanceIdentifier { NSParameterAssert(instance); NSParameterAssert(instanceIdentifier >= 0); dispatch_async(_lockQueue, ^{ @@ -79,7 +78,7 @@ - (void)addFlutterCreatedInstance:(NSObject *)instance withIdentifier:(long)inst }); } -- (long)addHostCreatedInstance:(nonnull NSObject *)instance { +- (long)addInstanceCreatedFromHost:(nonnull NSObject *)instance { NSParameterAssert(instance); long __block identifier = -1; dispatch_sync(_lockQueue, ^{ @@ -89,7 +88,7 @@ - (long)addHostCreatedInstance:(nonnull NSObject *)instance { return identifier; } -- (nullable NSObject *)removeStrongReferenceWithIdentifier:(long)instanceIdentifier { +- (nullable NSObject *)removeInstanceWithIdentifier:(long)instanceIdentifier { NSObject *__block instance = nil; dispatch_sync(_lockQueue, ^{ instance = [self.strongInstances objectForKey:@(instanceIdentifier)]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h index 08865b632834..2ac599603152 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.h @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN * Implementation of WKNavigationDelegate for FWFNavigationDelegateHostApiImpl. */ @interface FWFNavigationDelegate : FWFObject -@property(readonly, nonnull) FWFNavigationDelegateFlutterApiImpl *navigationDelegateApi; +@property(readonly, nonnull) FWFNavigationDelegateFlutterApiImpl *navigationDelegateAPI; @end /** diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m index 4afe8abcffbd..1a656549a116 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m @@ -44,7 +44,7 @@ - (instancetype)initWithBinaryMessenger:(id)binaryMessen instanceManager:(FWFInstanceManager *)instanceManager { self = [super initWithBinaryMessenger:binaryMessenger instanceManager:instanceManager]; if (self) { - _navigationDelegateApi = + _navigationDelegateAPI = [[FWFNavigationDelegateFlutterApiImpl alloc] initWithBinaryMessenger:binaryMessenger instanceManager:instanceManager]; } @@ -52,7 +52,7 @@ - (instancetype)initWithBinaryMessenger:(id)binaryMessen } - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { - [self.navigationDelegateApi didFinishNavigationForDelegate:self + [self.navigationDelegateAPI didFinishNavigationForDelegate:self webView:webView URL:webView.URL.absoluteString]; } @@ -83,7 +83,7 @@ - (void)createWithIdentifier:(nonnull NSNumber *)instanceId FWFNavigationDelegate *navigationDelegate = [[FWFNavigationDelegate alloc] initWithBinaryMessenger:self.binaryMessenger instanceManager:self.instanceManager]; - [self.instanceManager addFlutterCreatedInstance:navigationDelegate + [self.instanceManager addInstanceCreatedFromDart:navigationDelegate withIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m index 10d4b7d8de66..6065d382c646 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m @@ -76,6 +76,6 @@ - (void)removeObserverForObjectWithIdentifier:(nonnull NSNumber *)instanceId - (void)disposeObjectWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { - [self.instanceManager removeStrongReferenceWithIdentifier:instanceId.longValue]; + [self.instanceManager removeInstanceWithIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m index b209acf15f0b..88686eb7de60 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m @@ -25,7 +25,7 @@ - (WKPreferences *)preferencesForIdentifier:(NSNumber *)instanceId { - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { WKPreferences *preferences = [[WKPreferences alloc] init]; - [self.instanceManager addFlutterCreatedInstance:preferences withIdentifier:instanceId.longValue]; + [self.instanceManager addInstanceCreatedFromDart:preferences withIdentifier:instanceId.longValue]; } - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanceId @@ -33,7 +33,7 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; - [self.instanceManager addFlutterCreatedInstance:configuration.preferences + [self.instanceManager addInstanceCreatedFromDart:configuration.preferences withIdentifier:instanceId.longValue]; } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m index d9ea7cce512a..b02ba96cac0d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m @@ -32,7 +32,7 @@ - (FWFScriptMessageHandler *)scriptMessageHandlerForIdentifier:(NSNumber *)insta - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { FWFScriptMessageHandler *scriptMessageHandler = [[FWFScriptMessageHandler alloc] init]; - [self.instanceManager addFlutterCreatedInstance:scriptMessageHandler + [self.instanceManager addInstanceCreatedFromDart:scriptMessageHandler withIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m index 3d5b5df2fa9e..7737ee708269 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m @@ -27,7 +27,7 @@ - (void)createFromWebViewWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { WKWebView *webView = (WKWebView *)[self.instanceManager instanceForIdentifier:webViewInstanceId.longValue]; - [self.instanceManager addFlutterCreatedInstance:webView.scrollView + [self.instanceManager addInstanceCreatedFromDart:webView.scrollView withIdentifier:instanceId.longValue]; } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m index bc738da57195..f4b06cf3bd5a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m @@ -28,6 +28,6 @@ - (FWFUIDelegate *)delegateForIdentifier:(NSNumber *)instanceId { - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { FWFUIDelegate *uIDelegate = [[FWFUIDelegate alloc] init]; - [self.instanceManager addFlutterCreatedInstance:uIDelegate withIdentifier:instanceId.longValue]; + [self.instanceManager addInstanceCreatedFromDart:uIDelegate withIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m index 74c03aa8b898..4188961d72f1 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m @@ -29,7 +29,7 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; - [self.instanceManager addFlutterCreatedInstance:configuration.userContentController + [self.instanceManager addInstanceCreatedFromDart:configuration.userContentController withIdentifier:instanceId.longValue]; } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m index aa753b0769da..626d618d7d50 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m @@ -27,7 +27,7 @@ - (WKWebViewConfiguration *)webViewConfigurationForIdentifier:(NSNumber *)instan - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *webViewConfiguration = [[WKWebViewConfiguration alloc] init]; - [self.instanceManager addFlutterCreatedInstance:webViewConfiguration + [self.instanceManager addInstanceCreatedFromDart:webViewConfiguration withIdentifier:instanceId.longValue]; } @@ -36,7 +36,7 @@ - (void)createFromWebViewWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { WKWebView *webView = (WKWebView *)[self.instanceManager instanceForIdentifier:webViewInstanceId.longValue]; - [self.instanceManager addFlutterCreatedInstance:webView.configuration + [self.instanceManager addInstanceCreatedFromDart:webView.configuration withIdentifier:instanceId.longValue]; } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m index f78527143855..f705d78460f6 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m @@ -78,7 +78,7 @@ - (void)createWithIdentifier:(nonnull NSNumber *)instanceId instanceForIdentifier:configurationInstanceId.longValue]; FWFWebView *webView = [[FWFWebView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) configuration:configuration]; - [self.instanceManager addFlutterCreatedInstance:webView withIdentifier:instanceId.longValue]; + [self.instanceManager addInstanceCreatedFromDart:webView withIdentifier:instanceId.longValue]; } - (void)loadRequestForWebViewWithIdentifier:(nonnull NSNumber *)instanceId diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m index ffcab64d92ff..c402e632437a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m @@ -28,14 +28,14 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; - [self.instanceManager addFlutterCreatedInstance:configuration.websiteDataStore + [self.instanceManager addInstanceCreatedFromDart:configuration.websiteDataStore withIdentifier:instanceId.longValue]; } - (void)createDefaultDataStoreWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable __autoreleasing *_Nonnull) error { - [self.instanceManager addFlutterCreatedInstance:[WKWebsiteDataStore defaultDataStore] + [self.instanceManager addInstanceCreatedFromDart:[WKWebsiteDataStore defaultDataStore] withIdentifier:instanceId.longValue]; } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 760279b8c249..18d463a667ce 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart'; -/// An immutable object that can provide functional copies of themselves. +/// An immutable object that can provide functional copies of itself. /// /// All implementers are expected to be immutable as defined by the annotation. @immutable @@ -28,7 +28,7 @@ mixin Copyable { /// methods. Both are stored with the same identifier. /// /// When a weak referenced instance becomes inaccessible, -/// [onWeakReferenceRemoved] is called with it's associated identifier. +/// [onWeakReferenceRemoved] is called with its associated identifier. /// /// If an instance is retrieved and has the possiblity to be used, (e.g. calling /// [getInstance] with `returnedInstanceMayBeUsed` as `true`) a copy of the @@ -70,15 +70,15 @@ class InstanceManager { /// or becomes inaccessible. late final void Function(int) onWeakReferenceRemoved; - /// Adds a new instance that was instantiated by Flutter. + /// Adds a new instance that was instantiated by Dart. /// - /// In other words, Flutter wants to add a new instance that will represent - /// an object that will be instantied on the host platform. + /// In other words, Dart wants to add a new instance that will represent + /// an object that will be instantiated on the host platform. /// /// Throws assertion error if the instance has already been added. /// /// Returns the randomly generated id of the [instance] added. - int addDartCreatedInstance(Copyable instance) { + int addInstanceCreatedFromDart(Copyable instance) { assert(getIdentifier(instance) == null); final int identifier = _nextUniqueIdentifier(); @@ -120,7 +120,7 @@ class InstanceManager { return _strongInstances.remove(identifier); } - /// Retrieve the instance associated with identifier. + /// Retrieves the instance associated with identifier. /// /// The value returned is chosen in this order: /// 1. A weakly referenced instance asscociated with identifier. @@ -153,7 +153,7 @@ class InstanceManager { return weakInstance as T; } - /// Retrieve the identifier associated with instance. + /// Retrieves the identifier associated with instance. int? getIdentifier(Copyable instance) { return _identifiers[instance]; } @@ -166,8 +166,8 @@ class InstanceManager { /// Throws assertion error if the instance or its identifier has already been /// added. /// - /// Returns the randomly generated id of the [instance] added. - void addHostCreatedInstance(Copyable instance, int identifier) { + /// Returns unique identifier of the [instance] added. + void addInstanceCreatedFromHost(Copyable instance, int identifier) { assert(!containsIdentifier(identifier)); assert(getIdentifier(instance) == null); assert(identifier >= 0); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart index eb6052ccc42a..1f67f78e8c2d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart @@ -29,7 +29,7 @@ class UIScrollViewHostApiImpl extends UIScrollViewHostApi { UIScrollView instance, WKWebView webView, ) { - final int instanceId = instanceManager.addDartCreatedInstance(instance); + final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); return createFromWebView( instanceId, instanceManager.getIdentifier(webView)!, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart index 85b1a4a1c1b7..66739b2f914d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart @@ -236,7 +236,7 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { WKWebsiteDataStore instance, WKWebViewConfiguration configuration, ) { - final int instanceId = instanceManager.addDartCreatedInstance(instance); + final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); return createFromWebViewConfiguration( instanceId, @@ -248,7 +248,7 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { Future createDefaultDataStoreForInstances( WKWebsiteDataStore instance, ) async { - final int instanceId = instanceManager.addDartCreatedInstance(instance); + final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); return createDefaultDataStore(instanceId); } @@ -279,7 +279,7 @@ class WKScriptMessageHandlerHostApiImpl extends WKScriptMessageHandlerHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKScriptMessageHandler instance) async { - final int instanceId = instanceManager.addDartCreatedInstance(instance); + final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); return create(instanceId); } } @@ -300,7 +300,7 @@ class WKPreferencesHostApiImpl extends WKPreferencesHostApi { WKPreferences instance, WKWebViewConfiguration configuration, ) { - final int instanceId = instanceManager.addDartCreatedInstance(instance); + final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); return createFromWebViewConfiguration( instanceId, instanceManager.getIdentifier(configuration)!, @@ -335,7 +335,7 @@ class WKHttpCookieStoreHostApiImpl extends WKHttpCookieStoreHostApi { WKHttpCookieStore instance, WKWebsiteDataStore dataStore, ) { - final int instanceId = instanceManager.addDartCreatedInstance(instance); + final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); return createFromWebsiteDataStore( instanceId, instanceManager.getIdentifier(dataStore)!, @@ -371,7 +371,7 @@ class WKUserContentControllerHostApiImpl WKUserContentController instance, WKWebViewConfiguration configuration, ) async { - final int instanceId = instanceManager.addDartCreatedInstance(instance); + final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); return createFromWebViewConfiguration( instanceId, instanceManager.getIdentifier(configuration)!, @@ -443,7 +443,7 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKWebViewConfiguration instance) { - final int instanceId = instanceManager.addDartCreatedInstance(instance); + final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); return create(instanceId); } @@ -452,7 +452,7 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { WKWebViewConfiguration instance, WKWebView webView, ) async { - final int instanceId = instanceManager.addDartCreatedInstance(instance); + final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); return createFromWebView( instanceId, instanceManager.getIdentifier(webView)!, @@ -495,7 +495,7 @@ class WKUIDelegateHostApiImpl extends WKUIDelegateHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKUIDelegate instance) async { - final int instanceId = instanceManager.addDartCreatedInstance(instance); + final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); return create(instanceId); } } @@ -521,7 +521,7 @@ class WKNavigationDelegateHostApiImpl extends WKNavigationDelegateHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKNavigationDelegate instance) async { - final int instanceId = instanceManager.addDartCreatedInstance(instance); + final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); return create(instanceId); } @@ -590,7 +590,7 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { WKWebView instance, WKWebViewConfiguration configuration, ) { - final int instanceId = instanceManager.addDartCreatedInstance(instance); + final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); return create( instanceId, instanceManager.getIdentifier(configuration)!, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart index bd02efaf2542..8f33326a9557 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart @@ -13,7 +13,7 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addHostCreatedInstance(object, 0); + instanceManager.addInstanceCreatedFromHost(object, 0); expect(instanceManager.getIdentifier(object), 0); expect( @@ -28,15 +28,15 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addHostCreatedInstance(object, 0); + instanceManager.addInstanceCreatedFromHost(object, 0); expect( - () => instanceManager.addHostCreatedInstance(object, 1), + () => instanceManager.addInstanceCreatedFromHost(object, 1), throwsAssertionError, ); expect( - () => instanceManager.addHostCreatedInstance(CopyableObject(), 0), + () => instanceManager.addInstanceCreatedFromHost(CopyableObject(), 0), throwsAssertionError, ); }); @@ -47,7 +47,7 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addDartCreatedInstance(object); + instanceManager.addInstanceCreatedFromDart(object); final int? instanceId = instanceManager.getIdentifier(object); expect(instanceId, isNotNull); @@ -69,7 +69,7 @@ void main() { weakInstanceId = instanceId; }); - instanceManager.addHostCreatedInstance(object, 0); + instanceManager.addInstanceCreatedFromHost(object, 0); expect(instanceManager.removeWeakReference(object), 0); expect( @@ -85,7 +85,7 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addHostCreatedInstance(object, 0); + instanceManager.addInstanceCreatedFromHost(object, 0); expect(instanceManager.removeWeakReference(object), 0); final CopyableObject copy = instanceManager.getInstance( @@ -101,7 +101,7 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addHostCreatedInstance(object, 0); + instanceManager.addInstanceCreatedFromHost(object, 0); instanceManager.removeWeakReference(object); expect(instanceManager.removeReference(0), isA()); expect( @@ -116,7 +116,7 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addHostCreatedInstance(object, 0); + instanceManager.addInstanceCreatedFromHost(object, 0); expect(instanceManager.removeReference(0), isA()); expect( instanceManager.getInstance(0, returnedInstanceMayBeUsed: false), @@ -130,7 +130,7 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addHostCreatedInstance(object, 0); + instanceManager.addInstanceCreatedFromHost(object, 0); instanceManager.removeWeakReference(object); final CopyableObject strongCopy = instanceManager.getInstance( diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart index 58ba0ec1a385..00d75fa2e0be 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart @@ -35,7 +35,7 @@ void main() { TestNSObjectHostApi.setup(mockPlatformHostApi); object = NSObject(instanceManager: instanceManager); - instanceManager.addDartCreatedInstance(object); + instanceManager.addInstanceCreatedFromDart(object); }); tearDown(() { @@ -44,7 +44,7 @@ void main() { test('addObserver', () async { final NSObject observer = NSObject(instanceManager: instanceManager); - instanceManager.addDartCreatedInstance(observer); + instanceManager.addInstanceCreatedFromDart(observer); await object.addObserver( observer, @@ -76,7 +76,7 @@ void main() { test('removeObserver', () async { final NSObject observer = NSObject(instanceManager: instanceManager); - instanceManager.addDartCreatedInstance(observer); + instanceManager.addInstanceCreatedFromDart(observer); await object.removeObserver(observer, keyPath: 'aKeyPath'); @@ -96,7 +96,7 @@ void main() { final NSObject object = NSObject(instanceManager: instanceManager); final int identifier = - instanceManager.addDartCreatedInstance(object); + instanceManager.addInstanceCreatedFromDart(object); NSObject.dispose(object); expect(callbackIdentifier, identifier); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart index aeb4e1cc54ce..5423aa9e3d9b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart @@ -98,7 +98,7 @@ void main() { TestUIViewHostApi.setup(mockPlatformHostApi); view = UIView(instanceManager: instanceManager); - viewInstanceId = instanceManager.addDartCreatedInstance(view); + viewInstanceId = instanceManager.addInstanceCreatedFromDart(view); }); tearDown(() { From e966816217d9e53fd3dac18ee3a2c5741baf49ec Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 25 May 2022 12:46:05 -0700 Subject: [PATCH 28/40] use init constructor --- .../FWFHTTPCookieStoreHostApiTests.m | 8 +- .../ios/RunnerTests/FWFInstanceManagerTests.m | 12 +-- .../FWFNavigationDelegateHostApiTests.m | 8 +- .../ios/RunnerTests/FWFObjectHostApiTests.m | 12 +-- .../RunnerTests/FWFPreferencesHostApiTests.m | 10 +-- .../FWFScriptMessageHandlerHostApiTests.m | 4 +- .../RunnerTests/FWFScrollViewHostApiTests.m | 12 +-- .../RunnerTests/FWFUIDelegateHostApiTests.m | 4 +- .../ios/RunnerTests/FWFUIViewHostApiTests.m | 8 +- .../FWFUserContentControllerHostApiTests.m | 26 ++----- .../FWFWebViewConfigurationHostApiTests.m | 16 +--- .../ios/RunnerTests/FWFWebViewHostApiTests.m | 78 +++++-------------- .../FWFWebsiteDataStoreHostApiTests.m | 14 +--- .../ios/Classes/FWFHTTPCookieStoreHostApi.m | 2 +- .../ios/Classes/FWFInstanceManager.m | 15 +++- .../Classes/FWFNavigationDelegateHostApi.m | 2 +- .../ios/Classes/FWFPreferencesHostApi.m | 2 +- .../Classes/FWFScriptMessageHandlerHostApi.m | 2 +- .../ios/Classes/FWFScrollViewHostApi.m | 2 +- .../Classes/FWFUserContentControllerHostApi.m | 2 +- .../Classes/FWFWebViewConfigurationHostApi.m | 4 +- .../ios/Classes/FWFWebsiteDataStoreHostApi.m | 4 +- .../lib/src/ui_kit/ui_kit_api_impls.dart | 4 +- .../lib/src/web_kit/web_kit_api_impls.dart | 14 ++-- 24 files changed, 86 insertions(+), 179 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m index 3b2456e5621b..7767c1890f3d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m @@ -13,9 +13,7 @@ @interface FWFHTTPCookieStoreHostApiTests : XCTestCase @implementation FWFHTTPCookieStoreHostApiTests - (void)testCreateFromWebsiteDataStoreWithIdentifier API_AVAILABLE(ios(11.0)) { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; FWFHTTPCookieStoreHostApiImpl *hostAPI = [[FWFHTTPCookieStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -33,9 +31,7 @@ - (void)testCreateFromWebsiteDataStoreWithIdentifier API_AVAILABLE(ios(11.0)) { - (void)testSetCookie API_AVAILABLE(ios(11.0)) { WKHTTPCookieStore *mockHttpCookieStore = OCMClassMock([WKHTTPCookieStore class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockHttpCookieStore withIdentifier:0]; FWFHTTPCookieStoreHostApiImpl *hostAPI = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m index 25d35393b062..636fd8f3046f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m @@ -10,9 +10,7 @@ @interface FWFInstanceManagerTests : XCTestCase @implementation FWFInstanceManagerTests - (void)testAddFlutterCreatedInstance { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; NSObject *object = [[NSObject alloc] init]; [instanceManager addInstanceCreatedFromDart:object withIdentifier:0]; @@ -22,9 +20,7 @@ - (void)testAddFlutterCreatedInstance { } - (void)testAddHostCreatedInstance { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; NSObject *object = [[NSObject alloc] init]; [instanceManager addInstanceCreatedFromHost:object]; @@ -35,9 +31,7 @@ - (void)testAddHostCreatedInstance { } - (void)testRemoveStrongReferenceWithIdentifier { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; NSObject *object = [[NSObject alloc] init]; [instanceManager addInstanceCreatedFromDart:object withIdentifier:0]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m index c5cf8899e8ee..dd75891d4c49 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m @@ -13,9 +13,7 @@ @interface FWFNavigationDelegateHostApiTests : XCTestCase @implementation FWFNavigationDelegateHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; FWFNavigationDelegateHostApiImpl *hostAPI = [[FWFNavigationDelegateHostApiImpl alloc] initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) instanceManager:instanceManager]; @@ -30,9 +28,7 @@ - (void)testCreateWithIdentifier { } - (void)testDidFinishNavigation { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; FWFNavigationDelegateHostApiImpl *hostAPI = [[FWFNavigationDelegateHostApiImpl alloc] initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) instanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m index f923a64e8f9f..eefbfa0d1dec 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m @@ -15,9 +15,7 @@ @implementation FWFObjectHostApiTests - (void)testAddObserver { NSObject *mockObject = OCMClassMock([NSObject class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockObject withIdentifier:0]; FWFObjectHostApiImpl *hostAPI = @@ -49,9 +47,7 @@ - (void)testAddObserver { - (void)testRemoveObserver { NSObject *mockObject = OCMClassMock([NSObject class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockObject withIdentifier:0]; FWFObjectHostApiImpl *hostAPI = @@ -72,9 +68,7 @@ - (void)testRemoveObserver { - (void)testDispose { NSObject *object = [[NSObject alloc] init]; - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:object withIdentifier:0]; FWFObjectHostApiImpl *hostAPI = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m index f84ec5a1519f..f73b8aa4d254 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m @@ -13,14 +13,12 @@ @interface FWFPreferencesHostApiTests : XCTestCase @implementation FWFPreferencesHostApiTests - (void)testCreateFromWebViewConfigurationWithIdentifier { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; FWFPreferencesHostApiImpl *hostAPI = [[FWFPreferencesHostApiImpl alloc] initWithInstanceManager:instanceManager]; [instanceManager addInstanceCreatedFromDart:[[WKWebViewConfiguration alloc] init] - withIdentifier:0]; + withIdentifier:0]; FlutterError *error; [hostAPI createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -32,9 +30,7 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { - (void)testSetJavaScriptEnabled { WKPreferences *mockPreferences = OCMClassMock([WKPreferences class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockPreferences withIdentifier:0]; FWFPreferencesHostApiImpl *hostAPI = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m index df85c1f193bc..b74d21114cc4 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScriptMessageHandlerHostApiTests.m @@ -13,9 +13,7 @@ @interface FWFScriptMessageHandlerHostApiTests : XCTestCase @implementation FWFScriptMessageHandlerHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; FWFScriptMessageHandlerHostApiImpl *hostAPI = [[FWFScriptMessageHandlerHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m index b0af406f7c0b..913722045c04 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m @@ -16,9 +16,7 @@ - (void)testGetContentOffset { UIScrollView *mockScrollView = OCMClassMock([UIScrollView class]); OCMStub([mockScrollView contentOffset]).andReturn(CGPointMake(1.0, 2.0)); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockScrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostAPI = @@ -35,9 +33,7 @@ - (void)testScrollBy { UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; scrollView.contentOffset = CGPointMake(1, 2); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:scrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostAPI = @@ -53,9 +49,7 @@ - (void)testScrollBy { - (void)testSetContentOffset { UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:scrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostAPI = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m index 00bac36375c5..4ee36ae7c492 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIDelegateHostApiTests.m @@ -13,9 +13,7 @@ @interface FWFUIDelegateHostApiTests : XCTestCase @implementation FWFUIDelegateHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; FWFUIDelegateHostApiImpl *hostAPI = [[FWFUIDelegateHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m index 0c94dcb15312..9dfc2fd36900 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m @@ -15,9 +15,7 @@ @implementation FWFUIViewHostApiTests - (void)testSetBackgroundColor { UIView *mockUIView = OCMClassMock([UIView class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockUIView withIdentifier:0]; FWFUIViewHostApiImpl *hostAPI = @@ -36,9 +34,7 @@ - (void)testSetBackgroundColor { - (void)testSetOpaque { UIView *mockUIView = OCMClassMock([UIView class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockUIView withIdentifier:0]; FWFUIViewHostApiImpl *hostAPI = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m index 1b726d476734..279051287e0f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m @@ -13,14 +13,12 @@ @interface FWFUserContentControllerHostApiTests : XCTestCase @implementation FWFUserContentControllerHostApiTests - (void)testCreateFromWebViewConfigurationWithIdentifier { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; [instanceManager addInstanceCreatedFromDart:[[WKWebViewConfiguration alloc] init] - withIdentifier:0]; + withIdentifier:0]; FlutterError *error; [hostAPI createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -34,9 +32,7 @@ - (void)testAddScriptMessageHandler { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = @@ -59,9 +55,7 @@ - (void)testRemoveScriptMessageHandler { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = @@ -77,9 +71,7 @@ - (void)testRemoveAllScriptMessageHandlers API_AVAILABLE(ios(14.0)) { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = @@ -95,9 +87,7 @@ - (void)testAddUserScript { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = @@ -124,9 +114,7 @@ - (void)testRemoveAllUserScripts { WKUserContentController *mockUserContentController = OCMClassMock([WKUserContentController class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m index 6fa2e428cc73..8562c9f1ee14 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m @@ -13,9 +13,7 @@ @interface FWFWebViewConfigurationHostApiTests : XCTestCase @implementation FWFWebViewConfigurationHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; FWFWebViewConfigurationHostApiImpl *hostAPI = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -28,9 +26,7 @@ - (void)testCreateWithIdentifier { } - (void)testCreateFromWebViewWithIdentifier { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; FWFWebViewConfigurationHostApiImpl *hostAPI = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -49,9 +45,7 @@ - (void)testCreateFromWebViewWithIdentifier { - (void)testSetAllowsInlineMediaPlayback { WKWebViewConfiguration *mockWebViewConfiguration = OCMClassMock([WKWebViewConfiguration class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebViewConfiguration withIdentifier:0]; FWFWebViewConfigurationHostApiImpl *hostAPI = @@ -68,9 +62,7 @@ - (void)testSetAllowsInlineMediaPlayback { - (void)testSetMediaTypesRequiringUserActionForPlayback { WKWebViewConfiguration *mockWebViewConfiguration = OCMClassMock([WKWebViewConfiguration class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebViewConfiguration withIdentifier:0]; FWFWebViewConfigurationHostApiImpl *hostAPI = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m index 065c489c09aa..b9e9ff269551 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m @@ -13,14 +13,12 @@ @interface FWFWebViewHostApiTests : XCTestCase @implementation FWFWebViewHostApiTests - (void)testCreateWithIdentifier { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; [instanceManager addInstanceCreatedFromDart:[[WKWebViewConfiguration alloc] init] - withIdentifier:0]; + withIdentifier:0]; FlutterError *error; [hostAPI createWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -32,9 +30,7 @@ - (void)testCreateWithIdentifier { - (void)testLoadRequest { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -59,9 +55,7 @@ - (void)testLoadRequestWithInvalidUrl { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMReject([mockWebView loadRequest:OCMOCK_ANY]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -82,9 +76,7 @@ - (void)testLoadRequestWithInvalidUrl { - (void)testSetCustomUserAgent { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -100,9 +92,7 @@ - (void)testURL { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView URL]).andReturn([NSURL URLWithString:@"https://www.flutter.dev/"]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -118,9 +108,7 @@ - (void)testCanGoBack { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView canGoBack]).andReturn(YES); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -134,9 +122,7 @@ - (void)testCanGoBack { - (void)testSetUIDelegate { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -154,9 +140,7 @@ - (void)testSetUIDelegate { - (void)testSetNavigationDelegate { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -175,9 +159,7 @@ - (void)testEstimatedProgress { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView estimatedProgress]).andReturn(34.0); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -191,9 +173,7 @@ - (void)testEstimatedProgress { - (void)testloadHTMLString { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -211,9 +191,7 @@ - (void)testloadHTMLString { - (void)testLoadFileURL { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -234,9 +212,7 @@ - (void)testLoadFileURL { - (void)testLoadFlutterAsset { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFAssetManager *mockAssetManager = OCMClassMock([FWFAssetManager class]); @@ -265,9 +241,7 @@ - (void)testCanGoForward { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView canGoForward]).andReturn(NO); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -281,9 +255,7 @@ - (void)testCanGoForward { - (void)testGoBack { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -298,9 +270,7 @@ - (void)testGoBack { - (void)testGoForward { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -315,9 +285,7 @@ - (void)testGoForward { - (void)testReload { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -333,9 +301,7 @@ - (void)testTitle { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); OCMStub([mockWebView title]).andReturn(@"myTitle"); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -349,9 +315,7 @@ - (void)testTitle { - (void)testSetAllowsBackForwardNavigationGestures { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = @@ -370,9 +334,7 @@ - (void)testEvaluateJavaScript { evaluateJavaScript:@"runJavaScript" completionHandler:([OCMArg invokeBlockWithArgs:@"result", [NSNull null], nil])]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m index c43eda460446..c805f724b093 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m @@ -13,14 +13,12 @@ @interface FWFWebsiteDataStoreHostApiTests : XCTestCase @implementation FWFWebsiteDataStoreHostApiTests - (void)testCreateFromWebViewConfigurationWithIdentifier { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; FWFWebsiteDataStoreHostApiImpl *hostAPI = [[FWFWebsiteDataStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; [instanceManager addInstanceCreatedFromDart:[[WKWebViewConfiguration alloc] init] - withIdentifier:0]; + withIdentifier:0]; FlutterError *error; [hostAPI createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -30,9 +28,7 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { } - (void)testCreateDefaultDataStoreWithIdentifier { - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; FWFWebsiteDataStoreHostApiImpl *hostAPI = [[FWFWebsiteDataStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -56,9 +52,7 @@ - (void)testRemoveDataOfTypes { modifiedSince:[NSDate dateWithTimeIntervalSince1970:45.0] completionHandler:([OCMArg invokeBlock])]); - FWFInstanceManager *instanceManager = - [[FWFInstanceManager alloc] initWithDeallocCallback:^(long identifier){ - }]; + FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; [instanceManager addInstanceCreatedFromDart:mockWebsiteDataStore withIdentifier:0]; FWFWebsiteDataStoreHostApiImpl *hostAPI = diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m index 6af59cfe2654..0e801a863338 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m @@ -32,7 +32,7 @@ - (void)createFromWebsiteDataStoreWithIdentifier:(nonnull NSNumber *)instanceId WKWebsiteDataStore *dataStore = (WKWebsiteDataStore *)[self.instanceManager instanceForIdentifier:websiteDataStoreInstanceId.longValue]; [self.instanceManager addInstanceCreatedFromDart:dataStore.httpCookieStore - withIdentifier:instanceId.longValue]; + withIdentifier:instanceId.longValue]; } else { *error = [FlutterError errorWithCode:@"FWFUnsupportedVersionError" diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index fceeeba1c0d3..95c9427da972 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -57,10 +57,11 @@ @implementation FWFInstanceManager // 0 <= n < 2^16. long const FWFMinHostCreatedIdentifier = 65536; -- (instancetype)initWithDeallocCallback:(FWFOnDeallocCallback)callback { - self = [self init]; +- (instancetype)init { + self = [super init]; if (self) { - _deallocCallback = callback; + _deallocCallback = _deallocCallback ? _deallocCallback : ^(long identifier) { + }; _lockQueue = dispatch_queue_create("FWFInstanceManager", DISPATCH_QUEUE_SERIAL); _identifiers = [NSMapTable weakToStrongObjectsMapTable]; _weakInstances = [NSMapTable strongToWeakObjectsMapTable]; @@ -70,6 +71,14 @@ - (instancetype)initWithDeallocCallback:(FWFOnDeallocCallback)callback { return self; } +- (instancetype)initWithDeallocCallback:(FWFOnDeallocCallback)callback { + self = [self init]; + if (self) { + _deallocCallback = callback; + } + return self; +} + - (void)addInstanceCreatedFromDart:(NSObject *)instance withIdentifier:(long)instanceIdentifier { NSParameterAssert(instance); NSParameterAssert(instanceIdentifier >= 0); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m index 1a656549a116..cdb1add88f2d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m @@ -84,6 +84,6 @@ - (void)createWithIdentifier:(nonnull NSNumber *)instanceId [[FWFNavigationDelegate alloc] initWithBinaryMessenger:self.binaryMessenger instanceManager:self.instanceManager]; [self.instanceManager addInstanceCreatedFromDart:navigationDelegate - withIdentifier:instanceId.longValue]; + withIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m index 88686eb7de60..18db66847241 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m @@ -34,7 +34,7 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; [self.instanceManager addInstanceCreatedFromDart:configuration.preferences - withIdentifier:instanceId.longValue]; + withIdentifier:instanceId.longValue]; } - (void)setJavaScriptEnabledForPreferencesWithIdentifier:(nonnull NSNumber *)instanceId diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m index b02ba96cac0d..e46ad89cf31b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m @@ -33,6 +33,6 @@ - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { FWFScriptMessageHandler *scriptMessageHandler = [[FWFScriptMessageHandler alloc] init]; [self.instanceManager addInstanceCreatedFromDart:scriptMessageHandler - withIdentifier:instanceId.longValue]; + withIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m index 7737ee708269..7261606cdf97 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m @@ -28,7 +28,7 @@ - (void)createFromWebViewWithIdentifier:(nonnull NSNumber *)instanceId WKWebView *webView = (WKWebView *)[self.instanceManager instanceForIdentifier:webViewInstanceId.longValue]; [self.instanceManager addInstanceCreatedFromDart:webView.scrollView - withIdentifier:instanceId.longValue]; + withIdentifier:instanceId.longValue]; } - (NSArray *) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m index 4188961d72f1..e5926e722ed1 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m @@ -30,7 +30,7 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; [self.instanceManager addInstanceCreatedFromDart:configuration.userContentController - withIdentifier:instanceId.longValue]; + withIdentifier:instanceId.longValue]; } - (void)addScriptMessageHandlerForControllerWithIdentifier:(nonnull NSNumber *)instanceId diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m index 626d618d7d50..475fa61ea685 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m @@ -28,7 +28,7 @@ - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *webViewConfiguration = [[WKWebViewConfiguration alloc] init]; [self.instanceManager addInstanceCreatedFromDart:webViewConfiguration - withIdentifier:instanceId.longValue]; + withIdentifier:instanceId.longValue]; } - (void)createFromWebViewWithIdentifier:(nonnull NSNumber *)instanceId @@ -37,7 +37,7 @@ - (void)createFromWebViewWithIdentifier:(nonnull NSNumber *)instanceId WKWebView *webView = (WKWebView *)[self.instanceManager instanceForIdentifier:webViewInstanceId.longValue]; [self.instanceManager addInstanceCreatedFromDart:webView.configuration - withIdentifier:instanceId.longValue]; + withIdentifier:instanceId.longValue]; } - (void)setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:(nonnull NSNumber *)instanceId diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m index c402e632437a..dce33574f23f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m @@ -29,14 +29,14 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; [self.instanceManager addInstanceCreatedFromDart:configuration.websiteDataStore - withIdentifier:instanceId.longValue]; + withIdentifier:instanceId.longValue]; } - (void)createDefaultDataStoreWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable __autoreleasing *_Nonnull) error { [self.instanceManager addInstanceCreatedFromDart:[WKWebsiteDataStore defaultDataStore] - withIdentifier:instanceId.longValue]; + withIdentifier:instanceId.longValue]; } - (void) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart index 1f67f78e8c2d..79bcddf3af08 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart @@ -19,7 +19,7 @@ class UIScrollViewHostApiImpl extends UIScrollViewHostApi { UIScrollViewHostApiImpl({ super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -77,7 +77,7 @@ class UIViewHostApiImpl extends UIViewHostApi { UIViewHostApiImpl({ super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart index 66739b2f914d..45bd3d01b027 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart @@ -226,7 +226,7 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { WKWebsiteDataStoreHostApiImpl({ super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -272,7 +272,7 @@ class WKScriptMessageHandlerHostApiImpl extends WKScriptMessageHandlerHostApi { WKScriptMessageHandlerHostApiImpl({ super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -290,7 +290,7 @@ class WKPreferencesHostApiImpl extends WKPreferencesHostApi { WKPreferencesHostApiImpl({ super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -325,7 +325,7 @@ class WKHttpCookieStoreHostApiImpl extends WKHttpCookieStoreHostApi { WKHttpCookieStoreHostApiImpl({ super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -361,7 +361,7 @@ class WKUserContentControllerHostApiImpl WKUserContentControllerHostApiImpl({ super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -436,7 +436,7 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { WKWebViewConfigurationHostApiImpl({ super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -488,7 +488,7 @@ class WKUIDelegateHostApiImpl extends WKUIDelegateHostApi { WKUIDelegateHostApiImpl({ super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; From 3897535d10856c205f164714d9e4a50e9a4230f8 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 25 May 2022 12:52:48 -0700 Subject: [PATCH 29/40] version bump --- .../webview_flutter/webview_flutter_wkwebview/CHANGELOG.md | 4 ++++ .../webview_flutter/webview_flutter_wkwebview/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md b/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md index 00aa7293c9ad..5385113811b3 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md +++ b/packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.8.0 + +* Raises minimum Dart version to 2.17. + ## 2.7.5 * Minor fixes for new analysis options. diff --git a/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml b/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml index 7ff89c4ba682..21fb465218d3 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml +++ b/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml @@ -2,7 +2,7 @@ name: webview_flutter_wkwebview description: A Flutter plugin that provides a WebView widget based on Apple's WKWebView control. repository: https://github.com/flutter/plugins/tree/main/packages/webview_flutter/webview_flutter_wkwebview issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22 -version: 2.7.5 +version: 2.8.0 environment: sdk: ">=2.17.0 <3.0.0" From 312825a5b1ba1cf483437aa278743de5330a92fb Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 25 May 2022 14:00:11 -0700 Subject: [PATCH 30/40] update name --- .../FWFHTTPCookieStoreHostApiTests.m | 4 +- .../ios/RunnerTests/FWFInstanceManagerTests.m | 6 +-- .../FWFNavigationDelegateHostApiTests.m | 2 +- .../ios/RunnerTests/FWFObjectHostApiTests.m | 10 ++--- .../RunnerTests/FWFPreferencesHostApiTests.m | 5 +-- .../RunnerTests/FWFScrollViewHostApiTests.m | 6 +-- .../ios/RunnerTests/FWFUIViewHostApiTests.m | 4 +- .../FWFUserContentControllerHostApiTests.m | 15 +++---- .../FWFWebViewConfigurationHostApiTests.m | 6 +-- .../ios/RunnerTests/FWFWebViewHostApiTests.m | 43 +++++++++---------- .../FWFWebsiteDataStoreHostApiTests.m | 5 +-- .../ios/Classes/FWFHTTPCookieStoreHostApi.m | 4 +- .../ios/Classes/FWFInstanceManager.h | 4 +- .../ios/Classes/FWFInstanceManager.m | 4 +- .../Classes/FWFNavigationDelegateHostApi.m | 4 +- .../ios/Classes/FWFPreferencesHostApi.m | 6 +-- .../Classes/FWFScriptMessageHandlerHostApi.m | 4 +- .../ios/Classes/FWFScrollViewHostApi.m | 4 +- .../ios/Classes/FWFUIDelegateHostApi.m | 2 +- .../Classes/FWFUserContentControllerHostApi.m | 4 +- .../Classes/FWFWebViewConfigurationHostApi.m | 8 ++-- .../ios/Classes/FWFWebViewHostApi.m | 2 +- .../ios/Classes/FWFWebsiteDataStoreHostApi.m | 8 ++-- .../lib/src/common/instance_manager.dart | 4 +- .../lib/src/ui_kit/ui_kit_api_impls.dart | 2 +- .../lib/src/web_kit/web_kit_api_impls.dart | 22 +++++----- .../src/common/instance_manager_test.dart | 20 ++++----- .../test/src/foundation/foundation_test.dart | 9 ++-- .../test/src/ui_kit/ui_kit_test.dart | 2 +- 29 files changed, 107 insertions(+), 112 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m index 7767c1890f3d..45eefc3897ec 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFHTTPCookieStoreHostApiTests.m @@ -19,7 +19,7 @@ - (void)testCreateFromWebsiteDataStoreWithIdentifier API_AVAILABLE(ios(11.0)) { WKWebsiteDataStore *mockDataStore = OCMClassMock([WKWebsiteDataStore class]); OCMStub([mockDataStore httpCookieStore]).andReturn(OCMClassMock([WKHTTPCookieStore class])); - [instanceManager addInstanceCreatedFromDart:mockDataStore withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockDataStore withIdentifier:0]; FlutterError *error; [hostAPI createFromWebsiteDataStoreWithIdentifier:@1 dataStoreIdentifier:@0 error:&error]; @@ -32,7 +32,7 @@ - (void)testSetCookie API_AVAILABLE(ios(11.0)) { WKHTTPCookieStore *mockHttpCookieStore = OCMClassMock([WKHTTPCookieStore class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockHttpCookieStore withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockHttpCookieStore withIdentifier:0]; FWFHTTPCookieStoreHostApiImpl *hostAPI = [[FWFHTTPCookieStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m index 636fd8f3046f..f255e4ee34a5 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m @@ -13,7 +13,7 @@ - (void)testAddFlutterCreatedInstance { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; NSObject *object = [[NSObject alloc] init]; - [instanceManager addInstanceCreatedFromDart:object withIdentifier:0]; + [instanceManager addDartCreatedInstance:object withIdentifier:0]; XCTAssertEqualObjects([instanceManager instanceForIdentifier:0], object); XCTAssertEqual([instanceManager identifierForInstance:object identifierWillBePassedToFlutter:NO], 0); @@ -22,7 +22,7 @@ - (void)testAddFlutterCreatedInstance { - (void)testAddHostCreatedInstance { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; NSObject *object = [[NSObject alloc] init]; - [instanceManager addInstanceCreatedFromHost:object]; + [instanceManager addHostCreatedInstance:object]; long identifier = [instanceManager identifierForInstance:object identifierWillBePassedToFlutter:NO]; @@ -34,7 +34,7 @@ - (void)testRemoveStrongReferenceWithIdentifier { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; NSObject *object = [[NSObject alloc] init]; - [instanceManager addInstanceCreatedFromDart:object withIdentifier:0]; + [instanceManager addDartCreatedInstance:object withIdentifier:0]; XCTAssertEqualObjects([instanceManager removeInstanceWithIdentifier:0], object); XCTAssertEqual([instanceManager strongInstanceCount], 0); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m index dd75891d4c49..206137e301f5 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFNavigationDelegateHostApiTests.m @@ -48,7 +48,7 @@ - (void)testDidFinishNavigation { WKWebView *mockWebView = OCMClassMock([WKWebView class]); OCMStub([mockWebView URL]).andReturn([NSURL URLWithString:@"https://flutter.dev/"]); - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:1]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:1]; [mockDelegate webView:mockWebView didFinishNavigation:OCMClassMock([WKNavigation class])]; OCMVerify([mockFlutterApi didFinishNavigationForDelegateWithIdentifier:@0 diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m index eefbfa0d1dec..3a381295ea0d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m @@ -16,13 +16,13 @@ - (void)testAddObserver { NSObject *mockObject = OCMClassMock([NSObject class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockObject withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockObject withIdentifier:0]; FWFObjectHostApiImpl *hostAPI = [[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager]; NSObject *observerObject = [[NSObject alloc] init]; - [instanceManager addInstanceCreatedFromDart:observerObject withIdentifier:1]; + [instanceManager addDartCreatedInstance:observerObject withIdentifier:1]; FlutterError *error; [hostAPI @@ -48,13 +48,13 @@ - (void)testRemoveObserver { NSObject *mockObject = OCMClassMock([NSObject class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockObject withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockObject withIdentifier:0]; FWFObjectHostApiImpl *hostAPI = [[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager]; NSObject *observerObject = [[NSObject alloc] init]; - [instanceManager addInstanceCreatedFromDart:observerObject withIdentifier:1]; + [instanceManager addDartCreatedInstance:observerObject withIdentifier:1]; FlutterError *error; [hostAPI removeObserverForObjectWithIdentifier:@0 @@ -69,7 +69,7 @@ - (void)testDispose { NSObject *object = [[NSObject alloc] init]; FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:object withIdentifier:0]; + [instanceManager addDartCreatedInstance:object withIdentifier:0]; FWFObjectHostApiImpl *hostAPI = [[FWFObjectHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m index f73b8aa4d254..95b81ad5c389 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFPreferencesHostApiTests.m @@ -17,8 +17,7 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { FWFPreferencesHostApiImpl *hostAPI = [[FWFPreferencesHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addInstanceCreatedFromDart:[[WKWebViewConfiguration alloc] init] - withIdentifier:0]; + [instanceManager addDartCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; [hostAPI createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -31,7 +30,7 @@ - (void)testSetJavaScriptEnabled { WKPreferences *mockPreferences = OCMClassMock([WKPreferences class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockPreferences withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockPreferences withIdentifier:0]; FWFPreferencesHostApiImpl *hostAPI = [[FWFPreferencesHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m index 913722045c04..ede8dcf35d89 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFScrollViewHostApiTests.m @@ -17,7 +17,7 @@ - (void)testGetContentOffset { OCMStub([mockScrollView contentOffset]).andReturn(CGPointMake(1.0, 2.0)); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockScrollView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockScrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostAPI = [[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -34,7 +34,7 @@ - (void)testScrollBy { scrollView.contentOffset = CGPointMake(1, 2); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:scrollView withIdentifier:0]; + [instanceManager addDartCreatedInstance:scrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostAPI = [[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -50,7 +50,7 @@ - (void)testSetContentOffset { UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:scrollView withIdentifier:0]; + [instanceManager addDartCreatedInstance:scrollView withIdentifier:0]; FWFScrollViewHostApiImpl *hostAPI = [[FWFScrollViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m index 9dfc2fd36900..dbf444fbc84e 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m @@ -16,7 +16,7 @@ - (void)testSetBackgroundColor { UIView *mockUIView = OCMClassMock([UIView class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockUIView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockUIView withIdentifier:0]; FWFUIViewHostApiImpl *hostAPI = [[FWFUIViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -35,7 +35,7 @@ - (void)testSetOpaque { UIView *mockUIView = OCMClassMock([UIView class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockUIView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockUIView withIdentifier:0]; FWFUIViewHostApiImpl *hostAPI = [[FWFUIViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m index 279051287e0f..4f523e6da402 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUserContentControllerHostApiTests.m @@ -17,8 +17,7 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addInstanceCreatedFromDart:[[WKWebViewConfiguration alloc] init] - withIdentifier:0]; + [instanceManager addDartCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; [hostAPI createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -33,14 +32,14 @@ - (void)testAddScriptMessageHandler { OCMClassMock([WKUserContentController class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; id mockMessageHandler = OCMProtocolMock(@protocol(WKScriptMessageHandler)); - [instanceManager addInstanceCreatedFromDart:mockMessageHandler withIdentifier:1]; + [instanceManager addDartCreatedInstance:mockMessageHandler withIdentifier:1]; FlutterError *error; [hostAPI addScriptMessageHandlerForControllerWithIdentifier:@0 @@ -56,7 +55,7 @@ - (void)testRemoveScriptMessageHandler { OCMClassMock([WKUserContentController class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -72,7 +71,7 @@ - (void)testRemoveAllScriptMessageHandlers API_AVAILABLE(ios(14.0)) { OCMClassMock([WKUserContentController class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -88,7 +87,7 @@ - (void)testAddUserScript { OCMClassMock([WKUserContentController class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -115,7 +114,7 @@ - (void)testRemoveAllUserScripts { OCMClassMock([WKUserContentController class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockUserContentController withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockUserContentController withIdentifier:0]; FWFUserContentControllerHostApiImpl *hostAPI = [[FWFUserContentControllerHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m index 8562c9f1ee14..e09e16b62e45 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewConfigurationHostApiTests.m @@ -32,7 +32,7 @@ - (void)testCreateFromWebViewWithIdentifier { WKWebView *mockWebView = OCMClassMock([WKWebView class]); OCMStub([mockWebView configuration]).andReturn(OCMClassMock([WKWebViewConfiguration class])); - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FlutterError *error; [hostAPI createFromWebViewWithIdentifier:@1 webViewIdentifier:@0 error:&error]; @@ -46,7 +46,7 @@ - (void)testSetAllowsInlineMediaPlayback { WKWebViewConfiguration *mockWebViewConfiguration = OCMClassMock([WKWebViewConfiguration class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebViewConfiguration withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebViewConfiguration withIdentifier:0]; FWFWebViewConfigurationHostApiImpl *hostAPI = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -63,7 +63,7 @@ - (void)testSetMediaTypesRequiringUserActionForPlayback { WKWebViewConfiguration *mockWebViewConfiguration = OCMClassMock([WKWebViewConfiguration class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebViewConfiguration withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebViewConfiguration withIdentifier:0]; FWFWebViewConfigurationHostApiImpl *hostAPI = [[FWFWebViewConfigurationHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m index b9e9ff269551..0c71e3391dbb 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebViewHostApiTests.m @@ -17,8 +17,7 @@ - (void)testCreateWithIdentifier { FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addInstanceCreatedFromDart:[[WKWebViewConfiguration alloc] init] - withIdentifier:0]; + [instanceManager addDartCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; [hostAPI createWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -31,7 +30,7 @@ - (void)testLoadRequest { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -56,7 +55,7 @@ - (void)testLoadRequestWithInvalidUrl { OCMReject([mockWebView loadRequest:OCMOCK_ANY]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -77,7 +76,7 @@ - (void)testSetCustomUserAgent { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -93,7 +92,7 @@ - (void)testURL { OCMStub([mockWebView URL]).andReturn([NSURL URLWithString:@"https://www.flutter.dev/"]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -109,7 +108,7 @@ - (void)testCanGoBack { OCMStub([mockWebView canGoBack]).andReturn(YES); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -123,13 +122,13 @@ - (void)testSetUIDelegate { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; id mockDelegate = OCMProtocolMock(@protocol(WKUIDelegate)); - [instanceManager addInstanceCreatedFromDart:mockDelegate withIdentifier:1]; + [instanceManager addDartCreatedInstance:mockDelegate withIdentifier:1]; FlutterError *error; [hostAPI setUIDelegateForWebViewWithIdentifier:@0 delegateIdentifier:@1 error:&error]; @@ -141,13 +140,13 @@ - (void)testSetNavigationDelegate { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; id mockDelegate = OCMProtocolMock(@protocol(WKNavigationDelegate)); - [instanceManager addInstanceCreatedFromDart:mockDelegate withIdentifier:1]; + [instanceManager addDartCreatedInstance:mockDelegate withIdentifier:1]; FlutterError *error; [hostAPI setNavigationDelegateForWebViewWithIdentifier:@0 delegateIdentifier:@1 error:&error]; @@ -160,7 +159,7 @@ - (void)testEstimatedProgress { OCMStub([mockWebView estimatedProgress]).andReturn(34.0); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -174,7 +173,7 @@ - (void)testloadHTMLString { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -192,7 +191,7 @@ - (void)testLoadFileURL { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -213,7 +212,7 @@ - (void)testLoadFlutterAsset { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFAssetManager *mockAssetManager = OCMClassMock([FWFAssetManager class]); OCMStub([mockAssetManager lookupKeyForAsset:@"assets/index.html"]) @@ -242,7 +241,7 @@ - (void)testCanGoForward { OCMStub([mockWebView canGoForward]).andReturn(NO); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -256,7 +255,7 @@ - (void)testGoBack { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -271,7 +270,7 @@ - (void)testGoForward { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -286,7 +285,7 @@ - (void)testReload { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -302,7 +301,7 @@ - (void)testTitle { OCMStub([mockWebView title]).andReturn(@"myTitle"); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -316,7 +315,7 @@ - (void)testSetAllowsBackForwardNavigationGestures { FWFWebView *mockWebView = OCMClassMock([FWFWebView class]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; @@ -335,7 +334,7 @@ - (void)testEvaluateJavaScript { completionHandler:([OCMArg invokeBlockWithArgs:@"result", [NSNull null], nil])]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebView withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebView withIdentifier:0]; FWFWebViewHostApiImpl *hostAPI = [[FWFWebViewHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m index c805f724b093..18bc21facd21 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFWebsiteDataStoreHostApiTests.m @@ -17,8 +17,7 @@ - (void)testCreateFromWebViewConfigurationWithIdentifier { FWFWebsiteDataStoreHostApiImpl *hostAPI = [[FWFWebsiteDataStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; - [instanceManager addInstanceCreatedFromDart:[[WKWebViewConfiguration alloc] init] - withIdentifier:0]; + [instanceManager addDartCreatedInstance:[[WKWebViewConfiguration alloc] init] withIdentifier:0]; FlutterError *error; [hostAPI createFromWebViewConfigurationWithIdentifier:@1 configurationIdentifier:@0 error:&error]; @@ -53,7 +52,7 @@ - (void)testRemoveDataOfTypes { completionHandler:([OCMArg invokeBlock])]); FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; - [instanceManager addInstanceCreatedFromDart:mockWebsiteDataStore withIdentifier:0]; + [instanceManager addDartCreatedInstance:mockWebsiteDataStore withIdentifier:0]; FWFWebsiteDataStoreHostApiImpl *hostAPI = [[FWFWebsiteDataStoreHostApiImpl alloc] initWithInstanceManager:instanceManager]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m index 0e801a863338..c6bd1053c1e7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFHTTPCookieStoreHostApi.m @@ -31,8 +31,8 @@ - (void)createFromWebsiteDataStoreWithIdentifier:(nonnull NSNumber *)instanceId if (@available(iOS 11.0, *)) { WKWebsiteDataStore *dataStore = (WKWebsiteDataStore *)[self.instanceManager instanceForIdentifier:websiteDataStoreInstanceId.longValue]; - [self.instanceManager addInstanceCreatedFromDart:dataStore.httpCookieStore - withIdentifier:instanceId.longValue]; + [self.instanceManager addDartCreatedInstance:dataStore.httpCookieStore + withIdentifier:instanceId.longValue]; } else { *error = [FlutterError errorWithCode:@"FWFUnsupportedVersionError" diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h index 9af4ab527a07..8b3ff5129498 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h @@ -38,7 +38,7 @@ typedef void (^FWFOnDeallocCallback)(long identifier); * @param instance The instance to be stored. * @param instanceIdentifier The identifier to be paired with instance. This value must be >= 0. */ -- (void)addInstanceCreatedFromDart:(NSObject *)instance withIdentifier:(long)instanceIdentifier; +- (void)addDartCreatedInstance:(NSObject *)instance withIdentifier:(long)instanceIdentifier; /** * Adds a new instance that was instantiated from the host platform. @@ -46,7 +46,7 @@ typedef void (^FWFOnDeallocCallback)(long identifier); * @param instance The instance to be stored. * @return The unique identifier stored with instance. */ -- (long)addInstanceCreatedFromHost:(nonnull NSObject *)instance; +- (long)addHostCreatedInstance:(nonnull NSObject *)instance; /** * Removes `instanceIdentifier` and its associated strongly referenced instance, if present, from diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index 95c9427da972..db60a90e2010 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -79,7 +79,7 @@ - (instancetype)initWithDeallocCallback:(FWFOnDeallocCallback)callback { return self; } -- (void)addInstanceCreatedFromDart:(NSObject *)instance withIdentifier:(long)instanceIdentifier { +- (void)addDartCreatedInstance:(NSObject *)instance withIdentifier:(long)instanceIdentifier { NSParameterAssert(instance); NSParameterAssert(instanceIdentifier >= 0); dispatch_async(_lockQueue, ^{ @@ -87,7 +87,7 @@ - (void)addInstanceCreatedFromDart:(NSObject *)instance withIdentifier:(long)ins }); } -- (long)addInstanceCreatedFromHost:(nonnull NSObject *)instance { +- (long)addHostCreatedInstance:(nonnull NSObject *)instance { NSParameterAssert(instance); long __block identifier = -1; dispatch_sync(_lockQueue, ^{ diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m index cdb1add88f2d..0c2268b36d98 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m @@ -83,7 +83,7 @@ - (void)createWithIdentifier:(nonnull NSNumber *)instanceId FWFNavigationDelegate *navigationDelegate = [[FWFNavigationDelegate alloc] initWithBinaryMessenger:self.binaryMessenger instanceManager:self.instanceManager]; - [self.instanceManager addInstanceCreatedFromDart:navigationDelegate - withIdentifier:instanceId.longValue]; + [self.instanceManager addDartCreatedInstance:navigationDelegate + withIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m index 18db66847241..e06c69a5c062 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m @@ -25,7 +25,7 @@ - (WKPreferences *)preferencesForIdentifier:(NSNumber *)instanceId { - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { WKPreferences *preferences = [[WKPreferences alloc] init]; - [self.instanceManager addInstanceCreatedFromDart:preferences withIdentifier:instanceId.longValue]; + [self.instanceManager addDartCreatedInstance:preferences withIdentifier:instanceId.longValue]; } - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanceId @@ -33,8 +33,8 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; - [self.instanceManager addInstanceCreatedFromDart:configuration.preferences - withIdentifier:instanceId.longValue]; + [self.instanceManager addDartCreatedInstance:configuration.preferences + withIdentifier:instanceId.longValue]; } - (void)setJavaScriptEnabledForPreferencesWithIdentifier:(nonnull NSNumber *)instanceId diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m index e46ad89cf31b..ed4eb8ccd244 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScriptMessageHandlerHostApi.m @@ -32,7 +32,7 @@ - (FWFScriptMessageHandler *)scriptMessageHandlerForIdentifier:(NSNumber *)insta - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { FWFScriptMessageHandler *scriptMessageHandler = [[FWFScriptMessageHandler alloc] init]; - [self.instanceManager addInstanceCreatedFromDart:scriptMessageHandler - withIdentifier:instanceId.longValue]; + [self.instanceManager addDartCreatedInstance:scriptMessageHandler + withIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m index 7261606cdf97..da3eda4fd554 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFScrollViewHostApi.m @@ -27,8 +27,8 @@ - (void)createFromWebViewWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { WKWebView *webView = (WKWebView *)[self.instanceManager instanceForIdentifier:webViewInstanceId.longValue]; - [self.instanceManager addInstanceCreatedFromDart:webView.scrollView - withIdentifier:instanceId.longValue]; + [self.instanceManager addDartCreatedInstance:webView.scrollView + withIdentifier:instanceId.longValue]; } - (NSArray *) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m index f4b06cf3bd5a..5110bccd623a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m @@ -28,6 +28,6 @@ - (FWFUIDelegate *)delegateForIdentifier:(NSNumber *)instanceId { - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { FWFUIDelegate *uIDelegate = [[FWFUIDelegate alloc] init]; - [self.instanceManager addInstanceCreatedFromDart:uIDelegate withIdentifier:instanceId.longValue]; + [self.instanceManager addDartCreatedInstance:uIDelegate withIdentifier:instanceId.longValue]; } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m index e5926e722ed1..dba5b7697a66 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUserContentControllerHostApi.m @@ -29,8 +29,8 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; - [self.instanceManager addInstanceCreatedFromDart:configuration.userContentController - withIdentifier:instanceId.longValue]; + [self.instanceManager addDartCreatedInstance:configuration.userContentController + withIdentifier:instanceId.longValue]; } - (void)addScriptMessageHandlerForControllerWithIdentifier:(nonnull NSNumber *)instanceId diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m index 475fa61ea685..189e532afd44 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewConfigurationHostApi.m @@ -27,8 +27,8 @@ - (WKWebViewConfiguration *)webViewConfigurationForIdentifier:(NSNumber *)instan - (void)createWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *webViewConfiguration = [[WKWebViewConfiguration alloc] init]; - [self.instanceManager addInstanceCreatedFromDart:webViewConfiguration - withIdentifier:instanceId.longValue]; + [self.instanceManager addDartCreatedInstance:webViewConfiguration + withIdentifier:instanceId.longValue]; } - (void)createFromWebViewWithIdentifier:(nonnull NSNumber *)instanceId @@ -36,8 +36,8 @@ - (void)createFromWebViewWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error { WKWebView *webView = (WKWebView *)[self.instanceManager instanceForIdentifier:webViewInstanceId.longValue]; - [self.instanceManager addInstanceCreatedFromDart:webView.configuration - withIdentifier:instanceId.longValue]; + [self.instanceManager addDartCreatedInstance:webView.configuration + withIdentifier:instanceId.longValue]; } - (void)setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:(nonnull NSNumber *)instanceId diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m index f705d78460f6..f93449ffafbb 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m @@ -78,7 +78,7 @@ - (void)createWithIdentifier:(nonnull NSNumber *)instanceId instanceForIdentifier:configurationInstanceId.longValue]; FWFWebView *webView = [[FWFWebView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) configuration:configuration]; - [self.instanceManager addInstanceCreatedFromDart:webView withIdentifier:instanceId.longValue]; + [self.instanceManager addDartCreatedInstance:webView withIdentifier:instanceId.longValue]; } - (void)loadRequestForWebViewWithIdentifier:(nonnull NSNumber *)instanceId diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m index dce33574f23f..ae17ed7254d7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebsiteDataStoreHostApi.m @@ -28,15 +28,15 @@ - (void)createFromWebViewConfigurationWithIdentifier:(nonnull NSNumber *)instanc error:(FlutterError *_Nullable *_Nonnull)error { WKWebViewConfiguration *configuration = (WKWebViewConfiguration *)[self.instanceManager instanceForIdentifier:configurationInstanceId.longValue]; - [self.instanceManager addInstanceCreatedFromDart:configuration.websiteDataStore - withIdentifier:instanceId.longValue]; + [self.instanceManager addDartCreatedInstance:configuration.websiteDataStore + withIdentifier:instanceId.longValue]; } - (void)createDefaultDataStoreWithIdentifier:(nonnull NSNumber *)instanceId error:(FlutterError *_Nullable __autoreleasing *_Nonnull) error { - [self.instanceManager addInstanceCreatedFromDart:[WKWebsiteDataStore defaultDataStore] - withIdentifier:instanceId.longValue]; + [self.instanceManager addDartCreatedInstance:[WKWebsiteDataStore defaultDataStore] + withIdentifier:instanceId.longValue]; } - (void) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 18d463a667ce..defae1fffe14 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -78,7 +78,7 @@ class InstanceManager { /// Throws assertion error if the instance has already been added. /// /// Returns the randomly generated id of the [instance] added. - int addInstanceCreatedFromDart(Copyable instance) { + int addDartCreatedInstance(Copyable instance) { assert(getIdentifier(instance) == null); final int identifier = _nextUniqueIdentifier(); @@ -167,7 +167,7 @@ class InstanceManager { /// added. /// /// Returns unique identifier of the [instance] added. - void addInstanceCreatedFromHost(Copyable instance, int identifier) { + void addHostCreatedInstance(Copyable instance, int identifier) { assert(!containsIdentifier(identifier)); assert(getIdentifier(instance) == null); assert(identifier >= 0); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart index 79bcddf3af08..98d1599a277c 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart @@ -29,7 +29,7 @@ class UIScrollViewHostApiImpl extends UIScrollViewHostApi { UIScrollView instance, WKWebView webView, ) { - final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return createFromWebView( instanceId, instanceManager.getIdentifier(webView)!, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart index 45bd3d01b027..906695c22432 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart @@ -236,7 +236,7 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { WKWebsiteDataStore instance, WKWebViewConfiguration configuration, ) { - final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return createFromWebViewConfiguration( instanceId, @@ -248,7 +248,7 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { Future createDefaultDataStoreForInstances( WKWebsiteDataStore instance, ) async { - final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return createDefaultDataStore(instanceId); } @@ -279,7 +279,7 @@ class WKScriptMessageHandlerHostApiImpl extends WKScriptMessageHandlerHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKScriptMessageHandler instance) async { - final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return create(instanceId); } } @@ -300,7 +300,7 @@ class WKPreferencesHostApiImpl extends WKPreferencesHostApi { WKPreferences instance, WKWebViewConfiguration configuration, ) { - final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return createFromWebViewConfiguration( instanceId, instanceManager.getIdentifier(configuration)!, @@ -335,7 +335,7 @@ class WKHttpCookieStoreHostApiImpl extends WKHttpCookieStoreHostApi { WKHttpCookieStore instance, WKWebsiteDataStore dataStore, ) { - final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return createFromWebsiteDataStore( instanceId, instanceManager.getIdentifier(dataStore)!, @@ -371,7 +371,7 @@ class WKUserContentControllerHostApiImpl WKUserContentController instance, WKWebViewConfiguration configuration, ) async { - final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return createFromWebViewConfiguration( instanceId, instanceManager.getIdentifier(configuration)!, @@ -443,7 +443,7 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKWebViewConfiguration instance) { - final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return create(instanceId); } @@ -452,7 +452,7 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { WKWebViewConfiguration instance, WKWebView webView, ) async { - final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return createFromWebView( instanceId, instanceManager.getIdentifier(webView)!, @@ -495,7 +495,7 @@ class WKUIDelegateHostApiImpl extends WKUIDelegateHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKUIDelegate instance) async { - final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return create(instanceId); } } @@ -521,7 +521,7 @@ class WKNavigationDelegateHostApiImpl extends WKNavigationDelegateHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKNavigationDelegate instance) async { - final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return create(instanceId); } @@ -590,7 +590,7 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { WKWebView instance, WKWebViewConfiguration configuration, ) { - final int instanceId = instanceManager.addInstanceCreatedFromDart(instance); + final int instanceId = instanceManager.addDartCreatedInstance(instance); return create( instanceId, instanceManager.getIdentifier(configuration)!, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart index 8f33326a9557..bd02efaf2542 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart @@ -13,7 +13,7 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addInstanceCreatedFromHost(object, 0); + instanceManager.addHostCreatedInstance(object, 0); expect(instanceManager.getIdentifier(object), 0); expect( @@ -28,15 +28,15 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addInstanceCreatedFromHost(object, 0); + instanceManager.addHostCreatedInstance(object, 0); expect( - () => instanceManager.addInstanceCreatedFromHost(object, 1), + () => instanceManager.addHostCreatedInstance(object, 1), throwsAssertionError, ); expect( - () => instanceManager.addInstanceCreatedFromHost(CopyableObject(), 0), + () => instanceManager.addHostCreatedInstance(CopyableObject(), 0), throwsAssertionError, ); }); @@ -47,7 +47,7 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addInstanceCreatedFromDart(object); + instanceManager.addDartCreatedInstance(object); final int? instanceId = instanceManager.getIdentifier(object); expect(instanceId, isNotNull); @@ -69,7 +69,7 @@ void main() { weakInstanceId = instanceId; }); - instanceManager.addInstanceCreatedFromHost(object, 0); + instanceManager.addHostCreatedInstance(object, 0); expect(instanceManager.removeWeakReference(object), 0); expect( @@ -85,7 +85,7 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addInstanceCreatedFromHost(object, 0); + instanceManager.addHostCreatedInstance(object, 0); expect(instanceManager.removeWeakReference(object), 0); final CopyableObject copy = instanceManager.getInstance( @@ -101,7 +101,7 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addInstanceCreatedFromHost(object, 0); + instanceManager.addHostCreatedInstance(object, 0); instanceManager.removeWeakReference(object); expect(instanceManager.removeReference(0), isA()); expect( @@ -116,7 +116,7 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addInstanceCreatedFromHost(object, 0); + instanceManager.addHostCreatedInstance(object, 0); expect(instanceManager.removeReference(0), isA()); expect( instanceManager.getInstance(0, returnedInstanceMayBeUsed: false), @@ -130,7 +130,7 @@ void main() { final InstanceManager instanceManager = InstanceManager(onWeakReferenceRemoved: (_) {}); - instanceManager.addInstanceCreatedFromHost(object, 0); + instanceManager.addHostCreatedInstance(object, 0); instanceManager.removeWeakReference(object); final CopyableObject strongCopy = instanceManager.getInstance( diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart index 00d75fa2e0be..ca84369c9789 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/foundation/foundation_test.dart @@ -35,7 +35,7 @@ void main() { TestNSObjectHostApi.setup(mockPlatformHostApi); object = NSObject(instanceManager: instanceManager); - instanceManager.addInstanceCreatedFromDart(object); + instanceManager.addDartCreatedInstance(object); }); tearDown(() { @@ -44,7 +44,7 @@ void main() { test('addObserver', () async { final NSObject observer = NSObject(instanceManager: instanceManager); - instanceManager.addInstanceCreatedFromDart(observer); + instanceManager.addDartCreatedInstance(observer); await object.addObserver( observer, @@ -76,7 +76,7 @@ void main() { test('removeObserver', () async { final NSObject observer = NSObject(instanceManager: instanceManager); - instanceManager.addInstanceCreatedFromDart(observer); + instanceManager.addDartCreatedInstance(observer); await object.removeObserver(observer, keyPath: 'aKeyPath'); @@ -95,8 +95,7 @@ void main() { }); final NSObject object = NSObject(instanceManager: instanceManager); - final int identifier = - instanceManager.addInstanceCreatedFromDart(object); + final int identifier = instanceManager.addDartCreatedInstance(object); NSObject.dispose(object); expect(callbackIdentifier, identifier); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart index 5423aa9e3d9b..aeb4e1cc54ce 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/ui_kit/ui_kit_test.dart @@ -98,7 +98,7 @@ void main() { TestUIViewHostApi.setup(mockPlatformHostApi); view = UIView(instanceManager: instanceManager); - viewInstanceId = instanceManager.addInstanceCreatedFromDart(view); + viewInstanceId = instanceManager.addDartCreatedInstance(view); }); tearDown(() { From 2b7a9af34f92ac41939850f0d46cfe48ab0bc108 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 25 May 2022 15:53:07 -0700 Subject: [PATCH 31/40] undo changes to webview_flutter --- .../webview_flutter/example/ios/Flutter/AppFrameworkInfo.plist | 2 +- packages/webview_flutter/webview_flutter/example/ios/Podfile | 2 +- .../ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../webview_flutter/example/ios/Runner/Info.plist | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/webview_flutter/webview_flutter/example/ios/Flutter/AppFrameworkInfo.plist b/packages/webview_flutter/webview_flutter/example/ios/Flutter/AppFrameworkInfo.plist index 9625e105df39..8d4492f977ad 100644 --- a/packages/webview_flutter/webview_flutter/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/webview_flutter/webview_flutter/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 11.0 + 9.0 diff --git a/packages/webview_flutter/webview_flutter/example/ios/Podfile b/packages/webview_flutter/webview_flutter/example/ios/Podfile index d01e899e347b..66509fcae284 100644 --- a/packages/webview_flutter/webview_flutter/example/ios/Podfile +++ b/packages/webview_flutter/webview_flutter/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '11.0' +# platform :ios, '9.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index cb713d767632..d7453a8ce862 100644 --- a/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ UIViewControllerBasedStatusBarAppearance - CADisableMinimumFrameDurationOnPhone - From 86b193a8d7456fb4443bff2e9892a2486240205d Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 25 May 2022 15:53:48 -0700 Subject: [PATCH 32/40] add api impls --- .../src/foundation/foundation_api_impls.dart | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart new file mode 100644 index 000000000000..9575cb51c648 --- /dev/null +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation_api_impls.dart @@ -0,0 +1,134 @@ +// 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. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; + +import '../common/instance_manager.dart'; +import '../common/web_kit.pigeon.dart'; +import 'foundation.dart'; + +Iterable + _toNSKeyValueObservingOptionsEnumData( + Iterable options, +) { + return options.map(( + NSKeyValueObservingOptions option, + ) { + late final NSKeyValueObservingOptionsEnum? value; + switch (option) { + case NSKeyValueObservingOptions.newValue: + value = NSKeyValueObservingOptionsEnum.newValue; + break; + case NSKeyValueObservingOptions.oldValue: + value = NSKeyValueObservingOptionsEnum.oldValue; + break; + case NSKeyValueObservingOptions.initialValue: + value = NSKeyValueObservingOptionsEnum.initialValue; + break; + case NSKeyValueObservingOptions.priorNotification: + value = NSKeyValueObservingOptionsEnum.priorNotification; + break; + } + + return NSKeyValueObservingOptionsEnumData(value: value); + }); +} + +/// Handles initialization of Flutter APIs for the Foundation library. +// TODO(bparrishMines): Add NSObjectFlutterApiImpl once the callback methods +// are added. +class FoundationFlutterApis { + /// Constructs a [FoundationFlutterApis]. + @visibleForTesting + FoundationFlutterApis({ + BinaryMessenger? binaryMessenger, + // ignore: avoid_unused_constructor_parameters + InstanceManager? instanceManager, + }) : _binaryMessenger = binaryMessenger; + + static FoundationFlutterApis _instance = FoundationFlutterApis(); + + /// Sets the global instance containing the Flutter Apis for the Foundation library. + @visibleForTesting + static set instance(FoundationFlutterApis instance) { + _instance = instance; + } + + /// Global instance containing the Flutter Apis for the Foundation library. + static FoundationFlutterApis get instance { + return _instance; + } + + // ignore: unused_field + final BinaryMessenger? _binaryMessenger; + bool _hasBeenSetUp = false; + + /// Ensures all the Flutter APIs have been set up to receive calls from native code. + void ensureSetUp() { + if (!_hasBeenSetUp) { + _hasBeenSetUp = true; + } + } +} + +/// Host api implementation for [NSObject]. +@immutable +class NSObjectHostApiImpl extends NSObjectHostApi { + /// Constructs an [NSObjectHostApiImpl]. + NSObjectHostApiImpl({ + this.binaryMessenger, + InstanceManager? instanceManager, + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager, + super(binaryMessenger: binaryMessenger); + + /// Sends binary data across the Flutter platform barrier. + /// + /// If it is null, the default BinaryMessenger will be used which routes to + /// the host platform. + final BinaryMessenger? binaryMessenger; + + /// Maintains instances stored to communicate with Objective-C objects. + final InstanceManager instanceManager; + + /// Calls [addObserver] with the ids of the provided object instances. + Future addObserverForInstances( + NSObject instance, + NSObject observer, + String keyPath, + Set options, + ) { + return addObserver( + instanceManager.getIdentifier(instance)!, + instanceManager.getIdentifier(observer)!, + keyPath, + _toNSKeyValueObservingOptionsEnumData(options).toList(), + ); + } + + /// Calls [removeObserver] with the ids of the provided object instances. + Future removeObserverForInstances( + NSObject instance, + NSObject observer, + String keyPath, + ) { + return removeObserver( + instanceManager.getIdentifier(instance)!, + instanceManager.getIdentifier(observer)!, + keyPath, + ); + } + + @override + int get hashCode { + return Object.hash(binaryMessenger, instanceManager); + } + + @override + bool operator ==(Object other) { + return other is NSObjectHostApiImpl && + binaryMessenger == other.binaryMessenger && + instanceManager == other.instanceManager; + } +} From 61d5f8a445af7ceb23f480d55c2978e1ee187d2b Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 25 May 2022 16:01:38 -0700 Subject: [PATCH 33/40] undo changes to create methods --- .../lib/src/web_kit/web_kit_api_impls.dart | 44 +++++++------------ 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart index 1ba63865cd17..9b84cd3b2b38 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart @@ -236,10 +236,8 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { WKWebsiteDataStore instance, WKWebViewConfiguration configuration, ) { - final int instanceId = instanceManager.addDartCreatedInstance(instance); - return createFromWebViewConfiguration( - instanceId, + instanceManager.addDartCreatedInstance(instance), instanceManager.getIdentifier(configuration)!, ); } @@ -247,9 +245,10 @@ class WKWebsiteDataStoreHostApiImpl extends WKWebsiteDataStoreHostApi { /// Calls [createDefaultDataStore] with the ids of the provided object instances. Future createDefaultDataStoreForInstances( WKWebsiteDataStore instance, - ) async { - final int instanceId = instanceManager.addDartCreatedInstance(instance); - return createDefaultDataStore(instanceId); + ) { + return createDefaultDataStore( + instanceManager.addDartCreatedInstance(instance), + ); } /// Calls [removeDataOfTypes] with the ids of the provided object instances. @@ -278,9 +277,8 @@ class WKScriptMessageHandlerHostApiImpl extends WKScriptMessageHandlerHostApi { final InstanceManager instanceManager; /// Calls [create] with the ids of the provided object instances. - Future createForInstances(WKScriptMessageHandler instance) async { - final int instanceId = instanceManager.addDartCreatedInstance(instance); - return create(instanceId); + Future createForInstances(WKScriptMessageHandler instance) { + return create(instanceManager.addDartCreatedInstance(instance)); } } @@ -300,9 +298,8 @@ class WKPreferencesHostApiImpl extends WKPreferencesHostApi { WKPreferences instance, WKWebViewConfiguration configuration, ) { - final int instanceId = instanceManager.addDartCreatedInstance(instance); return createFromWebViewConfiguration( - instanceId, + instanceManager.addDartCreatedInstance(instance), instanceManager.getIdentifier(configuration)!, ); } @@ -335,9 +332,8 @@ class WKHttpCookieStoreHostApiImpl extends WKHttpCookieStoreHostApi { WKHttpCookieStore instance, WKWebsiteDataStore dataStore, ) { - final int instanceId = instanceManager.addDartCreatedInstance(instance); return createFromWebsiteDataStore( - instanceId, + instanceManager.addDartCreatedInstance(instance), instanceManager.getIdentifier(dataStore)!, ); } @@ -370,10 +366,9 @@ class WKUserContentControllerHostApiImpl Future createFromWebViewConfigurationForInstances( WKUserContentController instance, WKWebViewConfiguration configuration, - ) async { - final int instanceId = instanceManager.addDartCreatedInstance(instance); + ) { return createFromWebViewConfiguration( - instanceId, + instanceManager.addDartCreatedInstance(instance), instanceManager.getIdentifier(configuration)!, ); } @@ -443,18 +438,16 @@ class WKWebViewConfigurationHostApiImpl extends WKWebViewConfigurationHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKWebViewConfiguration instance) { - final int instanceId = instanceManager.addDartCreatedInstance(instance); - return create(instanceId); + return create(instanceManager.addDartCreatedInstance(instance)); } /// Calls [createFromWebView] with the ids of the provided object instances. Future createFromWebViewForInstances( WKWebViewConfiguration instance, WKWebView webView, - ) async { - final int instanceId = instanceManager.addDartCreatedInstance(instance); + ) { return createFromWebView( - instanceId, + instanceManager.addDartCreatedInstance(instance), instanceManager.getIdentifier(webView)!, ); } @@ -495,8 +488,7 @@ class WKUIDelegateHostApiImpl extends WKUIDelegateHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKUIDelegate instance) async { - final int instanceId = instanceManager.addDartCreatedInstance(instance); - return create(instanceId); + return create(instanceManager.addDartCreatedInstance(instance)); } } @@ -521,8 +513,7 @@ class WKNavigationDelegateHostApiImpl extends WKNavigationDelegateHostApi { /// Calls [create] with the ids of the provided object instances. Future createForInstances(WKNavigationDelegate instance) async { - final int instanceId = instanceManager.addDartCreatedInstance(instance); - return create(instanceId); + return create(instanceManager.addDartCreatedInstance(instance)); } @override @@ -590,9 +581,8 @@ class WKWebViewHostApiImpl extends WKWebViewHostApi { WKWebView instance, WKWebViewConfiguration configuration, ) { - final int instanceId = instanceManager.addDartCreatedInstance(instance); return create( - instanceId, + instanceManager.addDartCreatedInstance(instance), instanceManager.getIdentifier(configuration)!, ); } From 29e8ad0f3bce621c9560c9e02237e0cbb23b369c Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 25 May 2022 16:08:51 -0700 Subject: [PATCH 34/40] changes and stuff --- .../ios/Runner.xcodeproj/project.pbxproj | 8 +- .../ios/Classes/FWFGeneratedWebKitApis.h | 262 +++- .../ios/Classes/FWFGeneratedWebKitApis.m | 1234 ++++++++++------- .../ios/Classes/FWFInstanceManager.m | 1 - .../ios/Classes/FWFUIDelegateHostApi.m | 1 + .../ios/Classes/FWFUIViewHostApi.m | 2 +- .../lib/src/common/web_kit.pigeon.dart | 739 ++++++---- .../lib/src/ui_kit/ui_kit_api_impls.dart | 4 +- .../lib/src/web_kit/web_kit.dart | 28 +- .../webview_flutter_wkwebview/pubspec.yaml | 2 +- .../test/src/common/test_web_kit.pigeon.dart | 814 +++++++---- 11 files changed, 1884 insertions(+), 1211 deletions(-) diff --git a/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/project.pbxproj b/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/project.pbxproj index 0eaa82af7e93..0759b31a2f25 100644 --- a/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/webview_flutter/webview_flutter/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ @@ -274,7 +274,7 @@ isa = PBXProject; attributes = { DefaultBuildSystemTypeForWorkspace = Original; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1030; ORGANIZATIONNAME = "The Flutter Authors"; TargetAttributes = { 68BDCAE823C3F7CB00D9C032 = { @@ -552,7 +552,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -602,7 +602,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h index 9334703005bf..b291f4167725 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h @@ -126,104 +126,166 @@ typedef NS_ENUM(NSUInteger, FWFNSHttpCookiePropertyKeyEnum) { /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithUrl:(NSString *)url - httpMethod:(nullable NSString *)httpMethod - httpBody:(nullable FlutterStandardTypedData *)httpBody - allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields; -@property(nonatomic, copy) NSString * url; -@property(nonatomic, copy, nullable) NSString * httpMethod; -@property(nonatomic, strong, nullable) FlutterStandardTypedData * httpBody; -@property(nonatomic, strong) NSDictionary * allHttpHeaderFields; + httpMethod:(nullable NSString *)httpMethod + httpBody:(nullable FlutterStandardTypedData *)httpBody + allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields; +@property(nonatomic, copy) NSString *url; +@property(nonatomic, copy, nullable) NSString *httpMethod; +@property(nonatomic, strong, nullable) FlutterStandardTypedData *httpBody; +@property(nonatomic, strong) NSDictionary *allHttpHeaderFields; @end @interface FWFWKUserScriptData : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithSource:(NSString *)source - injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime - isMainFrameOnly:(NSNumber *)isMainFrameOnly; -@property(nonatomic, copy) NSString * source; -@property(nonatomic, strong, nullable) FWFWKUserScriptInjectionTimeEnumData * injectionTime; -@property(nonatomic, strong) NSNumber * isMainFrameOnly; + injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime + isMainFrameOnly:(NSNumber *)isMainFrameOnly; +@property(nonatomic, copy) NSString *source; +@property(nonatomic, strong, nullable) FWFWKUserScriptInjectionTimeEnumData *injectionTime; +@property(nonatomic, strong) NSNumber *isMainFrameOnly; @end @interface FWFNSHttpCookieData : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithPropertyKeys:(NSArray *)propertyKeys - propertyValues:(NSArray *)propertyValues; -@property(nonatomic, strong) NSArray * propertyKeys; -@property(nonatomic, strong) NSArray * propertyValues; + propertyValues:(NSArray *)propertyValues; +@property(nonatomic, strong) NSArray *propertyKeys; +@property(nonatomic, strong) NSArray *propertyValues; @end /// The codec used by FWFWKWebsiteDataStoreHostApi. NSObject *FWFWKWebsiteDataStoreHostApiGetCodec(void); @protocol FWFWKWebsiteDataStoreHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)identifier configurationIdentifier:(NSNumber *)configurationIdentifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)createDefaultDataStoreWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeDataFromDataStoreWithIdentifier:(NSNumber *)identifier ofTypes:(NSArray *)dataTypes modifiedSince:(NSNumber *)modificationTimeInSecondsSinceEpoch completion:(void(^)(NSNumber *_Nullable, FlutterError *_Nullable))completion; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)identifier + configurationIdentifier:(NSNumber *)configurationIdentifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createDefaultDataStoreWithIdentifier:(NSNumber *)identifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeDataFromDataStoreWithIdentifier:(NSNumber *)identifier + ofTypes:(NSArray *)dataTypes + modifiedSince:(NSNumber *)modificationTimeInSecondsSinceEpoch + completion:(void (^)(NSNumber *_Nullable, + FlutterError *_Nullable))completion; @end -extern void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKWebsiteDataStoreHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFUIViewHostApi. NSObject *FWFUIViewHostApiGetCodec(void); @protocol FWFUIViewHostApi -- (void)setBackgroundColorForViewWithIdentifier:(NSNumber *)identifier toValue:(nullable NSNumber *)value error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setOpaqueForViewWithIdentifier:(NSNumber *)identifier isOpaque:(NSNumber *)opaque error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setBackgroundColorForViewWithIdentifier:(NSNumber *)identifier + toValue:(nullable NSNumber *)value + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setOpaqueForViewWithIdentifier:(NSNumber *)identifier + isOpaque:(NSNumber *)opaque + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFUIViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFUIViewHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFUIScrollViewHostApi. NSObject *FWFUIScrollViewHostApiGetCodec(void); @protocol FWFUIScrollViewHostApi -- (void)createFromWebViewWithIdentifier:(NSNumber *)identifier webViewIdentifier:(NSNumber *)webViewIdentifier error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewWithIdentifier:(NSNumber *)identifier + webViewIdentifier:(NSNumber *)webViewIdentifier + error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSArray *)contentOffsetForScrollViewWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)scrollByForScrollViewWithIdentifier:(NSNumber *)identifier x:(NSNumber *)x y:(NSNumber *)y error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setContentOffsetForScrollViewWithIdentifier:(NSNumber *)identifier toX:(NSNumber *)x y:(NSNumber *)y error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSArray *) + contentOffsetForScrollViewWithIdentifier:(NSNumber *)identifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)scrollByForScrollViewWithIdentifier:(NSNumber *)identifier + x:(NSNumber *)x + y:(NSNumber *)y + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setContentOffsetForScrollViewWithIdentifier:(NSNumber *)identifier + toX:(NSNumber *)x + y:(NSNumber *)y + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFUIScrollViewHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKWebViewConfigurationHostApi. NSObject *FWFWKWebViewConfigurationHostApiGetCodec(void); @protocol FWFWKWebViewConfigurationHostApi - (void)createWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)createFromWebViewWithIdentifier:(NSNumber *)identifier webViewIdentifier:(NSNumber *)webViewIdentifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:(NSNumber *)identifier isAllowed:(NSNumber *)allow error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setMediaTypesRequiresUserActionForConfigurationWithIdentifier:(NSNumber *)identifier forTypes:(NSArray *)types error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewWithIdentifier:(NSNumber *)identifier + webViewIdentifier:(NSNumber *)webViewIdentifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:(NSNumber *)identifier + isAllowed:(NSNumber *)allow + error: + (FlutterError *_Nullable *_Nonnull) + error; +- (void) + setMediaTypesRequiresUserActionForConfigurationWithIdentifier:(NSNumber *)identifier + forTypes: + (NSArray< + FWFWKAudiovisualMediaTypeEnumData + *> *)types + error: + (FlutterError *_Nullable *_Nonnull) + error; @end -extern void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKWebViewConfigurationHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKUserContentControllerHostApi. NSObject *FWFWKUserContentControllerHostApiGetCodec(void); @protocol FWFWKUserContentControllerHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)identifier configurationIdentifier:(NSNumber *)configurationIdentifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)addScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)identifier handlerIdentifier:(NSNumber *)handlerIdentifier ofName:(NSString *)name error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)identifier name:(NSString *)name error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeAllScriptMessageHandlersForControllerWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)addUserScriptForControllerWithIdentifier:(NSNumber *)identifier userScript:(FWFWKUserScriptData *)userScript error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeAllUserScriptsForControllerWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)identifier + configurationIdentifier:(NSNumber *)configurationIdentifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)addScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)identifier + handlerIdentifier:(NSNumber *)handlerIdentifier + ofName:(NSString *)name + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeScriptMessageHandlerForControllerWithIdentifier:(NSNumber *)identifier + name:(NSString *)name + error:(FlutterError *_Nullable *_Nonnull) + error; +- (void)removeAllScriptMessageHandlersForControllerWithIdentifier:(NSNumber *)identifier + error: + (FlutterError *_Nullable *_Nonnull) + error; +- (void)addUserScriptForControllerWithIdentifier:(NSNumber *)identifier + userScript:(FWFWKUserScriptData *)userScript + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeAllUserScriptsForControllerWithIdentifier:(NSNumber *)identifier + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKUserContentControllerHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKPreferencesHostApi. NSObject *FWFWKPreferencesHostApiGetCodec(void); @protocol FWFWKPreferencesHostApi -- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)identifier configurationIdentifier:(NSNumber *)configurationIdentifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setJavaScriptEnabledForPreferencesWithIdentifier:(NSNumber *)identifier isEnabled:(NSNumber *)enabled error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createFromWebViewConfigurationWithIdentifier:(NSNumber *)identifier + configurationIdentifier:(NSNumber *)configurationIdentifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setJavaScriptEnabledForPreferencesWithIdentifier:(NSNumber *)identifier + isEnabled:(NSNumber *)enabled + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKPreferencesHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKPreferencesHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKScriptMessageHandlerHostApi. NSObject *FWFWKScriptMessageHandlerHostApiGetCodec(void); @@ -232,7 +294,9 @@ NSObject *FWFWKScriptMessageHandlerHostApiGetCodec(void); - (void)createWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKScriptMessageHandlerHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKNavigationDelegateHostApi. NSObject *FWFWKNavigationDelegateHostApiGetCodec(void); @@ -241,25 +305,40 @@ NSObject *FWFWKNavigationDelegateHostApiGetCodec(void); - (void)createWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKNavigationDelegateHostApiSetup( + id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKNavigationDelegateFlutterApi. NSObject *FWFWKNavigationDelegateFlutterApiGetCodec(void); @interface FWFWKNavigationDelegateFlutterApi : NSObject - (instancetype)initWithBinaryMessenger:(id)binaryMessenger; -- (void)didFinishNavigationForDelegateWithIdentifier:(NSNumber *)identifier webViewIdentifier:(NSNumber *)webViewIdentifier URL:(nullable NSString *)url completion:(void(^)(NSError *_Nullable))completion; +- (void)didFinishNavigationForDelegateWithIdentifier:(NSNumber *)identifier + webViewIdentifier:(NSNumber *)webViewIdentifier + URL:(nullable NSString *)url + completion:(void (^)(NSError *_Nullable))completion; @end /// The codec used by FWFNSObjectHostApi. NSObject *FWFNSObjectHostApiGetCodec(void); @protocol FWFNSObjectHostApi -- (void)disposeObjectWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)addObserverForObjectWithIdentifier:(NSNumber *)identifier observerIdentifier:(NSNumber *)observerIdentifier keyPath:(NSString *)keyPath options:(NSArray *)options error:(FlutterError *_Nullable *_Nonnull)error; -- (void)removeObserverForObjectWithIdentifier:(NSNumber *)identifier observerIdentifier:(NSNumber *)observerIdentifier keyPath:(NSString *)keyPath error:(FlutterError *_Nullable *_Nonnull)error; +- (void)disposeObjectWithIdentifier:(NSNumber *)identifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)addObserverForObjectWithIdentifier:(NSNumber *)identifier + observerIdentifier:(NSNumber *)observerIdentifier + keyPath:(NSString *)keyPath + options: + (NSArray *)options + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)removeObserverForObjectWithIdentifier:(NSNumber *)identifier + observerIdentifier:(NSNumber *)observerIdentifier + keyPath:(NSString *)keyPath + error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFNSObjectHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFNSObjectHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFNSObjectFlutterApi. NSObject *FWFNSObjectFlutterApiGetCodec(void); @@ -271,30 +350,65 @@ NSObject *FWFNSObjectFlutterApiGetCodec(void); NSObject *FWFWKWebViewHostApiGetCodec(void); @protocol FWFWKWebViewHostApi -- (void)createWithIdentifier:(NSNumber *)identifier configurationIdentifier:(NSNumber *)configurationIdentifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setUIDelegateForWebViewWithIdentifier:(NSNumber *)identifier delegateIdentifier:(nullable NSNumber *)uiDelegateIdentifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setNavigationDelegateForWebViewWithIdentifier:(NSNumber *)identifier delegateIdentifier:(nullable NSNumber *)navigationDelegateIdentifier error:(FlutterError *_Nullable *_Nonnull)error; -- (nullable NSString *)URLForWebViewWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; +- (void)createWithIdentifier:(NSNumber *)identifier + configurationIdentifier:(NSNumber *)configurationIdentifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setUIDelegateForWebViewWithIdentifier:(NSNumber *)identifier + delegateIdentifier:(nullable NSNumber *)uiDelegateIdentifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setNavigationDelegateForWebViewWithIdentifier:(NSNumber *)identifier + delegateIdentifier: + (nullable NSNumber *)navigationDelegateIdentifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSString *)URLForWebViewWithIdentifier:(NSNumber *)identifier + error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)estimatedProgressForWebViewWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadRequestForWebViewWithIdentifier:(NSNumber *)identifier request:(FWFNSUrlRequestData *)request error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadHTMLForWebViewWithIdentifier:(NSNumber *)identifier HTMLString:(NSString *)string baseURL:(nullable NSString *)baseUrl error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadFileForWebViewWithIdentifier:(NSNumber *)identifier fileURL:(NSString *)url readAccessURL:(NSString *)readAccessUrl error:(FlutterError *_Nullable *_Nonnull)error; -- (void)loadAssetForWebViewWithIdentifier:(NSNumber *)identifier assetKey:(NSString *)key error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSNumber *)estimatedProgressForWebViewWithIdentifier:(NSNumber *)identifier + error:(FlutterError *_Nullable *_Nonnull) + error; +- (void)loadRequestForWebViewWithIdentifier:(NSNumber *)identifier + request:(FWFNSUrlRequestData *)request + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadHTMLForWebViewWithIdentifier:(NSNumber *)identifier + HTMLString:(NSString *)string + baseURL:(nullable NSString *)baseUrl + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadFileForWebViewWithIdentifier:(NSNumber *)identifier + fileURL:(NSString *)url + readAccessURL:(NSString *)readAccessUrl + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)loadAssetForWebViewWithIdentifier:(NSNumber *)identifier + assetKey:(NSString *)key + error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)canGoBackForWebViewWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSNumber *)canGoBackForWebViewWithIdentifier:(NSNumber *)identifier + error:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)canGoForwardForWebViewWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)goBackForWebViewWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)goForwardForWebViewWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)reloadWebViewWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; -- (nullable NSString *)titleForWebViewWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setAllowsBackForwardForWebViewWithIdentifier:(NSNumber *)identifier isAllowed:(NSNumber *)allow error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setUserAgentForWebViewWithIdentifier:(NSNumber *)identifier userAgent:(nullable NSString *)userAgent error:(FlutterError *_Nullable *_Nonnull)error; -- (void)evaluateJavaScriptForWebViewWithIdentifier:(NSNumber *)identifier javaScriptString:(NSString *)javaScriptString completion:(void(^)(id _Nullable, FlutterError *_Nullable))completion; +- (nullable NSNumber *)canGoForwardForWebViewWithIdentifier:(NSNumber *)identifier + error: + (FlutterError *_Nullable *_Nonnull)error; +- (void)goBackForWebViewWithIdentifier:(NSNumber *)identifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)goForwardForWebViewWithIdentifier:(NSNumber *)identifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)reloadWebViewWithIdentifier:(NSNumber *)identifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSString *)titleForWebViewWithIdentifier:(NSNumber *)identifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setAllowsBackForwardForWebViewWithIdentifier:(NSNumber *)identifier + isAllowed:(NSNumber *)allow + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setUserAgentForWebViewWithIdentifier:(NSNumber *)identifier + userAgent:(nullable NSString *)userAgent + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)evaluateJavaScriptForWebViewWithIdentifier:(NSNumber *)identifier + javaScriptString:(NSString *)javaScriptString + completion:(void (^)(id _Nullable, + FlutterError *_Nullable))completion; @end -extern void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKWebViewHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKUIDelegateHostApi. NSObject *FWFWKUIDelegateHostApiGetCodec(void); @@ -303,16 +417,22 @@ NSObject *FWFWKUIDelegateHostApiGetCodec(void); - (void)createWithIdentifier:(NSNumber *)identifier error:(FlutterError *_Nullable *_Nonnull)error; @end -extern void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKUIDelegateHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); /// The codec used by FWFWKHttpCookieStoreHostApi. NSObject *FWFWKHttpCookieStoreHostApiGetCodec(void); @protocol FWFWKHttpCookieStoreHostApi -- (void)createFromWebsiteDataStoreWithIdentifier:(NSNumber *)identifier dataStoreIdentifier:(NSNumber *)websiteDataStoreIdentifier error:(FlutterError *_Nullable *_Nonnull)error; -- (void)setCookieForStoreWithIdentifier:(NSNumber *)identifier cookie:(FWFNSHttpCookieData *)cookie completion:(void(^)(FlutterError *_Nullable))completion; +- (void)createFromWebsiteDataStoreWithIdentifier:(NSNumber *)identifier + dataStoreIdentifier:(NSNumber *)websiteDataStoreIdentifier + error:(FlutterError *_Nullable *_Nonnull)error; +- (void)setCookieForStoreWithIdentifier:(NSNumber *)identifier + cookie:(FWFNSHttpCookieData *)cookie + completion:(void (^)(FlutterError *_Nullable))completion; @end -extern void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, NSObject *_Nullable api); +extern void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, + NSObject *_Nullable api); NS_ASSUME_NONNULL_END diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m index f2abaf233158..f936d151ddd3 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.m @@ -14,26 +14,25 @@ NSDictionary *errorDict = (NSDictionary *)[NSNull null]; if (error) { errorDict = @{ - @"code": (error.code ?: [NSNull null]), - @"message": (error.message ?: [NSNull null]), - @"details": (error.details ?: [NSNull null]), - }; + @"code" : (error.code ?: [NSNull null]), + @"message" : (error.message ?: [NSNull null]), + @"details" : (error.details ?: [NSNull null]), + }; } return @{ - @"result": (result ?: [NSNull null]), - @"error": errorDict, - }; + @"result" : (result ?: [NSNull null]), + @"error" : errorDict, + }; } -static id GetNullableObject(NSDictionary* dict, id key) { +static id GetNullableObject(NSDictionary *dict, id key) { id result = dict[key]; return (result == [NSNull null]) ? nil : result; } -static id GetNullableObjectAtIndex(NSArray* array, NSInteger key) { +static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { id result = array[key]; return (result == [NSNull null]) ? nil : result; } - @interface FWFNSKeyValueObservingOptionsEnumData () + (FWFNSKeyValueObservingOptionsEnumData *)fromMap:(NSDictionary *)dict; - (NSDictionary *)toMap; @@ -69,12 +68,14 @@ - (NSDictionary *)toMap; @implementation FWFNSKeyValueObservingOptionsEnumData + (instancetype)makeWithValue:(FWFNSKeyValueObservingOptionsEnum)value { - FWFNSKeyValueObservingOptionsEnumData* pigeonResult = [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; + FWFNSKeyValueObservingOptionsEnumData *pigeonResult = + [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFNSKeyValueObservingOptionsEnumData *)fromMap:(NSDictionary *)dict { - FWFNSKeyValueObservingOptionsEnumData *pigeonResult = [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; + FWFNSKeyValueObservingOptionsEnumData *pigeonResult = + [[FWFNSKeyValueObservingOptionsEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -87,12 +88,14 @@ - (NSDictionary *)toMap { @implementation FWFWKUserScriptInjectionTimeEnumData + (instancetype)makeWithValue:(FWFWKUserScriptInjectionTimeEnum)value { - FWFWKUserScriptInjectionTimeEnumData* pigeonResult = [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; + FWFWKUserScriptInjectionTimeEnumData *pigeonResult = + [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFWKUserScriptInjectionTimeEnumData *)fromMap:(NSDictionary *)dict { - FWFWKUserScriptInjectionTimeEnumData *pigeonResult = [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; + FWFWKUserScriptInjectionTimeEnumData *pigeonResult = + [[FWFWKUserScriptInjectionTimeEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -105,12 +108,14 @@ - (NSDictionary *)toMap { @implementation FWFWKAudiovisualMediaTypeEnumData + (instancetype)makeWithValue:(FWFWKAudiovisualMediaTypeEnum)value { - FWFWKAudiovisualMediaTypeEnumData* pigeonResult = [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; + FWFWKAudiovisualMediaTypeEnumData *pigeonResult = + [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFWKAudiovisualMediaTypeEnumData *)fromMap:(NSDictionary *)dict { - FWFWKAudiovisualMediaTypeEnumData *pigeonResult = [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; + FWFWKAudiovisualMediaTypeEnumData *pigeonResult = + [[FWFWKAudiovisualMediaTypeEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -123,7 +128,7 @@ - (NSDictionary *)toMap { @implementation FWFWKWebsiteDataTypeEnumData + (instancetype)makeWithValue:(FWFWKWebsiteDataTypeEnum)value { - FWFWKWebsiteDataTypeEnumData* pigeonResult = [[FWFWKWebsiteDataTypeEnumData alloc] init]; + FWFWKWebsiteDataTypeEnumData *pigeonResult = [[FWFWKWebsiteDataTypeEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } @@ -141,12 +146,14 @@ - (NSDictionary *)toMap { @implementation FWFNSHttpCookiePropertyKeyEnumData + (instancetype)makeWithValue:(FWFNSHttpCookiePropertyKeyEnum)value { - FWFNSHttpCookiePropertyKeyEnumData* pigeonResult = [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; + FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = + [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; pigeonResult.value = value; return pigeonResult; } + (FWFNSHttpCookiePropertyKeyEnumData *)fromMap:(NSDictionary *)dict { - FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; + FWFNSHttpCookiePropertyKeyEnumData *pigeonResult = + [[FWFNSHttpCookiePropertyKeyEnumData alloc] init]; pigeonResult.value = [GetNullableObject(dict, @"value") integerValue]; return pigeonResult; } @@ -159,10 +166,10 @@ - (NSDictionary *)toMap { @implementation FWFNSUrlRequestData + (instancetype)makeWithUrl:(NSString *)url - httpMethod:(nullable NSString *)httpMethod - httpBody:(nullable FlutterStandardTypedData *)httpBody - allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields { - FWFNSUrlRequestData* pigeonResult = [[FWFNSUrlRequestData alloc] init]; + httpMethod:(nullable NSString *)httpMethod + httpBody:(nullable FlutterStandardTypedData *)httpBody + allHttpHeaderFields:(NSDictionary *)allHttpHeaderFields { + FWFNSUrlRequestData *pigeonResult = [[FWFNSUrlRequestData alloc] init]; pigeonResult.url = url; pigeonResult.httpMethod = httpMethod; pigeonResult.httpBody = httpBody; @@ -191,9 +198,9 @@ - (NSDictionary *)toMap { @implementation FWFWKUserScriptData + (instancetype)makeWithSource:(NSString *)source - injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime - isMainFrameOnly:(NSNumber *)isMainFrameOnly { - FWFWKUserScriptData* pigeonResult = [[FWFWKUserScriptData alloc] init]; + injectionTime:(nullable FWFWKUserScriptInjectionTimeEnumData *)injectionTime + isMainFrameOnly:(NSNumber *)isMainFrameOnly { + FWFWKUserScriptData *pigeonResult = [[FWFWKUserScriptData alloc] init]; pigeonResult.source = source; pigeonResult.injectionTime = injectionTime; pigeonResult.isMainFrameOnly = isMainFrameOnly; @@ -203,7 +210,8 @@ + (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 fromMap:GetNullableObject(dict, @"injectionTime")]; pigeonResult.isMainFrameOnly = GetNullableObject(dict, @"isMainFrameOnly"); NSAssert(pigeonResult.isMainFrameOnly != nil, @""); return pigeonResult; @@ -219,8 +227,8 @@ - (NSDictionary *)toMap { @implementation FWFNSHttpCookieData + (instancetype)makeWithPropertyKeys:(NSArray *)propertyKeys - propertyValues:(NSArray *)propertyValues { - FWFNSHttpCookieData* pigeonResult = [[FWFNSHttpCookieData alloc] init]; + propertyValues:(NSArray *)propertyValues { + FWFNSHttpCookieData *pigeonResult = [[FWFNSHttpCookieData alloc] init]; pigeonResult.propertyKeys = propertyKeys; pigeonResult.propertyValues = propertyValues; return pigeonResult; @@ -244,15 +252,13 @@ - (NSDictionary *)toMap { @interface FWFWKWebsiteDataStoreHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebsiteDataStoreHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFWKWebsiteDataTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -260,13 +266,11 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKWebsiteDataStoreHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebsiteDataStoreHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -287,43 +291,52 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebsiteDataStoreHostApiCodecReaderWriter *readerWriter = [[FWFWKWebsiteDataStoreHostApiCodecReaderWriter alloc] init]; + FWFWKWebsiteDataStoreHostApiCodecReaderWriter *readerWriter = + [[FWFWKWebsiteDataStoreHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: + configurationIdentifier:error:)], + @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationIdentifier = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_identifier configurationIdentifier:arg_configurationIdentifier error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_identifier + configurationIdentifier:arg_configurationIdentifier + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createDefaultDataStoreWithIdentifier:error:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(createDefaultDataStoreWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createDefaultDataStoreWithIdentifier:error:)], + @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " + @"@selector(createDefaultDataStoreWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -331,30 +344,36 @@ void FWFWKWebsiteDataStoreHostApiSetup(id binaryMessenge [api createDefaultDataStoreWithIdentifier:arg_identifier error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes" binaryMessenger:binaryMessenger - codec:FWFWKWebsiteDataStoreHostApiGetCodec() ]; + codec:FWFWKWebsiteDataStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)], @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to @selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)", api); + NSCAssert( + [api respondsToSelector:@selector + (removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)], + @"FWFWKWebsiteDataStoreHostApi api (%@) doesn't respond to " + @"@selector(removeDataFromDataStoreWithIdentifier:ofTypes:modifiedSince:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSArray *arg_dataTypes = GetNullableObjectAtIndex(args, 1); NSNumber *arg_modificationTimeInSecondsSinceEpoch = GetNullableObjectAtIndex(args, 2); - [api removeDataFromDataStoreWithIdentifier:arg_identifier ofTypes:arg_dataTypes modifiedSince:arg_modificationTimeInSecondsSinceEpoch completion:^(NSNumber *_Nullable output, FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; + [api removeDataFromDataStoreWithIdentifier:arg_identifier + ofTypes:arg_dataTypes + modifiedSince:arg_modificationTimeInSecondsSinceEpoch + completion:^(NSNumber *_Nullable output, + FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -384,22 +403,26 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFUIViewHostApiCodecReaderWriter *readerWriter = [[FWFUIViewHostApiCodecReaderWriter alloc] init]; + FWFUIViewHostApiCodecReaderWriter *readerWriter = + [[FWFUIViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFUIViewHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFUIViewHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIViewHostApi.setBackgroundColor" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIViewHostApi.setBackgroundColor" binaryMessenger:binaryMessenger - codec:FWFUIViewHostApiGetCodec() ]; + codec:FWFUIViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setBackgroundColorForViewWithIdentifier:toValue:error:)], @"FWFUIViewHostApi api (%@) doesn't respond to @selector(setBackgroundColorForViewWithIdentifier:toValue:error:)", api); + NSCAssert([api respondsToSelector:@selector(setBackgroundColorForViewWithIdentifier: + toValue:error:)], + @"FWFUIViewHostApi api (%@) doesn't respond to " + @"@selector(setBackgroundColorForViewWithIdentifier:toValue:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -408,19 +431,20 @@ void FWFUIViewHostApiSetup(id binaryMessenger, NSObject< [api setBackgroundColorForViewWithIdentifier:arg_identifier toValue:arg_value error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIViewHostApi.setOpaque" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIViewHostApi.setOpaque" binaryMessenger:binaryMessenger - codec:FWFUIViewHostApiGetCodec() ]; + codec:FWFUIViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)], @"FWFUIViewHostApi api (%@) doesn't respond to @selector(setOpaqueForViewWithIdentifier:isOpaque:error:)", api); + NSCAssert([api respondsToSelector:@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)], + @"FWFUIViewHostApi api (%@) doesn't respond to " + @"@selector(setOpaqueForViewWithIdentifier:isOpaque:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -429,8 +453,7 @@ void FWFUIViewHostApiSetup(id binaryMessenger, NSObject< [api setOpaqueForViewWithIdentifier:arg_identifier isOpaque:arg_opaque error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -460,63 +483,72 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFUIScrollViewHostApiCodecReaderWriter *readerWriter = [[FWFUIScrollViewHostApiCodecReaderWriter alloc] init]; + FWFUIScrollViewHostApiCodecReaderWriter *readerWriter = + [[FWFUIScrollViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFUIScrollViewHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec() ]; + codec:FWFUIScrollViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier: + webViewIdentifier:error:)], + @"FWFUIScrollViewHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_webViewIdentifier = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewWithIdentifier:arg_identifier webViewIdentifier:arg_webViewIdentifier error:&error]; + [api createFromWebViewWithIdentifier:arg_identifier + webViewIdentifier:arg_webViewIdentifier + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec() ]; + codec:FWFUIScrollViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(contentOffsetForScrollViewWithIdentifier:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(contentOffsetForScrollViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(contentOffsetForScrollViewWithIdentifier:error:)], + @"FWFUIScrollViewHostApi api (%@) doesn't respond to " + @"@selector(contentOffsetForScrollViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); FlutterError *error; - NSArray *output = [api contentOffsetForScrollViewWithIdentifier:arg_identifier error:&error]; + NSArray *output = [api contentOffsetForScrollViewWithIdentifier:arg_identifier + error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.scrollBy" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.scrollBy" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec() ]; + codec:FWFUIScrollViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(scrollByForScrollViewWithIdentifier:x:y:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(scrollByForScrollViewWithIdentifier:x:y:error:)", api); + NSCAssert([api respondsToSelector:@selector(scrollByForScrollViewWithIdentifier:x:y:error:)], + @"FWFUIScrollViewHostApi api (%@) doesn't respond to " + @"@selector(scrollByForScrollViewWithIdentifier:x:y:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -526,30 +558,34 @@ void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSO [api scrollByForScrollViewWithIdentifier:arg_identifier x:arg_x y:arg_y error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset" binaryMessenger:binaryMessenger - codec:FWFUIScrollViewHostApiGetCodec() ]; + codec:FWFUIScrollViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)], @"FWFUIScrollViewHostApi api (%@) doesn't respond to @selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)", api); + NSCAssert([api respondsToSelector:@selector + (setContentOffsetForScrollViewWithIdentifier:toX:y:error:)], + @"FWFUIScrollViewHostApi api (%@) doesn't respond to " + @"@selector(setContentOffsetForScrollViewWithIdentifier:toX:y:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_x = GetNullableObjectAtIndex(args, 1); NSNumber *arg_y = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api setContentOffsetForScrollViewWithIdentifier:arg_identifier toX:arg_x y:arg_y error:&error]; + [api setContentOffsetForScrollViewWithIdentifier:arg_identifier + toX:arg_x + y:arg_y + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -557,15 +593,13 @@ void FWFUIScrollViewHostApiSetup(id binaryMessenger, NSO @interface FWFWKWebViewConfigurationHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebViewConfigurationHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFWKAudiovisualMediaTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -573,13 +607,11 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKWebViewConfigurationHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebViewConfigurationHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -600,22 +632,25 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebViewConfigurationHostApiCodecReaderWriter *readerWriter = [[FWFWKWebViewConfigurationHostApiCodecReaderWriter alloc] init]; + FWFWKWebViewConfigurationHostApiCodecReaderWriter *readerWriter = + [[FWFWKWebViewConfigurationHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKWebViewConfigurationHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; + codec:FWFWKWebViewConfigurationHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], + @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -623,71 +658,87 @@ void FWFWKWebViewConfigurationHostApiSetup(id binaryMess [api createWithIdentifier:arg_identifier error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; + codec:FWFWKWebViewConfigurationHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createFromWebViewWithIdentifier: + webViewIdentifier:error:)], + @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewWithIdentifier:webViewIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_webViewIdentifier = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewWithIdentifier:arg_identifier webViewIdentifier:arg_webViewIdentifier error:&error]; + [api createFromWebViewWithIdentifier:arg_identifier + webViewIdentifier:arg_webViewIdentifier + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; + codec:FWFWKWebViewConfigurationHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)", api); + NSCAssert( + [api respondsToSelector:@selector + (setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)], + @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " + @"@selector(setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:isAllowed:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_allow = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:arg_identifier isAllowed:arg_allow error:&error]; + [api setAllowsInlineMediaPlaybackForConfigurationWithIdentifier:arg_identifier + isAllowed:arg_allow + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewConfigurationHostApi." + @"setMediaTypesRequiringUserActionForPlayback" binaryMessenger:binaryMessenger - codec:FWFWKWebViewConfigurationHostApiGetCodec() ]; + codec:FWFWKWebViewConfigurationHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:error:)], @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to @selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:error:)", api); + NSCAssert([api respondsToSelector:@selector + (setMediaTypesRequiresUserActionForConfigurationWithIdentifier: + forTypes:error:)], + @"FWFWKWebViewConfigurationHostApi api (%@) doesn't respond to " + @"@selector(setMediaTypesRequiresUserActionForConfigurationWithIdentifier:forTypes:" + @"error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSArray *arg_types = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setMediaTypesRequiresUserActionForConfigurationWithIdentifier:arg_identifier forTypes:arg_types error:&error]; + [api setMediaTypesRequiresUserActionForConfigurationWithIdentifier:arg_identifier + forTypes:arg_types + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -695,18 +746,16 @@ void FWFWKWebViewConfigurationHostApiSetup(id binaryMess @interface FWFWKUserContentControllerHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKUserContentControllerHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFWKUserScriptData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFWKUserScriptInjectionTimeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -714,17 +763,14 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKUserContentControllerHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKUserContentControllerHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFWKUserScriptData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -745,86 +791,109 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKUserContentControllerHostApiCodecReaderWriter *readerWriter = [[FWFWKUserContentControllerHostApiCodecReaderWriter alloc] init]; + FWFWKUserContentControllerHostApiCodecReaderWriter *readerWriter = + [[FWFWKUserContentControllerHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKUserContentControllerHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: + configurationIdentifier:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationIdentifier = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_identifier configurationIdentifier:arg_configurationIdentifier error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_identifier + configurationIdentifier:arg_configurationIdentifier + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:ofName:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:ofName:error:)", api); + NSCAssert([api respondsToSelector:@selector + (addScriptMessageHandlerForControllerWithIdentifier: + handlerIdentifier:ofName:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(addScriptMessageHandlerForControllerWithIdentifier:handlerIdentifier:" + @"ofName:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_handlerIdentifier = GetNullableObjectAtIndex(args, 1); NSString *arg_name = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api addScriptMessageHandlerForControllerWithIdentifier:arg_identifier handlerIdentifier:arg_handlerIdentifier ofName:arg_name error:&error]; + [api addScriptMessageHandlerForControllerWithIdentifier:arg_identifier + handlerIdentifier:arg_handlerIdentifier + ofName:arg_name + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)", api); + NSCAssert([api respondsToSelector:@selector + (removeScriptMessageHandlerForControllerWithIdentifier:name:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(removeScriptMessageHandlerForControllerWithIdentifier:name:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSString *arg_name = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api removeScriptMessageHandlerForControllerWithIdentifier:arg_identifier name:arg_name error:&error]; + [api removeScriptMessageHandlerForControllerWithIdentifier:arg_identifier + name:arg_name + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector + (removeAllScriptMessageHandlersForControllerWithIdentifier:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(removeAllScriptMessageHandlersForControllerWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -832,40 +901,46 @@ void FWFWKUserContentControllerHostApiSetup(id binaryMes [api removeAllScriptMessageHandlersForControllerWithIdentifier:arg_identifier error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(addUserScriptForControllerWithIdentifier:userScript:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(addUserScriptForControllerWithIdentifier:userScript:error:)", api); + NSCAssert([api respondsToSelector:@selector(addUserScriptForControllerWithIdentifier: + userScript:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(addUserScriptForControllerWithIdentifier:userScript:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); FWFWKUserScriptData *arg_userScript = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api addUserScriptForControllerWithIdentifier:arg_identifier userScript:arg_userScript error:&error]; + [api addUserScriptForControllerWithIdentifier:arg_identifier + userScript:arg_userScript + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts" binaryMessenger:binaryMessenger - codec:FWFWKUserContentControllerHostApiGetCodec() ]; + codec:FWFWKUserContentControllerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeAllUserScriptsForControllerWithIdentifier:error:)], @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to @selector(removeAllUserScriptsForControllerWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector + (removeAllUserScriptsForControllerWithIdentifier:error:)], + @"FWFWKUserContentControllerHostApi api (%@) doesn't respond to " + @"@selector(removeAllUserScriptsForControllerWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -873,8 +948,7 @@ void FWFWKUserContentControllerHostApiSetup(id binaryMes [api removeAllUserScriptsForControllerWithIdentifier:arg_identifier error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -904,53 +978,63 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKPreferencesHostApiCodecReaderWriter *readerWriter = [[FWFWKPreferencesHostApiCodecReaderWriter alloc] init]; + FWFWKPreferencesHostApiCodecReaderWriter *readerWriter = + [[FWFWKPreferencesHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKPreferencesHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKPreferencesHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration" binaryMessenger:binaryMessenger - codec:FWFWKPreferencesHostApiGetCodec() ]; + codec:FWFWKPreferencesHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)], @"FWFWKPreferencesHostApi api (%@) doesn't respond to @selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(createFromWebViewConfigurationWithIdentifier: + configurationIdentifier:error:)], + @"FWFWKPreferencesHostApi api (%@) doesn't respond to " + @"@selector(createFromWebViewConfigurationWithIdentifier:configurationIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationIdentifier = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebViewConfigurationWithIdentifier:arg_identifier configurationIdentifier:arg_configurationIdentifier error:&error]; + [api createFromWebViewConfigurationWithIdentifier:arg_identifier + configurationIdentifier:arg_configurationIdentifier + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled" binaryMessenger:binaryMessenger - codec:FWFWKPreferencesHostApiGetCodec() ]; + codec:FWFWKPreferencesHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)], @"FWFWKPreferencesHostApi api (%@) doesn't respond to @selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)", api); + NSCAssert([api respondsToSelector:@selector + (setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)], + @"FWFWKPreferencesHostApi api (%@) doesn't respond to " + @"@selector(setJavaScriptEnabledForPreferencesWithIdentifier:isEnabled:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_enabled = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setJavaScriptEnabledForPreferencesWithIdentifier:arg_identifier isEnabled:arg_enabled error:&error]; + [api setJavaScriptEnabledForPreferencesWithIdentifier:arg_identifier + isEnabled:arg_enabled + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -980,22 +1064,25 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKScriptMessageHandlerHostApiCodecReaderWriter *readerWriter = [[FWFWKScriptMessageHandlerHostApiCodecReaderWriter alloc] init]; + FWFWKScriptMessageHandlerHostApiCodecReaderWriter *readerWriter = + [[FWFWKScriptMessageHandlerHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKScriptMessageHandlerHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKScriptMessageHandlerHostApiGetCodec() ]; + codec:FWFWKScriptMessageHandlerHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKScriptMessageHandlerHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], + @"FWFWKScriptMessageHandlerHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -1003,8 +1090,7 @@ void FWFWKScriptMessageHandlerHostApiSetup(id binaryMess [api createWithIdentifier:arg_identifier error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -1034,22 +1120,25 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKNavigationDelegateHostApiCodecReaderWriter *readerWriter = [[FWFWKNavigationDelegateHostApiCodecReaderWriter alloc] init]; + FWFWKNavigationDelegateHostApiCodecReaderWriter *readerWriter = + [[FWFWKNavigationDelegateHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKNavigationDelegateHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKNavigationDelegateHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKNavigationDelegateHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKNavigationDelegateHostApiGetCodec() ]; + codec:FWFWKNavigationDelegateHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKNavigationDelegateHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], + @"FWFWKNavigationDelegateHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -1057,8 +1146,7 @@ void FWFWKNavigationDelegateHostApiSetup(id binaryMessen [api createWithIdentifier:arg_identifier error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -1088,15 +1176,15 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKNavigationDelegateFlutterApiCodecReaderWriter *readerWriter = [[FWFWKNavigationDelegateFlutterApiCodecReaderWriter alloc] init]; + FWFWKNavigationDelegateFlutterApiCodecReaderWriter *readerWriter = + [[FWFWKNavigationDelegateFlutterApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - @interface FWFWKNavigationDelegateFlutterApi () -@property (nonatomic, strong) NSObject *binaryMessenger; +@property(nonatomic, strong) NSObject *binaryMessenger; @end @implementation FWFWKNavigationDelegateFlutterApi @@ -1108,29 +1196,34 @@ - (instancetype)initWithBinaryMessenger:(NSObject *)bina } return self; } -- (void)didFinishNavigationForDelegateWithIdentifier:(NSNumber *)arg_identifier webViewIdentifier:(NSNumber *)arg_webViewIdentifier URL:(nullable NSString *)arg_url completion:(void(^)(NSError *_Nullable))completion { - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel - messageChannelWithName:@"dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation" - binaryMessenger:self.binaryMessenger - codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; - [channel sendMessage:@[arg_identifier ?: [NSNull null], arg_webViewIdentifier ?: [NSNull null], arg_url ?: [NSNull null]] reply:^(id reply) { - completion(nil); - }]; +- (void)didFinishNavigationForDelegateWithIdentifier:(NSNumber *)arg_identifier + webViewIdentifier:(NSNumber *)arg_webViewIdentifier + URL:(nullable NSString *)arg_url + completion:(void (^)(NSError *_Nullable))completion { + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel + messageChannelWithName: + @"dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation" + binaryMessenger:self.binaryMessenger + codec:FWFWKNavigationDelegateFlutterApiGetCodec()]; + [channel sendMessage:@[ + arg_identifier ?: [NSNull null], arg_webViewIdentifier ?: [NSNull null], + arg_url ?: [NSNull null] + ] + reply:^(id reply) { + completion(nil); + }]; } @end @interface FWFNSObjectHostApiCodecReader : FlutterStandardReader @end @implementation FWFNSObjectHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFNSKeyValueObservingOptionsEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -1138,13 +1231,11 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFNSObjectHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFNSObjectHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -1165,22 +1256,25 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFNSObjectHostApiCodecReaderWriter *readerWriter = [[FWFNSObjectHostApiCodecReaderWriter alloc] init]; + FWFNSObjectHostApiCodecReaderWriter *readerWriter = + [[FWFNSObjectHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFNSObjectHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFNSObjectHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.dispose" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.dispose" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec() ]; + codec:FWFNSObjectHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(disposeObjectWithIdentifier:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(disposeObjectWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(disposeObjectWithIdentifier:error:)], + @"FWFNSObjectHostApi api (%@) doesn't respond to " + @"@selector(disposeObjectWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -1188,53 +1282,67 @@ void FWFNSObjectHostApiSetup(id binaryMessenger, NSObjec [api disposeObjectWithIdentifier:arg_identifier error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.addObserver" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.addObserver" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec() ]; + codec:FWFNSObjectHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:error:)", api); + NSCAssert([api respondsToSelector:@selector + (addObserverForObjectWithIdentifier: + observerIdentifier:keyPath:options:error:)], + @"FWFNSObjectHostApi api (%@) doesn't respond to " + @"@selector(addObserverForObjectWithIdentifier:observerIdentifier:keyPath:options:" + @"error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_observerIdentifier = GetNullableObjectAtIndex(args, 1); NSString *arg_keyPath = GetNullableObjectAtIndex(args, 2); - NSArray *arg_options = GetNullableObjectAtIndex(args, 3); + NSArray *arg_options = + GetNullableObjectAtIndex(args, 3); FlutterError *error; - [api addObserverForObjectWithIdentifier:arg_identifier observerIdentifier:arg_observerIdentifier keyPath:arg_keyPath options:arg_options error:&error]; + [api addObserverForObjectWithIdentifier:arg_identifier + observerIdentifier:arg_observerIdentifier + keyPath:arg_keyPath + options:arg_options + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.NSObjectHostApi.removeObserver" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.NSObjectHostApi.removeObserver" binaryMessenger:binaryMessenger - codec:FWFNSObjectHostApiGetCodec() ]; + codec:FWFNSObjectHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)], @"FWFNSObjectHostApi api (%@) doesn't respond to @selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(removeObserverForObjectWithIdentifier: + observerIdentifier:keyPath:error:)], + @"FWFNSObjectHostApi api (%@) doesn't respond to " + @"@selector(removeObserverForObjectWithIdentifier:observerIdentifier:keyPath:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_observerIdentifier = GetNullableObjectAtIndex(args, 1); NSString *arg_keyPath = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api removeObserverForObjectWithIdentifier:arg_identifier observerIdentifier:arg_observerIdentifier keyPath:arg_keyPath error:&error]; + [api removeObserverForObjectWithIdentifier:arg_identifier + observerIdentifier:arg_observerIdentifier + keyPath:arg_keyPath + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -1264,15 +1372,15 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFNSObjectFlutterApiCodecReaderWriter *readerWriter = [[FWFNSObjectFlutterApiCodecReaderWriter alloc] init]; + FWFNSObjectFlutterApiCodecReaderWriter *readerWriter = + [[FWFNSObjectFlutterApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - @interface FWFNSObjectFlutterApi () -@property (nonatomic, strong) NSObject *binaryMessenger; +@property(nonatomic, strong) NSObject *binaryMessenger; @end @implementation FWFNSObjectFlutterApi @@ -1288,36 +1396,34 @@ - (instancetype)initWithBinaryMessenger:(NSObject *)bina @interface FWFWKWebViewHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKWebViewHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFNSHttpCookieData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFNSHttpCookiePropertyKeyEnumData fromMap:[self readValue]]; - - case 130: + + case 130: return [FWFNSKeyValueObservingOptionsEnumData fromMap:[self readValue]]; - - case 131: + + case 131: return [FWFNSUrlRequestData fromMap:[self readValue]]; - - case 132: + + case 132: return [FWFWKAudiovisualMediaTypeEnumData fromMap:[self readValue]]; - - case 133: + + case 133: return [FWFWKUserScriptData fromMap:[self readValue]]; - - case 134: + + case 134: return [FWFWKUserScriptInjectionTimeEnumData fromMap:[self readValue]]; - - case 135: + + case 135: return [FWFWKWebsiteDataTypeEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -1325,41 +1431,32 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKWebViewHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKWebViewHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFNSHttpCookieData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { + } else if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { + } else if ([value isKindOfClass:[FWFNSKeyValueObservingOptionsEnumData class]]) { [self writeByte:130]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFNSUrlRequestData class]]) { + } else if ([value isKindOfClass:[FWFNSUrlRequestData class]]) { [self writeByte:131]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKAudiovisualMediaTypeEnumData class]]) { [self writeByte:132]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKUserScriptData class]]) { + } else if ([value isKindOfClass:[FWFWKUserScriptData class]]) { [self writeByte:133]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKUserScriptInjectionTimeEnumData class]]) { [self writeByte:134]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { + } else if ([value isKindOfClass:[FWFWKWebsiteDataTypeEnumData class]]) { [self writeByte:135]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -1380,85 +1477,101 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKWebViewHostApiCodecReaderWriter *readerWriter = [[FWFWKWebViewHostApiCodecReaderWriter alloc] init]; + FWFWKWebViewHostApiCodecReaderWriter *readerWriter = + [[FWFWKWebViewHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKWebViewHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:configurationIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(createWithIdentifier:configurationIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier: + configurationIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:configurationIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_configurationIdentifier = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createWithIdentifier:arg_identifier configurationIdentifier:arg_configurationIdentifier error:&error]; + [api createWithIdentifier:arg_identifier + configurationIdentifier:arg_configurationIdentifier + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(setUIDelegateForWebViewWithIdentifier: + delegateIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(setUIDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_uiDelegateIdentifier = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setUIDelegateForWebViewWithIdentifier:arg_identifier delegateIdentifier:arg_uiDelegateIdentifier error:&error]; + [api setUIDelegateForWebViewWithIdentifier:arg_identifier + delegateIdentifier:arg_uiDelegateIdentifier + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", api); + NSCAssert( + [api respondsToSelector:@selector(setNavigationDelegateForWebViewWithIdentifier: + delegateIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(setNavigationDelegateForWebViewWithIdentifier:delegateIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_navigationDelegateIdentifier = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setNavigationDelegateForWebViewWithIdentifier:arg_identifier delegateIdentifier:arg_navigationDelegateIdentifier error:&error]; + [api setNavigationDelegateForWebViewWithIdentifier:arg_identifier + delegateIdentifier:arg_navigationDelegateIdentifier + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getUrl" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getUrl" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(URLForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(URLForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(URLForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(URLForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -1466,39 +1579,44 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje NSString *output = [api URLForWebViewWithIdentifier:arg_identifier error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(estimatedProgressForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(estimatedProgressForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(estimatedProgressForWebViewWithIdentifier: + error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(estimatedProgressForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); FlutterError *error; - NSNumber *output = [api estimatedProgressForWebViewWithIdentifier:arg_identifier error:&error]; + NSNumber *output = [api estimatedProgressForWebViewWithIdentifier:arg_identifier + error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadRequest" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadRequest" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadRequestForWebViewWithIdentifier:request:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadRequestForWebViewWithIdentifier:request:error:)", api); + NSCAssert([api respondsToSelector:@selector(loadRequestForWebViewWithIdentifier: + request:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(loadRequestForWebViewWithIdentifier:request:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -1507,63 +1625,75 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api loadRequestForWebViewWithIdentifier:arg_identifier request:arg_request error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)", api); + NSCAssert([api respondsToSelector:@selector(loadHTMLForWebViewWithIdentifier: + HTMLString:baseURL:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(loadHTMLForWebViewWithIdentifier:HTMLString:baseURL:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSString *arg_string = GetNullableObjectAtIndex(args, 1); NSString *arg_baseUrl = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api loadHTMLForWebViewWithIdentifier:arg_identifier HTMLString:arg_string baseURL:arg_baseUrl error:&error]; + [api loadHTMLForWebViewWithIdentifier:arg_identifier + HTMLString:arg_string + baseURL:arg_baseUrl + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)", api); + NSCAssert([api respondsToSelector:@selector + (loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(loadFileForWebViewWithIdentifier:fileURL:readAccessURL:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSString *arg_url = GetNullableObjectAtIndex(args, 1); NSString *arg_readAccessUrl = GetNullableObjectAtIndex(args, 2); FlutterError *error; - [api loadFileForWebViewWithIdentifier:arg_identifier fileURL:arg_url readAccessURL:arg_readAccessUrl error:&error]; + [api loadFileForWebViewWithIdentifier:arg_identifier + fileURL:arg_url + readAccessURL:arg_readAccessUrl + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(loadAssetForWebViewWithIdentifier:assetKey:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(loadAssetForWebViewWithIdentifier:assetKey:error:)", api); + NSCAssert([api respondsToSelector:@selector(loadAssetForWebViewWithIdentifier: + assetKey:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(loadAssetForWebViewWithIdentifier:assetKey:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -1572,19 +1702,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api loadAssetForWebViewWithIdentifier:arg_identifier assetKey:arg_key error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoBack" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoBack" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(canGoBackForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(canGoBackForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(canGoBackForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(canGoBackForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -1592,19 +1723,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje NSNumber *output = [api canGoBackForWebViewWithIdentifier:arg_identifier error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoForward" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.canGoForward" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(canGoForwardForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(canGoForwardForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(canGoForwardForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(canGoForwardForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -1612,19 +1744,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje NSNumber *output = [api canGoForwardForWebViewWithIdentifier:arg_identifier error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goBack" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goBack" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(goBackForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(goBackForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(goBackForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(goBackForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -1632,19 +1765,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api goBackForWebViewWithIdentifier:arg_identifier error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goForward" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.goForward" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(goForwardForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(goForwardForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(goForwardForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(goForwardForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -1652,19 +1786,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api goForwardForWebViewWithIdentifier:arg_identifier error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.reload" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.reload" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(reloadWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(reloadWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(reloadWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(reloadWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -1672,19 +1807,20 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje [api reloadWebViewWithIdentifier:arg_identifier error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getTitle" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.getTitle" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(titleForWebViewWithIdentifier:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(titleForWebViewWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(titleForWebViewWithIdentifier:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(titleForWebViewWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -1692,71 +1828,85 @@ void FWFWKWebViewHostApiSetup(id binaryMessenger, NSObje NSString *output = [api titleForWebViewWithIdentifier:arg_identifier error:&error]; callback(wrapResult(output, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + @"dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)", api); + NSCAssert([api respondsToSelector:@selector + (setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(setAllowsBackForwardForWebViewWithIdentifier:isAllowed:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_allow = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setAllowsBackForwardForWebViewWithIdentifier:arg_identifier isAllowed:arg_allow error:&error]; + [api setAllowsBackForwardForWebViewWithIdentifier:arg_identifier + isAllowed:arg_allow + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)", api); + NSCAssert([api respondsToSelector:@selector(setUserAgentForWebViewWithIdentifier: + userAgent:error:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(setUserAgentForWebViewWithIdentifier:userAgent:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSString *arg_userAgent = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api setUserAgentForWebViewWithIdentifier:arg_identifier userAgent:arg_userAgent error:&error]; + [api setUserAgentForWebViewWithIdentifier:arg_identifier + userAgent:arg_userAgent + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript" binaryMessenger:binaryMessenger - codec:FWFWKWebViewHostApiGetCodec() ]; + codec:FWFWKWebViewHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)], @"FWFWKWebViewHostApi api (%@) doesn't respond to @selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)", api); + NSCAssert( + [api respondsToSelector:@selector + (evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)], + @"FWFWKWebViewHostApi api (%@) doesn't respond to " + @"@selector(evaluateJavaScriptForWebViewWithIdentifier:javaScriptString:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSString *arg_javaScriptString = GetNullableObjectAtIndex(args, 1); - [api evaluateJavaScriptForWebViewWithIdentifier:arg_identifier javaScriptString:arg_javaScriptString completion:^(id _Nullable output, FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; + [api evaluateJavaScriptForWebViewWithIdentifier:arg_identifier + javaScriptString:arg_javaScriptString + completion:^(id _Nullable output, + FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -1786,22 +1936,25 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKUIDelegateHostApiCodecReaderWriter *readerWriter = [[FWFWKUIDelegateHostApiCodecReaderWriter alloc] init]; + FWFWKUIDelegateHostApiCodecReaderWriter *readerWriter = + [[FWFWKUIDelegateHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKUIDelegateHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKUIDelegateHostApi.create" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKUIDelegateHostApi.create" binaryMessenger:binaryMessenger - codec:FWFWKUIDelegateHostApiGetCodec() ]; + codec:FWFWKUIDelegateHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], @"FWFWKUIDelegateHostApi api (%@) doesn't respond to @selector(createWithIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createWithIdentifier:error:)], + @"FWFWKUIDelegateHostApi api (%@) doesn't respond to " + @"@selector(createWithIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); @@ -1809,8 +1962,7 @@ void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSO [api createWithIdentifier:arg_identifier error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } @@ -1818,18 +1970,16 @@ void FWFWKUIDelegateHostApiSetup(id binaryMessenger, NSO @interface FWFWKHttpCookieStoreHostApiCodecReader : FlutterStandardReader @end @implementation FWFWKHttpCookieStoreHostApiCodecReader -- (nullable id)readValueOfType:(UInt8)type -{ +- (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: + case 128: return [FWFNSHttpCookieData fromMap:[self readValue]]; - - case 129: + + case 129: return [FWFNSHttpCookiePropertyKeyEnumData fromMap:[self readValue]]; - - default: + + default: return [super readValueOfType:type]; - } } @end @@ -1837,17 +1987,14 @@ - (nullable id)readValueOfType:(UInt8)type @interface FWFWKHttpCookieStoreHostApiCodecWriter : FlutterStandardWriter @end @implementation FWFWKHttpCookieStoreHostApiCodecWriter -- (void)writeValue:(id)value -{ +- (void)writeValue:(id)value { if ([value isKindOfClass:[FWFNSHttpCookieData class]]) { [self writeByte:128]; [self writeValue:[value toMap]]; - } else - if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { + } else if ([value isKindOfClass:[FWFNSHttpCookiePropertyKeyEnumData class]]) { [self writeByte:129]; [self writeValue:[value toMap]]; - } else -{ + } else { [super writeValue:value]; } } @@ -1868,53 +2015,62 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; dispatch_once(&sPred, ^{ - FWFWKHttpCookieStoreHostApiCodecReaderWriter *readerWriter = [[FWFWKHttpCookieStoreHostApiCodecReaderWriter alloc] init]; + FWFWKHttpCookieStoreHostApiCodecReaderWriter *readerWriter = + [[FWFWKHttpCookieStoreHostApiCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - -void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, NSObject *api) { +void FWFWKHttpCookieStoreHostApiSetup(id binaryMessenger, + NSObject *api) { { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore" binaryMessenger:binaryMessenger - codec:FWFWKHttpCookieStoreHostApiGetCodec() ]; + codec:FWFWKHttpCookieStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)], @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to @selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)", api); + NSCAssert([api respondsToSelector:@selector(createFromWebsiteDataStoreWithIdentifier: + dataStoreIdentifier:error:)], + @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to " + @"@selector(createFromWebsiteDataStoreWithIdentifier:dataStoreIdentifier:error:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); NSNumber *arg_websiteDataStoreIdentifier = GetNullableObjectAtIndex(args, 1); FlutterError *error; - [api createFromWebsiteDataStoreWithIdentifier:arg_identifier dataStoreIdentifier:arg_websiteDataStoreIdentifier error:&error]; + [api createFromWebsiteDataStoreWithIdentifier:arg_identifier + dataStoreIdentifier:arg_websiteDataStoreIdentifier + error:&error]; callback(wrapResult(nil, error)); }]; - } - else { + } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie" + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:@"dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie" binaryMessenger:binaryMessenger - codec:FWFWKHttpCookieStoreHostApiGetCodec() ]; + codec:FWFWKHttpCookieStoreHostApiGetCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(setCookieForStoreWithIdentifier:cookie:completion:)], @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to @selector(setCookieForStoreWithIdentifier:cookie:completion:)", api); + NSCAssert([api respondsToSelector:@selector(setCookieForStoreWithIdentifier: + cookie:completion:)], + @"FWFWKHttpCookieStoreHostApi api (%@) doesn't respond to " + @"@selector(setCookieForStoreWithIdentifier:cookie:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSNumber *arg_identifier = GetNullableObjectAtIndex(args, 0); FWFNSHttpCookieData *arg_cookie = GetNullableObjectAtIndex(args, 1); - [api setCookieForStoreWithIdentifier:arg_identifier cookie:arg_cookie completion:^(FlutterError *_Nullable error) { - callback(wrapResult(nil, error)); - }]; + [api setCookieForStoreWithIdentifier:arg_identifier + cookie:arg_cookie + completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; }]; - } - else { + } else { [channel setMessageHandler:nil]; } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index db60a90e2010..600af78b4427 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -3,7 +3,6 @@ // found in the LICENSE file. #import "FWFInstanceManager.h" -#import // Attaches to an object to receive a callback when the object is deallocated. @interface FWFFinalizer : NSObject diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m index 28d0ab53aaad..7a545f4c5379 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m @@ -30,4 +30,5 @@ - (void)createWithIdentifier:(nonnull NSNumber *)identifier FWFUIDelegate *uIDelegate = [[FWFUIDelegate alloc] init]; [self.instanceManager addDartCreatedInstance:uIDelegate withIdentifier:identifier.longValue]; } + @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIViewHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIViewHostApi.m index 8200ba005956..465738b570cd 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIViewHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIViewHostApi.m @@ -5,7 +5,7 @@ #import "FWFUIViewHostApi.h" @interface FWFUIViewHostApiImpl () -@property(nonatomic, weak) FWFInstanceManager *instanceManager; +@property(nonatomic) FWFInstanceManager *instanceManager; @end @implementation FWFUIViewHostApiImpl diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart index 304c7aab8c59..9d928a38a2ef 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/web_kit.pigeon.dart @@ -94,8 +94,7 @@ class NSKeyValueObservingOptionsEnumData { static NSKeyValueObservingOptionsEnumData decode(Object message) { final Map pigeonMap = message as Map; return NSKeyValueObservingOptionsEnumData( - value: NSKeyValueObservingOptionsEnum.values[pigeonMap['value']! as int] -, + value: NSKeyValueObservingOptionsEnum.values[pigeonMap['value']! as int], ); } } @@ -116,8 +115,7 @@ class WKUserScriptInjectionTimeEnumData { static WKUserScriptInjectionTimeEnumData decode(Object message) { final Map pigeonMap = message as Map; return WKUserScriptInjectionTimeEnumData( - value: WKUserScriptInjectionTimeEnum.values[pigeonMap['value']! as int] -, + value: WKUserScriptInjectionTimeEnum.values[pigeonMap['value']! as int], ); } } @@ -138,8 +136,7 @@ class WKAudiovisualMediaTypeEnumData { static WKAudiovisualMediaTypeEnumData decode(Object message) { final Map pigeonMap = message as Map; return WKAudiovisualMediaTypeEnumData( - value: WKAudiovisualMediaTypeEnum.values[pigeonMap['value']! as int] -, + value: WKAudiovisualMediaTypeEnum.values[pigeonMap['value']! as int], ); } } @@ -160,8 +157,7 @@ class WKWebsiteDataTypeEnumData { static WKWebsiteDataTypeEnumData decode(Object message) { final Map pigeonMap = message as Map; return WKWebsiteDataTypeEnumData( - value: WKWebsiteDataTypeEnum.values[pigeonMap['value']! as int] -, + value: WKWebsiteDataTypeEnum.values[pigeonMap['value']! as int], ); } } @@ -182,8 +178,7 @@ class NSHttpCookiePropertyKeyEnumData { static NSHttpCookiePropertyKeyEnumData decode(Object message) { final Map pigeonMap = message as Map; return NSHttpCookiePropertyKeyEnumData( - value: NSHttpCookiePropertyKeyEnum.values[pigeonMap['value']! as int] -, + value: NSHttpCookiePropertyKeyEnum.values[pigeonMap['value']! as int], ); } } @@ -216,7 +211,9 @@ class NSUrlRequestData { url: pigeonMap['url']! as String, httpMethod: pigeonMap['httpMethod'] as String?, httpBody: pigeonMap['httpBody'] as Uint8List?, - allHttpHeaderFields: (pigeonMap['allHttpHeaderFields'] as Map?)!.cast(), + allHttpHeaderFields: + (pigeonMap['allHttpHeaderFields'] as Map?)! + .cast(), ); } } @@ -245,7 +242,8 @@ class WKUserScriptData { return WKUserScriptData( source: pigeonMap['source']! as String, injectionTime: pigeonMap['injectionTime'] != null - ? WKUserScriptInjectionTimeEnumData.decode(pigeonMap['injectionTime']!) + ? WKUserScriptInjectionTimeEnumData.decode( + pigeonMap['injectionTime']!) : null, isMainFrameOnly: pigeonMap['isMainFrameOnly']! as bool, ); @@ -271,8 +269,10 @@ class NSHttpCookieData { static NSHttpCookieData decode(Object message) { final Map pigeonMap = message as Map; return NSHttpCookieData( - propertyKeys: (pigeonMap['propertyKeys'] as List?)!.cast(), - propertyValues: (pigeonMap['propertyValues'] as List?)!.cast(), + propertyKeys: (pigeonMap['propertyKeys'] as List?)! + .cast(), + propertyValues: + (pigeonMap['propertyValues'] as List?)!.cast(), ); } } @@ -284,20 +284,19 @@ class _WKWebsiteDataStoreHostApiCodec extends StandardMessageCodec { if (value is WKWebsiteDataTypeEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKWebsiteDataTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } @@ -306,24 +305,30 @@ class WKWebsiteDataStoreHostApi { /// Constructor for [WKWebsiteDataStoreHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKWebsiteDataStoreHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKWebsiteDataStoreHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _WKWebsiteDataStoreHostApiCodec(); - Future createFromWebViewConfiguration(int arg_identifier, int arg_configurationIdentifier) async { + Future createFromWebViewConfiguration( + int arg_identifier, int arg_configurationIdentifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_configurationIdentifier]) as Map?; + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_configurationIdentifier]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -336,7 +341,9 @@ class WKWebsiteDataStoreHostApi { Future createDefaultDataStore(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore', + codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -345,7 +352,8 @@ class WKWebsiteDataStoreHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -356,18 +364,26 @@ class WKWebsiteDataStoreHostApi { } } - Future removeDataOfTypes(int arg_identifier, List arg_dataTypes, double arg_modificationTimeInSecondsSinceEpoch) async { + Future removeDataOfTypes( + int arg_identifier, + List arg_dataTypes, + double arg_modificationTimeInSecondsSinceEpoch) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_dataTypes, arg_modificationTimeInSecondsSinceEpoch]) as Map?; + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel.send([ + arg_identifier, + arg_dataTypes, + arg_modificationTimeInSecondsSinceEpoch + ]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -392,7 +408,8 @@ class UIViewHostApi { /// Constructor for [UIViewHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - UIViewHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + UIViewHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; @@ -400,16 +417,18 @@ class UIViewHostApi { Future setBackgroundColor(int arg_identifier, int? arg_value) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIViewHostApi.setBackgroundColor', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_value]) as Map?; + 'dev.flutter.pigeon.UIViewHostApi.setBackgroundColor', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_value]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -422,16 +441,18 @@ class UIViewHostApi { Future setOpaque(int arg_identifier, bool arg_opaque) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIViewHostApi.setOpaque', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_opaque]) as Map?; + 'dev.flutter.pigeon.UIViewHostApi.setOpaque', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_opaque]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -451,24 +472,29 @@ class UIScrollViewHostApi { /// Constructor for [UIScrollViewHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - UIScrollViewHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + UIScrollViewHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _UIScrollViewHostApiCodec(); - Future createFromWebView(int arg_identifier, int arg_webViewIdentifier) async { + Future createFromWebView( + int arg_identifier, int arg_webViewIdentifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_identifier, arg_webViewIdentifier]) as Map?; + await channel.send([arg_identifier, arg_webViewIdentifier]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -481,7 +507,8 @@ class UIScrollViewHostApi { Future> getContentOffset(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -490,7 +517,8 @@ class UIScrollViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -508,16 +536,19 @@ class UIScrollViewHostApi { Future scrollBy(int arg_identifier, double arg_x, double arg_y) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.scrollBy', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.scrollBy', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_identifier, arg_x, arg_y]) as Map?; + await channel.send([arg_identifier, arg_x, arg_y]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -528,18 +559,22 @@ class UIScrollViewHostApi { } } - Future setContentOffset(int arg_identifier, double arg_x, double arg_y) async { + Future setContentOffset( + int arg_identifier, double arg_x, double arg_y) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_identifier, arg_x, arg_y]) as Map?; + await channel.send([arg_identifier, arg_x, arg_y]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -558,20 +593,19 @@ class _WKWebViewConfigurationHostApiCodec extends StandardMessageCodec { if (value is WKAudiovisualMediaTypeEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } @@ -580,15 +614,18 @@ class WKWebViewConfigurationHostApi { /// Constructor for [WKWebViewConfigurationHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKWebViewConfigurationHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKWebViewConfigurationHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; - static const MessageCodec codec = _WKWebViewConfigurationHostApiCodec(); + static const MessageCodec codec = + _WKWebViewConfigurationHostApiCodec(); Future create(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.create', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.create', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -597,7 +634,8 @@ class WKWebViewConfigurationHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -608,18 +646,23 @@ class WKWebViewConfigurationHostApi { } } - Future createFromWebView(int arg_identifier, int arg_webViewIdentifier) async { + Future createFromWebView( + int arg_identifier, int arg_webViewIdentifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView', + codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_identifier, arg_webViewIdentifier]) as Map?; + await channel.send([arg_identifier, arg_webViewIdentifier]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -630,18 +673,22 @@ class WKWebViewConfigurationHostApi { } } - Future setAllowsInlineMediaPlayback(int arg_identifier, bool arg_allow) async { + Future setAllowsInlineMediaPlayback( + int arg_identifier, bool arg_allow) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_allow]) as Map?; + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_allow]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -652,18 +699,22 @@ class WKWebViewConfigurationHostApi { } } - Future setMediaTypesRequiringUserActionForPlayback(int arg_identifier, List arg_types) async { + Future setMediaTypesRequiringUserActionForPlayback(int arg_identifier, + List arg_types) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_types]) as Map?; + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_types]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -682,27 +733,25 @@ class _WKUserContentControllerHostApiCodec extends StandardMessageCodec { if (value is WKUserScriptData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else - if (value is WKUserScriptInjectionTimeEnumData) { + } else if (value is WKUserScriptInjectionTimeEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKUserScriptData.decode(readValue(buffer)!); - - case 129: + + case 129: return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } @@ -711,24 +760,31 @@ class WKUserContentControllerHostApi { /// Constructor for [WKUserContentControllerHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKUserContentControllerHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKUserContentControllerHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; - static const MessageCodec codec = _WKUserContentControllerHostApiCodec(); + static const MessageCodec codec = + _WKUserContentControllerHostApiCodec(); - Future createFromWebViewConfiguration(int arg_identifier, int arg_configurationIdentifier) async { + Future createFromWebViewConfiguration( + int arg_identifier, int arg_configurationIdentifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_configurationIdentifier]) as Map?; + 'dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_configurationIdentifier]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -739,18 +795,23 @@ class WKUserContentControllerHostApi { } } - Future addScriptMessageHandler(int arg_identifier, int arg_handlerIdentifier, String arg_name) async { + Future addScriptMessageHandler( + int arg_identifier, int arg_handlerIdentifier, String arg_name) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_handlerIdentifier, arg_name]) as Map?; + 'dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_handlerIdentifier, arg_name]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -761,18 +822,22 @@ class WKUserContentControllerHostApi { } } - Future removeScriptMessageHandler(int arg_identifier, String arg_name) async { + Future removeScriptMessageHandler( + int arg_identifier, String arg_name) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_name]) as Map?; + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_name]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -785,7 +850,9 @@ class WKUserContentControllerHostApi { Future removeAllScriptMessageHandlers(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers', + codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -794,7 +861,8 @@ class WKUserContentControllerHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -805,18 +873,23 @@ class WKUserContentControllerHostApi { } } - Future addUserScript(int arg_identifier, WKUserScriptData arg_userScript) async { + Future addUserScript( + int arg_identifier, WKUserScriptData arg_userScript) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript', + codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_identifier, arg_userScript]) as Map?; + await channel.send([arg_identifier, arg_userScript]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -829,7 +902,9 @@ class WKUserContentControllerHostApi { Future removeAllUserScripts(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts', + codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -838,7 +913,8 @@ class WKUserContentControllerHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -858,24 +934,30 @@ class WKPreferencesHostApi { /// Constructor for [WKPreferencesHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKPreferencesHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKPreferencesHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _WKPreferencesHostApiCodec(); - Future createFromWebViewConfiguration(int arg_identifier, int arg_configurationIdentifier) async { + Future createFromWebViewConfiguration( + int arg_identifier, int arg_configurationIdentifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_configurationIdentifier]) as Map?; + 'dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_configurationIdentifier]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -886,18 +968,21 @@ class WKPreferencesHostApi { } } - Future setJavaScriptEnabled(int arg_identifier, bool arg_enabled) async { + Future setJavaScriptEnabled( + int arg_identifier, bool arg_enabled) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_enabled]) as Map?; + 'dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_enabled]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -917,15 +1002,18 @@ class WKScriptMessageHandlerHostApi { /// Constructor for [WKScriptMessageHandlerHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKScriptMessageHandlerHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKScriptMessageHandlerHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; - static const MessageCodec codec = _WKScriptMessageHandlerHostApiCodec(); + static const MessageCodec codec = + _WKScriptMessageHandlerHostApiCodec(); Future create(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -934,7 +1022,8 @@ class WKScriptMessageHandlerHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -954,15 +1043,18 @@ class WKNavigationDelegateHostApi { /// Constructor for [WKNavigationDelegateHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKNavigationDelegateHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKNavigationDelegateHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; - static const MessageCodec codec = _WKNavigationDelegateHostApiCodec(); + static const MessageCodec codec = + _WKNavigationDelegateHostApiCodec(); Future create(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKNavigationDelegateHostApi.create', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKNavigationDelegateHostApi.create', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -971,7 +1063,8 @@ class WKNavigationDelegateHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -986,26 +1079,35 @@ class WKNavigationDelegateHostApi { class _WKNavigationDelegateFlutterApiCodec extends StandardMessageCodec { const _WKNavigationDelegateFlutterApiCodec(); } + abstract class WKNavigationDelegateFlutterApi { - static const MessageCodec codec = _WKNavigationDelegateFlutterApiCodec(); + static const MessageCodec codec = + _WKNavigationDelegateFlutterApiCodec(); void didFinishNavigation(int identifier, int webViewIdentifier, String? url); - static void setup(WKNavigationDelegateFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(WKNavigationDelegateFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMessageHandler(null); } else { channel.setMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null, expected non-null int.'); final int? arg_webViewIdentifier = (args[1] as int?); - assert(arg_webViewIdentifier != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null, expected non-null int.'); + assert(arg_webViewIdentifier != null, + 'Argument for dev.flutter.pigeon.WKNavigationDelegateFlutterApi.didFinishNavigation was null, expected non-null int.'); final String? arg_url = (args[2] as String?); - api.didFinishNavigation(arg_identifier!, arg_webViewIdentifier!, arg_url); + api.didFinishNavigation( + arg_identifier!, arg_webViewIdentifier!, arg_url); return; }); } @@ -1020,20 +1122,19 @@ class _NSObjectHostApiCodec extends StandardMessageCodec { if (value is NSKeyValueObservingOptionsEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } @@ -1042,7 +1143,8 @@ class NSObjectHostApi { /// Constructor for [NSObjectHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - NSObjectHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + NSObjectHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; @@ -1050,7 +1152,8 @@ class NSObjectHostApi { Future dispose(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.dispose', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.NSObjectHostApi.dispose', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -1059,7 +1162,8 @@ class NSObjectHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1070,18 +1174,28 @@ class NSObjectHostApi { } } - Future addObserver(int arg_identifier, int arg_observerIdentifier, String arg_keyPath, List arg_options) async { + Future addObserver( + int arg_identifier, + int arg_observerIdentifier, + String arg_keyPath, + List arg_options) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.addObserver', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_observerIdentifier, arg_keyPath, arg_options]) as Map?; + 'dev.flutter.pigeon.NSObjectHostApi.addObserver', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel.send([ + arg_identifier, + arg_observerIdentifier, + arg_keyPath, + arg_options + ]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1092,18 +1206,22 @@ class NSObjectHostApi { } } - Future removeObserver(int arg_identifier, int arg_observerIdentifier, String arg_keyPath) async { + Future removeObserver(int arg_identifier, int arg_observerIdentifier, + String arg_keyPath) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.removeObserver', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_observerIdentifier, arg_keyPath]) as Map?; + 'dev.flutter.pigeon.NSObjectHostApi.removeObserver', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel.send( + [arg_identifier, arg_observerIdentifier, arg_keyPath]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1118,11 +1236,12 @@ class NSObjectHostApi { class _NSObjectFlutterApiCodec extends StandardMessageCodec { const _NSObjectFlutterApiCodec(); } + abstract class NSObjectFlutterApi { static const MessageCodec codec = _NSObjectFlutterApiCodec(); - static void setup(NSObjectFlutterApi? api, {BinaryMessenger? binaryMessenger}) { - } + static void setup(NSObjectFlutterApi? api, + {BinaryMessenger? binaryMessenger}) {} } class _WKWebViewHostApiCodec extends StandardMessageCodec { @@ -1132,69 +1251,61 @@ class _WKWebViewHostApiCodec extends StandardMessageCodec { if (value is NSHttpCookieData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else - if (value is NSHttpCookiePropertyKeyEnumData) { + } else if (value is NSHttpCookiePropertyKeyEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else - if (value is NSKeyValueObservingOptionsEnumData) { + } else if (value is NSKeyValueObservingOptionsEnumData) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else - if (value is NSUrlRequestData) { + } else if (value is NSUrlRequestData) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else - if (value is WKAudiovisualMediaTypeEnumData) { + } else if (value is WKAudiovisualMediaTypeEnumData) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else - if (value is WKUserScriptData) { + } else if (value is WKUserScriptData) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else - if (value is WKUserScriptInjectionTimeEnumData) { + } else if (value is WKUserScriptInjectionTimeEnumData) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else - if (value is WKWebsiteDataTypeEnumData) { + } else if (value is WKWebsiteDataTypeEnumData) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSHttpCookieData.decode(readValue(buffer)!); - - case 129: + + case 129: return NSHttpCookiePropertyKeyEnumData.decode(readValue(buffer)!); - - case 130: + + case 130: return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); - - case 131: + + case 131: return NSUrlRequestData.decode(readValue(buffer)!); - - case 132: + + case 132: return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); - - case 133: + + case 133: return WKUserScriptData.decode(readValue(buffer)!); - - case 134: + + case 134: return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); - - case 135: + + case 135: return WKWebsiteDataTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } @@ -1203,24 +1314,29 @@ class WKWebViewHostApi { /// Constructor for [WKWebViewHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKWebViewHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKWebViewHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _WKWebViewHostApiCodec(); - Future create(int arg_identifier, int arg_configurationIdentifier) async { + Future create( + int arg_identifier, int arg_configurationIdentifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.create', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_configurationIdentifier]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.create', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_configurationIdentifier]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1231,18 +1347,22 @@ class WKWebViewHostApi { } } - Future setUIDelegate(int arg_identifier, int? arg_uiDelegateIdentifier) async { + Future setUIDelegate( + int arg_identifier, int? arg_uiDelegateIdentifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_identifier, arg_uiDelegateIdentifier]) as Map?; + await channel.send([arg_identifier, arg_uiDelegateIdentifier]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1253,18 +1373,22 @@ class WKWebViewHostApi { } } - Future setNavigationDelegate(int arg_identifier, int? arg_navigationDelegateIdentifier) async { + Future setNavigationDelegate( + int arg_identifier, int? arg_navigationDelegateIdentifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_navigationDelegateIdentifier]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_navigationDelegateIdentifier]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1277,7 +1401,8 @@ class WKWebViewHostApi { Future getUrl(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getUrl', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getUrl', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -1286,7 +1411,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1299,7 +1425,8 @@ class WKWebViewHostApi { Future getEstimatedProgress(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -1308,7 +1435,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1324,18 +1452,21 @@ class WKWebViewHostApi { } } - Future loadRequest(int arg_identifier, NSUrlRequestData arg_request) async { + Future loadRequest( + int arg_identifier, NSUrlRequestData arg_request) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadRequest', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_request]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.loadRequest', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_request]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1346,18 +1477,22 @@ class WKWebViewHostApi { } } - Future loadHtmlString(int arg_identifier, String arg_string, String? arg_baseUrl) async { + Future loadHtmlString( + int arg_identifier, String arg_string, String? arg_baseUrl) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_identifier, arg_string, arg_baseUrl]) as Map?; + await channel.send([arg_identifier, arg_string, arg_baseUrl]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1368,18 +1503,22 @@ class WKWebViewHostApi { } } - Future loadFileUrl(int arg_identifier, String arg_url, String arg_readAccessUrl) async { + Future loadFileUrl( + int arg_identifier, String arg_url, String arg_readAccessUrl) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_url, arg_readAccessUrl]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_url, arg_readAccessUrl]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1392,16 +1531,18 @@ class WKWebViewHostApi { Future loadFlutterAsset(int arg_identifier, String arg_key) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_key]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_key]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1414,7 +1555,8 @@ class WKWebViewHostApi { Future canGoBack(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.canGoBack', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.canGoBack', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -1423,7 +1565,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1441,7 +1584,8 @@ class WKWebViewHostApi { Future canGoForward(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.canGoForward', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.canGoForward', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -1450,7 +1594,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1468,7 +1613,8 @@ class WKWebViewHostApi { Future goBack(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.goBack', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.goBack', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -1477,7 +1623,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1490,7 +1637,8 @@ class WKWebViewHostApi { Future goForward(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.goForward', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.goForward', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -1499,7 +1647,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1512,7 +1661,8 @@ class WKWebViewHostApi { Future reload(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.reload', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.reload', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -1521,7 +1671,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1534,7 +1685,8 @@ class WKWebViewHostApi { Future getTitle(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getTitle', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getTitle', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -1543,7 +1695,8 @@ class WKWebViewHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1554,18 +1707,22 @@ class WKWebViewHostApi { } } - Future setAllowsBackForwardNavigationGestures(int arg_identifier, bool arg_allow) async { + Future setAllowsBackForwardNavigationGestures( + int arg_identifier, bool arg_allow) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_allow]) as Map?; + 'dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_allow]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1576,18 +1733,22 @@ class WKWebViewHostApi { } } - Future setCustomUserAgent(int arg_identifier, String? arg_userAgent) async { + Future setCustomUserAgent( + int arg_identifier, String? arg_userAgent) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_identifier, arg_userAgent]) as Map?; + await channel.send([arg_identifier, arg_userAgent]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1598,18 +1759,22 @@ class WKWebViewHostApi { } } - Future evaluateJavaScript(int arg_identifier, String arg_javaScriptString) async { + Future evaluateJavaScript( + int arg_identifier, String arg_javaScriptString) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = - await channel.send([arg_identifier, arg_javaScriptString]) as Map?; + await channel.send([arg_identifier, arg_javaScriptString]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1629,7 +1794,8 @@ class WKUIDelegateHostApi { /// Constructor for [WKUIDelegateHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKUIDelegateHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKUIDelegateHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; @@ -1637,7 +1803,8 @@ class WKUIDelegateHostApi { Future create(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUIDelegateHostApi.create', codec, binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.WKUIDelegateHostApi.create', codec, + binaryMessenger: _binaryMessenger); final Map? replyMap = await channel.send([arg_identifier]) as Map?; if (replyMap == null) { @@ -1646,7 +1813,8 @@ class WKUIDelegateHostApi { message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1665,27 +1833,25 @@ class _WKHttpCookieStoreHostApiCodec extends StandardMessageCodec { if (value is NSHttpCookieData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else - if (value is NSHttpCookiePropertyKeyEnumData) { + } else if (value is NSHttpCookiePropertyKeyEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSHttpCookieData.decode(readValue(buffer)!); - - case 129: + + case 129: return NSHttpCookiePropertyKeyEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } @@ -1694,24 +1860,30 @@ class WKHttpCookieStoreHostApi { /// Constructor for [WKHttpCookieStoreHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - WKHttpCookieStoreHostApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; + WKHttpCookieStoreHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _WKHttpCookieStoreHostApiCodec(); - Future createFromWebsiteDataStore(int arg_identifier, int arg_websiteDataStoreIdentifier) async { + Future createFromWebsiteDataStore( + int arg_identifier, int arg_websiteDataStoreIdentifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_websiteDataStoreIdentifier]) as Map?; + 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore', + codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_websiteDataStoreIdentifier]) + as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, @@ -1722,18 +1894,21 @@ class WKHttpCookieStoreHostApi { } } - Future setCookie(int arg_identifier, NSHttpCookieData arg_cookie) async { + Future setCookie( + int arg_identifier, NSHttpCookieData arg_cookie) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_identifier, arg_cookie]) as Map?; + 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie', codec, + binaryMessenger: _binaryMessenger); + final Map? replyMap = await channel + .send([arg_identifier, arg_cookie]) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); } else if (replyMap['error'] != null) { - final Map error = (replyMap['error'] as Map?)!; + final Map error = + (replyMap['error'] as Map?)!; throw PlatformException( code: (error['code'] as String?)!, message: error['message'] as String?, diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart index 913754d74f3b..66d7a5c75046 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart @@ -20,7 +20,7 @@ class UIScrollViewHostApiImpl extends UIScrollViewHostApi { UIScrollViewHostApiImpl({ super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; @@ -77,7 +77,7 @@ class UIViewHostApiImpl extends UIViewHostApi { UIViewHostApiImpl({ super.binaryMessenger, InstanceManager? instanceManager, - }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; + }) : instanceManager = instanceManager ?? NSObject.globalInstanceManager; /// Maintains instances stored to communicate with Objective-C objects. final InstanceManager instanceManager; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart index c83b46abb62a..3dc6c5924aff 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart @@ -606,13 +606,9 @@ class WKNavigationDelegate extends NSObject { /// Constructs a [WKNavigationDelegate]. WKNavigationDelegate({ this.didFinishNavigation, - BinaryMessenger? binaryMessenger, - InstanceManager? instanceManager, - }) : _navigationDelegateApi = WKNavigationDelegateHostApiImpl( - binaryMessenger: binaryMessenger, - instanceManager: instanceManager, - ), - super( + super.binaryMessenger, + super.instanceManager, + }) : _navigationDelegateApi = WKNavigationDelegateHostApiImpl( binaryMessenger: binaryMessenger, instanceManager: instanceManager, ) { @@ -627,13 +623,9 @@ class WKNavigationDelegate extends NSObject { /// library or to create a copy for an InstanceManager. WKNavigationDelegate.detached({ this.didFinishNavigation, - BinaryMessenger? binaryMessenger, - InstanceManager? instanceManager, - }) : _navigationDelegateApi = WKNavigationDelegateHostApiImpl( - binaryMessenger: binaryMessenger, - instanceManager: instanceManager, - ), - super( + super.binaryMessenger, + super.instanceManager, + }) : _navigationDelegateApi = WKNavigationDelegateHostApiImpl( binaryMessenger: binaryMessenger, instanceManager: instanceManager, ); @@ -726,17 +718,13 @@ class WKWebView extends UIView { /// configuration object. WKWebView( WKWebViewConfiguration configuration, { - BinaryMessenger? binaryMessenger, - InstanceManager? instanceManager, + super.binaryMessenger, + super.instanceManager, }) : _binaryMessenger = binaryMessenger, _instanceManager = instanceManager, _webViewApi = WKWebViewHostApiImpl( binaryMessenger: binaryMessenger, instanceManager: instanceManager, - ), - super( - binaryMessenger: binaryMessenger, - instanceManager: instanceManager, ) { _webViewApi.createForInstances(this, configuration); } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml b/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml index 21fb465218d3..9c62aef10e6d 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml +++ b/packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml @@ -6,7 +6,7 @@ version: 2.8.0 environment: sdk: ">=2.17.0 <3.0.0" - flutter: ">=2.5.0" + flutter: ">=2.8.0" flutter: plugin: diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart index c49fe65eaabd..00865d66f2bc 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/test_web_kit.pigeon.dart @@ -21,59 +21,75 @@ class _TestWKWebsiteDataStoreHostApiCodec extends StandardMessageCodec { if (value is WKWebsiteDataTypeEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKWebsiteDataTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } + abstract class TestWKWebsiteDataStoreHostApi { - static const MessageCodec codec = _TestWKWebsiteDataStoreHostApiCodec(); + static const MessageCodec codec = + _TestWKWebsiteDataStoreHostApiCodec(); - void createFromWebViewConfiguration(int identifier, int configurationIdentifier); + void createFromWebViewConfiguration( + int identifier, int configurationIdentifier); void createDefaultDataStore(int identifier); - Future removeDataOfTypes(int identifier, List dataTypes, double modificationTimeInSecondsSinceEpoch); - static void setup(TestWKWebsiteDataStoreHostApi? api, {BinaryMessenger? binaryMessenger}) { + Future removeDataOfTypes( + int identifier, + List dataTypes, + double modificationTimeInSecondsSinceEpoch); + static void setup(TestWKWebsiteDataStoreHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null, expected non-null int.'); final int? arg_configurationIdentifier = (args[1] as int?); - assert(arg_configurationIdentifier != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null, expected non-null int.'); - api.createFromWebViewConfiguration(arg_identifier!, arg_configurationIdentifier!); + assert(arg_configurationIdentifier != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + api.createFromWebViewConfiguration( + arg_identifier!, arg_configurationIdentifier!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.createDefaultDataStore was null, expected non-null int.'); api.createDefaultDataStore(arg_identifier!); return {}; }); @@ -81,20 +97,29 @@ abstract class TestWKWebsiteDataStoreHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null int.'); - final List? arg_dataTypes = (args[1] as List?)?.cast(); - assert(arg_dataTypes != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null List.'); - final double? arg_modificationTimeInSecondsSinceEpoch = (args[2] as double?); - assert(arg_modificationTimeInSecondsSinceEpoch != null, 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null double.'); - final bool output = await api.removeDataOfTypes(arg_identifier!, arg_dataTypes!, arg_modificationTimeInSecondsSinceEpoch!); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null int.'); + final List? arg_dataTypes = + (args[1] as List?)?.cast(); + assert(arg_dataTypes != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null List.'); + final double? arg_modificationTimeInSecondsSinceEpoch = + (args[2] as double?); + assert(arg_modificationTimeInSecondsSinceEpoch != null, + 'Argument for dev.flutter.pigeon.WKWebsiteDataStoreHostApi.removeDataOfTypes was null, expected non-null double.'); + final bool output = await api.removeDataOfTypes(arg_identifier!, + arg_dataTypes!, arg_modificationTimeInSecondsSinceEpoch!); return {'result': output}; }); } @@ -105,23 +130,28 @@ abstract class TestWKWebsiteDataStoreHostApi { class _TestUIViewHostApiCodec extends StandardMessageCodec { const _TestUIViewHostApiCodec(); } + abstract class TestUIViewHostApi { static const MessageCodec codec = _TestUIViewHostApiCodec(); void setBackgroundColor(int identifier, int? value); void setOpaque(int identifier, bool opaque); - static void setup(TestUIViewHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestUIViewHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIViewHostApi.setBackgroundColor', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIViewHostApi.setBackgroundColor', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setBackgroundColor was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.UIViewHostApi.setBackgroundColor was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setBackgroundColor was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.UIViewHostApi.setBackgroundColor was null, expected non-null int.'); final int? arg_value = (args[1] as int?); api.setBackgroundColor(arg_identifier!, arg_value); return {}; @@ -130,17 +160,21 @@ abstract class TestUIViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIViewHostApi.setOpaque', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIViewHostApi.setOpaque', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null, expected non-null int.'); final bool? arg_opaque = (args[1] as bool?); - assert(arg_opaque != null, 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null, expected non-null bool.'); + assert(arg_opaque != null, + 'Argument for dev.flutter.pigeon.UIViewHostApi.setOpaque was null, expected non-null bool.'); api.setOpaque(arg_identifier!, arg_opaque!); return {}; }); @@ -152,6 +186,7 @@ abstract class TestUIViewHostApi { class _TestUIScrollViewHostApiCodec extends StandardMessageCodec { const _TestUIScrollViewHostApiCodec(); } + abstract class TestUIScrollViewHostApi { static const MessageCodec codec = _TestUIScrollViewHostApiCodec(); @@ -159,20 +194,25 @@ abstract class TestUIScrollViewHostApi { List getContentOffset(int identifier); void scrollBy(int identifier, double x, double y); void setContentOffset(int identifier, double x, double y); - static void setup(TestUIScrollViewHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestUIScrollViewHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null, expected non-null int.'); final int? arg_webViewIdentifier = (args[1] as int?); - assert(arg_webViewIdentifier != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null, expected non-null int.'); + assert(arg_webViewIdentifier != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.createFromWebView was null, expected non-null int.'); api.createFromWebView(arg_identifier!, arg_webViewIdentifier!); return {}; }); @@ -180,15 +220,18 @@ abstract class TestUIScrollViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.getContentOffset was null, expected non-null int.'); final List output = api.getContentOffset(arg_identifier!); return {'result': output}; }); @@ -196,19 +239,24 @@ abstract class TestUIScrollViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.scrollBy', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.scrollBy', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null int.'); final double? arg_x = (args[1] as double?); - assert(arg_x != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null double.'); + assert(arg_x != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null double.'); final double? arg_y = (args[2] as double?); - assert(arg_y != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null double.'); + assert(arg_y != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.scrollBy was null, expected non-null double.'); api.scrollBy(arg_identifier!, arg_x!, arg_y!); return {}; }); @@ -216,19 +264,24 @@ abstract class TestUIScrollViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null int.'); final double? arg_x = (args[1] as double?); - assert(arg_x != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null double.'); + assert(arg_x != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null double.'); final double? arg_y = (args[2] as double?); - assert(arg_y != null, 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null double.'); + assert(arg_y != null, + 'Argument for dev.flutter.pigeon.UIScrollViewHostApi.setContentOffset was null, expected non-null double.'); api.setContentOffset(arg_identifier!, arg_x!, arg_y!); return {}; }); @@ -244,42 +297,48 @@ class _TestWKWebViewConfigurationHostApiCodec extends StandardMessageCodec { if (value is WKAudiovisualMediaTypeEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } + abstract class TestWKWebViewConfigurationHostApi { - static const MessageCodec codec = _TestWKWebViewConfigurationHostApiCodec(); + static const MessageCodec codec = + _TestWKWebViewConfigurationHostApiCodec(); void create(int identifier); void createFromWebView(int identifier, int webViewIdentifier); void setAllowsInlineMediaPlayback(int identifier, bool allow); - void setMediaTypesRequiringUserActionForPlayback(int identifier, List types); - static void setup(TestWKWebViewConfigurationHostApi? api, {BinaryMessenger? binaryMessenger}) { + void setMediaTypesRequiringUserActionForPlayback( + int identifier, List types); + static void setup(TestWKWebViewConfigurationHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.create', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.create', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.create was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.create was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.create was null, expected non-null int.'); api.create(arg_identifier!); return {}; }); @@ -287,17 +346,22 @@ abstract class TestWKWebViewConfigurationHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null, expected non-null int.'); final int? arg_webViewIdentifier = (args[1] as int?); - assert(arg_webViewIdentifier != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null, expected non-null int.'); + assert(arg_webViewIdentifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.createFromWebView was null, expected non-null int.'); api.createFromWebView(arg_identifier!, arg_webViewIdentifier!); return {}; }); @@ -305,17 +369,22 @@ abstract class TestWKWebViewConfigurationHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null, expected non-null int.'); final bool? arg_allow = (args[1] as bool?); - assert(arg_allow != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null, expected non-null bool.'); + assert(arg_allow != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setAllowsInlineMediaPlayback was null, expected non-null bool.'); api.setAllowsInlineMediaPlayback(arg_identifier!, arg_allow!); return {}; }); @@ -323,18 +392,26 @@ abstract class TestWKWebViewConfigurationHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null, expected non-null int.'); - final List? arg_types = (args[1] as List?)?.cast(); - assert(arg_types != null, 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null, expected non-null List.'); - api.setMediaTypesRequiringUserActionForPlayback(arg_identifier!, arg_types!); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null, expected non-null int.'); + final List? arg_types = + (args[1] as List?) + ?.cast(); + assert(arg_types != null, + 'Argument for dev.flutter.pigeon.WKWebViewConfigurationHostApi.setMediaTypesRequiringUserActionForPlayback was null, expected non-null List.'); + api.setMediaTypesRequiringUserActionForPlayback( + arg_identifier!, arg_types!); return {}; }); } @@ -349,91 +426,112 @@ class _TestWKUserContentControllerHostApiCodec extends StandardMessageCodec { if (value is WKUserScriptData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else - if (value is WKUserScriptInjectionTimeEnumData) { + } else if (value is WKUserScriptInjectionTimeEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return WKUserScriptData.decode(readValue(buffer)!); - - case 129: + + case 129: return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } + abstract class TestWKUserContentControllerHostApi { - static const MessageCodec codec = _TestWKUserContentControllerHostApiCodec(); + static const MessageCodec codec = + _TestWKUserContentControllerHostApiCodec(); - void createFromWebViewConfiguration(int identifier, int configurationIdentifier); - void addScriptMessageHandler(int identifier, int handlerIdentifier, String name); + void createFromWebViewConfiguration( + int identifier, int configurationIdentifier); + void addScriptMessageHandler( + int identifier, int handlerIdentifier, String name); void removeScriptMessageHandler(int identifier, String name); void removeAllScriptMessageHandlers(int identifier); void addUserScript(int identifier, WKUserScriptData userScript); void removeAllUserScripts(int identifier); - static void setup(TestWKUserContentControllerHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKUserContentControllerHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null, expected non-null int.'); final int? arg_configurationIdentifier = (args[1] as int?); - assert(arg_configurationIdentifier != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null, expected non-null int.'); - api.createFromWebViewConfiguration(arg_identifier!, arg_configurationIdentifier!); + assert(arg_configurationIdentifier != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + api.createFromWebViewConfiguration( + arg_identifier!, arg_configurationIdentifier!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null int.'); final int? arg_handlerIdentifier = (args[1] as int?); - assert(arg_handlerIdentifier != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null int.'); + assert(arg_handlerIdentifier != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null int.'); final String? arg_name = (args[2] as String?); - assert(arg_name != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null String.'); - api.addScriptMessageHandler(arg_identifier!, arg_handlerIdentifier!, arg_name!); + assert(arg_name != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addScriptMessageHandler was null, expected non-null String.'); + api.addScriptMessageHandler( + arg_identifier!, arg_handlerIdentifier!, arg_name!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null, expected non-null int.'); final String? arg_name = (args[1] as String?); - assert(arg_name != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null, expected non-null String.'); + assert(arg_name != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeScriptMessageHandler was null, expected non-null String.'); api.removeScriptMessageHandler(arg_identifier!, arg_name!); return {}; }); @@ -441,15 +539,19 @@ abstract class TestWKUserContentControllerHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllScriptMessageHandlers was null, expected non-null int.'); api.removeAllScriptMessageHandlers(arg_identifier!); return {}; }); @@ -457,17 +559,23 @@ abstract class TestWKUserContentControllerHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null, expected non-null int.'); - final WKUserScriptData? arg_userScript = (args[1] as WKUserScriptData?); - assert(arg_userScript != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null, expected non-null WKUserScriptData.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null, expected non-null int.'); + final WKUserScriptData? arg_userScript = + (args[1] as WKUserScriptData?); + assert(arg_userScript != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.addUserScript was null, expected non-null WKUserScriptData.'); api.addUserScript(arg_identifier!, arg_userScript!); return {}; }); @@ -475,15 +583,19 @@ abstract class TestWKUserContentControllerHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKUserContentControllerHostApi.removeAllUserScripts was null, expected non-null int.'); api.removeAllUserScripts(arg_identifier!); return {}; }); @@ -495,43 +607,56 @@ abstract class TestWKUserContentControllerHostApi { class _TestWKPreferencesHostApiCodec extends StandardMessageCodec { const _TestWKPreferencesHostApiCodec(); } + abstract class TestWKPreferencesHostApi { static const MessageCodec codec = _TestWKPreferencesHostApiCodec(); - void createFromWebViewConfiguration(int identifier, int configurationIdentifier); + void createFromWebViewConfiguration( + int identifier, int configurationIdentifier); void setJavaScriptEnabled(int identifier, bool enabled); - static void setup(TestWKPreferencesHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKPreferencesHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null, expected non-null int.'); final int? arg_configurationIdentifier = (args[1] as int?); - assert(arg_configurationIdentifier != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null, expected non-null int.'); - api.createFromWebViewConfiguration(arg_identifier!, arg_configurationIdentifier!); + assert(arg_configurationIdentifier != null, + 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.createFromWebViewConfiguration was null, expected non-null int.'); + api.createFromWebViewConfiguration( + arg_identifier!, arg_configurationIdentifier!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null, expected non-null int.'); final bool? arg_enabled = (args[1] as bool?); - assert(arg_enabled != null, 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null, expected non-null bool.'); + assert(arg_enabled != null, + 'Argument for dev.flutter.pigeon.WKPreferencesHostApi.setJavaScriptEnabled was null, expected non-null bool.'); api.setJavaScriptEnabled(arg_identifier!, arg_enabled!); return {}; }); @@ -543,22 +668,28 @@ abstract class TestWKPreferencesHostApi { class _TestWKScriptMessageHandlerHostApiCodec extends StandardMessageCodec { const _TestWKScriptMessageHandlerHostApiCodec(); } + abstract class TestWKScriptMessageHandlerHostApi { - static const MessageCodec codec = _TestWKScriptMessageHandlerHostApiCodec(); + static const MessageCodec codec = + _TestWKScriptMessageHandlerHostApiCodec(); void create(int identifier); - static void setup(TestWKScriptMessageHandlerHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKScriptMessageHandlerHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKScriptMessageHandlerHostApi.create was null, expected non-null int.'); api.create(arg_identifier!); return {}; }); @@ -570,22 +701,28 @@ abstract class TestWKScriptMessageHandlerHostApi { class _TestWKNavigationDelegateHostApiCodec extends StandardMessageCodec { const _TestWKNavigationDelegateHostApiCodec(); } + abstract class TestWKNavigationDelegateHostApi { - static const MessageCodec codec = _TestWKNavigationDelegateHostApiCodec(); + static const MessageCodec codec = + _TestWKNavigationDelegateHostApiCodec(); void create(int identifier); - static void setup(TestWKNavigationDelegateHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKNavigationDelegateHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKNavigationDelegateHostApi.create', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKNavigationDelegateHostApi.create', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.create was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.create was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKNavigationDelegateHostApi.create was null, expected non-null int.'); api.create(arg_identifier!); return {}; }); @@ -601,41 +738,46 @@ class _TestNSObjectHostApiCodec extends StandardMessageCodec { if (value is NSKeyValueObservingOptionsEnumData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } + abstract class TestNSObjectHostApi { static const MessageCodec codec = _TestNSObjectHostApiCodec(); void dispose(int identifier); - void addObserver(int identifier, int observerIdentifier, String keyPath, List options); + void addObserver(int identifier, int observerIdentifier, String keyPath, + List options); void removeObserver(int identifier, int observerIdentifier, String keyPath); - static void setup(TestNSObjectHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestNSObjectHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.dispose', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.NSObjectHostApi.dispose', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.dispose was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.dispose was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.dispose was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.dispose was null, expected non-null int.'); api.dispose(arg_identifier!); return {}; }); @@ -643,42 +785,57 @@ abstract class TestNSObjectHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.addObserver', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.NSObjectHostApi.addObserver', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null int.'); final int? arg_observerIdentifier = (args[1] as int?); - assert(arg_observerIdentifier != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null int.'); + assert(arg_observerIdentifier != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null int.'); final String? arg_keyPath = (args[2] as String?); - assert(arg_keyPath != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null String.'); - final List? arg_options = (args[3] as List?)?.cast(); - assert(arg_options != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null List.'); - api.addObserver(arg_identifier!, arg_observerIdentifier!, arg_keyPath!, arg_options!); + assert(arg_keyPath != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null String.'); + final List? arg_options = + (args[3] as List?) + ?.cast(); + assert(arg_options != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.addObserver was null, expected non-null List.'); + api.addObserver(arg_identifier!, arg_observerIdentifier!, + arg_keyPath!, arg_options!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.NSObjectHostApi.removeObserver', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.NSObjectHostApi.removeObserver', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null int.'); final int? arg_observerIdentifier = (args[1] as int?); - assert(arg_observerIdentifier != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null int.'); + assert(arg_observerIdentifier != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null int.'); final String? arg_keyPath = (args[2] as String?); - assert(arg_keyPath != null, 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null String.'); - api.removeObserver(arg_identifier!, arg_observerIdentifier!, arg_keyPath!); + assert(arg_keyPath != null, + 'Argument for dev.flutter.pigeon.NSObjectHostApi.removeObserver was null, expected non-null String.'); + api.removeObserver( + arg_identifier!, arg_observerIdentifier!, arg_keyPath!); return {}; }); } @@ -693,72 +850,65 @@ class _TestWKWebViewHostApiCodec extends StandardMessageCodec { if (value is NSHttpCookieData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else - if (value is NSHttpCookiePropertyKeyEnumData) { + } else if (value is NSHttpCookiePropertyKeyEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else - if (value is NSKeyValueObservingOptionsEnumData) { + } else if (value is NSKeyValueObservingOptionsEnumData) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else - if (value is NSUrlRequestData) { + } else if (value is NSUrlRequestData) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else - if (value is WKAudiovisualMediaTypeEnumData) { + } else if (value is WKAudiovisualMediaTypeEnumData) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else - if (value is WKUserScriptData) { + } else if (value is WKUserScriptData) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else - if (value is WKUserScriptInjectionTimeEnumData) { + } else if (value is WKUserScriptInjectionTimeEnumData) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else - if (value is WKWebsiteDataTypeEnumData) { + } else if (value is WKWebsiteDataTypeEnumData) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSHttpCookieData.decode(readValue(buffer)!); - - case 129: + + case 129: return NSHttpCookiePropertyKeyEnumData.decode(readValue(buffer)!); - - case 130: + + case 130: return NSKeyValueObservingOptionsEnumData.decode(readValue(buffer)!); - - case 131: + + case 131: return NSUrlRequestData.decode(readValue(buffer)!); - - case 132: + + case 132: return WKAudiovisualMediaTypeEnumData.decode(readValue(buffer)!); - - case 133: + + case 133: return WKUserScriptData.decode(readValue(buffer)!); - - case 134: + + case 134: return WKUserScriptInjectionTimeEnumData.decode(readValue(buffer)!); - - case 135: + + case 135: return WKWebsiteDataTypeEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } + abstract class TestWKWebViewHostApi { static const MessageCodec codec = _TestWKWebViewHostApiCodec(); @@ -780,20 +930,25 @@ abstract class TestWKWebViewHostApi { void setAllowsBackForwardNavigationGestures(int identifier, bool allow); void setCustomUserAgent(int identifier, String? userAgent); Future evaluateJavaScript(int identifier, String javaScriptString); - static void setup(TestWKWebViewHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKWebViewHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.create', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.create', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null, expected non-null int.'); final int? arg_configurationIdentifier = (args[1] as int?); - assert(arg_configurationIdentifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null, expected non-null int.'); + assert(arg_configurationIdentifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.create was null, expected non-null int.'); api.create(arg_identifier!, arg_configurationIdentifier!); return {}; }); @@ -801,15 +956,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setUIDelegate was null, expected non-null int.'); final int? arg_uiDelegateIdentifier = (args[1] as int?); api.setUIDelegate(arg_identifier!, arg_uiDelegateIdentifier); return {}; @@ -818,32 +976,39 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setNavigationDelegate was null, expected non-null int.'); final int? arg_navigationDelegateIdentifier = (args[1] as int?); - api.setNavigationDelegate(arg_identifier!, arg_navigationDelegateIdentifier); + api.setNavigationDelegate( + arg_identifier!, arg_navigationDelegateIdentifier); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getUrl', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getUrl', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getUrl was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getUrl was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getUrl was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getUrl was null, expected non-null int.'); final String? output = api.getUrl(arg_identifier!); return {'result': output}; }); @@ -851,15 +1016,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getEstimatedProgress was null, expected non-null int.'); final double output = api.getEstimatedProgress(arg_identifier!); return {'result': output}; }); @@ -867,17 +1035,21 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadRequest', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadRequest', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null, expected non-null int.'); final NSUrlRequestData? arg_request = (args[1] as NSUrlRequestData?); - assert(arg_request != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null, expected non-null NSUrlRequestData.'); + assert(arg_request != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadRequest was null, expected non-null NSUrlRequestData.'); api.loadRequest(arg_identifier!, arg_request!); return {}; }); @@ -885,17 +1057,21 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null, expected non-null int.'); final String? arg_string = (args[1] as String?); - assert(arg_string != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null, expected non-null String.'); + assert(arg_string != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadHtmlString was null, expected non-null String.'); final String? arg_baseUrl = (args[2] as String?); api.loadHtmlString(arg_identifier!, arg_string!, arg_baseUrl); return {}; @@ -904,19 +1080,24 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null int.'); final String? arg_url = (args[1] as String?); - assert(arg_url != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null String.'); + assert(arg_url != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null String.'); final String? arg_readAccessUrl = (args[2] as String?); - assert(arg_readAccessUrl != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null String.'); + assert(arg_readAccessUrl != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFileUrl was null, expected non-null String.'); api.loadFileUrl(arg_identifier!, arg_url!, arg_readAccessUrl!); return {}; }); @@ -924,17 +1105,21 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null, expected non-null int.'); final String? arg_key = (args[1] as String?); - assert(arg_key != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null, expected non-null String.'); + assert(arg_key != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.loadFlutterAsset was null, expected non-null String.'); api.loadFlutterAsset(arg_identifier!, arg_key!); return {}; }); @@ -942,15 +1127,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.canGoBack', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.canGoBack', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoBack was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoBack was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoBack was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoBack was null, expected non-null int.'); final bool output = api.canGoBack(arg_identifier!); return {'result': output}; }); @@ -958,15 +1146,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.canGoForward', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.canGoForward', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoForward was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoForward was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoForward was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.canGoForward was null, expected non-null int.'); final bool output = api.canGoForward(arg_identifier!); return {'result': output}; }); @@ -974,15 +1165,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.goBack', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.goBack', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goBack was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goBack was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goBack was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goBack was null, expected non-null int.'); api.goBack(arg_identifier!); return {}; }); @@ -990,15 +1184,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.goForward', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.goForward', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goForward was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goForward was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goForward was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.goForward was null, expected non-null int.'); api.goForward(arg_identifier!); return {}; }); @@ -1006,15 +1203,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.reload', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.reload', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.reload was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.reload was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.reload was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.reload was null, expected non-null int.'); api.reload(arg_identifier!); return {}; }); @@ -1022,15 +1222,18 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.getTitle', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.getTitle', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getTitle was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getTitle was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getTitle was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.getTitle was null, expected non-null int.'); final String? output = api.getTitle(arg_identifier!); return {'result': output}; }); @@ -1038,33 +1241,42 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null, expected non-null int.'); final bool? arg_allow = (args[1] as bool?); - assert(arg_allow != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null, expected non-null bool.'); - api.setAllowsBackForwardNavigationGestures(arg_identifier!, arg_allow!); + assert(arg_allow != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setAllowsBackForwardNavigationGestures was null, expected non-null bool.'); + api.setAllowsBackForwardNavigationGestures( + arg_identifier!, arg_allow!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.setCustomUserAgent was null, expected non-null int.'); final String? arg_userAgent = (args[1] as String?); api.setCustomUserAgent(arg_identifier!, arg_userAgent); return {}; @@ -1073,18 +1285,23 @@ abstract class TestWKWebViewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null, expected non-null int.'); final String? arg_javaScriptString = (args[1] as String?); - assert(arg_javaScriptString != null, 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null, expected non-null String.'); - final Object? output = await api.evaluateJavaScript(arg_identifier!, arg_javaScriptString!); + assert(arg_javaScriptString != null, + 'Argument for dev.flutter.pigeon.WKWebViewHostApi.evaluateJavaScript was null, expected non-null String.'); + final Object? output = await api.evaluateJavaScript( + arg_identifier!, arg_javaScriptString!); return {'result': output}; }); } @@ -1095,22 +1312,27 @@ abstract class TestWKWebViewHostApi { class _TestWKUIDelegateHostApiCodec extends StandardMessageCodec { const _TestWKUIDelegateHostApiCodec(); } + abstract class TestWKUIDelegateHostApi { static const MessageCodec codec = _TestWKUIDelegateHostApiCodec(); void create(int identifier); - static void setup(TestWKUIDelegateHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKUIDelegateHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKUIDelegateHostApi.create', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKUIDelegateHostApi.create', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKUIDelegateHostApi.create was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKUIDelegateHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKUIDelegateHostApi.create was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKUIDelegateHostApi.create was null, expected non-null int.'); api.create(arg_identifier!); return {}; }); @@ -1126,67 +1348,79 @@ class _TestWKHttpCookieStoreHostApiCodec extends StandardMessageCodec { if (value is NSHttpCookieData) { buffer.putUint8(128); writeValue(buffer, value.encode()); - } else - if (value is NSHttpCookiePropertyKeyEnumData) { + } else if (value is NSHttpCookiePropertyKeyEnumData) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else -{ + } else { super.writeValue(buffer, value); } } + @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return NSHttpCookieData.decode(readValue(buffer)!); - - case 129: + + case 129: return NSHttpCookiePropertyKeyEnumData.decode(readValue(buffer)!); - - default: + + default: return super.readValueOfType(type, buffer); - } } } + abstract class TestWKHttpCookieStoreHostApi { - static const MessageCodec codec = _TestWKHttpCookieStoreHostApiCodec(); + static const MessageCodec codec = + _TestWKHttpCookieStoreHostApiCodec(); - void createFromWebsiteDataStore(int identifier, int websiteDataStoreIdentifier); + void createFromWebsiteDataStore( + int identifier, int websiteDataStoreIdentifier); Future setCookie(int identifier, NSHttpCookieData cookie); - static void setup(TestWKHttpCookieStoreHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestWKHttpCookieStoreHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore', + codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null, expected non-null int.'); final int? arg_websiteDataStoreIdentifier = (args[1] as int?); - assert(arg_websiteDataStoreIdentifier != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null, expected non-null int.'); - api.createFromWebsiteDataStore(arg_identifier!, arg_websiteDataStoreIdentifier!); + assert(arg_websiteDataStoreIdentifier != null, + 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.createFromWebsiteDataStore was null, expected non-null int.'); + api.createFromWebsiteDataStore( + arg_identifier!, arg_websiteDataStoreIdentifier!); return {}; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie', codec, binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie', codec, + binaryMessenger: binaryMessenger); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null, expected non-null int.'); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null, expected non-null int.'); final NSHttpCookieData? arg_cookie = (args[1] as NSHttpCookieData?); - assert(arg_cookie != null, 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null, expected non-null NSHttpCookieData.'); + assert(arg_cookie != null, + 'Argument for dev.flutter.pigeon.WKHttpCookieStoreHostApi.setCookie was null, expected non-null NSHttpCookieData.'); await api.setCookie(arg_identifier!, arg_cookie!); return {}; }); From 2be09aa09984948fbf55712367f9051cc20328a1 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Wed, 25 May 2022 17:30:13 -0700 Subject: [PATCH 35/40] some updates --- .../ios/Flutter/AppFrameworkInfo.plist | 2 +- .../example/ios/Podfile | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 4 +-- .../ios/RunnerTests/FWFInstanceManagerTests.m | 2 ++ .../ios/RunnerTests/FWFUIViewHostApiTests.m | 1 + .../ios/Classes/FWFInstanceManager.h | 15 ----------- .../ios/Classes/FWFInstanceManager.m | 5 +++- .../ios/Classes/FWFInstanceManager_Test.h | 26 +++++++++++++++++++ .../Classes/FWFNavigationDelegateHostApi.m | 2 ++ .../ios/Classes/FWFObjectHostApi.m | 2 ++ .../ios/Classes/FWFUIDelegateHostApi.m | 1 - .../ios/Classes/FlutterWebView.modulemap | 1 + .../lib/src/common/instance_manager.dart | 8 +++--- .../lib/src/ui_kit/ui_kit_api_impls.dart | 1 - .../lib/src/web_kit_webview_widget.dart | 4 +-- 15 files changed, 49 insertions(+), 27 deletions(-) create mode 100644 packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager_Test.h diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist index 8d4492f977ad..9625e105df39 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Podfile b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Podfile index 66509fcae284..d01e899e347b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Podfile +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +# platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj index e7519af18e7c..4ed8769ea518 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj @@ -614,7 +614,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -664,7 +664,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m index d1ceafe1545a..69206849e0cd 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m @@ -3,7 +3,9 @@ // found in the LICENSE file. #import + @import webview_flutter_wkwebview; +@import webview_flutter_wkwebview.Test; @interface FWFInstanceManagerTests : XCTestCase @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m index dbf444fbc84e..65a24d97a39a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFUIViewHostApiTests.m @@ -45,4 +45,5 @@ - (void)testSetOpaque { OCMVerify([mockUIView setOpaque:YES]); XCTAssertNil(error); } + @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h index 8b3ff5129498..cc76ea9676f7 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h @@ -82,21 +82,6 @@ typedef void (^FWFOnDeallocCallback)(long identifier); */ - (long)identifierForInstance:(nonnull NSObject *)instance identifierWillBePassedToFlutter:(BOOL)willBePassed; - -/** - * The number of instances stored as a strong reference. - * - * Added for debugging purposes. - */ -- (NSUInteger)strongInstanceCount; - -/** - * The number of instances stored as a weak reference. - * - * Added for debugging purposes. NSMapTables that store keys or objects as weak reference will be - * reclaimed nondeterministically. - */ -- (NSUInteger)weakInstanceCount; @end NS_ASSUME_NONNULL_END diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index 600af78b4427..0b6bbd4a5565 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -3,6 +3,9 @@ // found in the LICENSE file. #import "FWFInstanceManager.h" +#import "FWFInstanceManager_Test.h" + +#import // Attaches to an object to receive a callback when the object is deallocated. @interface FWFFinalizer : NSObject @@ -51,7 +54,7 @@ @interface FWFInstanceManager () @implementation FWFInstanceManager // Identifiers are locked to a specific range to avoid collisions with objects -// created simultaneously by Dart. +// created simultaneously from Dart. // Host uses identifiers >= 2^16 and Dart is expected to use values n where, // 0 <= n < 2^16. long const FWFMinHostCreatedIdentifier = 65536; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager_Test.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager_Test.h new file mode 100644 index 000000000000..4f609049de0e --- /dev/null +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager_Test.h @@ -0,0 +1,26 @@ +// 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. + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface FWFInstanceManager () +/** + * The number of instances stored as a strong reference. + * + * Added for debugging purposes. + */ +- (NSUInteger)strongInstanceCount; + +/** + * The number of instances stored as a weak reference. + * + * Added for debugging purposes. NSMapTables that store keys or objects as weak reference will be + * reclaimed nondeterministically. + */ +- (NSUInteger)weakInstanceCount; +@end + +NS_ASSUME_NONNULL_END diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m index ce849a15330c..9ca5247b93da 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m @@ -6,6 +6,7 @@ #import "FWFWebViewConfigurationHostApi.h" @interface FWFNavigationDelegateFlutterApiImpl () +// This reference must be weak to prevent a circular reference with the objects it stores. @property(nonatomic, weak) FWFInstanceManager *instanceManager; @end @@ -60,6 +61,7 @@ - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigat @interface FWFNavigationDelegateHostApiImpl () @property(weak) id binaryMessenger; +// This reference must be weak to prevent a circular reference with the objects it stores. @property(nonatomic, weak) FWFInstanceManager *instanceManager; @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m index 284cde74e4ad..0cc4c5693342 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFObjectHostApi.m @@ -6,6 +6,7 @@ #import "FWFDataConverters.h" @interface FWFObjectFlutterApi () +// This reference must be weak to prevent a circular reference with the objects it stores. @property(nonatomic, weak) FWFInstanceManager *instanceManager; @end @@ -33,6 +34,7 @@ - (instancetype)initWithBinaryMessenger:(id)binaryMessen @end @interface FWFObjectHostApiImpl () +// This reference must be weak to prevent a circular reference with the objects it stores. @property(nonatomic, weak) FWFInstanceManager *instanceManager; @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m index 7a545f4c5379..28d0ab53aaad 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFUIDelegateHostApi.m @@ -30,5 +30,4 @@ - (void)createWithIdentifier:(nonnull NSNumber *)identifier FWFUIDelegate *uIDelegate = [[FWFUIDelegate alloc] init]; [self.instanceManager addDartCreatedInstance:uIDelegate withIdentifier:identifier.longValue]; } - @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FlutterWebView.modulemap b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FlutterWebView.modulemap index 096507557688..639d89498d00 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FlutterWebView.modulemap +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FlutterWebView.modulemap @@ -7,5 +7,6 @@ framework module webview_flutter_wkwebview { explicit module Test { header "FlutterWebView_Test.h" header "FLTCookieManager_Test.h" + header "FWFInstanceManager_Test.h" } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index defae1fffe14..9cab112dd649 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -193,9 +193,11 @@ class InstanceManager { } int _nextUniqueIdentifier() { - while (containsIdentifier(_nextIdentifier)) { + late int identifier; + do { + identifier = _nextIdentifier; _nextIdentifier = (_nextIdentifier + 1) % _maxDartCreatedIdentifier; - } - return _nextIdentifier; + } while (containsIdentifier(identifier)); + return identifier; } } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart index 66d7a5c75046..0cf2feae13dd 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/ui_kit/ui_kit_api_impls.dart @@ -6,7 +6,6 @@ import 'dart:async'; import 'dart:math'; import 'package:flutter/painting.dart' show Color; -import 'package:flutter/services.dart'; import 'package:webview_flutter_wkwebview/src/foundation/foundation.dart'; import '../common/instance_manager.dart'; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit_webview_widget.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit_webview_widget.dart index 1d3f835b5d46..90f1554bf99b 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit_webview_widget.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit_webview_widget.dart @@ -18,14 +18,14 @@ import 'web_kit/web_kit.dart'; class WebKitWebViewWidget extends StatefulWidget { /// Constructs a [WebKitWebViewWidget]. const WebKitWebViewWidget({ - Key? key, + super.key, required this.creationParams, required this.callbacksHandler, required this.javascriptChannelRegistry, required this.onBuildWidget, this.configuration, @visibleForTesting this.webViewProxy = const WebViewWidgetProxy(), - }) : super(key: key); + }); /// The initial parameters used to setup the WebView. final CreationParams creationParams; From ea0fe93a80ecea830bb56f7870583c3e291b163b Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 26 May 2022 15:43:38 -0700 Subject: [PATCH 36/40] method names --- .../ios/RunnerTests/FWFInstanceManagerTests.m | 6 ++-- .../ios/RunnerTests/FWFObjectHostApiTests.m | 3 +- .../ios/Classes/FWFInstanceManager.h | 19 ++++++---- .../ios/Classes/FWFInstanceManager.m | 27 ++++++++------ .../Classes/FWFNavigationDelegateHostApi.m | 14 ++++---- .../lib/src/common/instance_manager.dart | 30 +++++++--------- .../lib/src/web_kit/web_kit_api_impls.dart | 13 +++---- .../src/common/instance_manager_test.dart | 35 +++++++------------ 8 files changed, 67 insertions(+), 80 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m index 69206849e0cd..8cb7f8327200 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m @@ -17,8 +17,7 @@ - (void)testAddFlutterCreatedInstance { [instanceManager addDartCreatedInstance:object withIdentifier:0]; XCTAssertEqualObjects([instanceManager instanceForIdentifier:0], object); - XCTAssertEqual([instanceManager identifierForInstance:object identifierWillBePassedToFlutter:NO], - 0); + XCTAssertEqual([instanceManager identifierWithStrongReferenceForInstance:object], 0); } - (void)testAddHostCreatedInstance { @@ -26,8 +25,7 @@ - (void)testAddHostCreatedInstance { NSObject *object = [[NSObject alloc] init]; [instanceManager addHostCreatedInstance:object]; - long identifier = [instanceManager identifierForInstance:object - identifierWillBePassedToFlutter:NO]; + long identifier = [instanceManager identifierWithStrongReferenceForInstance:object]; XCTAssertNotEqual(identifier, NSNotFound); XCTAssertEqualObjects([instanceManager instanceForIdentifier:identifier], object); } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m index 3a381295ea0d..bdaeae4c09dc 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFObjectHostApiTests.m @@ -79,8 +79,7 @@ - (void)testDispose { // Only the strong reference is removed, so the weak reference will remain until object is set to // nil. object = nil; - XCTAssertEqual([instanceManager identifierForInstance:object identifierWillBePassedToFlutter:NO], - NSNotFound); + XCTAssertFalse([instanceManager containsInstance:object]); XCTAssertNil(error); } @end diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h index cc76ea9676f7..902088246004 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h @@ -72,16 +72,23 @@ typedef void (^FWFOnDeallocCallback)(long identifier); /** * Retrieves the identifier paired with an instance. * + * If the manager contains `instance`, as a strong or weak reference, the strong reference to + * `instance` will be recreated and will need to be removed again with + * `removeInstanceWithIdentifier:`. + * * @param instance An instance that may be stored in the manager. - * @param willBePassed Whether the identifier will be passed to Dart. If YES, the strong reference - * to `instance` will be recreated and will need to be removed again by - * `removeStrongReferenceWithIdentifier:`. * - * @return The identifer associated with `instance` if the manager contains the value, otherwise + * @return The identifer associated with `instance` if the manager contains the value, otherwise * NSNotFound. */ -- (long)identifierForInstance:(nonnull NSObject *)instance - identifierWillBePassedToFlutter:(BOOL)willBePassed; +- (long)identifierWithStrongReferenceForInstance:(nonnull NSObject *)instance; + +/** + * Returns whether this manager contains the given `instance`. + * + * @return Whether this manager contains the given `instance`. + */ +- (BOOL)containsInstance:(nonnull NSObject *)instance; @end NS_ASSUME_NONNULL_END diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index 0b6bbd4a5565..8b1969ed3c84 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -118,25 +118,32 @@ - (nullable NSObject *)instanceForIdentifier:(long)instanceIdentifier { return instance; } -- (long)identifierForInstance:(nonnull NSObject *)instance - identifierWillBePassedToFlutter:(BOOL)willBePassed { +- (void)addInstance:(nonnull NSObject *)instance withIdentifier:(long)instanceIdentifier { + [self.identifiers setObject:@(instanceIdentifier) forKey:instance]; + [self.weakInstances setObject:instance forKey:@(instanceIdentifier)]; + [self.strongInstances setObject:instance forKey:@(instanceIdentifier)]; + [FWFFinalizer attachToInstance:instance + withIdentifier:instanceIdentifier + callback:self.deallocCallback]; +} + +- (long)identifierWithStrongReferenceForInstance:(nonnull NSObject *)instance { NSNumber *__block identifierNumber = nil; dispatch_sync(_lockQueue, ^{ identifierNumber = [self.identifiers objectForKey:instance]; - if (identifierNumber && willBePassed) { + if (identifierNumber) { [self.strongInstances setObject:instance forKey:identifierNumber]; } }); return identifierNumber ? identifierNumber.longValue : NSNotFound; } -- (void)addInstance:(nonnull NSObject *)instance withIdentifier:(long)instanceIdentifier { - [self.identifiers setObject:@(instanceIdentifier) forKey:instance]; - [self.weakInstances setObject:instance forKey:@(instanceIdentifier)]; - [self.strongInstances setObject:instance forKey:@(instanceIdentifier)]; - [FWFFinalizer attachToInstance:instance - withIdentifier:instanceIdentifier - callback:self.deallocCallback]; +- (BOOL)containsInstance:(nonnull NSObject *)instance { + BOOL __block containsInstance; + dispatch_sync(_lockQueue, ^{ + containsInstance = [self.identifiers objectForKey:instance]; + }); + return containsInstance; } - (NSUInteger)strongInstanceCount { diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m index 9ca5247b93da..be651c942c0e 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFNavigationDelegateHostApi.m @@ -20,19 +20,17 @@ - (instancetype)initWithBinaryMessenger:(id)binaryMessen return self; } -- (long)identifierForNavigationDelegate:(FWFNavigationDelegate *)instance { - return [self.instanceManager identifierForInstance:instance identifierWillBePassedToFlutter:NO]; +- (long)identifierForDelegate:(FWFNavigationDelegate *)instance { + return [self.instanceManager identifierWithStrongReferenceForInstance:instance]; } - (void)didFinishNavigationForDelegate:(FWFNavigationDelegate *)instance webView:(WKWebView *)webView URL:(NSString *)URL { - [self didFinishNavigationForDelegateWithIdentifier:@([self.instanceManager - identifierForInstance:instance - identifierWillBePassedToFlutter:YES]) - webViewIdentifier:@([self.instanceManager - identifierForInstance:webView - identifierWillBePassedToFlutter:YES]) + [self didFinishNavigationForDelegateWithIdentifier:@([self identifierForDelegate:instance]) + webViewIdentifier: + @([self.instanceManager + identifierWithStrongReferenceForInstance:webView]) URL:URL completion:^(NSError *error) { NSAssert(!error, @"%@", error); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 9cab112dd649..5a910241d08e 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -93,7 +93,7 @@ class InstanceManager { /// `null` if the instance was not found in this manager. /// /// This does not remove the the strong referenced instance associated with - /// [instance]. This can be done with [removeReference]. + /// [instance]. This can be done with [remove]. int? removeWeakReference(Copyable instance) { final int? identifier = getIdentifier(instance); if (identifier == null) { @@ -116,31 +116,25 @@ class InstanceManager { /// /// This does not remove the the weak referenced instance associtated with /// [identifier]. This can be done with [removeWeakReference]. - Copyable? removeReference(int identifier) { - return _strongInstances.remove(identifier); + T? remove(int identifier) { + return _strongInstances.remove(identifier) as T?; } /// Retrieves the instance associated with identifier. /// - /// The value returned is chosen in this order: - /// 1. A weakly referenced instance asscociated with identifier. - /// 2. When [returnedInstanceMayBeUsed] is set to `true` and the only instance - /// associated with identifier is a strongly referenced instance, a copy of the - /// instance is added as a weakly reference with the same instance id. Returning - /// the newly created weakly referenced copy. - /// 3. When [returnedInstanceMayBeUsed] is set to `false` and the only - /// instance associated with identifier has a strong reference. The strongly - /// referenced instance is returned. - /// 4. If no instance is associated with identifier, returns null. - T? getInstance( - int identifier, { - required bool returnedInstanceMayBeUsed, - }) { + /// The value returned is chosen from the following order: + /// + /// 1. A weakly referenced instance associated with identifier. + /// 2. If the only instance associated with identifier is a strongly + /// referenced instance, a copy of the instance is added as a weak reference + /// with the same identifier. Returning the newly created copy. + /// 3. If no instance is associated with identifier, returns null. + T? getInstanceWithWeakReference(int identifier) { final Copyable? weakInstance = _weakInstances[identifier]?.target; if (weakInstance == null) { final Copyable? strongInstance = _strongInstances[identifier]; - if (strongInstance != null && returnedInstanceMayBeUsed) { + if (strongInstance != null) { final Copyable copy = strongInstance.copy(); _identifiers[copy] = identifier; _weakInstances[identifier] = WeakReference(copy); diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart index 9b84cd3b2b38..85b9b492eb87 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit_api_impls.dart @@ -540,11 +540,8 @@ class WKNavigationDelegateFlutterApiImpl /// Maintains instances stored to communicate with native language objects. late final InstanceManager instanceManager; - WKNavigationDelegate _getDelegate(int instanceId) { - return instanceManager.getInstance( - instanceId, - returnedInstanceMayBeUsed: false, - )!; + WKNavigationDelegate _getDelegate(int identifier) { + return instanceManager.getInstanceWithWeakReference(identifier)!; } @override @@ -556,10 +553,8 @@ class WKNavigationDelegateFlutterApiImpl final void Function(WKWebView, String?)? function = _getDelegate(identifier).didFinishNavigation; function?.call( - instanceManager.getInstance( - webViewIdentifier, - returnedInstanceMayBeUsed: true, - )!, + instanceManager.getInstanceWithWeakReference(webViewIdentifier)! + as WKWebView, url, ); } diff --git a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart index bd02efaf2542..2fc68a489b6a 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/test/src/common/instance_manager_test.dart @@ -17,7 +17,7 @@ void main() { expect(instanceManager.getIdentifier(object), 0); expect( - instanceManager.getInstance(0, returnedInstanceMayBeUsed: false), + instanceManager.getInstanceWithWeakReference(0), object, ); }); @@ -31,7 +31,7 @@ void main() { instanceManager.addHostCreatedInstance(object, 0); expect( - () => instanceManager.addHostCreatedInstance(object, 1), + () => instanceManager.addHostCreatedInstance(object, 0), throwsAssertionError, ); @@ -52,10 +52,7 @@ void main() { final int? instanceId = instanceManager.getIdentifier(object); expect(instanceId, isNotNull); expect( - instanceManager.getInstance( - instanceId!, - returnedInstanceMayBeUsed: false, - ), + instanceManager.getInstanceWithWeakReference(instanceId!), object, ); }); @@ -73,7 +70,7 @@ void main() { expect(instanceManager.removeWeakReference(object), 0); expect( - instanceManager.getInstance(0, returnedInstanceMayBeUsed: false), + instanceManager.getInstanceWithWeakReference(0), isA(), ); expect(weakInstanceId, 0); @@ -88,9 +85,8 @@ void main() { instanceManager.addHostCreatedInstance(object, 0); expect(instanceManager.removeWeakReference(object), 0); - final CopyableObject copy = instanceManager.getInstance( + final CopyableObject copy = instanceManager.getInstanceWithWeakReference( 0, - returnedInstanceMayBeUsed: false, )!; expect(identical(object, copy), isFalse); }); @@ -103,11 +99,8 @@ void main() { instanceManager.addHostCreatedInstance(object, 0); instanceManager.removeWeakReference(object); - expect(instanceManager.removeReference(0), isA()); - expect( - instanceManager.getInstance(0, returnedInstanceMayBeUsed: false), - isNull, - ); + expect(instanceManager.remove(0), isA()); + expect(instanceManager.containsIdentifier(0), isFalse); }); test('removeStrongReference removes only strong reference', () { @@ -117,9 +110,9 @@ void main() { InstanceManager(onWeakReferenceRemoved: (_) {}); instanceManager.addHostCreatedInstance(object, 0); - expect(instanceManager.removeReference(0), isA()); + expect(instanceManager.remove(0), isA()); expect( - instanceManager.getInstance(0, returnedInstanceMayBeUsed: false), + instanceManager.getInstanceWithWeakReference(0), object, ); }); @@ -133,15 +126,11 @@ void main() { instanceManager.addHostCreatedInstance(object, 0); instanceManager.removeWeakReference(object); - final CopyableObject strongCopy = instanceManager.getInstance( - 0, - returnedInstanceMayBeUsed: false, - )!; - final CopyableObject newWeakCopy = instanceManager.getInstance( + final CopyableObject newWeakCopy = + instanceManager.getInstanceWithWeakReference( 0, - returnedInstanceMayBeUsed: true, )!; - expect(identical(strongCopy, newWeakCopy), isFalse); + expect(identical(object, newWeakCopy), isFalse); }); }); } From 9e47ddafa1b9d944621111f931532aa166f8260c Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 26 May 2022 16:05:12 -0700 Subject: [PATCH 37/40] more docs, yay --- .../webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h | 3 +++ .../lib/src/common/instance_manager.dart | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h index 902088246004..c06c3864aac0 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h @@ -76,6 +76,9 @@ typedef void (^FWFOnDeallocCallback)(long identifier); * `instance` will be recreated and will need to be removed again with * `removeInstanceWithIdentifier:`. * + * This method also expects the Dart `InstanceManager` to have, or recreate, a weak reference to the + * instance the identifier is associated with once it receives it. + * * @param instance An instance that may be stored in the manager. * * @return The identifer associated with `instance` if the manager contains the value, otherwise diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 5a910241d08e..5a8d2ef421a3 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -129,6 +129,9 @@ class InstanceManager { /// referenced instance, a copy of the instance is added as a weak reference /// with the same identifier. Returning the newly created copy. /// 3. If no instance is associated with identifier, returns null. + /// + /// This method also expects the host `InstanceManager` to have a strong + /// reference to the instance the identifier is associated with. T? getInstanceWithWeakReference(int identifier) { final Copyable? weakInstance = _weakInstances[identifier]?.target; From 8076bed25ebd232be486206ce1fada259435aeb0 Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Tue, 31 May 2022 14:11:27 -0700 Subject: [PATCH 38/40] spelling and docs --- .../ios/Classes/FWFInstanceManager.h | 2 +- .../lib/src/common/instance_manager.dart | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h index c06c3864aac0..5dec08055ce5 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.h @@ -81,7 +81,7 @@ typedef void (^FWFOnDeallocCallback)(long identifier); * * @param instance An instance that may be stored in the manager. * - * @return The identifer associated with `instance` if the manager contains the value, otherwise + * @return The identifier associated with `instance` if the manager contains the value, otherwise * NSNotFound. */ - (long)identifierWithStrongReferenceForInstance:(nonnull NSObject *)instance; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart index 5a8d2ef421a3..c9c8c2324cc6 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/common/instance_manager.dart @@ -30,11 +30,11 @@ mixin Copyable { /// When a weak referenced instance becomes inaccessible, /// [onWeakReferenceRemoved] is called with its associated identifier. /// -/// If an instance is retrieved and has the possiblity to be used, (e.g. calling -/// [getInstance] with `returnedInstanceMayBeUsed` as `true`) a copy of the -/// strong reference is added as a weak reference with the same identifier. This -/// prevents a scenario where the weak referenced instance was released and then -/// later returned by the host platform. +/// If an instance is retrieved and has the possibility to be used, +/// (e.g. calling [getInstanceWithWeakReference]) a copy of the strong reference +/// is added as a weak reference with the same identifier. This prevents a +/// scenario where the weak referenced instance was released and then later +/// returned by the host platform. class InstanceManager { /// Constructs an [InstanceManager]. InstanceManager({required void Function(int) onWeakReferenceRemoved}) { From 0fa7a146c19878361d82d963fba1b9ccbe8b5c4f Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 2 Jun 2022 11:36:32 -0700 Subject: [PATCH 39/40] pr comments --- .../example/ios/Flutter/AppFrameworkInfo.plist | 2 +- .../webview_flutter_wkwebview/example/ios/Podfile | 2 +- .../example/ios/Runner.xcodeproj/project.pbxproj | 4 ++-- .../webview_flutter_wkwebview/example/ios/Runner/Info.plist | 2 -- .../example/ios/RunnerTests/FWFInstanceManagerTests.m | 2 +- .../ios/Classes/FWFInstanceManager.m | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist index 9625e105df39..8d4492f977ad 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 11.0 + 9.0 diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Podfile b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Podfile index d01e899e347b..66509fcae284 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Podfile +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '11.0' +# platform :ios, '9.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj index 4ed8769ea518..e7519af18e7c 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner.xcodeproj/project.pbxproj @@ -614,7 +614,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -664,7 +664,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner/Info.plist b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner/Info.plist index bea41604e8aa..a810c5a172c0 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner/Info.plist +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/Runner/Info.plist @@ -41,7 +41,5 @@ UIViewControllerBasedStatusBarAppearance - CADisableMinimumFrameDurationOnPhone - diff --git a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m index 8cb7f8327200..2ad4bd48b2e8 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFInstanceManagerTests.m @@ -11,7 +11,7 @@ @interface FWFInstanceManagerTests : XCTestCase @end @implementation FWFInstanceManagerTests -- (void)testAddFlutterCreatedInstance { +- (void)testAddDartCreatedInstance { FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; NSObject *object = [[NSObject alloc] init]; diff --git a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m index 8b1969ed3c84..1fe04a39503f 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m +++ b/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFInstanceManager.m @@ -57,7 +57,7 @@ @implementation FWFInstanceManager // created simultaneously from Dart. // Host uses identifiers >= 2^16 and Dart is expected to use values n where, // 0 <= n < 2^16. -long const FWFMinHostCreatedIdentifier = 65536; +static long const FWFMinHostCreatedIdentifier = 65536; - (instancetype)init { self = [super init]; From 797d448825324ace7173c9d1f8bfea9cfd442c9b Mon Sep 17 00:00:00 2001 From: Maurice Parrish <10687576+bparrishMines@users.noreply.github.com> Date: Thu, 2 Jun 2022 12:08:06 -0700 Subject: [PATCH 40/40] format and issue --- .../webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart index 3dc6c5924aff..2b887e97adcf 100644 --- a/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart +++ b/packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart @@ -12,7 +12,7 @@ import 'web_kit_api_impls.dart'; // TODO(bparrishMines): All subclasses of NSObject need to pass their // InstanceManager and BinaryMessenger to its parent. They also need to -// override copy(); +// override copy(): https://github.com/flutter/flutter/issues/105245 /// Times at which to inject script content into a webpage. /// @@ -633,10 +633,7 @@ class WKNavigationDelegate extends NSObject { final WKNavigationDelegateHostApiImpl _navigationDelegateApi; /// Called when navigation is complete. - final void Function( - WKWebView webView, - String? url, - )? didFinishNavigation; + final void Function(WKWebView webView, String? url)? didFinishNavigation; /// Called when navigation from the main frame has started. Future setDidStartProvisionalNavigation(