diff --git a/flutter_inappwebview_android/lib/src/chrome_safari_browser/chrome_safari_browser.dart b/flutter_inappwebview_android/lib/src/chrome_safari_browser/chrome_safari_browser.dart index af770c3f..8c2b008f 100755 --- a/flutter_inappwebview_android/lib/src/chrome_safari_browser/chrome_safari_browser.dart +++ b/flutter_inappwebview_android/lib/src/chrome_safari_browser/chrome_safari_browser.dart @@ -86,11 +86,6 @@ class AndroidChromeSafariBrowser extends PlatformChromeSafariBrowser final bool? didLoadSuccessfully = call.arguments["didLoadSuccessfully"]; eventHandler?.onCompletedInitialLoad(didLoadSuccessfully); break; - case "onInitialLoadDidRedirect": - final String? url = call.arguments["url"]; - final WebUri? uri = url != null ? WebUri(url) : null; - eventHandler?.onInitialLoadDidRedirect(uri); - break; case "onNavigationEvent": final navigationEvent = CustomTabsNavigationEventType.fromNativeValue( call.arguments["navigationEvent"]); @@ -106,9 +101,6 @@ class AndroidChromeSafariBrowser extends PlatformChromeSafariBrowser eventHandler?.onRelationshipValidationResult( relation, requestedOrigin, result); break; - case "onWillOpenInBrowser": - eventHandler?.onWillOpenInBrowser(); - break; case "onClosed": _isOpened = false; final onClosed = eventHandler?.onClosed; @@ -370,30 +362,6 @@ class AndroidChromeSafariBrowser extends PlatformChromeSafariBrowser return await _staticChannel.invokeMethod("getPackageName", args); } - @override - Future clearWebsiteData() async { - Map args = {}; - await _staticChannel.invokeMethod("clearWebsiteData", args); - } - - @override - Future prewarmConnections(List URLs) async { - Map args = {}; - args.putIfAbsent('URLs', () => URLs.map((e) => e.toString()).toList()); - Map? result = - (await _staticChannel.invokeMethod("prewarmConnections", args)) - ?.cast(); - return PrewarmingToken.fromMap(result); - } - - @override - Future invalidatePrewarmingToken( - PrewarmingToken prewarmingToken) async { - Map args = {}; - args.putIfAbsent('prewarmingToken', () => prewarmingToken.toMap()); - await _staticChannel.invokeMethod("invalidatePrewarmingToken", args); - } - @override bool isOpened() { return _isOpened; diff --git a/flutter_inappwebview_android/lib/src/cookie_manager.dart b/flutter_inappwebview_android/lib/src/cookie_manager.dart index 1bef4439..1499b6e7 100755 --- a/flutter_inappwebview_android/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_android/lib/src/cookie_manager.dart @@ -5,9 +5,6 @@ import 'package:flutter/services.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; -import 'in_app_webview/headless_in_app_webview.dart'; -import 'platform_util.dart'; - /// Object specifying creation parameters for creating a [AndroidCookieManager]. /// /// When adding additional fields make sure they can be null or have a default @@ -77,28 +74,11 @@ class AndroidCookieManager extends PlatformCookieManager @Deprecated("Use webViewController instead") PlatformInAppWebViewController? iosBelow11WebViewController, PlatformInAppWebViewController? webViewController}) async { - webViewController = webViewController ?? iosBelow11WebViewController; - assert(url.toString().isNotEmpty); assert(name.isNotEmpty); assert(value.isNotEmpty); assert(path.isNotEmpty); - if (await _shouldUseJavascript()) { - await _setCookieWithJavaScript( - url: url, - name: name, - value: value, - domain: domain, - path: path, - expiresDate: expiresDate, - maxAge: maxAge, - isSecure: isSecure, - sameSite: sameSite, - webViewController: webViewController); - return true; - } - Map args = {}; args.putIfAbsent('url', () => url.toString()); args.putIfAbsent('name', () => name); @@ -114,57 +94,6 @@ class AndroidCookieManager extends PlatformCookieManager return await channel?.invokeMethod('setCookie', args) ?? false; } - Future _setCookieWithJavaScript( - {required WebUri url, - required String name, - required String value, - String path = "/", - String? domain, - int? expiresDate, - int? maxAge, - bool? isSecure, - HTTPCookieSameSitePolicy? sameSite, - PlatformInAppWebViewController? webViewController}) async { - var cookieValue = name + "=" + value + "; Path=" + path; - - if (domain != null) cookieValue += "; Domain=" + domain; - - if (expiresDate != null) - cookieValue += "; Expires=" + await _getCookieExpirationDate(expiresDate); - - if (maxAge != null) cookieValue += "; Max-Age=" + maxAge.toString(); - - if (isSecure != null && isSecure) cookieValue += "; Secure"; - - if (sameSite != null) - cookieValue += "; SameSite=" + sameSite.toNativeValue(); - - cookieValue += ";"; - - if (webViewController != null) { - final javaScriptEnabled = - (await webViewController.getSettings())?.javaScriptEnabled ?? false; - if (javaScriptEnabled) { - await webViewController.evaluateJavascript( - source: 'document.cookie="$cookieValue"'); - return; - } - } - - final setCookieCompleter = Completer(); - final headlessWebView = - AndroidHeadlessInAppWebView(AndroidHeadlessInAppWebViewCreationParams( - initialUrlRequest: URLRequest(url: url), - onLoadStop: (controller, url) async { - await controller.evaluateJavascript( - source: 'document.cookie="$cookieValue"'); - setCookieCompleter.complete(); - })); - await headlessWebView.run(); - await setCookieCompleter.future; - await headlessWebView.dispose(); - } - @override Future> getCookies( {required WebUri url, @@ -173,13 +102,6 @@ class AndroidCookieManager extends PlatformCookieManager PlatformInAppWebViewController? webViewController}) async { assert(url.toString().isNotEmpty); - webViewController = webViewController ?? iosBelow11WebViewController; - - if (await _shouldUseJavascript()) { - return await _getCookiesWithJavaScript( - url: url, webViewController: webViewController); - } - List cookies = []; Map args = {}; @@ -204,64 +126,6 @@ class AndroidCookieManager extends PlatformCookieManager return cookies; } - Future> _getCookiesWithJavaScript( - {required WebUri url, - PlatformInAppWebViewController? webViewController}) async { - assert(url.toString().isNotEmpty); - - List cookies = []; - - if (webViewController != null) { - final javaScriptEnabled = - (await webViewController.getSettings())?.javaScriptEnabled ?? false; - if (javaScriptEnabled) { - List documentCookies = (await webViewController - .evaluateJavascript(source: 'document.cookie') as String) - .split(';') - .map((documentCookie) => documentCookie.trim()) - .toList(); - documentCookies.forEach((documentCookie) { - List cookie = documentCookie.split('='); - if (cookie.length > 1) { - cookies.add(Cookie( - name: cookie[0], - value: cookie[1], - )); - } - }); - return cookies; - } - } - - final pageLoaded = Completer(); - final headlessWebView = - AndroidHeadlessInAppWebView(AndroidHeadlessInAppWebViewCreationParams( - initialUrlRequest: URLRequest(url: url), - onLoadStop: (controller, url) async { - pageLoaded.complete(); - }, - )); - await headlessWebView.run(); - await pageLoaded.future; - - List documentCookies = (await headlessWebView.webViewController! - .evaluateJavascript(source: 'document.cookie') as String) - .split(';') - .map((documentCookie) => documentCookie.trim()) - .toList(); - documentCookies.forEach((documentCookie) { - List cookie = documentCookie.split('='); - if (cookie.length > 1) { - cookies.add(Cookie( - name: cookie[0], - value: cookie[1], - )); - } - }); - await headlessWebView.dispose(); - return cookies; - } - @override Future getCookie( {required WebUri url, @@ -272,16 +136,6 @@ class AndroidCookieManager extends PlatformCookieManager assert(url.toString().isNotEmpty); assert(name.isNotEmpty); - webViewController = webViewController ?? iosBelow11WebViewController; - - if (await _shouldUseJavascript()) { - List cookies = await _getCookiesWithJavaScript( - url: url, webViewController: webViewController); - return cookies - .cast() - .firstWhere((cookie) => cookie!.name == name, orElse: () => null); - } - Map args = {}; args.putIfAbsent('url', () => url.toString()); List cookies = @@ -317,20 +171,6 @@ class AndroidCookieManager extends PlatformCookieManager assert(url.toString().isNotEmpty); assert(name.isNotEmpty); - webViewController = webViewController ?? iosBelow11WebViewController; - - if (await _shouldUseJavascript()) { - await _setCookieWithJavaScript( - url: url, - name: name, - value: "", - path: path, - domain: domain, - maxAge: -1, - webViewController: webViewController); - return; - } - Map args = {}; args.putIfAbsent('url', () => url.toString()); args.putIfAbsent('name', () => name); @@ -349,24 +189,6 @@ class AndroidCookieManager extends PlatformCookieManager PlatformInAppWebViewController? webViewController}) async { assert(url.toString().isNotEmpty); - webViewController = webViewController ?? iosBelow11WebViewController; - - if (await _shouldUseJavascript()) { - List cookies = await _getCookiesWithJavaScript( - url: url, webViewController: webViewController); - for (var i = 0; i < cookies.length; i++) { - await _setCookieWithJavaScript( - url: url, - name: cookies[i].name, - value: "", - path: path, - domain: domain, - maxAge: -1, - webViewController: webViewController); - } - return; - } - Map args = {}; args.putIfAbsent('url', () => url.toString()); args.putIfAbsent('domain', () => domain); @@ -380,57 +202,6 @@ class AndroidCookieManager extends PlatformCookieManager await channel?.invokeMethod('deleteAllCookies', args); } - @override - Future> getAllCookies() async { - List cookies = []; - - Map args = {}; - List cookieListMap = - await channel?.invokeMethod('getAllCookies', args) ?? []; - cookieListMap = cookieListMap.cast>(); - - cookieListMap.forEach((cookieMap) { - cookies.add(Cookie( - name: cookieMap["name"], - value: cookieMap["value"], - expiresDate: cookieMap["expiresDate"], - isSessionOnly: cookieMap["isSessionOnly"], - domain: cookieMap["domain"], - sameSite: - HTTPCookieSameSitePolicy.fromNativeValue(cookieMap["sameSite"]), - isSecure: cookieMap["isSecure"], - isHttpOnly: cookieMap["isHttpOnly"], - path: cookieMap["path"])); - }); - return cookies; - } - - Future _getCookieExpirationDate(int expiresDate) async { - var platformUtil = PlatformUtil.instance(); - var dateTime = DateTime.fromMillisecondsSinceEpoch(expiresDate).toUtc(); - return !kIsWeb - ? await platformUtil.formatDate( - date: dateTime, - format: 'EEE, dd MMM yyyy hh:mm:ss z', - locale: 'en_US', - timezone: 'GMT') - : await platformUtil.getWebCookieExpirationDate(date: dateTime); - } - - Future _shouldUseJavascript() async { - if (Util.isWeb) { - return true; - } - if (Util.isIOS || Util.isMacOS) { - final platformUtil = PlatformUtil.instance(); - final systemVersion = await platformUtil.getSystemVersion(); - return Util.isIOS - ? systemVersion.compareTo("11") == -1 - : systemVersion.compareTo("10.13") == -1; - } - return false; - } - @override void dispose() { // empty diff --git a/flutter_inappwebview_android/lib/src/find_interaction/find_interaction_controller.dart b/flutter_inappwebview_android/lib/src/find_interaction/find_interaction_controller.dart index da8c12b1..943176a5 100644 --- a/flutter_inappwebview_android/lib/src/find_interaction/find_interaction_controller.dart +++ b/flutter_inappwebview_android/lib/src/find_interaction/find_interaction_controller.dart @@ -98,30 +98,6 @@ class AndroidFindInteractionController extends PlatformFindInteractionController return await channel?.invokeMethod('getSearchText', args); } - ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.isFindNavigatorVisible} - Future isFindNavigatorVisible() async { - Map args = {}; - return await channel?.invokeMethod('isFindNavigatorVisible', args); - } - - ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.updateResultCount} - Future updateResultCount() async { - Map args = {}; - await channel?.invokeMethod('updateResultCount', args); - } - - ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.presentFindNavigator} - Future presentFindNavigator() async { - Map args = {}; - await channel?.invokeMethod('presentFindNavigator', args); - } - - ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.dismissFindNavigator} - Future dismissFindNavigator() async { - Map args = {}; - await channel?.invokeMethod('dismissFindNavigator', args); - } - ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.getActiveFindSession} Future getActiveFindSession() async { Map args = {}; diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart index 4142f77e..e374d991 100644 --- a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart @@ -1923,7 +1923,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController args.putIfAbsent('source', () => source); args.putIfAbsent('contentWorld', () => contentWorld?.toMap()); var data = await channel?.invokeMethod('evaluateJavascript', args); - if (data != null && (Util.isAndroid || Util.isWeb)) { + if (data != null) { try { // try to json decode the data coming from JavaScript // otherwise return it as it is. @@ -2185,8 +2185,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController {required double zoomFactor, @Deprecated('Use animated instead') bool? iosAnimated, bool animated = false}) async { - assert(!Util.isAndroid || - (Util.isAndroid && zoomFactor > 0.01 && zoomFactor <= 100.0)); + assert(zoomFactor > 0.01 && zoomFactor <= 100.0); Map args = {}; args.putIfAbsent('zoomFactor', () => zoomFactor); @@ -2398,8 +2397,6 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController @override Future addUserScript({required UserScript userScript}) async { - assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); - Map args = {}; args.putIfAbsent('userScript', () => userScript.toMap()); if (!(_userScripts[userScript.injectionTime]?.contains(userScript) ?? @@ -2411,8 +2408,6 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController @override Future addUserScripts({required List userScripts}) async { - assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); - for (var i = 0; i < userScripts.length; i++) { await addUserScript(userScript: userScripts[i]); } @@ -2420,8 +2415,6 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController @override Future removeUserScript({required UserScript userScript}) async { - assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); - var index = _userScripts[userScript.injectionTime]?.indexOf(userScript); if (index == null || index == -1) { return false; @@ -2438,8 +2431,6 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController @override Future removeUserScriptsByGroupName({required String groupName}) async { - assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); - final List userScriptsAtDocumentStart = List.from( _userScripts[UserScriptInjectionTime.AT_DOCUMENT_START] ?? []); for (final userScript in userScriptsAtDocumentStart) { @@ -2464,17 +2455,13 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController @override Future removeUserScripts( {required List userScripts}) async { - assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); - - for (final userScript in userScripts) { + for (final userScript in userScripts) { await removeUserScript(userScript: userScript); } } @override Future removeAllUserScripts() async { - assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); - _userScripts[UserScriptInjectionTime.AT_DOCUMENT_START]?.clear(); _userScripts[UserScriptInjectionTime.AT_DOCUMENT_END]?.clear(); @@ -2501,9 +2488,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (data == null) { return null; } - if (Util.isAndroid) { - data = json.decode(data); - } + data = json.decode(data); return CallAsyncJavaScriptResult( value: data["value"], error: data["error"]); } @@ -2512,12 +2497,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController Future saveWebArchive( {required String filePath, bool autoname = false}) async { if (!autoname) { - if (Util.isAndroid) { - assert(filePath.endsWith("." + WebArchiveFormat.MHT.toNativeValue())); - } else if (Util.isIOS || Util.isMacOS) { - assert(filePath - .endsWith("." + WebArchiveFormat.WEBARCHIVE.toNativeValue())); - } + assert(filePath.endsWith("." + WebArchiveFormat.MHT.toNativeValue())); } Map args = {}; @@ -2652,116 +2632,12 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return await channel?.invokeMethod('clearHistory', args); } - @override - Future reloadFromOrigin() async { - Map args = {}; - await channel?.invokeMethod('reloadFromOrigin', args); - } - - @override - Future createPdf( - {@Deprecated("Use pdfConfiguration instead") - // ignore: deprecated_member_use_from_same_package - IOSWKPDFConfiguration? iosWKPdfConfiguration, - PDFConfiguration? pdfConfiguration}) async { - Map args = {}; - args.putIfAbsent('pdfConfiguration', - () => pdfConfiguration?.toMap() ?? iosWKPdfConfiguration?.toMap()); - return await channel?.invokeMethod('createPdf', args); - } - - @override - Future createWebArchiveData() async { - Map args = {}; - return await channel?.invokeMethod('createWebArchiveData', args); - } - - @override - Future hasOnlySecureContent() async { - Map args = {}; - return await channel?.invokeMethod('hasOnlySecureContent', args) ?? - false; - } - - @override - Future pauseAllMediaPlayback() async { - Map args = {}; - return await channel?.invokeMethod('pauseAllMediaPlayback', args); - } - - @override - Future setAllMediaPlaybackSuspended({required bool suspended}) async { - Map args = {}; - args.putIfAbsent("suspended", () => suspended); - return await channel?.invokeMethod('setAllMediaPlaybackSuspended', args); - } - - @override - Future closeAllMediaPresentations() async { - Map args = {}; - return await channel?.invokeMethod('closeAllMediaPresentations', args); - } - - @override - Future requestMediaPlaybackState() async { - Map args = {}; - return MediaPlaybackState.fromNativeValue( - await channel?.invokeMethod('requestMediaPlaybackState', args)); - } - @override Future isInFullscreen() async { Map args = {}; return await channel?.invokeMethod('isInFullscreen', args) ?? false; } - @override - Future getCameraCaptureState() async { - Map args = {}; - return MediaCaptureState.fromNativeValue( - await channel?.invokeMethod('getCameraCaptureState', args)); - } - - @override - Future setCameraCaptureState({required MediaCaptureState state}) async { - Map args = {}; - args.putIfAbsent('state', () => state.toNativeValue()); - await channel?.invokeMethod('setCameraCaptureState', args); - } - - @override - Future getMicrophoneCaptureState() async { - Map args = {}; - return MediaCaptureState.fromNativeValue( - await channel?.invokeMethod('getMicrophoneCaptureState', args)); - } - - @override - Future setMicrophoneCaptureState( - {required MediaCaptureState state}) async { - Map args = {}; - args.putIfAbsent('state', () => state.toNativeValue()); - await channel?.invokeMethod('setMicrophoneCaptureState', args); - } - - @override - Future loadSimulatedRequest( - {required URLRequest urlRequest, - required Uint8List data, - URLResponse? urlResponse}) async { - Map args = {}; - args.putIfAbsent('urlRequest', () => urlRequest.toMap()); - args.putIfAbsent('data', () => data); - args.putIfAbsent('urlResponse', () => urlResponse?.toMap()); - await channel?.invokeMethod('loadSimulatedRequest', args); - } - - @override - Future getIFrameId() async { - Map args = {}; - return await channel?.invokeMethod('getIFrameId', args); - } - @override Future getDefaultUserAgent() async { Map args = {}; @@ -2837,13 +2713,6 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await _staticChannel.invokeMethod('disableWebView', args); } - @override - Future handlesURLScheme(String urlScheme) async { - Map args = {}; - args.putIfAbsent('urlScheme', () => urlScheme); - return await _staticChannel.invokeMethod('handlesURLScheme', args); - } - @override Future disposeKeepAlive(InAppWebViewKeepAlive keepAlive) async { Map args = {}; diff --git a/flutter_inappwebview_android/lib/src/print_job/print_job_controller.dart b/flutter_inappwebview_android/lib/src/print_job/print_job_controller.dart index 692c847c..76831154 100644 --- a/flutter_inappwebview_android/lib/src/print_job/print_job_controller.dart +++ b/flutter_inappwebview_android/lib/src/print_job/print_job_controller.dart @@ -43,13 +43,6 @@ class AndroidPrintJobController extends PlatformPrintJobController Future _handleMethod(MethodCall call) async { switch (call.method) { - case "onComplete": - bool completed = call.arguments["completed"]; - String? error = call.arguments["error"]; - if (params.onComplete != null) { - params.onComplete!(completed, error); - } - break; default: throw UnimplementedError("Unimplemented ${call.method} method"); } @@ -67,13 +60,6 @@ class AndroidPrintJobController extends PlatformPrintJobController await channel?.invokeMethod('restart', args); } - @override - Future dismiss({bool animated: true}) async { - Map args = {}; - args.putIfAbsent("animated", () => animated); - await channel?.invokeMethod('dismiss', args); - } - @override Future getInfo() async { Map args = {}; diff --git a/flutter_inappwebview_android/lib/src/pull_to_refresh/pull_to_refresh_controller.dart b/flutter_inappwebview_android/lib/src/pull_to_refresh/pull_to_refresh_controller.dart index aa651ce9..693c98a1 100644 --- a/flutter_inappwebview_android/lib/src/pull_to_refresh/pull_to_refresh_controller.dart +++ b/flutter_inappwebview_android/lib/src/pull_to_refresh/pull_to_refresh_controller.dart @@ -147,21 +147,6 @@ class AndroidPullToRefreshController extends PlatformPullToRefreshController await channel?.invokeMethod('setSize', args); } - @Deprecated("Use setStyledTitle instead") - @override - Future setAttributedTitle(IOSNSAttributedString attributedTitle) async { - Map args = {}; - args.putIfAbsent('attributedTitle', () => attributedTitle.toMap()); - await channel?.invokeMethod('setStyledTitle', args); - } - - @override - Future setStyledTitle(AttributedString attributedTitle) async { - Map args = {}; - args.putIfAbsent('attributedTitle', () => attributedTitle.toMap()); - await channel?.invokeMethod('setStyledTitle', args); - } - @override void dispose({bool isKeepAlive = false}) { disposeChannel(removeMethodCallHandler: !isKeepAlive); diff --git a/flutter_inappwebview_android/lib/src/web_storage/web_storage_manager.dart b/flutter_inappwebview_android/lib/src/web_storage/web_storage_manager.dart index 07a128dc..d5fc4562 100755 --- a/flutter_inappwebview_android/lib/src/web_storage/web_storage_manager.dart +++ b/flutter_inappwebview_android/lib/src/web_storage/web_storage_manager.dart @@ -105,71 +105,6 @@ class AndroidWebStorageManager extends PlatformWebStorageManager return await channel?.invokeMethod('getUsageForOrigin', args) ?? 0; } - @override - Future> fetchDataRecords( - {required Set dataTypes}) async { - List recordList = []; - List dataTypesList = []; - for (var dataType in dataTypes) { - dataTypesList.add(dataType.toNativeValue()); - } - Map args = {}; - args.putIfAbsent("dataTypes", () => dataTypesList); - List> records = - (await channel?.invokeMethod('fetchDataRecords', args)) - ?.cast>() ?? - []; - for (var record in records) { - List dataTypesString = record["dataTypes"].cast(); - Set dataTypes = Set(); - for (var dataTypeValue in dataTypesString) { - var dataType = WebsiteDataType.fromNativeValue(dataTypeValue); - if (dataType != null) { - dataTypes.add(dataType); - } - } - recordList.add(WebsiteDataRecord( - displayName: record["displayName"], dataTypes: dataTypes)); - } - return recordList; - } - - @override - Future removeDataFor( - {required Set dataTypes, - required List dataRecords}) async { - List dataTypesList = []; - for (var dataType in dataTypes) { - dataTypesList.add(dataType.toNativeValue()); - } - - List> recordList = []; - for (var record in dataRecords) { - recordList.add(record.toMap()); - } - - Map args = {}; - args.putIfAbsent("dataTypes", () => dataTypesList); - args.putIfAbsent("recordList", () => recordList); - await channel?.invokeMethod('removeDataFor', args); - } - - @override - Future removeDataModifiedSince( - {required Set dataTypes, required DateTime date}) async { - List dataTypesList = []; - for (var dataType in dataTypes) { - dataTypesList.add(dataType.toNativeValue()); - } - - var timestamp = date.millisecondsSinceEpoch; - - Map args = {}; - args.putIfAbsent("dataTypes", () => dataTypesList); - args.putIfAbsent("timestamp", () => timestamp); - await channel?.invokeMethod('removeDataModifiedSince', args); - } - @override void dispose() { // empty diff --git a/flutter_inappwebview_ios/lib/src/chrome_safari_browser/chrome_safari_browser.dart b/flutter_inappwebview_ios/lib/src/chrome_safari_browser/chrome_safari_browser.dart index 931e1b8e..dd837cd9 100755 --- a/flutter_inappwebview_ios/lib/src/chrome_safari_browser/chrome_safari_browser.dart +++ b/flutter_inappwebview_ios/lib/src/chrome_safari_browser/chrome_safari_browser.dart @@ -1,6 +1,5 @@ import 'dart:async'; import 'dart:collection'; -import 'dart:typed_data'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; @@ -49,9 +48,7 @@ class IOSChromeSafariBrowser extends PlatformChromeSafariBrowser return _staticValue; } - ChromeSafariBrowserActionButton? _actionButton; Map _menuItems = new HashMap(); - ChromeSafariBrowserSecondaryToolbar? _secondaryToolbar; bool _isOpened = false; static const MethodChannel _staticChannel = const MethodChannel('com.pichillilorenzo/flutter_chromesafaribrowser'); @@ -76,9 +73,6 @@ class IOSChromeSafariBrowser extends PlatformChromeSafariBrowser _debugLog(call.method, call.arguments); switch (call.method) { - case "onServiceConnected": - eventHandler?.onServiceConnected(); - break; case "onOpened": eventHandler?.onOpened(); break; @@ -91,21 +85,6 @@ class IOSChromeSafariBrowser extends PlatformChromeSafariBrowser final WebUri? uri = url != null ? WebUri(url) : null; eventHandler?.onInitialLoadDidRedirect(uri); break; - case "onNavigationEvent": - final navigationEvent = CustomTabsNavigationEventType.fromNativeValue( - call.arguments["navigationEvent"]); - eventHandler?.onNavigationEvent(navigationEvent); - break; - case "onRelationshipValidationResult": - final relation = - CustomTabsRelationType.fromNativeValue(call.arguments["relation"]); - final requestedOrigin = call.arguments["requestedOrigin"] != null - ? WebUri(call.arguments["requestedOrigin"]) - : null; - final bool result = call.arguments["result"]; - eventHandler?.onRelationshipValidationResult( - relation, requestedOrigin, result); - break; case "onWillOpenInBrowser": eventHandler?.onWillOpenInBrowser(); break; @@ -119,14 +98,7 @@ class IOSChromeSafariBrowser extends PlatformChromeSafariBrowser String url = call.arguments["url"]; String title = call.arguments["title"]; int id = call.arguments["id"].toInt(); - if (this._actionButton?.id == id) { - if (this._actionButton?.action != null) { - this._actionButton?.action!(url, title); - } - if (this._actionButton?.onClick != null) { - this._actionButton?.onClick!(WebUri(url), title); - } - } else if (this._menuItems[id] != null) { + if (this._menuItems[id] != null) { if (this._menuItems[id]?.action != null) { this._menuItems[id]?.action!(url, title); } @@ -135,52 +107,6 @@ class IOSChromeSafariBrowser extends PlatformChromeSafariBrowser } } break; - case "onSecondaryItemActionPerform": - final clickableIDs = this._secondaryToolbar?.clickableIDs; - if (clickableIDs != null) { - WebUri? url = call.arguments["url"] != null - ? WebUri(call.arguments["url"]) - : null; - String name = call.arguments["name"]; - for (final clickable in clickableIDs) { - var clickableFullname = clickable.id.name; - if (clickable.id.defType != null && - !clickableFullname.contains("/")) { - clickableFullname = "${clickable.id.defType}/$clickableFullname"; - } - if (clickable.id.defPackage != null && - !clickableFullname.contains(":")) { - clickableFullname = - "${clickable.id.defPackage}:$clickableFullname"; - } - if (clickableFullname == name) { - if (clickable.onClick != null) { - clickable.onClick!(url); - } - break; - } - } - } - break; - case "onMessageChannelReady": - eventHandler?.onMessageChannelReady(); - break; - case "onPostMessage": - final String message = call.arguments["message"]; - eventHandler?.onPostMessage(message); - break; - case "onVerticalScrollEvent": - final bool isDirectionUp = call.arguments["isDirectionUp"]; - eventHandler?.onVerticalScrollEvent(isDirectionUp); - break; - case "onGreatestScrollPercentageIncreased": - final int scrollPercentage = call.arguments["scrollPercentage"]; - eventHandler?.onGreatestScrollPercentageIncreased(scrollPercentage); - break; - case "onSessionEnded": - final bool didUserInteract = call.arguments["didUserInteract"]; - eventHandler?.onSessionEnded(didUserInteract); - break; default: throw UnimplementedError("Unimplemented ${call.method} method"); } @@ -227,86 +153,16 @@ class IOSChromeSafariBrowser extends PlatformChromeSafariBrowser () => otherLikelyURLs?.map((e) => e.toString()).toList()); args.putIfAbsent('referrer', () => referrer?.toString()); args.putIfAbsent('settings', () => initialSettings); - args.putIfAbsent('actionButton', () => _actionButton?.toMap()); - args.putIfAbsent('secondaryToolbar', () => _secondaryToolbar?.toMap()); args.putIfAbsent('menuItemList', () => menuItemList); await _staticChannel.invokeMethod('open', args); } - @override - Future launchUrl({ - required WebUri url, - Map? headers, - List? otherLikelyURLs, - WebUri? referrer, - }) async { - Map args = {}; - args.putIfAbsent('url', () => url.toString()); - args.putIfAbsent('headers', () => headers); - args.putIfAbsent('otherLikelyURLs', - () => otherLikelyURLs?.map((e) => e.toString()).toList()); - args.putIfAbsent('referrer', () => referrer?.toString()); - await channel?.invokeMethod("launchUrl", args); - } - - @override - Future mayLaunchUrl( - {WebUri? url, List? otherLikelyURLs}) async { - Map args = {}; - args.putIfAbsent('url', () => url?.toString()); - args.putIfAbsent('otherLikelyURLs', - () => otherLikelyURLs?.map((e) => e.toString()).toList()); - return await channel?.invokeMethod("mayLaunchUrl", args) ?? false; - } - - @override - Future validateRelationship( - {required CustomTabsRelationType relation, - required WebUri origin}) async { - Map args = {}; - args.putIfAbsent('relation', () => relation.toNativeValue()); - args.putIfAbsent('origin', () => origin.toString()); - return await channel?.invokeMethod("validateRelationship", args) ?? - false; - } - @override Future close() async { Map args = {}; await channel?.invokeMethod("close", args); } - @override - void setActionButton(ChromeSafariBrowserActionButton actionButton) { - this._actionButton = actionButton; - } - - @override - Future updateActionButton( - {required Uint8List icon, required String description}) async { - Map args = {}; - args.putIfAbsent('icon', () => icon); - args.putIfAbsent('description', () => description); - await channel?.invokeMethod("updateActionButton", args); - _actionButton?.icon = icon; - _actionButton?.description = description; - } - - @override - void setSecondaryToolbar( - ChromeSafariBrowserSecondaryToolbar secondaryToolbar) { - this._secondaryToolbar = secondaryToolbar; - } - - @override - Future updateSecondaryToolbar( - ChromeSafariBrowserSecondaryToolbar secondaryToolbar) async { - Map args = {}; - args.putIfAbsent('secondaryToolbar', () => secondaryToolbar.toMap()); - await channel?.invokeMethod("updateSecondaryToolbar", args); - this._secondaryToolbar = secondaryToolbar; - } - @override void addMenuItem(ChromeSafariBrowserMenuItem menuItem) { this._menuItems[menuItem.id] = menuItem; @@ -319,34 +175,6 @@ class IOSChromeSafariBrowser extends PlatformChromeSafariBrowser }); } - @override - Future requestPostMessageChannel( - {required WebUri sourceOrigin, WebUri? targetOrigin}) async { - Map args = {}; - args.putIfAbsent("sourceOrigin", () => sourceOrigin.toString()); - args.putIfAbsent("targetOrigin", () => targetOrigin.toString()); - return await channel?.invokeMethod( - "requestPostMessageChannel", args) ?? - false; - } - - @override - Future postMessage(String message) async { - Map args = {}; - args.putIfAbsent("message", () => message); - return CustomTabsPostMessageResultType.fromNativeValue( - await channel?.invokeMethod("postMessage", args)) ?? - CustomTabsPostMessageResultType.FAILURE_MESSAGING_ERROR; - } - - @override - Future isEngagementSignalsApiAvailable() async { - Map args = {}; - return await channel?.invokeMethod( - "isEngagementSignalsApiAvailable", args) ?? - false; - } - @override Future isAvailable() async { Map args = {}; @@ -354,22 +182,6 @@ class IOSChromeSafariBrowser extends PlatformChromeSafariBrowser false; } - @override - Future getMaxToolbarItems() async { - Map args = {}; - return await _staticChannel.invokeMethod("getMaxToolbarItems", args) ?? - 0; - } - - @override - Future getPackageName( - {List? packages, bool ignoreDefault = false}) async { - Map args = {}; - args.putIfAbsent("packages", () => packages); - args.putIfAbsent("ignoreDefault", () => ignoreDefault); - return await _staticChannel.invokeMethod("getPackageName", args); - } - @override Future clearWebsiteData() async { Map args = {}; diff --git a/flutter_inappwebview_ios/lib/src/cookie_manager.dart b/flutter_inappwebview_ios/lib/src/cookie_manager.dart index 26ecef34..e328c040 100755 --- a/flutter_inappwebview_ios/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_ios/lib/src/cookie_manager.dart @@ -418,9 +418,6 @@ class IOSCookieManager extends PlatformCookieManager } Future _shouldUseJavascript() async { - if (Util.isWeb) { - return true; - } if (Util.isIOS || Util.isMacOS) { final platformUtil = PlatformUtil.instance(); final systemVersion = await platformUtil.getSystemVersion(); diff --git a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart index 064acee2..210323b7 100644 --- a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart @@ -2595,63 +2595,6 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController false; } - @override - Future startSafeBrowsing() async { - Map args = {}; - return await channel?.invokeMethod('startSafeBrowsing', args) ?? - false; - } - - @override - Future clearSslPreferences() async { - Map args = {}; - await channel?.invokeMethod('clearSslPreferences', args); - } - - @override - Future pause() async { - Map args = {}; - await channel?.invokeMethod('pause', args); - } - - @override - Future resume() async { - Map args = {}; - await channel?.invokeMethod('resume', args); - } - - @override - Future pageDown({required bool bottom}) async { - Map args = {}; - args.putIfAbsent("bottom", () => bottom); - return await channel?.invokeMethod('pageDown', args) ?? false; - } - - @override - Future pageUp({required bool top}) async { - Map args = {}; - args.putIfAbsent("top", () => top); - return await channel?.invokeMethod('pageUp', args) ?? false; - } - - @override - Future zoomIn() async { - Map args = {}; - return await channel?.invokeMethod('zoomIn', args) ?? false; - } - - @override - Future zoomOut() async { - Map args = {}; - return await channel?.invokeMethod('zoomOut', args) ?? false; - } - - @override - Future clearHistory() async { - Map args = {}; - return await channel?.invokeMethod('clearHistory', args); - } - @override Future reloadFromOrigin() async { Map args = {}; @@ -2756,12 +2699,6 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController await channel?.invokeMethod('loadSimulatedRequest', args); } - @override - Future getIFrameId() async { - Map args = {}; - return await channel?.invokeMethod('getIFrameId', args); - } - @override Future getDefaultUserAgent() async { Map args = {}; @@ -2770,73 +2707,6 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController ''; } - @override - Future clearClientCertPreferences() async { - Map args = {}; - await _staticChannel.invokeMethod('clearClientCertPreferences', args); - } - - @override - Future getSafeBrowsingPrivacyPolicyUrl() async { - Map args = {}; - String? url = await _staticChannel.invokeMethod( - 'getSafeBrowsingPrivacyPolicyUrl', args); - return url != null ? WebUri(url) : null; - } - - @override - @Deprecated("Use setSafeBrowsingAllowlist instead") - Future setSafeBrowsingWhitelist({required List hosts}) async { - return await setSafeBrowsingAllowlist(hosts: hosts); - } - - @override - Future setSafeBrowsingAllowlist({required List hosts}) async { - Map args = {}; - args.putIfAbsent('hosts', () => hosts); - return await _staticChannel.invokeMethod( - 'setSafeBrowsingAllowlist', args) ?? - false; - } - - @override - Future getCurrentWebViewPackage() async { - Map args = {}; - Map? packageInfo = - (await _staticChannel.invokeMethod('getCurrentWebViewPackage', args)) - ?.cast(); - return WebViewPackageInfo.fromMap(packageInfo); - } - - @override - Future setWebContentsDebuggingEnabled(bool debuggingEnabled) async { - Map args = {}; - args.putIfAbsent('debuggingEnabled', () => debuggingEnabled); - return await _staticChannel.invokeMethod( - 'setWebContentsDebuggingEnabled', args); - } - - @override - Future getVariationsHeader() async { - Map args = {}; - return await _staticChannel.invokeMethod( - 'getVariationsHeader', args); - } - - @override - Future isMultiProcessEnabled() async { - Map args = {}; - return await _staticChannel.invokeMethod( - 'isMultiProcessEnabled', args) ?? - false; - } - - @override - Future disableWebView() async { - Map args = {}; - await _staticChannel.invokeMethod('disableWebView', args); - } - @override Future handlesURLScheme(String urlScheme) async { Map args = {}; diff --git a/flutter_inappwebview_ios/lib/src/print_job/print_job_controller.dart b/flutter_inappwebview_ios/lib/src/print_job/print_job_controller.dart index 7e74218e..27eac98f 100644 --- a/flutter_inappwebview_ios/lib/src/print_job/print_job_controller.dart +++ b/flutter_inappwebview_ios/lib/src/print_job/print_job_controller.dart @@ -55,18 +55,6 @@ class IOSPrintJobController extends PlatformPrintJobController } } - @override - Future cancel() async { - Map args = {}; - await channel?.invokeMethod('cancel', args); - } - - @override - Future restart() async { - Map args = {}; - await channel?.invokeMethod('restart', args); - } - @override Future dismiss({bool animated: true}) async { Map args = {}; diff --git a/flutter_inappwebview_ios/lib/src/pull_to_refresh/pull_to_refresh_controller.dart b/flutter_inappwebview_ios/lib/src/pull_to_refresh/pull_to_refresh_controller.dart index 5f3556cc..fae128c5 100644 --- a/flutter_inappwebview_ios/lib/src/pull_to_refresh/pull_to_refresh_controller.dart +++ b/flutter_inappwebview_ios/lib/src/pull_to_refresh/pull_to_refresh_controller.dart @@ -110,43 +110,6 @@ class IOSPullToRefreshController extends PlatformPullToRefreshController await channel?.invokeMethod('setBackgroundColor', args); } - @override - Future setDistanceToTriggerSync(int distanceToTriggerSync) async { - Map args = {}; - args.putIfAbsent('distanceToTriggerSync', () => distanceToTriggerSync); - await channel?.invokeMethod('setDistanceToTriggerSync', args); - } - - @override - Future setSlingshotDistance(int slingshotDistance) async { - Map args = {}; - args.putIfAbsent('slingshotDistance', () => slingshotDistance); - await channel?.invokeMethod('setSlingshotDistance', args); - } - - @override - Future getDefaultSlingshotDistance() async { - Map args = {}; - return await channel?.invokeMethod( - 'getDefaultSlingshotDistance', args) ?? - 0; - } - - @Deprecated("Use setIndicatorSize instead") - @override - Future setSize(AndroidPullToRefreshSize size) async { - Map args = {}; - args.putIfAbsent('size', () => size.toNativeValue()); - await channel?.invokeMethod('setSize', args); - } - - @override - Future setIndicatorSize(PullToRefreshSize size) async { - Map args = {}; - args.putIfAbsent('size', () => size.toNativeValue()); - await channel?.invokeMethod('setSize', args); - } - @Deprecated("Use setStyledTitle instead") @override Future setAttributedTitle(IOSNSAttributedString attributedTitle) async { diff --git a/flutter_inappwebview_ios/lib/src/web_storage/web_storage_manager.dart b/flutter_inappwebview_ios/lib/src/web_storage/web_storage_manager.dart index 530b28dd..bb259cc3 100755 --- a/flutter_inappwebview_ios/lib/src/web_storage/web_storage_manager.dart +++ b/flutter_inappwebview_ios/lib/src/web_storage/web_storage_manager.dart @@ -58,53 +58,6 @@ class IOSWebStorageManager extends PlatformWebStorageManager Future _handleMethod(MethodCall call) async {} - @override - Future> getOrigins() async { - List originsList = []; - - Map args = {}; - List> origins = - (await channel?.invokeMethod('getOrigins', args)) - ?.cast>() ?? - []; - - for (var origin in origins) { - originsList.add(WebStorageOrigin( - origin: origin["origin"], - quota: origin["quota"], - usage: origin["usage"])); - } - - return originsList; - } - - @override - Future deleteAllData() async { - Map args = {}; - await channel?.invokeMethod('deleteAllData', args); - } - - @override - Future deleteOrigin({required String origin}) async { - Map args = {}; - args.putIfAbsent("origin", () => origin); - await channel?.invokeMethod('deleteOrigin', args); - } - - @override - Future getQuotaForOrigin({required String origin}) async { - Map args = {}; - args.putIfAbsent("origin", () => origin); - return await channel?.invokeMethod('getQuotaForOrigin', args) ?? 0; - } - - @override - Future getUsageForOrigin({required String origin}) async { - Map args = {}; - args.putIfAbsent("origin", () => origin); - return await channel?.invokeMethod('getUsageForOrigin', args) ?? 0; - } - @override Future> fetchDataRecords( {required Set dataTypes}) async { diff --git a/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage.dart b/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage.dart index 1e2991f4..84ecd089 100644 --- a/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage.dart @@ -125,6 +125,7 @@ abstract class PlatformStorage implements Disposable { ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web ///{@endtemplate} Future length() { @@ -140,6 +141,7 @@ abstract class PlatformStorage implements Disposable { ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web ///{@endtemplate} Future setItem({required String key, required dynamic value}) { @@ -155,6 +157,7 @@ abstract class PlatformStorage implements Disposable { ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web ///{@endtemplate} Future getItem({required String key}) { @@ -170,6 +173,7 @@ abstract class PlatformStorage implements Disposable { ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web ///{@endtemplate} Future removeItem({required String key}) { @@ -185,6 +189,7 @@ abstract class PlatformStorage implements Disposable { ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web ///{@endtemplate} Future> getItems() { @@ -200,6 +205,7 @@ abstract class PlatformStorage implements Disposable { ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web ///{@endtemplate} Future clear() { @@ -216,6 +222,7 @@ abstract class PlatformStorage implements Disposable { ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web ///{@endtemplate} Future key({required int index}) {