From 1486b5af386863804d425c24e1c6e9849456581a Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 17 Nov 2023 23:28:11 +0100 Subject: [PATCH 01/23] first commit federated-plugin --- android/.idea/.name | 1 - android/.idea/caches/build_file_checksums.ser | Bin 488 -> 0 bytes android/.idea/caches/gradle_models.ser | Bin 96863 -> 0 bytes android/.idea/codeStyles/Project.xml | 29 - android/.idea/gradle.xml | 15 - android/.idea/misc.xml | 14 - android/.idea/modules.xml | 8 - android/.idea/runConfigurations.xml | 12 - android/.idea/vcs.xml | 6 - .../chrome_safari_browser/custom_tabs.dart | 4 +- .../sf_safari_view_controller.dart | 4 +- .../process_global_config/apply.dart | 2 +- .../clear_and_set_proxy_override.dart | 2 +- .../set_service_worker_client.dart | 4 +- .../should_intercept_request.dart | 4 +- example/integration_test/util.dart | 2 +- .../webview_flutter_test.dart | 4 +- .../chrome_safari_browser_example.screen.dart | 4 +- .../lib/in_app_browser_example.screen.dart | 26 +- example/lib/in_app_webiew_example.screen.dart | 2 +- ...authentication_session_example.screen.dart | 2 +- flutter_inappwebview_android/.gitignore | 30 + flutter_inappwebview_android/.metadata | 30 + flutter_inappwebview_android/CHANGELOG.md | 3 + flutter_inappwebview_android/LICENSE | 1 + flutter_inappwebview_android/README.md | 15 + .../analysis_options.yaml | 11 + .../android}/.gitignore | 0 .../android}/build.gradle | 0 .../android}/gradle.properties | 0 .../android}/proguard-rules.pro | 0 .../android}/settings.gradle | 0 .../android}/src/main/AndroidManifest.xml | 0 .../flutter_inappwebview/ISettings.java | 0 .../InAppWebViewFileProvider.java | 0 .../InAppWebViewFlutterPlugin.java | 0 .../flutter_inappwebview/MyCookieManager.java | 0 .../flutter_inappwebview/MyWebStorage.java | 0 .../flutter_inappwebview/PlatformUtil.java | 0 .../flutter_inappwebview/Util.java | 0 .../WebViewFeatureManager.java | 0 .../ActionBroadcastReceiver.java | 0 .../ChromeCustomTabsActivity.java | 0 ...hromeCustomTabsActivitySingleInstance.java | 0 .../ChromeCustomTabsChannelDelegate.java | 0 .../ChromeCustomTabsSettings.java | 0 .../ChromeSafariBrowserManager.java | 0 .../CustomTabActivityHelper.java | 0 .../chrome_custom_tabs/CustomTabsHelper.java | 0 .../chrome_custom_tabs/KeepAliveService.java | 0 .../chrome_custom_tabs/ServiceConnection.java | 0 .../ServiceConnectionCallback.java | 0 .../TrustedWebActivity.java | 0 .../TrustedWebActivitySingleInstance.java | 0 .../content_blocker/ContentBlocker.java | 0 .../content_blocker/ContentBlockerAction.java | 0 .../ContentBlockerActionType.java | 0 .../ContentBlockerHandler.java | 0 .../ContentBlockerTrigger.java | 0 .../ContentBlockerTriggerResourceType.java | 0 .../CredentialDatabase.java | 0 .../CredentialDatabaseHandler.java | 0 .../CredentialDatabaseHelper.java | 0 .../URLCredentialContract.java | 0 .../credential_database/URLCredentialDao.java | 0 .../URLProtectionSpaceContract.java | 0 .../URLProtectionSpaceDao.java | 0 .../FindInteractionChannelDelegate.java | 0 .../FindInteractionController.java | 0 .../FindInteractionSettings.java | 0 .../HeadlessInAppWebView.java | 0 .../HeadlessInAppWebViewManager.java | 0 .../HeadlessWebViewChannelDelegate.java | 0 .../ActivityResultListener.java | 0 .../in_app_browser/InAppBrowserActivity.java | 0 .../InAppBrowserChannelDelegate.java | 0 .../in_app_browser/InAppBrowserDelegate.java | 0 .../in_app_browser/InAppBrowserManager.java | 0 .../in_app_browser/InAppBrowserSettings.java | 0 .../plugin_scripts_js/ConsoleLogJS.java | 0 .../InterceptAjaxRequestJS.java | 0 .../InterceptFetchRequestJS.java | 0 .../plugin_scripts_js/JavaScriptBridgeJS.java | 0 .../plugin_scripts_js/OnLoadResourceJS.java | 0 .../OnWindowBlurEventJS.java | 0 .../OnWindowFocusEventJS.java | 0 .../plugin_scripts_js/PluginScriptsUtil.java | 0 .../plugin_scripts_js/PrintJS.java | 0 .../plugin_scripts_js/PromisePolyfillJS.java | 0 .../print_job/PrintJobChannelDelegate.java | 0 .../print_job/PrintJobController.java | 0 .../print_job/PrintJobManager.java | 0 .../print_job/PrintJobSettings.java | 0 .../ProcessGlobalConfigManager.java | 0 .../ProcessGlobalConfigSettings.java | 0 .../proxy/ProxyManager.java | 0 .../proxy/ProxySettings.java | 0 .../PullToRefreshChannelDelegate.java | 0 .../pull_to_refresh/PullToRefreshLayout.java | 0 .../PullToRefreshSettings.java | 0 .../ServiceWorkerChannelDelegate.java | 0 .../service_worker/ServiceWorkerManager.java | 0 .../TracingControllerChannelDelegate.java | 0 .../tracing/TracingControllerManager.java | 0 .../tracing/TracingSettings.java | 0 .../types/AndroidResource.java | 0 .../types/BaseCallbackResultImpl.java | 0 .../types/ChannelDelegateImpl.java | 0 .../types/ClientCertChallenge.java | 0 .../types/ClientCertResponse.java | 0 .../types/ContentWorld.java | 0 .../types/CreateWindowAction.java | 0 .../types/CustomSchemeResponse.java | 0 .../types/CustomTabsActionButton.java | 0 .../types/CustomTabsMenuItem.java | 0 .../types/CustomTabsSecondaryToolbar.java | 0 .../types/Disposable.java | 0 .../types/DownloadStartRequest.java | 0 .../types/FindSession.java | 0 ...olocationPermissionShowPromptResponse.java | 0 .../types/HitTestResult.java | 0 .../types/HttpAuthResponse.java | 0 .../types/HttpAuthenticationChallenge.java | 0 .../types/ICallbackResult.java | 0 .../types/IChannelDelegate.java | 0 .../types/InAppBrowserMenuItem.java | 0 .../types/JsAlertResponse.java | 0 .../types/JsBeforeUnloadResponse.java | 0 .../types/JsConfirmResponse.java | 0 .../types/JsPromptResponse.java | 0 .../types/MarginsExt.java | 0 .../types/MediaSizeExt.java | 0 .../types/NavigationAction.java | 0 .../types/NavigationActionPolicy.java | 0 .../types/PermissionResponse.java | 0 .../types/PluginScript.java | 0 .../types/PreferredContentModeOptionType.java | 0 .../types/PrintAttributesExt.java | 0 .../types/PrintJobInfoExt.java | 0 .../types/ProxyRuleExt.java | 0 .../types/ResolutionExt.java | 0 .../types/SafeBrowsingResponse.java | 0 .../types/ServerTrustAuthResponse.java | 0 .../types/ServerTrustChallenge.java | 0 .../flutter_inappwebview/types/Size2D.java | 0 .../types/SslCertificateExt.java | 0 .../types/SslErrorExt.java | 0 .../types/SyncBaseCallbackResultImpl.java | 0 .../types/URLAuthenticationChallenge.java | 0 .../types/URLCredential.java | 0 .../types/URLProtectionSpace.java | 0 .../types/URLRequest.java | 0 .../types/UserContentController.java | 0 .../types/UserScript.java | 0 .../types/UserScriptInjectionTime.java | 0 .../types/WebMessage.java | 0 .../types/WebMessageCompatExt.java | 0 .../types/WebMessagePort.java | 0 .../types/WebMessagePortCompatExt.java | 0 .../types/WebResourceErrorExt.java | 0 .../types/WebResourceRequestExt.java | 0 .../types/WebResourceResponseExt.java | 0 .../types/WebViewAssetLoaderExt.java | 0 .../webview/ContextMenuSettings.java | 0 .../webview/FlutterWebViewFactory.java | 0 .../webview/InAppWebViewInterface.java | 0 .../webview/InAppWebViewManager.java | 0 .../webview/JavaScriptBridgeInterface.java | 0 .../webview/PlatformWebView.java | 0 .../webview/WebViewChannelDelegate.java | 0 .../WebViewChannelDelegateMethods.java | 0 .../in_app_webview/DisplayListenerProxy.java | 0 .../in_app_webview/FlutterWebView.java | 0 .../webview/in_app_webview/InAppWebView.java | 0 .../InAppWebViewChromeClient.java | 1 - .../in_app_webview/InAppWebViewClient.java | 0 .../InAppWebViewClientCompat.java | 0 .../InAppWebViewRenderProcessClient.java | 0 .../in_app_webview/InAppWebViewSettings.java | 0 .../in_app_webview/InputAwareWebView.java | 0 ...readedInputConnectionProxyAdapterView.java | 0 .../web_message/WebMessageChannel.java | 0 .../WebMessageChannelChannelDelegate.java | 0 .../web_message/WebMessageListener.java | 0 .../WebMessageListenerChannelDelegate.java | 0 .../drawable/floating_action_mode_shape.xml | 0 .../src/main/res/layout/activity_web_view.xml | 0 .../res/layout/chrome_custom_tabs_layout.xml | 0 .../main/res/layout/floating_action_mode.xml | 0 .../res/layout/floating_action_mode_item.xml | 0 .../android}/src/main/res/menu/menu_main.xml | 0 .../android}/src/main/res/values/strings.xml | 0 .../android}/src/main/res/values/styles.xml | 0 .../src/main/res/xml/provider_paths.xml | 0 .../example/.gitignore | 44 + .../example/README.md | 16 + .../example/analysis_options.yaml | 28 + .../example/android/.gitignore | 13 + .../example/android/app/build.gradle | 57 + .../android/app/src/debug/AndroidManifest.xml | 7 + .../android/app/src/main/AndroidManifest.xml | 33 + .../MainActivity.java | 6 + .../res/drawable-v21/launch_background.xml | 12 + .../main/res/drawable/launch_background.xml | 12 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes .../app/src/main/res/values-night/styles.xml | 18 + .../app/src/main/res/values/styles.xml | 18 + .../app/src/profile/AndroidManifest.xml | 7 + .../example/android/build.gradle | 31 + .../example/android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 5 + .../example/android/settings.gradle | 20 + .../plugin_integration_test.dart | 25 + .../example/lib/main.dart | 63 + .../example/pubspec.lock | 282 ++ .../example/pubspec.yaml | 85 + .../example/test/widget_test.dart | 27 + .../lib/flutter_inappwebview_android.dart | 3 + .../lib/src/cookie_manager.dart | 575 +++ .../find_interaction_controller.dart | 229 + .../lib/src/find_interaction/main.dart | 1 + .../src/http_auth_credentials_database.dart | 196 + .../src/in_app_browser/in_app_browser.dart | 525 +++ .../lib/src/in_app_browser/main.dart | 1 + .../src/in_app_webview/_static_channel.dart | 4 + .../headless_in_app_webview.dart | 491 ++ .../src/in_app_webview/in_app_webview.dart | 474 ++ .../in_app_webview_controller.dart | 4090 +++++++++++++++++ .../lib/src/in_app_webview/main.dart | 3 + .../lib/src/inappwebview_platform.dart | 343 ++ .../lib/src/main.dart | 21 + .../lib}/src/platform_util.dart | 2 +- .../lib/src/print_job/main.dart | 1 + .../src/print_job/print_job_controller.dart | 128 + .../lib/src/process_global_config.dart | 102 + .../lib/src/proxy_controller.dart | 99 + .../lib/src/pull_to_refresh/main.dart | 1 + .../pull_to_refresh_controller.dart | 258 ++ .../lib/src/service_worker_controller.dart | 212 + .../lib/src/tracing_controller.dart | 113 + .../lib/src/web_message/main.dart | 3 + .../src/web_message/web_message_channel.dart | 127 + .../src/web_message/web_message_listener.dart | 176 + .../lib/src/web_message/web_message_port.dart | 114 + .../lib/src/web_storage/main.dart | 2 + .../lib/src/web_storage/web_storage.dart | 311 ++ .../src/web_storage/web_storage_manager.dart | 232 + .../lib/src/webview_asset_loader.dart | 349 ++ .../lib/src/webview_feature.dart | 118 + flutter_inappwebview_android/pubspec.yaml | 74 + ...ppwebview_android_method_channel_test.dart | 27 + .../flutter_inappwebview_android_test.dart | 29 + .../.gitignore | 30 + .../.metadata | 10 + .../CHANGELOG.md | 3 + .../LICENSE | 1 + .../README.md | 39 + .../analysis_options.yaml | 11 + ...utter_inappwebview_platform_interface.dart | 3 + .../android/chrome_custom_tabs_options.dart | 4 +- .../chrome_safari_browser/android/main.dart | 0 .../src/chrome_safari_browser/apple/main.dart | 0 .../apple/safari_options.dart | 4 +- .../chrome_safari_action_button.dart | 4 +- .../chrome_safari_action_button.g.dart | 2 +- .../chrome_safari_browser_menu_item.dart | 4 +- .../chrome_safari_browser_menu_item.g.dart | 2 +- ...rome_safari_browser_secondary_toolbar.dart | 4 +- ...me_safari_browser_secondary_toolbar.g.dart | 2 +- .../chrome_safari_browser_settings.dart | 0 .../chrome_safari_browser_settings.g.dart | 0 .../lib/src/chrome_safari_browser/main.dart | 14 + .../platform_chrome_safari_browser.dart | 697 +++ .../lib}/src/content_blocker.dart | 0 .../lib}/src/context_menu/context_menu.dart | 4 +- .../lib}/src/context_menu/context_menu.g.dart | 2 +- .../src/context_menu/context_menu_item.dart | 0 .../src/context_menu/context_menu_item.g.dart | 0 .../context_menu/context_menu_settings.dart | 0 .../context_menu/context_menu_settings.g.dart | 0 .../lib}/src/context_menu/main.dart | 0 .../lib}/src/debug_logging_settings.dart | 0 .../lib/src/find_interaction/main.dart | 1 + .../platform_find_interaction_controller.dart | 225 + .../android/in_app_browser_options.dart | 4 +- .../lib}/src/in_app_browser/android/main.dart | 0 .../apple/in_app_browser_options.dart | 4 +- .../lib}/src/in_app_browser/apple/main.dart | 0 .../in_app_browser_menu_item.dart | 4 +- .../in_app_browser_menu_item.g.dart | 2 +- .../in_app_browser_settings.dart | 1 - .../in_app_browser_settings.g.dart | 0 .../lib/src/in_app_browser/main.dart | 11 + .../platform_in_app_browser.dart | 1309 ++++++ .../lib}/src/in_app_localhost_server.dart | 0 .../android/in_app_webview_options.dart | 1 - .../lib/src/in_app_webview/android/main.dart | 1 + .../apple/in_app_webview_options.dart | 53 +- .../lib/src/in_app_webview/apple/main.dart | 1 + .../in_app_webview_keep_alive.dart | 20 +- .../in_app_webview_settings.dart | 101 +- .../in_app_webview_settings.g.dart | 93 +- .../lib/src/in_app_webview/main.dart | 11 + .../platform_headless_in_app_webview.dart | 265 ++ .../platform_inappwebview_controller.dart | 2086 +++++++++ .../platform_inappwebview_widget.dart | 224 + .../src/in_app_webview/platform_webview.dart | 223 +- .../lib/src/inappwebview_platform.dart | 430 ++ .../lib/src/main.dart | 34 + .../lib}/src/mime_type_resolver.dart | 0 .../lib/src/platform_cookie_manager.dart | 253 + ...atform_http_auth_credentials_database.dart | 132 + .../src/platform_process_global_config.dart | 109 +- .../src/platform_process_global_config.g.dart | 18 +- .../lib/src/platform_proxy_controller.dart | 98 +- .../lib/src/platform_proxy_controller.g.dart | 4 +- .../platform_service_worker_controller.dart | 191 + .../lib/src/platform_tracing_controller.dart | 105 +- .../src/platform_tracing_controller.g.dart | 4 +- .../src/platform_webview_asset_loader.dart | 430 ++ .../lib/src/platform_webview_feature.dart | 657 +-- .../lib/src/platform_webview_feature.g.dart | 58 +- .../lib/src/print_job/main.dart | 2 + .../platform_print_job_controller.dart | 133 + .../src/print_job/print_job_settings.dart | 6 +- .../src/print_job/print_job_settings.g.dart | 4 +- .../lib/src/pull_to_refresh/main.dart | 3 + .../platform_pull_to_refresh_controller.dart | 227 + .../pull_to_refresh_settings.dart | 0 .../pull_to_refresh_settings.g.dart | 0 .../lib}/src/types/action_mode_menu_item.dart | 0 .../src/types/action_mode_menu_item.g.dart | 0 .../lib}/src/types/activity_button.dart | 0 .../lib}/src/types/activity_button.g.dart | 0 .../lib}/src/types/ajax_request.dart | 0 .../lib}/src/types/ajax_request.g.dart | 0 .../lib}/src/types/ajax_request_action.dart | 0 .../lib}/src/types/ajax_request_action.g.dart | 0 .../lib}/src/types/ajax_request_event.dart | 0 .../lib}/src/types/ajax_request_event.g.dart | 0 .../src/types/ajax_request_event_type.dart | 0 .../src/types/ajax_request_event_type.g.dart | 0 .../lib}/src/types/ajax_request_headers.dart | 0 .../src/types/ajax_request_headers.g.dart | 0 .../src/types/ajax_request_ready_state.dart | 0 .../src/types/ajax_request_ready_state.g.dart | 0 .../lib}/src/types/android_resource.dart | 0 .../lib}/src/types/android_resource.g.dart | 0 .../lib}/src/types/attributed_string.dart | 4 +- .../lib}/src/types/attributed_string.g.dart | 4 +- .../attributed_string_text_effect_style.dart | 0 ...attributed_string_text_effect_style.g.dart | 0 .../lib}/src/types/cache_mode.dart | 0 .../lib}/src/types/cache_mode.g.dart | 0 .../types/call_async_javascript_result.dart | 4 +- .../types/call_async_javascript_result.g.dart | 0 .../lib}/src/types/client_cert_challenge.dart | 2 +- .../src/types/client_cert_challenge.g.dart | 0 .../lib}/src/types/client_cert_response.dart | 2 +- .../src/types/client_cert_response.g.dart | 0 .../types/client_cert_response_action.dart | 0 .../types/client_cert_response_action.g.dart | 0 .../lib}/src/types/compress_format.dart | 0 .../lib}/src/types/compress_format.g.dart | 0 .../lib}/src/types/console_message.dart | 2 +- .../lib}/src/types/console_message.g.dart | 0 .../lib}/src/types/console_message_level.dart | 0 .../src/types/console_message_level.g.dart | 0 .../types/content_blocker_action_type.dart | 0 .../types/content_blocker_action_type.g.dart | 0 .../content_blocker_trigger_load_context.dart | 0 ...ontent_blocker_trigger_load_context.g.dart | 0 .../content_blocker_trigger_load_type.dart | 0 .../content_blocker_trigger_load_type.g.dart | 0 ...content_blocker_trigger_resource_type.dart | 0 ...ntent_blocker_trigger_resource_type.g.dart | 0 .../lib}/src/types/content_world.dart | 0 .../lib}/src/types/cookie.dart | 6 +- .../lib}/src/types/cookie.g.dart | 2 +- .../lib}/src/types/create_window_action.dart | 4 +- .../src/types/create_window_action.g.dart | 2 +- .../lib}/src/types/cross_origin.dart | 0 .../lib}/src/types/cross_origin.g.dart | 0 .../types/css_link_html_tag_attributes.dart | 4 +- .../types/css_link_html_tag_attributes.g.dart | 0 .../src/types/custom_scheme_response.dart | 2 +- .../src/types/custom_scheme_response.g.dart | 0 .../custom_tabs_navigation_event_type.dart | 4 +- .../custom_tabs_navigation_event_type.g.dart | 2 +- .../custom_tabs_post_message_result_type.dart | 0 ...ustom_tabs_post_message_result_type.g.dart | 0 .../src/types/custom_tabs_relation_type.dart | 0 .../types/custom_tabs_relation_type.g.dart | 0 .../src/types/custom_tabs_share_state.dart | 0 .../src/types/custom_tabs_share_state.g.dart | 0 .../lib}/src/types/data_detector_types.dart | 0 .../lib}/src/types/data_detector_types.g.dart | 0 .../lib}/src/types/dismiss_button_style.dart | 0 .../src/types/dismiss_button_style.g.dart | 0 .../lib}/src/types/disposable.dart | 0 .../src/types/download_start_request.dart | 2 +- .../src/types/download_start_request.g.dart | 0 .../lib}/src/types/favicon.dart | 4 +- .../lib}/src/types/favicon.g.dart | 0 .../lib}/src/types/fetch_request.dart | 0 .../lib}/src/types/fetch_request.g.dart | 0 .../lib}/src/types/fetch_request_action.dart | 0 .../src/types/fetch_request_action.g.dart | 0 .../src/types/fetch_request_credential.dart | 0 .../src/types/fetch_request_credential.g.dart | 0 .../fetch_request_credential_default.dart | 0 .../fetch_request_credential_default.g.dart | 0 .../fetch_request_federated_credential.dart | 0 .../fetch_request_federated_credential.g.dart | 0 .../fetch_request_password_credential.dart | 0 .../fetch_request_password_credential.g.dart | 0 .../lib}/src/types/find_session.dart | 0 .../lib}/src/types/find_session.g.dart | 0 .../lib}/src/types/force_dark.dart | 0 .../lib}/src/types/force_dark.g.dart | 0 .../lib}/src/types/force_dark_strategy.dart | 16 +- .../lib}/src/types/force_dark_strategy.g.dart | 14 +- .../src/types/form_resubmission_action.dart | 2 +- .../src/types/form_resubmission_action.g.dart | 0 .../lib}/src/types/frame_info.dart | 0 .../lib}/src/types/frame_info.g.dart | 0 ...ation_permission_show_prompt_response.dart | 2 +- ...ion_permission_show_prompt_response.g.dart | 0 .../lib}/src/types/http_auth_response.dart | 2 +- .../lib}/src/types/http_auth_response.g.dart | 0 .../src/types/http_auth_response_action.dart | 0 .../types/http_auth_response_action.g.dart | 0 .../types/http_authentication_challenge.dart | 2 +- .../http_authentication_challenge.g.dart | 0 .../types/http_cookie_same_site_policy.dart | 0 .../types/http_cookie_same_site_policy.g.dart | 0 .../types/in_app_webview_hit_test_result.dart | 0 .../in_app_webview_hit_test_result.g.dart | 0 .../in_app_webview_hit_test_result_type.dart | 0 ...in_app_webview_hit_test_result_type.g.dart | 0 .../types/in_app_webview_initial_data.dart | 4 +- .../types/in_app_webview_initial_data.g.dart | 2 +- .../lib}/src/types/in_app_webview_rect.dart | 0 .../lib}/src/types/in_app_webview_rect.g.dart | 0 .../types/javascript_handler_callback.dart | 4 +- .../lib}/src/types/js_alert_request.dart | 2 +- .../lib}/src/types/js_alert_request.g.dart | 0 .../lib}/src/types/js_alert_response.dart | 2 +- .../lib}/src/types/js_alert_response.g.dart | 0 .../src/types/js_alert_response_action.dart | 0 .../src/types/js_alert_response_action.g.dart | 0 .../src/types/js_before_unload_request.dart | 2 +- .../src/types/js_before_unload_request.g.dart | 0 .../src/types/js_before_unload_response.dart | 2 +- .../types/js_before_unload_response.g.dart | 0 .../js_before_unload_response_action.dart | 0 .../js_before_unload_response_action.g.dart | 0 .../lib}/src/types/js_confirm_request.dart | 2 +- .../lib}/src/types/js_confirm_request.g.dart | 0 .../lib}/src/types/js_confirm_response.dart | 2 +- .../lib}/src/types/js_confirm_response.g.dart | 0 .../src/types/js_confirm_response_action.dart | 0 .../types/js_confirm_response_action.g.dart | 0 .../lib}/src/types/js_prompt_request.dart | 2 +- .../lib}/src/types/js_prompt_request.g.dart | 0 .../lib}/src/types/js_prompt_response.dart | 2 +- .../lib}/src/types/js_prompt_response.g.dart | 0 .../src/types/js_prompt_response_action.dart | 0 .../types/js_prompt_response_action.g.dart | 0 .../lib}/src/types/layout_algorithm.dart | 0 .../lib}/src/types/layout_algorithm.g.dart | 0 .../types/layout_in_display_cutout_mode.dart | 0 .../layout_in_display_cutout_mode.g.dart | 0 .../lib}/src/types/loaded_resource.dart | 4 +- .../lib}/src/types/loaded_resource.g.dart | 2 +- .../lib}/src/types/login_request.dart | 2 +- .../lib}/src/types/login_request.g.dart | 0 .../lib}/src/types/main.dart | 1 + .../lib}/src/types/media_capture_state.dart | 0 .../lib}/src/types/media_capture_state.g.dart | 0 .../lib}/src/types/media_playback_state.dart | 0 .../src/types/media_playback_state.g.dart | 0 .../lib}/src/types/meta_tag.dart | 4 +- .../lib}/src/types/meta_tag.g.dart | 0 .../lib}/src/types/meta_tag_attribute.dart | 0 .../lib}/src/types/meta_tag_attribute.g.dart | 0 .../lib}/src/types/mixed_content_mode.dart | 0 .../lib}/src/types/mixed_content_mode.g.dart | 0 .../src/types/modal_presentation_style.dart | 0 .../src/types/modal_presentation_style.g.dart | 0 .../src/types/modal_transition_style.dart | 0 .../src/types/modal_transition_style.g.dart | 0 .../lib}/src/types/navigation_action.dart | 2 +- .../lib}/src/types/navigation_action.g.dart | 0 .../src/types/navigation_action_policy.dart | 2 +- .../src/types/navigation_action_policy.g.dart | 0 .../lib}/src/types/navigation_response.dart | 2 +- .../lib}/src/types/navigation_response.g.dart | 0 .../src/types/navigation_response_action.dart | 2 +- .../types/navigation_response_action.g.dart | 0 .../lib}/src/types/navigation_type.dart | 2 +- .../lib}/src/types/navigation_type.g.dart | 0 .../src/types/on_post_message_callback.dart | 6 + .../lib}/src/types/over_scroll_mode.dart | 10 +- .../lib}/src/types/over_scroll_mode.g.dart | 8 +- .../lib}/src/types/pdf_configuration.dart | 6 +- .../lib}/src/types/pdf_configuration.g.dart | 4 +- .../lib}/src/types/permission_request.dart | 2 +- .../lib}/src/types/permission_request.g.dart | 0 .../src/types/permission_resource_type.dart | 0 .../src/types/permission_resource_type.g.dart | 0 .../lib}/src/types/permission_response.dart | 2 +- .../lib}/src/types/permission_response.g.dart | 0 .../src/types/permission_response_action.dart | 0 .../types/permission_response_action.g.dart | 0 .../lib}/src/types/prewarming_token.dart | 4 +- .../lib}/src/types/prewarming_token.g.dart | 2 +- .../lib}/src/types/print_job_attributes.dart | 2 +- .../src/types/print_job_attributes.g.dart | 2 +- .../lib}/src/types/print_job_color_mode.dart | 2 +- .../src/types/print_job_color_mode.g.dart | 2 +- .../lib}/src/types/print_job_disposition.dart | 2 +- .../src/types/print_job_disposition.g.dart | 2 +- .../lib}/src/types/print_job_duplex_mode.dart | 2 +- .../src/types/print_job_duplex_mode.g.dart | 2 +- .../lib}/src/types/print_job_info.dart | 2 +- .../lib}/src/types/print_job_info.g.dart | 2 +- .../lib}/src/types/print_job_media_size.dart | 2 +- .../src/types/print_job_media_size.g.dart | 2 +- .../lib}/src/types/print_job_orientation.dart | 2 +- .../src/types/print_job_orientation.g.dart | 2 +- .../lib}/src/types/print_job_output_type.dart | 2 +- .../src/types/print_job_output_type.g.dart | 2 +- .../lib}/src/types/print_job_page_order.dart | 2 +- .../src/types/print_job_page_order.g.dart | 2 +- .../src/types/print_job_pagination_mode.dart | 2 +- .../types/print_job_pagination_mode.g.dart | 2 +- .../types/print_job_rendering_quality.dart | 2 +- .../types/print_job_rendering_quality.g.dart | 2 +- .../lib}/src/types/print_job_resolution.dart | 2 +- .../src/types/print_job_resolution.g.dart | 2 +- .../lib}/src/types/print_job_state.dart | 2 +- .../lib}/src/types/print_job_state.g.dart | 2 +- .../lib}/src/types/printer.dart | 2 +- .../lib}/src/types/printer.g.dart | 2 +- .../lib}/src/types/proxy_rule.dart | 0 .../lib}/src/types/proxy_rule.g.dart | 0 .../lib}/src/types/proxy_scheme_filter.dart | 4 +- .../lib}/src/types/proxy_scheme_filter.g.dart | 2 +- .../lib}/src/types/pull_to_refresh_size.dart | 0 .../src/types/pull_to_refresh_size.g.dart | 0 .../lib}/src/types/referrer_policy.dart | 0 .../lib}/src/types/referrer_policy.g.dart | 0 .../src/types/render_process_gone_detail.dart | 4 +- .../types/render_process_gone_detail.g.dart | 2 +- .../lib}/src/types/renderer_priority.dart | 0 .../lib}/src/types/renderer_priority.g.dart | 0 .../src/types/renderer_priority_policy.dart | 2 +- .../src/types/renderer_priority_policy.g.dart | 0 .../types/request_focus_node_href_result.dart | 4 +- .../request_focus_node_href_result.g.dart | 0 .../src/types/request_image_ref_result.dart | 4 +- .../src/types/request_image_ref_result.g.dart | 0 .../src/types/safe_browsing_response.dart | 6 +- .../src/types/safe_browsing_response.g.dart | 0 .../types/safe_browsing_response_action.dart | 0 .../safe_browsing_response_action.g.dart | 0 .../lib}/src/types/safe_browsing_threat.dart | 0 .../src/types/safe_browsing_threat.g.dart | 0 .../lib}/src/types/sandbox.dart | 0 .../lib}/src/types/sandbox.g.dart | 0 .../src/types/screenshot_configuration.dart | 10 +- .../src/types/screenshot_configuration.g.dart | 4 +- .../src/types/script_html_tag_attributes.dart | 4 +- .../types/script_html_tag_attributes.g.dart | 0 .../lib}/src/types/scrollbar_style.dart | 0 .../lib}/src/types/scrollbar_style.g.dart | 0 ...iew_content_inset_adjustment_behavior.dart | 0 ...w_content_inset_adjustment_behavior.g.dart | 0 .../types/scrollview_deceleration_rate.dart | 0 .../types/scrollview_deceleration_rate.g.dart | 0 .../types/search_result_display_style.dart | 0 .../types/search_result_display_style.g.dart | 0 .../lib}/src/types/security_origin.dart | 0 .../lib}/src/types/security_origin.g.dart | 0 .../lib}/src/types/selection_granularity.dart | 0 .../src/types/selection_granularity.g.dart | 0 .../src/types/server_trust_auth_response.dart | 2 +- .../types/server_trust_auth_response.g.dart | 0 .../server_trust_auth_response_action.dart | 0 .../server_trust_auth_response_action.g.dart | 0 .../src/types/server_trust_challenge.dart | 2 +- .../src/types/server_trust_challenge.g.dart | 0 .../should_allow_deprecated_tls_action.dart | 2 +- .../should_allow_deprecated_tls_action.g.dart | 0 .../lib}/src/types/ssl_certificate.dart | 0 .../lib}/src/types/ssl_certificate.g.dart | 0 .../lib}/src/types/ssl_certificate_dname.dart | 0 .../src/types/ssl_certificate_dname.g.dart | 0 .../lib}/src/types/ssl_error.dart | 0 .../lib}/src/types/ssl_error.g.dart | 0 .../lib}/src/types/ssl_error_type.dart | 0 .../lib}/src/types/ssl_error_type.g.dart | 0 .../lib}/src/types/tracing_category.dart | 0 .../lib}/src/types/tracing_category.g.dart | 0 .../lib}/src/types/tracing_mode.dart | 0 .../lib}/src/types/tracing_mode.g.dart | 0 ...ted_web_activity_default_display_mode.dart | 0 ...d_web_activity_default_display_mode.g.dart | 0 .../trusted_web_activity_display_mode.dart | 0 .../trusted_web_activity_display_mode.g.dart | 0 ...d_web_activity_immersive_display_mode.dart | 0 ...web_activity_immersive_display_mode.g.dart | 0 ...usted_web_activity_screen_orientation.dart | 0 ...ted_web_activity_screen_orientation.g.dart | 0 .../lib}/src/types/ui_event_attribution.dart | 0 .../src/types/ui_event_attribution.g.dart | 0 .../lib}/src/types/ui_image.dart | 0 .../lib}/src/types/ui_image.g.dart | 0 .../lib}/src/types/underline_style.dart | 0 .../lib}/src/types/underline_style.g.dart | 0 .../types/url_authentication_challenge.dart | 0 .../types/url_authentication_challenge.g.dart | 0 .../lib}/src/types/url_credential.dart | 0 .../lib}/src/types/url_credential.g.dart | 0 .../src/types/url_credential_persistence.dart | 0 .../types/url_credential_persistence.g.dart | 0 .../lib}/src/types/url_protection_space.dart | 0 .../src/types/url_protection_space.g.dart | 0 ...rotection_space_authentication_method.dart | 0 ...tection_space_authentication_method.g.dart | 0 ...rotection_space_http_auth_credentials.dart | 4 +- ...tection_space_http_auth_credentials.g.dart | 2 +- .../url_protection_space_proxy_type.dart | 0 .../url_protection_space_proxy_type.g.dart | 0 .../lib}/src/types/url_request.dart | 0 .../lib}/src/types/url_request.g.dart | 0 .../src/types/url_request_attribution.dart | 0 .../src/types/url_request_attribution.g.dart | 0 .../src/types/url_request_cache_policy.dart | 0 .../src/types/url_request_cache_policy.g.dart | 0 .../url_request_network_service_type.dart | 0 .../url_request_network_service_type.g.dart | 0 .../lib}/src/types/url_response.dart | 0 .../lib}/src/types/url_response.g.dart | 0 .../types/user_preferred_content_mode.dart | 0 .../types/user_preferred_content_mode.g.dart | 0 .../lib}/src/types/user_script.dart | 8 +- .../lib}/src/types/user_script.g.dart | 4 +- .../src/types/user_script_injection_time.dart | 4 +- .../types/user_script_injection_time.g.dart | 2 +- .../types/vertical_scrollbar_position.dart | 0 .../types/vertical_scrollbar_position.g.dart | 0 .../lib}/src/types/web_archive_format.dart | 0 .../lib}/src/types/web_archive_format.g.dart | 0 .../web_authentication_session_error.dart | 0 .../web_authentication_session_error.g.dart | 0 .../lib}/src/types/web_history.dart | 4 +- .../lib}/src/types/web_history.g.dart | 2 +- .../lib}/src/types/web_history_item.dart | 4 +- .../lib}/src/types/web_history_item.g.dart | 2 +- .../lib}/src/types/web_message_callback.dart | 2 +- .../lib}/src/types/web_resource_error.dart | 0 .../lib}/src/types/web_resource_error.g.dart | 0 .../src/types/web_resource_error_type.dart | 0 .../src/types/web_resource_error_type.g.dart | 0 .../lib}/src/types/web_resource_request.dart | 4 +- .../src/types/web_resource_request.g.dart | 2 +- .../lib}/src/types/web_resource_response.dart | 4 +- .../src/types/web_resource_response.g.dart | 2 +- .../lib}/src/types/web_storage_origin.dart | 7 +- .../lib}/src/types/web_storage_origin.g.dart | 2 +- .../lib}/src/types/web_storage_type.dart | 4 +- .../lib}/src/types/web_storage_type.g.dart | 0 .../lib}/src/types/website_data_record.dart | 0 .../lib}/src/types/website_data_record.g.dart | 0 .../lib}/src/types/website_data_type.dart | 0 .../lib}/src/types/website_data_type.g.dart | 0 .../lib}/src/types/webview_package_info.dart | 6 +- .../src/types/webview_package_info.g.dart | 4 +- .../types/webview_render_process_action.dart | 2 +- .../webview_render_process_action.g.dart | 0 .../lib}/src/types/window_features.dart | 0 .../lib}/src/types/window_features.g.dart | 0 .../lib}/src/types/window_style_mask.dart | 0 .../lib}/src/types/window_style_mask.g.dart | 0 .../window_titlebar_separator_style.dart | 0 .../window_titlebar_separator_style.g.dart | 0 .../lib}/src/types/window_type.dart | 0 .../lib}/src/types/window_type.g.dart | 0 .../lib}/src/util.dart | 0 .../src/web_authentication_session/main.dart | 3 + .../platform_web_authenticate_session.dart | 212 + .../web_authenticate_session_settings.dart | 6 +- .../web_authenticate_session_settings.g.dart | 4 +- .../lib/src/web_message/main.dart | 4 + .../platform_web_message_channel.dart | 114 + .../platform_web_message_listener.dart | 177 + .../platform_web_message_port.dart | 106 + .../lib}/src/web_message/web_message.dart | 6 +- .../lib}/src/web_message/web_message.g.dart | 4 +- .../lib/src/web_storage/main.dart | 3 + .../src/web_storage/platform_web_storage.dart | 330 ++ .../platform_web_storage_manager.dart | 152 + .../src/web_storage/web_storage_item.dart | 0 .../src/web_storage/web_storage_item.g.dart | 0 .../lib}/src/web_uri.dart | 0 .../src/x509_certificate/asn1_decoder.dart | 0 .../x509_certificate/asn1_der_encoder.dart | 0 .../asn1_distinguished_names.dart | 0 .../src/x509_certificate/asn1_identifier.dart | 0 .../src/x509_certificate/asn1_object.dart | 0 .../lib}/src/x509_certificate/key_usage.dart | 0 .../lib}/src/x509_certificate/main.dart | 0 .../lib}/src/x509_certificate/oid.dart | 0 .../x509_certificate/x509_certificate.dart | 0 .../src/x509_certificate/x509_extension.dart | 0 .../src/x509_certificate/x509_public_key.dart | 0 .../pubspec.yaml | 59 + ..._inappwebview_platform_interface_test.dart | 7 + lib/flutter_inappwebview.dart | 12 + lib/src/android/main.dart | 16 - lib/src/android/webview_asset_loader.dart | 181 - lib/src/apple/main.dart | 1 - .../chrome_safari_browser.dart | 13 +- lib/src/chrome_safari_browser/main.dart | 13 - lib/src/cookie_manager.dart | 476 +- .../find_interaction_controller.dart | 152 +- lib/src/http_auth_credentials_database.dart | 133 +- lib/src/in_app_browser/in_app_browser.dart | 369 +- lib/src/in_app_browser/main.dart | 10 - .../android/in_app_webview_controller.dart | 44 +- lib/src/in_app_webview/android/main.dart | 1 - .../apple/in_app_webview_controller.dart | 27 +- lib/src/in_app_webview/apple/main.dart | 1 - .../headless_in_app_webview.dart | 1198 ++--- lib/src/in_app_webview/in_app_webview.dart | 1266 ++--- .../in_app_webview_controller.dart | 2716 +---------- lib/src/in_app_webview/main.dart | 12 +- lib/src/main.dart | 16 +- lib/src/print_job/main.dart | 1 - lib/src/print_job/print_job_controller.dart | 87 +- lib/src/process_global_config.dart | 68 + lib/src/proxy_controller.dart | 62 + lib/src/pull_to_refresh/main.dart | 4 +- .../pull_to_refresh_controller.dart | 173 +- .../service_worker_controller.dart | 253 +- lib/src/tracing_controller.dart | 72 + lib/src/types/on_post_message_callback.dart | 6 - .../headless_in_app_web_view_web_element.dart | 2 +- lib/src/web/in_app_web_view_web_element.dart | 2 +- lib/src/web/platform_util.dart | 2 +- lib/src/web_authentication_session/main.dart | 2 - .../web_authenticate_session.dart | 147 +- lib/src/web_message/main.dart | 5 +- lib/src/web_message/web_message_channel.dart | 93 +- lib/src/web_message/web_message_listener.dart | 149 +- lib/src/web_message/web_message_port.dart | 80 +- lib/src/web_storage/_static_channel.dart | 4 - .../android/web_storage_manager.dart | 32 +- .../web_storage/ios/web_storage_manager.dart | 56 +- lib/src/web_storage/main.dart | 1 - lib/src/web_storage/web_storage.dart | 205 +- lib/src/web_storage/web_storage_manager.dart | 156 +- ...oader.g.dart => webview_asset_loader.dart} | 319 +- lib/src/webview_feature.dart | 52 + pubspec.yaml | 10 +- 771 files changed, 21512 insertions(+), 7599 deletions(-) delete mode 100755 android/.idea/.name delete mode 100755 android/.idea/caches/build_file_checksums.ser delete mode 100755 android/.idea/caches/gradle_models.ser delete mode 100755 android/.idea/codeStyles/Project.xml delete mode 100755 android/.idea/gradle.xml delete mode 100755 android/.idea/misc.xml delete mode 100755 android/.idea/modules.xml delete mode 100755 android/.idea/runConfigurations.xml delete mode 100755 android/.idea/vcs.xml create mode 100644 flutter_inappwebview_android/.gitignore create mode 100644 flutter_inappwebview_android/.metadata create mode 100644 flutter_inappwebview_android/CHANGELOG.md create mode 100644 flutter_inappwebview_android/LICENSE create mode 100644 flutter_inappwebview_android/README.md create mode 100644 flutter_inappwebview_android/analysis_options.yaml rename {android => flutter_inappwebview_android/android}/.gitignore (100%) rename {android => flutter_inappwebview_android/android}/build.gradle (100%) rename {android => flutter_inappwebview_android/android}/gradle.properties (100%) rename {android => flutter_inappwebview_android/android}/proguard-rules.pro (100%) rename {android => flutter_inappwebview_android/android}/settings.gradle (100%) rename {android => flutter_inappwebview_android/android}/src/main/AndroidManifest.xml (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/ISettings.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebViewFileProvider.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebViewFlutterPlugin.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyCookieManager.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyWebStorage.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/PlatformUtil.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/Util.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/WebViewFeatureManager.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ActionBroadcastReceiver.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsActivity.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsActivitySingleInstance.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsChannelDelegate.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsSettings.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeSafariBrowserManager.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/CustomTabActivityHelper.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/CustomTabsHelper.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/KeepAliveService.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ServiceConnection.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ServiceConnectionCallback.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/TrustedWebActivity.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/TrustedWebActivitySingleInstance.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlocker.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerAction.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerActionType.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerHandler.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerTrigger.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerTriggerResourceType.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabase.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabaseHandler.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabaseHelper.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLCredentialContract.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLCredentialDao.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLProtectionSpaceContract.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLProtectionSpaceDao.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionChannelDelegate.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionController.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionSettings.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessInAppWebView.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessInAppWebViewManager.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessWebViewChannelDelegate.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/ActivityResultListener.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserActivity.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserChannelDelegate.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserDelegate.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserManager.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserSettings.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/ConsoleLogJS.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/InterceptAjaxRequestJS.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/InterceptFetchRequestJS.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/JavaScriptBridgeJS.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnLoadResourceJS.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnWindowBlurEventJS.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnWindowFocusEventJS.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PluginScriptsUtil.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PrintJS.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PromisePolyfillJS.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobChannelDelegate.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobController.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobManager.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobSettings.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/process_global_config/ProcessGlobalConfigManager.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/process_global_config/ProcessGlobalConfigSettings.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/proxy/ProxyManager.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/proxy/ProxySettings.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshChannelDelegate.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshLayout.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshSettings.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/service_worker/ServiceWorkerChannelDelegate.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/service_worker/ServiceWorkerManager.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingControllerChannelDelegate.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingControllerManager.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingSettings.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/AndroidResource.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/BaseCallbackResultImpl.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ChannelDelegateImpl.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ClientCertChallenge.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ClientCertResponse.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ContentWorld.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CreateWindowAction.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomSchemeResponse.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsActionButton.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsMenuItem.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsSecondaryToolbar.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/Disposable.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/DownloadStartRequest.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/FindSession.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/GeolocationPermissionShowPromptResponse.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HitTestResult.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HttpAuthResponse.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HttpAuthenticationChallenge.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ICallbackResult.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/IChannelDelegate.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/InAppBrowserMenuItem.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsAlertResponse.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsBeforeUnloadResponse.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsConfirmResponse.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsPromptResponse.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/MarginsExt.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/MediaSizeExt.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/NavigationAction.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/NavigationActionPolicy.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PermissionResponse.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PluginScript.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PreferredContentModeOptionType.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PrintAttributesExt.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PrintJobInfoExt.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ProxyRuleExt.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ResolutionExt.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SafeBrowsingResponse.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ServerTrustAuthResponse.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ServerTrustChallenge.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/Size2D.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SslCertificateExt.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SslErrorExt.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SyncBaseCallbackResultImpl.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLAuthenticationChallenge.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLCredential.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLProtectionSpace.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLRequest.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserContentController.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserScript.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserScriptInjectionTime.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessage.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessageCompatExt.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessagePort.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessagePortCompatExt.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceErrorExt.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceRequestExt.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceResponseExt.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebViewAssetLoaderExt.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/ContextMenuSettings.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/FlutterWebViewFactory.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/InAppWebViewInterface.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/InAppWebViewManager.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/JavaScriptBridgeInterface.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/PlatformWebView.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegate.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegateMethods.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/DisplayListenerProxy.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/FlutterWebView.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebView.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewChromeClient.java (99%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewClient.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewClientCompat.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewRenderProcessClient.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewSettings.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InputAwareWebView.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/ThreadedInputConnectionProxyAdapterView.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageChannel.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageChannelChannelDelegate.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageListener.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageListenerChannelDelegate.java (100%) rename {android => flutter_inappwebview_android/android}/src/main/res/drawable/floating_action_mode_shape.xml (100%) rename {android => flutter_inappwebview_android/android}/src/main/res/layout/activity_web_view.xml (100%) rename {android => flutter_inappwebview_android/android}/src/main/res/layout/chrome_custom_tabs_layout.xml (100%) rename {android => flutter_inappwebview_android/android}/src/main/res/layout/floating_action_mode.xml (100%) rename {android => flutter_inappwebview_android/android}/src/main/res/layout/floating_action_mode_item.xml (100%) rename {android => flutter_inappwebview_android/android}/src/main/res/menu/menu_main.xml (100%) rename {android => flutter_inappwebview_android/android}/src/main/res/values/strings.xml (100%) rename {android => flutter_inappwebview_android/android}/src/main/res/values/styles.xml (100%) rename {android => flutter_inappwebview_android/android}/src/main/res/xml/provider_paths.xml (100%) create mode 100644 flutter_inappwebview_android/example/.gitignore create mode 100644 flutter_inappwebview_android/example/README.md create mode 100644 flutter_inappwebview_android/example/analysis_options.yaml create mode 100644 flutter_inappwebview_android/example/android/.gitignore create mode 100644 flutter_inappwebview_android/example/android/app/build.gradle create mode 100644 flutter_inappwebview_android/example/android/app/src/debug/AndroidManifest.xml create mode 100644 flutter_inappwebview_android/example/android/app/src/main/AndroidManifest.xml create mode 100644 flutter_inappwebview_android/example/android/app/src/main/java/com/pichillilorenzo/flutter_inappwebview_android_example/MainActivity.java create mode 100644 flutter_inappwebview_android/example/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 flutter_inappwebview_android/example/android/app/src/main/res/drawable/launch_background.xml create mode 100644 flutter_inappwebview_android/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 flutter_inappwebview_android/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 flutter_inappwebview_android/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 flutter_inappwebview_android/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 flutter_inappwebview_android/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 flutter_inappwebview_android/example/android/app/src/main/res/values-night/styles.xml create mode 100644 flutter_inappwebview_android/example/android/app/src/main/res/values/styles.xml create mode 100644 flutter_inappwebview_android/example/android/app/src/profile/AndroidManifest.xml create mode 100644 flutter_inappwebview_android/example/android/build.gradle create mode 100644 flutter_inappwebview_android/example/android/gradle.properties create mode 100644 flutter_inappwebview_android/example/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 flutter_inappwebview_android/example/android/settings.gradle create mode 100644 flutter_inappwebview_android/example/integration_test/plugin_integration_test.dart create mode 100644 flutter_inappwebview_android/example/lib/main.dart create mode 100644 flutter_inappwebview_android/example/pubspec.lock create mode 100644 flutter_inappwebview_android/example/pubspec.yaml create mode 100644 flutter_inappwebview_android/example/test/widget_test.dart create mode 100644 flutter_inappwebview_android/lib/flutter_inappwebview_android.dart create mode 100755 flutter_inappwebview_android/lib/src/cookie_manager.dart create mode 100644 flutter_inappwebview_android/lib/src/find_interaction/find_interaction_controller.dart create mode 100644 flutter_inappwebview_android/lib/src/find_interaction/main.dart create mode 100755 flutter_inappwebview_android/lib/src/http_auth_credentials_database.dart create mode 100755 flutter_inappwebview_android/lib/src/in_app_browser/in_app_browser.dart create mode 100644 flutter_inappwebview_android/lib/src/in_app_browser/main.dart create mode 100644 flutter_inappwebview_android/lib/src/in_app_webview/_static_channel.dart create mode 100644 flutter_inappwebview_android/lib/src/in_app_webview/headless_in_app_webview.dart create mode 100755 flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart create mode 100644 flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart create mode 100644 flutter_inappwebview_android/lib/src/in_app_webview/main.dart create mode 100644 flutter_inappwebview_android/lib/src/inappwebview_platform.dart create mode 100644 flutter_inappwebview_android/lib/src/main.dart rename {lib => flutter_inappwebview_android/lib}/src/platform_util.dart (96%) create mode 100644 flutter_inappwebview_android/lib/src/print_job/main.dart create mode 100644 flutter_inappwebview_android/lib/src/print_job/print_job_controller.dart create mode 100644 flutter_inappwebview_android/lib/src/process_global_config.dart create mode 100644 flutter_inappwebview_android/lib/src/proxy_controller.dart create mode 100644 flutter_inappwebview_android/lib/src/pull_to_refresh/main.dart create mode 100644 flutter_inappwebview_android/lib/src/pull_to_refresh/pull_to_refresh_controller.dart create mode 100644 flutter_inappwebview_android/lib/src/service_worker_controller.dart create mode 100644 flutter_inappwebview_android/lib/src/tracing_controller.dart create mode 100644 flutter_inappwebview_android/lib/src/web_message/main.dart create mode 100644 flutter_inappwebview_android/lib/src/web_message/web_message_channel.dart create mode 100644 flutter_inappwebview_android/lib/src/web_message/web_message_listener.dart create mode 100644 flutter_inappwebview_android/lib/src/web_message/web_message_port.dart create mode 100644 flutter_inappwebview_android/lib/src/web_storage/main.dart create mode 100644 flutter_inappwebview_android/lib/src/web_storage/web_storage.dart create mode 100755 flutter_inappwebview_android/lib/src/web_storage/web_storage_manager.dart create mode 100644 flutter_inappwebview_android/lib/src/webview_asset_loader.dart create mode 100644 flutter_inappwebview_android/lib/src/webview_feature.dart create mode 100644 flutter_inappwebview_android/pubspec.yaml create mode 100644 flutter_inappwebview_android/test/flutter_inappwebview_android_method_channel_test.dart create mode 100644 flutter_inappwebview_android/test/flutter_inappwebview_android_test.dart create mode 100644 flutter_inappwebview_platform_interface/.gitignore create mode 100644 flutter_inappwebview_platform_interface/.metadata create mode 100644 flutter_inappwebview_platform_interface/CHANGELOG.md create mode 100644 flutter_inappwebview_platform_interface/LICENSE create mode 100644 flutter_inappwebview_platform_interface/README.md create mode 100644 flutter_inappwebview_platform_interface/analysis_options.yaml create mode 100644 flutter_inappwebview_platform_interface/lib/flutter_inappwebview_platform_interface.dart rename {lib => flutter_inappwebview_platform_interface/lib}/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/chrome_safari_browser/android/main.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/chrome_safari_browser/apple/main.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/chrome_safari_browser/apple/safari_options.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/chrome_safari_browser/chrome_safari_action_button.dart (89%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/chrome_safari_browser/chrome_safari_action_button.g.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/chrome_safari_browser/chrome_safari_browser_menu_item.dart (88%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.dart (94%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/chrome_safari_browser/chrome_safari_browser_settings.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart (100%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/main.dart create mode 100755 flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart rename {lib => flutter_inappwebview_platform_interface/lib}/src/content_blocker.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/context_menu/context_menu.dart (92%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/context_menu/context_menu.g.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/context_menu/context_menu_item.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/context_menu/context_menu_item.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/context_menu/context_menu_settings.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/context_menu/context_menu_settings.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/context_menu/main.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/debug_logging_settings.dart (100%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/find_interaction/main.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart rename {lib => flutter_inappwebview_platform_interface/lib}/src/in_app_browser/android/in_app_browser_options.dart (94%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/in_app_browser/android/main.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/in_app_browser/apple/in_app_browser_options.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/in_app_browser/apple/main.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/in_app_browser/in_app_browser_menu_item.dart (93%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/in_app_browser/in_app_browser_menu_item.g.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/in_app_browser/in_app_browser_settings.dart (99%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/in_app_browser/in_app_browser_settings.g.dart (100%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/in_app_browser/main.dart create mode 100755 flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart rename {lib => flutter_inappwebview_platform_interface/lib}/src/in_app_localhost_server.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/in_app_webview/android/in_app_webview_options.dart (99%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/in_app_webview/android/main.dart rename {lib => flutter_inappwebview_platform_interface/lib}/src/in_app_webview/apple/in_app_webview_options.dart (91%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/in_app_webview/apple/main.dart rename {lib => flutter_inappwebview_platform_interface/lib}/src/in_app_webview/in_app_webview_keep_alive.dart (64%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/in_app_webview/in_app_webview_settings.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/in_app_webview/in_app_webview_settings.g.dart (96%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/in_app_webview/main.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_widget.dart rename lib/src/in_app_webview/webview.dart => flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart (89%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/main.dart rename {lib => flutter_inappwebview_platform_interface/lib}/src/mime_type_resolver.dart (100%) create mode 100755 flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart create mode 100755 flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart rename lib/src/android/process_global_config.dart => flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.dart (61%) rename lib/src/android/process_global_config.g.dart => flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.g.dart (88%) rename lib/src/android/proxy_controller.dart => flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.dart (68%) rename lib/src/android/proxy_controller.g.dart => flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart (97%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.dart rename lib/src/android/tracing_controller.dart => flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.dart (63%) rename lib/src/android/tracing_controller.g.dart => flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart (94%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.dart rename lib/src/android/webview_feature.dart => flutter_inappwebview_platform_interface/lib/src/platform_webview_feature.dart (55%) rename lib/src/android/webview_feature.g.dart => flutter_inappwebview_platform_interface/lib/src/platform_webview_feature.g.dart (87%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/print_job/main.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart rename {lib => flutter_inappwebview_platform_interface/lib}/src/print_job/print_job_settings.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/print_job/print_job_settings.g.dart (99%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/main.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.dart rename {lib => flutter_inappwebview_platform_interface/lib}/src/pull_to_refresh/pull_to_refresh_settings.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/pull_to_refresh/pull_to_refresh_settings.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/action_mode_menu_item.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/action_mode_menu_item.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/activity_button.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/activity_button.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ajax_request.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ajax_request.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ajax_request_action.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ajax_request_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ajax_request_event.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ajax_request_event.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ajax_request_event_type.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ajax_request_event_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ajax_request_headers.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ajax_request_headers.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ajax_request_ready_state.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ajax_request_ready_state.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/android_resource.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/android_resource.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/attributed_string.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/attributed_string.g.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/attributed_string_text_effect_style.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/attributed_string_text_effect_style.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/cache_mode.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/cache_mode.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/call_async_javascript_result.dart (73%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/call_async_javascript_result.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/client_cert_challenge.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/client_cert_challenge.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/client_cert_response.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/client_cert_response.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/client_cert_response_action.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/client_cert_response_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/compress_format.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/compress_format.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/console_message.dart (94%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/console_message.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/console_message_level.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/console_message_level.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/content_blocker_action_type.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/content_blocker_action_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/content_blocker_trigger_load_context.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/content_blocker_trigger_load_context.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/content_blocker_trigger_load_type.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/content_blocker_trigger_load_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/content_blocker_trigger_resource_type.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/content_blocker_trigger_resource_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/content_world.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/cookie.dart (94%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/cookie.g.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/create_window_action.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/create_window_action.g.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/cross_origin.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/cross_origin.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/css_link_html_tag_attributes.dart (93%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/css_link_html_tag_attributes.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/custom_scheme_response.dart (94%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/custom_scheme_response.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/custom_tabs_navigation_event_type.dart (90%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/custom_tabs_navigation_event_type.g.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/custom_tabs_post_message_result_type.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/custom_tabs_post_message_result_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/custom_tabs_relation_type.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/custom_tabs_relation_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/custom_tabs_share_state.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/custom_tabs_share_state.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/data_detector_types.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/data_detector_types.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/dismiss_button_style.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/dismiss_button_style.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/disposable.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/download_start_request.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/download_start_request.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/favicon.dart (83%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/favicon.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/fetch_request.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/fetch_request.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/fetch_request_action.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/fetch_request_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/fetch_request_credential.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/fetch_request_credential.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/fetch_request_credential_default.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/fetch_request_credential_default.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/fetch_request_federated_credential.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/fetch_request_federated_credential.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/fetch_request_password_credential.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/fetch_request_password_credential.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/find_session.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/find_session.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/force_dark.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/force_dark.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/force_dark_strategy.dart (74%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/force_dark_strategy.g.dart (87%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/form_resubmission_action.dart (93%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/form_resubmission_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/frame_info.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/frame_info.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/geolocation_permission_show_prompt_response.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/geolocation_permission_show_prompt_response.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/http_auth_response.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/http_auth_response.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/http_auth_response_action.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/http_auth_response_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/http_authentication_challenge.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/http_authentication_challenge.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/http_cookie_same_site_policy.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/http_cookie_same_site_policy.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/in_app_webview_hit_test_result.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/in_app_webview_hit_test_result.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/in_app_webview_hit_test_result_type.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/in_app_webview_hit_test_result_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/in_app_webview_initial_data.dart (91%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/in_app_webview_initial_data.g.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/in_app_webview_rect.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/in_app_webview_rect.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/javascript_handler_callback.dart (83%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_alert_request.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_alert_request.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_alert_response.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_alert_response.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_alert_response_action.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_alert_response_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_before_unload_request.dart (92%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_before_unload_request.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_before_unload_response.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_before_unload_response.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_before_unload_response_action.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_before_unload_response_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_confirm_request.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_confirm_request.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_confirm_response.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_confirm_response.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_confirm_response_action.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_confirm_response_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_prompt_request.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_prompt_request.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_prompt_response.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_prompt_response.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_prompt_response_action.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/js_prompt_response_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/layout_algorithm.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/layout_algorithm.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/layout_in_display_cutout_mode.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/layout_in_display_cutout_mode.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/loaded_resource.dart (88%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/loaded_resource.g.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/login_request.dart (94%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/login_request.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/main.dart (99%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/media_capture_state.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/media_capture_state.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/media_playback_state.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/media_playback_state.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/meta_tag.dart (80%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/meta_tag.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/meta_tag_attribute.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/meta_tag_attribute.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/mixed_content_mode.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/mixed_content_mode.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/modal_presentation_style.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/modal_presentation_style.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/modal_transition_style.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/modal_transition_style.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/navigation_action.dart (99%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/navigation_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/navigation_action_policy.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/navigation_action_policy.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/navigation_response.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/navigation_response.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/navigation_response_action.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/navigation_response_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/navigation_type.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/navigation_type.g.dart (100%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/types/on_post_message_callback.dart rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/over_scroll_mode.dart (86%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/over_scroll_mode.g.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/pdf_configuration.dart (91%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/pdf_configuration.g.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/permission_request.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/permission_request.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/permission_resource_type.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/permission_resource_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/permission_response.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/permission_response.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/permission_response_action.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/permission_response_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/prewarming_token.dart (60%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/prewarming_token.g.dart (89%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_attributes.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_attributes.g.dart (99%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_color_mode.dart (90%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_color_mode.g.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_disposition.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_disposition.g.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_duplex_mode.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_duplex_mode.g.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_info.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_info.g.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_media_size.dart (99%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_media_size.g.dart (99%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_orientation.dart (91%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_orientation.g.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_output_type.dart (94%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_output_type.g.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_page_order.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_page_order.g.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_pagination_mode.dart (92%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_pagination_mode.g.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_rendering_quality.dart (93%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_rendering_quality.g.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_resolution.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_resolution.g.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_state.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/print_job_state.g.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/printer.dart (90%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/printer.g.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/proxy_rule.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/proxy_rule.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/proxy_scheme_filter.dart (83%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/proxy_scheme_filter.g.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/pull_to_refresh_size.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/pull_to_refresh_size.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/referrer_policy.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/referrer_policy.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/render_process_gone_detail.dart (90%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/render_process_gone_detail.g.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/renderer_priority.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/renderer_priority.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/renderer_priority_policy.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/renderer_priority_policy.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/request_focus_node_href_result.dart (71%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/request_focus_node_href_result.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/request_image_ref_result.dart (64%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/request_image_ref_result.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/safe_browsing_response.dart (78%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/safe_browsing_response.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/safe_browsing_response_action.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/safe_browsing_response_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/safe_browsing_threat.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/safe_browsing_threat.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/sandbox.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/sandbox.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/screenshot_configuration.dart (89%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/screenshot_configuration.g.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/script_html_tag_attributes.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/script_html_tag_attributes.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/scrollbar_style.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/scrollbar_style.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/scrollview_content_inset_adjustment_behavior.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/scrollview_content_inset_adjustment_behavior.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/scrollview_deceleration_rate.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/scrollview_deceleration_rate.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/search_result_display_style.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/search_result_display_style.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/security_origin.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/security_origin.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/selection_granularity.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/selection_granularity.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/server_trust_auth_response.dart (93%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/server_trust_auth_response.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/server_trust_auth_response_action.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/server_trust_auth_response_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/server_trust_challenge.dart (93%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/server_trust_challenge.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/should_allow_deprecated_tls_action.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/should_allow_deprecated_tls_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ssl_certificate.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ssl_certificate.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ssl_certificate_dname.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ssl_certificate_dname.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ssl_error.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ssl_error.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ssl_error_type.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ssl_error_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/tracing_category.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/tracing_category.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/tracing_mode.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/tracing_mode.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/trusted_web_activity_default_display_mode.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/trusted_web_activity_default_display_mode.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/trusted_web_activity_display_mode.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/trusted_web_activity_display_mode.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/trusted_web_activity_immersive_display_mode.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/trusted_web_activity_immersive_display_mode.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/trusted_web_activity_screen_orientation.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/trusted_web_activity_screen_orientation.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ui_event_attribution.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ui_event_attribution.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ui_image.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/ui_image.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/underline_style.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/underline_style.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_authentication_challenge.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_authentication_challenge.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_credential.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_credential.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_credential_persistence.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_credential_persistence.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_protection_space.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_protection_space.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_protection_space_authentication_method.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_protection_space_authentication_method.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_protection_space_http_auth_credentials.dart (82%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_protection_space_http_auth_credentials.g.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_protection_space_proxy_type.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_protection_space_proxy_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_request.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_request.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_request_attribution.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_request_attribution.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_request_cache_policy.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_request_cache_policy.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_request_network_service_type.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_request_network_service_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_response.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/url_response.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/user_preferred_content_mode.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/user_preferred_content_mode.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/user_script.dart (90%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/user_script.g.dart (96%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/user_script_injection_time.dart (91%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/user_script_injection_time.g.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/vertical_scrollbar_position.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/vertical_scrollbar_position.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_archive_format.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_archive_format.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_authentication_session_error.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_authentication_session_error.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_history.dart (88%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_history.g.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_history_item.dart (91%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_history_item.g.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_message_callback.dart (71%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_resource_error.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_resource_error.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_resource_error_type.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_resource_error_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_resource_request.dart (93%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_resource_request.g.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_resource_response.dart (93%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_resource_response.g.dart (97%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_storage_origin.dart (84%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_storage_origin.g.dart (98%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_storage_type.dart (90%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/web_storage_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/website_data_record.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/website_data_record.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/website_data_type.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/website_data_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/webview_package_info.dart (82%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/webview_package_info.g.dart (95%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/webview_render_process_action.dart (94%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/webview_render_process_action.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/window_features.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/window_features.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/window_style_mask.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/window_style_mask.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/window_titlebar_separator_style.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/window_titlebar_separator_style.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/window_type.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/types/window_type.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/util.dart (100%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/web_authentication_session/main.dart create mode 100755 flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.dart rename {lib => flutter_inappwebview_platform_interface/lib}/src/web_authentication_session/web_authenticate_session_settings.dart (82%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/web_authentication_session/web_authenticate_session_settings.g.dart (91%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/web_message/main.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_channel.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_listener.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_port.dart rename {lib => flutter_inappwebview_platform_interface/lib}/src/web_message/web_message.dart (92%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/web_message/web_message.g.dart (97%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/web_storage/main.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage.dart create mode 100755 flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage_manager.dart rename {lib => flutter_inappwebview_platform_interface/lib}/src/web_storage/web_storage_item.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/web_storage/web_storage_item.g.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/web_uri.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/x509_certificate/asn1_decoder.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/x509_certificate/asn1_der_encoder.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/x509_certificate/asn1_distinguished_names.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/x509_certificate/asn1_identifier.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/x509_certificate/asn1_object.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/x509_certificate/key_usage.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/x509_certificate/main.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/x509_certificate/oid.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/x509_certificate/x509_certificate.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/x509_certificate/x509_extension.dart (100%) rename {lib => flutter_inappwebview_platform_interface/lib}/src/x509_certificate/x509_public_key.dart (100%) create mode 100644 flutter_inappwebview_platform_interface/pubspec.yaml create mode 100644 flutter_inappwebview_platform_interface/test/flutter_inappwebview_platform_interface_test.dart delete mode 100644 lib/src/android/main.dart delete mode 100644 lib/src/android/webview_asset_loader.dart delete mode 100644 lib/src/apple/main.dart create mode 100644 lib/src/process_global_config.dart create mode 100644 lib/src/proxy_controller.dart rename lib/src/{android => }/service_worker_controller.dart (56%) create mode 100644 lib/src/tracing_controller.dart delete mode 100644 lib/src/types/on_post_message_callback.dart delete mode 100644 lib/src/web_storage/_static_channel.dart rename lib/src/{android/webview_asset_loader.g.dart => webview_asset_loader.dart} (51%) create mode 100644 lib/src/webview_feature.dart diff --git a/android/.idea/.name b/android/.idea/.name deleted file mode 100755 index 198f3c84..00000000 --- a/android/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -flutter_inappbrowser \ No newline at end of file diff --git a/android/.idea/caches/build_file_checksums.ser b/android/.idea/caches/build_file_checksums.ser deleted file mode 100755 index 118c2ce5fe55d70396f8b860dd613222a5ecb7c3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 488 zcmZ4UmVvdnh`~NNKUXg?FQq6yGexf?KR>5fFEb@IQ7^qHF(oHeub?PDD>b=9F91S2 zm1gFoxMk*~I%lLNXBU^|7Q2L-Ts|(GuF1r}nf0c10Sz%rqwkqh4j`PRhEYuK1HVRi|F zihgKuYEiL%QEG)gRIffFUPi@R zl0X3lvlg!KscW)a`25+Ct5)`H=dd;UQo*K~LF-Vc#HvcL;Thf}8Y6diRO zH^2=A1w}`38JBUyeV@f~8I{j*#|0f%)KTYS+{W*J?ya?}s_WH4$nWF#qtdUId(S=h zZ1>!A&V9%I!iqs(m{Yp#oYYbK-KLr|y4}_w*Hkqrx6qf=mX_=FyZbc7$PJb{O0Khz zQzT_?6aQ|&znZ#(Ki$?}2)WzP#>!}4{^}!=?Js$s07{W<lLE_-}ejSiM^~t-W;R06os*|CV-@)Nf+8=Rq)A zh2z^x=Eo+f7(#6;y3U&vmj|uo@prr1$#aU!vo7;&bYBl%eyFCq*)XZy(psJ44;xC#=FmYymjQ);kFYWAhjg8Iz4$0VS2*+}$n%(^7 zW=q2hC%2d8wHA8RRC6LMG+}_pwwGKt8Fd`T=E%J3hTf!}V?f*uq7@6`oC$Hx3vrH9 z$_T`qN`whU&C~6rIn_ipAla!&sw8uMXLlEShOqL|owFOaZlWKI@ae&k0AV%b;bu2S z!<=6CrcK8l^TWS@<+lpcJs`sVzLvj|7&7127V{gs%CN0L?&KGS8l+AT>soYpa8k&V ztYAYmX_Mq&j?<6~yN9XSCH289=Bt2Wqozy4ma(DR(VGi~P#iM?4# zK_@#}!-ZzYl#RfWSD4K~6fH1BLs)wz!GZ?&cWMJBQFrt;y}4-4FYeDb7dnvoe15I> zLH#8C=LUnJJy)b7I+(g{>wususoA=sv#mKG?ZT9`<(Xdnw{2#{E-fwOL3n;i@^gWUru91Z%`20ckZLxxcD%yTHC zuO-oLeuSAms?#Nc2a@?juxVN=us@hFWST_1>-&P}9=h3qDZ*W&b$4K*QaAxdRbM!k z$z!rMa+^BCw)-KZ_>mju=4UV2x@jXBZB^=Oq1%ONU`bPj3!vOwyFD~W2aqARc3y+w z(1HP{ZtnK&CMSi7YlS1B(wHa*>0awn#8=3qTw&=9VI1-YIR=#Z;KnaL>GtCXk8Vu@ zXtD}n!Cmaq5T@kKo0dj?pzhE2T9Too|AD0%))nj4&)hyRCC%dLhH#Oqoj95%&#=w( z4YXXbo-5=^tj*kzS{4E2WDG@Q%VJw%nsWi2JMGamATpQzG%AZ-!erDAv%3I|!QNqp z7Pqe;Ee_yAjuWse2?SG2@CPxhJ@1DXa^ii--5&^v@n$VDp^ikFtBN~4cwNbXtdxlrx8mFfW8e%8)#WHK_|*QeyiYBU%*{Z+n_RN zi>suTDg60j&{Rkyv0Q-iS^l?s-f z0UM?~B!JV+&5lXd0~D)b1He==qxJNzdE;?H_-MiI?8Q zCth{ut$eW!^FJUHu+xNuANZe0v?#Q&meVyiE)LXW5M`CI0;C5w=N@66ZM-byvGws2&z$~uJEw(vr!ewZRBb#u; zxZ{dU0qVO(8^9acl4@TY-`iE$4$YEI&U^-pFk1>5aGB@yc=_y$kGRVaj@~ouG!0Y# zkQ~~6;+CU+A2!8X(%^w~+%hHK){Odz7I|~o^b{rQ4pBE5%}=Cs+m;#Dd}8gIY?=<2 zXRB;F45RYPvH>ANf@MS!QKBoARJKtCf39g!IT9p5W@SVdK4G=}&fos15jI_$(@Ymz zZA6=5sYt@?BU%`3NQ8P=C3CDiv|qy+jMCOVjXz)lZawIwYNBGB1&W zDHSuh@a40;uFhg2!UPiO;r|FD=u`%)HKYg`lnDhy$)8lqFMA-%vcWPT1Gn5Ugrg)L z<%a!U?1Wsj%q>Sxz(l}a&FCKN_zhIPrRIc_8N#E-gaUZ_#^$VV$Hx#JGv;&eCXTr? zG{m-B1$2M+HK5*KrKNv>Qsq7SU8g{|hdywr(PfyXJIu*^i`-&3R zhpeN_<|$Har?M4BaOV@ev+Exfr+TAWw+yMm3+V^P_NWOHsC z!UbcjK_^}vmL!X7<2x=q3~h+43RiqJdh|s8j<-`iucCE?B=b0N2R4jk;^i#vd>5!Y zXxwMwBRrZzAbg*N^)rBW4m$`EH}SA`%qz3~1)dB*@A4S8t5{6Z#=dlr0{swQKQ20b zvj7E1T>{s&|r_}L%Zj#vyZg`-XemNkuVe*V(5-drq!tCsE~tY{~F09%M^~b@HHEGRx{A{aie_mW(xsY%LkqYM3Ph`ki=n811IA zV_3HjrX9mOhzQzBWye@O@G#P`K@X|y7}k&5jv=YSG!cbAFE<-*i!ay8k=dgTFld@h z9i^)x(S`bgMMEizY@8dAy#lQ+H<2dCWHo=tZ3X{BF38XO(j7M;Z2QVxo7dG1VM@%^ zh_Jo}=$D(`<4W9efxVl|lnr||Wj~o69KgYdB1IfA<@L3YsOE|zhUS?^4nQA+u+vFt zsFS8ree+-c?kLjlHL@2Ybk8NtaRKfEYw;30fF0>A$If-2Bbvy&W_hd5Bd>BXlfF*) z!5wdU;D#5}p$nq!%=%aXA zyFkB*H^Z_C!VoqB@Wz9mUvuf@l{X+WcMg&7tedUEiuNv~^*Y^68Nvk1PMY{Bu?GGs zki=$xv1dK93MYQRZhjYUOwgY{8cpV)WV_|Ajy#J6lOK^;uyTa;AVx0NmXKZ}F%<%I zdBgW%kQ95c+qY7Y!RA+qX0Psa7tXEEc;rccME?^85)^6nwOan;l_bC^DgJ? ziU-!PUGsx_5Nk%}=SYw3o8_@!hMxKSLmQv> z%2$2h?(!5RT_0Qx4RyR(f<{<0gwvpX8C@}5YKm*3cZNi$)0er_Y5c_MJk=@bw>7ni zGBATY4ME|`*wqyocbrs_>*=~rlXrE~*h~K^d4;NHSc|;nGogEeToN2M%!&~v1S?Tb zqw)w+gKndM0jm30@)|N}^gWnBm}yFY=P&We`@(Z?JB$787!Rv3naf=aIRGu0#urS3 zQNNp?2g#;}9Ni-I?S&9%gYx|?i)ftO;v=&<46ydlG|TO_>&JL$8jnp(5Xr+H;iw@d zU{)Sdm%*CEmQ;OWLl?#$>NkNt456_s_5@t` z(S>_VXtVW&i6bEG(tdZ?vtJ@CV%6v@%yGk9<*-jUeO)EI;k5<~KKIaofRlm{fb}>= zi!uj%=xZ+c{8?ye;zt&%zsAMtW{I6V6&M5KwmJ2$E9P~|TVGeqiNv)&9OFe7j`O^u zysB4Zsa{j%Vyz;odB(FnNPB%eqy=;XL|S0y-CgCVbtSXYON>a5USH*HeFIQAuDb^e1 zLZK!rMWrUW8d&FUU<7j?`oll}$%8qm)9D&)-)6@3)7`=-=6?RBwV)q_W?3J4Fz4K6 zn4`<%UjDkNb|(088pqUI-H+g_QfV~wqM}wB)rzDPDw0^P*LA5VRg{9Fsx_tDXrRoM ztATO&`t!$r{8t#?1wnK^!)1zFh|q9N0(;i|&j8)5|#=J5p!bM)C)8ab4ow<+eQ~dqBrpE8sE3(m{;f>v*H~HIJD>Q90gt zUMv*Vnyi&;#j>c@>Y}DMD!N#yL$r!zxzH$=3YC&rDzJ}0;WVBR9Q1DQ{V&FGZnwXX z+bgvdL;)Bx)(>dUz6Ly$MyL9imA}3h%Et2^T3PLG#Y6-=zooUmxZ^qx7GhGmyV<;_ zQ(&S5@hBB5s!}S7jdHP}7qp66s1^!UQLl-TB9|MoUJwgX!TTxjQ5r$U9XFgqj9#{7 zGaP@KvZS=M8T%Jm6sU?gQyimLj@Wu5yl}^leuJh@@HcJZX|=n-i=XzniU(nL#UmSk zFZoem^6vifTA^0ZbqW8JE5%Ytl$A=gUWTmD6|Gt?i7M!*R<9_&W?%p~`gH`Iw|(Hz zt1)IrLrZ;SFVr+>iZ08+PA_2ZTxW^jFNj5Hfh3Ev}?q4+bN`CuW>q zV=9NcQlCqcJsBwzm!?D2E#oK*A&P{n>{S9nliLcSymp zWqkX)3a>T@!TR(=3POaGUpl0~gv$B&$|eo}_JSn+E!Cgi1mXNxThi-&iG?!F*gxDN zZ2gGY{5~F)*(bjv~=$tN@#51 z{x2VR??)_VjxSHsl4-aFAAd2C0+vwGK4x1Wd&Uiv?6)5HNdxkDy)BOqu!JPlOh}sX z{s~jR*`}jy;3s!Hp`+sdDJR{~HiT0{K1FY*hVfG2-p?#C9{+z^{^LwfcLyLzQ6 z)#{S2R}0vuEofRr)GE5%P)oWjm&8C{&PT$*8LJY!K;^xE+KBbKcw||vVFRmFQn0;I z(zRl#Qm#ty^JB9IKctFQs_12@6xNz=#2%SBW@93R`a*#Ab(4=o>{u-l-wMnOu)`Zc zejW4DaB6(e=WsTpQi1I#mTBv?{-a`pg z&_d+P|MLwI3Z!N$ke0R}DN8f_pLGMCY00*7*A1IvwbZxIe8xsYI3@T?^l{usAC7YR z;YCmWjYU!Mm+-+I28hsNL#*rAR)ZoEu_xImNaae6c7JKBvR(>WuDmyVzQ*b%4pTlD zG_Oih>lIlq7O+=}0ED8Z6l-$1)MykHtt_jWQc-lJTq|S$Ik++3I6VUQZ^Pjak!H*6 zC0~!i=2(Rk-*U|guEQEVes%Pchi(ERwNZROXjYTxD5D>ocf}7a(Gg$bX9iD%E_(h$ zH;bXFXiO~8gDn~Y7fwHT+^6q?mOu<4JGFK($0sLP6XCGf!B}M^e)z?E4B_;^38s(P zCiuTQDrozScRk6XqvvKbThxtDI_DwNMIGTWh_uq>D&jtBVzp3JG__dLtD0U5(n22y z2Pm-?BIvw|sH|3tCG6IeDu{lRDzuYkWI7_5tWQQdL zDMCBF@FAVfPz9BdI!}nRKpl1BJ@?VJjk8+vF0V(Ndt(*UJMTT|S|s*+8(>=L{f<^@ z{_I}eBBA&WR&U#W!Gz#er6kr1O1)9373xw|Rtv}s5R1h|xlvMax|l!k>TTh)GFBCN zVHt6+dG%03kt@}*T&n2}ghCedq6pnnFG!N2Hp+5Ek|;hIVOk@N_{QgvtIr9CJ49r8 zA@;SNkHp?sjT1k9E-gHVB|7}NCAEjd?MTm2d|~87MJkl|fk9~}%UR&apS=4$mI#Qy z|CJh!2-T6=AsK(RLiI&_BQ7;|0+qzeuRH1=pd_3qE~;VDlW-dMjPuJq?$Pa@A1!|M ziHPE|Uq)k2ZNc<=+yFtH*gUnSGxmv3iw3YK1}pLGyZDMBW;7L_w}-)kdLSk}Bmw8EFRP8d5l%?|lRE zh`{*X3mY(B!}&-|ja3HmqqtIla=0PEuL9!R?p^W>v{Zv7F$`6An8rC3Sm-9D=3bcY5~mCUqs z`;J?vjY|IB#}6PK18IRHAEA>o!aH#^!JGc^rZX&>iJyPq>();@<+4^2%ZTSCAuQL_ zLaB%d--?7y45^`Ol^~7q58Dx93(=G;KjReC_yh&>sq6rREjmItC}ondP$bb zHMvmJWVInyk?*V*{q6V$>JgIhO;R7Az7Fz{m>jDyjBuQWEN3zR>2O7gUxUQomd*e@ z(V8Uw5o1@mB^~0ghqC}BVl@#zFewY5LN!eMtKL<{y)$aGv>dAqvI$GszfA__KMK|#S?A)FC#h|9j8eC2alt^6` zkt0&C!Ny0rwTk3eNef(JyeVAxja4XaNb;UP+&IfCm6}{cQGjv*#YSp~6hkIrrJ_oD ztpJBq6`6`f#EumtPZPe8d4y$ri`EUEukCy!*2XH2_<^hGpg9at;a3^)H~rEfC0bj= zU&^P1$W|1`-1Nb!#qjZ$$tj_T&=K*yJSpJ`RS)qOWoaP^(hN`e(j~w0tU(5-6O3w4 zJ*lIaYY_h(x4au&gM91f@*1o`d>?t%Aik%Lw%E4qn!H6k@z)@}hW)~?S}s;}y`-rU zmVPA$+2oA{u(3$kPcU*_!Ub0HAn{NiPkFd*C1Jd zWviCIe0KYvEa?z`4Uz>Y5&9+m8YBy#LX}MXHAp7l1ZkQ-JnzycLJ2qpd6Xf_V7JMu zHsku~7Kfv{W!IS}A#d?0=WVp-Dw$`u=V+7tKl>Ix>KwVO@db|4kze?s%8pd3pzKo- zbw1=WQa{Sr4wq`>dbuFhYV{yBlDJBrJ+iz5lGk}vgmVfCqgX8|N~2OhNtB9Is;RnG zM;R`?T11U9q%k(&yt3Q!jmaY%<8RH4X*nN>t+A@29ll}H5?^bMU`x`<(XO8K|(F|MO_?W*~q!WKp=mm)F|rJa!FQD=1wZex>`^hK^o%y;gW8wZ^{o(KH!!cqj_kAYDp`h zQXxtfmJ3C(P-vi>qgX-cZUeE!wNkNGfUX%A~Sxpx*t?u57F2ht3l$2;A8>Q zVT%^OMu{K9nFWHP*BkM7i!*`C)-cDcdDOfmCgS_}GJz#R(-w@txI~ zU@0(`>WNpbUk8maYik5)u+%{bf7)AbcJvlf=le53_uP_lbQPl9ezHjG4u4bV>a1~H zIojv8r6V3|kyU&bX+YQh8AL^1P14Fr1ChBX(kmAW3W{|%YGu7z6%p?gq<%h_Q2hh| zgywyy9$B);)kaCHR&m}41S1Uyog-0Dgyl#lt(IDK>QsTZD!I{y4kwBbsGXKgrI zBA~&Op8@LxG2lb2^9&4A#eWU z#!4PhV+~D(tF4NS8x=9TRc!iKYp8dPy1$}Qt{2NSsnn3okA36t2*UUboftb~l|nNd zPa&SIq;MQo!}p8+_(o7tL_|yb`0mEUu-F2=c+tCGWU+4i(A32JN67T}HcMhiLdAG| zw|#OLf+Y9CZ&}jbdA4D1pCK?dLGM#{KIL0Ds)JsJ%s$5RwIi`V{Gl6XtZ9#5(3zbL z;1-fBVX1(WaJd3sP8BDulyyl|sx`GJ>)4*Clbi&5h{6BG6xA)Vt(#)NQ$ z%I5gxV3R@+B$=;2`#Nt_D?8?~*M(cB+n@3L;TDpk{+tW`>xYoktKIKIVmnc-?gx(K ze%4vv`iw;o@ztceO~0&?N)X+$T2u;}UMV4KxsKC?^r|XhD?u)(fki&<43|)2CAb?B zeom%|K(9nESBol&G9nNOhg@JeP%hPQ&Y6y*j~dldS#DI3)lsikJT3SJ=8kv3Mq#}8^v2hCxK3ctXQzobuxlxWjDeo$*lh-?M$OYNuj5tZ>5D=DFfPz3S! zFH^!3su1F@tJ6Xfq!`}$jniHS5ngeO?qPq>?MtfEBZt4@`D>hNIBCP|cP#hO0aTYbLQ7qL8s6nf0h(9WoWEH0m$#USn@>>#W z2M;KS9de=3s~>c&)<6k&t*BLXS%+e%A*-)ets*0%uBbAy`*cMum#|oHx8WO{M=Zv7 z;EiuQABnlKDk8o|EhRXIBQpF-BECC1C0e4jL;}NjELBDmj;$u1JG0|i7Uw4kp>r{q zk2#{jh|m-9^;X)c3RM&d){-fwC~$-LfA0Fwhau3N4PuVJ&?t-mIfjBYXGj!!_5C=SWG)VislPS!NfTsP_R4bRog4PiAdO^ijY!&f7qF91k zzgAcDiXK>O{R0X0NB}^nzvM%;SEt}S4k~R}Kul{N|v2`8~aaO<)r;*f7h zX(YJetXQmEf;P23o^Y`e2ol1I0?_VNELu&`i;a3!7Ezu_!pT*V-l$5|hN`Q`Fqdc_ zTrMMcDYz})pgm$Wet>=;z`joMk(eE;YU1xvX9U*aj2yr6853U-5+km5KUjC^+eA1$m_%<$U-Y@@(I3Ec`Hp*~>l`1&5qK2}B zI8g~vOGRvFlmipFUzSj_Fc9+m>PARjZ>Wt14#UM^Qfj?`Lz@uPTGNWvVxv-2pzjnB zmCKPF!N2tl!Xpghr%WZq%vjB^HylSHA}=8rhtuHwl0Uw9O^AkQNguyXa8gig$$tCW zuKu9KvGF|%NxP4b;d!X`mPfVNdZkc+!>e9W>mVPA!Lial{+6o`ckw|wT#@3} z0`aRkWq_V&jgVmVmH{Ez+TrQdJHKd2h4^XASzstaQ^emQ$O5QPt&zaHlEHKZZk+$> zmg~-h262uuvIp+cAXM84l2mJr)giZ^b>tGZ%k2i%*`JMSk=hI1_XLYx;=3&aI`E4e zSu5f2B2CfD#UeC`q*kknqT^&$BvIht*TCSacV(zY?6G?_2~MU^D&=BHs#BGxx>{|> z4LWFCMg2AkZ@3n^ zk+Fj3Liv>TPS4WeBDIjbga%vBe%wnKN7IR z8$o{E^U{ZK4rils1LH^CW=CMQ4*JzCXW3!EY1V!z2`e9=hte2-X+aCsMQOYnseua8 zN4Hd;`9$cWf~}7b8oW10nT$A}3Ax70ag>Q)zvwyyX1U*InrDyWBYX0rK5xhH#W#T6 zE&D|y&M~Utd<+!(D;E$%TUQhbYY7$E;9{eW+Jr&s<_+OoKGr>EV~1yVo7frAF_n^n zR6?<$AbYTY6T*?NUaDj7T-3x;y^I37i1w8<(bI%)SRT0#My%g&7N%SZ`Dgj$HdXO$A3P+bt;C`${8R{?;A zh4qMqQo8LP0&zEL@^HblKz3;ZW4=2?mIzJbbDV<>pj0)6+Vt)=`!&?MuDA1A+fHF)6H=6OL*xT_z3oZh+rxt8j9AX@k|Z`Aw7c zCrq%1J0xX4!oTbWorfp3mv;2K2LOe-wJG+L${+h7b4JddsY+CCj#vclzy{kq(IM3 zS2H%67Kv;oUOyzV5A~bh0Z34`)WaGA`HbHCylh`(QTNvpU>43CT zPY#g5f@$~q3z65C^{>FgsJD4L05C* zlUM-%^rdv!OqVT&5Pz>LE$j{j<(}T8#o6@bblGkQ@vX#^u=`+JOwgc%@4)qF6_Q z=%S1e$2nuaAtdlXW(0zpMZU7??^Vts3AQn`1xZ<2HyHMM-M+!LSk|FpdTZdPCmBc5 zp%`pk$60l96{pmp`XFU(tHlz6uXH44Fr6@CE{hg(E!Or7|0kdeUsXj+?Bvhr@>9Cp zZwLv3>9ZV2vj-%8R@JUswR~50Q zlug!ntj!u$Q#1AtcaS*Mt)mINgD$tz<<2DH&T2aeynfPu6T$HoLx}J1OaX^U>F*5E z29tLYMDL;tvfJXfQuOMkc)B-Vx9xSy7zLH5(~ ziwKaH8bW*-kOmNwm|qb{%r_E9ucFH>Nq8&`T%4M3PO`*E)2*AFH%b5Zhn$?<9yQaQ znpY%cFT6M*Q3K2m?54S8)<$O5%5sW5V^XH>qstHI@}Gv__DwywF#1S$>c<4b&kW&^ z6~^UMJN4@zs-5};LGv5B{LT>exm=PDDq0x9PW{pl;@59aNGxtzt=|0~FXglv-|LdH z2I8pK#ogTaGPpEFf1=AD>GGE(mZ7^dzZi}z${MiR6adTgR1&XCN?15ePp=B1>FE^& z)zNf0CW%N)2^ypA=_8VOT~hY!rt#is&;4Ce^MaxTdsL~wPb38ir3`T3U>ygG$W_EQ zYjRDJ%c5FU3Js~D`OFKutr_Q+ThyDD^3<6`)o0M<>?G!e-FOm^{WALD1jxBb%!@RD zn1cFIK}0>ZmOy$8T^^UjyhsBVm(~{~;iWX)y2*LPdGEM}lXLvli@A~Mr;KtHXD^GA z+)!{V4HkR_gt8zmx1rYSbPrYan1%6Z+g3JPnz8;3Amqsorf9NF7kIeh?}?`X)FtTaSIu_EAbZ$$vbru@NsL-{3$2k1TM!Q zS4z`Q&j`vAQC7I3BKt+eu^o+qRIb#D5;E0mrE(p|2r_zhB?67{?==IRdtafs`!Zd= zY6uDHoMbi z84PaDc*V`{GB{_%uZG}+1Dm0XzPQ8aTv^T($?~f)o6|SZg%8xtagL!p{ZwK{-&;{ z%X5-g9!~2?p!P}qspk?T&rhCp&oO(Du+MoU>0_$HB zg>=}GEG<~3z~_}RMiv0m|3(0Qi7sDBA}g|^1upbIpC||-GgP@*QYr!Q9w?IE@+^7gsS)!#oh*SqJ+EsKqWAV zIh~rI%L+q?AHn18A;}1Q%rLc*pjnl~2b~%kQyCl=s0_#}KedJ~CmKTh-IvtBafN_w zf%rRssrzm_8}7t5%b-Y6DD z8D(uz&#IzHI1A7u`ipGOrmxKz|D6DD=af!UNfF^w%_NIoUnfb1;-~(71W-H4;x`L` zOa|cL^CL=Nieew9DAa%IU=kwC0zS?IiM-QUbnj+^FZ|>yw{kX!zxd7Oga>XHr9V^% zGdi84%R0J-oiMy+XUUl8$rsYN}k&5NnPi=yF3Xp}t8;wD!K% z+Zw{#@`zc4a5COekbN}yLCo$Xc{(OPl4RB3?b+@s$(Ve+G5Jvf>k~;<4cURk`D5~* zgZN|eQv~3@(&gWhtQxX|lJUqS)_w6qr?UgX%_py_-SlzJC-L)J(jJz_)rPZa;At=7 z)Kbjl^vQHNi7uxlL8zxYKO;mQo*CdPJ)M9#D~VB_78p}KoEt>`(`OS{6#FoZ_=6-~ zoOGu&a>einLx{gHO^X&cssHTQ>%Nq9xuA5hJVr)0R>@(@1ss7<6LBhdRYyrH8Aa7g zIH|UXQ(@~BoCd2^e9Hx2o2afb(o2vgm?~o;r%H6GC0Q=`I`NZ!^iX^{V5&|4U6^FK zkOe^Ia$z=z{HMq;n%Y2@O-YsuS-{7a3oy>&2eV|+y_*g0TR8c3oDJf;4#-2Kg>rzV z${L(P3aGx0;yXABxmJ+nf`ls2qAY1vTwBRDhuqE0c>V}lCU2t|+)9@nN%q~{?fXeS z8g@U)KapVBl|-VZgvF%x-GS6jnX*%VMVF@}2{ua!8Ygrl>c%%GQugeo@i(6P-+$&b z9)C$J4VF3z7xK-H-h$;H5WyRvPeymTN`1SU?f>LZgOifmN|kwxWcbC2>Hj zGeP%)2>(4aneV0x_88;u30@>h01RU+MOnoZJ zk~kX(IX7Uz7C)0X8vxu)aqmZeelcf?_)2JSu-Vi4nvOCId&3MMoKq|nB)!_GmqZCQ z)~e-_tmu*^;dmJwgNahoY=`(_Tm1VQoe8)V#1Xg9yuO+)w;DqH`g#6d{0tF28b3qa zMiAYegxoTL$mEAN2lB%k2)4J-<*p<~S|$K;c1V=PnMwa{Zg}VLinW{@;^$1Za28>Z zR*=iOCKnWJiir*Agp!H?{~D6TMOntt9JW8`kv0eLhGxuvf+(H#JEuNNmoFrttK^XS zsr!or#g~(W94Cgtr0A~&QuI9p&o}6TBY@*4%q0ejQ!zq!<44ga?$b@VZ+iCMCpO?y zR*T~jJa%DF%+WMW)b!Ws^6eznds@JK^w=m)*~>f1k7j3yE{k+| zW)gLp7)(DMUq?VZJBb8L3WQ0(&krQv=MXp)t~QN`vH0n^NnzrY``1a*bdq-IkgVX; zom+*vbB%a)=bUPHR?)f1(Rz8VqI0nd%n^YKYoBrDsX4E$76d^(J%wt+?mX zC50Tl7_S4RU8I?pupTqir}FNOyZeiKeT~@Mhw?sF{XMUb)`Ypt8<96(Wn%tMlr*`{nT#{e4hh=dPE*H@o(E*W&c4O1JX*r~9$mNfs_(t{_Yqq|&S3}hO#k^xZO#cO*Er7$TTunY;b1q_ku>jU>Lqr)N>=J|uA_IYx{D`p@p0eH z^It&Alf1+xkl_ydN`QKnpluf=Wwl<{!PD0DV}qB=We; z1(P-LqY;9cSZ*Ou)G40jXDwI-Jg;EoaT!_}Vy8TXK(`81!xY6k+X$K5B@Om(m)fkX zC+cdVgeCvjL1kYkFLO?>LhWMA>1gjqczT}`j%hDlg^IP1yS#KV{zh-`R#I_Nh6EJv zM1fC!)4GAuqT8fq$AJ#)ycK|1$Tuq#JI^n4jfPq#hTxS$`8&K}PAO0L>bmFs1^>}I z>-l6XpOl?09gH988S_>ebCNLvloh{sjl-T5*S+wuv2IT~Rf^9jx z6W=vwZN*;#-?{Mk##&MeEB;J_y^JobZ0Ya8Tg7EkH34)*j}@$S=67nhfa0*TEbfI$ z*=}qOC;(XihSM9rp^#SiK3roQDvJYSLIzjt+hY9kWZLUyX>nky1p+^ zd23s~G7+Tp&3fg5pPL{HCkO&-=&^<{ec2WBykMydr9eo@-Sn8E=w$X;lE%Tv(=4H`pHua;Y<=zF0Y}>8|ZQuUEV{N57On6bong9jKkEc=;r^S3uVWz_&Qy_ zNtbWa>zu+s)SD4WHL_IUyp7?~}BIM;I1 z&pdX)Kj@V5*cmjIgONuqcn0q-9&aNdK*pV9^}&R*NjDa<+^(nul;Kq;;bP8y6xm11aSo6qg{B800|WiykUCT{M(`Rd=(b2d(41H%*rA@IL1>s|lCU03&d{N-EF)f(Z{ z7s6zm6l?q|Jj2@)x6&sYh?FO8yXUR5k7d7{(_tvaPP$Ol;fXiXq zE~n#>I1JH^P%>;x+*xZ!vT4ktNp`To8^Q(Tb6wy^VM)DauE&v*yG(2KXfOloMLIUi zo-Ed&`!mxib%`{<3XsqWH@>Uomej#XEDKsr#tU{ITP^p#`?GUgpSb~Yzw?-ocXn!2 z86O#w?w8LGd6|&mevdi7Eo$@(a0F#5;mt4PDAh_h(wf;?!kKj}Hu7G-j~yt2__>p3 ztkV4MgMDBL%fqx>cF4-@^gGBt$boR>C|x5W_77`fwl{nU|%)+*Bw*0`VO(y)cb zUH5isEe+ENU#Ih)dCzI%h?yCNOZFxEWsS%f7{UqW(@mWN&3?B-729F-n>V*>8qP^G zgyZRN$LlWj4dEQ`ExxRv(c4Qovu*m!glU#O1URTqtl&I|lgwWXMcd4?gW%vdZ<`-E z59mvb7laKIuwR#uz}Z0cj#+2m59c&G7DVBlP7NGvi&{oz(7Zj;&51TJ=5sb)XS&S0-VuZ0%)ZUX z_L%)otWi5tY<^>nXat~#kG5^SXODa}f1}$0uVKQ8-mRSqk5~ZL*$*~wmSHm=va4YT z3>Tfju&wdc*{orJ;fT$cQ)lzAMF)175{bHX-!@0ZTN!l%8N#tMGpg%EHTIf)V+s39 z%?0c?lGwEF8XGX3)*u0zsvT%5*4_!1laMp~t~opiS5;dy0R)=xhYc1)oViY5&u8t8 zRgOaQnRVb8Ss{1;e3=i-c08Yf)jUf<7xrf%)@gDu>tU~O;loZJGz9QO*n1F&d>b$7 zEsN41TEp71X$W}szGK1*M)%zJ00~O)JY>FBLpW{pwgYg$BMVB!CJ^TH}nk`I$Rhtd$5|Zds;a&vlsRvR@*ZuZQcYYf?r@-8&a!f@{8K|2=C>)i^bWgy27h4ztW;fs!3m!wj%y^%h5aTS%kSET!fW5_Z!O{GODF{~a zzcx3?9m#*&jXr8-hP(?1G1%H17&~aAb70^ESzmkrgS@Tv=}=hjVYSv&tVL5n&$o1% zFhBWH0}=s~5%`*GzCgZ#uh?1!MwjaalXAiK&P@n#lH>gmd4@@K-WdT5lj=NkK?Bk2 z+_ymhNt<`Myd9ln_HfgpvC)*rp63uG?72A&76u^%-M2%=0GaH5Yh)ClANNz&IIQuR zo!TRTS;#i@7|COgi68vyonxj2JAvkV6TA-x7SBVBm`_Gf0P*8};B67}H~QFa z6UwjG*O;_o>jnHVN~-2VEHA8w<{eaT0E1WtGjv;fw;Xv)3D<{OY%VQ)|%2%F-t7i`$aG{O}R zBt%#v^nwWsjIMES+1)|1^|5i-I^eN)@imOm4tx;Y3ckAEM6}B&>9R$-`QA=8TWlUV zHv;LHM+g>!{4Y$Y8UT+Oz4U`MX3+#Qdg-nSmves>4Onxxfi}Ih0jAKVcG^JRfq{b8 z<~jh;jCGsv$g5Ovx0 z)pi`?djL{M9?*v#3^9%DLQ*y6XEv1ULO9CJ`K;u5M2jnJ$WqjcDgvIR;0)tu0 zvn}|AV58VK{E`Ef+5riL;SeY>&n1oj9cUNC+ctF^Tg`lQHavy^d-h--XMt(`MHVD< H - - - - - - - - - - - - - \ No newline at end of file diff --git a/android/.idea/gradle.xml b/android/.idea/gradle.xml deleted file mode 100755 index 2996d531..00000000 --- a/android/.idea/gradle.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/android/.idea/misc.xml b/android/.idea/misc.xml deleted file mode 100755 index af0bbdde..00000000 --- a/android/.idea/misc.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/android/.idea/modules.xml b/android/.idea/modules.xml deleted file mode 100755 index f33b6a32..00000000 --- a/android/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/android/.idea/runConfigurations.xml b/android/.idea/runConfigurations.xml deleted file mode 100755 index 7f68460d..00000000 --- a/android/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/android/.idea/vcs.xml b/android/.idea/vcs.xml deleted file mode 100755 index 6c0b8635..00000000 --- a/android/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/example/integration_test/chrome_safari_browser/custom_tabs.dart b/example/integration_test/chrome_safari_browser/custom_tabs.dart index d62bdd88..104914cb 100644 --- a/example/integration_test/chrome_safari_browser/custom_tabs.dart +++ b/example/integration_test/chrome_safari_browser/custom_tabs.dart @@ -214,12 +214,12 @@ void customTabs() { }); skippableTest('getMaxToolbarItems', () async { - expect(await ChromeSafariBrowser.getMaxToolbarItems(), + expect(await PlatformChromeSafariBrowser.getMaxToolbarItems(), greaterThanOrEqualTo(0)); }); skippableTest('getPackageName', () async { - expect(await ChromeSafariBrowser.getPackageName(), isNotNull); + expect(await PlatformChromeSafariBrowser.getPackageName(), isNotNull); }); }, skip: shouldSkip); } diff --git a/example/integration_test/chrome_safari_browser/sf_safari_view_controller.dart b/example/integration_test/chrome_safari_browser/sf_safari_view_controller.dart index c4579d67..1dd11bfe 100644 --- a/example/integration_test/chrome_safari_browser/sf_safari_view_controller.dart +++ b/example/integration_test/chrome_safari_browser/sf_safari_view_controller.dart @@ -32,10 +32,10 @@ void sfSafariViewController() { skippableTest('create and invalidate Prewarming Token', () async { final prewarmingToken = - await ChromeSafariBrowser.prewarmConnections([TEST_URL_1]); + await PlatformChromeSafariBrowser.prewarmConnections([TEST_URL_1]); expect(prewarmingToken, isNotNull); await expectLater( - ChromeSafariBrowser.invalidatePrewarmingToken(prewarmingToken!), + PlatformChromeSafariBrowser.invalidatePrewarmingToken(prewarmingToken!), completes); }); }, skip: shouldSkip); diff --git a/example/integration_test/process_global_config/apply.dart b/example/integration_test/process_global_config/apply.dart index 285809cd..df32f723 100644 --- a/example/integration_test/process_global_config/apply.dart +++ b/example/integration_test/process_global_config/apply.dart @@ -9,7 +9,7 @@ void apply() { skippableTestWidgets('apply', (WidgetTester tester) async { await expectLater( - ProcessGlobalConfig.instance().apply( + PlatformProcessGlobalConfig.instance().apply( settings: ProcessGlobalConfigSettings( dataDirectorySuffix: (await WebViewFeature.isStartupFeatureSupported( diff --git a/example/integration_test/proxy_controller/clear_and_set_proxy_override.dart b/example/integration_test/proxy_controller/clear_and_set_proxy_override.dart index 349902e6..99601b05 100644 --- a/example/integration_test/proxy_controller/clear_and_set_proxy_override.dart +++ b/example/integration_test/proxy_controller/clear_and_set_proxy_override.dart @@ -17,7 +17,7 @@ void clearAndSetProxyOverride() { await WebViewFeature.isFeatureSupported(WebViewFeature.PROXY_OVERRIDE); if (proxyAvailable) { - ProxyController proxyController = ProxyController.instance(); + PlatformProxyController proxyController = PlatformProxyController.instance(); await proxyController.clearProxyOverride(); await proxyController.setProxyOverride( diff --git a/example/integration_test/service_worker_controller/set_service_worker_client.dart b/example/integration_test/service_worker_controller/set_service_worker_client.dart index 30b8b4e4..1c3baef1 100644 --- a/example/integration_test/service_worker_controller/set_service_worker_client.dart +++ b/example/integration_test/service_worker_controller/set_service_worker_client.dart @@ -17,8 +17,8 @@ void setServiceWorkerClient() { WebViewFeature.SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST); if (swAvailable && swInterceptAvailable) { - ServiceWorkerController serviceWorkerController = - ServiceWorkerController.instance(); + PlatformServiceWorkerController serviceWorkerController = + PlatformServiceWorkerController.instance(); await serviceWorkerController.setServiceWorkerClient(null); } diff --git a/example/integration_test/service_worker_controller/should_intercept_request.dart b/example/integration_test/service_worker_controller/should_intercept_request.dart index 319f6e96..a7ff2df1 100644 --- a/example/integration_test/service_worker_controller/should_intercept_request.dart +++ b/example/integration_test/service_worker_controller/should_intercept_request.dart @@ -16,8 +16,8 @@ void shouldInterceptRequest() { WebViewFeature.SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST); if (swAvailable && swInterceptAvailable) { - ServiceWorkerController serviceWorkerController = - ServiceWorkerController.instance(); + PlatformServiceWorkerController serviceWorkerController = + PlatformServiceWorkerController.instance(); await serviceWorkerController.setServiceWorkerClient(ServiceWorkerClient( shouldInterceptRequest: (request) async { diff --git a/example/integration_test/util.dart b/example/integration_test/util.dart index 031873ad..a6305352 100644 --- a/example/integration_test/util.dart +++ b/example/integration_test/util.dart @@ -111,7 +111,7 @@ class MyInAppBrowser extends InAppBrowser { } } -class MyChromeSafariBrowser extends ChromeSafariBrowser { +class MyChromeSafariBrowser extends PlatformChromeSafariBrowser { final Completer serviceConnected = Completer(); final Completer opened = Completer(); final Completer firstPageLoaded = Completer(); diff --git a/example/integration_test/webview_flutter_test.dart b/example/integration_test/webview_flutter_test.dart index cc7e6d0e..00612ccd 100644 --- a/example/integration_test/webview_flutter_test.dart +++ b/example/integration_test/webview_flutter_test.dart @@ -22,8 +22,8 @@ void main() { WebView.debugLoggingSettings.maxLogMessageLength = 7000; InAppBrowser.debugLoggingSettings.usePrint = true; InAppBrowser.debugLoggingSettings.maxLogMessageLength = 7000; - ChromeSafariBrowser.debugLoggingSettings.usePrint = true; - ChromeSafariBrowser.debugLoggingSettings.maxLogMessageLength = 7000; + PlatformChromeSafariBrowser.debugLoggingSettings.usePrint = true; + PlatformChromeSafariBrowser.debugLoggingSettings.maxLogMessageLength = 7000; WebAuthenticationSession.debugLoggingSettings.usePrint = true; WebAuthenticationSession.debugLoggingSettings.maxLogMessageLength = 7000; PullToRefreshController.debugLoggingSettings.usePrint = true; diff --git a/example/lib/chrome_safari_browser_example.screen.dart b/example/lib/chrome_safari_browser_example.screen.dart index 99995909..dfa8ca7c 100755 --- a/example/lib/chrome_safari_browser_example.screen.dart +++ b/example/lib/chrome_safari_browser_example.screen.dart @@ -4,7 +4,7 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'main.dart'; -class MyChromeSafariBrowser extends ChromeSafariBrowser { +class MyChromeSafariBrowser extends PlatformChromeSafariBrowser { @override void onOpened() { print("ChromeSafari browser opened"); @@ -22,7 +22,7 @@ class MyChromeSafariBrowser extends ChromeSafariBrowser { } class ChromeSafariBrowserExampleScreen extends StatefulWidget { - final ChromeSafariBrowser browser = MyChromeSafariBrowser(); + final PlatformChromeSafariBrowser browser = MyChromeSafariBrowser(); @override _ChromeSafariBrowserExampleScreenState createState() => diff --git a/example/lib/in_app_browser_example.screen.dart b/example/lib/in_app_browser_example.screen.dart index a7b7cb3b..4c9b968d 100755 --- a/example/lib/in_app_browser_example.screen.dart +++ b/example/lib/in_app_browser_example.screen.dart @@ -11,8 +11,13 @@ import 'main.dart'; class MyInAppBrowser extends InAppBrowser { MyInAppBrowser( - {int? windowId, UnmodifiableListView? initialUserScripts}) - : super(windowId: windowId, initialUserScripts: initialUserScripts); + {int? windowId, + UnmodifiableListView? initialUserScripts, + PullToRefreshController? pullToRefreshController}) + : super( + windowId: windowId, + initialUserScripts: initialUserScripts, + pullToRefreshController: pullToRefreshController); @override Future onBrowserCreated() async { @@ -59,21 +64,19 @@ class MyInAppBrowser extends InAppBrowser { } class InAppBrowserExampleScreen extends StatefulWidget { - final MyInAppBrowser browser = new MyInAppBrowser(); - @override _InAppBrowserExampleScreenState createState() => new _InAppBrowserExampleScreenState(); } class _InAppBrowserExampleScreenState extends State { - PullToRefreshController? pullToRefreshController; + late final MyInAppBrowser browser; @override void initState() { super.initState(); - pullToRefreshController = kIsWeb || + PullToRefreshController? pullToRefreshController = kIsWeb || ![TargetPlatform.iOS, TargetPlatform.android] .contains(defaultTargetPlatform) ? null @@ -83,15 +86,16 @@ class _InAppBrowserExampleScreenState extends State { ), onRefresh: () async { if (Platform.isAndroid) { - widget.browser.webViewController?.reload(); + browser.webViewController?.reload(); } else if (Platform.isIOS) { - widget.browser.webViewController?.loadUrl( + browser.webViewController?.loadUrl( urlRequest: URLRequest( - url: await widget.browser.webViewController?.getUrl())); + url: await browser.webViewController?.getUrl())); } }, ); - widget.browser.pullToRefreshController = pullToRefreshController; + + browser = MyInAppBrowser(pullToRefreshController: pullToRefreshController); } @override @@ -108,7 +112,7 @@ class _InAppBrowserExampleScreenState extends State { children: [ ElevatedButton( onPressed: () async { - await widget.browser.openUrlRequest( + await browser.openUrlRequest( urlRequest: URLRequest(url: WebUri("https://flutter.dev")), settings: InAppBrowserClassSettings( diff --git a/example/lib/in_app_webiew_example.screen.dart b/example/lib/in_app_webiew_example.screen.dart index 6eff2d15..aca062db 100755 --- a/example/lib/in_app_webiew_example.screen.dart +++ b/example/lib/in_app_webiew_example.screen.dart @@ -15,7 +15,7 @@ class InAppWebViewExampleScreen extends StatefulWidget { class _InAppWebViewExampleScreenState extends State { final GlobalKey webViewKey = GlobalKey(); - InAppWebViewController? webViewController; + PlatformInAppWebViewController? webViewController; InAppWebViewSettings settings = InAppWebViewSettings( isInspectable: kDebugMode, mediaPlaybackRequiresUserGesture: false, diff --git a/example/lib/web_authentication_session_example.screen.dart b/example/lib/web_authentication_session_example.screen.dart index 761cf80d..1383b33f 100755 --- a/example/lib/web_authentication_session_example.screen.dart +++ b/example/lib/web_authentication_session_example.screen.dart @@ -12,7 +12,7 @@ class WebAuthenticationSessionExampleScreen extends StatefulWidget { class _WebAuthenticationSessionExampleScreenState extends State { - WebAuthenticationSession? session; + PlatformWebAuthenticationSession? session; String? token; @override diff --git a/flutter_inappwebview_android/.gitignore b/flutter_inappwebview_android/.gitignore new file mode 100644 index 00000000..96486fd9 --- /dev/null +++ b/flutter_inappwebview_android/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/flutter_inappwebview_android/.metadata b/flutter_inappwebview_android/.metadata new file mode 100644 index 00000000..3f294f39 --- /dev/null +++ b/flutter_inappwebview_android/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "6c4930c4ac86fb286f30e31d0ec8bffbcbb9953e" + channel: "stable" + +project_type: plugin + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 6c4930c4ac86fb286f30e31d0ec8bffbcbb9953e + base_revision: 6c4930c4ac86fb286f30e31d0ec8bffbcbb9953e + - platform: android + create_revision: 6c4930c4ac86fb286f30e31d0ec8bffbcbb9953e + base_revision: 6c4930c4ac86fb286f30e31d0ec8bffbcbb9953e + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/flutter_inappwebview_android/CHANGELOG.md b/flutter_inappwebview_android/CHANGELOG.md new file mode 100644 index 00000000..41cc7d81 --- /dev/null +++ b/flutter_inappwebview_android/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/flutter_inappwebview_android/LICENSE b/flutter_inappwebview_android/LICENSE new file mode 100644 index 00000000..ba75c69f --- /dev/null +++ b/flutter_inappwebview_android/LICENSE @@ -0,0 +1 @@ +TODO: Add your license here. diff --git a/flutter_inappwebview_android/README.md b/flutter_inappwebview_android/README.md new file mode 100644 index 00000000..e114ca17 --- /dev/null +++ b/flutter_inappwebview_android/README.md @@ -0,0 +1,15 @@ +# flutter_inappwebview_android + +Android implementation of the flutter_inappwebview plugin. + +## Getting Started + +This project is a starting point for a Flutter +[plug-in package](https://flutter.dev/developing-packages/), +a specialized package that includes platform-specific implementation code for +Android and/or iOS. + +For help getting started with Flutter development, view the +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. + diff --git a/flutter_inappwebview_android/analysis_options.yaml b/flutter_inappwebview_android/analysis_options.yaml new file mode 100644 index 00000000..24ec4a21 --- /dev/null +++ b/flutter_inappwebview_android/analysis_options.yaml @@ -0,0 +1,11 @@ +include: package:flutter_lints/flutter.yaml + +linter: + rules: + constant_identifier_names: ignore + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options +analyzer: + errors: + deprecated_member_use_from_same_package: ignore \ No newline at end of file diff --git a/android/.gitignore b/flutter_inappwebview_android/android/.gitignore similarity index 100% rename from android/.gitignore rename to flutter_inappwebview_android/android/.gitignore diff --git a/android/build.gradle b/flutter_inappwebview_android/android/build.gradle similarity index 100% rename from android/build.gradle rename to flutter_inappwebview_android/android/build.gradle diff --git a/android/gradle.properties b/flutter_inappwebview_android/android/gradle.properties similarity index 100% rename from android/gradle.properties rename to flutter_inappwebview_android/android/gradle.properties diff --git a/android/proguard-rules.pro b/flutter_inappwebview_android/android/proguard-rules.pro similarity index 100% rename from android/proguard-rules.pro rename to flutter_inappwebview_android/android/proguard-rules.pro diff --git a/android/settings.gradle b/flutter_inappwebview_android/android/settings.gradle similarity index 100% rename from android/settings.gradle rename to flutter_inappwebview_android/android/settings.gradle diff --git a/android/src/main/AndroidManifest.xml b/flutter_inappwebview_android/android/src/main/AndroidManifest.xml similarity index 100% rename from android/src/main/AndroidManifest.xml rename to flutter_inappwebview_android/android/src/main/AndroidManifest.xml diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ISettings.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ISettings.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ISettings.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ISettings.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebViewFileProvider.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebViewFileProvider.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebViewFileProvider.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebViewFileProvider.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebViewFlutterPlugin.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebViewFlutterPlugin.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebViewFlutterPlugin.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebViewFlutterPlugin.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyCookieManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyCookieManager.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyCookieManager.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyCookieManager.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyWebStorage.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyWebStorage.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyWebStorage.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyWebStorage.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/PlatformUtil.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/PlatformUtil.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/PlatformUtil.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/PlatformUtil.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/Util.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/Util.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/Util.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/Util.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/WebViewFeatureManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/WebViewFeatureManager.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/WebViewFeatureManager.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/WebViewFeatureManager.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ActionBroadcastReceiver.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ActionBroadcastReceiver.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ActionBroadcastReceiver.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ActionBroadcastReceiver.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsActivity.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsActivity.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsActivity.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsActivity.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsActivitySingleInstance.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsActivitySingleInstance.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsActivitySingleInstance.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsActivitySingleInstance.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsChannelDelegate.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsChannelDelegate.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsChannelDelegate.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsSettings.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsSettings.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsSettings.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsSettings.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeSafariBrowserManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeSafariBrowserManager.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeSafariBrowserManager.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeSafariBrowserManager.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/CustomTabActivityHelper.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/CustomTabActivityHelper.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/CustomTabActivityHelper.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/CustomTabActivityHelper.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/CustomTabsHelper.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/CustomTabsHelper.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/CustomTabsHelper.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/CustomTabsHelper.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/KeepAliveService.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/KeepAliveService.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/KeepAliveService.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/KeepAliveService.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ServiceConnection.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ServiceConnection.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ServiceConnection.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ServiceConnection.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ServiceConnectionCallback.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ServiceConnectionCallback.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ServiceConnectionCallback.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ServiceConnectionCallback.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/TrustedWebActivity.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/TrustedWebActivity.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/TrustedWebActivity.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/TrustedWebActivity.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/TrustedWebActivitySingleInstance.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/TrustedWebActivitySingleInstance.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/TrustedWebActivitySingleInstance.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/TrustedWebActivitySingleInstance.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlocker.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlocker.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlocker.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlocker.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerAction.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerAction.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerAction.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerAction.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerActionType.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerActionType.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerActionType.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerActionType.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerHandler.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerHandler.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerHandler.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerHandler.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerTrigger.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerTrigger.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerTrigger.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerTrigger.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerTriggerResourceType.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerTriggerResourceType.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerTriggerResourceType.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/content_blocker/ContentBlockerTriggerResourceType.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabase.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabase.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabase.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabase.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabaseHandler.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabaseHandler.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabaseHandler.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabaseHandler.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabaseHelper.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabaseHelper.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabaseHelper.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/CredentialDatabaseHelper.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLCredentialContract.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLCredentialContract.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLCredentialContract.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLCredentialContract.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLCredentialDao.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLCredentialDao.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLCredentialDao.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLCredentialDao.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLProtectionSpaceContract.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLProtectionSpaceContract.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLProtectionSpaceContract.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLProtectionSpaceContract.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLProtectionSpaceDao.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLProtectionSpaceDao.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLProtectionSpaceDao.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/credential_database/URLProtectionSpaceDao.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionChannelDelegate.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionChannelDelegate.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionChannelDelegate.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionController.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionController.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionController.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionController.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionSettings.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionSettings.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionSettings.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/find_interaction/FindInteractionSettings.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessInAppWebView.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessInAppWebView.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessInAppWebView.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessInAppWebView.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessInAppWebViewManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessInAppWebViewManager.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessInAppWebViewManager.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessInAppWebViewManager.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessWebViewChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessWebViewChannelDelegate.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessWebViewChannelDelegate.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/headless_in_app_webview/HeadlessWebViewChannelDelegate.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/ActivityResultListener.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/ActivityResultListener.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/ActivityResultListener.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/ActivityResultListener.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserActivity.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserActivity.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserActivity.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserActivity.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserChannelDelegate.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserChannelDelegate.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserChannelDelegate.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserDelegate.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserDelegate.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserDelegate.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserManager.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserManager.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserManager.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserSettings.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserSettings.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserSettings.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserSettings.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/ConsoleLogJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/ConsoleLogJS.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/ConsoleLogJS.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/ConsoleLogJS.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/InterceptAjaxRequestJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/InterceptAjaxRequestJS.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/InterceptAjaxRequestJS.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/InterceptAjaxRequestJS.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/InterceptFetchRequestJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/InterceptFetchRequestJS.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/InterceptFetchRequestJS.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/InterceptFetchRequestJS.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/JavaScriptBridgeJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/JavaScriptBridgeJS.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/JavaScriptBridgeJS.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/JavaScriptBridgeJS.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnLoadResourceJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnLoadResourceJS.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnLoadResourceJS.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnLoadResourceJS.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnWindowBlurEventJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnWindowBlurEventJS.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnWindowBlurEventJS.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnWindowBlurEventJS.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnWindowFocusEventJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnWindowFocusEventJS.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnWindowFocusEventJS.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/OnWindowFocusEventJS.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PluginScriptsUtil.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PluginScriptsUtil.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PluginScriptsUtil.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PluginScriptsUtil.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PrintJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PrintJS.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PrintJS.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PrintJS.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PromisePolyfillJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PromisePolyfillJS.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PromisePolyfillJS.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/PromisePolyfillJS.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobChannelDelegate.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobChannelDelegate.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobChannelDelegate.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobController.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobController.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobController.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobController.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobManager.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobManager.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobManager.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobSettings.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobSettings.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobSettings.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/print_job/PrintJobSettings.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/process_global_config/ProcessGlobalConfigManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/process_global_config/ProcessGlobalConfigManager.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/process_global_config/ProcessGlobalConfigManager.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/process_global_config/ProcessGlobalConfigManager.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/process_global_config/ProcessGlobalConfigSettings.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/process_global_config/ProcessGlobalConfigSettings.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/process_global_config/ProcessGlobalConfigSettings.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/process_global_config/ProcessGlobalConfigSettings.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/proxy/ProxyManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/proxy/ProxyManager.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/proxy/ProxyManager.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/proxy/ProxyManager.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/proxy/ProxySettings.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/proxy/ProxySettings.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/proxy/ProxySettings.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/proxy/ProxySettings.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshChannelDelegate.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshChannelDelegate.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshChannelDelegate.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshLayout.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshLayout.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshLayout.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshLayout.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshSettings.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshSettings.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshSettings.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/pull_to_refresh/PullToRefreshSettings.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/service_worker/ServiceWorkerChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/service_worker/ServiceWorkerChannelDelegate.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/service_worker/ServiceWorkerChannelDelegate.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/service_worker/ServiceWorkerChannelDelegate.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/service_worker/ServiceWorkerManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/service_worker/ServiceWorkerManager.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/service_worker/ServiceWorkerManager.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/service_worker/ServiceWorkerManager.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingControllerChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingControllerChannelDelegate.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingControllerChannelDelegate.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingControllerChannelDelegate.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingControllerManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingControllerManager.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingControllerManager.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingControllerManager.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingSettings.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingSettings.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingSettings.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/tracing/TracingSettings.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/AndroidResource.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/AndroidResource.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/AndroidResource.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/AndroidResource.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/BaseCallbackResultImpl.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/BaseCallbackResultImpl.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/BaseCallbackResultImpl.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/BaseCallbackResultImpl.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ChannelDelegateImpl.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ChannelDelegateImpl.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ChannelDelegateImpl.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ChannelDelegateImpl.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ClientCertChallenge.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ClientCertChallenge.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ClientCertChallenge.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ClientCertChallenge.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ClientCertResponse.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ClientCertResponse.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ClientCertResponse.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ClientCertResponse.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ContentWorld.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ContentWorld.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ContentWorld.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ContentWorld.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CreateWindowAction.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CreateWindowAction.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CreateWindowAction.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CreateWindowAction.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomSchemeResponse.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomSchemeResponse.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomSchemeResponse.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomSchemeResponse.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsActionButton.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsActionButton.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsActionButton.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsActionButton.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsMenuItem.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsMenuItem.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsMenuItem.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsMenuItem.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsSecondaryToolbar.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsSecondaryToolbar.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsSecondaryToolbar.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/CustomTabsSecondaryToolbar.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/Disposable.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/Disposable.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/Disposable.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/Disposable.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/DownloadStartRequest.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/DownloadStartRequest.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/DownloadStartRequest.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/DownloadStartRequest.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/FindSession.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/FindSession.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/FindSession.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/FindSession.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/GeolocationPermissionShowPromptResponse.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/GeolocationPermissionShowPromptResponse.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/GeolocationPermissionShowPromptResponse.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/GeolocationPermissionShowPromptResponse.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HitTestResult.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HitTestResult.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HitTestResult.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HitTestResult.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HttpAuthResponse.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HttpAuthResponse.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HttpAuthResponse.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HttpAuthResponse.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HttpAuthenticationChallenge.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HttpAuthenticationChallenge.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HttpAuthenticationChallenge.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/HttpAuthenticationChallenge.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ICallbackResult.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ICallbackResult.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ICallbackResult.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ICallbackResult.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/IChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/IChannelDelegate.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/IChannelDelegate.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/IChannelDelegate.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/InAppBrowserMenuItem.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/InAppBrowserMenuItem.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/InAppBrowserMenuItem.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/InAppBrowserMenuItem.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsAlertResponse.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsAlertResponse.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsAlertResponse.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsAlertResponse.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsBeforeUnloadResponse.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsBeforeUnloadResponse.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsBeforeUnloadResponse.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsBeforeUnloadResponse.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsConfirmResponse.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsConfirmResponse.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsConfirmResponse.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsConfirmResponse.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsPromptResponse.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsPromptResponse.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsPromptResponse.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/JsPromptResponse.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/MarginsExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/MarginsExt.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/MarginsExt.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/MarginsExt.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/MediaSizeExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/MediaSizeExt.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/MediaSizeExt.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/MediaSizeExt.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/NavigationAction.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/NavigationAction.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/NavigationAction.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/NavigationAction.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/NavigationActionPolicy.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/NavigationActionPolicy.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/NavigationActionPolicy.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/NavigationActionPolicy.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PermissionResponse.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PermissionResponse.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PermissionResponse.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PermissionResponse.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PluginScript.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PluginScript.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PluginScript.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PluginScript.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PreferredContentModeOptionType.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PreferredContentModeOptionType.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PreferredContentModeOptionType.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PreferredContentModeOptionType.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PrintAttributesExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PrintAttributesExt.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PrintAttributesExt.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PrintAttributesExt.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PrintJobInfoExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PrintJobInfoExt.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PrintJobInfoExt.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/PrintJobInfoExt.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ProxyRuleExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ProxyRuleExt.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ProxyRuleExt.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ProxyRuleExt.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ResolutionExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ResolutionExt.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ResolutionExt.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ResolutionExt.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SafeBrowsingResponse.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SafeBrowsingResponse.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SafeBrowsingResponse.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SafeBrowsingResponse.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ServerTrustAuthResponse.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ServerTrustAuthResponse.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ServerTrustAuthResponse.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ServerTrustAuthResponse.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ServerTrustChallenge.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ServerTrustChallenge.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ServerTrustChallenge.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/ServerTrustChallenge.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/Size2D.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/Size2D.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/Size2D.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/Size2D.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SslCertificateExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SslCertificateExt.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SslCertificateExt.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SslCertificateExt.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SslErrorExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SslErrorExt.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SslErrorExt.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SslErrorExt.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SyncBaseCallbackResultImpl.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SyncBaseCallbackResultImpl.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SyncBaseCallbackResultImpl.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/SyncBaseCallbackResultImpl.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLAuthenticationChallenge.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLAuthenticationChallenge.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLAuthenticationChallenge.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLAuthenticationChallenge.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLCredential.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLCredential.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLCredential.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLCredential.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLProtectionSpace.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLProtectionSpace.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLProtectionSpace.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLProtectionSpace.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLRequest.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLRequest.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLRequest.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/URLRequest.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserContentController.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserContentController.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserContentController.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserContentController.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserScript.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserScript.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserScript.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserScript.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserScriptInjectionTime.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserScriptInjectionTime.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserScriptInjectionTime.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/UserScriptInjectionTime.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessage.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessage.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessage.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessage.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessageCompatExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessageCompatExt.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessageCompatExt.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessageCompatExt.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessagePort.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessagePort.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessagePort.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessagePort.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessagePortCompatExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessagePortCompatExt.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessagePortCompatExt.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebMessagePortCompatExt.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceErrorExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceErrorExt.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceErrorExt.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceErrorExt.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceRequestExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceRequestExt.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceRequestExt.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceRequestExt.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceResponseExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceResponseExt.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceResponseExt.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebResourceResponseExt.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebViewAssetLoaderExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebViewAssetLoaderExt.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebViewAssetLoaderExt.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/types/WebViewAssetLoaderExt.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/ContextMenuSettings.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/ContextMenuSettings.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/ContextMenuSettings.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/ContextMenuSettings.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/FlutterWebViewFactory.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/FlutterWebViewFactory.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/FlutterWebViewFactory.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/FlutterWebViewFactory.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/InAppWebViewInterface.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/InAppWebViewInterface.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/InAppWebViewInterface.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/InAppWebViewInterface.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/InAppWebViewManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/InAppWebViewManager.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/InAppWebViewManager.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/InAppWebViewManager.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/JavaScriptBridgeInterface.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/JavaScriptBridgeInterface.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/JavaScriptBridgeInterface.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/JavaScriptBridgeInterface.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/PlatformWebView.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/PlatformWebView.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/PlatformWebView.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/PlatformWebView.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegate.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegate.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegate.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegateMethods.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegateMethods.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegateMethods.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegateMethods.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/DisplayListenerProxy.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/DisplayListenerProxy.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/DisplayListenerProxy.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/DisplayListenerProxy.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/FlutterWebView.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/FlutterWebView.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/FlutterWebView.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/FlutterWebView.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebView.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebView.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebView.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebView.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewChromeClient.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewChromeClient.java similarity index 99% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewChromeClient.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewChromeClient.java index 8a3c9e5d..75f1fcf5 100755 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewChromeClient.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewChromeClient.java @@ -47,7 +47,6 @@ import androidx.core.content.ContextCompat; import androidx.core.content.FileProvider; import com.pichillilorenzo.flutter_inappwebview.InAppWebViewFileProvider; -import com.pichillilorenzo.flutter_inappwebview.R; import com.pichillilorenzo.flutter_inappwebview.types.CreateWindowAction; import com.pichillilorenzo.flutter_inappwebview.in_app_browser.ActivityResultListener; import com.pichillilorenzo.flutter_inappwebview.in_app_browser.InAppBrowserDelegate; diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewClient.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewClient.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewClient.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewClient.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewClientCompat.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewClientCompat.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewClientCompat.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewClientCompat.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewRenderProcessClient.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewRenderProcessClient.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewRenderProcessClient.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewRenderProcessClient.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewSettings.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewSettings.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewSettings.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebViewSettings.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InputAwareWebView.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InputAwareWebView.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InputAwareWebView.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InputAwareWebView.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/ThreadedInputConnectionProxyAdapterView.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/ThreadedInputConnectionProxyAdapterView.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/ThreadedInputConnectionProxyAdapterView.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/ThreadedInputConnectionProxyAdapterView.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageChannel.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageChannel.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageChannel.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageChannel.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageChannelChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageChannelChannelDelegate.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageChannelChannelDelegate.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageChannelChannelDelegate.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageListener.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageListener.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageListener.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageListener.java diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageListenerChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageListenerChannelDelegate.java similarity index 100% rename from android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageListenerChannelDelegate.java rename to flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/web_message/WebMessageListenerChannelDelegate.java diff --git a/android/src/main/res/drawable/floating_action_mode_shape.xml b/flutter_inappwebview_android/android/src/main/res/drawable/floating_action_mode_shape.xml similarity index 100% rename from android/src/main/res/drawable/floating_action_mode_shape.xml rename to flutter_inappwebview_android/android/src/main/res/drawable/floating_action_mode_shape.xml diff --git a/android/src/main/res/layout/activity_web_view.xml b/flutter_inappwebview_android/android/src/main/res/layout/activity_web_view.xml similarity index 100% rename from android/src/main/res/layout/activity_web_view.xml rename to flutter_inappwebview_android/android/src/main/res/layout/activity_web_view.xml diff --git a/android/src/main/res/layout/chrome_custom_tabs_layout.xml b/flutter_inappwebview_android/android/src/main/res/layout/chrome_custom_tabs_layout.xml similarity index 100% rename from android/src/main/res/layout/chrome_custom_tabs_layout.xml rename to flutter_inappwebview_android/android/src/main/res/layout/chrome_custom_tabs_layout.xml diff --git a/android/src/main/res/layout/floating_action_mode.xml b/flutter_inappwebview_android/android/src/main/res/layout/floating_action_mode.xml similarity index 100% rename from android/src/main/res/layout/floating_action_mode.xml rename to flutter_inappwebview_android/android/src/main/res/layout/floating_action_mode.xml diff --git a/android/src/main/res/layout/floating_action_mode_item.xml b/flutter_inappwebview_android/android/src/main/res/layout/floating_action_mode_item.xml similarity index 100% rename from android/src/main/res/layout/floating_action_mode_item.xml rename to flutter_inappwebview_android/android/src/main/res/layout/floating_action_mode_item.xml diff --git a/android/src/main/res/menu/menu_main.xml b/flutter_inappwebview_android/android/src/main/res/menu/menu_main.xml similarity index 100% rename from android/src/main/res/menu/menu_main.xml rename to flutter_inappwebview_android/android/src/main/res/menu/menu_main.xml diff --git a/android/src/main/res/values/strings.xml b/flutter_inappwebview_android/android/src/main/res/values/strings.xml similarity index 100% rename from android/src/main/res/values/strings.xml rename to flutter_inappwebview_android/android/src/main/res/values/strings.xml diff --git a/android/src/main/res/values/styles.xml b/flutter_inappwebview_android/android/src/main/res/values/styles.xml similarity index 100% rename from android/src/main/res/values/styles.xml rename to flutter_inappwebview_android/android/src/main/res/values/styles.xml diff --git a/android/src/main/res/xml/provider_paths.xml b/flutter_inappwebview_android/android/src/main/res/xml/provider_paths.xml similarity index 100% rename from android/src/main/res/xml/provider_paths.xml rename to flutter_inappwebview_android/android/src/main/res/xml/provider_paths.xml diff --git a/flutter_inappwebview_android/example/.gitignore b/flutter_inappwebview_android/example/.gitignore new file mode 100644 index 00000000..24476c5d --- /dev/null +++ b/flutter_inappwebview_android/example/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/flutter_inappwebview_android/example/README.md b/flutter_inappwebview_android/example/README.md new file mode 100644 index 00000000..833308e7 --- /dev/null +++ b/flutter_inappwebview_android/example/README.md @@ -0,0 +1,16 @@ +# flutter_inappwebview_android_example + +Demonstrates how to use the flutter_inappwebview_android plugin. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/flutter_inappwebview_android/example/analysis_options.yaml b/flutter_inappwebview_android/example/analysis_options.yaml new file mode 100644 index 00000000..0d290213 --- /dev/null +++ b/flutter_inappwebview_android/example/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/flutter_inappwebview_android/example/android/.gitignore b/flutter_inappwebview_android/example/android/.gitignore new file mode 100644 index 00000000..6f568019 --- /dev/null +++ b/flutter_inappwebview_android/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/flutter_inappwebview_android/example/android/app/build.gradle b/flutter_inappwebview_android/example/android/app/build.gradle new file mode 100644 index 00000000..ec439213 --- /dev/null +++ b/flutter_inappwebview_android/example/android/app/build.gradle @@ -0,0 +1,57 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +android { + namespace "com.pichillilorenzo.flutter_inappwebview_android_example" + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.pichillilorenzo.flutter_inappwebview_android_example" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} diff --git a/flutter_inappwebview_android/example/android/app/src/debug/AndroidManifest.xml b/flutter_inappwebview_android/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 00000000..399f6981 --- /dev/null +++ b/flutter_inappwebview_android/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/flutter_inappwebview_android/example/android/app/src/main/AndroidManifest.xml b/flutter_inappwebview_android/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..587125fe --- /dev/null +++ b/flutter_inappwebview_android/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/flutter_inappwebview_android/example/android/app/src/main/java/com/pichillilorenzo/flutter_inappwebview_android_example/MainActivity.java b/flutter_inappwebview_android/example/android/app/src/main/java/com/pichillilorenzo/flutter_inappwebview_android_example/MainActivity.java new file mode 100644 index 00000000..8463e659 --- /dev/null +++ b/flutter_inappwebview_android/example/android/app/src/main/java/com/pichillilorenzo/flutter_inappwebview_android_example/MainActivity.java @@ -0,0 +1,6 @@ +package com.pichillilorenzo.flutter_inappwebview_android_example; + +import io.flutter.embedding.android.FlutterActivity; + +public class MainActivity extends FlutterActivity { +} diff --git a/flutter_inappwebview_android/example/android/app/src/main/res/drawable-v21/launch_background.xml b/flutter_inappwebview_android/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 00000000..f74085f3 --- /dev/null +++ b/flutter_inappwebview_android/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/flutter_inappwebview_android/example/android/app/src/main/res/drawable/launch_background.xml b/flutter_inappwebview_android/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 00000000..304732f8 --- /dev/null +++ b/flutter_inappwebview_android/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/flutter_inappwebview_android/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/flutter_inappwebview_android/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/flutter_inappwebview_android/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/flutter_inappwebview_android/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/flutter_inappwebview_android/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/flutter_inappwebview_android/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/flutter_inappwebview_android/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/flutter_inappwebview_android/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/flutter_inappwebview_android/example/android/app/src/main/res/values-night/styles.xml b/flutter_inappwebview_android/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 00000000..06952be7 --- /dev/null +++ b/flutter_inappwebview_android/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/flutter_inappwebview_android/example/android/app/src/main/res/values/styles.xml b/flutter_inappwebview_android/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..cb1ef880 --- /dev/null +++ b/flutter_inappwebview_android/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/flutter_inappwebview_android/example/android/app/src/profile/AndroidManifest.xml b/flutter_inappwebview_android/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 00000000..399f6981 --- /dev/null +++ b/flutter_inappwebview_android/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/flutter_inappwebview_android/example/android/build.gradle b/flutter_inappwebview_android/example/android/build.gradle new file mode 100644 index 00000000..f7eb7f63 --- /dev/null +++ b/flutter_inappwebview_android/example/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.7.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.3.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/flutter_inappwebview_android/example/android/gradle.properties b/flutter_inappwebview_android/example/android/gradle.properties new file mode 100644 index 00000000..94adc3a3 --- /dev/null +++ b/flutter_inappwebview_android/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/flutter_inappwebview_android/example/android/gradle/wrapper/gradle-wrapper.properties b/flutter_inappwebview_android/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..3c472b99 --- /dev/null +++ b/flutter_inappwebview_android/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/flutter_inappwebview_android/example/android/settings.gradle b/flutter_inappwebview_android/example/android/settings.gradle new file mode 100644 index 00000000..55c4ca8b --- /dev/null +++ b/flutter_inappwebview_android/example/android/settings.gradle @@ -0,0 +1,20 @@ +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + } + settings.ext.flutterSdkPath = flutterSdkPath() + + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") + + plugins { + id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false + } +} + +include ":app" + +apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/flutter_inappwebview_android/example/integration_test/plugin_integration_test.dart b/flutter_inappwebview_android/example/integration_test/plugin_integration_test.dart new file mode 100644 index 00000000..2784454b --- /dev/null +++ b/flutter_inappwebview_android/example/integration_test/plugin_integration_test.dart @@ -0,0 +1,25 @@ +// This is a basic Flutter integration test. +// +// Since integration tests run in a full Flutter application, they can interact +// with the host side of a plugin implementation, unlike Dart unit tests. +// +// For more information about Flutter integration tests, please see +// https://docs.flutter.dev/cookbook/testing/integration/introduction + + +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'package:flutter_inappwebview_android/flutter_inappwebview_android.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('getPlatformVersion test', (WidgetTester tester) async { + final FlutterInappwebviewAndroid plugin = FlutterInappwebviewAndroid(); + final String? version = await plugin.getPlatformVersion(); + // The version string depends on the host platform running the test, so + // just assert that some non-empty string is returned. + expect(version?.isNotEmpty, true); + }); +} diff --git a/flutter_inappwebview_android/example/lib/main.dart b/flutter_inappwebview_android/example/lib/main.dart new file mode 100644 index 00000000..80ee1023 --- /dev/null +++ b/flutter_inappwebview_android/example/lib/main.dart @@ -0,0 +1,63 @@ +import 'package:flutter/material.dart'; +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_android/flutter_inappwebview_android.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({super.key}); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + String _platformVersion = 'Unknown'; + final _flutterInappwebviewAndroidPlugin = FlutterInappwebviewAndroid(); + + @override + void initState() { + super.initState(); + initPlatformState(); + } + + // Platform messages are asynchronous, so we initialize in an async method. + Future initPlatformState() async { + String platformVersion; + // Platform messages may fail, so we use a try/catch PlatformException. + // We also handle the message potentially returning null. + try { + platformVersion = + await _flutterInappwebviewAndroidPlugin.getPlatformVersion() ?? 'Unknown platform version'; + } on PlatformException { + platformVersion = 'Failed to get platform version.'; + } + + // If the widget was removed from the tree while the asynchronous platform + // message was in flight, we want to discard the reply rather than calling + // setState to update our non-existent appearance. + if (!mounted) return; + + setState(() { + _platformVersion = platformVersion; + }); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: Center( + child: Text('Running on: $_platformVersion\n'), + ), + ), + ); + } +} diff --git a/flutter_inappwebview_android/example/pubspec.lock b/flutter_inappwebview_android/example/pubspec.lock new file mode 100644 index 00000000..86d6e013 --- /dev/null +++ b/flutter_inappwebview_android/example/pubspec.lock @@ -0,0 +1,282 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + characters: + dependency: transitive + description: + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" + source: hosted + version: "1.3.0" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + collection: + dependency: transitive + description: + name: collection + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + url: "https://pub.dev" + source: hosted + version: "1.17.2" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d + url: "https://pub.dev" + source: hosted + version: "1.0.6" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_driver: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_inappwebview_android: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "0.0.1" + flutter_inappwebview_internal_annotations: + dependency: transitive + description: + name: flutter_inappwebview_internal_annotations + sha256: "5f80fd30e208ddded7dbbcd0d569e7995f9f63d45ea3f548d8dd4c0b473fb4c8" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter_inappwebview_platform_interface: + dependency: transitive + description: + path: "../../flutter_inappwebview_platform_interface" + relative: true + source: path + version: "0.0.1" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + url: "https://pub.dev" + source: hosted + version: "2.0.3" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + fuchsia_remote_debug_protocol: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + integration_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + matcher: + dependency: transitive + description: + name: matcher + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" + source: hosted + version: "0.12.16" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" + source: hosted + version: "0.5.0" + meta: + dependency: transitive + description: + name: meta + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + path: + dependency: transitive + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" + source: hosted + version: "1.8.3" + platform: + dependency: transitive + description: + name: platform + sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d + url: "https://pub.dev" + source: hosted + version: "2.1.6" + process: + dependency: transitive + description: + name: process + sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + url: "https://pub.dev" + source: hosted + version: "4.2.4" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + sync_http: + dependency: transitive + description: + name: sync_http + sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" + url: "https://pub.dev" + source: hosted + version: "0.3.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + url: "https://pub.dev" + source: hosted + version: "0.6.0" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: c620a6f783fa22436da68e42db7ebbf18b8c44b9a46ab911f666ff09ffd9153f + url: "https://pub.dev" + source: hosted + version: "11.7.1" + web: + dependency: transitive + description: + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" + source: hosted + version: "0.1.4-beta" + webdriver: + dependency: transitive + description: + name: webdriver + sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49" + url: "https://pub.dev" + source: hosted + version: "3.0.2" +sdks: + dart: ">=3.1.4 <4.0.0" + flutter: ">=3.0.0" diff --git a/flutter_inappwebview_android/example/pubspec.yaml b/flutter_inappwebview_android/example/pubspec.yaml new file mode 100644 index 00000000..4aaafc26 --- /dev/null +++ b/flutter_inappwebview_android/example/pubspec.yaml @@ -0,0 +1,85 @@ +name: flutter_inappwebview_android_example +description: Demonstrates how to use the flutter_inappwebview_android plugin. +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +environment: + sdk: '>=3.1.4 <4.0.0' + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + flutter_inappwebview_android: + # When depending on this package from a real application you should use: + # flutter_inappwebview_android: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + integration_test: + sdk: flutter + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/flutter_inappwebview_android/example/test/widget_test.dart b/flutter_inappwebview_android/example/test/widget_test.dart new file mode 100644 index 00000000..60063477 --- /dev/null +++ b/flutter_inappwebview_android/example/test/widget_test.dart @@ -0,0 +1,27 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:flutter_inappwebview_android_example/main.dart'; + +void main() { + testWidgets('Verify Platform version', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that platform version is retrieved. + expect( + find.byWidgetPredicate( + (Widget widget) => widget is Text && + widget.data!.startsWith('Running on:'), + ), + findsOneWidget, + ); + }); +} diff --git a/flutter_inappwebview_android/lib/flutter_inappwebview_android.dart b/flutter_inappwebview_android/lib/flutter_inappwebview_android.dart new file mode 100644 index 00000000..3f3145f4 --- /dev/null +++ b/flutter_inappwebview_android/lib/flutter_inappwebview_android.dart @@ -0,0 +1,3 @@ +library flutter_inappwebview_android; + +export 'src/main.dart'; \ No newline at end of file diff --git a/flutter_inappwebview_android/lib/src/cookie_manager.dart b/flutter_inappwebview_android/lib/src/cookie_manager.dart new file mode 100755 index 00000000..04e44aa5 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/cookie_manager.dart @@ -0,0 +1,575 @@ +import 'dart:async'; + +import 'package:flutter/foundation.dart'; +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 +/// value to avoid breaking changes. See [PlatformCookieManagerCreationParams] for +/// more information. +@immutable +class AndroidCookieManagerCreationParams + extends PlatformCookieManagerCreationParams { + /// Creates a new [AndroidCookieManagerCreationParams] instance. + const AndroidCookieManagerCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformCookieManagerCreationParams params, + ) : super(); + + /// Creates a [AndroidCookieManagerCreationParams] instance based on [PlatformCookieManagerCreationParams]. + factory AndroidCookieManagerCreationParams.fromPlatformCookieManagerCreationParams( + PlatformCookieManagerCreationParams params) { + return AndroidCookieManagerCreationParams(params); + } +} + +///Class that implements a singleton object (shared instance) which manages the cookies used by WebView instances. +///On Android, it is implemented using [CookieManager](https://developer.android.com/reference/android/webkit/CookieManager). +///On iOS, it is implemented using [WKHTTPCookieStore](https://developer.apple.com/documentation/webkit/wkhttpcookiestore). +/// +///**NOTE for iOS below 11.0 and Web platform (LIMITED SUPPORT!)**: in this case, almost all of the methods ([AndroidCookieManager.deleteAllCookies] and [AndroidCookieManager.getAllCookies] are not supported!) +///has been implemented using JavaScript because there is no other way to work with them on iOS below 11.0. +///See https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies for JavaScript restrictions. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- MacOS +///- Web +class AndroidCookieManager extends PlatformCookieManager + with ChannelController { + /// Creates a new [AndroidCookieManager]. + AndroidCookieManager(PlatformCookieManagerCreationParams params) + : super.implementation( + params is AndroidCookieManagerCreationParams + ? params + : AndroidCookieManagerCreationParams + .fromPlatformCookieManagerCreationParams(params), + ) { + channel = const MethodChannel( + 'com.pichillilorenzo/flutter_inappwebview_cookiemanager'); + handler = handleMethod; + initMethodCallHandler(); + } + + static AndroidCookieManager? _instance; + + ///Gets the [AndroidCookieManager] shared instance. + static AndroidCookieManager instance() { + return (_instance != null) ? _instance! : _init(); + } + + static AndroidCookieManager _init() { + _instance = AndroidCookieManager(AndroidCookieManagerCreationParams( + const PlatformCookieManagerCreationParams())); + return _instance!; + } + + Future _handleMethod(MethodCall call) async {} + + ///Sets a cookie for the given [url]. Any existing cookie with the same [host], [path] and [name] will be replaced with the new cookie. + ///The cookie being set will be ignored if it is expired. + /// + ///The default value of [path] is `"/"`. + /// + ///[webViewController] could be used if you need to set a session-only cookie using JavaScript (so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) + ///on the current URL of the [WebView] managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. In this case the [url] parameter is ignored. + /// + ///The return value indicates whether the cookie was set successfully. + ///Note that it will return always `true` for Web platform, iOS below 11.0 and MacOS below 10.13. + /// + ///**NOTE for iOS below 11.0 and MacOS below 10.13**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [AndroidHeadlessInAppWebView] + ///to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [AndroidHeadlessInAppWebView] + ///to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - CookieManager.setCookie](https://developer.android.com/reference/android/webkit/CookieManager#setCookie(java.lang.String,%20java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) + ///- iOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie)) + ///- MacOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie)) + ///- Web + @override + Future setCookie( + {required WebUri url, + required String name, + required String value, + String path = "/", + String? domain, + int? expiresDate, + int? maxAge, + bool? isSecure, + bool? isHttpOnly, + HTTPCookieSameSitePolicy? sameSite, + @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); + args.putIfAbsent('value', () => value); + args.putIfAbsent('domain', () => domain); + args.putIfAbsent('path', () => path); + args.putIfAbsent('expiresDate', () => expiresDate?.toString()); + args.putIfAbsent('maxAge', () => maxAge); + args.putIfAbsent('isSecure', () => isSecure); + args.putIfAbsent('isHttpOnly', () => isHttpOnly); + args.putIfAbsent('sameSite', () => sameSite?.toNativeValue()); + + 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(); + } + + ///Gets all the cookies for the given [url]. + /// + ///[webViewController] is used for getting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) + ///from the current context of the [WebView] managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. JavaScript must be enabled in order to work. + ///In this case the [url] parameter is ignored. + /// + ///**NOTE for iOS below 11.0 and MacOS below 10.13**: All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. + ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [AndroidHeadlessInAppWebView] + ///to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!). + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [AndroidHeadlessInAppWebView] + ///to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!). + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - CookieManager.getCookie](https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String))) + ///- iOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) + ///- MacOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) + ///- Web + @override + Future> getCookies( + {required WebUri url, + @Deprecated("Use webViewController instead") + PlatformInAppWebViewController? iosBelow11WebViewController, + PlatformInAppWebViewController? webViewController}) async { + assert(url.toString().isNotEmpty); + + webViewController = webViewController ?? iosBelow11WebViewController; + + if (await _shouldUseJavascript()) { + return await _getCookiesWithJavaScript( + url: url, webViewController: webViewController); + } + + List cookies = []; + + Map args = {}; + args.putIfAbsent('url', () => url.toString()); + List cookieListMap = + await channel?.invokeMethod('getCookies', 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> _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; + } + + ///Gets a cookie by its [name] for the given [url]. + /// + ///[webViewController] is used for getting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) + ///from the current context of the [WebView] managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. JavaScript must be enabled in order to work. + ///In this case the [url] parameter is ignored. + /// + ///**NOTE for iOS below 11.0 and MacOS below 10.13**: All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. + ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [AndroidHeadlessInAppWebView] + ///to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!). + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [AndroidHeadlessInAppWebView] + ///to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!). + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + @override + Future getCookie( + {required WebUri url, + required String name, + @Deprecated("Use webViewController instead") + PlatformInAppWebViewController? iosBelow11WebViewController, + PlatformInAppWebViewController? webViewController}) async { + 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 = + await channel?.invokeMethod('getCookies', args) ?? []; + cookies = cookies.cast>(); + for (var i = 0; i < cookies.length; i++) { + cookies[i] = cookies[i].cast(); + if (cookies[i]["name"] == name) + return Cookie( + name: cookies[i]["name"], + value: cookies[i]["value"], + expiresDate: cookies[i]["expiresDate"], + isSessionOnly: cookies[i]["isSessionOnly"], + domain: cookies[i]["domain"], + sameSite: HTTPCookieSameSitePolicy.fromNativeValue( + cookies[i]["sameSite"]), + isSecure: cookies[i]["isSecure"], + isHttpOnly: cookies[i]["isHttpOnly"], + path: cookies[i]["path"]); + } + return null; + } + + ///Removes a cookie by its [name] for the given [url], [domain] and [path]. + /// + ///The default value of [path] is `"/"`. + /// + ///[webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) + ///from the current context of the [WebView] managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. JavaScript must be enabled in order to work. + ///In this case the [url] parameter is ignored. + /// + ///**NOTE for iOS below 11.0 and MacOS below 10.13**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [AndroidHeadlessInAppWebView] + ///to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [AndroidHeadlessInAppWebView] + ///to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete) + ///- MacOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete) + ///- Web + @override + Future deleteCookie( + {required WebUri url, + required String name, + String path = "/", + String? domain, + @Deprecated("Use webViewController instead") + PlatformInAppWebViewController? iosBelow11WebViewController, + PlatformInAppWebViewController? webViewController}) async { + 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); + args.putIfAbsent('domain', () => domain); + args.putIfAbsent('path', () => path); + await channel?.invokeMethod('deleteCookie', args); + } + + ///Removes all cookies for the given [url], [domain] and [path]. + /// + ///The default value of [path] is `"/"`. + /// + ///[webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) + ///from the current context of the [WebView] managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. JavaScript must be enabled in order to work. + ///In this case the [url] parameter is ignored. + /// + ///**NOTE for iOS below 11.0 and MacOS below 10.13**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [AndroidHeadlessInAppWebView] + ///to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [AndroidHeadlessInAppWebView] + ///to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + @override + Future deleteCookies( + {required WebUri url, + String path = "/", + String? domain, + @Deprecated("Use webViewController instead") + PlatformInAppWebViewController? iosBelow11WebViewController, + 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); + args.putIfAbsent('path', () => path); + await channel?.invokeMethod('deleteCookies', args); + } + + ///Removes all cookies. + /// + ///**NOTE for iOS**: available from iOS 11.0+. + /// + ///**NOTE for MacOS**: available from iOS 10.13+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - CookieManager.removeAllCookies](https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) + ///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) + ///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) + @override + Future deleteAllCookies() async { + Map args = {}; + await channel?.invokeMethod('deleteAllCookies', args); + } + + ///Fetches all stored cookies. + /// + ///**NOTE for iOS**: available on iOS 11.0+. + /// + ///**NOTE for MacOS**: available from iOS 10.13+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) + ///- MacOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) + @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 + } +} + +extension InternalCookieManager on AndroidCookieManager { + get handleMethod => _handleMethod; +} 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 new file mode 100644 index 00000000..c789a091 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/find_interaction/find_interaction_controller.dart @@ -0,0 +1,229 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +/// Object specifying creation parameters for creating a [AndroidFindInteractionController]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformFindInteractionControllerCreationParams] for +/// more information. +@immutable +class AndroidFindInteractionControllerCreationParams + extends PlatformFindInteractionControllerCreationParams { + /// Creates a new [AndroidFindInteractionControllerCreationParams] instance. + const AndroidFindInteractionControllerCreationParams( + {super.onFindResultReceived}); + + /// Creates a [AndroidFindInteractionControllerCreationParams] instance based on [PlatformFindInteractionControllerCreationParams]. + factory AndroidFindInteractionControllerCreationParams.fromPlatformFindInteractionControllerCreationParams( + // Recommended placeholder to prevent being broken by platform interface. + // ignore: avoid_unused_constructor_parameters + PlatformFindInteractionControllerCreationParams params) { + return AndroidFindInteractionControllerCreationParams( + onFindResultReceived: params.onFindResultReceived); + } +} + +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- MacOS +class AndroidFindInteractionController extends PlatformFindInteractionController + with ChannelController { + ///Debug settings. + static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings(); + + /// Constructs a [AndroidFindInteractionController]. + AndroidFindInteractionController( + PlatformFindInteractionControllerCreationParams params) + : super.implementation( + params is AndroidFindInteractionControllerCreationParams + ? params + : AndroidFindInteractionControllerCreationParams + .fromPlatformFindInteractionControllerCreationParams(params), + ); + + _debugLog(String method, dynamic args) { + debugLog( + className: this.runtimeType.toString(), + debugLoggingSettings: + AndroidFindInteractionController.debugLoggingSettings, + method: method, + args: args); + } + + Future _handleMethod(MethodCall call) async { + _debugLog(call.method, call.arguments); + + switch (call.method) { + case "onFindResultReceived": + if (onFindResultReceived != null) { + int activeMatchOrdinal = call.arguments["activeMatchOrdinal"]; + int numberOfMatches = call.arguments["numberOfMatches"]; + bool isDoneCounting = call.arguments["isDoneCounting"]; + onFindResultReceived!( + this, activeMatchOrdinal, numberOfMatches, isDoneCounting); + } + break; + default: + throw UnimplementedError("Unimplemented ${call.method} method"); + } + return null; + } + + ///Finds all instances of find on the page and highlights them. Notifies [AndroidFindInteractionController.onFindResultReceived] listener. + /// + ///[find] represents the string to find. + /// + ///**NOTE**: on Android native WebView, it finds all instances asynchronously. Successive calls to this will cancel any pending searches. + /// + ///**NOTE**: on iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true`, + ///it uses the built-in find interaction native UI, + ///otherwise this is implemented using CSS and Javascript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.findAllAsync](https://developer.android.com/reference/android/webkit/WebView#findAllAsync(java.lang.String))) + ///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.presentFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2) with [Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)) + ///- MacOS + Future findAll({String? find}) async { + Map args = {}; + args.putIfAbsent('find', () => find); + await channel?.invokeMethod('findAll', args); + } + + ///Highlights and scrolls to the next match found by [findAll]. Notifies [AndroidFindInteractionController.onFindResultReceived] listener. + /// + ///[forward] represents the direction to search. The default value is `true`, meaning forward. + /// + ///**NOTE**: on iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true`, + ///it uses the built-in find interaction native UI, + ///otherwise this is implemented using CSS and Javascript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.findNext](https://developer.android.com/reference/android/webkit/WebView#findNext(boolean))) + ///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.findNext](https://developer.apple.com/documentation/uikit/uifindinteraction/3975829-findnext?changes=_2) and ([Official API - UIFindInteraction.findPrevious](https://developer.apple.com/documentation/uikit/uifindinteraction/3975830-findprevious?changes=_2))) + ///- MacOS + Future findNext({bool forward = true}) async { + Map args = {}; + args.putIfAbsent('forward', () => forward); + await channel?.invokeMethod('findNext', args); + } + + ///Clears the highlighting surrounding text matches created by [findAll]. + /// + ///**NOTE**: on iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true`, + ///it uses the built-in find interaction native UI, + ///otherwise this is implemented using CSS and Javascript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.clearMatches](https://developer.android.com/reference/android/webkit/WebView#clearMatches())) + ///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.dismissFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2)) + ///- MacOS + Future clearMatches() async { + Map args = {}; + await channel?.invokeMethod('clearMatches', args); + } + + ///Pre-populate the search text to be used. + /// + ///On iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true, + ///it will pre-populate the system find panel's search text field with a search query. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)) + ///- MacOS + Future setSearchText(String? searchText) async { + Map args = {}; + args.putIfAbsent('searchText', () => searchText); + await channel?.invokeMethod('setSearchText', args); + } + + ///Get the search text used. + /// + ///On iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true, + ///it will get the system find panel's search text field value. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)) + ///- MacOS + Future getSearchText() async { + Map args = {}; + return await channel?.invokeMethod('getSearchText', args); + } + + ///A Boolean value that indicates when the find panel displays onscreen. + /// + ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - UIFindInteraction.isFindNavigatorVisible](https://developer.apple.com/documentation/uikit/uifindinteraction/3975828-isfindnavigatorvisible?changes=_2)) + Future isFindNavigatorVisible() async { + Map args = {}; + return await channel?.invokeMethod('isFindNavigatorVisible', args); + } + + ///Updates the results the interface displays for the active search. + /// + ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - UIFindInteraction.updateResultCount](https://developer.apple.com/documentation/uikit/uifindinteraction/3975835-updateresultcount?changes=_2)) + Future updateResultCount() async { + Map args = {}; + await channel?.invokeMethod('updateResultCount', args); + } + + ///Begins a search, displaying the find panel. + /// + ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - UIFindInteraction.presentFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2)) + Future presentFindNavigator() async { + Map args = {}; + await channel?.invokeMethod('presentFindNavigator', args); + } + + ///Dismisses the find panel, if present. + /// + ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - UIFindInteraction.dismissFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2)) + Future dismissFindNavigator() async { + Map args = {}; + await channel?.invokeMethod('dismissFindNavigator', args); + } + + ///If there's a currently active find session, returns the active find session. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - UIFindInteraction.activeFindSession](https://developer.apple.com/documentation/uikit/uifindinteraction/3975825-activefindsession?changes=_7____4_8&language=objc)) + ///- MacOS + Future getActiveFindSession() async { + Map args = {}; + Map? result = + (await channel?.invokeMethod('getActiveFindSession', args)) + ?.cast(); + return FindSession.fromMap(result); + } + + ///Disposes the controller. + @override + void dispose({bool isKeepAlive = false}) { + disposeChannel(removeMethodCallHandler: !isKeepAlive); + } +} + +extension InternalFindInteractionController + on AndroidFindInteractionController { + void init(dynamic id) { + channel = MethodChannel( + 'com.pichillilorenzo/flutter_inappwebview_find_interaction_$id'); + handler = _handleMethod; + initMethodCallHandler(); + } +} diff --git a/flutter_inappwebview_android/lib/src/find_interaction/main.dart b/flutter_inappwebview_android/lib/src/find_interaction/main.dart new file mode 100644 index 00000000..433e2f36 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/find_interaction/main.dart @@ -0,0 +1 @@ +export 'find_interaction_controller.dart' hide InternalFindInteractionController; diff --git a/flutter_inappwebview_android/lib/src/http_auth_credentials_database.dart b/flutter_inappwebview_android/lib/src/http_auth_credentials_database.dart new file mode 100755 index 00000000..49cddf60 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/http_auth_credentials_database.dart @@ -0,0 +1,196 @@ +import 'dart:async'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +/// Object specifying creation parameters for creating a [AndroidHttpAuthCredentialDatabase]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformHttpAuthCredentialDatabaseCreationParams] for +/// more information. +@immutable +class AndroidHttpAuthCredentialDatabaseCreationParams + extends PlatformHttpAuthCredentialDatabaseCreationParams { + /// Creates a new [AndroidHttpAuthCredentialDatabaseCreationParams] instance. + const AndroidHttpAuthCredentialDatabaseCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformHttpAuthCredentialDatabaseCreationParams params, + ) : super(); + + /// Creates a [AndroidHttpAuthCredentialDatabaseCreationParams] instance based on [PlatformHttpAuthCredentialDatabaseCreationParams]. + factory AndroidHttpAuthCredentialDatabaseCreationParams.fromPlatformHttpAuthCredentialDatabaseCreationParams( + PlatformHttpAuthCredentialDatabaseCreationParams params) { + return AndroidHttpAuthCredentialDatabaseCreationParams(params); + } +} + +///Class that implements a singleton object (shared instance) which manages the shared HTTP auth credentials cache. +///On iOS and MacOS, this class uses the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class. +///On Android, this class has a custom implementation using `android.database.sqlite.SQLiteDatabase` because +///[WebViewDatabase](https://developer.android.com/reference/android/webkit/WebViewDatabase) +///doesn't offer the same functionalities as iOS `URLCredentialStorage`. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- MacOS +class AndroidHttpAuthCredentialDatabase + extends PlatformHttpAuthCredentialDatabase with ChannelController { + /// Creates a new [AndroidHttpAuthCredentialDatabase]. + AndroidHttpAuthCredentialDatabase( + PlatformHttpAuthCredentialDatabaseCreationParams params) + : super.implementation( + params is AndroidHttpAuthCredentialDatabaseCreationParams + ? params + : AndroidHttpAuthCredentialDatabaseCreationParams + .fromPlatformHttpAuthCredentialDatabaseCreationParams(params), + ) { + channel = const MethodChannel( + 'com.pichillilorenzo/flutter_inappwebview_credential_database'); + handler = handleMethod; + initMethodCallHandler(); + } + + static AndroidHttpAuthCredentialDatabase? _instance; + + ///Gets the database shared instance. + static AndroidHttpAuthCredentialDatabase instance() { + return (_instance != null) ? _instance! : _init(); + } + + static AndroidHttpAuthCredentialDatabase _init() { + _instance = AndroidHttpAuthCredentialDatabase( + AndroidHttpAuthCredentialDatabaseCreationParams( + const PlatformHttpAuthCredentialDatabaseCreationParams())); + return _instance!; + } + + Future _handleMethod(MethodCall call) async {} + + ///Gets a map list of all HTTP auth credentials saved. + ///Each map contains the key `protectionSpace` of type [URLProtectionSpace] + ///and the key `credentials` of type List<[URLCredential]> that contains all the HTTP auth credentials saved for that `protectionSpace`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - URLCredentialStorage.allCredentials](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials)) + ///- MacOS ([Official API - URLCredentialStorage.allCredentials](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials)) + Future> + getAllAuthCredentials() async { + Map args = {}; + List allCredentials = + await channel?.invokeMethod('getAllAuthCredentials', args) ?? []; + + List result = []; + + for (Map map in allCredentials) { + var element = URLProtectionSpaceHttpAuthCredentials.fromMap( + map.cast()); + if (element != null) { + result.add(element); + } + } + return result; + } + + ///Gets all the HTTP auth credentials saved for that [protectionSpace]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future> getHttpAuthCredentials( + {required URLProtectionSpace protectionSpace}) async { + Map args = {}; + args.putIfAbsent("host", () => protectionSpace.host); + args.putIfAbsent("protocol", () => protectionSpace.protocol); + args.putIfAbsent("realm", () => protectionSpace.realm); + args.putIfAbsent("port", () => protectionSpace.port); + List credentialList = + await channel?.invokeMethod('getHttpAuthCredentials', args) ?? []; + List credentials = []; + for (Map map in credentialList) { + var credential = URLCredential.fromMap(map.cast()); + if (credential != null) { + credentials.add(credential); + } + } + return credentials; + } + + ///Saves an HTTP auth [credential] for that [protectionSpace]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - URLCredentialStorage.set](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set)) + ///- MacOS ([Official API - URLCredentialStorage.set](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set)) + Future setHttpAuthCredential( + {required URLProtectionSpace protectionSpace, + required URLCredential credential}) async { + Map args = {}; + args.putIfAbsent("host", () => protectionSpace.host); + args.putIfAbsent("protocol", () => protectionSpace.protocol); + args.putIfAbsent("realm", () => protectionSpace.realm); + args.putIfAbsent("port", () => protectionSpace.port); + args.putIfAbsent("username", () => credential.username); + args.putIfAbsent("password", () => credential.password); + await channel?.invokeMethod('setHttpAuthCredential', args); + } + + ///Removes an HTTP auth [credential] for that [protectionSpace]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - URLCredentialStorage.remove](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove)) + ///- MacOS ([Official API - URLCredentialStorage.remove](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove)) + Future removeHttpAuthCredential( + {required URLProtectionSpace protectionSpace, + required URLCredential credential}) async { + Map args = {}; + args.putIfAbsent("host", () => protectionSpace.host); + args.putIfAbsent("protocol", () => protectionSpace.protocol); + args.putIfAbsent("realm", () => protectionSpace.realm); + args.putIfAbsent("port", () => protectionSpace.port); + args.putIfAbsent("username", () => credential.username); + args.putIfAbsent("password", () => credential.password); + await channel?.invokeMethod('removeHttpAuthCredential', args); + } + + ///Removes all the HTTP auth credentials saved for that [protectionSpace]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future removeHttpAuthCredentials( + {required URLProtectionSpace protectionSpace}) async { + Map args = {}; + args.putIfAbsent("host", () => protectionSpace.host); + args.putIfAbsent("protocol", () => protectionSpace.protocol); + args.putIfAbsent("realm", () => protectionSpace.realm); + args.putIfAbsent("port", () => protectionSpace.port); + await channel?.invokeMethod('removeHttpAuthCredentials', args); + } + + ///Removes all the HTTP auth credentials saved in the database. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future clearAllAuthCredentials() async { + Map args = {}; + await channel?.invokeMethod('clearAllAuthCredentials', args); + } + + @override + void dispose() { + // empty + } +} + +extension InternalHttpAuthCredentialDatabase + on AndroidHttpAuthCredentialDatabase { + get handleMethod => _handleMethod; +} diff --git a/flutter_inappwebview_android/lib/src/in_app_browser/in_app_browser.dart b/flutter_inappwebview_android/lib/src/in_app_browser/in_app_browser.dart new file mode 100755 index 00000000..599b71b4 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/in_app_browser/in_app_browser.dart @@ -0,0 +1,525 @@ +import 'dart:async'; +import 'dart:collection'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +import '../find_interaction/find_interaction_controller.dart'; +import '../in_app_webview/in_app_webview_controller.dart'; +import '../pull_to_refresh/pull_to_refresh_controller.dart'; + +/// Object specifying creation parameters for creating a [AndroidInAppBrowser]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformInAppBrowserCreationParams] for +/// more information. +class AndroidInAppBrowserCreationParams + extends PlatformInAppBrowserCreationParams { + /// Creates a new [AndroidInAppBrowserCreationParams] instance. + AndroidInAppBrowserCreationParams( + {super.contextMenu, + this.pullToRefreshController, + this.findInteractionController, + super.initialUserScripts, + super.windowId}); + + /// Creates a [AndroidInAppBrowserCreationParams] instance based on [PlatformInAppBrowserCreationParams]. + factory AndroidInAppBrowserCreationParams.fromPlatformInAppBrowserCreationParams( + // Recommended placeholder to prevent being broken by platform interface. + // ignore: avoid_unused_constructor_parameters + PlatformInAppBrowserCreationParams params) { + return AndroidInAppBrowserCreationParams( + contextMenu: params.contextMenu, + pullToRefreshController: + params.pullToRefreshController as AndroidPullToRefreshController?, + findInteractionController: params.findInteractionController + as AndroidFindInteractionController?, + initialUserScripts: params.initialUserScripts, + windowId: params.windowId); + } + + @override + final AndroidFindInteractionController? findInteractionController; + + @override + final AndroidPullToRefreshController? pullToRefreshController; +} + +///This class uses the native WebView of the platform. +///The [webViewController] field can be used to access the [InAppWebViewController] API. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- MacOS +class AndroidInAppBrowser extends PlatformInAppBrowser with ChannelController { + ///Debug settings. + static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings(); + + ///View ID used internally. + final String id = IdGenerator.generate(); + + /// Constructs a [AndroidInAppBrowser]. + AndroidInAppBrowser(PlatformInAppBrowserCreationParams params) + : super.implementation( + params is AndroidInAppBrowserCreationParams + ? params + : AndroidInAppBrowserCreationParams + .fromPlatformInAppBrowserCreationParams(params), + ) { + _contextMenu = params.contextMenu; + } + + static final AndroidInAppBrowser _staticValue = + AndroidInAppBrowser(AndroidInAppBrowserCreationParams()); + + factory AndroidInAppBrowser.static() { + return _staticValue; + } + + AndroidInAppBrowserCreationParams get _androidParams => + params as AndroidInAppBrowserCreationParams; + + static const MethodChannel _staticChannel = + const MethodChannel('com.pichillilorenzo/flutter_inappbrowser'); + + ContextMenu? _contextMenu; + + ContextMenu? get contextMenu => _contextMenu; + + Map _menuItems = HashMap(); + bool _isOpened = false; + AndroidInAppWebViewController? _webViewController; + + ///WebView Controller that can be used to access the [AndroidInAppWebViewController] API. + ///When [onExit] is fired, this will be `null` and cannot be used anymore. + AndroidInAppWebViewController? get webViewController { + return _isOpened ? _webViewController : null; + } + + _init() { + channel = MethodChannel('com.pichillilorenzo/flutter_inappbrowser_$id'); + handler = _handleMethod; + initMethodCallHandler(); + + _webViewController = AndroidInAppWebViewController.fromInAppBrowser( + AndroidInAppWebViewControllerCreationParams(id: id), + channel!, + this, + this.initialUserScripts); + _androidParams.pullToRefreshController?.init(id); + _androidParams.findInteractionController?.init(id); + } + + _debugLog(String method, dynamic args) { + debugLog( + className: this.runtimeType.toString(), + id: id, + debugLoggingSettings: PlatformInAppBrowser.debugLoggingSettings, + method: method, + args: args); + } + + Future _handleMethod(MethodCall call) async { + switch (call.method) { + case "onBrowserCreated": + _debugLog(call.method, call.arguments); + eventHandler?.onBrowserCreated(); + break; + case "onMenuItemClicked": + _debugLog(call.method, call.arguments); + int id = call.arguments["id"].toInt(); + if (this._menuItems[id] != null) { + if (this._menuItems[id]?.onClick != null) { + this._menuItems[id]?.onClick!(); + } + } + break; + case "onExit": + _debugLog(call.method, call.arguments); + _isOpened = false; + dispose(); + eventHandler?.onExit(); + break; + default: + return _webViewController?.handleMethod(call); + } + } + + Map _prepareOpenRequest( + {@Deprecated('Use settings instead') InAppBrowserClassOptions? options, + InAppBrowserClassSettings? settings}) { + assert(!_isOpened, 'The browser is already opened.'); + _isOpened = true; + _init(); + + var initialSettings = settings?.toMap() ?? + options?.toMap() ?? + InAppBrowserClassSettings().toMap(); + + Map pullToRefreshSettings = + pullToRefreshController?.settings.toMap() ?? + pullToRefreshController?.options.toMap() ?? + PullToRefreshSettings(enabled: false).toMap(); + + List> menuItemList = []; + _menuItems.forEach((key, value) { + menuItemList.add(value.toMap()); + }); + + Map args = {}; + args.putIfAbsent('id', () => id); + args.putIfAbsent('settings', () => initialSettings); + args.putIfAbsent('contextMenu', () => contextMenu?.toMap() ?? {}); + args.putIfAbsent('windowId', () => windowId); + args.putIfAbsent('initialUserScripts', + () => initialUserScripts?.map((e) => e.toMap()).toList() ?? []); + args.putIfAbsent('pullToRefreshSettings', () => pullToRefreshSettings); + args.putIfAbsent('menuItems', () => menuItemList); + return args; + } + + ///Opens the [PlatformInAppBrowser] instance with an [urlRequest]. + /// + ///[urlRequest]: The [urlRequest] to load. + /// + ///[options]: Options for the [PlatformInAppBrowser]. + /// + ///[settings]: Settings for the [PlatformInAppBrowser]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future openUrlRequest( + {required URLRequest urlRequest, + // ignore: deprecated_member_use_from_same_package + @Deprecated('Use settings instead') InAppBrowserClassOptions? options, + InAppBrowserClassSettings? settings}) async { + assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty); + + Map args = + _prepareOpenRequest(options: options, settings: settings); + args.putIfAbsent('urlRequest', () => urlRequest.toMap()); + await _staticChannel.invokeMethod('open', args); + } + + ///Opens the [PlatformInAppBrowser] instance with the given [assetFilePath] file. + /// + ///[options]: Options for the [PlatformInAppBrowser]. + /// + ///To be able to load your local files (assets, js, css, etc.), you need to add them in the `assets` section of the `pubspec.yaml` file, otherwise they cannot be found! + /// + ///Example of a `pubspec.yaml` file: + ///```yaml + ///... + /// + ///# The following section is specific to Flutter. + ///flutter: + /// + /// # The following line ensures that the Material Icons font is + /// # included with your application, so that you can use the icons in + /// # the material Icons class. + /// uses-material-design: true + /// + /// assets: + /// - assets/index.html + /// - assets/css/ + /// - assets/images/ + /// + ///... + ///``` + ///Example of a `main.dart` file: + ///```dart + ///... + ///inAppBrowser.openFile(assetFilePath: "assets/index.html"); + ///... + ///``` + /// + ///[headers]: The additional headers to be used in the HTTP request for this URL, specified as a map from name to value. + /// + ///[options]: Options for the [PlatformInAppBrowser]. + /// + ///[settings]: Settings for the [PlatformInAppBrowser]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future openFile( + {required String assetFilePath, + // ignore: deprecated_member_use_from_same_package + @Deprecated('Use settings instead') InAppBrowserClassOptions? options, + InAppBrowserClassSettings? settings}) async { + assert(assetFilePath.isNotEmpty); + + Map args = + _prepareOpenRequest(options: options, settings: settings); + args.putIfAbsent('assetFilePath', () => assetFilePath); + await _staticChannel.invokeMethod('open', args); + } + + ///Opens the [PlatformInAppBrowser] instance with [data] as a content, using [baseUrl] as the base URL for it. + /// + ///The [mimeType] parameter specifies the format of the data. The default value is `"text/html"`. + /// + ///The [encoding] parameter specifies the encoding of the data. The default value is `"utf8"`. + /// + ///The [androidHistoryUrl] parameter is the URL to use as the history entry. The default value is `about:blank`. If non-null, this must be a valid URL. This parameter is used only on Android. + /// + ///The [options] parameter specifies the options for the [PlatformInAppBrowser]. + /// + ///[settings]: Settings for the [PlatformInAppBrowser]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future openData( + {required String data, + String mimeType = "text/html", + String encoding = "utf8", + WebUri? baseUrl, + @Deprecated("Use historyUrl instead") Uri? androidHistoryUrl, + WebUri? historyUrl, + // ignore: deprecated_member_use_from_same_package + @Deprecated('Use settings instead') InAppBrowserClassOptions? options, + InAppBrowserClassSettings? settings}) async { + Map args = + _prepareOpenRequest(options: options, settings: settings); + args.putIfAbsent('data', () => data); + args.putIfAbsent('mimeType', () => mimeType); + args.putIfAbsent('encoding', () => encoding); + args.putIfAbsent('baseUrl', () => baseUrl?.toString() ?? "about:blank"); + args.putIfAbsent('historyUrl', + () => (historyUrl ?? androidHistoryUrl)?.toString() ?? "about:blank"); + await _staticChannel.invokeMethod('open', args); + } + + ///This is a static method that opens an [url] in the system browser. You wont be able to use the [PlatformInAppBrowser] methods here! + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future openWithSystemBrowser({required WebUri url}) async { + assert(url.toString().isNotEmpty); + + Map args = {}; + args.putIfAbsent('url', () => url.toString()); + return await _staticChannel.invokeMethod('openWithSystemBrowser', args); + } + + ///Adds a [InAppBrowserMenuItem] to the menu. + ///If the browser is already open, + ///it will take effect the next time it is opened. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS 14.0+ + void addMenuItem(InAppBrowserMenuItem menuItem) { + _menuItems[menuItem.id] = menuItem; + } + + ///Adds a list of [InAppBrowserMenuItem] to the menu. + ///If the browser is already open, + ///it will take effect the next time it is opened. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS 14.0+ + void addMenuItems(List menuItems) { + menuItems.forEach((menuItem) { + _menuItems[menuItem.id] = menuItem; + }); + } + + ///Removes the [menuItem] from the list. + ///Returns `true` if it was in the list, `false` otherwise. + ///If the browser is already open, + ///it will take effect the next time it is opened. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS 14.0+ + bool removeMenuItem(InAppBrowserMenuItem menuItem) { + return _menuItems.remove(menuItem.id) != null; + } + + ///Removes a list of [menuItems] from the list. + ///If the browser is already open, + ///it will take effect the next time it is opened. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS 14.0+ + void removeMenuItems(List menuItems) { + for (final menuItem in menuItems) { + removeMenuItem(menuItem); + } + } + + ///Removes all the menu items from the list. + ///If the browser is already open, + ///it will take effect the next time it is opened. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS 14.0+ + void removeAllMenuItem() { + _menuItems.clear(); + } + + ///Returns `true` if the [menuItem] has been already added, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS 14.0+ + bool hasMenuItem(InAppBrowserMenuItem menuItem) { + return _menuItems.containsKey(menuItem.id); + } + + ///Displays an [PlatformInAppBrowser] window that was opened hidden. Calling this has no effect if the [PlatformInAppBrowser] was already visible. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future show() async { + assert(_isOpened, 'The browser is not opened.'); + + Map args = {}; + await channel?.invokeMethod('show', args); + } + + ///Hides the [PlatformInAppBrowser] window. Calling this has no effect if the [PlatformInAppBrowser] was already hidden. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future hide() async { + assert(_isOpened, 'The browser is not opened.'); + + Map args = {}; + await channel?.invokeMethod('hide', args); + } + + ///Closes the [PlatformInAppBrowser] window. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future close() async { + assert(_isOpened, 'The browser is not opened.'); + + Map args = {}; + await channel?.invokeMethod('close', args); + } + + ///Check if the Web View of the [PlatformInAppBrowser] instance is hidden. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future isHidden() async { + assert(_isOpened, 'The browser is not opened.'); + + Map args = {}; + return await channel?.invokeMethod('isHidden', args) ?? false; + } + + ///Use [setSettings] instead. + @Deprecated('Use setSettings instead') + Future setOptions({required InAppBrowserClassOptions options}) async { + assert(_isOpened, 'The browser is not opened.'); + + Map args = {}; + args.putIfAbsent('settings', () => options.toMap()); + await channel?.invokeMethod('setSettings', args); + } + + ///Use [getSettings] instead. + @Deprecated('Use getSettings instead') + Future getOptions() async { + assert(_isOpened, 'The browser is not opened.'); + Map args = {}; + + Map? options = + await channel?.invokeMethod('getSettings', args); + if (options != null) { + options = options.cast(); + return InAppBrowserClassOptions.fromMap(options as Map); + } + + return null; + } + + ///Sets the [PlatformInAppBrowser] settings with the new [settings] and evaluates them. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future setSettings( + {required InAppBrowserClassSettings settings}) async { + assert(_isOpened, 'The browser is not opened.'); + + Map args = {}; + args.putIfAbsent('settings', () => settings.toMap()); + await channel?.invokeMethod('setSettings', args); + } + + ///Gets the current [PlatformInAppBrowser] settings. Returns `null` if it wasn't able to get them. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future getSettings() async { + assert(_isOpened, 'The browser is not opened.'); + + Map args = {}; + + Map? settings = + await channel?.invokeMethod('getSettings', args); + if (settings != null) { + settings = settings.cast(); + return InAppBrowserClassSettings.fromMap( + settings as Map); + } + + return null; + } + + ///Returns `true` if the [PlatformInAppBrowser] instance is opened, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + bool isOpened() { + return this._isOpened; + } + + ///Disposes the channel and controllers. + @override + @mustCallSuper + void dispose() { + disposeChannel(); + _webViewController?.dispose(); + _webViewController = null; + pullToRefreshController?.dispose(); + findInteractionController?.dispose(); + eventHandler = null; + } +} + +extension InternalInAppBrowser on AndroidInAppBrowser { + void setContextMenu(ContextMenu? contextMenu) { + _contextMenu = contextMenu; + } +} diff --git a/flutter_inappwebview_android/lib/src/in_app_browser/main.dart b/flutter_inappwebview_android/lib/src/in_app_browser/main.dart new file mode 100644 index 00000000..e11eb8b1 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/in_app_browser/main.dart @@ -0,0 +1 @@ +export 'in_app_browser.dart' hide InternalInAppBrowser; diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/_static_channel.dart b/flutter_inappwebview_android/lib/src/in_app_webview/_static_channel.dart new file mode 100644 index 00000000..beb7de70 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/in_app_webview/_static_channel.dart @@ -0,0 +1,4 @@ +import 'package:flutter/services.dart'; + +const IN_APP_WEBVIEW_STATIC_CHANNEL = + MethodChannel('com.pichillilorenzo/flutter_inappwebview_manager'); diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/headless_in_app_webview.dart b/flutter_inappwebview_android/lib/src/in_app_webview/headless_in_app_webview.dart new file mode 100644 index 00000000..605254e3 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/in_app_webview/headless_in_app_webview.dart @@ -0,0 +1,491 @@ +import 'dart:ui'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; +import '../find_interaction/find_interaction_controller.dart'; +import '../pull_to_refresh/pull_to_refresh_controller.dart'; +import 'in_app_webview_controller.dart'; + +/// Object specifying creation parameters for creating a [AndroidCookieManager]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformHeadlessInAppWebViewCreationParams] for +/// more information. +@immutable +class AndroidHeadlessInAppWebViewCreationParams + extends PlatformHeadlessInAppWebViewCreationParams { + /// Creates a new [AndroidHeadlessInAppWebViewCreationParams] instance. + AndroidHeadlessInAppWebViewCreationParams( + {super.initialSize, + super.windowId, + super.onWebViewCreated, + super.onLoadStart, + super.onLoadStop, + @Deprecated('Use onReceivedError instead') super.onLoadError, + super.onReceivedError, + @Deprecated("Use onReceivedHttpError instead") super.onLoadHttpError, + super.onReceivedHttpError, + super.onProgressChanged, + super.onConsoleMessage, + super.shouldOverrideUrlLoading, + super.onLoadResource, + super.onScrollChanged, + @Deprecated('Use onDownloadStartRequest instead') super.onDownloadStart, + super.onDownloadStartRequest, + @Deprecated('Use onLoadResourceWithCustomScheme instead') + super.onLoadResourceCustomScheme, + super.onLoadResourceWithCustomScheme, + super.onCreateWindow, + super.onCloseWindow, + super.onJsAlert, + super.onJsConfirm, + super.onJsPrompt, + super.onReceivedHttpAuthRequest, + super.onReceivedServerTrustAuthRequest, + super.onReceivedClientCertRequest, + @Deprecated('Use FindInteractionController.onFindResultReceived instead') + super.onFindResultReceived, + super.shouldInterceptAjaxRequest, + super.onAjaxReadyStateChange, + super.onAjaxProgress, + super.shouldInterceptFetchRequest, + super.onUpdateVisitedHistory, + @Deprecated("Use onPrintRequest instead") super.onPrint, + super.onPrintRequest, + super.onLongPressHitTestResult, + super.onEnterFullscreen, + super.onExitFullscreen, + super.onPageCommitVisible, + super.onTitleChanged, + super.onWindowFocus, + super.onWindowBlur, + super.onOverScrolled, + super.onZoomScaleChanged, + @Deprecated('Use onSafeBrowsingHit instead') + super.androidOnSafeBrowsingHit, + super.onSafeBrowsingHit, + @Deprecated('Use onPermissionRequest instead') + super.androidOnPermissionRequest, + super.onPermissionRequest, + @Deprecated('Use onGeolocationPermissionsShowPrompt instead') + super.androidOnGeolocationPermissionsShowPrompt, + super.onGeolocationPermissionsShowPrompt, + @Deprecated('Use onGeolocationPermissionsHidePrompt instead') + super.androidOnGeolocationPermissionsHidePrompt, + super.onGeolocationPermissionsHidePrompt, + @Deprecated('Use shouldInterceptRequest instead') + super.androidShouldInterceptRequest, + super.shouldInterceptRequest, + @Deprecated('Use onRenderProcessGone instead') + super.androidOnRenderProcessGone, + super.onRenderProcessGone, + @Deprecated('Use onRenderProcessResponsive instead') + super.androidOnRenderProcessResponsive, + super.onRenderProcessResponsive, + @Deprecated('Use onRenderProcessUnresponsive instead') + super.androidOnRenderProcessUnresponsive, + super.onRenderProcessUnresponsive, + @Deprecated('Use onFormResubmission instead') + super.androidOnFormResubmission, + super.onFormResubmission, + @Deprecated('Use onZoomScaleChanged instead') super.androidOnScaleChanged, + @Deprecated('Use onReceivedIcon instead') super.androidOnReceivedIcon, + super.onReceivedIcon, + @Deprecated('Use onReceivedTouchIconUrl instead') + super.androidOnReceivedTouchIconUrl, + super.onReceivedTouchIconUrl, + @Deprecated('Use onJsBeforeUnload instead') super.androidOnJsBeforeUnload, + super.onJsBeforeUnload, + @Deprecated('Use onReceivedLoginRequest instead') + super.androidOnReceivedLoginRequest, + super.onReceivedLoginRequest, + super.onPermissionRequestCanceled, + super.onRequestFocus, + @Deprecated('Use onWebContentProcessDidTerminate instead') + super.iosOnWebContentProcessDidTerminate, + super.onWebContentProcessDidTerminate, + @Deprecated( + 'Use onDidReceiveServerRedirectForProvisionalNavigation instead') + super.iosOnDidReceiveServerRedirectForProvisionalNavigation, + super.onDidReceiveServerRedirectForProvisionalNavigation, + @Deprecated('Use onNavigationResponse instead') + super.iosOnNavigationResponse, + super.onNavigationResponse, + @Deprecated('Use shouldAllowDeprecatedTLS instead') + super.iosShouldAllowDeprecatedTLS, + super.shouldAllowDeprecatedTLS, + super.onCameraCaptureStateChanged, + super.onMicrophoneCaptureStateChanged, + super.onContentSizeChanged, + super.initialUrlRequest, + super.initialFile, + super.initialData, + @Deprecated('Use initialSettings instead') super.initialOptions, + super.initialSettings, + super.contextMenu, + super.initialUserScripts, + this.pullToRefreshController, + this.findInteractionController}); + + /// Creates a [AndroidHeadlessInAppWebViewCreationParams] instance based on [PlatformHeadlessInAppWebViewCreationParams]. + AndroidHeadlessInAppWebViewCreationParams.fromPlatformHeadlessInAppWebViewCreationParams( + PlatformHeadlessInAppWebViewCreationParams params) + : this( + initialSize: params.initialSize, + windowId: params.windowId, + onWebViewCreated: params.onWebViewCreated, + onLoadStart: params.onLoadStart, + onLoadStop: params.onLoadStop, + onLoadError: params.onLoadError, + onReceivedError: params.onReceivedError, + onLoadHttpError: params.onLoadHttpError, + onReceivedHttpError: params.onReceivedHttpError, + onProgressChanged: params.onProgressChanged, + onConsoleMessage: params.onConsoleMessage, + shouldOverrideUrlLoading: params.shouldOverrideUrlLoading, + onLoadResource: params.onLoadResource, + onScrollChanged: params.onScrollChanged, + onDownloadStart: params.onDownloadStart, + onDownloadStartRequest: params.onDownloadStartRequest, + onLoadResourceCustomScheme: params.onLoadResourceCustomScheme, + onLoadResourceWithCustomScheme: + params.onLoadResourceWithCustomScheme, + onCreateWindow: params.onCreateWindow, + onCloseWindow: params.onCloseWindow, + onJsAlert: params.onJsAlert, + onJsConfirm: params.onJsConfirm, + onJsPrompt: params.onJsPrompt, + onReceivedHttpAuthRequest: params.onReceivedHttpAuthRequest, + onReceivedServerTrustAuthRequest: + params.onReceivedServerTrustAuthRequest, + onReceivedClientCertRequest: params.onReceivedClientCertRequest, + onFindResultReceived: params.onFindResultReceived, + shouldInterceptAjaxRequest: params.shouldInterceptAjaxRequest, + onAjaxReadyStateChange: params.onAjaxReadyStateChange, + onAjaxProgress: params.onAjaxProgress, + shouldInterceptFetchRequest: params.shouldInterceptFetchRequest, + onUpdateVisitedHistory: params.onUpdateVisitedHistory, + onPrint: params.onPrint, + onPrintRequest: params.onPrintRequest, + onLongPressHitTestResult: params.onLongPressHitTestResult, + onEnterFullscreen: params.onEnterFullscreen, + onExitFullscreen: params.onExitFullscreen, + onPageCommitVisible: params.onPageCommitVisible, + onTitleChanged: params.onTitleChanged, + onWindowFocus: params.onWindowFocus, + onWindowBlur: params.onWindowBlur, + onOverScrolled: params.onOverScrolled, + onZoomScaleChanged: params.onZoomScaleChanged, + androidOnSafeBrowsingHit: params.androidOnSafeBrowsingHit, + onSafeBrowsingHit: params.onSafeBrowsingHit, + androidOnPermissionRequest: params.androidOnPermissionRequest, + onPermissionRequest: params.onPermissionRequest, + androidOnGeolocationPermissionsShowPrompt: + params.androidOnGeolocationPermissionsShowPrompt, + onGeolocationPermissionsShowPrompt: + params.onGeolocationPermissionsShowPrompt, + androidOnGeolocationPermissionsHidePrompt: + params.androidOnGeolocationPermissionsHidePrompt, + onGeolocationPermissionsHidePrompt: + params.onGeolocationPermissionsHidePrompt, + androidShouldInterceptRequest: params.androidShouldInterceptRequest, + shouldInterceptRequest: params.shouldInterceptRequest, + androidOnRenderProcessGone: params.androidOnRenderProcessGone, + onRenderProcessGone: params.onRenderProcessGone, + androidOnRenderProcessResponsive: + params.androidOnRenderProcessResponsive, + onRenderProcessResponsive: params.onRenderProcessResponsive, + androidOnRenderProcessUnresponsive: + params.androidOnRenderProcessUnresponsive, + onRenderProcessUnresponsive: params.onRenderProcessUnresponsive, + androidOnFormResubmission: params.androidOnFormResubmission, + onFormResubmission: params.onFormResubmission, + androidOnScaleChanged: params.androidOnScaleChanged, + androidOnReceivedIcon: params.androidOnReceivedIcon, + onReceivedIcon: params.onReceivedIcon, + androidOnReceivedTouchIconUrl: params.androidOnReceivedTouchIconUrl, + onReceivedTouchIconUrl: params.onReceivedTouchIconUrl, + androidOnJsBeforeUnload: params.androidOnJsBeforeUnload, + onJsBeforeUnload: params.onJsBeforeUnload, + androidOnReceivedLoginRequest: params.androidOnReceivedLoginRequest, + onReceivedLoginRequest: params.onReceivedLoginRequest, + onPermissionRequestCanceled: params.onPermissionRequestCanceled, + onRequestFocus: params.onRequestFocus, + iosOnWebContentProcessDidTerminate: + params.iosOnWebContentProcessDidTerminate, + onWebContentProcessDidTerminate: + params.onWebContentProcessDidTerminate, + iosOnDidReceiveServerRedirectForProvisionalNavigation: + params.iosOnDidReceiveServerRedirectForProvisionalNavigation, + onDidReceiveServerRedirectForProvisionalNavigation: + params.onDidReceiveServerRedirectForProvisionalNavigation, + iosOnNavigationResponse: params.iosOnNavigationResponse, + onNavigationResponse: params.onNavigationResponse, + iosShouldAllowDeprecatedTLS: params.iosShouldAllowDeprecatedTLS, + shouldAllowDeprecatedTLS: params.shouldAllowDeprecatedTLS, + onCameraCaptureStateChanged: params.onCameraCaptureStateChanged, + onMicrophoneCaptureStateChanged: + params.onMicrophoneCaptureStateChanged, + onContentSizeChanged: params.onContentSizeChanged, + initialUrlRequest: params.initialUrlRequest, + initialFile: params.initialFile, + initialData: params.initialData, + initialOptions: params.initialOptions, + initialSettings: params.initialSettings, + contextMenu: params.contextMenu, + initialUserScripts: params.initialUserScripts, + pullToRefreshController: params.pullToRefreshController + as AndroidPullToRefreshController?, + findInteractionController: params.findInteractionController + as AndroidFindInteractionController?); + + @override + final AndroidFindInteractionController? findInteractionController; + + @override + final AndroidPullToRefreshController? pullToRefreshController; +} + +///{@template flutter_inappwebview.HeadlessInAppWebView} +///Class that represents a WebView in headless mode. +///It can be used to run a WebView in background without attaching an `InAppWebView` to the widget tree. +/// +///**NOTE**: Remember to dispose it when you don't need it anymore. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- Web +///- MacOS +///{@endtemplate} +class AndroidHeadlessInAppWebView extends PlatformHeadlessInAppWebView + with ChannelController { + ///View ID. + @override + late final String id; + + bool _started = false; + bool _running = false; + + static const MethodChannel _sharedChannel = + const MethodChannel('com.pichillilorenzo/flutter_headless_inappwebview'); + + AndroidInAppWebViewController? _webViewController; + + /// Constructs a [AndroidHeadlessInAppWebView]. + AndroidHeadlessInAppWebView(PlatformHeadlessInAppWebViewCreationParams params) + : super.implementation( + params is AndroidHeadlessInAppWebViewCreationParams + ? params + : AndroidHeadlessInAppWebViewCreationParams + .fromPlatformHeadlessInAppWebViewCreationParams(params), + ) { + id = IdGenerator.generate(); + } + + ///WebView Controller that can be used to access the [InAppWebViewController] API. + @override + AndroidInAppWebViewController? get webViewController => _webViewController; + + AndroidHeadlessInAppWebViewCreationParams get _androidParams => + params as AndroidHeadlessInAppWebViewCreationParams; + + _init() { + _webViewController = AndroidInAppWebViewController( + AndroidInAppWebViewControllerCreationParams( + id: id, webviewParams: params), + ); + _androidParams.pullToRefreshController?.init(id); + _androidParams.findInteractionController?.init(id); + channel = + MethodChannel('com.pichillilorenzo/flutter_headless_inappwebview_$id'); + handler = _handleMethod; + initMethodCallHandler(); + } + + Future _handleMethod(MethodCall call) async { + switch (call.method) { + case "onWebViewCreated": + if (params.onWebViewCreated != null && _webViewController != null) { + params.onWebViewCreated!(_webViewController!); + } + break; + default: + throw UnimplementedError("Unimplemented ${call.method} method"); + } + return null; + } + + ///Runs the headless WebView. + /// + ///**NOTE for Web**: it will append a new `iframe` to the body. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + ///- MacOS + Future run() async { + if (_started) { + return; + } + _started = true; + _init(); + + final initialSettings = params.initialSettings ?? InAppWebViewSettings(); + _inferInitialSettings(initialSettings); + + Map settingsMap = + (params.initialSettings != null ? initialSettings.toMap() : null) ?? + params.initialOptions?.toMap() ?? + initialSettings.toMap(); + + Map pullToRefreshSettings = + _androidParams.pullToRefreshController?.params.settings.toMap() ?? + _androidParams.pullToRefreshController?.params.options.toMap() ?? + PullToRefreshSettings(enabled: false).toMap(); + + Map args = {}; + args.putIfAbsent('id', () => id); + args.putIfAbsent( + 'params', + () => { + 'initialUrlRequest': params.initialUrlRequest?.toMap(), + 'initialFile': params.initialFile, + 'initialData': params.initialData?.toMap(), + 'initialSettings': settingsMap, + 'contextMenu': params.contextMenu?.toMap() ?? {}, + 'windowId': params.windowId, + 'initialUserScripts': + params.initialUserScripts?.map((e) => e.toMap()).toList() ?? + [], + 'pullToRefreshSettings': pullToRefreshSettings, + 'initialSize': params.initialSize.toMap() + }); + await _sharedChannel.invokeMethod('run', args); + _running = true; + } + + void _inferInitialSettings(InAppWebViewSettings settings) { + if (params.shouldOverrideUrlLoading != null && + settings.useShouldOverrideUrlLoading == null) { + settings.useShouldOverrideUrlLoading = true; + } + if (params.onLoadResource != null && settings.useOnLoadResource == null) { + settings.useOnLoadResource = true; + } + if (params.onDownloadStartRequest != null && + settings.useOnDownloadStart == null) { + settings.useOnDownloadStart = true; + } + if (params.shouldInterceptAjaxRequest != null && + settings.useShouldInterceptAjaxRequest == null) { + settings.useShouldInterceptAjaxRequest = true; + } + if (params.shouldInterceptFetchRequest != null && + settings.useShouldInterceptFetchRequest == null) { + settings.useShouldInterceptFetchRequest = true; + } + if (params.shouldInterceptRequest != null && + settings.useShouldInterceptRequest == null) { + settings.useShouldInterceptRequest = true; + } + if (params.onRenderProcessGone != null && + settings.useOnRenderProcessGone == null) { + settings.useOnRenderProcessGone = true; + } + if (params.onNavigationResponse != null && + settings.useOnNavigationResponse == null) { + settings.useOnNavigationResponse = true; + } + } + + ///Indicates if the headless WebView is running or not. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + ///- MacOS + @override + bool isRunning() { + return _running; + } + + ///Set the size of the WebView in pixels. + /// + ///Set `-1` to match the corresponding width or height of the current device screen size. + ///`Size(-1, -1)` will match both width and height of the current device screen size. + /// + ///Note that if the [AndroidHeadlessInAppWebView] is not running, this method won't have effect. + /// + ///**NOTE for Android**: `Size` width and height values will be converted to `int` values because they cannot have `double` values. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + ///- MacOS + @override + Future setSize(Size size) async { + if (!_running) { + return; + } + + Map args = {}; + args.putIfAbsent('size', () => size.toMap()); + await channel?.invokeMethod('setSize', args); + } + + ///Gets the current size in pixels of the WebView. + /// + ///Note that if the [AndroidHeadlessInAppWebView] is not running, this method will return `null`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + ///- MacOS + @override + Future getSize() async { + if (!_running) { + return null; + } + + Map args = {}; + Map sizeMap = + (await channel?.invokeMethod('getSize', args))?.cast(); + return MapSize.fromMap(sizeMap); + } + + ///Disposes the headless WebView. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + ///- MacOS + @override + Future dispose() async { + if (!_running) { + return; + } + Map args = {}; + await channel?.invokeMethod('dispose', args); + disposeChannel(); + _started = false; + _running = false; + _webViewController?.dispose(); + _webViewController = null; + _androidParams.pullToRefreshController?.dispose(); + _androidParams.findInteractionController?.dispose(); + } +} + +extension InternalHeadlessInAppWebView on AndroidHeadlessInAppWebView { + Future internalDispose() async { + _started = false; + _running = false; + } +} diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart new file mode 100755 index 00000000..51582ab5 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart @@ -0,0 +1,474 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter/gestures.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; +import 'headless_in_app_webview.dart'; + +import '../find_interaction/find_interaction_controller.dart'; +import 'in_app_webview_controller.dart'; +import '../pull_to_refresh/main.dart'; +import '../pull_to_refresh/pull_to_refresh_controller.dart'; + +/// Object specifying creation parameters for creating a [PlatformInAppWebViewWidget]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +class AndroidInAppWebViewWidgetCreationParams + extends PlatformInAppWebViewWidgetCreationParams { + AndroidInAppWebViewWidgetCreationParams( + {super.key, + super.layoutDirection, + super.gestureRecognizers, + super.headlessWebView, + super.keepAlive, + super.preventGestureDelay, + super.windowId, + super.onWebViewCreated, + super.onLoadStart, + super.onLoadStop, + @Deprecated('Use onReceivedError instead') super.onLoadError, + super.onReceivedError, + @Deprecated("Use onReceivedHttpError instead") super.onLoadHttpError, + super.onReceivedHttpError, + super.onProgressChanged, + super.onConsoleMessage, + super.shouldOverrideUrlLoading, + super.onLoadResource, + super.onScrollChanged, + @Deprecated('Use onDownloadStartRequest instead') super.onDownloadStart, + super.onDownloadStartRequest, + @Deprecated('Use onLoadResourceWithCustomScheme instead') + super.onLoadResourceCustomScheme, + super.onLoadResourceWithCustomScheme, + super.onCreateWindow, + super.onCloseWindow, + super.onJsAlert, + super.onJsConfirm, + super.onJsPrompt, + super.onReceivedHttpAuthRequest, + super.onReceivedServerTrustAuthRequest, + super.onReceivedClientCertRequest, + @Deprecated('Use FindInteractionController.onFindResultReceived instead') + super.onFindResultReceived, + super.shouldInterceptAjaxRequest, + super.onAjaxReadyStateChange, + super.onAjaxProgress, + super.shouldInterceptFetchRequest, + super.onUpdateVisitedHistory, + @Deprecated("Use onPrintRequest instead") super.onPrint, + super.onPrintRequest, + super.onLongPressHitTestResult, + super.onEnterFullscreen, + super.onExitFullscreen, + super.onPageCommitVisible, + super.onTitleChanged, + super.onWindowFocus, + super.onWindowBlur, + super.onOverScrolled, + super.onZoomScaleChanged, + @Deprecated('Use onSafeBrowsingHit instead') + super.androidOnSafeBrowsingHit, + super.onSafeBrowsingHit, + @Deprecated('Use onPermissionRequest instead') + super.androidOnPermissionRequest, + super.onPermissionRequest, + @Deprecated('Use onGeolocationPermissionsShowPrompt instead') + super.androidOnGeolocationPermissionsShowPrompt, + super.onGeolocationPermissionsShowPrompt, + @Deprecated('Use onGeolocationPermissionsHidePrompt instead') + super.androidOnGeolocationPermissionsHidePrompt, + super.onGeolocationPermissionsHidePrompt, + @Deprecated('Use shouldInterceptRequest instead') + super.androidShouldInterceptRequest, + super.shouldInterceptRequest, + @Deprecated('Use onRenderProcessGone instead') + super.androidOnRenderProcessGone, + super.onRenderProcessGone, + @Deprecated('Use onRenderProcessResponsive instead') + super.androidOnRenderProcessResponsive, + super.onRenderProcessResponsive, + @Deprecated('Use onRenderProcessUnresponsive instead') + super.androidOnRenderProcessUnresponsive, + super.onRenderProcessUnresponsive, + @Deprecated('Use onFormResubmission instead') + super.androidOnFormResubmission, + super.onFormResubmission, + @Deprecated('Use onZoomScaleChanged instead') super.androidOnScaleChanged, + @Deprecated('Use onReceivedIcon instead') super.androidOnReceivedIcon, + super.onReceivedIcon, + @Deprecated('Use onReceivedTouchIconUrl instead') + super.androidOnReceivedTouchIconUrl, + super.onReceivedTouchIconUrl, + @Deprecated('Use onJsBeforeUnload instead') super.androidOnJsBeforeUnload, + super.onJsBeforeUnload, + @Deprecated('Use onReceivedLoginRequest instead') + super.androidOnReceivedLoginRequest, + super.onReceivedLoginRequest, + super.onPermissionRequestCanceled, + super.onRequestFocus, + @Deprecated('Use onWebContentProcessDidTerminate instead') + super.iosOnWebContentProcessDidTerminate, + super.onWebContentProcessDidTerminate, + @Deprecated( + 'Use onDidReceiveServerRedirectForProvisionalNavigation instead') + super.iosOnDidReceiveServerRedirectForProvisionalNavigation, + super.onDidReceiveServerRedirectForProvisionalNavigation, + @Deprecated('Use onNavigationResponse instead') + super.iosOnNavigationResponse, + super.onNavigationResponse, + @Deprecated('Use shouldAllowDeprecatedTLS instead') + super.iosShouldAllowDeprecatedTLS, + super.shouldAllowDeprecatedTLS, + super.onCameraCaptureStateChanged, + super.onMicrophoneCaptureStateChanged, + super.onContentSizeChanged, + super.initialUrlRequest, + super.initialFile, + super.initialData, + @Deprecated('Use initialSettings instead') super.initialOptions, + super.initialSettings, + super.contextMenu, + super.initialUserScripts, + this.pullToRefreshController, + this.findInteractionController}); + + /// Constructs a [AndroidInAppWebViewWidgetCreationParams] using a + /// [PlatformInAppWebViewWidgetCreationParams]. + AndroidInAppWebViewWidgetCreationParams.fromPlatformInAppWebViewWidgetCreationParams( + PlatformInAppWebViewWidgetCreationParams params) + : this( + key: params.key, + layoutDirection: params.layoutDirection, + gestureRecognizers: params.gestureRecognizers, + headlessWebView: params.headlessWebView, + keepAlive: params.keepAlive, + preventGestureDelay: params.preventGestureDelay, + windowId: params.windowId, + onWebViewCreated: params.onWebViewCreated, + onLoadStart: params.onLoadStart, + onLoadStop: params.onLoadStop, + onLoadError: params.onLoadError, + onReceivedError: params.onReceivedError, + onLoadHttpError: params.onLoadHttpError, + onReceivedHttpError: params.onReceivedHttpError, + onProgressChanged: params.onProgressChanged, + onConsoleMessage: params.onConsoleMessage, + shouldOverrideUrlLoading: params.shouldOverrideUrlLoading, + onLoadResource: params.onLoadResource, + onScrollChanged: params.onScrollChanged, + onDownloadStart: params.onDownloadStart, + onDownloadStartRequest: params.onDownloadStartRequest, + onLoadResourceCustomScheme: params.onLoadResourceCustomScheme, + onLoadResourceWithCustomScheme: + params.onLoadResourceWithCustomScheme, + onCreateWindow: params.onCreateWindow, + onCloseWindow: params.onCloseWindow, + onJsAlert: params.onJsAlert, + onJsConfirm: params.onJsConfirm, + onJsPrompt: params.onJsPrompt, + onReceivedHttpAuthRequest: params.onReceivedHttpAuthRequest, + onReceivedServerTrustAuthRequest: + params.onReceivedServerTrustAuthRequest, + onReceivedClientCertRequest: params.onReceivedClientCertRequest, + onFindResultReceived: params.onFindResultReceived, + shouldInterceptAjaxRequest: params.shouldInterceptAjaxRequest, + onAjaxReadyStateChange: params.onAjaxReadyStateChange, + onAjaxProgress: params.onAjaxProgress, + shouldInterceptFetchRequest: params.shouldInterceptFetchRequest, + onUpdateVisitedHistory: params.onUpdateVisitedHistory, + onPrint: params.onPrint, + onPrintRequest: params.onPrintRequest, + onLongPressHitTestResult: params.onLongPressHitTestResult, + onEnterFullscreen: params.onEnterFullscreen, + onExitFullscreen: params.onExitFullscreen, + onPageCommitVisible: params.onPageCommitVisible, + onTitleChanged: params.onTitleChanged, + onWindowFocus: params.onWindowFocus, + onWindowBlur: params.onWindowBlur, + onOverScrolled: params.onOverScrolled, + onZoomScaleChanged: params.onZoomScaleChanged, + androidOnSafeBrowsingHit: params.androidOnSafeBrowsingHit, + onSafeBrowsingHit: params.onSafeBrowsingHit, + androidOnPermissionRequest: params.androidOnPermissionRequest, + onPermissionRequest: params.onPermissionRequest, + androidOnGeolocationPermissionsShowPrompt: + params.androidOnGeolocationPermissionsShowPrompt, + onGeolocationPermissionsShowPrompt: + params.onGeolocationPermissionsShowPrompt, + androidOnGeolocationPermissionsHidePrompt: + params.androidOnGeolocationPermissionsHidePrompt, + onGeolocationPermissionsHidePrompt: + params.onGeolocationPermissionsHidePrompt, + androidShouldInterceptRequest: params.androidShouldInterceptRequest, + shouldInterceptRequest: params.shouldInterceptRequest, + androidOnRenderProcessGone: params.androidOnRenderProcessGone, + onRenderProcessGone: params.onRenderProcessGone, + androidOnRenderProcessResponsive: + params.androidOnRenderProcessResponsive, + onRenderProcessResponsive: params.onRenderProcessResponsive, + androidOnRenderProcessUnresponsive: + params.androidOnRenderProcessUnresponsive, + onRenderProcessUnresponsive: params.onRenderProcessUnresponsive, + androidOnFormResubmission: params.androidOnFormResubmission, + onFormResubmission: params.onFormResubmission, + androidOnScaleChanged: params.androidOnScaleChanged, + androidOnReceivedIcon: params.androidOnReceivedIcon, + onReceivedIcon: params.onReceivedIcon, + androidOnReceivedTouchIconUrl: params.androidOnReceivedTouchIconUrl, + onReceivedTouchIconUrl: params.onReceivedTouchIconUrl, + androidOnJsBeforeUnload: params.androidOnJsBeforeUnload, + onJsBeforeUnload: params.onJsBeforeUnload, + androidOnReceivedLoginRequest: params.androidOnReceivedLoginRequest, + onReceivedLoginRequest: params.onReceivedLoginRequest, + onPermissionRequestCanceled: params.onPermissionRequestCanceled, + onRequestFocus: params.onRequestFocus, + iosOnWebContentProcessDidTerminate: + params.iosOnWebContentProcessDidTerminate, + onWebContentProcessDidTerminate: + params.onWebContentProcessDidTerminate, + iosOnDidReceiveServerRedirectForProvisionalNavigation: + params.iosOnDidReceiveServerRedirectForProvisionalNavigation, + onDidReceiveServerRedirectForProvisionalNavigation: + params.onDidReceiveServerRedirectForProvisionalNavigation, + iosOnNavigationResponse: params.iosOnNavigationResponse, + onNavigationResponse: params.onNavigationResponse, + iosShouldAllowDeprecatedTLS: params.iosShouldAllowDeprecatedTLS, + shouldAllowDeprecatedTLS: params.shouldAllowDeprecatedTLS, + onCameraCaptureStateChanged: params.onCameraCaptureStateChanged, + onMicrophoneCaptureStateChanged: + params.onMicrophoneCaptureStateChanged, + onContentSizeChanged: params.onContentSizeChanged, + initialUrlRequest: params.initialUrlRequest, + initialFile: params.initialFile, + initialData: params.initialData, + initialOptions: params.initialOptions, + initialSettings: params.initialSettings, + contextMenu: params.contextMenu, + initialUserScripts: params.initialUserScripts, + pullToRefreshController: params.pullToRefreshController + as AndroidPullToRefreshController?, + findInteractionController: params.findInteractionController + as AndroidFindInteractionController?); + + @override + final AndroidFindInteractionController? findInteractionController; + + @override + final AndroidPullToRefreshController? pullToRefreshController; +} + +///{@template flutter_inappwebview.InAppWebView} +///Flutter Widget for adding an **inline native WebView** integrated in the flutter widget tree. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- Web +///{@endtemplate} +class AndroidInAppWebViewWidget extends PlatformInAppWebViewWidget { + /// Constructs a [AndroidInAppWebViewWidget]. + AndroidInAppWebViewWidget(PlatformInAppWebViewWidgetCreationParams params) + : super.implementation( + params is AndroidInAppWebViewWidgetCreationParams + ? params + : AndroidInAppWebViewWidgetCreationParams + .fromPlatformInAppWebViewWidgetCreationParams(params), + ); + + AndroidInAppWebViewWidgetCreationParams get _androidParams => + params as AndroidInAppWebViewWidgetCreationParams; + + AndroidInAppWebViewController? _controller; + + AndroidHeadlessInAppWebView? get _androidHeadlessInAppWebView => + _androidParams.headlessWebView as AndroidHeadlessInAppWebView?; + + @override + Widget build(BuildContext context) { + final initialSettings = + _androidParams.initialSettings ?? InAppWebViewSettings(); + _inferInitialSettings(initialSettings); + + Map settingsMap = (_androidParams.initialSettings != null + ? initialSettings.toMap() + : null) ?? + // ignore: deprecated_member_use_from_same_package + _androidParams.initialOptions?.toMap() ?? + initialSettings.toMap(); + + Map pullToRefreshSettings = + _androidParams.pullToRefreshController?.params.settings.toMap() ?? + // ignore: deprecated_member_use_from_same_package + _androidParams.pullToRefreshController?.params.options.toMap() ?? + PullToRefreshSettings(enabled: false).toMap(); + + if ((_androidParams.headlessWebView?.isRunning() ?? false) && + _androidParams.keepAlive != null) { + final headlessId = _androidParams.headlessWebView?.id; + if (headlessId != null) { + // force keep alive id to match headless webview id + _androidParams.keepAlive?.id = headlessId; + } + } + + var useHybridComposition = (_androidParams.initialSettings != null + ? initialSettings.useHybridComposition + : _androidParams.initialOptions?.android.useHybridComposition) ?? + true; + + return PlatformViewLink( + // Setting a default key using `params` ensures the `PlatformViewLink` + // recreates the PlatformView when changes are made. + key: _androidParams.key ?? + ValueKey( + params as AndroidInAppWebViewWidgetCreationParams), + viewType: 'com.pichillilorenzo/flutter_inappwebview', + surfaceFactory: ( + BuildContext context, + PlatformViewController controller, + ) { + return AndroidViewSurface( + controller: controller as AndroidViewController, + gestureRecognizers: _androidParams.gestureRecognizers ?? + const >{}, + hitTestBehavior: PlatformViewHitTestBehavior.opaque, + ); + }, + onCreatePlatformView: (PlatformViewCreationParams params) { + return _createAndroidViewController( + hybridComposition: useHybridComposition, + id: params.id, + viewType: 'com.pichillilorenzo/flutter_inappwebview', + layoutDirection: _androidParams.layoutDirection ?? + Directionality.maybeOf(context) ?? + TextDirection.rtl, + creationParams: { + 'initialUrlRequest': _androidParams.initialUrlRequest?.toMap(), + 'initialFile': _androidParams.initialFile, + 'initialData': _androidParams.initialData?.toMap(), + 'initialSettings': settingsMap, + 'contextMenu': _androidParams.contextMenu?.toMap() ?? {}, + 'windowId': _androidParams.windowId, + 'headlessWebViewId': + _androidParams.headlessWebView?.isRunning() ?? false + ? _androidParams.headlessWebView?.id + : null, + 'initialUserScripts': _androidParams.initialUserScripts + ?.map((e) => e.toMap()) + .toList() ?? + [], + 'pullToRefreshSettings': pullToRefreshSettings, + 'keepAliveId': _androidParams.keepAlive?.id + }, + ) + ..addOnPlatformViewCreatedListener(params.onPlatformViewCreated) + ..addOnPlatformViewCreatedListener((id) => _onPlatformViewCreated(id)) + ..create(); + }, + ); + } + + @override + void dispose() { + dynamic viewId = _controller?.getViewId(); + debugLog( + className: runtimeType.toString(), + id: viewId?.toString(), + debugLoggingSettings: PlatformInAppWebViewController.debugLoggingSettings, + method: "dispose", + args: []); + final isKeepAlive = _androidParams.keepAlive != null; + _controller?.dispose(isKeepAlive: isKeepAlive); + _controller = null; + _androidParams.pullToRefreshController?.dispose(isKeepAlive: isKeepAlive); + _androidParams.findInteractionController?.dispose(isKeepAlive: isKeepAlive); + } + + AndroidViewController _createAndroidViewController({ + required bool hybridComposition, + required int id, + required String viewType, + required TextDirection layoutDirection, + required Map creationParams, + }) { + if (hybridComposition) { + return PlatformViewsService.initExpensiveAndroidView( + id: id, + viewType: viewType, + layoutDirection: layoutDirection, + creationParams: creationParams, + creationParamsCodec: const StandardMessageCodec(), + ); + } + return PlatformViewsService.initSurfaceAndroidView( + id: id, + viewType: viewType, + layoutDirection: layoutDirection, + creationParams: creationParams, + creationParamsCodec: const StandardMessageCodec(), + ); + } + + void _onPlatformViewCreated(int id) { + dynamic viewId = id; + if (!kIsWeb) { + if (_androidParams.headlessWebView?.isRunning() ?? false) { + viewId = _androidParams.headlessWebView?.id; + } + viewId = _androidParams.keepAlive?.id ?? viewId ?? id; + } + _androidHeadlessInAppWebView?.internalDispose(); + _controller = AndroidInAppWebViewController( + PlatformInAppWebViewControllerCreationParams( + id: viewId, webviewParams: params)); + _androidParams.pullToRefreshController?.init(viewId); + _androidParams.findInteractionController?.init(viewId); + debugLog( + className: runtimeType.toString(), + id: viewId?.toString(), + debugLoggingSettings: PlatformInAppWebViewController.debugLoggingSettings, + method: "onWebViewCreated", + args: []); + if (_androidParams.onWebViewCreated != null) { + _androidParams.onWebViewCreated!(_controller!); + } + } + + void _inferInitialSettings(InAppWebViewSettings settings) { + if (_androidParams.shouldOverrideUrlLoading != null && + settings.useShouldOverrideUrlLoading == null) { + settings.useShouldOverrideUrlLoading = true; + } + if (_androidParams.onLoadResource != null && + settings.useOnLoadResource == null) { + settings.useOnLoadResource = true; + } + if (_androidParams.onDownloadStartRequest != null && + settings.useOnDownloadStart == null) { + settings.useOnDownloadStart = true; + } + if (_androidParams.shouldInterceptAjaxRequest != null && + settings.useShouldInterceptAjaxRequest == null) { + settings.useShouldInterceptAjaxRequest = true; + } + if (_androidParams.shouldInterceptFetchRequest != null && + settings.useShouldInterceptFetchRequest == null) { + settings.useShouldInterceptFetchRequest = true; + } + if (_androidParams.shouldInterceptRequest != null && + settings.useShouldInterceptRequest == null) { + settings.useShouldInterceptRequest = true; + } + if (_androidParams.onRenderProcessGone != null && + settings.useOnRenderProcessGone == null) { + settings.useOnRenderProcessGone = true; + } + if (_androidParams.onNavigationResponse != null && + settings.useOnNavigationResponse == null) { + settings.useOnNavigationResponse = true; + } + } +} 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 new file mode 100644 index 00000000..33bc26a3 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart @@ -0,0 +1,4090 @@ +import 'dart:io'; +import 'dart:collection'; +import 'dart:convert'; +import 'dart:core'; +import 'dart:developer' as developer; +import 'dart:typed_data'; +import 'dart:ui'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +import '../web_message/main.dart'; + +import '../in_app_browser/in_app_browser.dart'; +import '../web_storage/web_storage.dart'; + +import 'headless_in_app_webview.dart'; +import '_static_channel.dart'; + +import '../print_job/main.dart'; +import '../find_interaction/main.dart'; + +///List of forbidden names for JavaScript handlers. +// ignore: non_constant_identifier_names +final _JAVASCRIPT_HANDLER_FORBIDDEN_NAMES = UnmodifiableListView([ + "onLoadResource", + "shouldInterceptAjaxRequest", + "onAjaxReadyStateChange", + "onAjaxProgress", + "shouldInterceptFetchRequest", + "onPrintRequest", + "onWindowFocus", + "onWindowBlur", + "callAsyncJavaScript", + "evaluateJavaScriptWithContentWorld" +]); + +/// Object specifying creation parameters for creating a [AndroidInAppWebViewController]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformInAppWebViewControllerCreationParams] for +/// more information. +@immutable +class AndroidInAppWebViewControllerCreationParams + extends PlatformInAppWebViewControllerCreationParams { + /// Creates a new [AndroidInAppWebViewControllerCreationParams] instance. + const AndroidInAppWebViewControllerCreationParams( + {required super.id, super.webviewParams}); + + /// Creates a [AndroidInAppWebViewControllerCreationParams] instance based on [PlatformInAppWebViewControllerCreationParams]. + factory AndroidInAppWebViewControllerCreationParams.fromPlatformInAppWebViewControllerCreationParams( + // Recommended placeholder to prevent being broken by platform interface. + // ignore: avoid_unused_constructor_parameters + PlatformInAppWebViewControllerCreationParams params) { + return AndroidInAppWebViewControllerCreationParams( + id: params.id, webviewParams: params.webviewParams); + } +} + +///Controls a WebView, such as an [InAppWebView] widget instance, a [AndroidHeadlessInAppWebView] instance or [AndroidInAppBrowser] WebView instance. +/// +///If you are using the [InAppWebView] widget, an [InAppWebViewController] instance can be obtained by setting the [InAppWebView.onWebViewCreated] +///callback. Instead, if you are using an [AndroidInAppBrowser] instance, you can get it through the [AndroidInAppBrowser.webViewController] attribute. +class AndroidInAppWebViewController extends PlatformInAppWebViewController + with ChannelController { + static final MethodChannel _staticChannel = IN_APP_WEBVIEW_STATIC_CHANNEL; + + // List of properties to be saved and restored for keep alive feature + Map _javaScriptHandlersMap = + HashMap(); + Map> _userScripts = { + UserScriptInjectionTime.AT_DOCUMENT_START: [], + UserScriptInjectionTime.AT_DOCUMENT_END: [] + }; + Set _webMessageListenerObjNames = Set(); + Map _injectedScriptsFromURL = {}; + Set _webMessageChannels = Set(); + Set _webMessageListeners = Set(); + + // static map that contains the properties to be saved and restored for keep alive feature + static final Map + _keepAliveMap = {}; + + AndroidInAppBrowser? _inAppBrowser; + PlatformInAppBrowserEvents? get _inAppBrowserEventHandler => _inAppBrowser?.eventHandler; + + ///Provides access to the JavaScript [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API): `window.sessionStorage` and `window.localStorage`. + late AndroidWebStorage webStorage; + + AndroidInAppWebViewController( + PlatformInAppWebViewControllerCreationParams params) + : super.implementation(params + is AndroidInAppWebViewControllerCreationParams + ? params + : AndroidInAppWebViewControllerCreationParams + .fromPlatformInAppWebViewControllerCreationParams(params)) { + channel = + MethodChannel('com.pichillilorenzo/flutter_inappwebview_$id'); + handler = handleMethod; + initMethodCallHandler(); + + final initialUserScripts = webviewParams?.initialUserScripts; + if (initialUserScripts != null) { + for (final userScript in initialUserScripts) { + if (userScript.injectionTime == + UserScriptInjectionTime.AT_DOCUMENT_START) { + this + ._userScripts[UserScriptInjectionTime.AT_DOCUMENT_START] + ?.add(userScript); + } else { + this + ._userScripts[UserScriptInjectionTime.AT_DOCUMENT_END] + ?.add(userScript); + } + } + } + + this._init(params); + } + + static final AndroidInAppWebViewController _staticValue = AndroidInAppWebViewController( + AndroidInAppWebViewControllerCreationParams(id: null)); + + factory AndroidInAppWebViewController.static() { + return _staticValue; + } + + AndroidInAppWebViewController.fromInAppBrowser( + PlatformInAppWebViewControllerCreationParams params, + MethodChannel channel, + AndroidInAppBrowser inAppBrowser, + UnmodifiableListView? initialUserScripts) + : super.implementation( + params is AndroidInAppWebViewControllerCreationParams + ? params + : AndroidInAppWebViewControllerCreationParams + .fromPlatformInAppWebViewControllerCreationParams(params)) { + this.channel = channel; + this._inAppBrowser = inAppBrowser; + + if (initialUserScripts != null) { + for (final userScript in initialUserScripts) { + if (userScript.injectionTime == + UserScriptInjectionTime.AT_DOCUMENT_START) { + this + ._userScripts[UserScriptInjectionTime.AT_DOCUMENT_START] + ?.add(userScript); + } else { + this + ._userScripts[UserScriptInjectionTime.AT_DOCUMENT_END] + ?.add(userScript); + } + } + } + this._init(params); + } + + void _init(PlatformInAppWebViewControllerCreationParams params) { + webStorage = AndroidWebStorage(AndroidWebStorageCreationParams( + localStorage: AndroidLocalStorage.defaultStorage(), + sessionStorage: AndroidSessionStorage.defaultStorage())); + + if (params.webviewParams is PlatformInAppWebViewWidgetCreationParams) { + final keepAlive = + (params.webviewParams as PlatformInAppWebViewWidgetCreationParams) + .keepAlive; + if (keepAlive != null) { + InAppWebViewControllerKeepAliveProps? props = _keepAliveMap[keepAlive]; + if (props == null) { + // save controller properties to restore it later + _keepAliveMap[keepAlive] = InAppWebViewControllerKeepAliveProps( + injectedScriptsFromURL: _injectedScriptsFromURL, + javaScriptHandlersMap: _javaScriptHandlersMap, + userScripts: _userScripts, + webMessageListenerObjNames: _webMessageListenerObjNames, + webMessageChannels: _webMessageChannels, + webMessageListeners: _webMessageListeners); + } else { + // restore controller properties + _injectedScriptsFromURL = props.injectedScriptsFromURL; + _javaScriptHandlersMap = props.javaScriptHandlersMap; + _userScripts = props.userScripts; + _webMessageListenerObjNames = props.webMessageListenerObjNames; + _webMessageChannels = + props.webMessageChannels as Set; + _webMessageListeners = + props.webMessageListeners as Set; + } + } + } + } + + _debugLog(String method, dynamic args) { + debugLog( + className: this.runtimeType.toString(), + name: _inAppBrowser == null ? "WebView" : _inAppBrowser.runtimeType.toString(), + id: (getViewId() ?? _inAppBrowser?.id).toString(), + debugLoggingSettings: PlatformInAppWebViewController.debugLoggingSettings, + method: method, + args: args); + } + + Future _handleMethod(MethodCall call) async { + if (PlatformInAppWebViewController.debugLoggingSettings.enabled && + call.method != "onCallJsHandler") { + _debugLog(call.method, call.arguments); + } + + switch (call.method) { + case "onLoadStart": + _injectedScriptsFromURL.clear(); + if ((webviewParams != null && + webviewParams!.onLoadStart != null) || + _inAppBrowserEventHandler != null) { + String? url = call.arguments["url"]; + WebUri? uri = url != null ? WebUri(url) : null; + if (webviewParams != null && + webviewParams!.onLoadStart != null) + webviewParams!.onLoadStart!(this, uri); + else + _inAppBrowserEventHandler!.onLoadStart(uri); + } + break; + case "onLoadStop": + if ((webviewParams != null && + webviewParams!.onLoadStop != null) || + _inAppBrowserEventHandler != null) { + String? url = call.arguments["url"]; + WebUri? uri = url != null ? WebUri(url) : null; + if (webviewParams != null && + webviewParams!.onLoadStop != null) + webviewParams!.onLoadStop!(this, uri); + else + _inAppBrowserEventHandler!.onLoadStop(uri); + } + break; + case "onReceivedError": + if ((webviewParams != null && + (webviewParams!.onReceivedError != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.onLoadError != null)) || + _inAppBrowserEventHandler != null) { + WebResourceRequest request = WebResourceRequest.fromMap( + call.arguments["request"].cast())!; + WebResourceError error = WebResourceError.fromMap( + call.arguments["error"].cast())!; + var isForMainFrame = request.isForMainFrame ?? false; + + if (webviewParams != null) { + if (webviewParams!.onReceivedError != null) + webviewParams!.onReceivedError!(this, request, error); + else if (isForMainFrame) { + // ignore: deprecated_member_use_from_same_package + webviewParams!.onLoadError!(this, request.url, + error.type.toNativeValue() ?? -1, error.description); + } + } else { + if (isForMainFrame) { + _inAppBrowserEventHandler!.onLoadError(request.url, error.type.toNativeValue() ?? -1, + error.description); + } + _inAppBrowserEventHandler!.onReceivedError(request, error); + } + } + break; + case "onReceivedHttpError": + if ((webviewParams != null && + (webviewParams!.onReceivedHttpError != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.onLoadHttpError != null)) || + _inAppBrowserEventHandler != null) { + WebResourceRequest request = WebResourceRequest.fromMap( + call.arguments["request"].cast())!; + WebResourceResponse errorResponse = WebResourceResponse.fromMap( + call.arguments["errorResponse"].cast())!; + var isForMainFrame = request.isForMainFrame ?? false; + + if (webviewParams != null) { + if (webviewParams!.onReceivedHttpError != null) + webviewParams!.onReceivedHttpError!( + this, request, errorResponse); + else if (isForMainFrame) { + // ignore: deprecated_member_use_from_same_package + webviewParams!.onLoadHttpError!( + this, + request.url, + errorResponse.statusCode ?? -1, + errorResponse.reasonPhrase ?? ''); + } + } else { + if (isForMainFrame) { + _inAppBrowserEventHandler!.onLoadHttpError(request.url, errorResponse.statusCode ?? -1, + errorResponse.reasonPhrase ?? ''); + } + _inAppBrowserEventHandler!.onReceivedHttpError(request, errorResponse); + } + } + break; + case "onProgressChanged": + if ((webviewParams != null && + webviewParams!.onProgressChanged != null) || + _inAppBrowserEventHandler != null) { + int progress = call.arguments["progress"]; + if (webviewParams != null && + webviewParams!.onProgressChanged != null) + webviewParams!.onProgressChanged!(this, progress); + else + _inAppBrowserEventHandler!.onProgressChanged(progress); + } + break; + case "shouldOverrideUrlLoading": + if ((webviewParams != null && + webviewParams!.shouldOverrideUrlLoading != null) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + NavigationAction navigationAction = + NavigationAction.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.shouldOverrideUrlLoading != null) + return (await webviewParams!.shouldOverrideUrlLoading!( + this, navigationAction)) + ?.toNativeValue(); + return (await _inAppBrowserEventHandler!.shouldOverrideUrlLoading(navigationAction)) + ?.toNativeValue(); + } + break; + case "onConsoleMessage": + if ((webviewParams != null && + webviewParams!.onConsoleMessage != null) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + ConsoleMessage consoleMessage = ConsoleMessage.fromMap(arguments)!; + if (webviewParams != null && + webviewParams!.onConsoleMessage != null) + webviewParams!.onConsoleMessage!(this, consoleMessage); + else + _inAppBrowserEventHandler!.onConsoleMessage(consoleMessage); + } + break; + case "onScrollChanged": + if ((webviewParams != null && + webviewParams!.onScrollChanged != null) || + _inAppBrowserEventHandler != null) { + int x = call.arguments["x"]; + int y = call.arguments["y"]; + if (webviewParams != null && + webviewParams!.onScrollChanged != null) + webviewParams!.onScrollChanged!(this, x, y); + else + _inAppBrowserEventHandler!.onScrollChanged(x, y); + } + break; + case "onDownloadStartRequest": + if ((webviewParams != null && + // ignore: deprecated_member_use_from_same_package + (webviewParams!.onDownloadStart != null || + webviewParams!.onDownloadStartRequest != null)) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + DownloadStartRequest downloadStartRequest = + DownloadStartRequest.fromMap(arguments)!; + + if (webviewParams != null) { + if (webviewParams!.onDownloadStartRequest != null) + webviewParams!.onDownloadStartRequest!( + this, downloadStartRequest); + else { + // ignore: deprecated_member_use_from_same_package + webviewParams!.onDownloadStart!( + this, downloadStartRequest.url); + } + } else { + // ignore: deprecated_member_use_from_same_package + _inAppBrowserEventHandler!.onDownloadStart(downloadStartRequest.url); + _inAppBrowserEventHandler!.onDownloadStartRequest(downloadStartRequest); + } + } + break; + case "onLoadResourceWithCustomScheme": + if ((webviewParams != null && + (webviewParams!.onLoadResourceWithCustomScheme != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.onLoadResourceCustomScheme != + null)) || + _inAppBrowserEventHandler != null) { + Map requestMap = + call.arguments["request"].cast(); + WebResourceRequest request = WebResourceRequest.fromMap(requestMap)!; + + if (webviewParams != null) { + if (webviewParams!.onLoadResourceWithCustomScheme != null) + return (await webviewParams! + .onLoadResourceWithCustomScheme!(this, request)) + ?.toMap(); + else { + return (await params + .webviewParams! + // ignore: deprecated_member_use_from_same_package + .onLoadResourceCustomScheme!(this, request.url)) + ?.toMap(); + } + } else { + return ((await _inAppBrowserEventHandler!.onLoadResourceWithCustomScheme(request)) ?? + (await _inAppBrowserEventHandler!.onLoadResourceCustomScheme(request.url))) + ?.toMap(); + } + } + break; + case "onCreateWindow": + if ((webviewParams != null && + webviewParams!.onCreateWindow != null) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + CreateWindowAction createWindowAction = + CreateWindowAction.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.onCreateWindow != null) + return await webviewParams!.onCreateWindow!( + this, createWindowAction); + else + return await _inAppBrowserEventHandler!.onCreateWindow(createWindowAction); + } + break; + case "onCloseWindow": + if (webviewParams != null && + webviewParams!.onCloseWindow != null) + webviewParams!.onCloseWindow!(this); + else if (_inAppBrowserEventHandler != null) _inAppBrowserEventHandler!.onCloseWindow(); + break; + case "onTitleChanged": + if ((webviewParams != null && + webviewParams!.onTitleChanged != null) || + _inAppBrowserEventHandler != null) { + String? title = call.arguments["title"]; + if (webviewParams != null && + webviewParams!.onTitleChanged != null) + webviewParams!.onTitleChanged!(this, title); + else + _inAppBrowserEventHandler!.onTitleChanged(title); + } + break; + case "onGeolocationPermissionsShowPrompt": + if ((webviewParams != null && + (webviewParams!.onGeolocationPermissionsShowPrompt != + null || + // ignore: deprecated_member_use_from_same_package + webviewParams! + .androidOnGeolocationPermissionsShowPrompt != + null)) || + _inAppBrowserEventHandler != null) { + String origin = call.arguments["origin"]; + + if (webviewParams != null) { + if (webviewParams!.onGeolocationPermissionsShowPrompt != + null) + return (await webviewParams! + .onGeolocationPermissionsShowPrompt!(this, origin)) + ?.toMap(); + else { + return (await params + .webviewParams! + // ignore: deprecated_member_use_from_same_package + .androidOnGeolocationPermissionsShowPrompt!(this, origin)) + ?.toMap(); + } + } else { + return ((await _inAppBrowserEventHandler!.onGeolocationPermissionsShowPrompt(origin)) ?? + (await _inAppBrowserEventHandler!.androidOnGeolocationPermissionsShowPrompt(origin))) + ?.toMap(); + } + } + break; + case "onGeolocationPermissionsHidePrompt": + if (webviewParams != null && + (webviewParams!.onGeolocationPermissionsHidePrompt != null || + // ignore: deprecated_member_use_from_same_package + webviewParams! + .androidOnGeolocationPermissionsHidePrompt != + null)) { + if (webviewParams!.onGeolocationPermissionsHidePrompt != null) + webviewParams!.onGeolocationPermissionsHidePrompt!(this); + else { + // ignore: deprecated_member_use_from_same_package + webviewParams! + .androidOnGeolocationPermissionsHidePrompt!(this); + } + } else if (_inAppBrowserEventHandler != null) { + _inAppBrowserEventHandler!.onGeolocationPermissionsHidePrompt(); + // ignore: deprecated_member_use_from_same_package + _inAppBrowserEventHandler!.androidOnGeolocationPermissionsHidePrompt(); + } + break; + case "shouldInterceptRequest": + if ((webviewParams != null && + (webviewParams!.shouldInterceptRequest != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidShouldInterceptRequest != + null)) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + WebResourceRequest request = WebResourceRequest.fromMap(arguments)!; + + if (webviewParams != null) { + if (webviewParams!.shouldInterceptRequest != null) + return (await webviewParams!.shouldInterceptRequest!( + this, request)) + ?.toMap(); + else { + // ignore: deprecated_member_use_from_same_package + return (await webviewParams! + .androidShouldInterceptRequest!(this, request)) + ?.toMap(); + } + } else { + return ((await _inAppBrowserEventHandler!.shouldInterceptRequest(request)) ?? + (await _inAppBrowserEventHandler!.androidShouldInterceptRequest(request))) + ?.toMap(); + } + } + break; + case "onRenderProcessUnresponsive": + if ((webviewParams != null && + (webviewParams!.onRenderProcessUnresponsive != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnRenderProcessUnresponsive != + null)) || + _inAppBrowserEventHandler != null) { + String? url = call.arguments["url"]; + WebUri? uri = url != null ? WebUri(url) : null; + + if (webviewParams != null) { + if (webviewParams!.onRenderProcessUnresponsive != null) + return (await webviewParams!.onRenderProcessUnresponsive!( + this, uri)) + ?.toNativeValue(); + else { + // ignore: deprecated_member_use_from_same_package + return (await webviewParams! + .androidOnRenderProcessUnresponsive!(this, uri)) + ?.toNativeValue(); + } + } else { + return ((await _inAppBrowserEventHandler!.onRenderProcessUnresponsive(uri)) ?? + (await _inAppBrowserEventHandler!.androidOnRenderProcessUnresponsive(uri))) + ?.toNativeValue(); + } + } + break; + case "onRenderProcessResponsive": + if ((webviewParams != null && + (webviewParams!.onRenderProcessResponsive != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnRenderProcessResponsive != + null)) || + _inAppBrowserEventHandler != null) { + String? url = call.arguments["url"]; + WebUri? uri = url != null ? WebUri(url) : null; + + if (webviewParams != null) { + if (webviewParams!.onRenderProcessResponsive != null) + return (await webviewParams!.onRenderProcessResponsive!( + this, uri)) + ?.toNativeValue(); + else { + // ignore: deprecated_member_use_from_same_package + return (await webviewParams! + .androidOnRenderProcessResponsive!(this, uri)) + ?.toNativeValue(); + } + } else { + return ((await _inAppBrowserEventHandler!.onRenderProcessResponsive(uri)) ?? + (await _inAppBrowserEventHandler!.androidOnRenderProcessResponsive(uri))) + ?.toNativeValue(); + } + } + break; + case "onRenderProcessGone": + if ((webviewParams != null && + (webviewParams!.onRenderProcessGone != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnRenderProcessGone != + null)) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + RenderProcessGoneDetail detail = + RenderProcessGoneDetail.fromMap(arguments)!; + + if (webviewParams != null) { + if (webviewParams!.onRenderProcessGone != null) + webviewParams!.onRenderProcessGone!(this, detail); + else { + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnRenderProcessGone!(this, detail); + } + } else if (_inAppBrowserEventHandler != null) { + _inAppBrowserEventHandler!.onRenderProcessGone(detail); + // ignore: deprecated_member_use_from_same_package + _inAppBrowserEventHandler!.androidOnRenderProcessGone(detail); + } + } + break; + case "onFormResubmission": + if ((webviewParams != null && + (webviewParams!.onFormResubmission != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnFormResubmission != null)) || + _inAppBrowserEventHandler != null) { + String? url = call.arguments["url"]; + WebUri? uri = url != null ? WebUri(url) : null; + + if (webviewParams != null) { + if (webviewParams!.onFormResubmission != null) + return (await webviewParams!.onFormResubmission!( + this, uri)) + ?.toNativeValue(); + else { + // ignore: deprecated_member_use_from_same_package + return (await webviewParams!.androidOnFormResubmission!( + this, uri)) + ?.toNativeValue(); + } + } else { + return ((await _inAppBrowserEventHandler!.onFormResubmission(uri)) ?? + // ignore: deprecated_member_use_from_same_package + (await _inAppBrowserEventHandler!.androidOnFormResubmission(uri))) + ?.toNativeValue(); + } + } + break; + case "onZoomScaleChanged": + if ((webviewParams != null && + // ignore: deprecated_member_use_from_same_package + (webviewParams!.androidOnScaleChanged != null || + webviewParams!.onZoomScaleChanged != null)) || + _inAppBrowserEventHandler != null) { + double oldScale = call.arguments["oldScale"]; + double newScale = call.arguments["newScale"]; + + if (webviewParams != null) { + if (webviewParams!.onZoomScaleChanged != null) + webviewParams!.onZoomScaleChanged!( + this, oldScale, newScale); + else { + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnScaleChanged!( + this, oldScale, newScale); + } + } else { + _inAppBrowserEventHandler!.onZoomScaleChanged(oldScale, newScale); + // ignore: deprecated_member_use_from_same_package + _inAppBrowserEventHandler!.androidOnScaleChanged(oldScale, newScale); + } + } + break; + case "onReceivedIcon": + if ((webviewParams != null && + (webviewParams!.onReceivedIcon != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnReceivedIcon != null)) || + _inAppBrowserEventHandler != null) { + Uint8List icon = + Uint8List.fromList(call.arguments["icon"].cast()); + + if (webviewParams != null) { + if (webviewParams!.onReceivedIcon != null) + webviewParams!.onReceivedIcon!(this, icon); + else { + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnReceivedIcon!(this, icon); + } + } else { + _inAppBrowserEventHandler!.onReceivedIcon(icon); + // ignore: deprecated_member_use_from_same_package + _inAppBrowserEventHandler!.androidOnReceivedIcon(icon); + } + } + break; + case "onReceivedTouchIconUrl": + if ((webviewParams != null && + (webviewParams!.onReceivedTouchIconUrl != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnReceivedTouchIconUrl != + null)) || + _inAppBrowserEventHandler != null) { + String url = call.arguments["url"]; + bool precomposed = call.arguments["precomposed"]; + WebUri uri = WebUri(url); + + if (webviewParams != null) { + if (webviewParams!.onReceivedTouchIconUrl != null) + webviewParams!.onReceivedTouchIconUrl!( + this, uri, precomposed); + else { + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnReceivedTouchIconUrl!( + this, uri, precomposed); + } + } else { + _inAppBrowserEventHandler!.onReceivedTouchIconUrl(uri, precomposed); + // ignore: deprecated_member_use_from_same_package + _inAppBrowserEventHandler!.androidOnReceivedTouchIconUrl(uri, precomposed); + } + } + break; + case "onJsAlert": + if ((webviewParams != null && + webviewParams!.onJsAlert != null) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + JsAlertRequest jsAlertRequest = JsAlertRequest.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.onJsAlert != null) + return (await webviewParams!.onJsAlert!( + this, jsAlertRequest)) + ?.toMap(); + else + return (await _inAppBrowserEventHandler!.onJsAlert(jsAlertRequest))?.toMap(); + } + break; + case "onJsConfirm": + if ((webviewParams != null && + webviewParams!.onJsConfirm != null) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + JsConfirmRequest jsConfirmRequest = + JsConfirmRequest.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.onJsConfirm != null) + return (await webviewParams!.onJsConfirm!( + this, jsConfirmRequest)) + ?.toMap(); + else + return (await _inAppBrowserEventHandler!.onJsConfirm(jsConfirmRequest)) + ?.toMap(); + } + break; + case "onJsPrompt": + if ((webviewParams != null && + webviewParams!.onJsPrompt != null) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + JsPromptRequest jsPromptRequest = JsPromptRequest.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.onJsPrompt != null) + return (await webviewParams!.onJsPrompt!( + this, jsPromptRequest)) + ?.toMap(); + else + return (await _inAppBrowserEventHandler!.onJsPrompt(jsPromptRequest))?.toMap(); + } + break; + case "onJsBeforeUnload": + if ((webviewParams != null && + (webviewParams!.onJsBeforeUnload != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnJsBeforeUnload != null)) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + JsBeforeUnloadRequest jsBeforeUnloadRequest = + JsBeforeUnloadRequest.fromMap(arguments)!; + + if (webviewParams != null) { + if (webviewParams!.onJsBeforeUnload != null) + return (await webviewParams!.onJsBeforeUnload!( + this, jsBeforeUnloadRequest)) + ?.toMap(); + else { + // ignore: deprecated_member_use_from_same_package + return (await webviewParams!.androidOnJsBeforeUnload!( + this, jsBeforeUnloadRequest)) + ?.toMap(); + } + } else { + return ((await _inAppBrowserEventHandler!.onJsBeforeUnload(jsBeforeUnloadRequest)) ?? + (await _inAppBrowserEventHandler!.androidOnJsBeforeUnload(jsBeforeUnloadRequest))) + ?.toMap(); + } + } + break; + case "onSafeBrowsingHit": + if ((webviewParams != null && + (webviewParams!.onSafeBrowsingHit != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnSafeBrowsingHit != null)) || + _inAppBrowserEventHandler != null) { + String url = call.arguments["url"]; + SafeBrowsingThreat? threatType = + SafeBrowsingThreat.fromNativeValue(call.arguments["threatType"]); + WebUri uri = WebUri(url); + + if (webviewParams != null) { + if (webviewParams!.onSafeBrowsingHit != null) + return (await webviewParams!.onSafeBrowsingHit!( + this, uri, threatType)) + ?.toMap(); + else { + // ignore: deprecated_member_use_from_same_package + return (await webviewParams!.androidOnSafeBrowsingHit!( + this, uri, threatType)) + ?.toMap(); + } + } else { + return ((await _inAppBrowserEventHandler!.onSafeBrowsingHit(uri, threatType)) ?? + (await _inAppBrowserEventHandler!.androidOnSafeBrowsingHit(uri, threatType))) + ?.toMap(); + } + } + break; + case "onReceivedLoginRequest": + if ((webviewParams != null && + (webviewParams!.onReceivedLoginRequest != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnReceivedLoginRequest != + null)) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + LoginRequest loginRequest = LoginRequest.fromMap(arguments)!; + + if (webviewParams != null) { + if (webviewParams!.onReceivedLoginRequest != null) + webviewParams!.onReceivedLoginRequest!(this, loginRequest); + else { + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnReceivedLoginRequest!( + this, loginRequest); + } + } else { + _inAppBrowserEventHandler!.onReceivedLoginRequest(loginRequest); + // ignore: deprecated_member_use_from_same_package + _inAppBrowserEventHandler!.androidOnReceivedLoginRequest(loginRequest); + } + } + break; + case "onPermissionRequestCanceled": + if ((webviewParams != null && + webviewParams!.onPermissionRequestCanceled != null) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + PermissionRequest permissionRequest = + PermissionRequest.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.onPermissionRequestCanceled != null) + webviewParams!.onPermissionRequestCanceled!( + this, permissionRequest); + else + _inAppBrowserEventHandler!.onPermissionRequestCanceled(permissionRequest); + } + break; + case "onRequestFocus": + if ((webviewParams != null && + webviewParams!.onRequestFocus != null) || + _inAppBrowserEventHandler != null) { + if (webviewParams != null && + webviewParams!.onRequestFocus != null) + webviewParams!.onRequestFocus!(this); + else + _inAppBrowserEventHandler!.onRequestFocus(); + } + break; + case "onReceivedHttpAuthRequest": + if ((webviewParams != null && + webviewParams!.onReceivedHttpAuthRequest != null) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + HttpAuthenticationChallenge challenge = + HttpAuthenticationChallenge.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.onReceivedHttpAuthRequest != null) + return (await webviewParams!.onReceivedHttpAuthRequest!( + this, challenge)) + ?.toMap(); + else + return (await _inAppBrowserEventHandler!.onReceivedHttpAuthRequest(challenge)) + ?.toMap(); + } + break; + case "onReceivedServerTrustAuthRequest": + if ((webviewParams != null && + webviewParams!.onReceivedServerTrustAuthRequest != + null) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + ServerTrustChallenge challenge = + ServerTrustChallenge.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.onReceivedServerTrustAuthRequest != null) + return (await webviewParams! + .onReceivedServerTrustAuthRequest!(this, challenge)) + ?.toMap(); + else + return (await _inAppBrowserEventHandler!.onReceivedServerTrustAuthRequest(challenge)) + ?.toMap(); + } + break; + case "onReceivedClientCertRequest": + if ((webviewParams != null && + webviewParams!.onReceivedClientCertRequest != null) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + ClientCertChallenge challenge = + ClientCertChallenge.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.onReceivedClientCertRequest != null) + return (await webviewParams!.onReceivedClientCertRequest!( + this, challenge)) + ?.toMap(); + else + return (await _inAppBrowserEventHandler!.onReceivedClientCertRequest(challenge)) + ?.toMap(); + } + break; + case "onFindResultReceived": + if ((webviewParams != null && + (webviewParams!.onFindResultReceived != null || + (webviewParams!.findInteractionController != null && + webviewParams!.findInteractionController!.params + .onFindResultReceived != + null))) || + _inAppBrowserEventHandler != null) { + int activeMatchOrdinal = call.arguments["activeMatchOrdinal"]; + int numberOfMatches = call.arguments["numberOfMatches"]; + bool isDoneCounting = call.arguments["isDoneCounting"]; + if (webviewParams != null) { + if (webviewParams!.findInteractionController != null && + webviewParams!.findInteractionController!.params + .onFindResultReceived != + null) + webviewParams!.findInteractionController!.params + .onFindResultReceived!( + webviewParams!.findInteractionController!, + activeMatchOrdinal, + numberOfMatches, + isDoneCounting); + else + webviewParams!.onFindResultReceived!( + this, activeMatchOrdinal, numberOfMatches, isDoneCounting); + } else { + if (_inAppBrowser!.findInteractionController != null && + _inAppBrowser! + .findInteractionController!.onFindResultReceived != + null) + _inAppBrowser!.findInteractionController!.onFindResultReceived!( + webviewParams!.findInteractionController!, + activeMatchOrdinal, + numberOfMatches, + isDoneCounting); + else + _inAppBrowserEventHandler!.onFindResultReceived( + activeMatchOrdinal, numberOfMatches, isDoneCounting); + } + } + break; + case "onPermissionRequest": + if ((webviewParams != null && + (webviewParams!.onPermissionRequest != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.androidOnPermissionRequest != + null)) || + _inAppBrowserEventHandler != null) { + String origin = call.arguments["origin"]; + List resources = call.arguments["resources"].cast(); + + Map arguments = + call.arguments.cast(); + PermissionRequest permissionRequest = + PermissionRequest.fromMap(arguments)!; + + if (webviewParams != null) { + if (webviewParams!.onPermissionRequest != null) + return (await webviewParams!.onPermissionRequest!( + this, permissionRequest)) + ?.toMap(); + else { + // ignore: deprecated_member_use_from_same_package + return (await webviewParams!.androidOnPermissionRequest!( + this, origin, resources)) + ?.toMap(); + } + } else { + return (await _inAppBrowserEventHandler!.onPermissionRequest(permissionRequest)) + ?.toMap() ?? + (await _inAppBrowserEventHandler!.androidOnPermissionRequest(origin, resources)) + ?.toMap(); + } + } + break; + case "onUpdateVisitedHistory": + if ((webviewParams != null && + webviewParams!.onUpdateVisitedHistory != null) || + _inAppBrowserEventHandler != null) { + String? url = call.arguments["url"]; + bool? isReload = call.arguments["isReload"]; + WebUri? uri = url != null ? WebUri(url) : null; + if (webviewParams != null && + webviewParams!.onUpdateVisitedHistory != null) + webviewParams!.onUpdateVisitedHistory!(this, uri, isReload); + else + _inAppBrowserEventHandler!.onUpdateVisitedHistory(uri, isReload); + } + break; + case "onWebContentProcessDidTerminate": + if (webviewParams != null && + (webviewParams!.onWebContentProcessDidTerminate != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.iosOnWebContentProcessDidTerminate != + null)) { + if (webviewParams!.onWebContentProcessDidTerminate != null) + webviewParams!.onWebContentProcessDidTerminate!(this); + else { + // ignore: deprecated_member_use_from_same_package + webviewParams!.iosOnWebContentProcessDidTerminate!(this); + } + } else if (_inAppBrowserEventHandler != null) { + _inAppBrowserEventHandler!.onWebContentProcessDidTerminate(); + // ignore: deprecated_member_use_from_same_package + _inAppBrowserEventHandler!.iosOnWebContentProcessDidTerminate(); + } + break; + case "onPageCommitVisible": + if ((webviewParams != null && + webviewParams!.onPageCommitVisible != null) || + _inAppBrowserEventHandler != null) { + String? url = call.arguments["url"]; + WebUri? uri = url != null ? WebUri(url) : null; + if (webviewParams != null && + webviewParams!.onPageCommitVisible != null) + webviewParams!.onPageCommitVisible!(this, uri); + else + _inAppBrowserEventHandler!.onPageCommitVisible(uri); + } + break; + case "onDidReceiveServerRedirectForProvisionalNavigation": + if (webviewParams != null && + (webviewParams! + .onDidReceiveServerRedirectForProvisionalNavigation != + null || + params + .webviewParams! + // ignore: deprecated_member_use_from_same_package + .iosOnDidReceiveServerRedirectForProvisionalNavigation != + null)) { + if (webviewParams! + .onDidReceiveServerRedirectForProvisionalNavigation != + null) + webviewParams! + .onDidReceiveServerRedirectForProvisionalNavigation!(this); + else { + params + .webviewParams! + // ignore: deprecated_member_use_from_same_package + .iosOnDidReceiveServerRedirectForProvisionalNavigation!(this); + } + } else if (_inAppBrowserEventHandler != null) { + _inAppBrowserEventHandler!.onDidReceiveServerRedirectForProvisionalNavigation(); + _inAppBrowserEventHandler!.iosOnDidReceiveServerRedirectForProvisionalNavigation(); + } + break; + case "onNavigationResponse": + if ((webviewParams != null && + (webviewParams!.onNavigationResponse != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.iosOnNavigationResponse != null)) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + // ignore: deprecated_member_use_from_same_package + IOSWKNavigationResponse iosOnNavigationResponse = + // ignore: deprecated_member_use_from_same_package + IOSWKNavigationResponse.fromMap(arguments)!; + + NavigationResponse navigationResponse = + NavigationResponse.fromMap(arguments)!; + + if (webviewParams != null) { + if (webviewParams!.onNavigationResponse != null) + return (await webviewParams!.onNavigationResponse!( + this, navigationResponse)) + ?.toNativeValue(); + else { + // ignore: deprecated_member_use_from_same_package + return (await webviewParams!.iosOnNavigationResponse!( + this, iosOnNavigationResponse)) + ?.toNativeValue(); + } + } else { + return (await _inAppBrowserEventHandler!.onNavigationResponse(navigationResponse)) + ?.toNativeValue() ?? + (await _inAppBrowserEventHandler!.iosOnNavigationResponse(iosOnNavigationResponse)) + ?.toNativeValue(); + } + } + break; + case "shouldAllowDeprecatedTLS": + if ((webviewParams != null && + (webviewParams!.shouldAllowDeprecatedTLS != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.iosShouldAllowDeprecatedTLS != + null)) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + URLAuthenticationChallenge challenge = + URLAuthenticationChallenge.fromMap(arguments)!; + + if (webviewParams != null) { + if (webviewParams!.shouldAllowDeprecatedTLS != null) + return (await webviewParams!.shouldAllowDeprecatedTLS!( + this, challenge)) + ?.toNativeValue(); + else { + // ignore: deprecated_member_use_from_same_package + return (await webviewParams!.iosShouldAllowDeprecatedTLS!( + this, challenge)) + ?.toNativeValue(); + } + } else { + return (await _inAppBrowserEventHandler!.shouldAllowDeprecatedTLS(challenge)) + ?.toNativeValue() ?? + // ignore: deprecated_member_use_from_same_package + (await _inAppBrowserEventHandler!.iosShouldAllowDeprecatedTLS(challenge)) + ?.toNativeValue(); + } + } + break; + case "onLongPressHitTestResult": + if ((webviewParams != null && + webviewParams!.onLongPressHitTestResult != null) || + _inAppBrowserEventHandler != null) { + Map arguments = + call.arguments.cast(); + InAppWebViewHitTestResult hitTestResult = + InAppWebViewHitTestResult.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.onLongPressHitTestResult != null) + webviewParams!.onLongPressHitTestResult!( + this, hitTestResult); + else + _inAppBrowserEventHandler!.onLongPressHitTestResult(hitTestResult); + } + break; + case "onCreateContextMenu": + ContextMenu? contextMenu; + if (webviewParams != null && + webviewParams!.contextMenu != null) { + contextMenu = webviewParams!.contextMenu; + } else if (_inAppBrowserEventHandler != null && + _inAppBrowser!.contextMenu != null) { + contextMenu = _inAppBrowser!.contextMenu; + } + + if (contextMenu != null && contextMenu.onCreateContextMenu != null) { + Map arguments = + call.arguments.cast(); + InAppWebViewHitTestResult hitTestResult = + InAppWebViewHitTestResult.fromMap(arguments)!; + + contextMenu.onCreateContextMenu!(hitTestResult); + } + break; + case "onHideContextMenu": + ContextMenu? contextMenu; + if (webviewParams != null && + webviewParams!.contextMenu != null) { + contextMenu = webviewParams!.contextMenu; + } else if (_inAppBrowserEventHandler != null && + _inAppBrowser!.contextMenu != null) { + contextMenu = _inAppBrowser!.contextMenu; + } + + if (contextMenu != null && contextMenu.onHideContextMenu != null) { + contextMenu.onHideContextMenu!(); + } + break; + case "onContextMenuActionItemClicked": + ContextMenu? contextMenu; + if (webviewParams != null && + webviewParams!.contextMenu != null) { + contextMenu = webviewParams!.contextMenu; + } else if (_inAppBrowserEventHandler != null && + _inAppBrowser!.contextMenu != null) { + contextMenu = _inAppBrowser!.contextMenu; + } + + if (contextMenu != null) { + int? androidId = call.arguments["androidId"]; + String? iosId = call.arguments["iosId"]; + dynamic id = call.arguments["id"]; + String title = call.arguments["title"]; + + ContextMenuItem menuItemClicked = ContextMenuItem( + id: id, + // ignore: deprecated_member_use_from_same_package + androidId: androidId, + // ignore: deprecated_member_use_from_same_package + iosId: iosId, + title: title, + action: null); + + for (var menuItem in contextMenu.menuItems) { + if (menuItem.id == id) { + menuItemClicked = menuItem; + if (menuItem.action != null) { + menuItem.action!(); + } + break; + } + } + + if (contextMenu.onContextMenuActionItemClicked != null) { + contextMenu.onContextMenuActionItemClicked!(menuItemClicked); + } + } + break; + case "onEnterFullscreen": + if (webviewParams != null && + webviewParams!.onEnterFullscreen != null) + webviewParams!.onEnterFullscreen!(this); + else if (_inAppBrowserEventHandler != null) _inAppBrowserEventHandler!.onEnterFullscreen(); + break; + case "onExitFullscreen": + if (webviewParams != null && + webviewParams!.onExitFullscreen != null) + webviewParams!.onExitFullscreen!(this); + else if (_inAppBrowserEventHandler != null) _inAppBrowserEventHandler!.onExitFullscreen(); + break; + case "onOverScrolled": + if ((webviewParams != null && + webviewParams!.onOverScrolled != null) || + _inAppBrowserEventHandler != null) { + int x = call.arguments["x"]; + int y = call.arguments["y"]; + bool clampedX = call.arguments["clampedX"]; + bool clampedY = call.arguments["clampedY"]; + + if (webviewParams != null && + webviewParams!.onOverScrolled != null) + webviewParams!.onOverScrolled!( + this, x, y, clampedX, clampedY); + else + _inAppBrowserEventHandler!.onOverScrolled(x, y, clampedX, clampedY); + } + break; + case "onWindowFocus": + if (webviewParams != null && + webviewParams!.onWindowFocus != null) + webviewParams!.onWindowFocus!(this); + else if (_inAppBrowserEventHandler != null) _inAppBrowserEventHandler!.onWindowFocus(); + break; + case "onWindowBlur": + if (webviewParams != null && + webviewParams!.onWindowBlur != null) + webviewParams!.onWindowBlur!(this); + else if (_inAppBrowserEventHandler != null) _inAppBrowserEventHandler!.onWindowBlur(); + break; + case "onPrintRequest": + if ((webviewParams != null && + (webviewParams!.onPrintRequest != null || + // ignore: deprecated_member_use_from_same_package + webviewParams!.onPrint != null)) || + _inAppBrowserEventHandler != null) { + String? url = call.arguments["url"]; + String? printJobId = call.arguments["printJobId"]; + WebUri? uri = url != null ? WebUri(url) : null; + AndroidPrintJobController? printJob = printJobId != null + ? AndroidPrintJobController( + AndroidPrintJobControllerCreationParams(id: printJobId)) + : null; + + if (webviewParams != null) { + if (webviewParams!.onPrintRequest != null) + return await webviewParams!.onPrintRequest!( + this, uri, printJob); + else { + // ignore: deprecated_member_use_from_same_package + webviewParams!.onPrint!(this, uri); + return false; + } + } else { + // ignore: deprecated_member_use_from_same_package + _inAppBrowserEventHandler!.onPrint(uri); + return await _inAppBrowserEventHandler!.onPrintRequest(uri, printJob); + } + } + break; + case "onInjectedScriptLoaded": + String id = call.arguments[0]; + var onLoadCallback = _injectedScriptsFromURL[id]?.onLoad; + if ((webviewParams != null || _inAppBrowserEventHandler != null) && + onLoadCallback != null) { + onLoadCallback(); + } + break; + case "onInjectedScriptError": + String id = call.arguments[0]; + var onErrorCallback = _injectedScriptsFromURL[id]?.onError; + if ((webviewParams != null || _inAppBrowserEventHandler != null) && + onErrorCallback != null) { + onErrorCallback(); + } + break; + case "onCameraCaptureStateChanged": + if ((webviewParams != null && + webviewParams!.onCameraCaptureStateChanged != null) || + _inAppBrowserEventHandler != null) { + var oldState = + MediaCaptureState.fromNativeValue(call.arguments["oldState"]); + var newState = + MediaCaptureState.fromNativeValue(call.arguments["newState"]); + + if (webviewParams != null && + webviewParams!.onCameraCaptureStateChanged != null) + webviewParams!.onCameraCaptureStateChanged!( + this, oldState, newState); + else + _inAppBrowserEventHandler!.onCameraCaptureStateChanged(oldState, newState); + } + break; + case "onMicrophoneCaptureStateChanged": + if ((webviewParams != null && + webviewParams!.onMicrophoneCaptureStateChanged != + null) || + _inAppBrowserEventHandler != null) { + var oldState = + MediaCaptureState.fromNativeValue(call.arguments["oldState"]); + var newState = + MediaCaptureState.fromNativeValue(call.arguments["newState"]); + + if (webviewParams != null && + webviewParams!.onMicrophoneCaptureStateChanged != null) + webviewParams!.onMicrophoneCaptureStateChanged!( + this, oldState, newState); + else + _inAppBrowserEventHandler!.onMicrophoneCaptureStateChanged(oldState, newState); + } + break; + case "onContentSizeChanged": + if ((webviewParams != null && + webviewParams!.onContentSizeChanged != null) || + _inAppBrowserEventHandler != null) { + var oldContentSize = MapSize.fromMap( + call.arguments["oldContentSize"]?.cast())!; + var newContentSize = MapSize.fromMap( + call.arguments["newContentSize"]?.cast())!; + + if (webviewParams != null && + webviewParams!.onContentSizeChanged != null) + webviewParams!.onContentSizeChanged!( + this, oldContentSize, newContentSize); + else + _inAppBrowserEventHandler!.onContentSizeChanged(oldContentSize, newContentSize); + } + break; + case "onCallJsHandler": + String handlerName = call.arguments["handlerName"]; + // decode args to json + List args = jsonDecode(call.arguments["args"]); + + _debugLog(handlerName, args); + + switch (handlerName) { + case "onLoadResource": + if ((webviewParams != null && + webviewParams!.onLoadResource != null) || + _inAppBrowserEventHandler != null) { + Map arguments = args[0].cast(); + arguments["startTime"] = arguments["startTime"] is int + ? arguments["startTime"].toDouble() + : arguments["startTime"]; + arguments["duration"] = arguments["duration"] is int + ? arguments["duration"].toDouble() + : arguments["duration"]; + + var response = LoadedResource.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.onLoadResource != null) + webviewParams!.onLoadResource!(this, response); + else + _inAppBrowserEventHandler!.onLoadResource(response); + } + return null; + case "shouldInterceptAjaxRequest": + if ((webviewParams != null && + webviewParams!.shouldInterceptAjaxRequest != null) || + _inAppBrowserEventHandler != null) { + Map arguments = args[0].cast(); + AjaxRequest request = AjaxRequest.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.shouldInterceptAjaxRequest != null) + return jsonEncode(await params + .webviewParams!.shouldInterceptAjaxRequest!(this, request)); + else + return jsonEncode( + await _inAppBrowserEventHandler!.shouldInterceptAjaxRequest(request)); + } + return null; + case "onAjaxReadyStateChange": + if ((webviewParams != null && + webviewParams!.onAjaxReadyStateChange != null) || + _inAppBrowserEventHandler != null) { + Map arguments = args[0].cast(); + AjaxRequest request = AjaxRequest.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.onAjaxReadyStateChange != null) + return (await webviewParams!.onAjaxReadyStateChange!( + this, request)) + ?.toNativeValue(); + else + return (await _inAppBrowserEventHandler!.onAjaxReadyStateChange(request)) + ?.toNativeValue(); + } + return null; + case "onAjaxProgress": + if ((webviewParams != null && + webviewParams!.onAjaxProgress != null) || + _inAppBrowserEventHandler != null) { + Map arguments = args[0].cast(); + AjaxRequest request = AjaxRequest.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.onAjaxProgress != null) + return (await webviewParams!.onAjaxProgress!( + this, request)) + ?.toNativeValue(); + else + return (await _inAppBrowserEventHandler!.onAjaxProgress(request)) + ?.toNativeValue(); + } + return null; + case "shouldInterceptFetchRequest": + if ((webviewParams != null && + webviewParams!.shouldInterceptFetchRequest != + null) || + _inAppBrowserEventHandler != null) { + Map arguments = args[0].cast(); + FetchRequest request = FetchRequest.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.shouldInterceptFetchRequest != null) + return jsonEncode(await webviewParams! + .shouldInterceptFetchRequest!(this, request)); + else + return jsonEncode( + await _inAppBrowserEventHandler!.shouldInterceptFetchRequest(request)); + } + return null; + case "onWindowFocus": + if (webviewParams != null && + webviewParams!.onWindowFocus != null) + webviewParams!.onWindowFocus!(this); + else if (_inAppBrowserEventHandler != null) _inAppBrowserEventHandler!.onWindowFocus(); + return null; + case "onWindowBlur": + if (webviewParams != null && + webviewParams!.onWindowBlur != null) + webviewParams!.onWindowBlur!(this); + else if (_inAppBrowserEventHandler != null) _inAppBrowserEventHandler!.onWindowBlur(); + return null; + case "onInjectedScriptLoaded": + String id = args[0]; + var onLoadCallback = _injectedScriptsFromURL[id]?.onLoad; + if ((webviewParams != null || _inAppBrowserEventHandler != null) && + onLoadCallback != null) { + onLoadCallback(); + } + return null; + case "onInjectedScriptError": + String id = args[0]; + var onErrorCallback = _injectedScriptsFromURL[id]?.onError; + if ((webviewParams != null || _inAppBrowserEventHandler != null) && + onErrorCallback != null) { + onErrorCallback(); + } + return null; + } + + if (_javaScriptHandlersMap.containsKey(handlerName)) { + // convert result to json + try { + return jsonEncode(await _javaScriptHandlersMap[handlerName]!(args)); + } catch (error, stacktrace) { + developer.log(error.toString() + '\n' + stacktrace.toString(), + name: 'JavaScript Handler "$handlerName"'); + throw Exception(error.toString().replaceFirst('Exception: ', '')); + } + } + break; + default: + throw UnimplementedError("Unimplemented ${call.method} method"); + } + return null; + } + + ///Gets the URL for the current page. + ///This is not always the same as the URL passed to [WebView.onLoadStart] because although the load for that URL has begun, the current page may not have changed. + /// + ///**NOTE for Web**: If `window.location.href` isn't accessible inside the iframe, + ///it will return the current value of the `iframe.src` attribute. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getUrl](https://developer.android.com/reference/android/webkit/WebView#getUrl())) + ///- iOS ([Official API - WKWebView.url](https://developer.apple.com/documentation/webkit/wkwebview/1415005-url)) + ///- MacOS ([Official API - WKWebView.url](https://developer.apple.com/documentation/webkit/wkwebview/1415005-url)) + ///- Web + Future getUrl() async { + Map args = {}; + String? url = await channel?.invokeMethod('getUrl', args); + return url != null ? WebUri(url) : null; + } + + ///Gets the title for the current page. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getTitle](https://developer.android.com/reference/android/webkit/WebView#getTitle())) + ///- iOS ([Official API - WKWebView.title](https://developer.apple.com/documentation/webkit/wkwebview/1415015-title)) + ///- MacOS ([Official API - WKWebView.title](https://developer.apple.com/documentation/webkit/wkwebview/1415015-title)) + ///- Web + Future getTitle() async { + Map args = {}; + return await channel?.invokeMethod('getTitle', args); + } + + ///Gets the progress for the current page. The progress value is between 0 and 100. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getProgress](https://developer.android.com/reference/android/webkit/WebView#getProgress())) + ///- iOS ([Official API - WKWebView.estimatedProgress](https://developer.apple.com/documentation/webkit/wkwebview/1415007-estimatedprogress)) + ///- MacOS ([Official API - WKWebView.estimatedProgress](https://developer.apple.com/documentation/webkit/wkwebview/1415007-estimatedprogress)) + Future getProgress() async { + Map args = {}; + return await channel?.invokeMethod('getProgress', args); + } + + ///Gets the content html of the page. It first tries to get the content through javascript. + ///If this doesn't work, it tries to get the content reading the file: + ///- checking if it is an asset (`file:///`) or + ///- downloading it using an `HttpClient` through the WebView's current url. + /// + ///Returns `null` if it was unable to get it. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future getHtml() async { + String? html; + + InAppWebViewSettings? settings = await getSettings(); + if (settings != null && settings.javaScriptEnabled == true) { + html = await evaluateJavascript( + source: "window.document.getElementsByTagName('html')[0].outerHTML;"); + if (html != null && html.isNotEmpty) return html; + } + + var webviewUrl = await getUrl(); + if (webviewUrl == null) { + return html; + } + + if (webviewUrl.isScheme("file")) { + var assetPathSplitted = webviewUrl.toString().split("/flutter_assets/"); + var assetPath = assetPathSplitted[assetPathSplitted.length - 1]; + try { + var bytes = await rootBundle.load(assetPath); + html = utf8.decode(bytes.buffer.asUint8List()); + } catch (e) {} + } else { + try { + HttpClient client = HttpClient(); + var htmlRequest = await client.getUrl(webviewUrl); + html = + await (await htmlRequest.close()).transform(Utf8Decoder()).join(); + } catch (e) { + developer.log(e.toString(), name: this.runtimeType.toString()); + } + } + + return html; + } + + ///Gets the list of all favicons for the current page. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future> getFavicons() async { + List favicons = []; + + var webviewUrl = await getUrl(); + + if (webviewUrl == null) { + return favicons; + } + + String? manifestUrl; + + var html = await getHtml(); + if (html == null || html.isEmpty) { + return favicons; + } + var assetPathBase; + + if (webviewUrl.isScheme("file")) { + var assetPathSplitted = webviewUrl.toString().split("/flutter_assets/"); + assetPathBase = assetPathSplitted[0] + "/flutter_assets/"; + } + + InAppWebViewSettings? settings = await getSettings(); + if (settings != null && settings.javaScriptEnabled == true) { + List> links = (await evaluateJavascript(source: """ +(function() { + var linkNodes = document.head.getElementsByTagName("link"); + var links = []; + for (var i = 0; i < linkNodes.length; i++) { + var linkNode = linkNodes[i]; + if (linkNode.rel === 'manifest') { + links.push( + { + rel: linkNode.rel, + href: linkNode.href, + sizes: null + } + ); + } else if (linkNode.rel != null && linkNode.rel.indexOf('icon') >= 0) { + links.push( + { + rel: linkNode.rel, + href: linkNode.href, + sizes: linkNode.sizes != null && linkNode.sizes.value != "" ? linkNode.sizes.value : null + } + ); + } + } + return links; +})(); +"""))?.cast>() ?? []; + for (var link in links) { + if (link["rel"] == "manifest") { + manifestUrl = link["href"]; + if (!_isUrlAbsolute(manifestUrl!)) { + if (manifestUrl.startsWith("/")) { + manifestUrl = manifestUrl.substring(1); + } + manifestUrl = ((assetPathBase == null) + ? webviewUrl.scheme + "://" + webviewUrl.host + "/" + : assetPathBase) + + manifestUrl; + } + continue; + } + favicons.addAll(_createFavicons(webviewUrl, assetPathBase, link["href"], + link["rel"], link["sizes"], false)); + } + } + + // try to get /favicon.ico + try { + HttpClient client = HttpClient(); + var faviconUrl = + webviewUrl.scheme + "://" + webviewUrl.host + "/favicon.ico"; + var faviconUri = WebUri(faviconUrl); + var headRequest = await client.headUrl(faviconUri); + var headResponse = await headRequest.close(); + if (headResponse.statusCode == 200) { + favicons.add(Favicon(url: faviconUri, rel: "shortcut icon")); + } + } catch (e) { + developer.log("/favicon.ico file not found: " + e.toString(), + name: this.runtimeType.toString()); + } + + // try to get the manifest file + HttpClientRequest? manifestRequest; + HttpClientResponse? manifestResponse; + bool manifestFound = false; + if (manifestUrl == null) { + manifestUrl = + webviewUrl.scheme + "://" + webviewUrl.host + "/manifest.json"; + } + try { + HttpClient client = HttpClient(); + manifestRequest = await client.getUrl(Uri.parse(manifestUrl)); + manifestResponse = await manifestRequest.close(); + manifestFound = manifestResponse.statusCode == 200 && + manifestResponse.headers.contentType?.mimeType == "application/json"; + } catch (e) { + developer.log("Manifest file not found: " + e.toString(), + name: this.runtimeType.toString()); + } + + if (manifestFound) { + try { + Map manifest = json + .decode(await manifestResponse!.transform(Utf8Decoder()).join()); + if (manifest.containsKey("icons")) { + for (Map icon in manifest["icons"]) { + favicons.addAll(_createFavicons(webviewUrl, assetPathBase, + icon["src"], icon["rel"], icon["sizes"], true)); + } + } + } on FormatException catch (_) { + /// The [manifestResponse] might not has a valid JSON string, catch and + /// ignore the error + } + } + + return favicons; + } + + bool _isUrlAbsolute(String url) { + return url.startsWith("http://") || url.startsWith("https://"); + } + + List _createFavicons(WebUri url, String? assetPathBase, + String urlIcon, String? rel, String? sizes, bool isManifest) { + List favicons = []; + + List urlSplitted = urlIcon.split("/"); + if (!_isUrlAbsolute(urlIcon)) { + if (urlIcon.startsWith("/")) { + urlIcon = urlIcon.substring(1); + } + urlIcon = ((assetPathBase == null) + ? url.scheme + "://" + url.host + "/" + : assetPathBase) + + urlIcon; + } + if (isManifest) { + rel = (sizes != null) + ? urlSplitted[urlSplitted.length - 1] + .replaceFirst("-" + sizes, "") + .split(" ")[0] + .split(".")[0] + : null; + } + if (sizes != null && sizes.isNotEmpty && sizes != "any") { + List sizesSplitted = sizes.split(" "); + for (String size in sizesSplitted) { + int width = int.parse(size.split("x")[0]); + int height = int.parse(size.split("x")[1]); + favicons.add(Favicon( + url: WebUri(urlIcon), rel: rel, width: width, height: height)); + } + } else { + favicons.add( + Favicon(url: WebUri(urlIcon), rel: rel, width: null, height: null)); + } + + return favicons; + } + + ///Loads the given [urlRequest]. + /// + ///- [allowingReadAccessTo], used in combination with [urlRequest] (using the `file://` scheme), + ///it represents the URL from which to read the web content. + ///This URL must be a file-based URL (using the `file://` scheme). + ///Specify the same value as the URL parameter to prevent WebView from reading any other content. + ///Specify a directory to give WebView permission to read additional files in the specified directory. + ///**NOTE**: available only on iOS and MacOS. + /// + ///**NOTE for Android**: when loading an URL Request using "POST" method, headers are ignored. + /// + ///**NOTE for Web**: if method is "GET" and headers are empty, it will change the `src` of the iframe. + ///For all other cases it will try to create an XMLHttpRequest and load the result inside the iframe. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.loadUrl](https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String))). If method is "POST", [Official API - WebView.postUrl](https://developer.android.com/reference/android/webkit/WebView#postUrl(java.lang.String,%20byte[])) + ///- iOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load). If [allowingReadAccessTo] is used, [Official API - WKWebView.loadFileURL](https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl)) + ///- MacOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load). If [allowingReadAccessTo] is used, [Official API - WKWebView.loadFileURL](https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl)) + ///- Web + Future loadUrl( + {required URLRequest urlRequest, + @Deprecated('Use allowingReadAccessTo instead') + Uri? iosAllowingReadAccessTo, + WebUri? allowingReadAccessTo}) async { + assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty); + assert( + allowingReadAccessTo == null || allowingReadAccessTo.isScheme("file")); + assert(iosAllowingReadAccessTo == null || + iosAllowingReadAccessTo.isScheme("file")); + + Map args = {}; + args.putIfAbsent('urlRequest', () => urlRequest.toMap()); + args.putIfAbsent( + 'allowingReadAccessTo', + () => + allowingReadAccessTo?.toString() ?? + iosAllowingReadAccessTo?.toString()); + await channel?.invokeMethod('loadUrl', args); + } + + ///Loads the given [url] with [postData] (x-www-form-urlencoded) using `POST` method into this WebView. + /// + ///Example: + ///```dart + ///var postData = Uint8List.fromList(utf8.encode("firstname=Foo&surname=Bar")); + ///controller.postUrl(url: WebUri("https://www.example.com/"), postData: postData); + ///``` + /// + ///**NOTE for Web**: it will try to create an XMLHttpRequest and load the result inside the iframe. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.postUrl](https://developer.android.com/reference/android/webkit/WebView#postUrl(java.lang.String,%20byte[]))) + ///- iOS + ///- MacOS + ///- Web + Future postUrl( + {required WebUri url, required Uint8List postData}) async { + assert(url.toString().isNotEmpty); + Map args = {}; + args.putIfAbsent('url', () => url.toString()); + args.putIfAbsent('postData', () => postData); + await channel?.invokeMethod('postUrl', args); + } + + ///Loads the given [data] into this WebView, using [baseUrl] as the base URL for the content. + /// + ///- [mimeType] argument specifies the format of the data. The default value is `"text/html"`. + ///- [encoding] argument specifies the encoding of the data. The default value is `"utf8"`. + ///**NOTE**: not used on Web. + ///- [historyUrl] is an Android-specific argument that represents the URL to use as the history entry. The default value is `about:blank`. If non-null, this must be a valid URL. + ///**NOTE**: not used on Web. + ///- [allowingReadAccessTo], used in combination with [baseUrl] (using the `file://` scheme), + ///it represents the URL from which to read the web content. + ///This [baseUrl] must be a file-based URL (using the `file://` scheme). + ///Specify the same value as the [baseUrl] parameter to prevent WebView from reading any other content. + ///Specify a directory to give WebView permission to read additional files in the specified directory. + ///**NOTE**: available only on iOS and MacOS. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.loadDataWithBaseURL](https://developer.android.com/reference/android/webkit/WebView#loadDataWithBaseURL(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String))) + ///- iOS ([Official API - WKWebView.loadHTMLString](https://developer.apple.com/documentation/webkit/wkwebview/1415004-loadhtmlstring) or [Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1415011-load)) + ///- MacOS ([Official API - WKWebView.loadHTMLString](https://developer.apple.com/documentation/webkit/wkwebview/1415004-loadhtmlstring) or [Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1415011-load)) + ///- Web + Future loadData( + {required String data, + String mimeType = "text/html", + String encoding = "utf8", + WebUri? baseUrl, + @Deprecated('Use historyUrl instead') Uri? androidHistoryUrl, + WebUri? historyUrl, + @Deprecated('Use allowingReadAccessTo instead') + Uri? iosAllowingReadAccessTo, + WebUri? allowingReadAccessTo}) async { + assert( + allowingReadAccessTo == null || allowingReadAccessTo.isScheme("file")); + assert(iosAllowingReadAccessTo == null || + iosAllowingReadAccessTo.isScheme("file")); + + Map args = {}; + args.putIfAbsent('data', () => data); + args.putIfAbsent('mimeType', () => mimeType); + args.putIfAbsent('encoding', () => encoding); + args.putIfAbsent('baseUrl', () => baseUrl?.toString() ?? "about:blank"); + args.putIfAbsent( + 'historyUrl', + () => + historyUrl?.toString() ?? + androidHistoryUrl?.toString() ?? + "about:blank"); + args.putIfAbsent( + 'allowingReadAccessTo', + () => + allowingReadAccessTo?.toString() ?? + iosAllowingReadAccessTo?.toString()); + await channel?.invokeMethod('loadData', args); + } + + ///Loads the given [assetFilePath]. + /// + ///To be able to load your local files (assets, js, css, etc.), you need to add them in the `assets` section of the `pubspec.yaml` file, otherwise they cannot be found! + /// + ///Example of a `pubspec.yaml` file: + ///```yaml + ///... + /// + ///# The following section is specific to Flutter. + ///flutter: + /// + /// # The following line ensures that the Material Icons font is + /// # included with your application, so that you can use the icons in + /// # the material Icons class. + /// uses-material-design: true + /// + /// assets: + /// - assets/index.html + /// - assets/css/ + /// - assets/images/ + /// + ///... + ///``` + ///Example: + ///```dart + ///... + ///controller.loadFile(assetFilePath: "assets/index.html"); + ///... + ///``` + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.loadUrl](https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String))) + ///- iOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load)) + ///- MacOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load)) + ///- Web + Future loadFile({required String assetFilePath}) async { + assert(assetFilePath.isNotEmpty); + Map args = {}; + args.putIfAbsent('assetFilePath', () => assetFilePath); + await channel?.invokeMethod('loadFile', args); + } + + ///Reloads the WebView. + /// + ///**NOTE for Web**: if `window.location.reload()` is not accessible inside the iframe, it will reload using the iframe `src` attribute. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.reload](https://developer.android.com/reference/android/webkit/WebView#reload())) + ///- iOS ([Official API - WKWebView.reload](https://developer.apple.com/documentation/webkit/wkwebview/1414969-reload)) + ///- MacOS ([Official API - WKWebView.reload](https://developer.apple.com/documentation/webkit/wkwebview/1414969-reload)) + ///- Web ([Official API - Location.reload](https://developer.mozilla.org/en-US/docs/Web/API/Location/reload)) + Future reload() async { + Map args = {}; + await channel?.invokeMethod('reload', args); + } + + ///Goes back in the history of the WebView. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.goBack](https://developer.android.com/reference/android/webkit/WebView#goBack())) + ///- iOS ([Official API - WKWebView.goBack](https://developer.apple.com/documentation/webkit/wkwebview/1414952-goback)) + ///- MacOS ([Official API - WKWebView.goBack](https://developer.apple.com/documentation/webkit/wkwebview/1414952-goback)) + ///- Web ([Official API - History.back](https://developer.mozilla.org/en-US/docs/Web/API/History/back)) + Future goBack() async { + Map args = {}; + await channel?.invokeMethod('goBack', args); + } + + ///Returns a boolean value indicating whether the WebView can move backward. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.canGoBack](https://developer.android.com/reference/android/webkit/WebView#canGoBack())) + ///- iOS ([Official API - WKWebView.canGoBack](https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback)) + ///- MacOS ([Official API - WKWebView.canGoBack](https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback)) + Future canGoBack() async { + Map args = {}; + return await channel?.invokeMethod('canGoBack', args) ?? false; + } + + ///Goes forward in the history of the WebView. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.goForward](https://developer.android.com/reference/android/webkit/WebView#goForward())) + ///- iOS ([Official API - WKWebView.goForward](https://developer.apple.com/documentation/webkit/wkwebview/1414993-goforward)) + ///- MacOS ([Official API - WKWebView.goForward](https://developer.apple.com/documentation/webkit/wkwebview/1414993-goforward)) + ///- Web ([Official API - History.forward](https://developer.mozilla.org/en-US/docs/Web/API/History/forward)) + Future goForward() async { + Map args = {}; + await channel?.invokeMethod('goForward', args); + } + + ///Returns a boolean value indicating whether the WebView can move forward. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.canGoForward](https://developer.android.com/reference/android/webkit/WebView#canGoForward())) + ///- iOS ([Official API - WKWebView.canGoForward](https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward)) + ///- MacOS ([Official API - WKWebView.canGoForward](https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward)) + Future canGoForward() async { + Map args = {}; + return await channel?.invokeMethod('canGoForward', args) ?? false; + } + + ///Goes to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.goBackOrForward](https://developer.android.com/reference/android/webkit/WebView#goBackOrForward(int))) + ///- iOS ([Official API - WKWebView.go](https://developer.apple.com/documentation/webkit/wkwebview/1414991-go)) + ///- MacOS ([Official API - WKWebView.go](https://developer.apple.com/documentation/webkit/wkwebview/1414991-go)) + ///- Web ([Official API - History.go](https://developer.mozilla.org/en-US/docs/Web/API/History/go)) + Future goBackOrForward({required int steps}) async { + Map args = {}; + args.putIfAbsent('steps', () => steps); + await channel?.invokeMethod('goBackOrForward', args); + } + + ///Returns a boolean value indicating whether the WebView can go back or forward the given number of steps. Steps is negative if backward and positive if forward. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.canGoBackOrForward](https://developer.android.com/reference/android/webkit/WebView#canGoBackOrForward(int))) + ///- iOS + ///- MacOS + Future canGoBackOrForward({required int steps}) async { + Map args = {}; + args.putIfAbsent('steps', () => steps); + return await channel?.invokeMethod('canGoBackOrForward', args) ?? + false; + } + + ///Navigates to a [WebHistoryItem] from the back-forward [WebHistory.list] and sets it as the current item. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future goTo({required WebHistoryItem historyItem}) async { + var steps = historyItem.offset; + if (steps != null) { + await goBackOrForward(steps: steps); + } + } + + ///Check if the WebView instance is in a loading state. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future isLoading() async { + Map args = {}; + return await channel?.invokeMethod('isLoading', args) ?? false; + } + + ///Stops the WebView from loading. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.stopLoading](https://developer.android.com/reference/android/webkit/WebView#stopLoading())) + ///- iOS ([Official API - WKWebView.stopLoading](https://developer.apple.com/documentation/webkit/wkwebview/1414981-stoploading)) + ///- MacOS ([Official API - WKWebView.stopLoading](https://developer.apple.com/documentation/webkit/wkwebview/1414981-stoploading)) + ///- Web ([Official API - Window.stop](https://developer.mozilla.org/en-US/docs/Web/API/Window/stop)) + Future stopLoading() async { + Map args = {}; + await channel?.invokeMethod('stopLoading', args); + } + + ///Evaluates JavaScript [source] code into the WebView and returns the result of the evaluation. + /// + ///[contentWorld], on iOS, it represents the namespace in which to evaluate the JavaScript [source] code. + ///Instead, on Android, it will run the [source] code into an iframe, using `eval(source);` to get and return the result. + ///This parameter doesn’t apply to changes you make to the underlying web content, such as the document’s DOM structure. + ///Those changes remain visible to all scripts, regardless of which content world you specify. + ///For more information about content worlds, see [ContentWorld]. + ///Available on iOS 14.0+ and MacOS 11.0+. + ///**NOTE**: not used on Web. + /// + ///**NOTE**: This method shouldn't be called in the [WebView.onWebViewCreated] or [WebView.onLoadStart] events, + ///because, in these events, the [WebView] is not ready to handle it yet. + ///Instead, you should call this method, for example, inside the [WebView.onLoadStop] event or in any other events + ///where you know the page is ready "enough". + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.evaluateJavascript](https://developer.android.com/reference/android/webkit/WebView#evaluateJavascript(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.String%3E))) + ///- iOS ([Official API - WKWebView.evaluateJavascript](https://developer.apple.com/documentation/webkit/wkwebview/3656442-evaluatejavascript)) + ///- MacOS ([Official API - WKWebView.evaluateJavascript](https://developer.apple.com/documentation/webkit/wkwebview/3656442-evaluatejavascript)) + ///- Web ([Official API - Window.eval](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval?retiredLocale=it)) + Future evaluateJavascript( + {required String source, ContentWorld? contentWorld}) async { + Map args = {}; + args.putIfAbsent('source', () => source); + args.putIfAbsent('contentWorld', () => contentWorld?.toMap()); + var data = await channel?.invokeMethod('evaluateJavascript', args); + if (data != null && (Util.isAndroid || Util.isWeb)) { + try { + // try to json decode the data coming from JavaScript + // otherwise return it as it is. + data = json.decode(data); + } catch (e) {} + } + return data; + } + + ///Injects an external JavaScript file into the WebView from a defined url. + /// + ///[scriptHtmlTagAttributes] represents the possible the ` + ///``` + /// + ///Instead, on the `onLoadStop` WebView event, you can use `callHandler` directly: + ///```dart + /// // Inject JavaScript that will receive data back from Flutter + /// inAppWebViewController.evaluateJavascript(source: """ + /// window.flutter_inappwebview.callHandler('test', 'Text from Javascript').then(function(result) { + /// console.log(result); + /// }); + /// """); + ///``` + /// + ///Forbidden names for JavaScript handlers are defined in [_JAVASCRIPT_HANDLER_FORBIDDEN_NAMES]. + /// + ///**NOTE**: This method should be called, for example, in the [WebView.onWebViewCreated] or [WebView.onLoadStart] events or, at least, + ///before you know that your JavaScript code will call the `window.flutter_inappwebview.callHandler` method, + ///otherwise you won't be able to intercept the JavaScript message. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + void addJavaScriptHandler( + {required String handlerName, + required JavaScriptHandlerCallback callback}) { + assert(!_JAVASCRIPT_HANDLER_FORBIDDEN_NAMES.contains(handlerName), + '"$handlerName" is a forbidden name!'); + this._javaScriptHandlersMap[handlerName] = (callback); + } + + ///Removes a JavaScript message handler previously added with the [addJavaScriptHandler] associated to [handlerName] key. + ///Returns the value associated with [handlerName] before it was removed. + ///Returns `null` if [handlerName] was not found. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + JavaScriptHandlerCallback? removeJavaScriptHandler( + {required String handlerName}) { + return this._javaScriptHandlersMap.remove(handlerName); + } + + ///Returns `true` if a JavaScript handler with [handlerName] already exists, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + bool hasJavaScriptHandler({required String handlerName}) { + return this._javaScriptHandlersMap.containsKey(handlerName); + } + + ///Takes a screenshot of the WebView's visible viewport and returns a [Uint8List]. Returns `null` if it wasn't be able to take it. + /// + ///[screenshotConfiguration] represents the configuration data to use when generating an image from a web view’s contents. + /// + ///**NOTE for iOS**: available on iOS 11.0+. + /// + ///**NOTE for MacOS**: available on MacOS 10.13+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - WKWebView.takeSnapshot](https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot)) + ///- MacOS ([Official API - WKWebView.takeSnapshot](https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot)) + Future takeScreenshot( + {ScreenshotConfiguration? screenshotConfiguration}) async { + Map args = {}; + args.putIfAbsent( + 'screenshotConfiguration', () => screenshotConfiguration?.toMap()); + return await channel?.invokeMethod('takeScreenshot', args); + } + + ///Use [setSettings] instead. + @Deprecated('Use setSettings instead') + Future setOptions({required InAppWebViewGroupOptions options}) async { + InAppWebViewSettings settings = + InAppWebViewSettings.fromMap(options.toMap()) ?? InAppWebViewSettings(); + await setSettings(settings: settings); + } + + ///Use [getSettings] instead. + @Deprecated('Use getSettings instead') + Future getOptions() async { + InAppWebViewSettings? settings = await getSettings(); + + Map? options = settings?.toMap(); + if (options != null) { + options = options.cast(); + return InAppWebViewGroupOptions.fromMap(options as Map); + } + + return null; + } + + ///Sets the WebView settings with the new [settings] and evaluates them. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future setSettings({required InAppWebViewSettings settings}) async { + Map args = {}; + + args.putIfAbsent('settings', () => settings.toMap()); + await channel?.invokeMethod('setSettings', args); + } + + ///Gets the current WebView settings. Returns `null` if it wasn't able to get them. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future getSettings() async { + Map args = {}; + + Map? settings = + await channel?.invokeMethod('getSettings', args); + if (settings != null) { + settings = settings.cast(); + return InAppWebViewSettings.fromMap(settings as Map); + } + + return null; + } + + ///Gets the WebHistory for this WebView. This contains the back/forward list for use in querying each item in the history stack. + ///This contains only a snapshot of the current state. + ///Multiple calls to this method may return different objects. + ///The object returned from this method will not be updated to reflect any new state. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.copyBackForwardList](https://developer.android.com/reference/android/webkit/WebView#copyBackForwardList())) + ///- iOS ([Official API - WKWebView.backForwardList](https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist)) + ///- MacOS ([Official API - WKWebView.backForwardList](https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist)) + Future getCopyBackForwardList() async { + Map args = {}; + Map? result = + (await channel?.invokeMethod('getCopyBackForwardList', args)) + ?.cast(); + return WebHistory.fromMap(result); + } + + ///Clears all the WebView's cache. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future clearCache() async { + Map args = {}; + await channel?.invokeMethod('clearCache', args); + } + + ///Use [AndroidFindInteractionController.findAll] instead. + @Deprecated("Use FindInteractionController.findAll instead") + Future findAllAsync({required String find}) async { + Map args = {}; + args.putIfAbsent('find', () => find); + await channel?.invokeMethod('findAll', args); + } + + ///Use [AndroidFindInteractionController.findNext] instead. + @Deprecated("Use FindInteractionController.findNext instead") + Future findNext({required bool forward}) async { + Map args = {}; + args.putIfAbsent('forward', () => forward); + await channel?.invokeMethod('findNext', args); + } + + ///Use [AndroidFindInteractionController.clearMatches] instead. + @Deprecated("Use FindInteractionController.clearMatches instead") + Future clearMatches() async { + Map args = {}; + await channel?.invokeMethod('clearMatches', args); + } + + ///Use [tRexRunnerHtml] instead. + @Deprecated("Use tRexRunnerHtml instead") + Future getTRexRunnerHtml() async { + return await tRexRunnerHtml; + } + + ///Use [tRexRunnerCss] instead. + @Deprecated("Use tRexRunnerCss instead") + Future getTRexRunnerCss() async { + return await tRexRunnerCss; + } + + ///Scrolls the WebView to the position. + /// + ///[x] represents the x position to scroll to. + /// + ///[y] represents the y position to scroll to. + /// + ///[animated] `true` to animate the scroll transition, `false` to make the scoll transition immediate. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: this method is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - View.scrollTo](https://developer.android.com/reference/android/view/View#scrollTo(int,%20int))) + ///- iOS ([Official API - UIScrollView.setContentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset)) + ///- MacOS + ///- Web ([Official API - Window.scrollTo](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo)) + Future scrollTo( + {required int x, required int y, bool animated = false}) async { + Map args = {}; + args.putIfAbsent('x', () => x); + args.putIfAbsent('y', () => y); + args.putIfAbsent('animated', () => animated); + await channel?.invokeMethod('scrollTo', args); + } + + ///Moves the scrolled position of the WebView. + /// + ///[x] represents the amount of pixels to scroll by horizontally. + /// + ///[y] represents the amount of pixels to scroll by vertically. + /// + ///[animated] `true` to animate the scroll transition, `false` to make the scoll transition immediate. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: this method is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - View.scrollBy](https://developer.android.com/reference/android/view/View#scrollBy(int,%20int))) + ///- iOS ([Official API - UIScrollView.setContentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset)) + ///- MacOS + ///- Web ([Official API - Window.scrollBy](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy)) + Future scrollBy( + {required int x, required int y, bool animated = false}) async { + Map args = {}; + args.putIfAbsent('x', () => x); + args.putIfAbsent('y', () => y); + args.putIfAbsent('animated', () => animated); + await channel?.invokeMethod('scrollBy', args); + } + + ///On Android native WebView, it pauses all layout, parsing, and JavaScript timers for all WebViews. + ///This is a global requests, not restricted to just this WebView. This can be useful if the application has been paused. + /// + ///**NOTE for iOS**: it is implemented using JavaScript and it is restricted to just this WebView. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript and it is restricted to just this WebView. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.pauseTimers](https://developer.android.com/reference/android/webkit/WebView#pauseTimers())) + ///- iOS + ///- MacOS + Future pauseTimers() async { + Map args = {}; + await channel?.invokeMethod('pauseTimers', args); + } + + ///On Android, it resumes all layout, parsing, and JavaScript timers for all WebViews. This will resume dispatching all timers. + /// + ///**NOTE for iOS**: it is implemented using JavaScript and it is restricted to just this WebView. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript and it is restricted to just this WebView. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.resumeTimers](https://developer.android.com/reference/android/webkit/WebView#resumeTimers())) + ///- iOS + ///- MacOS + Future resumeTimers() async { + Map args = {}; + await channel?.invokeMethod('resumeTimers', args); + } + + ///Prints the current page. + /// + ///To obtain the [AndroidPrintJobController], use [settings] argument with [PrintJobSettings.handledByClient] to `true`. + ///Otherwise this method will return `null` and the [AndroidPrintJobController] will be handled and disposed automatically by the system. + /// + ///**NOTE for Android**: available on Android 19+. + /// + ///**NOTE for MacOS**: [AndroidPrintJobController] is available on MacOS 11.0+. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. Also, [AndroidPrintJobController] is always `null`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintManager.print](https://developer.android.com/reference/android/print/PrintManager#print(java.lang.String,%20android.print.PrintDocumentAdapter,%20android.print.PrintAttributes))) + ///- iOS ([Official API - UIPrintInteractionController.present](https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/1618149-present)) + ///- MacOS (if 11.0+, [Official API - WKWebView.printOperation](https://developer.apple.com/documentation/webkit/wkwebview/3516861-printoperation), else [Official API - NSView.printView](https://developer.apple.com/documentation/appkit/nsview/1483705-printview)) + ///- Web ([Official API - Window.print](https://developer.mozilla.org/en-US/docs/Web/API/Window/print)) + Future printCurrentPage( + {PrintJobSettings? settings}) async { + Map args = {}; + args.putIfAbsent("settings", () => settings?.toMap()); + String? jobId = + await channel?.invokeMethod('printCurrentPage', args); + if (jobId != null) { + return AndroidPrintJobController( + PlatformPrintJobControllerCreationParams(id: jobId)); + } + return null; + } + + ///Gets the height of the HTML content. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getContentHeight](https://developer.android.com/reference/android/webkit/WebView#getContentHeight())) + ///- iOS ([Official API - UIScrollView.contentSize](https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize)) + ///- MacOS + ///- Web ([Official API - Document.documentElement.scrollHeight](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight)) + Future getContentHeight() async { + Map args = {}; + var height = await channel?.invokeMethod('getContentHeight', args); + if (height == null || height == 0) { + // try to use javascript + var scrollHeight = await evaluateJavascript( + source: "document.documentElement.scrollHeight;"); + if (scrollHeight != null && scrollHeight is num) { + height = scrollHeight.toInt(); + } + } + return height; + } + + ///Gets the width of the HTML content. + /// + ///**NOTE for Android**: it is implemented using JavaScript. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - UIScrollView.contentSize](https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize)) + ///- MacOS + ///- Web ([Official API - Document.documentElement.scrollWidth](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth)) + Future getContentWidth() async { + Map args = {}; + var height = await channel?.invokeMethod('getContentWidth', args); + if (height == null || height == 0) { + // try to use javascript + var scrollHeight = await evaluateJavascript( + source: "document.documentElement.scrollWidth;"); + if (scrollHeight != null && scrollHeight is num) { + height = scrollHeight.toInt(); + } + } + return height; + } + + ///Performs a zoom operation in this WebView. + /// + ///[zoomFactor] represents the zoom factor to apply. On Android, the zoom factor will be clamped to the Webview's zoom limits and, also, this value must be in the range 0.01 (excluded) to 100.0 (included). + /// + ///[animated] `true` to animate the transition to the new scale, `false` to make the transition immediate. + ///**NOTE**: available only on iOS. + /// + ///**NOTE**: available on Android 21+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.zoomBy](https://developer.android.com/reference/android/webkit/WebView#zoomBy(float))) + ///- iOS ([Official API - UIScrollView.setZoomScale](https://developer.apple.com/documentation/uikit/uiscrollview/1619412-setzoomscale)) + Future zoomBy( + {required double zoomFactor, + @Deprecated('Use animated instead') bool? iosAnimated, + bool animated = false}) async { + assert(!Util.isAndroid || + (Util.isAndroid && zoomFactor > 0.01 && zoomFactor <= 100.0)); + + Map args = {}; + args.putIfAbsent('zoomFactor', () => zoomFactor); + args.putIfAbsent('animated', () => iosAnimated ?? animated); + return await channel?.invokeMethod('zoomBy', args); + } + + ///Gets the URL that was originally requested for the current page. + ///This is not always the same as the URL passed to [InAppWebView.onLoadStart] because although the load for that URL has begun, + ///the current page may not have changed. Also, there may have been redirects resulting in a different URL to that originally requested. + /// + ///**NOTE for Web**: it will return the current value of the `iframe.src` attribute. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getOriginalUrl](https://developer.android.com/reference/android/webkit/WebView#getOriginalUrl())) + ///- iOS + ///- MacOS + ///- Web + Future getOriginalUrl() async { + Map args = {}; + String? url = await channel?.invokeMethod('getOriginalUrl', args); + return url != null ? WebUri(url) : null; + } + + ///Gets the current zoom scale of the WebView. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - UIScrollView.zoomScale](https://developer.apple.com/documentation/uikit/uiscrollview/1619419-zoomscale)) + Future getZoomScale() async { + Map args = {}; + return await channel?.invokeMethod('getZoomScale', args); + } + + ///Use [getZoomScale] instead. + @Deprecated('Use getZoomScale instead') + Future getScale() async { + return await getZoomScale(); + } + + ///Gets the selected text. + /// + ///**NOTE**: this method is implemented with using JavaScript. + /// + ///**NOTE for Android native WebView**: available only on Android 19+. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future getSelectedText() async { + Map args = {}; + return await channel?.invokeMethod('getSelectedText', args); + } + + ///Gets the hit result for hitting an HTML elements. + /// + ///**NOTE**: On iOS, it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getHitTestResult](https://developer.android.com/reference/android/webkit/WebView#getHitTestResult())) + ///- iOS + Future getHitTestResult() async { + Map args = {}; + Map? hitTestResultMap = + await channel?.invokeMethod('getHitTestResult', args); + + if (hitTestResultMap == null) { + return null; + } + + hitTestResultMap = hitTestResultMap.cast(); + + InAppWebViewHitTestResultType? type = + InAppWebViewHitTestResultType.fromNativeValue( + hitTestResultMap["type"]?.toInt()); + String? extra = hitTestResultMap["extra"]; + return InAppWebViewHitTestResult(type: type, extra: extra); + } + + ///Clears the current focus. On iOS and Android native WebView, it will clear also, for example, the current text selection. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - ViewGroup.clearFocus](https://developer.android.com/reference/android/view/ViewGroup#clearFocus())) + ///- iOS ([Official API - UIResponder.resignFirstResponder](https://developer.apple.com/documentation/uikit/uiresponder/1621097-resignfirstresponder)) + Future clearFocus() async { + Map args = {}; + return await channel?.invokeMethod('clearFocus', args); + } + + ///Sets or updates the WebView context menu to be used next time it will appear. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + Future setContextMenu(ContextMenu? contextMenu) async { + Map args = {}; + args.putIfAbsent("contextMenu", () => contextMenu?.toMap()); + await channel?.invokeMethod('setContextMenu', args); + _inAppBrowser?.setContextMenu(contextMenu); + } + + ///Requests the anchor or image element URL at the last tapped point. + /// + ///**NOTE**: On iOS, it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.requestFocusNodeHref](https://developer.android.com/reference/android/webkit/WebView#requestFocusNodeHref(android.os.Message))) + ///- iOS + Future requestFocusNodeHref() async { + Map args = {}; + Map? result = + await channel?.invokeMethod('requestFocusNodeHref', args); + return result != null + ? RequestFocusNodeHrefResult( + url: result['url'] != null ? WebUri(result['url']) : null, + title: result['title'], + src: result['src'], + ) + : null; + } + + ///Requests the URL of the image last touched by the user. + /// + ///**NOTE**: On iOS, it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.requestImageRef](https://developer.android.com/reference/android/webkit/WebView#requestImageRef(android.os.Message))) + ///- iOS + Future requestImageRef() async { + Map args = {}; + Map? result = + await channel?.invokeMethod('requestImageRef', args); + return result != null + ? RequestImageRefResult( + url: result['url'] != null ? WebUri(result['url']) : null, + ) + : null; + } + + ///Returns the list of `` tags of the current WebView. + /// + ///**NOTE**: It is implemented using JavaScript. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future> getMetaTags() async { + List metaTags = []; + + List>? metaTagList = + (await evaluateJavascript(source: """ +(function() { + var metaTags = []; + var metaTagNodes = document.head.getElementsByTagName('meta'); + for (var i = 0; i < metaTagNodes.length; i++) { + var metaTagNode = metaTagNodes[i]; + + var otherAttributes = metaTagNode.getAttributeNames(); + var nameIndex = otherAttributes.indexOf("name"); + if (nameIndex !== -1) otherAttributes.splice(nameIndex, 1); + var contentIndex = otherAttributes.indexOf("content"); + if (contentIndex !== -1) otherAttributes.splice(contentIndex, 1); + + var attrs = []; + for (var j = 0; j < otherAttributes.length; j++) { + var otherAttribute = otherAttributes[j]; + attrs.push( + { + name: otherAttribute, + value: metaTagNode.getAttribute(otherAttribute) + } + ); + } + + metaTags.push( + { + name: metaTagNode.name, + content: metaTagNode.content, + attrs: attrs + } + ); + } + return metaTags; +})(); + """))?.cast>(); + + if (metaTagList == null) { + return metaTags; + } + + for (var metaTag in metaTagList) { + var attrs = []; + + for (var metaTagAttr in metaTag["attrs"]) { + attrs.add(MetaTagAttribute( + name: metaTagAttr["name"], value: metaTagAttr["value"])); + } + + metaTags.add(MetaTag( + name: metaTag["name"], content: metaTag["content"], attrs: attrs)); + } + + return metaTags; + } + + ///Returns an instance of [Color] representing the `content` value of the + ///`` tag of the current WebView, if available, otherwise `null`. + /// + ///**NOTE**: on Android, Web, iOS < 15.0 and MacOS < 12.0, it is implemented using JavaScript. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - WKWebView.themeColor](https://developer.apple.com/documentation/webkit/wkwebview/3794258-themecolor)) + ///- MacOS ([Official API - WKWebView.themeColor](https://developer.apple.com/documentation/webkit/wkwebview/3794258-themecolor)) + ///- Web + Future getMetaThemeColor() async { + Color? themeColor; + + try { + Map args = {}; + themeColor = UtilColor.fromStringRepresentation( + await channel?.invokeMethod('getMetaThemeColor', args)); + return themeColor; + } catch (e) { + // not implemented + } + + // try using javascript + var metaTags = await getMetaTags(); + MetaTag? metaTagThemeColor; + + for (var metaTag in metaTags) { + if (metaTag.name == "theme-color") { + metaTagThemeColor = metaTag; + break; + } + } + + if (metaTagThemeColor == null) { + return null; + } + + var colorValue = metaTagThemeColor.content; + + themeColor = colorValue != null + ? UtilColor.fromStringRepresentation(colorValue) + : null; + + return themeColor; + } + + ///Returns the scrolled left position of the current WebView. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - View.getScrollX](https://developer.android.com/reference/android/view/View#getScrollX())) + ///- iOS ([Official API - UIScrollView.contentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset)) + ///- MacOS + ///- Web ([Official API - Window.scrollX](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX)) + Future getScrollX() async { + Map args = {}; + return await channel?.invokeMethod('getScrollX', args); + } + + ///Returns the scrolled top position of the current WebView. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - View.getScrollY](https://developer.android.com/reference/android/view/View#getScrollY())) + ///- iOS ([Official API - UIScrollView.contentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset)) + ///- MacOS + ///- Web ([Official API - Window.scrollY](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY)) + Future getScrollY() async { + Map args = {}; + return await channel?.invokeMethod('getScrollY', args); + } + + ///Gets the SSL certificate for the main top-level page or null if there is no certificate (the site is not secure). + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getCertificate](https://developer.android.com/reference/android/webkit/WebView#getCertificate())) + ///- iOS + ///- MacOS + Future getCertificate() async { + Map args = {}; + Map? sslCertificateMap = + (await channel?.invokeMethod('getCertificate', args)) + ?.cast(); + return SslCertificate.fromMap(sslCertificateMap); + } + + ///Injects the specified [userScript] into the webpage’s content. + /// + ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. + ///There isn't any way to add/remove user scripts specific to window WebViews. + ///This is a limitation of the native WebKit APIs. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - WKUserContentController.addUserScript](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript)) + ///- MacOS ([Official API - WKUserContentController.addUserScript](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript)) + 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) ?? + false)) { + _userScripts[userScript.injectionTime]?.add(userScript); + await channel?.invokeMethod('addUserScript', args); + } + } + + ///Injects the [userScripts] into the webpage’s content. + /// + ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. + ///There isn't any way to add/remove user scripts specific to window WebViews. + ///This is a limitation of the native WebKit APIs. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + 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]); + } + } + + ///Removes the specified [userScript] from the webpage’s content. + ///User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load. + ///Returns `true` if [userScript] was in the list, `false` otherwise. + /// + ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. + ///There isn't any way to add/remove user scripts specific to window WebViews. + ///This is a limitation of the native WebKit APIs. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + 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; + } + + _userScripts[userScript.injectionTime]?.remove(userScript); + Map args = {}; + args.putIfAbsent('userScript', () => userScript.toMap()); + args.putIfAbsent('index', () => index); + await channel?.invokeMethod('removeUserScript', args); + + return true; + } + + ///Removes all the [UserScript]s with [groupName] as group name from the webpage’s content. + ///User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load. + /// + ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. + ///There isn't any way to add/remove user scripts specific to window WebViews. + ///This is a limitation of the native WebKit APIs. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + 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) { + if (userScript.groupName == groupName) { + _userScripts[userScript.injectionTime]?.remove(userScript); + } + } + + final List userScriptsAtDocumentEnd = + List.from(_userScripts[UserScriptInjectionTime.AT_DOCUMENT_END] ?? []); + for (final userScript in userScriptsAtDocumentEnd) { + if (userScript.groupName == groupName) { + _userScripts[userScript.injectionTime]?.remove(userScript); + } + } + + Map args = {}; + args.putIfAbsent('groupName', () => groupName); + await channel?.invokeMethod('removeUserScriptsByGroupName', args); + } + + ///Removes the [userScripts] from the webpage’s content. + ///User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load. + /// + ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. + ///There isn't any way to add/remove user scripts specific to window WebViews. + ///This is a limitation of the native WebKit APIs. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future removeUserScripts( + {required List userScripts}) async { + assert(webviewParams?.windowId == null || + (!Util.isIOS && !Util.isMacOS)); + + for (final userScript in userScripts) { + await removeUserScript(userScript: userScript); + } + } + + ///Removes all the user scripts from the webpage’s content. + /// + ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. + ///There isn't any way to add/remove user scripts specific to window WebViews. + ///This is a limitation of the native WebKit APIs. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - WKUserContentController.removeAllUserScripts](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts)) + ///- MacOS ([Official API - WKUserContentController.removeAllUserScripts](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts)) + Future removeAllUserScripts() async { + assert(webviewParams?.windowId == null || + (!Util.isIOS && !Util.isMacOS)); + + _userScripts[UserScriptInjectionTime.AT_DOCUMENT_START]?.clear(); + _userScripts[UserScriptInjectionTime.AT_DOCUMENT_END]?.clear(); + + Map args = {}; + await channel?.invokeMethod('removeAllUserScripts', args); + } + + ///Returns `true` if the [userScript] has been already added, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + bool hasUserScript({required UserScript userScript}) { + return _userScripts[userScript.injectionTime]?.contains(userScript) ?? + false; + } + + ///Executes the specified string as an asynchronous JavaScript function. + /// + ///[functionBody] is the JavaScript string to use as the function body. + ///This method treats the string as an anonymous JavaScript function body and calls it with the named arguments in the arguments parameter. + /// + ///[arguments] is a `Map` of the arguments to pass to the function call. + ///Each key in the `Map` corresponds to the name of an argument in the [functionBody] string, + ///and the value of that key is the value to use during the evaluation of the code. + ///Supported value types can be found in the official Flutter docs: + ///[Platform channel data types support and codecs](https://flutter.dev/docs/development/platform-integration/platform-channels#codec), + ///except for [Uint8List], [Int32List], [Int64List], and [Float64List] that should be converted into a [List]. + ///All items in a `List` or `Map` must also be one of the supported types. + /// + ///[contentWorld], on iOS, it represents the namespace in which to evaluate the JavaScript [source] code. + ///Instead, on Android, it will run the [source] code into an iframe. + ///This parameter doesn’t apply to changes you make to the underlying web content, such as the document’s DOM structure. + ///Those changes remain visible to all scripts, regardless of which content world you specify. + ///For more information about content worlds, see [ContentWorld]. + ///Available on iOS 14.3+. + /// + ///**NOTE**: This method shouldn't be called in the [WebView.onWebViewCreated] or [WebView.onLoadStart] events, + ///because, in these events, the [WebView] is not ready to handle it yet. + ///Instead, you should call this method, for example, inside the [WebView.onLoadStop] event or in any other events + ///where you know the page is ready "enough". + /// + ///**NOTE for iOS**: available only on iOS 10.3+. + /// + ///**NOTE for Android**: available only on Android 21+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - WKWebView.callAsyncJavaScript](https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript)) + ///- MacOS ([Official API - WKWebView.callAsyncJavaScript](https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript)) + Future callAsyncJavaScript( + {required String functionBody, + Map arguments = const {}, + ContentWorld? contentWorld}) async { + Map args = {}; + args.putIfAbsent('functionBody', () => functionBody); + args.putIfAbsent('arguments', () => arguments); + args.putIfAbsent('contentWorld', () => contentWorld?.toMap()); + var data = await channel?.invokeMethod('callAsyncJavaScript', args); + if (data == null) { + return null; + } + if (Util.isAndroid) { + data = json.decode(data); + } + return CallAsyncJavaScriptResult( + value: data["value"], error: data["error"]); + } + + ///Saves the current WebView as a web archive. + ///Returns the file path under which the web archive file was saved, or `null` if saving the file failed. + /// + ///[filePath] represents the file path where the archive should be placed. This value cannot be `null`. + /// + ///[autoname] if `false`, takes [filePath] to be a file. + ///If `true`, [filePath] is assumed to be a directory in which a filename will be chosen according to the URL of the current page. + /// + ///**NOTE for iOS**: Available on iOS 14.0+. If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension. + /// + ///**NOTE for MacOS**: Available on MacOS 11.0+. If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension. + /// + ///**NOTE for Android**: if [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.MHT] file extension. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.saveWebArchive](https://developer.android.com/reference/android/webkit/WebView#saveWebArchive(java.lang.String,%20boolean,%20android.webkit.ValueCallback%3Cjava.lang.String%3E))) + ///- iOS + ///- MacOS + 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())); + } + } + + Map args = {}; + args.putIfAbsent("filePath", () => filePath); + args.putIfAbsent("autoname", () => autoname); + return await channel?.invokeMethod('saveWebArchive', args); + } + + ///Indicates whether the webpage context is capable of using features that require [secure contexts](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts). + ///This is implemented using Javascript (see [window.isSecureContext](https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext)). + /// + ///**NOTE for Android**: available Android 21.0+. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. Returns `false` otherwise. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web ([Official API - Window.isSecureContext](https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext)) + Future isSecureContext() async { + Map args = {}; + return await channel?.invokeMethod('isSecureContext', args) ?? false; + } + + ///Creates a message channel to communicate with JavaScript and returns the message channel with ports that represent the endpoints of this message channel. + ///The HTML5 message channel functionality is described [here](https://html.spec.whatwg.org/multipage/comms.html#messagechannel). + /// + ///The returned message channels are entangled and already in started state. + /// + ///This method should be called when the page is loaded, for example, when the [WebView.onLoadStop] is fired, otherwise the [AndroidWebMessageChannel] won't work. + /// + ///**NOTE for Android native WebView**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.CREATE_WEB_MESSAGE_CHANNEL]. + /// + ///**NOTE for iOS**: it is implemented using JavaScript. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.createWebMessageChannel](https://developer.android.com/reference/androidx/webkit/WebViewCompat#createWebMessageChannel(android.webkit.WebView))) + ///- iOS + ///- MacOS + Future createWebMessageChannel() async { + Map args = {}; + Map? result = + (await channel?.invokeMethod('createWebMessageChannel', args)) + ?.cast(); + final webMessageChannel = AndroidWebMessageChannel.static().fromMap(result); + if (webMessageChannel != null) { + _webMessageChannels.add(webMessageChannel); + } + return webMessageChannel; + } + + ///Post a message to main frame. The embedded application can restrict the messages to a certain target origin. + ///See [HTML5 spec](https://html.spec.whatwg.org/multipage/comms.html#posting-messages) for how target origin can be used. + /// + ///A target origin can be set as a wildcard ("*"). However this is not recommended. + /// + ///**NOTE for Android native WebView**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.POST_WEB_MESSAGE]. + /// + ///**NOTE for iOS**: it is implemented using JavaScript. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.postWebMessage](https://developer.android.com/reference/androidx/webkit/WebViewCompat#postWebMessage(android.webkit.WebView,%20androidx.webkit.WebMessageCompat,%20android.net.Uri))) + ///- iOS + ///- MacOS + Future postWebMessage( + {required WebMessage message, WebUri? targetOrigin}) async { + if (targetOrigin == null) { + targetOrigin = WebUri(''); + } + Map args = {}; + args.putIfAbsent('message', () => message.toMap()); + args.putIfAbsent('targetOrigin', () => targetOrigin.toString()); + await channel?.invokeMethod('postWebMessage', args); + } + + ///Adds a [AndroidWebMessageListener] to the WebView and injects a JavaScript object into each frame that the [AndroidWebMessageListener] will listen on. + /// + ///The injected JavaScript object will be named [AndroidWebMessageListener.jsObjectName] in the global scope. + ///This will inject the JavaScript object in any frame whose origin matches [AndroidWebMessageListener.allowedOriginRules] + ///for every navigation after this call, and the JavaScript object will be available immediately when the page begins to load. + /// + ///Each [AndroidWebMessageListener.allowedOriginRules] entry must follow the format `SCHEME "://" [ HOSTNAME_PATTERN [ ":" PORT ] ]`, each part is explained in the below table: + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + ///
RuleDescriptionExample
http/https with hostnameSCHEME is http or https; HOSTNAME_PATTERN is a regular hostname; PORT is optional, when not present, the rule will match port 80 for http and port + /// 443 for https. + /// + ///
    + ///
  • https://foobar.com:8080 - Matches https:// URL on port 8080, whose normalized + /// host is foobar.com. + ///
  • + ///
  • https://www.example.com - Matches https:// URL on port 443, whose normalized host + /// is www.example.com. + ///
  • + ///
+ ///
http/https with pattern matchingSCHEME is http or https; HOSTNAME_PATTERN is a sub-domain matching + /// pattern with a leading *.; PORT is optional, when not present, the rule will + /// match port 80 for http and port 443 for https. + /// + ///
    + ///
  • https://*.example.com - Matches https://calendar.example.com and + /// https://foo.bar.example.com but not https://example.com. + ///
  • + ///
  • https://*.example.com:8080 - Matches https://calendar.example.com:8080
  • + ///
+ ///
http/https with IP literalSCHEME is https or https; HOSTNAME_PATTERN is IP literal; PORT is + /// optional, when not present, the rule will match port 80 for http and port 443 + /// for https. + /// + ///
    + ///
  • https://127.0.0.1 - Matches https:// URL on port 443, whose IPv4 address is + /// 127.0.0.1 + ///
  • + ///
  • https://[::1] or https://[0:0::1]- Matches any URL to the IPv6 loopback + /// address with port 443. + ///
  • + ///
  • https://[::1]:99 - Matches any https:// URL to the IPv6 loopback on port 99.
  • + ///
+ ///
Custom schemeSCHEME is a custom scheme; HOSTNAME_PATTERN and PORT must not be + /// present. + /// + ///
    + ///
  • my-app-scheme:// - Matches any my-app-scheme:// URL.
  • + ///
+ ///
*Wildcard rule, matches any origin. + ///
    + ///
  • *
  • + ///
+ ///
+ /// + ///Note that this is a powerful API, as the JavaScript object will be injected when the frame's origin matches any one of the allowed origins. + ///The HTTPS scheme is strongly recommended for security; allowing HTTP origins exposes the injected object to any potential network-based attackers. + ///If a wildcard "*" is provided, it will inject the JavaScript object to all frames. + ///A wildcard should only be used if the app wants **any** third party web page to be able to use the injected object. + ///When using a wildcard, the app must treat received messages as untrustworthy and validate any data carefully. + /// + ///This method can be called multiple times to inject multiple JavaScript objects. + /// + ///Let's say the injected JavaScript object is named `myObject`. We will have following methods on that object once it is available to use: + /// + ///```javascript + /// // Web page (in JavaScript) + /// // message needs to be a JavaScript String, MessagePorts is an optional parameter. + /// myObject.postMessage(message[, MessagePorts]) // on Android + /// myObject.postMessage(message) // on iOS + /// + /// // To receive messages posted from the app side, assign a function to the "onmessage" + /// // property. This function should accept a single "event" argument. "event" has a "data" + /// // property, which is the message string from the app side. + /// myObject.onmessage = function(event) { ... } + /// + /// // To be compatible with DOM EventTarget's addEventListener, it accepts type and listener + /// // parameters, where type can be only "message" type and listener can only be a JavaScript + /// // function for myObject. An event object will be passed to listener with a "data" property, + /// // which is the message string from the app side. + /// myObject.addEventListener(type, listener) + /// + /// // To be compatible with DOM EventTarget's removeEventListener, it accepts type and listener + /// // parameters, where type can be only "message" type and listener can only be a JavaScript + /// // function for myObject. + /// myObject.removeEventListener(type, listener) + ///``` + /// + ///We start the communication between JavaScript and the app from the JavaScript side. + ///In order to send message from the app to JavaScript, it needs to post a message from JavaScript first, + ///so the app will have a [AndroidJavaScriptReplyProxy] object to respond. Example: + /// + ///```javascript + /// // Web page (in JavaScript) + /// myObject.onmessage = function(event) { + /// // prints "Got it!" when we receive the app's response. + /// console.log(event.data); + /// } + /// myObject.postMessage("I'm ready!"); + ///``` + /// + ///```dart + /// // Flutter App + /// child: InAppWebView( + /// onWebViewCreated: (controller) async { + /// if (defaultTargetPlatform != TargetPlatform.android || await WebViewFeature.isFeatureSupported(WebViewFeature.WEB_MESSAGE_LISTENER)) { + /// await controller.addWebMessageListener(WebMessageListener( + /// jsObjectName: "myObject", + /// onPostMessage: (message, sourceOrigin, isMainFrame, replyProxy) { + /// // do something about message, sourceOrigin and isMainFrame. + /// replyProxy.postMessage("Got it!"); + /// }, + /// )); + /// } + /// await controller.loadUrl(urlRequest: URLRequest(url: WebUri("https://www.example.com"))); + /// }, + /// ), + ///``` + /// + ///**NOTE for Android**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.WEB_MESSAGE_LISTENER]. + /// + ///**NOTE for iOS**: it is implemented using JavaScript. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.WebMessageListener](https://developer.android.com/reference/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,%20java.lang.String,%20java.util.Set%3Cjava.lang.String%3E,%20androidx.webkit.WebViewCompat.WebMessageListener))) + ///- iOS + ///- MacOS + @override + Future addWebMessageListener( + PlatformWebMessageListener webMessageListener) async { + assert(!_webMessageListeners.contains(webMessageListener), + "${webMessageListener} was already added."); + assert( + !_webMessageListenerObjNames + .contains(webMessageListener.params.jsObjectName), + "jsObjectName ${webMessageListener.params.jsObjectName} was already added."); + _webMessageListeners.add(webMessageListener as AndroidWebMessageListener); + _webMessageListenerObjNames.add(webMessageListener.params.jsObjectName); + + Map args = {}; + args.putIfAbsent('webMessageListener', () => webMessageListener.toMap()); + await channel?.invokeMethod('addWebMessageListener', args); + } + + ///Returns `true` if the [webMessageListener] has been already added, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + @override + bool hasWebMessageListener(PlatformWebMessageListener webMessageListener) { + return _webMessageListeners.contains(webMessageListener) || + _webMessageListenerObjNames + .contains(webMessageListener.params.jsObjectName); + } + + ///Returns `true` if the webpage can scroll vertically, otherwise `false`. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + @override + Future canScrollVertically() async { + Map args = {}; + return await channel?.invokeMethod('canScrollVertically', args) ?? + false; + } + + ///Returns `true` if the webpage can scroll horizontally, otherwise `false`. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + @override + Future canScrollHorizontally() async { + Map args = {}; + return await channel?.invokeMethod('canScrollHorizontally', args) ?? + false; + } + + ///Starts Safe Browsing initialization. + /// + ///URL loads are not guaranteed to be protected by Safe Browsing until after the this method returns true. + ///Safe Browsing is not fully supported on all devices. For those devices this method will returns false. + /// + ///This should not be called if Safe Browsing has been disabled by manifest tag or [AndroidInAppWebViewOptions.safeBrowsingEnabled]. + ///This prepares resources used for Safe Browsing. + /// + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.START_SAFE_BROWSING]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.startSafeBrowsing](https://developer.android.com/reference/android/webkit/WebView#startSafeBrowsing(android.content.Context,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) + @override + Future startSafeBrowsing() async { + Map args = {}; + return await channel?.invokeMethod('startSafeBrowsing', args) ?? + false; + } + + ///Clears the SSL preferences table stored in response to proceeding with SSL certificate errors. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.clearSslPreferences](https://developer.android.com/reference/android/webkit/WebView#clearSslPreferences())) + @override + Future clearSslPreferences() async { + Map args = {}; + await channel?.invokeMethod('clearSslPreferences', args); + } + + ///Does a best-effort attempt to pause any processing that can be paused safely, such as animations and geolocation. Note that this call does not pause JavaScript. + ///To pause JavaScript globally, use [InAppWebViewController.pauseTimers]. To resume WebView, call [resume]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.onPause](https://developer.android.com/reference/android/webkit/WebView#onPause())) + @override + Future pause() async { + Map args = {}; + await channel?.invokeMethod('pause', args); + } + + ///Resumes a WebView after a previous call to [pause]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.onResume](https://developer.android.com/reference/android/webkit/WebView#onResume())) + @override + Future resume() async { + Map args = {}; + await channel?.invokeMethod('resume', args); + } + + ///Scrolls the contents of this WebView down by half the page size. + ///Returns `true` if the page was scrolled. + /// + ///[bottom] `true` to jump to bottom of page. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.pageDown](https://developer.android.com/reference/android/webkit/WebView#pageDown(boolean))) + @override + Future pageDown({required bool bottom}) async { + Map args = {}; + args.putIfAbsent("bottom", () => bottom); + return await channel?.invokeMethod('pageDown', args) ?? false; + } + + ///Scrolls the contents of this WebView up by half the view size. + ///Returns `true` if the page was scrolled. + /// + ///[top] `true` to jump to the top of the page. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.pageUp](https://developer.android.com/reference/android/webkit/WebView#pageUp(boolean))) + @override + Future pageUp({required bool top}) async { + Map args = {}; + args.putIfAbsent("top", () => top); + return await channel?.invokeMethod('pageUp', args) ?? false; + } + + ///Performs zoom in in this WebView. + ///Returns `true` if zoom in succeeds, `false` if no zoom changes. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.zoomIn](https://developer.android.com/reference/android/webkit/WebView#zoomIn())) + @override + Future zoomIn() async { + Map args = {}; + return await channel?.invokeMethod('zoomIn', args) ?? false; + } + + ///Performs zoom out in this WebView. + ///Returns `true` if zoom out succeeds, `false` if no zoom changes. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.zoomOut](https://developer.android.com/reference/android/webkit/WebView#zoomOut())) + Future zoomOut() async { + Map args = {}; + return await channel?.invokeMethod('zoomOut', args) ?? false; + } + + ///Clears the internal back/forward list. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.clearHistory](https://developer.android.com/reference/android/webkit/WebView#clearHistory())) + Future clearHistory() async { + Map args = {}; + return await channel?.invokeMethod('clearHistory', args); + } + + ///Reloads the current page, performing end-to-end revalidation using cache-validating conditionals if possible. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.reloadFromOrigin](https://developer.apple.com/documentation/webkit/wkwebview/1414956-reloadfromorigin)) + ///- MacOS ([Official API - WKWebView.reloadFromOrigin](https://developer.apple.com/documentation/webkit/wkwebview/1414956-reloadfromorigin)) + Future reloadFromOrigin() async { + Map args = {}; + await channel?.invokeMethod('reloadFromOrigin', args); + } + + ///Generates PDF data from the web view’s contents asynchronously. + ///Returns `null` if a problem occurred. + /// + ///[pdfConfiguration] represents the object that specifies the portion of the web view to capture as PDF data. + /// + ///**NOTE for iOS**: available only on iOS 14.0+. + /// + ///**NOTE for MacOS**: available only on MacOS 11.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.createPdf](https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf)) + ///- MacOS ([Official API - WKWebView.createPdf](https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf)) + 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); + } + + ///Creates a web archive of the web view’s current contents asynchronously. + ///Returns `null` if a problem occurred. + /// + ///**NOTE for iOS**: available only on iOS 14.0+. + /// + ///**NOTE for MacOS**: available only on MacOS 11.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.createWebArchiveData](https://developer.apple.com/documentation/webkit/wkwebview/3650491-createwebarchivedata)) + ///- MacOS ([Official API - WKWebView.createWebArchiveData](https://developer.apple.com/documentation/webkit/wkwebview/3650491-createwebarchivedata)) + Future createWebArchiveData() async { + Map args = {}; + return await channel?.invokeMethod('createWebArchiveData', args); + } + + ///A Boolean value indicating whether all resources on the page have been loaded over securely encrypted connections. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.hasOnlySecureContent](https://developer.apple.com/documentation/webkit/wkwebview/1415002-hasonlysecurecontent)) + ///- MacOS ([Official API - WKWebView.hasOnlySecureContent](https://developer.apple.com/documentation/webkit/wkwebview/1415002-hasonlysecurecontent)) + Future hasOnlySecureContent() async { + Map args = {}; + return await channel?.invokeMethod('hasOnlySecureContent', args) ?? + false; + } + + ///Pauses playback of all media in the web view. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.pauseAllMediaPlayback](https://developer.apple.com/documentation/webkit/wkwebview/3752240-pauseallmediaplayback)). + ///- MacOS ([Official API - WKWebView.pauseAllMediaPlayback](https://developer.apple.com/documentation/webkit/wkwebview/3752240-pauseallmediaplayback)). + Future pauseAllMediaPlayback() async { + Map args = {}; + return await channel?.invokeMethod('pauseAllMediaPlayback', args); + } + + ///Changes whether the webpage is suspending playback of all media in the page. + ///Pass `true` to pause all media the web view is playing. Neither the user nor the webpage can resume playback until you call this method again with `false`. + /// + ///[suspended] represents a [bool] value that indicates whether the webpage should suspend media playback. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.setAllMediaPlaybackSuspended](https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended)). + ///- MacOS ([Official API - WKWebView.setAllMediaPlaybackSuspended](https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended)). + Future setAllMediaPlaybackSuspended({required bool suspended}) async { + Map args = {}; + args.putIfAbsent("suspended", () => suspended); + return await channel?.invokeMethod('setAllMediaPlaybackSuspended', args); + } + + ///Closes all media the web view is presenting, including picture-in-picture video and fullscreen video. + /// + ///**NOTE for iOS**: available on iOS 14.5+. + /// + ///**NOTE for MacOS**: available on MacOS 11.3+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.closeAllMediaPresentations](https://developer.apple.com/documentation/webkit/wkwebview/3752235-closeallmediapresentations)). + ///- MacOS ([Official API - WKWebView.closeAllMediaPresentations](https://developer.apple.com/documentation/webkit/wkwebview/3752235-closeallmediapresentations)). + Future closeAllMediaPresentations() async { + Map args = {}; + return await channel?.invokeMethod('closeAllMediaPresentations', args); + } + + ///Requests the playback status of media in the web view. + ///Returns a [MediaPlaybackState] that indicates whether the media in the web view is playing, paused, or suspended. + ///If there’s no media in the web view to play, this method provides [MediaPlaybackState.NONE]. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.requestMediaPlaybackState](https://developer.apple.com/documentation/webkit/wkwebview/3752241-requestmediaplaybackstate)). + ///- MacOS ([Official API - WKWebView.requestMediaPlaybackState](https://developer.apple.com/documentation/webkit/wkwebview/3752241-requestmediaplaybackstate)). + Future requestMediaPlaybackState() async { + Map args = {}; + return MediaPlaybackState.fromNativeValue( + await channel?.invokeMethod('requestMediaPlaybackState', args)); + } + + ///Returns `true` if the [WebView] is in fullscreen mode, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future isInFullscreen() async { + Map args = {}; + return await channel?.invokeMethod('isInFullscreen', args) ?? false; + } + + ///Returns a [MediaCaptureState] that indicates whether the webpage is using the camera to capture images or video. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.cameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763093-cameracapturestate)). + ///- MacOS ([Official API - WKWebView.cameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763093-cameracapturestate)). + Future getCameraCaptureState() async { + Map args = {}; + return MediaCaptureState.fromNativeValue( + await channel?.invokeMethod('getCameraCaptureState', args)); + } + + ///Changes whether the webpage is using the camera to capture images or video. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.setCameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763097-setcameracapturestate)). + ///- MacOS ([Official API - WKWebView.setCameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763097-setcameracapturestate)). + Future setCameraCaptureState({required MediaCaptureState state}) async { + Map args = {}; + args.putIfAbsent('state', () => state.toNativeValue()); + await channel?.invokeMethod('setCameraCaptureState', args); + } + + ///Returns a [MediaCaptureState] that indicates whether the webpage is using the microphone to capture audio. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.microphoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763096-microphonecapturestate)). + ///- MacOS ([Official API - WKWebView.microphoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763096-microphonecapturestate)). + Future getMicrophoneCaptureState() async { + Map args = {}; + return MediaCaptureState.fromNativeValue( + await channel?.invokeMethod('getMicrophoneCaptureState', args)); + } + + ///Changes whether the webpage is using the microphone to capture audio. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.setMicrophoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763098-setmicrophonecapturestate)). + ///- MacOS ([Official API - WKWebView.setMicrophoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763098-setmicrophonecapturestate)). + Future setMicrophoneCaptureState( + {required MediaCaptureState state}) async { + Map args = {}; + args.putIfAbsent('state', () => state.toNativeValue()); + await channel?.invokeMethod('setMicrophoneCaptureState', args); + } + + ///Loads the web content from the data you provide as if the data were the response to the request. + ///If [urlResponse] is `null`, it loads the web content from the data as an utf8 encoded HTML string as the response to the request. + /// + ///[urlRequest] represents a URL request that specifies the base URL and other loading details the system uses to interpret the data you provide. + /// + ///[urlResponse] represents a response the system uses to interpret the data you provide. + /// + ///[data] represents the data or the utf8 encoded HTML string to use as the contents of the webpage. + /// + ///Example: + ///```dart + ///controller.loadSimulateloadSimulatedRequestdRequest(urlRequest: URLRequest( + /// url: WebUri("https://flutter.dev"), + /// ), + /// data: Uint8List.fromList(utf8.encode("

Hello

")) + ///); + ///``` + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.loadSimulatedRequest(_:response:responseData:)](https://developer.apple.com/documentation/webkit/wkwebview/3763094-loadsimulatedrequest) and [Official API - WKWebView.loadSimulatedRequest(_:responseHTML:)](https://developer.apple.com/documentation/webkit/wkwebview/3763095-loadsimulatedrequest)). + ///- MacOS ([Official API - WKWebView.loadSimulatedRequest(_:response:responseData:)](https://developer.apple.com/documentation/webkit/wkwebview/3763094-loadsimulatedrequest) and [Official API - WKWebView.loadSimulatedRequest(_:responseHTML:)](https://developer.apple.com/documentation/webkit/wkwebview/3763095-loadsimulatedrequest)). + 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); + } + + ///Returns the iframe `id` attribute used on the Web platform. + /// + ///**Supported Platforms/Implementations**: + ///- Web + Future getIFrameId() async { + Map args = {}; + return await channel?.invokeMethod('getIFrameId', args); + } + + ///Gets the default user agent. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebSettings.getDefaultUserAgent](https://developer.android.com/reference/android/webkit/WebSettings#getDefaultUserAgent(android.content.Context))) + ///- iOS + ///- MacOS + Future getDefaultUserAgent() async { + Map args = {}; + return await _staticChannel.invokeMethod( + 'getDefaultUserAgent', args) ?? + ''; + } + + ///Clears the client certificate preferences stored in response to proceeding/cancelling client cert requests. + ///Note that WebView automatically clears these preferences when the system keychain is updated. + ///The preferences are shared by all the WebViews that are created by the embedder application. + /// + ///**NOTE**: On iOS certificate-based credentials are never stored permanently. + /// + ///**NOTE**: available on Android 21+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.clearClientCertPreferences](https://developer.android.com/reference/android/webkit/WebView#clearClientCertPreferences(java.lang.Runnable))) + Future clearClientCertPreferences() async { + Map args = {}; + await _staticChannel.invokeMethod('clearClientCertPreferences', args); + } + + ///Returns a URL pointing to the privacy policy for Safe Browsing reporting. + /// + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SAFE_BROWSING_PRIVACY_POLICY_URL]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.getSafeBrowsingPrivacyPolicyUrl](https://developer.android.com/reference/androidx/webkit/WebViewCompat#getSafeBrowsingPrivacyPolicyUrl())) + Future getSafeBrowsingPrivacyPolicyUrl() async { + Map args = {}; + String? url = await _staticChannel.invokeMethod( + 'getSafeBrowsingPrivacyPolicyUrl', args); + return url != null ? WebUri(url) : null; + } + + ///Use [setSafeBrowsingAllowlist] instead. + @Deprecated("Use setSafeBrowsingAllowlist instead") + Future setSafeBrowsingWhitelist({required List hosts}) async { + return await setSafeBrowsingAllowlist(hosts: hosts); + } + + ///Sets the list of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks. The list is global for all the WebViews. + /// + /// Each rule should take one of these: + ///| Rule | Example | Matches Subdomain | + ///| -- | -- | -- | + ///| HOSTNAME | example.com | Yes | + ///| .HOSTNAME | .example.com | No | + ///| IPV4_LITERAL | 192.168.1.1 | No | + ///| IPV6_LITERAL_WITH_BRACKETS | [10:20:30:40:50:60:70:80] | No | + /// + ///All other rules, including wildcards, are invalid. The correct syntax for hosts is defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3.2.2). + /// + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SAFE_BROWSING_ALLOWLIST]. + /// + ///[hosts] represents the list of hosts. This value must never be `null`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.setSafeBrowsingAllowlist](https://developer.android.com/reference/androidx/webkit/WebViewCompat#setSafeBrowsingAllowlist(java.util.Set%3Cjava.lang.String%3E,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) + Future setSafeBrowsingAllowlist({required List hosts}) async { + Map args = {}; + args.putIfAbsent('hosts', () => hosts); + return await _staticChannel.invokeMethod( + 'setSafeBrowsingAllowlist', args) ?? + false; + } + + ///If WebView has already been loaded into the current process this method will return the package that was used to load it. + ///Otherwise, the package that would be used if the WebView was loaded right now will be returned; + ///this does not cause WebView to be loaded, so this information may become outdated at any time. + ///The WebView package changes either when the current WebView package is updated, disabled, or uninstalled. + ///It can also be changed through a Developer Setting. If the WebView package changes, any app process that + ///has loaded WebView will be killed. + ///The next time the app starts and loads WebView it will use the new WebView package instead. + /// + ///**NOTE**: available only on Android 21+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.getCurrentWebViewPackage](https://developer.android.com/reference/androidx/webkit/WebViewCompat#getCurrentWebViewPackage(android.content.Context))) + Future getCurrentWebViewPackage() async { + Map args = {}; + Map? packageInfo = + (await _staticChannel.invokeMethod('getCurrentWebViewPackage', args)) + ?.cast(); + return WebViewPackageInfo.fromMap(packageInfo); + } + + ///Enables debugging of web contents (HTML / CSS / JavaScript) loaded into any WebViews of this application. + ///This flag can be enabled in order to facilitate debugging of web layouts and JavaScript code running inside WebViews. + ///Please refer to WebView documentation for the debugging guide. The default is `false`. + /// + ///[debuggingEnabled] whether to enable web contents debugging. + /// + ///**NOTE**: available only on Android 19+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.setWebContentsDebuggingEnabled](https://developer.android.com/reference/android/webkit/WebView#setWebContentsDebuggingEnabled(boolean))) + Future setWebContentsDebuggingEnabled(bool debuggingEnabled) async { + Map args = {}; + args.putIfAbsent('debuggingEnabled', () => debuggingEnabled); + return await _staticChannel.invokeMethod( + 'setWebContentsDebuggingEnabled', args); + } + + ///Gets the WebView variations encoded to be used as the X-Client-Data HTTP header. + /// + ///The app is responsible for adding the X-Client-Data header to any request + ///that may use variations metadata, such as requests to Google web properties. + ///The returned string will be a base64 encoded ClientVariations proto: + ///https://source.chromium.org/chromium/chromium/src/+/main:components/variations/proto/client_variations.proto + /// + ///The string may be empty if the header is not available. + /// + ///**NOTE for Android native WebView**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.GET_VARIATIONS_HEADER]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.getVariationsHeader](https://developer.android.com/reference/androidx/webkit/WebViewCompat#getVariationsHeader())) + Future getVariationsHeader() async { + Map args = {}; + return await _staticChannel.invokeMethod( + 'getVariationsHeader', args); + } + + ///Returns `true` if WebView is running in multi process mode. + /// + ///In Android O and above, WebView may run in "multiprocess" mode. + ///In multiprocess mode, rendering of web content is performed by a sandboxed + ///renderer process separate to the application process. + ///This renderer process may be shared with other WebViews in the application, + ///but is not shared with other application processes. + /// + ///**NOTE for Android native WebView**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.MULTI_PROCESS]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.isMultiProcessEnabled](https://developer.android.com/reference/androidx/webkit/WebViewCompat#isMultiProcessEnabled())) + Future isMultiProcessEnabled() async { + Map args = {}; + return await _staticChannel.invokeMethod( + 'isMultiProcessEnabled', args) ?? + false; + } + + ///Indicate that the current process does not intend to use WebView, + ///and that an exception should be thrown if a WebView is created or any other + ///methods in the `android.webkit` package are used. + /// + ///Applications with multiple processes may wish to call this in processes that + ///are not intended to use WebView to avoid accidentally incurring the memory usage + ///of initializing WebView in long-lived processes that have no need for it, + ///and to prevent potential data directory conflicts (see [ProcessGlobalConfigSettings.dataDirectorySuffix]). + /// + ///**NOTE for Android**: available only on Android 28+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.disableWebView](https://developer.android.com/reference/android/webkit/WebView.html#disableWebView())) + Future disableWebView() async { + Map args = {}; + await _staticChannel.invokeMethod('disableWebView', args); + } + + ///Returns a Boolean value that indicates whether WebKit natively supports resources with the specified URL scheme. + /// + ///[urlScheme] represents the URL scheme associated with the resource. + /// + ///**NOTE for iOS**: available only on iOS 11.0+. + /// + ///**NOTE for MacOS**: available only on MacOS 10.13+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.handlesURLScheme](https://developer.apple.com/documentation/webkit/wkwebview/2875370-handlesurlscheme)) + ///- MacOS ([Official API - WKWebView.handlesURLScheme](https://developer.apple.com/documentation/webkit/wkwebview/2875370-handlesurlscheme)) + Future handlesURLScheme(String urlScheme) async { + Map args = {}; + args.putIfAbsent('urlScheme', () => urlScheme); + return await _staticChannel.invokeMethod('handlesURLScheme', args); + } + + ///Disposes the WebView that is using the [keepAlive] instance + ///for the keep alive feature. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + Future disposeKeepAlive(InAppWebViewKeepAlive keepAlive) async { + Map args = {}; + args.putIfAbsent('keepAliveId', () => keepAlive.id); + await _staticChannel.invokeMethod('disposeKeepAlive', args); + _keepAliveMap[keepAlive] = null; + } + + ///Gets the html (with javascript) of the Chromium's t-rex runner game. Used in combination with [tRexRunnerCss]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future get tRexRunnerHtml async => await rootBundle.loadString( + 'packages/flutter_inappwebview/assets/t_rex_runner/t-rex.html'); + + ///Gets the css of the Chromium's t-rex runner game. Used in combination with [tRexRunnerHtml]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future get tRexRunnerCss async => await rootBundle.loadString( + 'packages/flutter_inappwebview/assets/t_rex_runner/t-rex.css'); + + ///View ID used internally. + dynamic getViewId() { + return id; + } + + ///Disposes the controller. + @override + void dispose({bool isKeepAlive = false}) { + disposeChannel(removeMethodCallHandler: !isKeepAlive); + _inAppBrowser = null; + webStorage.dispose(); + if (!isKeepAlive) { + _javaScriptHandlersMap.clear(); + _userScripts.clear(); + _webMessageListenerObjNames.clear(); + _injectedScriptsFromURL.clear(); + for (final webMessageChannel in _webMessageChannels) { + webMessageChannel.dispose(); + } + _webMessageChannels.clear(); + for (final webMessageListener in _webMessageListeners) { + webMessageListener.dispose(); + } + _webMessageListeners.clear(); + } + } +} + +extension InternalInAppWebViewController on AndroidInAppWebViewController { + get handleMethod => _handleMethod; +} diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/main.dart b/flutter_inappwebview_android/lib/src/in_app_webview/main.dart new file mode 100644 index 00000000..b83b0611 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/in_app_webview/main.dart @@ -0,0 +1,3 @@ +export 'in_app_webview_controller.dart' hide InternalInAppWebViewController; +export 'in_app_webview.dart'; +export 'headless_in_app_webview.dart' hide InternalHeadlessInAppWebView; diff --git a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart new file mode 100644 index 00000000..6c9bb608 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart @@ -0,0 +1,343 @@ +import 'package:flutter_inappwebview_android/src/print_job/main.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +import 'cookie_manager.dart'; +import 'http_auth_credentials_database.dart'; +import 'find_interaction/main.dart'; +import 'in_app_browser/in_app_browser.dart'; +import 'in_app_webview/main.dart'; +import 'pull_to_refresh/main.dart'; +import 'web_message/main.dart'; +import 'web_storage/main.dart'; +import 'process_global_config.dart'; +import 'proxy_controller.dart'; +import 'service_worker_controller.dart'; +import 'tracing_controller.dart'; +import 'webview_asset_loader.dart'; +import 'webview_feature.dart' as wv; + +/// Implementation of [WebViewPlatform] using the WebKit API. +class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { + /// Registers this class as the default instance of [WebViewPlatform]. + static void registerWith() { + InAppWebViewPlatform.instance = AndroidInAppWebViewPlatform(); + } + + /// Creates a new [AndroidCookieManager]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [CookieManager] in `flutter_inappwebview` instead. + AndroidCookieManager createPlatformCookieManager( + PlatformCookieManagerCreationParams params, + ) { + return AndroidCookieManager(params); + } + + /// Creates a new [AndroidInAppWebViewController]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InAppWebViewController] in `flutter_inappwebview` instead. + AndroidInAppWebViewController createPlatformInAppWebViewController( + PlatformInAppWebViewControllerCreationParams params, + ) { + return AndroidInAppWebViewController(params); + } + + /// Creates a new empty [AndroidInAppWebViewController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InAppWebViewController] in `flutter_inappwebview` instead. + AndroidInAppWebViewController createPlatformInAppWebViewControllerStatic() { + return AndroidInAppWebViewController.static(); + } + + /// Creates a new [AndroidInAppWebViewWidget]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InAppWebView] in `flutter_inappwebview` instead. + AndroidInAppWebViewWidget createPlatformInAppWebViewWidget( + PlatformInAppWebViewWidgetCreationParams params, + ) { + return AndroidInAppWebViewWidget(params); + } + + /// Creates a new [AndroidFindInteractionController]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [FindInteractionController] in `flutter_inappwebview` instead. + AndroidFindInteractionController createPlatformFindInteractionController( + PlatformFindInteractionControllerCreationParams params, + ) { + return AndroidFindInteractionController(params); + } + + /// Creates a new [AndroidPrintJobController]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PrintJobController] in `flutter_inappwebview` instead. + AndroidPrintJobController createPlatformPrintJobController( + PlatformPrintJobControllerCreationParams params, + ) { + return AndroidPrintJobController(params); + } + + /// Creates a new [AndroidPullToRefreshController]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PullToRefreshController] in `flutter_inappwebview` instead. + AndroidPullToRefreshController createPlatformPullToRefreshController( + PlatformPullToRefreshControllerCreationParams params, + ) { + return AndroidPullToRefreshController(params); + } + + /// Creates a new [AndroidWebMessageChannel]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessageChannel] in `flutter_inappwebview` instead. + AndroidWebMessageChannel createPlatformWebMessageChannel( + PlatformWebMessageChannelCreationParams params, + ) { + return AndroidWebMessageChannel(params); + } + + /// Creates a new empty [AndroidWebMessageChannel] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessageChannel] in `flutter_inappwebview` instead. + AndroidWebMessageChannel createPlatformWebMessageChannelStatic() { + return AndroidWebMessageChannel.static(); + } + + /// Creates a new [AndroidWebMessageListener]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessageListener] in `flutter_inappwebview` instead. + AndroidWebMessageListener createPlatformWebMessageListener( + PlatformWebMessageListenerCreationParams params, + ) { + return AndroidWebMessageListener(params); + } + + /// Creates a new [AndroidJavaScriptReplyProxy]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [JavaScriptReplyProxy] in `flutter_inappwebview` instead. + AndroidJavaScriptReplyProxy createPlatformJavaScriptReplyProxy( + PlatformJavaScriptReplyProxyCreationParams params, + ) { + return AndroidJavaScriptReplyProxy(params); + } + + /// Creates a new [AndroidWebMessagePort]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessagePort] in `flutter_inappwebview` instead. + AndroidWebMessagePort createPlatformWebMessagePort( + PlatformWebMessagePortCreationParams params, + ) { + return AndroidWebMessagePort(params); + } + + /// Creates a new [AndroidWebStorage]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [AndroidWebStorage] in `flutter_inappwebview` instead. + AndroidWebStorage createPlatformWebStorage( + PlatformWebStorageCreationParams params, + ) { + return AndroidWebStorage(params); + } + + /// Creates a new [AndroidStorage]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [AndroidStorage] in `flutter_inappwebview` instead. + AndroidStorage createPlatformStorage( + PlatformStorageCreationParams params, + ) { + return AndroidStorage(params); + } + + /// Creates a new [AndroidLocalStorage]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [AndroidLocalStorage] in `flutter_inappwebview` instead. + AndroidLocalStorage createPlatformLocalStorage( + PlatformLocalStorageCreationParams params, + ) { + return AndroidLocalStorage(params); + } + + /// Creates a new [AndroidSessionStorage]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PlatformSessionStorage] in `flutter_inappwebview` instead. + AndroidSessionStorage createPlatformSessionStorage( + PlatformSessionStorageCreationParams params, + ) { + return AndroidSessionStorage(params); + } + + /// Creates a new [AndroidHeadlessInAppWebView]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [HeadlessInAppWebView] in `flutter_inappwebview` instead. + AndroidHeadlessInAppWebView createPlatformHeadlessInAppWebView( + PlatformHeadlessInAppWebViewCreationParams params, + ) { + return AndroidHeadlessInAppWebView(params); + } + + /// Creates a new [AndroidHttpAuthCredentialDatabase]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [HttpAuthCredentialDatabase] in `flutter_inappwebview` instead. + AndroidHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabase( + PlatformHttpAuthCredentialDatabaseCreationParams params, + ) { + return AndroidHttpAuthCredentialDatabase(params); + } + + /// Creates a new [AndroidInAppBrowser]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InAppBrowser] in `flutter_inappwebview` instead. + AndroidInAppBrowser createPlatformInAppBrowser( + PlatformInAppBrowserCreationParams params, + ) { + return AndroidInAppBrowser(params); + } + + /// Creates a new empty [AndroidInAppBrowser] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InAppBrowser] in `flutter_inappwebview` instead. + AndroidInAppBrowser createPlatformInAppBrowserStatic() { + return AndroidInAppBrowser.static(); + } + + /// Creates a new [AndroidProcessGlobalConfig]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProcessGlobalConfig] in `flutter_inappwebview` instead. + AndroidProcessGlobalConfig createPlatformProcessGlobalConfig( + PlatformProcessGlobalConfigCreationParams params, + ) { + return AndroidProcessGlobalConfig(params); + } + + /// Creates a new [AndroidProxyController]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProxyController] in `flutter_inappwebview` instead. + AndroidProxyController createPlatformProxyController( + PlatformProxyControllerCreationParams params, + ) { + return AndroidProxyController(params); + } + + /// Creates a new [AndroidServiceWorkerController]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ServiceWorkerController] in `flutter_inappwebview` instead. + AndroidServiceWorkerController createPlatformServiceWorkerController( + PlatformServiceWorkerControllerCreationParams params, + ) { + return AndroidServiceWorkerController(params); + } + + /// Creates a new empty [AndroidServiceWorkerController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ServiceWorkerController] in `flutter_inappwebview` instead. + AndroidServiceWorkerController createPlatformServiceWorkerControllerStatic() { + return AndroidServiceWorkerController.static(); + } + + /// Creates a new [AndroidTracingController]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [TracingController] in `flutter_inappwebview` instead. + AndroidTracingController createPlatformTracingController( + PlatformTracingControllerCreationParams params, + ) { + return AndroidTracingController(params); + } + + /// Creates a new [AndroidWebViewAssetLoader]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebViewAssetLoader] in `flutter_inappwebview` instead. + AndroidWebViewAssetLoader createPlatformWebViewAssetLoader( + PlatformWebViewAssetLoaderCreationParams params, + ) { + return AndroidWebViewAssetLoader(params); + } + + /// Creates a new empty [AndroidWebViewAssetLoader] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebViewAssetLoader] in `flutter_inappwebview` instead. + AndroidWebViewAssetLoader createAndroidWebViewAssetLoaderStatic() { + return AndroidWebViewAssetLoader.static(); + } + + /// Creates a new [AndroidPathHandler]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PathHandler] in `flutter_inappwebview` instead. + AndroidPathHandler createPlatformPathHandler( + PlatformPathHandlerCreationParams params, + ) { + return AndroidPathHandler(params); + } + + /// Creates a new [AndroidAssetsPathHandler]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [AssetsPathHandler] in `flutter_inappwebview` instead. + AndroidAssetsPathHandler createPlatformAssetsPathHandler( + PlatformAssetsPathHandlerCreationParams params, + ) { + return AndroidAssetsPathHandler(params); + } + + /// Creates a new [AndroidResourcesPathHandler]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ResourcesPathHandler] in `flutter_inappwebview` instead. + AndroidResourcesPathHandler createPlatformResourcesPathHandler( + PlatformResourcesPathHandlerCreationParams params, + ) { + return AndroidResourcesPathHandler(params); + } + + /// Creates a new [AndroidInternalStoragePathHandler]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InternalStoragePathHandler] in `flutter_inappwebview` instead. + AndroidInternalStoragePathHandler createPlatformInternalStoragePathHandler( + PlatformInternalStoragePathHandlerCreationParams params, + ) { + return AndroidInternalStoragePathHandler(params); + } + + /// Creates a new [wv.AndroidWebViewFeature]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebViewFeature] in `flutter_inappwebview` instead. + wv.AndroidWebViewFeature createPlatformWebViewFeature( + PlatformWebViewFeatureCreationParams params, + ) { + return wv.AndroidWebViewFeature(params); + } + + /// Creates a new empty [wv.AndroidWebViewFeature] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebViewFeature] in `flutter_inappwebview` instead. + wv.AndroidWebViewFeature createPlatformWebViewFeatureStatic() { + return wv.AndroidWebViewFeature.static(); + } +} diff --git a/flutter_inappwebview_android/lib/src/main.dart b/flutter_inappwebview_android/lib/src/main.dart new file mode 100644 index 00000000..d26694c3 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/main.dart @@ -0,0 +1,21 @@ +export 'inappwebview_platform.dart'; +export 'in_app_webview/main.dart'; +export 'in_app_browser/main.dart'; +// export 'chrome_safari_browser/main.dart'; +export 'web_storage/main.dart'; +export 'cookie_manager.dart' hide InternalCookieManager; +export 'http_auth_credentials_database.dart' hide InternalHttpAuthCredentialDatabase; +export 'pull_to_refresh/main.dart'; +export 'web_message/main.dart'; +export 'print_job/main.dart'; +export 'find_interaction/main.dart'; +export 'service_worker_controller.dart'; +export 'webview_feature.dart' + hide InternalWebViewFeature; +export 'proxy_controller.dart' hide InternalProxyController; +export 'webview_asset_loader.dart' + hide + InteranlWebViewAssetLoader, + InteranlPathHandler; +export 'tracing_controller.dart' hide InternalTracingController; +export 'process_global_config.dart' hide InternalProcessGlobalConfig; \ No newline at end of file diff --git a/lib/src/platform_util.dart b/flutter_inappwebview_android/lib/src/platform_util.dart similarity index 96% rename from lib/src/platform_util.dart rename to flutter_inappwebview_android/lib/src/platform_util.dart index 71250cb8..e84f9a15 100644 --- a/lib/src/platform_util.dart +++ b/flutter_inappwebview_android/lib/src/platform_util.dart @@ -3,7 +3,7 @@ import 'package:flutter/services.dart'; ///Platform native utilities class PlatformUtil { static PlatformUtil? _instance; - static const MethodChannel _channel = const MethodChannel( + static const MethodChannel _channel = MethodChannel( 'com.pichillilorenzo/flutter_inappwebview_platformutil'); PlatformUtil._(); diff --git a/flutter_inappwebview_android/lib/src/print_job/main.dart b/flutter_inappwebview_android/lib/src/print_job/main.dart new file mode 100644 index 00000000..4e70ad94 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/print_job/main.dart @@ -0,0 +1 @@ +export 'print_job_controller.dart'; 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 new file mode 100644 index 00000000..771b29ca --- /dev/null +++ b/flutter_inappwebview_android/lib/src/print_job/print_job_controller.dart @@ -0,0 +1,128 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +/// Object specifying creation parameters for creating a [AndroidPrintJobController]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformPrintJobControllerCreationParams] for +/// more information. +@immutable +class AndroidPrintJobControllerCreationParams + extends PlatformPrintJobControllerCreationParams { + /// Creates a new [AndroidPrintJobControllerCreationParams] instance. + const AndroidPrintJobControllerCreationParams( + {required super.id, super.onComplete}); + + /// Creates a [AndroidPrintJobControllerCreationParams] instance based on [PlatformPrintJobControllerCreationParams]. + factory AndroidPrintJobControllerCreationParams.fromPlatformPrintJobControllerCreationParams( + // Recommended placeholder to prevent being broken by platform interface. + // ignore: avoid_unused_constructor_parameters + PlatformPrintJobControllerCreationParams params) { + return AndroidPrintJobControllerCreationParams( + id: params.id, onComplete: params.onComplete); + } +} + +///Class representing a print job eventually returned by [InAppWebViewController.printCurrentPage]. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- MacOS +class AndroidPrintJobController extends PlatformPrintJobController + with ChannelController { + /// Constructs a [AndroidPrintJobController]. + AndroidPrintJobController(PlatformPrintJobControllerCreationParams params) + : super.implementation( + params is AndroidPrintJobControllerCreationParams + ? params + : AndroidPrintJobControllerCreationParams + .fromPlatformPrintJobControllerCreationParams(params), + ) { + channel = MethodChannel( + 'com.pichillilorenzo/flutter_inappwebview_printjobcontroller_${params.id}'); + handler = _handleMethod; + initMethodCallHandler(); + } + + 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"); + } + } + + ///Cancels this print job. + ///You can request cancellation of a queued, started, blocked, or failed print job. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintJob.cancel](https://developer.android.com/reference/android/print/PrintJob#cancel())) + Future cancel() async { + Map args = {}; + await channel?.invokeMethod('cancel', args); + } + + ///Restarts this print job. + ///You can request restart of a failed print job. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintJob.restart](https://developer.android.com/reference/android/print/PrintJob#restart())) + Future restart() async { + Map args = {}; + await channel?.invokeMethod('restart', args); + } + + ///Dismisses the printing-options sheet or popover. + /// + ///You should dismiss the printing options when they are presented in a sheet or + ///animated from a rectangle and the user changes the orientation of the device. + ///(This, of course, assumes your application responds to orientation changes.) + ///You should then present the printing options again once the new orientation takes effect. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + Future dismiss({bool animated: true}) async { + Map args = {}; + args.putIfAbsent("animated", () => animated); + await channel?.invokeMethod('dismiss', args); + } + + ///Gets the [PrintJobInfo] that describes this job. + /// + ///**NOTE**: The returned info object is a snapshot of the + ///current print job state. Every call to this method returns a fresh + ///info object that reflects the current print job state. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintJob.getInfo](https://developer.android.com/reference/android/print/PrintJob#getInfo())) + ///- iOS + ///- MacOS + Future getInfo() async { + Map args = {}; + Map? infoMap = + (await channel?.invokeMethod('getInfo', args))?.cast(); + return PrintJobInfo.fromMap(infoMap); + } + + ///Disposes the print job. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + @override + Future dispose() async { + Map args = {}; + await channel?.invokeMethod('dispose', args); + disposeChannel(); + } +} + diff --git a/flutter_inappwebview_android/lib/src/process_global_config.dart b/flutter_inappwebview_android/lib/src/process_global_config.dart new file mode 100644 index 00000000..8dacc426 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/process_global_config.dart @@ -0,0 +1,102 @@ +import 'dart:async'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +/// Object specifying creation parameters for creating a [AndroidProcessGlobalConfig]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformProcessGlobalConfigCreationParams] for +/// more information. +@immutable +class AndroidProcessGlobalConfigCreationParams + extends PlatformProcessGlobalConfigCreationParams { + /// Creates a new [AndroidProcessGlobalConfigCreationParams] instance. + const AndroidProcessGlobalConfigCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformProcessGlobalConfigCreationParams params, + ) : super(); + + /// Creates a [AndroidProcessGlobalConfigCreationParams] instance based on [PlatformProcessGlobalConfigCreationParams]. + factory AndroidProcessGlobalConfigCreationParams.fromPlatformProcessGlobalConfigCreationParams( + PlatformProcessGlobalConfigCreationParams params) { + return AndroidProcessGlobalConfigCreationParams(params); + } +} + +///Process Global Configuration for [WebView]. +///WebView has some process-global configuration parameters +///that cannot be changed once WebView has been loaded. +///This class allows apps to set these parameters. +/// +///If it is used, the configuration should be set and apply should +///be called prior to loading WebView into the calling process. +///Most of the methods in `android.webkit` and `androidx.webkit` packages load WebView, +///so the configuration should be applied before calling any of these methods. +/// +///The following code configures the data directory suffix that WebView uses and +///then applies the configuration. WebView uses this configuration when it is loaded. +/// +///[apply] can only be called once. +/// +///Only a single thread should access this class at a given time. +/// +///The configuration should be set up as early as possible during application startup, +///to ensure that it happens before any other thread can call a method that loads [WebView]. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView ([Official API - ProcessGlobalConfig](https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig)) +class AndroidProcessGlobalConfig extends PlatformProcessGlobalConfig with ChannelController { + /// Creates a new [AndroidProcessGlobalConfig]. + AndroidProcessGlobalConfig(PlatformProcessGlobalConfigCreationParams params) + : super.implementation( + params is AndroidProcessGlobalConfigCreationParams + ? params + : AndroidProcessGlobalConfigCreationParams + .fromPlatformProcessGlobalConfigCreationParams(params), + ) { + channel = const MethodChannel( + 'com.pichillilorenzo/flutter_inappwebview_processglobalconfig'); + handler = handleMethod; + initMethodCallHandler(); + } + + static AndroidProcessGlobalConfig? _instance; + + ///Gets the [AndroidProcessGlobalConfig] shared instance. + static AndroidProcessGlobalConfig instance() { + return (_instance != null) ? _instance! : _init(); + } + + static AndroidProcessGlobalConfig _init() { + _instance = AndroidProcessGlobalConfig(AndroidProcessGlobalConfigCreationParams( + const PlatformProcessGlobalConfigCreationParams())); + return _instance!; + } + + Future _handleMethod(MethodCall call) async {} + + ///Applies the configuration to be used by [WebView] on loading. + ///This method can only be called once. + /// + ///Calling this method will not cause [WebView] to be loaded and will not block the calling thread. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - ProcessGlobalConfig.apply](https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig#apply(androidx.webkit.ProcessGlobalConfig))) + Future apply({required ProcessGlobalConfigSettings settings}) async { + Map args = {}; + args.putIfAbsent("settings", () => settings.toMap()); + await channel?.invokeMethod('apply', args); + } + + @override + void dispose() { + // empty + } +} + +extension InternalProcessGlobalConfig on AndroidProcessGlobalConfig { + get handleMethod => _handleMethod; +} + diff --git a/flutter_inappwebview_android/lib/src/proxy_controller.dart b/flutter_inappwebview_android/lib/src/proxy_controller.dart new file mode 100644 index 00000000..8735fbe5 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/proxy_controller.dart @@ -0,0 +1,99 @@ +import 'dart:async'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +/// Object specifying creation parameters for creating a [AndroidProxyController]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformProxyControllerCreationParams] for +/// more information. +@immutable +class AndroidProxyControllerCreationParams + extends PlatformProxyControllerCreationParams { + /// Creates a new [AndroidProxyControllerCreationParams] instance. + const AndroidProxyControllerCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformProxyControllerCreationParams params, + ) : super(); + + /// Creates a [AndroidProxyControllerCreationParams] instance based on [PlatformProxyControllerCreationParams]. + factory AndroidProxyControllerCreationParams.fromPlatformProxyControllerCreationParams( + PlatformProxyControllerCreationParams params) { + return AndroidProxyControllerCreationParams(params); + } +} + +///Manages setting and clearing a process-specific override for the Android system-wide proxy settings that govern network requests made by [WebView]. +/// +///[WebView] may make network requests in order to fetch content that is not otherwise read from the file system or provided directly by application code. +///In this case by default the system-wide Android network proxy settings are used to redirect requests to appropriate proxy servers. +/// +///In the rare case that it is necessary for an application to explicitly specify its proxy configuration, +///this API may be used to explicitly specify the proxy rules that govern WebView initiated network requests. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView ([Official API - ProxyController](https://developer.android.com/reference/androidx/webkit/ProxyController)) +class AndroidProxyController extends PlatformProxyController with ChannelController { + /// Creates a new [AndroidProxyController]. + AndroidProxyController(PlatformProxyControllerCreationParams params) + : super.implementation( + params is AndroidProxyControllerCreationParams + ? params + : AndroidProxyControllerCreationParams + .fromPlatformProxyControllerCreationParams(params), + ) { + channel = const MethodChannel( + 'com.pichillilorenzo/flutter_inappwebview_proxycontroller'); + handler = handleMethod; + initMethodCallHandler(); + } + + static AndroidProxyController? _instance; + + ///Gets the [AndroidProxyController] shared instance. + static AndroidProxyController instance() { + return (_instance != null) ? _instance! : _init(); + } + + static AndroidProxyController _init() { + _instance = AndroidProxyController(AndroidProxyControllerCreationParams( + const PlatformProxyControllerCreationParams())); + return _instance!; + } + + Future _handleMethod(MethodCall call) async {} + + ///Sets [ProxySettings] which will be used by all [WebView]s in the app. + ///URLs that match patterns in the bypass list will not be directed to any proxy. + ///Instead, the request will be made directly to the origin specified by the URL. + ///Network connections are not guaranteed to immediately use the new proxy setting; wait for the method to return before loading a page. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - ProxyController.setProxyOverride](https://developer.android.com/reference/androidx/webkit/ProxyController#setProxyOverride(androidx.webkit.ProxyConfig,%20java.util.concurrent.Executor,%20java.lang.Runnable))) + Future setProxyOverride({required ProxySettings settings}) async { + Map args = {}; + args.putIfAbsent("settings", () => settings.toMap()); + await channel?.invokeMethod('setProxyOverride', args); + } + + ///Clears the proxy settings. + ///Network connections are not guaranteed to immediately use the new proxy setting; wait for the method to return before loading a page. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - ProxyController.clearProxyOverride](https://developer.android.com/reference/androidx/webkit/ProxyController#clearProxyOverride(java.util.concurrent.Executor,%20java.lang.Runnable))) + Future clearProxyOverride() async { + Map args = {}; + await channel?.invokeMethod('clearProxyOverride', args); + } + + @override + void dispose() { + // empty + } +} + +extension InternalProxyController on AndroidProxyController { + get handleMethod => _handleMethod; +} diff --git a/flutter_inappwebview_android/lib/src/pull_to_refresh/main.dart b/flutter_inappwebview_android/lib/src/pull_to_refresh/main.dart new file mode 100644 index 00000000..586af9d8 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/pull_to_refresh/main.dart @@ -0,0 +1 @@ +export 'pull_to_refresh_controller.dart' hide InternalPullToRefreshController; 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 new file mode 100644 index 00000000..8777d5e5 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/pull_to_refresh/pull_to_refresh_controller.dart @@ -0,0 +1,258 @@ +import 'dart:ui'; + +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +/// Object specifying creation parameters for creating a [AndroidPullToRefreshController]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformPullToRefreshControllerCreationParams] for +/// more information. +class AndroidPullToRefreshControllerCreationParams + extends PlatformPullToRefreshControllerCreationParams { + /// Creates a new [AndroidPullToRefreshControllerCreationParams] instance. + AndroidPullToRefreshControllerCreationParams( + {super.onRefresh, super.options, super.settings}); + + /// Creates a [AndroidPullToRefreshControllerCreationParams] instance based on [PlatformPullToRefreshControllerCreationParams]. + factory AndroidPullToRefreshControllerCreationParams.fromPlatformPullToRefreshControllerCreationParams( + // Recommended placeholder to prevent being broken by platform interface. + // ignore: avoid_unused_constructor_parameters + PlatformPullToRefreshControllerCreationParams params) { + return AndroidPullToRefreshControllerCreationParams( + onRefresh: params.onRefresh, + options: params.options, + settings: params.settings); + } +} + +///A standard controller that can initiate the refreshing of a scroll view’s contents. +///This should be used whenever the user can refresh the contents of a WebView via a vertical swipe gesture. +/// +///All the methods should be called only when the WebView has been created or is already running +///(for example [WebView.onWebViewCreated] or [InAppBrowser.onBrowserCreated]). +/// +///**NOTE for Android**: to be able to use the "pull-to-refresh" feature, [InAppWebViewSettings.useHybridComposition] must be `true`. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +class AndroidPullToRefreshController extends PlatformPullToRefreshController + with ChannelController { + ///Debug settings. + static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings(); + + /// Constructs a [AndroidPullToRefreshController]. + AndroidPullToRefreshController( + PlatformPullToRefreshControllerCreationParams params) + : super.implementation( + params is AndroidPullToRefreshControllerCreationParams + ? params + : AndroidPullToRefreshControllerCreationParams + .fromPlatformPullToRefreshControllerCreationParams(params), + ); + + _debugLog(String method, dynamic args) { + debugLog( + className: this.runtimeType.toString(), + debugLoggingSettings: + AndroidPullToRefreshController.debugLoggingSettings, + method: method, + args: args); + } + + Future _handleMethod(MethodCall call) async { + _debugLog(call.method, call.arguments); + + switch (call.method) { + case "onRefresh": + if (params.onRefresh != null) params.onRefresh!(); + break; + default: + throw UnimplementedError("Unimplemented ${call.method} method"); + } + return null; + } + + ///Sets whether the pull-to-refresh feature is enabled or not. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.setEnabled](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setEnabled(boolean))) + ///- iOS ([Official API - UIScrollView.refreshControl](https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol)) + @override + Future setEnabled(bool enabled) async { + Map args = {}; + args.putIfAbsent('enabled', () => enabled); + await channel?.invokeMethod('setEnabled', args); + } + + ///Returns `true` is pull-to-refresh feature is enabled, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - View.isEnabled](https://developer.android.com/reference/android/view/View#isEnabled())) + ///- iOS ([Official API - UIScrollView.refreshControl](https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol)) + @override + Future isEnabled() async { + Map args = {}; + return await channel?.invokeMethod('isEnabled', args) ?? false; + } + + Future _setRefreshing(bool refreshing) async { + Map args = {}; + args.putIfAbsent('refreshing', () => refreshing); + await channel?.invokeMethod('setRefreshing', args); + } + + ///Tells the controller that a refresh operation was started programmatically. + /// + ///Call this method when an external event source triggers a programmatic refresh of your scrolling view. + ///This method updates the state of the refresh control to reflect the in-progress refresh operation. + ///When the refresh operation ends, be sure to call the [endRefreshing] method to return the controller to its default state. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + @override + Future beginRefreshing() async { + return await _setRefreshing(true); + } + + ///Tells the controller that a refresh operation has ended. + /// + ///Call this method at the end of any refresh operation (whether it was initiated programmatically or by the user) + ///to return the refresh control to its default state. + ///If the refresh control is at least partially visible, calling this method also hides it. + ///If animations are also enabled, the control is hidden using an animation. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + @override + Future endRefreshing() async { + await _setRefreshing(false); + } + + ///Returns whether a refresh operation has been triggered and is in progress. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.isRefreshing](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#isRefreshing())) + ///- iOS ([Official API - UIRefreshControl.isRefreshing](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624844-isrefreshing)) + @override + Future isRefreshing() async { + Map args = {}; + return await channel?.invokeMethod('isRefreshing', args) ?? false; + } + + ///Sets the color of the refresh control. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.setColorSchemeColors](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setColorSchemeColors(int...))) + ///- iOS ([Official API - UIRefreshControl.tintColor](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624847-tintcolor)) + @override + Future setColor(Color color) async { + Map args = {}; + args.putIfAbsent('color', () => color.toHex()); + await channel?.invokeMethod('setColor', args); + } + + ///Sets the background color of the refresh control. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.setProgressBackgroundColorSchemeColor](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setProgressBackgroundColorSchemeColor(int))) + ///- iOS ([Official API - UIView.backgroundColor](https://developer.apple.com/documentation/uikit/uiview/1622591-backgroundcolor)) + @override + Future setBackgroundColor(Color color) async { + Map args = {}; + args.putIfAbsent('color', () => color.toHex()); + await channel?.invokeMethod('setBackgroundColor', args); + } + + ///Set the distance to trigger a sync in dips. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.setDistanceToTriggerSync](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setDistanceToTriggerSync(int))) + @override + Future setDistanceToTriggerSync(int distanceToTriggerSync) async { + Map args = {}; + args.putIfAbsent('distanceToTriggerSync', () => distanceToTriggerSync); + await channel?.invokeMethod('setDistanceToTriggerSync', args); + } + + ///Sets the distance that the refresh indicator can be pulled beyond its resting position during a swipe gesture. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.setSlingshotDistance](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setSlingshotDistance(int))) + @override + Future setSlingshotDistance(int slingshotDistance) async { + Map args = {}; + args.putIfAbsent('slingshotDistance', () => slingshotDistance); + await channel?.invokeMethod('setSlingshotDistance', args); + } + + ///Gets the default distance that the refresh indicator can be pulled beyond its resting position during a swipe gesture. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.DEFAULT_SLINGSHOT_DISTANCE](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#DEFAULT_SLINGSHOT_DISTANCE())) + @override + Future getDefaultSlingshotDistance() async { + Map args = {}; + return await channel?.invokeMethod( + 'getDefaultSlingshotDistance', args) ?? + 0; + } + + ///Use [setIndicatorSize] instead. + @Deprecated("Use setIndicatorSize instead") + @override + Future setSize(AndroidPullToRefreshSize size) async { + Map args = {}; + args.putIfAbsent('size', () => size.toNativeValue()); + await channel?.invokeMethod('setSize', args); + } + + ///Sets the size of the refresh indicator. One of [PullToRefreshSize.DEFAULT], or [PullToRefreshSize.LARGE]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.setSize](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setSize(int))) + @override + Future setIndicatorSize(PullToRefreshSize size) async { + Map args = {}; + args.putIfAbsent('size', () => size.toNativeValue()); + await channel?.invokeMethod('setSize', args); + } + + ///Use [setStyledTitle] instead. + @Deprecated("Use setStyledTitle instead") + @override + Future setAttributedTitle(IOSNSAttributedString attributedTitle) async { + Map args = {}; + args.putIfAbsent('attributedTitle', () => attributedTitle.toMap()); + await channel?.invokeMethod('setStyledTitle', args); + } + + ///Sets the styled title text to display in the refresh control. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - UIRefreshControl.attributedTitle](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624845-attributedtitle)) + @override + Future setStyledTitle(AttributedString attributedTitle) async { + Map args = {}; + args.putIfAbsent('attributedTitle', () => attributedTitle.toMap()); + await channel?.invokeMethod('setStyledTitle', args); + } + + ///Disposes the controller. + @override + void dispose({bool isKeepAlive = false}) { + disposeChannel(removeMethodCallHandler: !isKeepAlive); + } +} + +extension InternalPullToRefreshController on AndroidPullToRefreshController { + void init(dynamic id) { + channel = MethodChannel( + 'com.pichillilorenzo/flutter_inappwebview_pull_to_refresh_$id'); + handler = _handleMethod; + initMethodCallHandler(); + } +} diff --git a/flutter_inappwebview_android/lib/src/service_worker_controller.dart b/flutter_inappwebview_android/lib/src/service_worker_controller.dart new file mode 100644 index 00000000..0a07137a --- /dev/null +++ b/flutter_inappwebview_android/lib/src/service_worker_controller.dart @@ -0,0 +1,212 @@ +import 'dart:async'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +/// Object specifying creation parameters for creating a [AndroidServiceWorkerController]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformServiceWorkerControllerCreationParams] for +/// more information. +@immutable +class AndroidServiceWorkerControllerCreationParams + extends PlatformServiceWorkerControllerCreationParams { + /// Creates a new [AndroidServiceWorkerControllerCreationParams] instance. + const AndroidServiceWorkerControllerCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformServiceWorkerControllerCreationParams params, + ) : super(); + + /// Creates a [AndroidServiceWorkerControllerCreationParams] instance based on [PlatformServiceWorkerControllerCreationParams]. + factory AndroidServiceWorkerControllerCreationParams.fromPlatformServiceWorkerControllerCreationParams( + PlatformServiceWorkerControllerCreationParams params) { + return AndroidServiceWorkerControllerCreationParams(params); + } +} + +///Class that manages Service Workers used by [WebView]. +/// +///**NOTE**: available on Android 24+. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView ([Official API - ServiceWorkerControllerCompat](https://developer.android.com/reference/androidx/webkit/ServiceWorkerControllerCompat)) +class AndroidServiceWorkerController extends PlatformServiceWorkerController + with ChannelController { + /// Creates a new [AndroidServiceWorkerController]. + AndroidServiceWorkerController( + PlatformServiceWorkerControllerCreationParams params) + : super.implementation( + params is AndroidServiceWorkerControllerCreationParams + ? params + : AndroidServiceWorkerControllerCreationParams + .fromPlatformServiceWorkerControllerCreationParams(params), + ) { + channel = const MethodChannel( + 'com.pichillilorenzo/flutter_inappwebview_serviceworkercontroller'); + handler = handleMethod; + initMethodCallHandler(); + } + + factory AndroidServiceWorkerController.static() { + return instance(); + } + + static AndroidServiceWorkerController? _instance; + + ///Gets the [AndroidServiceWorkerController] shared instance. + static AndroidServiceWorkerController instance() { + return (_instance != null) ? _instance! : _init(); + } + + static AndroidServiceWorkerController _init() { + _instance = AndroidServiceWorkerController( + AndroidServiceWorkerControllerCreationParams( + const PlatformServiceWorkerControllerCreationParams())); + return _instance!; + } + + ServiceWorkerClient? _serviceWorkerClient; + + ServiceWorkerClient? get serviceWorkerClient => _serviceWorkerClient; + + ///Sets the client to capture service worker related callbacks. + ///A [ServiceWorkerClient] should be set before any service workers are active, e.g. a safe place is before any WebView instances are created or pages loaded. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - ServiceWorkerControllerCompat.setServiceWorkerClient](https://developer.android.com/reference/androidx/webkit/ServiceWorkerControllerCompat#setServiceWorkerClient(androidx.webkit.ServiceWorkerClientCompat))) + Future setServiceWorkerClient(ServiceWorkerClient? value) async { + Map args = {}; + args.putIfAbsent('isNull', () => value == null); + await channel?.invokeMethod("setServiceWorkerClient", args); + _serviceWorkerClient = value; + } + + Future _handleMethod(MethodCall call) async { + AndroidServiceWorkerController controller = + AndroidServiceWorkerController.instance(); + ServiceWorkerClient? serviceWorkerClient = controller._serviceWorkerClient; + + switch (call.method) { + case "shouldInterceptRequest": + if (serviceWorkerClient != null && + serviceWorkerClient.shouldInterceptRequest != null) { + Map arguments = + call.arguments.cast(); + WebResourceRequest request = WebResourceRequest.fromMap(arguments)!; + + return (await serviceWorkerClient.shouldInterceptRequest!(request)) + ?.toMap(); + } + break; + default: + throw UnimplementedError("Unimplemented ${call.method} method"); + } + + return null; + } + + ///Gets whether Service Workers support content URL access. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CONTENT_ACCESS]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowContentAccess() + Future getAllowContentAccess() async { + Map args = {}; + return await channel?.invokeMethod('getAllowContentAccess', args) ?? false; + } + + ///Gets whether Service Workers support file access. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_FILE_ACCESS]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowFileAccess() + Future getAllowFileAccess() async { + Map args = {}; + return await channel?.invokeMethod('getAllowFileAccess', args) ?? + false; + } + + ///Gets whether Service Workers are prohibited from loading any resources from the network. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getBlockNetworkLoads() + Future getBlockNetworkLoads() async { + Map args = {}; + return await channel?.invokeMethod('getBlockNetworkLoads', args) ?? + false; + } + + ///Gets the current setting for overriding the cache mode. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CACHE_MODE]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getCacheMode() + Future getCacheMode() async { + Map args = {}; + return CacheMode.fromNativeValue( + await channel?.invokeMethod('getCacheMode', args)); + } + + ///Enables or disables content URL access from Service Workers. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CONTENT_ACCESS]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowContentAccess(boolean) + Future setAllowContentAccess(bool allow) async { + Map args = {}; + args.putIfAbsent("allow", () => allow); + await channel?.invokeMethod('setAllowContentAccess', args); + } + + ///Enables or disables file access within Service Workers. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_FILE_ACCESS]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowFileAccess(boolean) + Future setAllowFileAccess(bool allow) async { + Map args = {}; + args.putIfAbsent("allow", () => allow); + await channel?.invokeMethod('setAllowFileAccess', args); + } + + ///Sets whether Service Workers should not load resources from the network. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setBlockNetworkLoads(boolean) + Future setBlockNetworkLoads(bool flag) async { + Map args = {}; + args.putIfAbsent("flag", () => flag); + await channel?.invokeMethod('setBlockNetworkLoads', args); + } + + ///Overrides the way the cache is used. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CACHE_MODE]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setCacheMode(int) + Future setCacheMode(CacheMode mode) async { + Map args = {}; + args.putIfAbsent("mode", () => mode.toNativeValue()); + await channel?.invokeMethod('setCacheMode', args); + } + + @override + void dispose() { + // empty + } +} + +extension InternalServiceWorkerController on AndroidServiceWorkerController { + get handleMethod => _handleMethod; +} diff --git a/flutter_inappwebview_android/lib/src/tracing_controller.dart b/flutter_inappwebview_android/lib/src/tracing_controller.dart new file mode 100644 index 00000000..5616e784 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/tracing_controller.dart @@ -0,0 +1,113 @@ +import 'dart:async'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +/// Object specifying creation parameters for creating a [AndroidTracingController]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformTracingControllerCreationParams] for +/// more information. +@immutable +class AndroidTracingControllerCreationParams + extends PlatformTracingControllerCreationParams { + /// Creates a new [AndroidTracingControllerCreationParams] instance. + const AndroidTracingControllerCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformTracingControllerCreationParams params, + ) : super(); + + /// Creates a [AndroidTracingControllerCreationParams] instance based on [PlatformTracingControllerCreationParams]. + factory AndroidTracingControllerCreationParams.fromPlatformTracingControllerCreationParams( + PlatformTracingControllerCreationParams params) { + return AndroidTracingControllerCreationParams(params); + } +} + +///Manages tracing of [WebView]s. +///In particular provides functionality for the app to enable/disable tracing of parts of code and to collect tracing data. +///This is useful for profiling performance issues, debugging and memory usage analysis in production and real life scenarios. +/// +///The resulting trace data is sent back as a byte sequence in json format. +///This file can be loaded in "chrome://tracing" for further analysis. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView ([Official API - TracingController](https://developer.android.com/reference/androidx/webkit/TracingController)) +class AndroidTracingController extends PlatformTracingController with ChannelController { + /// Creates a new [AndroidTracingController]. + AndroidTracingController(PlatformTracingControllerCreationParams params) + : super.implementation( + params is AndroidTracingControllerCreationParams + ? params + : AndroidTracingControllerCreationParams + .fromPlatformTracingControllerCreationParams(params), + ) { + channel = const MethodChannel( + 'com.pichillilorenzo/flutter_inappwebview_tracingcontroller'); + handler = handleMethod; + initMethodCallHandler(); + } + + static AndroidTracingController? _instance; + + ///Gets the [AndroidTracingController] shared instance. + static AndroidTracingController instance() { + return (_instance != null) ? _instance! : _init(); + } + + static AndroidTracingController _init() { + _instance = AndroidTracingController(AndroidTracingControllerCreationParams( + const PlatformTracingControllerCreationParams())); + return _instance!; + } + + Future _handleMethod(MethodCall call) async {} + + ///Starts tracing all [WebView]s. + ///Depending on the trace mode in trace config specifies how the trace events are recorded. + ///For tracing modes [TracingMode.RECORD_UNTIL_FULL] and [TracingMode.RECORD_CONTINUOUSLY] + ///the events are recorded using an internal buffer and flushed to the outputStream + ///when [stop] is called. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - TracingController.start](https://developer.android.com/reference/android/webkit/TracingController#start(android.webkit.TracingConfig))) + Future start({required TracingSettings settings}) async { + Map args = {}; + args.putIfAbsent("settings", () => settings.toMap()); + await channel?.invokeMethod('start', args); + } + + ///Stops tracing and flushes tracing data to the specified output stream. + ///The data is sent to the specified output stream in json format typically in + ///chunks. + /// + ///Returns `false` if the WebView framework was not tracing at the time of the call, + ///`true` otherwise. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - TracingController.stop](https://developer.android.com/reference/android/webkit/TracingController#stop(java.io.OutputStream,%20java.util.concurrent.Executor))) + Future stop({String? filePath}) async { + Map args = {}; + args.putIfAbsent("filePath", () => filePath); + return await channel?.invokeMethod('stop', args) ?? false; + } + + ///Returns whether the WebView framework is tracing. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - TracingController.isTracing](https://developer.android.com/reference/android/webkit/TracingController#isTracing())) + Future isTracing() async { + Map args = {}; + return await channel?.invokeMethod('isTracing', args) ?? false; + } + + @override + void dispose() { + // empty + } +} + +extension InternalTracingController on AndroidTracingController { + get handleMethod => _handleMethod; +} diff --git a/flutter_inappwebview_android/lib/src/web_message/main.dart b/flutter_inappwebview_android/lib/src/web_message/main.dart new file mode 100644 index 00000000..d41e30c7 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/web_message/main.dart @@ -0,0 +1,3 @@ +export 'web_message_port.dart' hide InternalWebMessagePort; +export 'web_message_channel.dart' hide InternalWebMessageChannel; +export 'web_message_listener.dart'; diff --git a/flutter_inappwebview_android/lib/src/web_message/web_message_channel.dart b/flutter_inappwebview_android/lib/src/web_message/web_message_channel.dart new file mode 100644 index 00000000..2661b3ba --- /dev/null +++ b/flutter_inappwebview_android/lib/src/web_message/web_message_channel.dart @@ -0,0 +1,127 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; +import 'web_message_port.dart'; + +/// Object specifying creation parameters for creating a [AndroidWebMessageChannel]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformWebMessageChannelCreationParams] for +/// more information. +@immutable +class AndroidWebMessageChannelCreationParams + extends PlatformWebMessageChannelCreationParams { + /// Creates a new [AndroidWebMessageChannelCreationParams] instance. + const AndroidWebMessageChannelCreationParams( + {required super.id, required super.port1, required super.port2}); + + /// Creates a [AndroidWebMessageChannelCreationParams] instance based on [PlatformWebMessageChannelCreationParams]. + factory AndroidWebMessageChannelCreationParams.fromPlatformWebMessageChannelCreationParams( + // Recommended placeholder to prevent being broken by platform interface. + // ignore: avoid_unused_constructor_parameters + PlatformWebMessageChannelCreationParams params) { + return AndroidWebMessageChannelCreationParams( + id: params.id, port1: params.port1, port2: params.port2); + } + + @override + String toString() { + return 'AndroidWebMessageChannelCreationParams{id: $id, port1: $port1, port2: $port2}'; + } +} + +///The representation of the [HTML5 message channels](https://html.spec.whatwg.org/multipage/web-messaging.html#message-channels). +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- MacOS +class AndroidWebMessageChannel extends PlatformWebMessageChannel + with ChannelController { + /// Constructs a [AndroidWebMessageChannel]. + AndroidWebMessageChannel(PlatformWebMessageChannelCreationParams params) + : super.implementation( + params is AndroidWebMessageChannelCreationParams + ? params + : AndroidWebMessageChannelCreationParams + .fromPlatformWebMessageChannelCreationParams(params), + ) { + channel = MethodChannel( + 'com.pichillilorenzo/flutter_inappwebview_web_message_channel_${params.id}'); + handler = _handleMethod; + initMethodCallHandler(); + } + + static final AndroidWebMessageChannel _staticValue = AndroidWebMessageChannel( + AndroidWebMessageChannelCreationParams( + id: '', + port1: AndroidWebMessagePort( + AndroidWebMessagePortCreationParams(index: 0)), + port2: AndroidWebMessagePort( + AndroidWebMessagePortCreationParams(index: 1)))); + + factory AndroidWebMessageChannel.static() { + return _staticValue; + } + + AndroidWebMessagePort get _androidPort1 => + port1 as AndroidWebMessagePort; + + AndroidWebMessagePort get _androidPort2 => + port2 as AndroidWebMessagePort; + + static AndroidWebMessageChannel? _fromMap(Map? map) { + if (map == null) { + return null; + } + var webMessageChannel = AndroidWebMessageChannel( + AndroidWebMessageChannelCreationParams( + id: map["id"], + port1: AndroidWebMessagePort( + AndroidWebMessagePortCreationParams(index: 0)), + port2: AndroidWebMessagePort( + AndroidWebMessagePortCreationParams(index: 1)))); + webMessageChannel._androidPort1.webMessageChannel = webMessageChannel; + webMessageChannel._androidPort2.webMessageChannel = webMessageChannel; + return webMessageChannel; + } + + Future _handleMethod(MethodCall call) async { + switch (call.method) { + case "onMessage": + int index = call.arguments["index"]; + var port = index == 0 ? _androidPort1 : _androidPort2; + if (port.onMessage != null) { + WebMessage? message = call.arguments["message"] != null + ? WebMessage.fromMap( + call.arguments["message"].cast()) + : null; + port.onMessage!(message); + } + break; + default: + throw UnimplementedError("Unimplemented ${call.method} method"); + } + return null; + } + + @override + AndroidWebMessageChannel? fromMap(Map? map) { + return _fromMap(map); + } + + ///Disposes the web message channel. + @override + void dispose() { + disposeChannel(); + } + + @override + String toString() { + return 'AndroidWebMessageChannel{id: $id, port1: $port1, port2: $port2}'; + } +} + +extension InternalWebMessageChannel on AndroidWebMessageChannel { + MethodChannel? get internalChannel => channel; +} diff --git a/flutter_inappwebview_android/lib/src/web_message/web_message_listener.dart b/flutter_inappwebview_android/lib/src/web_message/web_message_listener.dart new file mode 100644 index 00000000..115f4737 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/web_message/web_message_listener.dart @@ -0,0 +1,176 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +/// Object specifying creation parameters for creating a [AndroidWebMessageListener]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformWebMessageListenerCreationParams] for +/// more information. +@immutable +class AndroidWebMessageListenerCreationParams + extends PlatformWebMessageListenerCreationParams { + /// Creates a new [AndroidWebMessageListenerCreationParams] instance. + const AndroidWebMessageListenerCreationParams( + {required this.allowedOriginRules, + required super.jsObjectName, + super.onPostMessage}); + + /// Creates a [AndroidWebMessageListenerCreationParams] instance based on [PlatformWebMessageListenerCreationParams]. + factory AndroidWebMessageListenerCreationParams.fromPlatformWebMessageListenerCreationParams( + // Recommended placeholder to prevent being broken by platform interface. + // ignore: avoid_unused_constructor_parameters + PlatformWebMessageListenerCreationParams params) { + return AndroidWebMessageListenerCreationParams( + allowedOriginRules: params.allowedOriginRules ?? Set.from(["*"]), + jsObjectName: params.jsObjectName, + onPostMessage: params.onPostMessage); + } + + @override + final Set allowedOriginRules; + + @override + String toString() { + return 'AndroidWebMessageListenerCreationParams{jsObjectName: $jsObjectName, allowedOriginRules: $allowedOriginRules, onPostMessage: $onPostMessage}'; + } +} + +///This listener receives messages sent on the JavaScript object which was injected by [InAppWebViewController.addWebMessageListener]. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- MacOS +class AndroidWebMessageListener extends PlatformWebMessageListener + with ChannelController { + /// Constructs a [AndroidWebMessageListener]. + AndroidWebMessageListener(PlatformWebMessageListenerCreationParams params) + : super.implementation( + params is AndroidWebMessageListenerCreationParams + ? params + : AndroidWebMessageListenerCreationParams + .fromPlatformWebMessageListenerCreationParams(params), + ) { + assert(!this._androidParams.allowedOriginRules.contains(""), + "allowedOriginRules cannot contain empty strings"); + channel = MethodChannel( + 'com.pichillilorenzo/flutter_inappwebview_web_message_listener_${_id}_${params.jsObjectName}'); + handler = _handleMethod; + initMethodCallHandler(); + } + + ///Message Listener ID used internally. + final String _id = IdGenerator.generate(); + + AndroidJavaScriptReplyProxy? _replyProxy; + + AndroidWebMessageListenerCreationParams get _androidParams => + params as AndroidWebMessageListenerCreationParams; + + Future _handleMethod(MethodCall call) async { + switch (call.method) { + case "onPostMessage": + if (_replyProxy == null) { + _replyProxy = AndroidJavaScriptReplyProxy( + PlatformJavaScriptReplyProxyCreationParams( + webMessageListener: this)); + } + if (onPostMessage != null) { + WebMessage? message = call.arguments["message"] != null + ? WebMessage.fromMap( + call.arguments["message"].cast()) + : null; + WebUri? sourceOrigin = call.arguments["sourceOrigin"] != null + ? WebUri(call.arguments["sourceOrigin"]) + : null; + bool isMainFrame = call.arguments["isMainFrame"]; + onPostMessage!( + message, sourceOrigin, isMainFrame, _replyProxy!); + } + break; + default: + throw UnimplementedError("Unimplemented ${call.method} method"); + } + return null; + } + + @override + void dispose() { + disposeChannel(); + } + + Map toMap() { + return { + "id": _id, + "jsObjectName": params.jsObjectName, + "allowedOriginRules": _androidParams.allowedOriginRules.toList(), + }; + } + + Map toJson() { + return this.toMap(); + } + + @override + String toString() { + return 'AndroidWebMessageListener{id: ${_id}, jsObjectName: ${params.jsObjectName}, allowedOriginRules: ${params.allowedOriginRules}, replyProxy: $_replyProxy}'; + } +} + +/// Object specifying creation parameters for creating a [AndroidJavaScriptReplyProxy]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformJavaScriptReplyProxyCreationParams] for +/// more information. +@immutable +class AndroidJavaScriptReplyProxyCreationParams + extends PlatformJavaScriptReplyProxyCreationParams { + /// Creates a new [AndroidJavaScriptReplyProxyCreationParams] instance. + const AndroidJavaScriptReplyProxyCreationParams( + {required super.webMessageListener}); + + /// Creates a [AndroidJavaScriptReplyProxyCreationParams] instance based on [PlatformJavaScriptReplyProxyCreationParams]. + factory AndroidJavaScriptReplyProxyCreationParams.fromPlatformJavaScriptReplyProxyCreationParams( + // Recommended placeholder to prevent being broken by platform interface. + // ignore: avoid_unused_constructor_parameters + PlatformJavaScriptReplyProxyCreationParams params) { + return AndroidJavaScriptReplyProxyCreationParams( + webMessageListener: params.webMessageListener); + } +} + +///This class represents the JavaScript object injected by [InAppWebViewController.addWebMessageListener]. +///An instance will be given by [AndroidWebMessageListener.onPostMessage]. +///The app can use `postMessage(String)` to talk to the JavaScript context. +/// +///There is a 1:1 relationship between this object and the JavaScript object in a frame. +class AndroidJavaScriptReplyProxy extends PlatformJavaScriptReplyProxy { + /// Constructs a [AndroidWebMessageListener]. + AndroidJavaScriptReplyProxy(PlatformJavaScriptReplyProxyCreationParams params) + : super.implementation( + params is AndroidJavaScriptReplyProxyCreationParams + ? params + : AndroidJavaScriptReplyProxyCreationParams + .fromPlatformJavaScriptReplyProxyCreationParams(params), + ); + + AndroidWebMessageListener get _androidWebMessageListener => + params.webMessageListener as AndroidWebMessageListener; + + ///Post a [message] to the injected JavaScript object which sent this [AndroidJavaScriptReplyProxy]. + /// + ///If [message] is of type [WebMessageType.ARRAY_BUFFER], be aware that large byte buffers can lead to out-of-memory crashes on low-end devices. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/JavaScriptReplyProxy#postMessage(java.lang.String) + Future postMessage(WebMessage message) async { + Map args = {}; + args.putIfAbsent('message', () => message.toMap()); + await _androidWebMessageListener.channel?.invokeMethod('postMessage', args); + } + + @override + String toString() { + return 'AndroidJavaScriptReplyProxy{}'; + } +} diff --git a/flutter_inappwebview_android/lib/src/web_message/web_message_port.dart b/flutter_inappwebview_android/lib/src/web_message/web_message_port.dart new file mode 100644 index 00000000..9e171f98 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/web_message/web_message_port.dart @@ -0,0 +1,114 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +import 'web_message_channel.dart'; + +/// Object specifying creation parameters for creating a [AndroidWebMessagePort]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformWebMessagePortCreationParams] for +/// more information. +@immutable +class AndroidWebMessagePortCreationParams + extends PlatformWebMessagePortCreationParams { + /// Creates a new [AndroidWebMessagePortCreationParams] instance. + const AndroidWebMessagePortCreationParams( + {required super.index}); + + /// Creates a [AndroidWebMessagePortCreationParams] instance based on [PlatformWebMessagePortCreationParams]. + factory AndroidWebMessagePortCreationParams.fromPlatformWebMessagePortCreationParams( + // Recommended placeholder to prevent being broken by platform interface. + // ignore: avoid_unused_constructor_parameters + PlatformWebMessagePortCreationParams params) { + return AndroidWebMessagePortCreationParams( + index: params.index); + } + + @override + String toString() { + return 'AndroidWebMessagePortCreationParams{index: $index}'; + } +} + +///The representation of the [HTML5 message ports](https://html.spec.whatwg.org/multipage/comms.html#messageport). +/// +///A Message port represents one endpoint of a Message Channel. In Android webview, there is no separate Message Channel object. +///When a message channel is created, both ports are tangled to each other and started. +///See [InAppWebViewController.createWebMessageChannel] for creating a message channel. +/// +///When a message port is first created or received via transfer, it does not have a [WebMessageCallback] to receive web messages. +///On Android, the messages are queued until a [WebMessageCallback] is set. +/// +///A message port should be closed when it is not used by the embedder application anymore. +///A closed port cannot be transferred or cannot be reopened to send messages. +///Close can be called multiple times. +/// +///When a port is transferred to JavaScript, it cannot be used to send or receive messages at the Dart side anymore. +///Different from HTML5 Spec, a port cannot be transferred if one of these has ever happened: i. a message callback was set, ii. a message was posted on it. +///A transferred port cannot be closed by the application, since the ownership is also transferred. +/// +///It is possible to transfer both ports of a channel to JavaScript, for example for communication between subframes. +class AndroidWebMessagePort extends PlatformWebMessagePort { + + WebMessageCallback? _onMessage; + late AndroidWebMessageChannel _webMessageChannel; + + /// Constructs a [AndroidWebMessagePort]. + AndroidWebMessagePort( + PlatformWebMessagePortCreationParams params) + : super.implementation( + params is AndroidWebMessagePortCreationParams + ? params + : AndroidWebMessagePortCreationParams + .fromPlatformWebMessagePortCreationParams(params), + ); + + ///Sets a callback to receive message events on the main thread. + Future setWebMessageCallback(WebMessageCallback? onMessage) async { + Map args = {}; + args.putIfAbsent('index', () => params.index); + await _webMessageChannel.internalChannel + ?.invokeMethod('setWebMessageCallback', args); + this._onMessage = onMessage; + } + + ///Post a WebMessage to the entangled port. + Future postMessage(WebMessage message) async { + Map args = {}; + args.putIfAbsent('index', () => params.index); + args.putIfAbsent('message', () => message.toMap()); + await _webMessageChannel.internalChannel?.invokeMethod('postMessage', args); + } + + ///Close the message port and free any resources associated with it. + Future close() async { + Map args = {}; + args.putIfAbsent('index', () => params.index); + await _webMessageChannel.internalChannel?.invokeMethod('close', args); + } + + Map toMap() { + return { + "index": params.index, + "webMessageChannelId": this._webMessageChannel.params.id + }; + } + + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'AndroidWebMessagePort{index: ${params.index}}'; + } +} + +extension InternalWebMessagePort on AndroidWebMessagePort { + WebMessageCallback? get onMessage => _onMessage; + void set onMessage(WebMessageCallback? value) => _onMessage = value; + + AndroidWebMessageChannel get webMessageChannel => _webMessageChannel; + void set webMessageChannel(AndroidWebMessageChannel value) => + _webMessageChannel = value; +} diff --git a/flutter_inappwebview_android/lib/src/web_storage/main.dart b/flutter_inappwebview_android/lib/src/web_storage/main.dart new file mode 100644 index 00000000..7265ae52 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/web_storage/main.dart @@ -0,0 +1,2 @@ +export 'web_storage.dart'; +export 'web_storage_manager.dart' hide InternalWebStorageManager; diff --git a/flutter_inappwebview_android/lib/src/web_storage/web_storage.dart b/flutter_inappwebview_android/lib/src/web_storage/web_storage.dart new file mode 100644 index 00000000..161d02ba --- /dev/null +++ b/flutter_inappwebview_android/lib/src/web_storage/web_storage.dart @@ -0,0 +1,311 @@ +import 'dart:convert'; + +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +import '../in_app_webview/in_app_webview_controller.dart'; + +/// Object specifying creation parameters for creating a [AndroidWebStorage]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformWebStorageCreationParams] for +/// more information. +class AndroidWebStorageCreationParams extends PlatformWebStorageCreationParams { + /// Creates a new [AndroidWebStorageCreationParams] instance. + AndroidWebStorageCreationParams( + {required super.localStorage, required super.sessionStorage}); + + /// Creates a [AndroidWebStorageCreationParams] instance based on [PlatformWebStorageCreationParams]. + factory AndroidWebStorageCreationParams.fromPlatformWebStorageCreationParams( + // Recommended placeholder to prevent being broken by platform interface. + // ignore: avoid_unused_constructor_parameters + PlatformWebStorageCreationParams params) { + return AndroidWebStorageCreationParams( + localStorage: params.localStorage, + sessionStorage: params.sessionStorage); + } +} + +///Class that provides access to the JavaScript [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API): `window.sessionStorage` and `window.localStorage`. +///It used by [InAppWebViewController.webStorage]. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- MacOS +///- Web +class AndroidWebStorage extends PlatformWebStorage { + /// Constructs a [AndroidWebStorage]. + AndroidWebStorage(PlatformWebStorageCreationParams params) + : super.implementation( + params is AndroidWebStorageCreationParams + ? params + : AndroidWebStorageCreationParams + .fromPlatformWebStorageCreationParams(params), + ); + + PlatformLocalStorage get localStorage => params.localStorage; + + PlatformSessionStorage get sessionStorage => params.sessionStorage; + + ///Disposes the web storage. + @override + void dispose() { + localStorage.dispose(); + sessionStorage.dispose(); + } +} + +/// Object specifying creation parameters for creating a [AndroidStorage]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformStorageCreationParams] for +/// more information. +class AndroidStorageCreationParams extends PlatformStorageCreationParams { + /// Creates a new [AndroidStorageCreationParams] instance. + AndroidStorageCreationParams({required super.webStorageType}); + + /// Creates a [AndroidStorageCreationParams] instance based on [PlatformStorageCreationParams]. + factory AndroidStorageCreationParams.fromPlatformStorageCreationParams( + // Recommended placeholder to prevent being broken by platform interface. + // ignore: avoid_unused_constructor_parameters + PlatformStorageCreationParams params) { + return AndroidStorageCreationParams(webStorageType: params.webStorageType); + } +} + +///Class that provides methods to manage the JavaScript [Storage](https://developer.mozilla.org/en-US/docs/Web/API/Storage) object. +///It is used by [AndroidLocalStorage] and [AndroidSessionStorage]. +class AndroidStorage extends PlatformStorage { + /// Constructs a [AndroidStorage]. + AndroidStorage(PlatformStorageCreationParams params) + : super.implementation( + params is AndroidStorageCreationParams + ? params + : AndroidStorageCreationParams.fromPlatformStorageCreationParams( + params), + ); + + AndroidInAppWebViewController? _controller; + + ///Returns an integer representing the number of data items stored in the Storage object. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + Future length() async { + var result = await _controller?.evaluateJavascript(source: """ + window.$webStorageType.length; + """); + return result != null ? int.parse(json.decode(result)) : null; + } + + ///When passed a [key] name and [value], will add that key to the storage, or update that key's value if it already exists. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + Future setItem({required String key, required dynamic value}) async { + var encodedValue = json.encode(value); + await _controller?.evaluateJavascript(source: """ + window.$webStorageType.setItem("$key", ${value is String ? encodedValue : "JSON.stringify($encodedValue)"}); + """); + } + + ///When passed a [key] name, will return that key's value, or `null` if the key does not exist, in the given Storage object. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + Future getItem({required String key}) async { + var itemValue = await _controller?.evaluateJavascript(source: """ + window.$webStorageType.getItem("$key"); + """); + + if (itemValue == null) { + return null; + } + + try { + return json.decode(itemValue); + } catch (e) {} + + return itemValue; + } + + ///When passed a [key] name, will remove that key from the given Storage object if it exists. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + Future removeItem({required String key}) async { + await _controller?.evaluateJavascript(source: """ + window.$webStorageType.removeItem("$key"); + """); + } + + ///Returns the list of all items from the given Storage object. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + Future> getItems() async { + var webStorageItems = []; + + List>? items = + (await _controller?.evaluateJavascript(source: """ +(function() { + var webStorageItems = []; + for(var i = 0; i < window.$webStorageType.length; i++){ + var key = window.$webStorageType.key(i); + webStorageItems.push( + { + key: key, + value: window.$webStorageType.getItem(key) + } + ); + } + return webStorageItems; +})(); + """)).cast>(); + + if (items == null) { + return webStorageItems; + } + + for (var item in items) { + webStorageItems + .add(WebStorageItem(key: item["key"], value: item["value"])); + } + + return webStorageItems; + } + + ///Clears all keys stored in a given Storage object. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + Future clear() async { + await _controller?.evaluateJavascript(source: """ + window.$webStorageType.clear(); + """); + } + + ///When passed a number [index], returns the name of the nth key in a given Storage object. + ///The order of keys is user-agent defined, so you should not rely on it. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + Future key({required int index}) async { + var result = await _controller?.evaluateJavascript(source: """ + window.$webStorageType.key($index); + """); + return result != null ? json.decode(result) : null; + } + + ///Disposes the storage. + @override + void dispose() { + _controller = null; + } +} + +/// Object specifying creation parameters for creating a [AndroidLocalStorage]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformLocalStorageCreationParams] for +/// more information. +class AndroidLocalStorageCreationParams + extends PlatformLocalStorageCreationParams { + /// Creates a new [AndroidLocalStorageCreationParams] instance. + AndroidLocalStorageCreationParams(super.params); + + /// Creates a [AndroidLocalStorageCreationParams] instance based on [PlatformLocalStorageCreationParams]. + factory AndroidLocalStorageCreationParams.fromPlatformLocalStorageCreationParams( + // Recommended placeholder to prevent being broken by platform interface. + // ignore: avoid_unused_constructor_parameters + PlatformLocalStorageCreationParams params) { + return AndroidLocalStorageCreationParams(params); + } +} + +///Class that provides methods to manage the JavaScript `window.localStorage` object. +///It used by [AndroidWebStorage]. +class AndroidLocalStorage extends AndroidStorage implements PlatformLocalStorage { + /// Constructs a [AndroidLocalStorage]. + AndroidLocalStorage(PlatformLocalStorageCreationParams params) + : super( + params is AndroidLocalStorageCreationParams + ? params + : AndroidLocalStorageCreationParams + .fromPlatformLocalStorageCreationParams(params), + ); + + /// Default storage + factory AndroidLocalStorage.defaultStorage() { + return AndroidLocalStorage(AndroidLocalStorageCreationParams( + PlatformLocalStorageCreationParams(PlatformStorageCreationParams( + webStorageType: WebStorageType.LOCAL_STORAGE)))); + } +} + +/// Object specifying creation parameters for creating a [AndroidSessionStorage]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformSessionStorageCreationParams] for +/// more information. +class AndroidSessionStorageCreationParams + extends PlatformSessionStorageCreationParams { + /// Creates a new [AndroidSessionStorageCreationParams] instance. + AndroidSessionStorageCreationParams(super.params); + + /// Creates a [AndroidSessionStorageCreationParams] instance based on [PlatformSessionStorageCreationParams]. + factory AndroidSessionStorageCreationParams.fromPlatformSessionStorageCreationParams( + // Recommended placeholder to prevent being broken by platform interface. + // ignore: avoid_unused_constructor_parameters + PlatformSessionStorageCreationParams params) { + return AndroidSessionStorageCreationParams(params); + } +} + +///Class that provides methods to manage the JavaScript `window.sessionStorage` object. +///It used by [AndroidWebStorage]. +class AndroidSessionStorage extends AndroidStorage implements PlatformSessionStorage { + /// Constructs a [AndroidSessionStorage]. + AndroidSessionStorage(PlatformSessionStorageCreationParams params) + : super( + params is AndroidSessionStorageCreationParams + ? params + : AndroidSessionStorageCreationParams + .fromPlatformSessionStorageCreationParams(params), + ); + + /// Default storage + factory AndroidSessionStorage.defaultStorage() { + return AndroidSessionStorage(AndroidSessionStorageCreationParams( + PlatformSessionStorageCreationParams(PlatformStorageCreationParams( + webStorageType: WebStorageType.SESSION_STORAGE)))); + } +} 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 new file mode 100755 index 00000000..2b8b88d9 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/web_storage/web_storage_manager.dart @@ -0,0 +1,232 @@ +import 'dart:async'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +/// Object specifying creation parameters for creating a [AndroidWebStorageManager]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformWebStorageManagerCreationParams] for +/// more information. +@immutable +class AndroidWebStorageManagerCreationParams + extends PlatformWebStorageManagerCreationParams { + /// Creates a new [AndroidWebStorageManagerCreationParams] instance. + const AndroidWebStorageManagerCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformWebStorageManagerCreationParams params, + ) : super(); + + /// Creates a [AndroidWebStorageManagerCreationParams] instance based on [PlatformWebStorageManagerCreationParams]. + factory AndroidWebStorageManagerCreationParams.fromPlatformWebStorageManagerCreationParams( + PlatformWebStorageManagerCreationParams params) { + return AndroidWebStorageManagerCreationParams(params); + } +} + +///Class that implements a singleton object (shared instance) which manages the web storage used by WebView instances. +///On Android, it is implemented using [WebStorage](https://developer.android.com/reference/android/webkit/WebStorage.html). +///On iOS and MacOS, it is implemented using [WKWebsiteDataStore.default()](https://developer.apple.com/documentation/webkit/wkwebsitedatastore). +/// +///**NOTE for iOS**: available from iOS 9.0+. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- MacOS +class AndroidWebStorageManager extends PlatformWebStorageManager + with ChannelController { + /// Creates a new [AndroidWebStorageManager]. + AndroidWebStorageManager(PlatformWebStorageManagerCreationParams params) + : super.implementation( + params is AndroidWebStorageManagerCreationParams + ? params + : AndroidWebStorageManagerCreationParams + .fromPlatformWebStorageManagerCreationParams(params), + ) { + channel = const MethodChannel( + 'com.pichillilorenzo/flutter_inappwebview_webstoragemanager'); + handler = handleMethod; + initMethodCallHandler(); + } + + static AndroidWebStorageManager? _instance; + + ///Gets the WebStorage manager shared instance. + static AndroidWebStorageManager instance() { + return (_instance != null) ? _instance! : _init(); + } + + static AndroidWebStorageManager _init() { + _instance = AndroidWebStorageManager(AndroidWebStorageManagerCreationParams( + const PlatformWebStorageManagerCreationParams())); + return _instance!; + } + + Future _handleMethod(MethodCall call) async {} + + ///Gets the origins currently using either the Application Cache or Web SQL Database APIs. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebStorage.getOrigins](https://developer.android.com/reference/android/webkit/WebStorage#getOrigins(android.webkit.ValueCallback%3Cjava.util.Map%3E))) + 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; + } + + ///Clears all storage currently being used by the JavaScript storage APIs. + ///This includes the Application Cache, Web SQL Database and the HTML5 Web Storage APIs. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebStorage.deleteAllData](https://developer.android.com/reference/android/webkit/WebStorage#deleteAllData())) + Future deleteAllData() async { + Map args = {}; + await channel?.invokeMethod('deleteAllData', args); + } + + ///Clears the storage currently being used by both the Application Cache and Web SQL Database APIs by the given [origin]. + ///The origin is specified using its string representation. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebStorage.deleteOrigin](https://developer.android.com/reference/android/webkit/WebStorage#deleteOrigin(java.lang.String))) + Future deleteOrigin({required String origin}) async { + Map args = {}; + args.putIfAbsent("origin", () => origin); + await channel?.invokeMethod('deleteOrigin', args); + } + + ///Gets the storage quota for the Web SQL Database API for the given [origin]. + ///The quota is given in bytes and the origin is specified using its string representation. + ///Note that a quota is not enforced on a per-origin basis for the Application Cache API. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebStorage.getQuotaForOrigin](https://developer.android.com/reference/android/webkit/WebStorage#getQuotaForOrigin(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Long%3E))) + Future getQuotaForOrigin({required String origin}) async { + Map args = {}; + args.putIfAbsent("origin", () => origin); + return await channel?.invokeMethod('getQuotaForOrigin', args) ?? 0; + } + + ///Gets the amount of storage currently being used by both the Application Cache and Web SQL Database APIs by the given [origin]. + ///The amount is given in bytes and the origin is specified using its string representation. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebStorage.getUsageForOrigin](https://developer.android.com/reference/android/webkit/WebStorage#getUsageForOrigin(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Long%3E))) + Future getUsageForOrigin({required String origin}) async { + Map args = {}; + args.putIfAbsent("origin", () => origin); + return await channel?.invokeMethod('getUsageForOrigin', args) ?? 0; + } + + ///Fetches data records containing the given website data types. + /// + ///[dataTypes] represents the website data types to fetch records for. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebsiteDataStore.fetchDataRecords](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532932-fetchdatarecords)) + ///- MacOS ([Official API - WKWebsiteDataStore.fetchDataRecords](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532932-fetchdatarecords)) + 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; + } + + ///Removes website data of the given types for the given data records. + /// + ///[dataTypes] represents the website data types that should be removed. + /// + ///[dataRecords] represents the website data records to delete website data for. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata)) + ///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata)) + 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); + } + + ///Removes all website data of the given types that has been modified since the given date. + /// + ///[dataTypes] represents the website data types that should be removed. + /// + ///[date] represents a date. All website data modified after this date will be removed. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) + ///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) + 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 + } +} + +extension InternalWebStorageManager on AndroidWebStorageManager { + get handleMethod => _handleMethod; +} diff --git a/flutter_inappwebview_android/lib/src/webview_asset_loader.dart b/flutter_inappwebview_android/lib/src/webview_asset_loader.dart new file mode 100644 index 00000000..b70ce81f --- /dev/null +++ b/flutter_inappwebview_android/lib/src/webview_asset_loader.dart @@ -0,0 +1,349 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +/// Object specifying creation parameters for creating a [AndroidWebViewAssetLoader]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformWebViewAssetLoaderCreationParams] for +/// more information. +@immutable +class AndroidWebViewAssetLoaderCreationParams + extends PlatformWebViewAssetLoaderCreationParams { + /// Creates a new [AndroidWebViewAssetLoaderCreationParams] instance. + const AndroidWebViewAssetLoaderCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformWebViewAssetLoaderCreationParams params, + ) : super(); + + /// Creates a [AndroidWebViewAssetLoaderCreationParams] instance based on [PlatformWebViewAssetLoaderCreationParams]. + factory AndroidWebViewAssetLoaderCreationParams.fromPlatformWebViewAssetLoaderCreationParams( + PlatformWebViewAssetLoaderCreationParams params) { + return AndroidWebViewAssetLoaderCreationParams(params); + } +} + +///Helper class to load local files including application's static assets and resources using http(s):// URLs inside a [WebView] class. +///Loading local files using web-like URLs instead of `file://` is desirable as it is compatible with the Same-Origin policy. +/// +///For more context about application's assets and resources and how to normally access them please refer to +///[Android Developer Docs: App resources overview](https://developer.android.com/guide/topics/resources/providing-resources). +/// +///Using http(s):// URLs to access local resources may conflict with a real website. +///This means that local files should only be hosted on domains your organization owns +///(at paths reserved for this purpose) or the default domain reserved for this: `appassets.androidplatform.net`. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +class AndroidWebViewAssetLoader extends PlatformWebViewAssetLoader { + /// Creates a new [AndroidWebViewAssetLoader]. + AndroidWebViewAssetLoader(PlatformWebViewAssetLoaderCreationParams params) + : super.implementation( + params is AndroidWebViewAssetLoaderCreationParams + ? params + : AndroidWebViewAssetLoaderCreationParams + .fromPlatformWebViewAssetLoaderCreationParams(params), + ); + + factory AndroidWebViewAssetLoader.static() { + return instance(); + } + + static AndroidWebViewAssetLoader? _instance; + + ///Gets the [AndroidWebViewAssetLoader] shared instance. + static AndroidWebViewAssetLoader instance() { + return (_instance != null) ? _instance! : _init(); + } + + static AndroidWebViewAssetLoader _init() { + _instance = AndroidWebViewAssetLoader( + AndroidWebViewAssetLoaderCreationParams( + const PlatformWebViewAssetLoaderCreationParams())); + return _instance!; + } + + ///Set the domain under which app assets can be accessed. The default domain is `appassets.androidplatform.net`. + String? get domain => params.domain; + + ///Allow using the HTTP scheme in addition to HTTPS. The default is to not allow HTTP. + bool? get httpAllowed => params.httpAllowed; + + ///List of registered path handlers. + /// + ///[WebViewAssetLoader] will try Path Handlers in the order they're registered, + ///and will use whichever is the first to return a non-null. + List? get pathHandlers => + params.pathHandlers as List?; + + ///Gets a possible [AndroidWebViewAssetLoader] instance from a [Map] value. + AndroidWebViewAssetLoader? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = AndroidWebViewAssetLoader( + AndroidWebViewAssetLoaderCreationParams( + PlatformWebViewAssetLoaderCreationParams( + domain: map['domain'], + httpAllowed: map['httpAllowed'], + pathHandlers: map['pathHandlers'] != null + ? List.from(map['pathHandlers'].map((e) => e)) + : null, + ))); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "domain": domain, + "httpAllowed": httpAllowed, + "pathHandlers": pathHandlers?.map((e) => e.toMap()).toList(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + ///Returns a copy of WebViewAssetLoader. + AndroidWebViewAssetLoader copy() { + return fromMap(toMap()) ?? + AndroidWebViewAssetLoader(AndroidWebViewAssetLoaderCreationParams( + const PlatformWebViewAssetLoaderCreationParams())); + } + + @override + String toString() { + return 'AndroidWebViewAssetLoader{domain: $domain, httpAllowed: $httpAllowed, pathHandlers: $pathHandlers}'; + } +} + +/// Object specifying creation parameters for creating a [AndroidPathHandler]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformPathHandlerCreationParams] for +/// more information. +@immutable +class AndroidPathHandlerCreationParams + extends PlatformPathHandlerCreationParams { + /// Creates a new [AndroidPathHandlerCreationParams] instance. + AndroidPathHandlerCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformPathHandlerCreationParams params, + ) : super(path: params.path); + + /// Creates a [AndroidPathHandlerCreationParams] instance based on [PlatformPathHandlerCreationParams]. + factory AndroidPathHandlerCreationParams.fromPlatformPathHandlerCreationParams( + PlatformPathHandlerCreationParams params) { + return AndroidPathHandlerCreationParams(params); + } +} + +///A handler that produces responses for a registered path. +/// +///Implement this interface to handle other use-cases according to your app's needs. +class AndroidPathHandler extends PlatformPathHandler + with ChannelController { + /// Creates a new [AndroidPathHandler]. + AndroidPathHandler(PlatformPathHandlerCreationParams params) + : super.implementation( + params is AndroidPathHandlerCreationParams + ? params + : AndroidPathHandlerCreationParams + .fromPlatformPathHandlerCreationParams(params), + ) { + _type = this.runtimeType.toString(); + _id = IdGenerator.generate(); + channel = MethodChannel( + 'com.pichillilorenzo/flutter_inappwebview_custompathhandler_${_id}'); + handler = _handleMethod; + initMethodCallHandler(); + } + + late final String _type; + late final String _id; + + Future _handleMethod(MethodCall call) async { + switch (call.method) { + case "handle": + String path = call.arguments["path"]; + return (await eventHandler?.handle(path))?.toMap(); + default: + throw UnimplementedError("Unimplemented ${call.method} method"); + } + } + + ///Converts instance to a map. + Map toMap() { + return {"path": path, "type": _type, "id": _id}; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'AndroidPathHandler{path: $path}'; + } + + @override + void dispose() { + disposeChannel(); + eventHandler = null; + } +} + +/// Object specifying creation parameters for creating a [AndroidAssetsPathHandler]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformAssetsPathHandlerCreationParams] for +/// more information. +@immutable +class AndroidAssetsPathHandlerCreationParams + extends PlatformAssetsPathHandlerCreationParams { + /// Creates a new [AndroidAssetsPathHandlerCreationParams] instance. + AndroidAssetsPathHandlerCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformAssetsPathHandlerCreationParams params, + ) : super(params); + + /// Creates a [AndroidAssetsPathHandlerCreationParams] instance based on [PlatformAssetsPathHandlerCreationParams]. + factory AndroidAssetsPathHandlerCreationParams.fromPlatformAssetsPathHandlerCreationParams( + PlatformAssetsPathHandlerCreationParams params) { + return AndroidAssetsPathHandlerCreationParams(params); + } +} + +///Handler class to open a file from assets directory in the application APK. +/// +///Opens the requested file from the application's assets directory. +/// +///The matched prefix path used shouldn't be a prefix of a real web path. +///Thus, if the requested file cannot be found a [WebResourceResponse] object with a `null` data will be returned instead of `null`. +///This saves the time of falling back to network and trying to resolve a path that doesn't exist. +///A [WebResourceResponse] with `null` data will be received as an HTTP response with status code `404` and no body. +/// +///The MIME type for the file will be determined from the file's extension using +///[guessContentTypeFromName](https://developer.android.com/reference/java/net/URLConnection.html#guessContentTypeFromName-java.lang.String-). +///Developers should ensure that asset files are named using standard file extensions. +///If the file does not have a recognised extension, `text/plain` will be used by default. +class AndroidAssetsPathHandler extends AndroidPathHandler implements PlatformAssetsPathHandler { + /// Constructs a [AndroidAssetsPathHandler]. + AndroidAssetsPathHandler(PlatformAssetsPathHandlerCreationParams params) + : super( + params is AndroidAssetsPathHandlerCreationParams + ? params + : AndroidAssetsPathHandlerCreationParams + .fromPlatformAssetsPathHandlerCreationParams(params), + ); +} + +/// Object specifying creation parameters for creating a [AndroidResourcesPathHandler]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformResourcesPathHandlerCreationParams] for +/// more information. +@immutable +class AndroidResourcesPathHandlerCreationParams + extends PlatformResourcesPathHandlerCreationParams { + /// Creates a new [AndroidResourcesPathHandlerCreationParams] instance. + AndroidResourcesPathHandlerCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformResourcesPathHandlerCreationParams params, + ) : super(params); + + /// Creates a [AndroidResourcesPathHandlerCreationParams] instance based on [PlatformResourcesPathHandlerCreationParams]. + factory AndroidResourcesPathHandlerCreationParams.fromPlatformResourcesPathHandlerCreationParams( + PlatformResourcesPathHandlerCreationParams params) { + return AndroidResourcesPathHandlerCreationParams(params); + } +} + +///Handler class to open a file from resources directory in the application APK. +/// +///Opens the requested file from application's resources directory. +/// +///The matched prefix path used shouldn't be a prefix of a real web path. +///Thus, if the requested file cannot be found a [WebResourceResponse] object with a `null` data will be returned instead of `null`. +///This saves the time of falling back to network and trying to resolve a path that doesn't exist. +///A [WebResourceResponse] with `null` data will be received as an HTTP response with status code `404` and no body. +/// +///The MIME type for the file will be determined from the file's extension using +///[guessContentTypeFromName](https://developer.android.com/reference/java/net/URLConnection.html#guessContentTypeFromName-java.lang.String-). +///Developers should ensure that asset files are named using standard file extensions. +///If the file does not have a recognised extension, `text/plain` will be used by default. +class AndroidResourcesPathHandler extends AndroidPathHandler implements PlatformResourcesPathHandler { + /// Constructs a [AndroidResourcesPathHandler]. + AndroidResourcesPathHandler(PlatformResourcesPathHandlerCreationParams params) + : super( + params is AndroidResourcesPathHandlerCreationParams + ? params + : AndroidResourcesPathHandlerCreationParams + .fromPlatformResourcesPathHandlerCreationParams(params), + ); +} + +/// Object specifying creation parameters for creating a [AndroidInternalStoragePathHandler]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformInternalStoragePathHandlerCreationParams] for +/// more information. +@immutable +class AndroidInternalStoragePathHandlerCreationParams + extends PlatformInternalStoragePathHandlerCreationParams { + /// Creates a new [AndroidInternalStoragePathHandlerCreationParams] instance. + AndroidInternalStoragePathHandlerCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformInternalStoragePathHandlerCreationParams params, + ) : super(params, directory: params.directory); + + /// Creates a [AndroidInternalStoragePathHandlerCreationParams] instance based on [PlatformInternalStoragePathHandlerCreationParams]. + factory AndroidInternalStoragePathHandlerCreationParams.fromPlatformInternalStoragePathHandlerCreationParams( + PlatformInternalStoragePathHandlerCreationParams params) { + return AndroidInternalStoragePathHandlerCreationParams(params); + } +} + +///Handler class to open files from application internal storage. +///For more information about android storage please refer to +///[Android Developers Docs: Data and file storage overview](https://developer.android.com/guide/topics/data/data-storage). +/// +///To avoid leaking user or app data to the web, make sure to choose [directory] carefully, +///and assume any file under this directory could be accessed by any web page subject to same-origin rules. +/// +///Opens the requested file from the exposed data directory. +/// +///The matched prefix path used shouldn't be a prefix of a real web path. +///Thus, if the requested file cannot be found a [WebResourceResponse] object with a `null` data will be returned instead of `null`. +///This saves the time of falling back to network and trying to resolve a path that doesn't exist. +///A [WebResourceResponse] with `null` data will be received as an HTTP response with status code `404` and no body. +/// +///The MIME type for the file will be determined from the file's extension using +///[guessContentTypeFromName](https://developer.android.com/reference/java/net/URLConnection.html#guessContentTypeFromName-java.lang.String-). +///Developers should ensure that asset files are named using standard file extensions. +///If the file does not have a recognised extension, `text/plain` will be used by default. +class AndroidInternalStoragePathHandler extends AndroidPathHandler implements PlatformInternalStoragePathHandler { + /// Constructs a [AndroidInternalStoragePathHandler]. + AndroidInternalStoragePathHandler(PlatformInternalStoragePathHandlerCreationParams params) + : super( + params is AndroidInternalStoragePathHandlerCreationParams + ? params + : AndroidInternalStoragePathHandlerCreationParams + .fromPlatformInternalStoragePathHandlerCreationParams(params), + ); + + AndroidInternalStoragePathHandlerCreationParams get _internalParams => + params as AndroidInternalStoragePathHandlerCreationParams; + + @override + String get directory => _internalParams.directory; +} diff --git a/flutter_inappwebview_android/lib/src/webview_feature.dart b/flutter_inappwebview_android/lib/src/webview_feature.dart new file mode 100644 index 00000000..7d2bbf3b --- /dev/null +++ b/flutter_inappwebview_android/lib/src/webview_feature.dart @@ -0,0 +1,118 @@ +import 'dart:async'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +/// Object specifying creation parameters for creating a [AndroidWebViewFeature]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformWebViewFeatureCreationParams] for +/// more information. +@immutable +class AndroidWebViewFeatureCreationParams + extends PlatformWebViewFeatureCreationParams { + /// Creates a new [AndroidWebViewFeatureCreationParams] instance. + const AndroidWebViewFeatureCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformWebViewFeatureCreationParams params, + ) : super(); + + /// Creates a [AndroidWebViewFeatureCreationParams] instance based on [PlatformWebViewFeatureCreationParams]. + factory AndroidWebViewFeatureCreationParams.fromPlatformWebViewFeatureCreationParams( + PlatformWebViewFeatureCreationParams params) { + return AndroidWebViewFeatureCreationParams(params); + } +} + +///Class that represents an Android-specific utility class for checking which WebView Support Library features are supported on the device. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +class AndroidWebViewFeature extends PlatformWebViewFeature + with ChannelController { + /// Creates a new [AndroidWebViewFeature]. + AndroidWebViewFeature(PlatformWebViewFeatureCreationParams params) + : super.implementation( + params is AndroidWebViewFeatureCreationParams + ? params + : AndroidWebViewFeatureCreationParams + .fromPlatformWebViewFeatureCreationParams(params), + ) { + channel = const MethodChannel( + 'com.pichillilorenzo/flutter_inappwebview_webviewfeature'); + handler = handleMethod; + initMethodCallHandler(); + } + + factory AndroidWebViewFeature.static() { + return instance(); + } + + static AndroidWebViewFeature? _instance; + + ///Gets the [AndroidWebViewFeature] shared instance. + static AndroidWebViewFeature instance() { + return (_instance != null) ? _instance! : _init(); + } + + static AndroidWebViewFeature _init() { + _instance = AndroidWebViewFeature(AndroidWebViewFeatureCreationParams( + const PlatformWebViewFeatureCreationParams())); + return _instance!; + } + + Future _handleMethod(MethodCall call) async {} + + ///Return whether a feature is supported at run-time. On devices running Android version `Build.VERSION_CODES.LOLLIPOP` and higher, + ///this will check whether a feature is supported, depending on the combination of the desired feature, the Android version of device, + ///and the WebView APK on the device. If running on a device with a lower API level, this will always return `false`. + /// + ///**Note**: This method is different from [isStartupFeatureSupported] and this + ///method only accepts certain features. + ///Please verify that the correct feature checking method is used for a particular feature. + /// + ///**Note**: If this method returns `false`, it is not safe to invoke the methods + ///requiring the desired feature. + ///Furthermore, if this method returns `false` for a particular feature, any callback guarded by that feature will not be invoked. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String) + Future isFeatureSupported(WebViewFeature feature) async { + Map args = {}; + args.putIfAbsent("feature", () => feature.toNativeValue()); + return await channel?.invokeMethod('isFeatureSupported', args) ?? + false; + } + + ///Return whether a startup feature is supported at run-time. + ///On devices running Android version `Build.VERSION_CODES.LOLLIPOP` and higher, + ///this will check whether a startup feature is supported, + ///depending on the combination of the desired feature, + ///the Android version of device, and the WebView APK on the device. + ///If running on a device with a lower API level, this will always return `false`. + /// + ///**Note**: This method is different from [isFeatureSupported] and this method only accepts startup features. + ///Please verify that the correct feature checking method is used for a particular feature. + /// + ///**Note**: If this method returns `false`, it is not safe to invoke the methods requiring the desired feature. + ///Furthermore, if this method returns `false` for a particular feature, + ///any callback guarded by that feature will not be invoked. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String) + Future isStartupFeatureSupported(WebViewFeature startupFeature) async { + Map args = {}; + args.putIfAbsent("startupFeature", () => startupFeature.toNativeValue()); + return await channel?.invokeMethod( + 'isStartupFeatureSupported', args) ?? + false; + } + + @override + void dispose() { + // empty + } +} + +extension InternalWebViewFeature on AndroidWebViewFeature { + get handleMethod => _handleMethod; +} diff --git a/flutter_inappwebview_android/pubspec.yaml b/flutter_inappwebview_android/pubspec.yaml new file mode 100644 index 00000000..98957363 --- /dev/null +++ b/flutter_inappwebview_android/pubspec.yaml @@ -0,0 +1,74 @@ +name: flutter_inappwebview_android +description: Android implementation of the flutter_inappwebview plugin. +version: 0.0.1 +homepage: + +environment: + sdk: ">=2.17.0 <4.0.0" + flutter: ">=3.0.0" + +dependencies: + flutter: + sdk: flutter + flutter_inappwebview_platform_interface: + path: ../flutter_inappwebview_platform_interface + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + plugin_platform_interface: ^2.0.2 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + # This section identifies this Flutter project as a plugin project. + # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) + # which should be registered in the plugin registry. This is required for + # using method channels. + # The Android 'package' specifies package in which the registered class is. + # This is required for using method channels on Android. + # The 'ffiPlugin' specifies that native code should be built and bundled. + # This is required for using `dart:ffi`. + # All these are used by the tooling to maintain consistency when + # adding or updating assets for this project. + plugin: + implements: flutter_inappwebview_platform + platforms: + android: + package: com.pichillilorenzo.flutter_inappwebview + pluginClass: InAppWebViewFlutterPlugin + dartPluginClass: AndroidInAppWebViewPlatform + + # To add assets to your plugin package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # To add custom fonts to your plugin package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages diff --git a/flutter_inappwebview_android/test/flutter_inappwebview_android_method_channel_test.dart b/flutter_inappwebview_android/test/flutter_inappwebview_android_method_channel_test.dart new file mode 100644 index 00000000..516d04a4 --- /dev/null +++ b/flutter_inappwebview_android/test/flutter_inappwebview_android_method_channel_test.dart @@ -0,0 +1,27 @@ +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter_inappwebview_android/flutter_inappwebview_android_method_channel.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + MethodChannelInAppWebViewFlutterAndroid platform = MethodChannelInAppWebViewFlutterAndroid(); + const MethodChannel channel = MethodChannel('flutter_inappwebview_android'); + + setUp(() { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( + channel, + (MethodCall methodCall) async { + return '42'; + }, + ); + }); + + tearDown(() { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(channel, null); + }); + + test('getPlatformVersion', () async { + expect(await platform.getPlatformVersion(), '42'); + }); +} diff --git a/flutter_inappwebview_android/test/flutter_inappwebview_android_test.dart b/flutter_inappwebview_android/test/flutter_inappwebview_android_test.dart new file mode 100644 index 00000000..44503fdb --- /dev/null +++ b/flutter_inappwebview_android/test/flutter_inappwebview_android_test.dart @@ -0,0 +1,29 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter_inappwebview_android/flutter_inappwebview_android.dart'; +import 'package:flutter_inappwebview_android/flutter_inappwebview_android_platform_interface.dart'; +import 'package:flutter_inappwebview_android/flutter_inappwebview_android_method_channel.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +class MockFlutterInappwebviewAndroidPlatform + with MockPlatformInterfaceMixin + implements InAppWebViewFlutterAndroid { + + @override + Future getPlatformVersion() => Future.value('42'); +} + +void main() { + final InAppWebViewFlutterAndroid initialPlatform = InAppWebViewFlutterAndroid.instance; + + test('$MethodChannelInAppWebViewFlutterAndroid is the default instance', () { + expect(initialPlatform, isInstanceOf()); + }); + + test('getPlatformVersion', () async { + FlutterInappwebviewAndroid flutterInappwebviewAndroidPlugin = FlutterInappwebviewAndroid(); + MockFlutterInappwebviewAndroidPlatform fakePlatform = MockFlutterInappwebviewAndroidPlatform(); + InAppWebViewFlutterAndroid.instance = fakePlatform; + + expect(await flutterInappwebviewAndroidPlugin.getPlatformVersion(), '42'); + }); +} diff --git a/flutter_inappwebview_platform_interface/.gitignore b/flutter_inappwebview_platform_interface/.gitignore new file mode 100644 index 00000000..96486fd9 --- /dev/null +++ b/flutter_inappwebview_platform_interface/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/flutter_inappwebview_platform_interface/.metadata b/flutter_inappwebview_platform_interface/.metadata new file mode 100644 index 00000000..5c536bce --- /dev/null +++ b/flutter_inappwebview_platform_interface/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "6c4930c4ac86fb286f30e31d0ec8bffbcbb9953e" + channel: "stable" + +project_type: package diff --git a/flutter_inappwebview_platform_interface/CHANGELOG.md b/flutter_inappwebview_platform_interface/CHANGELOG.md new file mode 100644 index 00000000..41cc7d81 --- /dev/null +++ b/flutter_inappwebview_platform_interface/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/flutter_inappwebview_platform_interface/LICENSE b/flutter_inappwebview_platform_interface/LICENSE new file mode 100644 index 00000000..ba75c69f --- /dev/null +++ b/flutter_inappwebview_platform_interface/LICENSE @@ -0,0 +1 @@ +TODO: Add your license here. diff --git a/flutter_inappwebview_platform_interface/README.md b/flutter_inappwebview_platform_interface/README.md new file mode 100644 index 00000000..02fe8eca --- /dev/null +++ b/flutter_inappwebview_platform_interface/README.md @@ -0,0 +1,39 @@ + + +TODO: Put a short description of the package here that helps potential users +know whether this package might be useful for them. + +## Features + +TODO: List what your package can do. Maybe include images, gifs, or videos. + +## Getting started + +TODO: List prerequisites and provide or point to information on how to +start using the package. + +## Usage + +TODO: Include short and useful examples for package users. Add longer examples +to `/example` folder. + +```dart +const like = 'sample'; +``` + +## Additional information + +TODO: Tell users more about the package: where to find more information, how to +contribute to the package, how to file issues, what response they can expect +from the package authors, and more. diff --git a/flutter_inappwebview_platform_interface/analysis_options.yaml b/flutter_inappwebview_platform_interface/analysis_options.yaml new file mode 100644 index 00000000..24ec4a21 --- /dev/null +++ b/flutter_inappwebview_platform_interface/analysis_options.yaml @@ -0,0 +1,11 @@ +include: package:flutter_lints/flutter.yaml + +linter: + rules: + constant_identifier_names: ignore + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options +analyzer: + errors: + deprecated_member_use_from_same_package: ignore \ No newline at end of file diff --git a/flutter_inappwebview_platform_interface/lib/flutter_inappwebview_platform_interface.dart b/flutter_inappwebview_platform_interface/lib/flutter_inappwebview_platform_interface.dart new file mode 100644 index 00000000..0af8b5b2 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/flutter_inappwebview_platform_interface.dart @@ -0,0 +1,3 @@ +library flutter_inappwebview_platform_interface; + +export 'src/main.dart'; \ No newline at end of file diff --git a/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart similarity index 97% rename from lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart rename to flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart index 7b43dab9..3803d311 100755 --- a/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart @@ -4,11 +4,11 @@ import '../../util.dart'; import '../../types/main.dart'; import '../chrome_safari_browser_settings.dart'; -import '../chrome_safari_browser.dart'; +import '../platform_chrome_safari_browser.dart'; import '../../in_app_webview/android/in_app_webview_options.dart'; -///This class represents all the Android-only [ChromeSafariBrowser] options available. +///This class represents all the Android-only [PlatformChromeSafariBrowser] options available. ///Use [ChromeSafariBrowserSettings] instead. @Deprecated('Use ChromeSafariBrowserSettings instead') class AndroidChromeCustomTabsOptions diff --git a/lib/src/chrome_safari_browser/android/main.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/android/main.dart similarity index 100% rename from lib/src/chrome_safari_browser/android/main.dart rename to flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/android/main.dart diff --git a/lib/src/chrome_safari_browser/apple/main.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/apple/main.dart similarity index 100% rename from lib/src/chrome_safari_browser/apple/main.dart rename to flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/apple/main.dart diff --git a/lib/src/chrome_safari_browser/apple/safari_options.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/apple/safari_options.dart similarity index 96% rename from lib/src/chrome_safari_browser/apple/safari_options.dart rename to flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/apple/safari_options.dart index 9559ac6d..9eb397b4 100755 --- a/lib/src/chrome_safari_browser/apple/safari_options.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/apple/safari_options.dart @@ -4,11 +4,11 @@ import '../../util.dart'; import '../../types/main.dart'; import '../chrome_safari_browser_settings.dart'; -import '../chrome_safari_browser.dart'; +import '../platform_chrome_safari_browser.dart'; import '../../in_app_webview/apple/in_app_webview_options.dart'; -///This class represents all the iOS-only [ChromeSafariBrowser] options available. +///This class represents all the iOS-only [PlatformChromeSafariBrowser] options available. ///Use [ChromeSafariBrowserSettings] instead. @Deprecated('Use ChromeSafariBrowserSettings instead') class IOSSafariOptions implements ChromeSafariBrowserOptions, IosOptions { diff --git a/lib/src/chrome_safari_browser/chrome_safari_action_button.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.dart similarity index 89% rename from lib/src/chrome_safari_browser/chrome_safari_action_button.dart rename to flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.dart index 7f2a56bf..400296a1 100644 --- a/lib/src/chrome_safari_browser/chrome_safari_action_button.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.dart @@ -2,13 +2,13 @@ import 'dart:typed_data'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import 'chrome_safari_browser.dart'; +import 'platform_chrome_safari_browser.dart'; import 'chrome_safari_browser_menu_item.dart'; import '../web_uri.dart'; part 'chrome_safari_action_button.g.dart'; -///Class that represents a custom action button for a [ChromeSafariBrowser] instance. +///Class that represents a custom action button for a [PlatformChromeSafariBrowser] instance. @SupportedPlatforms(platforms: [ AndroidPlatform(note: 'Not available in an Android Trusted Web Activity.'), ]) diff --git a/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart similarity index 96% rename from lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart rename to flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart index 7d9e3c23..663b1435 100644 --- a/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart @@ -6,7 +6,7 @@ part of 'chrome_safari_action_button.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Class that represents a custom action button for a [ChromeSafariBrowser] instance. +///Class that represents a custom action button for a [PlatformChromeSafariBrowser] instance. /// ///**NOTE for Android native WebView**: Not available in an Android Trusted Web Activity. /// diff --git a/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.dart similarity index 88% rename from lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.dart rename to flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.dart index a5ac4599..f3a62579 100644 --- a/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.dart @@ -1,12 +1,12 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import '../types/ui_image.dart'; -import 'chrome_safari_browser.dart'; +import 'platform_chrome_safari_browser.dart'; import '../web_uri.dart'; part 'chrome_safari_browser_menu_item.g.dart'; -///Class that represents a custom menu item for a [ChromeSafariBrowser] instance. +///Class that represents a custom menu item for a [PlatformChromeSafariBrowser] instance. @SupportedPlatforms(platforms: [ AndroidPlatform(note: 'Not available in an Android Trusted Web Activity.'), IOSPlatform() diff --git a/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart similarity index 95% rename from lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart rename to flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart index 014ad3de..7b524976 100644 --- a/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart @@ -6,7 +6,7 @@ part of 'chrome_safari_browser_menu_item.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Class that represents a custom menu item for a [ChromeSafariBrowser] instance. +///Class that represents a custom menu item for a [PlatformChromeSafariBrowser] instance. /// ///**NOTE for Android native WebView**: Not available in an Android Trusted Web Activity. /// diff --git a/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.dart similarity index 94% rename from lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.dart rename to flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.dart index 9dfe02c8..6404b07a 100644 --- a/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.dart @@ -2,7 +2,7 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_i import '../types/android_resource.dart'; import '../web_uri.dart'; -import 'chrome_safari_browser.dart'; +import 'platform_chrome_safari_browser.dart'; part 'chrome_safari_browser_secondary_toolbar.g.dart'; @@ -29,7 +29,7 @@ class ChromeSafariBrowserSecondaryToolbar_ { {required this.layout, this.clickableIDs = const []}); } -///Class that represents a clickable ID item of the secondary toolbar for a [ChromeSafariBrowser] instance. +///Class that represents a clickable ID item of the secondary toolbar for a [PlatformChromeSafariBrowser] instance. @SupportedPlatforms(platforms: [ AndroidPlatform(note: 'Not available in an Android Trusted Web Activity.') ]) diff --git a/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart similarity index 98% rename from lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart rename to flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart index 20185c2f..a829e024 100644 --- a/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart @@ -70,7 +70,7 @@ class ChromeSafariBrowserSecondaryToolbar { } } -///Class that represents a clickable ID item of the secondary toolbar for a [ChromeSafariBrowser] instance. +///Class that represents a clickable ID item of the secondary toolbar for a [PlatformChromeSafariBrowser] instance. /// ///**NOTE for Android native WebView**: Not available in an Android Trusted Web Activity. /// diff --git a/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart similarity index 100% rename from lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart rename to flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart diff --git a/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart similarity index 100% rename from lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart rename to flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/main.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/main.dart new file mode 100644 index 00000000..a2c764ce --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/main.dart @@ -0,0 +1,14 @@ +export 'platform_chrome_safari_browser.dart'; +export 'chrome_safari_browser_settings.dart' + show + ChromeSafariBrowserOptions, + ChromeSafariBrowserSettings, + ChromeSafariBrowserClassOptions; +export 'android/main.dart'; +export 'apple/main.dart'; +export 'chrome_safari_action_button.dart' show ChromeSafariBrowserActionButton; +export 'chrome_safari_browser_menu_item.dart' show ChromeSafariBrowserMenuItem; +export 'chrome_safari_browser_secondary_toolbar.dart' + show + ChromeSafariBrowserSecondaryToolbar, + ChromeSafariBrowserSecondaryToolbarClickableID; diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart new file mode 100755 index 00000000..b3ebbff0 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart @@ -0,0 +1,697 @@ +import 'dart:async'; +import 'dart:collection'; +import 'dart:typed_data'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import '../types/custom_tabs_navigation_event_type.dart'; +import '../types/custom_tabs_post_message_result_type.dart'; +import '../types/custom_tabs_relation_type.dart'; +import '../types/prewarming_token.dart'; +import '../util.dart'; +import '../debug_logging_settings.dart'; + +import '../web_uri.dart'; +import 'chrome_safari_browser_settings.dart'; +import 'chrome_safari_action_button.dart'; +import 'chrome_safari_browser_menu_item.dart'; +import 'chrome_safari_browser_secondary_toolbar.dart'; + +///This class uses native [Chrome Custom Tabs](https://developer.android.com/reference/android/support/customtabs/package-summary) on Android +///and [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) on iOS. +/// +///**NOTE**: If you want to use the `ChromeSafariBrowser` class on Android 11+ you need to specify your app querying for +///`android.support.customtabs.action.CustomTabsService` in your `AndroidManifest.xml` +///(you can read more about it here: https://developers.google.com/web/android/custom-tabs/best-practices#applications_targeting_android_11_api_level_30_or_above). +/// +///**Supported Platforms/Implementations**: +///- Android +///- iOS +class PlatformChromeSafariBrowser extends ChannelController { + ///Debug settings. + static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings(); + + ///View ID used internally. + late final String id; + + ChromeSafariBrowserActionButton? _actionButton; + Map _menuItems = new HashMap(); + ChromeSafariBrowserSecondaryToolbar? _secondaryToolbar; + bool _isOpened = false; + static const MethodChannel _sharedChannel = + const MethodChannel('com.pichillilorenzo/flutter_chromesafaribrowser'); + + PlatformChromeSafariBrowser() { + id = IdGenerator.generate(); + channel = + MethodChannel('com.pichillilorenzo/flutter_chromesafaribrowser_$id'); + handler = _handleMethod; + initMethodCallHandler(); + _isOpened = false; + } + + _init() { + channel = + MethodChannel('com.pichillilorenzo/flutter_chromesafaribrowser_$id'); + handler = _handleMethod; + initMethodCallHandler(); + } + + _debugLog(String method, dynamic args) { + debugLog( + className: this.runtimeType.toString(), + id: id, + debugLoggingSettings: PlatformChromeSafariBrowser.debugLoggingSettings, + method: method, + args: args); + } + + Future _handleMethod(MethodCall call) async { + _debugLog(call.method, call.arguments); + + switch (call.method) { + case "onServiceConnected": + onServiceConnected(); + break; + case "onOpened": + onOpened(); + break; + case "onCompletedInitialLoad": + final bool? didLoadSuccessfully = call.arguments["didLoadSuccessfully"]; + onCompletedInitialLoad(didLoadSuccessfully); + break; + case "onInitialLoadDidRedirect": + final String? url = call.arguments["url"]; + final WebUri? uri = url != null ? WebUri(url) : null; + onInitialLoadDidRedirect(uri); + break; + case "onNavigationEvent": + final navigationEvent = CustomTabsNavigationEventType.fromNativeValue( + call.arguments["navigationEvent"]); + 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"]; + onRelationshipValidationResult(relation, requestedOrigin, result); + break; + case "onWillOpenInBrowser": + onWillOpenInBrowser(); + break; + case "onClosed": + _isOpened = false; + dispose(); + onClosed(); + break; + case "onItemActionPerform": + 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]?.action != null) { + this._menuItems[id]?.action!(url, title); + } + if (this._menuItems[id]?.onClick != null) { + this._menuItems[id]?.onClick!(WebUri(url), title); + } + } + 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": + onMessageChannelReady(); + break; + case "onPostMessage": + final String message = call.arguments["message"]; + onPostMessage(message); + break; + case "onVerticalScrollEvent": + final bool isDirectionUp = call.arguments["isDirectionUp"]; + onVerticalScrollEvent(isDirectionUp); + break; + case "onGreatestScrollPercentageIncreased": + final int scrollPercentage = call.arguments["scrollPercentage"]; + onGreatestScrollPercentageIncreased(scrollPercentage); + break; + case "onSessionEnded": + final bool didUserInteract = call.arguments["didUserInteract"]; + onSessionEnded(didUserInteract); + break; + default: + throw UnimplementedError("Unimplemented ${call.method} method"); + } + } + + ///Opens the [PlatformChromeSafariBrowser] instance with an [url]. + /// + ///[url] - The [url] to load. On iOS, the [url] is required and must use the `http` or `https` scheme. + /// + ///[headers] (Supported only on Android) - [whitelisted](https://fetch.spec.whatwg.org/#cors-safelisted-request-header) cross-origin request headers. + ///It is possible to attach non-whitelisted headers to cross-origin requests, when the server and client are related using a + ///[digital asset link](https://developers.google.com/digital-asset-links/v1/getting-started). + /// + ///[otherLikelyURLs] - Other likely destinations, sorted in decreasing likelihood order. Supported only on Android. + /// + ///[referrer] - referrer header. Supported only on Android. + /// + ///[options] - Deprecated. Use `settings` instead. + /// + ///[settings] - Settings for the [PlatformChromeSafariBrowser]. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + Future open( + {WebUri? url, + Map? headers, + List? otherLikelyURLs, + WebUri? referrer, + @Deprecated('Use settings instead') + // ignore: deprecated_member_use_from_same_package + ChromeSafariBrowserClassOptions? options, + ChromeSafariBrowserSettings? settings}) async { + assert(!_isOpened, 'The browser is already opened.'); + _isOpened = true; + + if (Util.isIOS) { + assert(url != null, 'The specified URL must not be null on iOS.'); + assert(['http', 'https'].contains(url!.scheme), + 'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.'); + } + if (url != null) { + assert(url.toString().isNotEmpty, 'The specified URL must not be empty.'); + } + + _init(); + + List> menuItemList = []; + _menuItems.forEach((key, value) { + menuItemList.add(value.toMap()); + }); + + var initialSettings = settings?.toMap() ?? + options?.toMap() ?? + ChromeSafariBrowserSettings().toMap(); + + Map args = {}; + args.putIfAbsent('id', () => id); + args.putIfAbsent('url', () => url?.toString()); + args.putIfAbsent('headers', () => headers); + args.putIfAbsent('otherLikelyURLs', + () => 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 _sharedChannel.invokeMethod('open', args); + } + + ///Tells the browser to launch with [url]. + /// + ///[url] - initial url. + /// + ///[headers] (Supported only on Android) - [whitelisted](https://fetch.spec.whatwg.org/#cors-safelisted-request-header) cross-origin request headers. + ///It is possible to attach non-whitelisted headers to cross-origin requests, when the server and client are related using a + ///[digital asset link](https://developers.google.com/digital-asset-links/v1/getting-started). + /// + ///[otherLikelyURLs] - Other likely destinations, sorted in decreasing likelihood order. + /// + ///[referrer] - referrer header. Supported only on Android. + /// + ///**Supported Platforms/Implementations**: + ///- Android + 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); + } + + ///Tells the browser of a likely future navigation to a URL. + ///The most likely URL has to be specified first. + ///Optionally, a list of other likely URLs can be provided. + ///They are treated as less likely than the first one, and have to be sorted in decreasing priority order. + ///These additional URLs may be ignored. All previous calls to this method will be deprioritized. + /// + ///[url] - Most likely URL, may be null if otherLikelyBundles is provided. + /// + ///[otherLikelyURLs] - Other likely destinations, sorted in decreasing likelihood order. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsSession.mayLaunchUrl](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#mayLaunchUrl(android.net.Uri,android.os.Bundle,java.util.List%3Candroid.os.Bundle%3E))) + 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; + } + + ///Requests to validate a relationship between the application and an origin. + /// + ///See [here](https://developers.google.com/digital-asset-links/v1/getting-started) for documentation about Digital Asset Links. + ///This methods requests the browser to verify a relation with the calling application, to grant the associated rights. + /// + ///If this method returns `true`, the validation result will be provided through [onRelationshipValidationResult]. + ///Otherwise the request didn't succeed. + /// + ///[relation] – Relation to check, must be one of the [CustomTabsRelationType] constants. + /// + ///[origin] – Origin. + /// + ///[extras] – Reserved for future use. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsSession.validateRelationship](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#validateRelationship(int,android.net.Uri,android.os.Bundle))) + 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; + } + + ///Closes the [PlatformChromeSafariBrowser] instance. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + Future close() async { + Map args = {}; + await channel?.invokeMethod("close", args); + } + + ///Set a custom action button. + /// + ///**NOTE**: Not available in a Trusted Web Activity. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsIntent.Builder.setActionButton](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setActionButton(android.graphics.Bitmap,%20java.lang.String,%20android.app.PendingIntent,%20boolean))) + void setActionButton(ChromeSafariBrowserActionButton actionButton) { + this._actionButton = actionButton; + } + + ///Updates the [ChromeSafariBrowserActionButton.icon] and [ChromeSafariBrowserActionButton.description]. + /// + ///**NOTE**: Not available in a Trusted Web Activity. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsSession.setActionButton](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#setActionButton(android.graphics.Bitmap,java.lang.String))) + 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; + } + + ///Sets the remote views displayed in the secondary toolbar in a custom tab. + /// + ///**NOTE**: Not available in a Trusted Web Activity. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsIntent.Builder.setSecondaryToolbarViews](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent))) + void setSecondaryToolbar( + ChromeSafariBrowserSecondaryToolbar secondaryToolbar) { + this._secondaryToolbar = secondaryToolbar; + } + + ///Sets or updates (if already present) the Remote Views of the secondary toolbar in an existing custom tab session. + /// + ///**NOTE**: Not available in a Trusted Web Activity. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsSession.setSecondaryToolbarViews](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent))) + Future updateSecondaryToolbar( + ChromeSafariBrowserSecondaryToolbar secondaryToolbar) async { + Map args = {}; + args.putIfAbsent('secondaryToolbar', () => secondaryToolbar.toMap()); + await channel?.invokeMethod("updateSecondaryToolbar", args); + this._secondaryToolbar = secondaryToolbar; + } + + ///Adds a [ChromeSafariBrowserMenuItem] to the menu. + /// + ///**NOTE**: Not available in an Android Trusted Web Activity. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + void addMenuItem(ChromeSafariBrowserMenuItem menuItem) { + this._menuItems[menuItem.id] = menuItem; + } + + ///Adds a list of [ChromeSafariBrowserMenuItem] to the menu. + /// + ///**NOTE**: Not available in an Android Trusted Web Activity. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + void addMenuItems(List menuItems) { + menuItems.forEach((menuItem) { + this._menuItems[menuItem.id] = menuItem; + }); + } + + ///Sends a request to create a two way postMessage channel between the client + ///and the browser. + ///If you want to specifying the target origin to communicate with, set the [targetOrigin]. + /// + ///[sourceOrigin] - A origin that the client is requesting to be + ///identified as during the postMessage communication. + ///It has to either start with http or https. + /// + ///[targetOrigin] - The target Origin to establish the postMessage communication with. + ///This can be the app's package name, it has to either start with http or https. + /// + ///Returns whether the implementation accepted the request. + ///Note that returning true here doesn't mean an origin has already been + ///assigned as the validation is asynchronous. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsSession.requestPostMessageChannel](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#requestPostMessageChannel(android.net.Uri,android.net.Uri,android.os.Bundle))) + 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; + } + + ///Sends a postMessage request using the origin communicated via [requestPostMessageChannel]. + ///Fails when called before [onMessageChannelReady] event. + /// + ///[message] – The message that is being sent. + /// + ///Returns an integer constant about the postMessage request result. + ///Will return CustomTabsService.RESULT_SUCCESS if successful. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsSession.postMessage](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#postMessage(java.lang.String,android.os.Bundle))) + Future postMessage(String message) async { + Map args = {}; + args.putIfAbsent("message", () => message); + return CustomTabsPostMessageResultType.fromNativeValue( + await channel?.invokeMethod("postMessage", args)) ?? + CustomTabsPostMessageResultType.FAILURE_MESSAGING_ERROR; + } + + ///Returns whether the Engagement Signals API is available. + ///The availability of the Engagement Signals API may change at runtime. + ///If an EngagementSignalsCallback has been set, an [onSessionEnded] + ///signal will be sent if the API becomes unavailable later. + /// + ///Returns whether the Engagement Signals API is available. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsSession.isEngagementSignalsApiAvailable](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#isEngagementSignalsApiAvailable(android.os.Bundle))) + Future isEngagementSignalsApiAvailable() async { + Map args = {}; + return await channel?.invokeMethod( + "isEngagementSignalsApiAvailable", args) ?? + false; + } + + ///On Android, returns `true` if Chrome Custom Tabs is available. + ///On iOS, returns `true` if SFSafariViewController is available. + ///Otherwise returns `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + static Future isAvailable() async { + Map args = {}; + return await _sharedChannel.invokeMethod("isAvailable", args) ?? + false; + } + + ///The maximum number of allowed secondary toolbar items. + /// + ///**Supported Platforms/Implementations**: + ///- Android + static Future getMaxToolbarItems() async { + Map args = {}; + return await _sharedChannel.invokeMethod("getMaxToolbarItems", args) ?? + 0; + } + + ///Returns the preferred package to use for Custom Tabs. + ///The preferred package name is the default VIEW intent handler as long as it supports Custom Tabs. + ///To modify this preferred behavior, set [ignoreDefault] to `true` and give a + ///non empty list of package names in packages. + ///This method queries the `PackageManager` to determine which packages support the Custom Tabs API. + ///On apps that target Android 11 and above, this requires adding the following + ///package visibility elements to your manifest. + /// + ///[packages] – Ordered list of packages to test for Custom Tabs support, in decreasing order of priority. + /// + ///[ignoreDefault] – If set, the default VIEW handler won't get priority over other browsers. + /// + ///Returns the preferred package name for handling Custom Tabs, or null. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsClient.getPackageName](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsClient#getPackageName(android.content.Context,java.util.List%3Cjava.lang.String%3E,boolean)))) + static Future getPackageName( + {List? packages, bool ignoreDefault = false}) async { + Map args = {}; + args.putIfAbsent("packages", () => packages); + args.putIfAbsent("ignoreDefault", () => ignoreDefault); + return await _sharedChannel.invokeMethod("getPackageName", args); + } + + ///Clear associated website data accrued from browsing activity within your app. + ///This includes all local storage, cached resources, and cookies. + /// + ///**NOTE for iOS**: available on iOS 16.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - SFSafariViewController.DataStore.clearWebsiteData](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/datastore/3981117-clearwebsitedata)) + static Future clearWebsiteData() async { + Map args = {}; + await _sharedChannel.invokeMethod("clearWebsiteData", args); + } + + ///Prewarms a connection to each URL. SFSafariViewController will automatically use a + ///prewarmed connection if possible when loading its initial URL. + /// + ///Returns a token object that corresponds to the requested URLs. You must keep a strong + ///reference to this token as long as you expect the prewarmed connections to remain open. If the same + ///server is requested in multiple calls to this method, all of the corresponding tokens must be + ///invalidated or released to end the prewarmed connection to that server. + /// + ///This method uses a best-effort approach to prewarming connections, but may delay + ///or drop requests based on the volume of requests made by your app. Use this method when you expect + ///to present the browser soon. Many HTTP servers time out connections after a few minutes. + ///After a timeout, prewarming delivers less performance benefit. + /// + ///[URLs] - the URLs of servers that the browser should prewarm connections to. + ///Only supports URLs with `http://` or `https://` schemes. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections)) + static Future prewarmConnections(List URLs) async { + Map args = {}; + args.putIfAbsent('URLs', () => URLs.map((e) => e.toString()).toList()); + Map? result = + (await _sharedChannel.invokeMethod("prewarmConnections", args)) + ?.cast(); + return PrewarmingToken.fromMap(result); + } + + ///Ends all prewarmed connections associated with the token, except for connections that are also kept alive by other tokens. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections)) + static Future invalidatePrewarmingToken( + PrewarmingToken prewarmingToken) async { + Map args = {}; + args.putIfAbsent('prewarmingToken', () => prewarmingToken.toMap()); + await _sharedChannel.invokeMethod("invalidatePrewarmingToken", args); + } + + ///Event fired when the when connecting from Android Custom Tabs Service. + /// + ///**Supported Platforms/Implementations**: + ///- Android + void onServiceConnected() {} + + ///Event fired when the [PlatformChromeSafariBrowser] is opened. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + void onOpened() {} + + ///Event fired when the initial URL load is complete. + /// + ///[didLoadSuccessfully] - `true` if loading completed successfully; otherwise, `false`. Supported only on iOS. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS ([Official API - SFSafariViewControllerDelegate.safariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/1621215-safariviewcontroller)) + void onCompletedInitialLoad(bool? didLoadSuccessfully) {} + + ///Event fired when the initial URL load is complete. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - SFSafariViewControllerDelegate.safariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/2923545-safariviewcontroller)) + void onInitialLoadDidRedirect(WebUri? url) {} + + ///Event fired when a navigation event happens. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsCallback.onNavigationEvent](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onNavigationEvent(int,android.os.Bundle))) + void onNavigationEvent(CustomTabsNavigationEventType? navigationEvent) {} + + ///Event fired when a relationship validation result is available. + /// + ///[relation] - Relation for which the result is available. Value previously passed to [validateRelationship]. + /// + ///[requestedOrigin] - Origin requested. Value previously passed to [validateRelationship]. + /// + ///[result] - Whether the relation was validated. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsCallback.onRelationshipValidationResult](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onRelationshipValidationResult(int,android.net.Uri,boolean,android.os.Bundle))) + void onRelationshipValidationResult( + CustomTabsRelationType? relation, WebUri? requestedOrigin, bool result) {} + + ///Event fired when the user opens the current page in the default browser by tapping the toolbar button. + /// + ///**NOTE for iOS**: available on iOS 14.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - SFSafariViewControllerDelegate.safariViewControllerWillOpenInBrowser](https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/3650426-safariviewcontrollerwillopeninbr)) + void onWillOpenInBrowser() {} + + ///Called when the [PlatformChromeSafariBrowser] has requested a postMessage channel through + ///[requestPostMessageChannel] and the channel is ready for sending and receiving messages on both ends. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsCallback.onMessageChannelReady](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onMessageChannelReady(android.os.Bundle))) + void onMessageChannelReady() {} + + ///Called when a tab controlled by this [PlatformChromeSafariBrowser] has sent a postMessage. + ///If [postMessage] is called from a single thread, then the messages will be posted in the same order. + ///When received on the client side, it is the client's responsibility to preserve the ordering further. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsCallback.onPostMessage](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onPostMessage(java.lang.String,android.os.Bundle))) + void onPostMessage(String message) {} + + ///Called when a user scrolls the tab. + /// + ///[isDirectionUp] - `false` when the user scrolls farther down the page, + ///and `true` when the user scrolls back up toward the top of the page. + /// + ///**NOTE**: available only if [isEngagementSignalsApiAvailable] returns `true`. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - EngagementSignalsCallback.onVerticalScrollEvent](https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onVerticalScrollEvent(boolean,android.os.Bundle))) + void onVerticalScrollEvent(bool isDirectionUp) {} + + ///Called when a user has reached a greater scroll percentage on the page. The greatest scroll + ///percentage is reset if the user navigates to a different page. If the current page's total + ///height changes, this method will be called again only if the scroll progress reaches a + ///higher percentage based on the new and current height of the page. + /// + ///[scrollPercentage] - An integer indicating the percent of scrollable progress + ///the user hasmade down the current page. + /// + ///**NOTE**: available only if [isEngagementSignalsApiAvailable] returns `true`. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - EngagementSignalsCallback.onGreatestScrollPercentageIncreased](https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onGreatestScrollPercentageIncreased(int,android.os.Bundle))) + void onGreatestScrollPercentageIncreased(int scrollPercentage) {} + + ///Called when a `CustomTabsSession` is ending or when no further Engagement Signals + ///callbacks are expected to report whether any user action has occurred during the session. + /// + ///[didUserInteract] - Whether the user has interacted with the page in any way, e.g. scrolling. + /// + ///**NOTE**: available only if [isEngagementSignalsApiAvailable] returns `true`. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - EngagementSignalsCallback.onSessionEnded](https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onSessionEnded(boolean,android.os.Bundle))) + void onSessionEnded(bool didUserInteract) {} + + ///Event fired when the [PlatformChromeSafariBrowser] is closed. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + void onClosed() {} + + ///Returns `true` if the [PlatformChromeSafariBrowser] instance is opened, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + bool isOpened() { + return _isOpened; + } + + ///Disposes the channel. + @override + @mustCallSuper + void dispose() { + disposeChannel(); + } +} diff --git a/lib/src/content_blocker.dart b/flutter_inappwebview_platform_interface/lib/src/content_blocker.dart similarity index 100% rename from lib/src/content_blocker.dart rename to flutter_inappwebview_platform_interface/lib/src/content_blocker.dart diff --git a/lib/src/context_menu/context_menu.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.dart similarity index 92% rename from lib/src/context_menu/context_menu.dart rename to flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.dart index 9af6cf0b..6e790c4d 100644 --- a/lib/src/context_menu/context_menu.dart +++ b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.dart @@ -1,13 +1,13 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; +import '../in_app_webview/platform_webview.dart'; import '../types/in_app_webview_hit_test_result.dart'; import 'context_menu_item.dart'; import 'context_menu_settings.dart'; part 'context_menu.g.dart'; -///Class that represents the WebView context menu. It used by [WebView.contextMenu]. +///Class that represents the WebView context menu. It used by [PlatformWebViewCreationParams.contextMenu]. @SupportedPlatforms(platforms: [ AndroidPlatform( note: diff --git a/lib/src/context_menu/context_menu.g.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart similarity index 96% rename from lib/src/context_menu/context_menu.g.dart rename to flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart index 01e57939..c3b39050 100644 --- a/lib/src/context_menu/context_menu.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart @@ -6,7 +6,7 @@ part of 'context_menu.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Class that represents the WebView context menu. It used by [WebView.contextMenu]. +///Class that represents the WebView context menu. It used by [PlatformWebViewCreationParams.contextMenu]. /// ///**NOTE for Android native WebView**: To make it work properly on Android, JavaScript should be enabled! /// diff --git a/lib/src/context_menu/context_menu_item.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.dart similarity index 100% rename from lib/src/context_menu/context_menu_item.dart rename to flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.dart diff --git a/lib/src/context_menu/context_menu_item.g.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.g.dart similarity index 100% rename from lib/src/context_menu/context_menu_item.g.dart rename to flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.g.dart diff --git a/lib/src/context_menu/context_menu_settings.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.dart similarity index 100% rename from lib/src/context_menu/context_menu_settings.dart rename to flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.dart diff --git a/lib/src/context_menu/context_menu_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.g.dart similarity index 100% rename from lib/src/context_menu/context_menu_settings.g.dart rename to flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.g.dart diff --git a/lib/src/context_menu/main.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/main.dart similarity index 100% rename from lib/src/context_menu/main.dart rename to flutter_inappwebview_platform_interface/lib/src/context_menu/main.dart diff --git a/lib/src/debug_logging_settings.dart b/flutter_inappwebview_platform_interface/lib/src/debug_logging_settings.dart similarity index 100% rename from lib/src/debug_logging_settings.dart rename to flutter_inappwebview_platform_interface/lib/src/debug_logging_settings.dart diff --git a/flutter_inappwebview_platform_interface/lib/src/find_interaction/main.dart b/flutter_inappwebview_platform_interface/lib/src/find_interaction/main.dart new file mode 100644 index 00000000..59ad6cde --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/find_interaction/main.dart @@ -0,0 +1 @@ +export 'platform_find_interaction_controller.dart'; diff --git a/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart b/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart new file mode 100644 index 00000000..9b5a1047 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart @@ -0,0 +1,225 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_platform_interface/src/types/disposable.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +import '../in_app_webview/in_app_webview_settings.dart'; +import '../debug_logging_settings.dart'; +import '../inappwebview_platform.dart'; +import '../types/main.dart'; + +/// Object specifying creation parameters for creating a [PlatformFindInteractionController]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformFindInteractionControllerCreationParams { + /// Used by the platform implementation to create a new [PlatformFindInteractionController]. + const PlatformFindInteractionControllerCreationParams( + {this.onFindResultReceived}); + + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.onFindResultReceived} + final void Function( + PlatformFindInteractionController controller, + int activeMatchOrdinal, + int numberOfMatches, + bool isDoneCounting)? onFindResultReceived; +} + +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- MacOS +abstract class PlatformFindInteractionController extends PlatformInterface implements Disposable { + ///Debug settings. + static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings(); + + /// Creates a new [PlatformFindInteractionController] + factory PlatformFindInteractionController( + PlatformFindInteractionControllerCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformFindInteractionController webViewControllerDelegate = + InAppWebViewPlatform.instance!.createPlatformFindInteractionController(params); + PlatformInterface.verify(webViewControllerDelegate, _token); + return webViewControllerDelegate; + } + + /// Used by the platform implementation to create a new [PlatformFindInteractionController]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformFindInteractionController.implementation(this.params) : super(token: _token); + + static final Object _token = Object(); + + /// The parameters used to initialize the [PlatformFindInteractionController]. + final PlatformFindInteractionControllerCreationParams params; + + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.onFindResultReceived} + ///Event fired as find-on-page operations progress. + ///The listener may be notified multiple times while the operation is underway, and the [numberOfMatches] value should not be considered final unless [isDoneCounting] is true. + /// + ///[activeMatchOrdinal] represents the zero-based ordinal of the currently selected match. + /// + ///[numberOfMatches] represents how many matches have been found. + /// + ///[isDoneCounting] whether the find operation has actually completed. + /// + ///**NOTE**: on iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true`, this event will not be called. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.FindListener.onFindResultReceived](https://developer.android.com/reference/android/webkit/WebView.FindListener#onFindResultReceived(int,%20int,%20boolean))) + ///- iOS + ///- MacOS + ///{@endtemplate} + void Function( + PlatformFindInteractionController controller, + int activeMatchOrdinal, + int numberOfMatches, + bool isDoneCounting)? get onFindResultReceived => params.onFindResultReceived; + + ///Finds all instances of find on the page and highlights them. Notifies [PlatformFindInteractionController.onFindResultReceived] listener. + /// + ///[find] represents the string to find. + /// + ///**NOTE**: on Android native WebView, it finds all instances asynchronously. Successive calls to this will cancel any pending searches. + /// + ///**NOTE**: on iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true`, + ///it uses the built-in find interaction native UI, + ///otherwise this is implemented using CSS and Javascript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.findAllAsync](https://developer.android.com/reference/android/webkit/WebView#findAllAsync(java.lang.String))) + ///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.presentFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2) with [Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)) + ///- MacOS + Future findAll({String? find}) { + throw UnimplementedError( + 'findAll is not implemented on the current platform'); + } + + ///Highlights and scrolls to the next match found by [findAll]. Notifies [PlatformFindInteractionController.onFindResultReceived] listener. + /// + ///[forward] represents the direction to search. The default value is `true`, meaning forward. + /// + ///**NOTE**: on iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true`, + ///it uses the built-in find interaction native UI, + ///otherwise this is implemented using CSS and Javascript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.findNext](https://developer.android.com/reference/android/webkit/WebView#findNext(boolean))) + ///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.findNext](https://developer.apple.com/documentation/uikit/uifindinteraction/3975829-findnext?changes=_2) and ([Official API - UIFindInteraction.findPrevious](https://developer.apple.com/documentation/uikit/uifindinteraction/3975830-findprevious?changes=_2))) + ///- MacOS + Future findNext({bool forward = true}) { + throw UnimplementedError( + 'findNext is not implemented on the current platform'); + } + + ///Clears the highlighting surrounding text matches created by [findAll]. + /// + ///**NOTE**: on iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true`, + ///it uses the built-in find interaction native UI, + ///otherwise this is implemented using CSS and Javascript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.clearMatches](https://developer.android.com/reference/android/webkit/WebView#clearMatches())) + ///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.dismissFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2)) + ///- MacOS + Future clearMatches() { + throw UnimplementedError( + 'clearMatches is not implemented on the current platform'); + } + + ///Pre-populate the search text to be used. + /// + ///On iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true, + ///it will pre-populate the system find panel's search text field with a search query. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)) + ///- MacOS + Future setSearchText(String? searchText) { + throw UnimplementedError( + 'setSearchText is not implemented on the current platform'); + } + + ///Get the search text used. + /// + ///On iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true, + ///it will get the system find panel's search text field value. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)) + ///- MacOS + Future getSearchText() { + throw UnimplementedError( + 'getSearchText is not implemented on the current platform'); + } + + ///A Boolean value that indicates when the find panel displays onscreen. + /// + ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - UIFindInteraction.isFindNavigatorVisible](https://developer.apple.com/documentation/uikit/uifindinteraction/3975828-isfindnavigatorvisible?changes=_2)) + Future isFindNavigatorVisible() { + throw UnimplementedError( + 'isFindNavigatorVisible is not implemented on the current platform'); + } + + ///Updates the results the interface displays for the active search. + /// + ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - UIFindInteraction.updateResultCount](https://developer.apple.com/documentation/uikit/uifindinteraction/3975835-updateresultcount?changes=_2)) + Future updateResultCount() { + throw UnimplementedError( + 'updateResultCount is not implemented on the current platform'); + } + + ///Begins a search, displaying the find panel. + /// + ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - UIFindInteraction.presentFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2)) + Future presentFindNavigator() { + throw UnimplementedError( + 'presentFindNavigator is not implemented on the current platform'); + } + + ///Dismisses the find panel, if present. + /// + ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - UIFindInteraction.dismissFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2)) + Future dismissFindNavigator() { + throw UnimplementedError( + 'dismissFindNavigator is not implemented on the current platform'); + } + + ///If there's a currently active find session, returns the active find session. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - UIFindInteraction.activeFindSession](https://developer.apple.com/documentation/uikit/uifindinteraction/3975825-activefindsession?changes=_7____4_8&language=objc)) + ///- MacOS + Future getActiveFindSession() { + throw UnimplementedError( + 'getActiveFindSession is not implemented on the current platform'); + } + + @override + void dispose() { + throw UnimplementedError( + 'dispose is not implemented on the current platform'); + } +} diff --git a/lib/src/in_app_browser/android/in_app_browser_options.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/android/in_app_browser_options.dart similarity index 94% rename from lib/src/in_app_browser/android/in_app_browser_options.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_browser/android/in_app_browser_options.dart index 1ab5ba24..700f37dc 100755 --- a/lib/src/in_app_browser/android/in_app_browser_options.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/android/in_app_browser_options.dart @@ -1,9 +1,9 @@ import '../../in_app_webview/android/in_app_webview_options.dart'; import '../in_app_browser_settings.dart'; -import '../in_app_browser.dart'; +import '../platform_in_app_browser.dart'; -///This class represents all the Android-only [InAppBrowser] options available. +///This class represents all the Android-only [PlatformInAppBrowser] options available. ///Use [InAppBrowserSettings] instead. @Deprecated('Use InAppBrowserSettings instead') class AndroidInAppBrowserOptions implements BrowserOptions, AndroidOptions { diff --git a/lib/src/in_app_browser/android/main.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/android/main.dart similarity index 100% rename from lib/src/in_app_browser/android/main.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_browser/android/main.dart diff --git a/lib/src/in_app_browser/apple/in_app_browser_options.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/apple/in_app_browser_options.dart similarity index 96% rename from lib/src/in_app_browser/apple/in_app_browser_options.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_browser/apple/in_app_browser_options.dart index e34c1127..d5cdc540 100755 --- a/lib/src/in_app_browser/apple/in_app_browser_options.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/apple/in_app_browser_options.dart @@ -3,12 +3,12 @@ import 'dart:ui'; import '../../in_app_webview/apple/in_app_webview_options.dart'; import '../in_app_browser_settings.dart'; -import '../in_app_browser.dart'; +import '../platform_in_app_browser.dart'; import '../../types/main.dart'; import '../../util.dart'; -///This class represents all the iOS-only [InAppBrowser] options available. +///This class represents all the iOS-only [PlatformInAppBrowser] options available. ///Use [InAppBrowserSettings] instead. @Deprecated('Use InAppBrowserSettings instead') class IOSInAppBrowserOptions implements BrowserOptions, IosOptions { diff --git a/lib/src/in_app_browser/apple/main.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/apple/main.dart similarity index 100% rename from lib/src/in_app_browser/apple/main.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_browser/apple/main.dart diff --git a/lib/src/in_app_browser/in_app_browser_menu_item.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_menu_item.dart similarity index 93% rename from lib/src/in_app_browser/in_app_browser_menu_item.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_menu_item.dart index a9e7d239..5f082e7a 100644 --- a/lib/src/in_app_browser/in_app_browser_menu_item.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_menu_item.dart @@ -5,7 +5,7 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_i import '../util.dart'; -import 'in_app_browser.dart'; +import 'platform_in_app_browser.dart'; import '../types/main.dart'; part 'in_app_browser_menu_item.g.dart'; @@ -30,7 +30,7 @@ dynamic _deserializeIcon(dynamic icon) { return null; } -///Class that represents a custom menu item for a [InAppBrowser] instance. +///Class that represents a custom menu item for a [PlatformInAppBrowser] instance. @SupportedPlatforms(platforms: [ AndroidPlatform(), IOSPlatform(), diff --git a/lib/src/in_app_browser/in_app_browser_menu_item.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_menu_item.g.dart similarity index 96% rename from lib/src/in_app_browser/in_app_browser_menu_item.g.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_menu_item.g.dart index e7382b27..6fef0857 100644 --- a/lib/src/in_app_browser/in_app_browser_menu_item.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_menu_item.g.dart @@ -6,7 +6,7 @@ part of 'in_app_browser_menu_item.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Class that represents a custom menu item for a [InAppBrowser] instance. +///Class that represents a custom menu item for a [PlatformInAppBrowser] instance. /// ///**Supported Platforms/Implementations**: ///- Android native WebView diff --git a/lib/src/in_app_browser/in_app_browser_settings.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart similarity index 99% rename from lib/src/in_app_browser/in_app_browser_settings.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart index d8d61dff..ab372cfe 100755 --- a/lib/src/in_app_browser/in_app_browser_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart @@ -1,7 +1,6 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; -import 'package:flutter_inappwebview/src/types/main.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import '../types/in_app_webview_rect.dart'; diff --git a/lib/src/in_app_browser/in_app_browser_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart similarity index 100% rename from lib/src/in_app_browser/in_app_browser_settings.g.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/main.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/main.dart new file mode 100644 index 00000000..1b7b1bec --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/main.dart @@ -0,0 +1,11 @@ +export 'platform_in_app_browser.dart'; +export 'in_app_browser_settings.dart' + show + InAppBrowserClassSettings, + BrowserOptions, + InAppBrowserSettings, + InAppBrowserClassOptions, + InAppBrowserOptions; +export 'android/main.dart'; +export 'apple/main.dart'; +export 'in_app_browser_menu_item.dart' show InAppBrowserMenuItem; diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart new file mode 100755 index 00000000..e3ed7bc2 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart @@ -0,0 +1,1309 @@ +import 'dart:async'; +import 'dart:collection'; +import 'dart:typed_data'; +import 'dart:ui'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/src/types/disposable.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import '../context_menu/context_menu.dart'; +import '../find_interaction/platform_find_interaction_controller.dart'; +import '../inappwebview_platform.dart'; +import '../pull_to_refresh/main.dart'; +import '../types/main.dart'; + +import '../in_app_webview/platform_inappwebview_controller.dart'; +import '../in_app_webview/in_app_webview_settings.dart'; + +import '../print_job/main.dart'; +import '../web_uri.dart'; +import 'in_app_browser_menu_item.dart'; +import 'in_app_browser_settings.dart'; +import '../debug_logging_settings.dart'; +import '../pull_to_refresh/platform_pull_to_refresh_controller.dart'; + +/// Object specifying creation parameters for creating a [PlatformInAppBrowser]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformInAppBrowserCreationParams { + /// Used by the platform implementation to create a new [PlatformInAppBrowser]. + const PlatformInAppBrowserCreationParams( + {this.contextMenu, + this.pullToRefreshController, + this.findInteractionController, + this.initialUserScripts, + this.windowId}); + + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.contextMenu} + final ContextMenu? contextMenu; + + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.pullToRefreshController} + final PlatformPullToRefreshController? pullToRefreshController; + + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.findInteractionController} + final PlatformFindInteractionController? findInteractionController; + + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.initialUserScripts} + final UnmodifiableListView? initialUserScripts; + + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.windowId} + final int? windowId; +} + +///This class uses the native WebView of the platform. +///The [webViewController] field can be used to access the [PlatformInAppWebViewController] API. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- MacOS +abstract class PlatformInAppBrowser extends PlatformInterface implements Disposable { + ///Debug settings. + static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings(); + + /// Event handler object that handles the [PlatformInAppBrowser] events. + PlatformInAppBrowserEvents? eventHandler; + + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.id} + ///View ID used internally. + ///@{endtemplate} + String get id; + + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.contextMenu} + ///Context menu used by the browser. It should be set before opening the browser. + ///@{endtemplate} + ContextMenu? get contextMenu => params.contextMenu; + + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.pullToRefreshController} + ///Represents the pull-to-refresh feature controller. + ///@{endtemplate} + PlatformPullToRefreshController? get pullToRefreshController => params.pullToRefreshController; + + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.findInteractionController} + ///Represents the find interaction feature controller. + ///@{endtemplate} + PlatformFindInteractionController? get findInteractionController => params.findInteractionController; + + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.initialUserScripts} + ///Initial list of user scripts to be loaded at start or end of a page loading. + ///@{endtemplate} + UnmodifiableListView? get initialUserScripts => params.initialUserScripts; + + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.windowId} + ///The window id of a [CreateWindowAction.windowId]. + ///@{endtemplate} + int? get windowId => params.windowId; + + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.webViewController} + ///WebView Controller that can be used to access the [PlatformInAppWebViewController] API. + ///When [onExit] is fired, this will be `null` and cannot be used anymore. + ///@{endtemplate} + PlatformInAppWebViewController? get webViewController; + + /// Creates a new [PlatformInAppBrowser] + factory PlatformInAppBrowser(PlatformInAppBrowserCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformInAppBrowser inAppBrowser = + InAppWebViewPlatform.instance!.createPlatformInAppBrowser(params); + PlatformInterface.verify(inAppBrowser, _token); + return inAppBrowser; + } + + /// Creates a new [PlatformInAppBrowser] to access static methods. + factory PlatformInAppBrowser.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformInAppBrowser inAppBrowserStatic = + InAppWebViewPlatform.instance!.createPlatformInAppBrowserStatic(); + PlatformInterface.verify(inAppBrowserStatic, _token); + return inAppBrowserStatic; + } + + /// Used by the platform implementation to create a new [PlatformInAppBrowser]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformInAppBrowser.implementation(this.params) : super(token: _token); + + static final Object _token = Object(); + + /// The parameters used to initialize the [PlatformInAppBrowser]. + final PlatformInAppBrowserCreationParams params; + + ///Opens the [PlatformInAppBrowser] instance with an [urlRequest]. + /// + ///[urlRequest]: The [urlRequest] to load. + /// + ///[options]: Options for the [PlatformInAppBrowser]. + /// + ///[settings]: Settings for the [PlatformInAppBrowser]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future openUrlRequest( + {required URLRequest urlRequest, + // ignore: deprecated_member_use_from_same_package + @Deprecated('Use settings instead') InAppBrowserClassOptions? options, + InAppBrowserClassSettings? settings}) { + throw UnimplementedError( + 'openUrlRequest is not implemented on the current platform'); + } + + ///Opens the [PlatformInAppBrowser] instance with the given [assetFilePath] file. + /// + ///[options]: Options for the [PlatformInAppBrowser]. + /// + ///To be able to load your local files (assets, js, css, etc.), you need to add them in the `assets` section of the `pubspec.yaml` file, otherwise they cannot be found! + /// + ///Example of a `pubspec.yaml` file: + ///```yaml + ///... + /// + ///# The following section is specific to Flutter. + ///flutter: + /// + /// # The following line ensures that the Material Icons font is + /// # included with your application, so that you can use the icons in + /// # the material Icons class. + /// uses-material-design: true + /// + /// assets: + /// - assets/index.html + /// - assets/css/ + /// - assets/images/ + /// + ///... + ///``` + ///Example of a `main.dart` file: + ///```dart + ///... + ///inAppBrowser.openFile(assetFilePath: "assets/index.html"); + ///... + ///``` + /// + ///[headers]: The additional headers to be used in the HTTP request for this URL, specified as a map from name to value. + /// + ///[options]: Options for the [PlatformInAppBrowser]. + /// + ///[settings]: Settings for the [PlatformInAppBrowser]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future openFile( + {required String assetFilePath, + // ignore: deprecated_member_use_from_same_package + @Deprecated('Use settings instead') InAppBrowserClassOptions? options, + InAppBrowserClassSettings? settings}) { + throw UnimplementedError( + 'openFile is not implemented on the current platform'); + } + + ///Opens the [PlatformInAppBrowser] instance with [data] as a content, using [baseUrl] as the base URL for it. + /// + ///The [mimeType] parameter specifies the format of the data. The default value is `"text/html"`. + /// + ///The [encoding] parameter specifies the encoding of the data. The default value is `"utf8"`. + /// + ///The [androidHistoryUrl] parameter is the URL to use as the history entry. The default value is `about:blank`. If non-null, this must be a valid URL. This parameter is used only on Android. + /// + ///The [options] parameter specifies the options for the [PlatformInAppBrowser]. + /// + ///[settings]: Settings for the [PlatformInAppBrowser]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future openData( + {required String data, + String mimeType = "text/html", + String encoding = "utf8", + WebUri? baseUrl, + @Deprecated("Use historyUrl instead") Uri? androidHistoryUrl, + WebUri? historyUrl, + // ignore: deprecated_member_use_from_same_package + @Deprecated('Use settings instead') InAppBrowserClassOptions? options, + InAppBrowserClassSettings? settings}) { + throw UnimplementedError( + 'openData is not implemented on the current platform'); + } + + ///This is a static method that opens an [url] in the system browser. You wont be able to use the [PlatformInAppBrowser] methods here! + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future openWithSystemBrowser({required WebUri url}) { + throw UnimplementedError( + 'openWithSystemBrowser is not implemented on the current platform'); + } + + ///Adds a [InAppBrowserMenuItem] to the menu. + ///If the browser is already open, + ///it will take effect the next time it is opened. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS 14.0+ + void addMenuItem(InAppBrowserMenuItem menuItem) { + throw UnimplementedError( + 'addMenuItem is not implemented on the current platform'); + } + + ///Adds a list of [InAppBrowserMenuItem] to the menu. + ///If the browser is already open, + ///it will take effect the next time it is opened. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS 14.0+ + void addMenuItems(List menuItems) { + throw UnimplementedError( + 'addMenuItems is not implemented on the current platform'); + } + + ///Removes the [menuItem] from the list. + ///Returns `true` if it was in the list, `false` otherwise. + ///If the browser is already open, + ///it will take effect the next time it is opened. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS 14.0+ + bool removeMenuItem(InAppBrowserMenuItem menuItem) { + throw UnimplementedError( + 'removeMenuItem is not implemented on the current platform'); + } + + ///Removes a list of [menuItems] from the list. + ///If the browser is already open, + ///it will take effect the next time it is opened. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS 14.0+ + void removeMenuItems(List menuItems) { + throw UnimplementedError( + 'removeMenuItems is not implemented on the current platform'); + } + + ///Removes all the menu items from the list. + ///If the browser is already open, + ///it will take effect the next time it is opened. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS 14.0+ + void removeAllMenuItem() { + throw UnimplementedError( + 'removeAllMenuItem is not implemented on the current platform'); + } + + ///Returns `true` if the [menuItem] has been already added, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS 14.0+ + bool hasMenuItem(InAppBrowserMenuItem menuItem) { + throw UnimplementedError( + 'hasMenuItem is not implemented on the current platform'); + } + + ///Displays an [PlatformInAppBrowser] window that was opened hidden. Calling this has no effect if the [PlatformInAppBrowser] was already visible. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future show() { + throw UnimplementedError('show is not implemented on the current platform'); + } + + ///Hides the [PlatformInAppBrowser] window. Calling this has no effect if the [PlatformInAppBrowser] was already hidden. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future hide() { + throw UnimplementedError('hide is not implemented on the current platform'); + } + + ///Closes the [PlatformInAppBrowser] window. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future close() { + throw UnimplementedError( + 'close is not implemented on the current platform'); + } + + ///Check if the Web View of the [PlatformInAppBrowser] instance is hidden. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future isHidden() { + throw UnimplementedError( + 'isHidden is not implemented on the current platform'); + } + + ///Use [setSettings] instead. + @Deprecated('Use setSettings instead') + Future setOptions({required InAppBrowserClassOptions options}) { + throw UnimplementedError( + 'setOptions is not implemented on the current platform'); + } + + ///Use [getSettings] instead. + @Deprecated('Use getSettings instead') + Future getOptions() { + throw UnimplementedError( + 'getOptions is not implemented on the current platform'); + } + + ///Sets the [PlatformInAppBrowser] settings with the new [settings] and evaluates them. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future setSettings({required InAppBrowserClassSettings settings}) { + throw UnimplementedError( + 'setSettings is not implemented on the current platform'); + } + + ///Gets the current [PlatformInAppBrowser] settings. Returns `null` if it wasn't able to get them. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future getSettings() { + throw UnimplementedError( + 'getSettings is not implemented on the current platform'); + } + + ///Returns `true` if the [PlatformInAppBrowser] instance is opened, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + bool isOpened() { + throw UnimplementedError( + 'isOpened is not implemented on the current platform'); + } + + ///Disposes the channel and controllers. + @override + void dispose() { + throw UnimplementedError( + 'dispose is not implemented on the current platform'); + } +} + +abstract class PlatformInAppBrowserEvents { + ///Event fired when the [PlatformInAppBrowser] is created. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + void onBrowserCreated() {} + + ///Event fired when the [PlatformInAppBrowser] window is closed. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + void onExit() {} + + ///Event fired when the [PlatformInAppBrowser] starts to load an [url]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.onPageStarted](https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap))) + ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview)) + ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview)) + void onLoadStart(WebUri? url) {} + + ///Event fired when the [PlatformInAppBrowser] finishes loading an [url]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.onPageFinished](https://developer.android.com/reference/android/webkit/WebViewClient#onPageFinished(android.webkit.WebView,%20java.lang.String))) + ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview)) + ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview)) + void onLoadStop(WebUri? url) {} + + ///Use [onReceivedError] instead. + @Deprecated("Use onReceivedError instead") + void onLoadError(Uri? url, int code, String message) {} + + ///Event fired when the [PlatformInAppBrowser] encounters an [error] loading a [request]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.onReceivedError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError))) + ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview)) + ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview)) + void onReceivedError(WebResourceRequest request, WebResourceError error) {} + + ///Use [onReceivedHttpError] instead. + @Deprecated("Use onReceivedHttpError instead") + void onLoadHttpError(Uri? url, int statusCode, String description) {} + + ///Event fired when the [PlatformInAppBrowser] receives an HTTP error. + /// + ///[request] represents the originating request. + /// + ///[errorResponse] represents the information about the error occurred. + /// + ///**NOTE**: available on Android 23+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.onReceivedHttpError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceResponse))) + ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview)) + ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview)) + void onReceivedHttpError( + WebResourceRequest request, WebResourceResponse errorResponse) {} + + ///Event fired when the current [progress] (range 0-100) of loading a page is changed. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onProgressChanged](https://developer.android.com/reference/android/webkit/WebChromeClient#onProgressChanged(android.webkit.WebView,%20int))) + ///- iOS + ///- MacOS + void onProgressChanged(int progress) {} + + ///Event fired when the [PlatformInAppBrowser] webview receives a [ConsoleMessage]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onConsoleMessage](https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage))) + ///- iOS + ///- MacOS + void onConsoleMessage(ConsoleMessage consoleMessage) {} + + ///Give the host application a chance to take control when a URL is about to be loaded in the current WebView. This event is not called on the initial load of the WebView. + /// + ///Note that on Android there isn't any way to load an URL for a frame that is not the main frame, so if the request is not for the main frame, the navigation is allowed by default. + ///However, if you want to cancel requests for subframes, you can use the [InAppWebViewSettings.regexToCancelSubFramesLoading] setting + ///to write a Regular Expression that, if the url request of a subframe matches, then the request of that subframe is canceled. + /// + ///Also, on Android, this method is not called for POST requests. + /// + ///[navigationAction] represents an object that contains information about an action that causes navigation to occur. + /// + ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldOverrideUrlLoading] setting to `true`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.shouldOverrideUrlLoading](https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20java.lang.String))) + ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview)) + ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview)) + Future? shouldOverrideUrlLoading( + NavigationAction navigationAction) { + return null; + } + + ///Event fired when the [PlatformInAppBrowser] webview loads a resource. + /// + ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnLoadResource] and [InAppWebViewSettings.javaScriptEnabled] setting to `true`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + void onLoadResource(LoadedResource resource) {} + + ///Event fired when the [PlatformInAppBrowser] webview scrolls. + /// + ///[x] represents the current horizontal scroll origin in pixels. + /// + ///[y] represents the current vertical scroll origin in pixels. + /// + ///**NOTE for MacOS**: this method is implemented with using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.onScrollChanged](https://developer.android.com/reference/android/webkit/WebView#onScrollChanged(int,%20int,%20int,%20int))) + ///- iOS ([Official API - UIScrollViewDelegate.scrollViewDidScroll](https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619392-scrollviewdidscroll)) + ///- MacOS + void onScrollChanged(int x, int y) {} + + ///Use [onDownloadStartRequest] instead + @Deprecated('Use onDownloadStartRequest instead') + void onDownloadStart(Uri url) {} + + ///Event fired when `WebView` recognizes a downloadable file. + ///To download the file, you can use the [flutter_downloader](https://pub.dev/packages/flutter_downloader) plugin. + /// + ///[downloadStartRequest] represents the request of the file to download. + /// + ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnDownloadStart] setting to `true`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.setDownloadListener](https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener))) + ///- iOS + ///- MacOS + void onDownloadStartRequest(DownloadStartRequest downloadStartRequest) {} + + ///Use [onLoadResourceWithCustomScheme] instead. + @Deprecated('Use onLoadResourceWithCustomScheme instead') + Future? onLoadResourceCustomScheme(Uri url) { + return null; + } + + ///Event fired when the [PlatformInAppBrowser] webview finds the `custom-scheme` while loading a resource. + ///Here you can handle the url [request] and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - WKURLSchemeHandler](https://developer.apple.com/documentation/webkit/wkurlschemehandler)) + ///- MacOS ([Official API - WKURLSchemeHandler](https://developer.apple.com/documentation/webkit/wkurlschemehandler)) + Future? onLoadResourceWithCustomScheme( + WebResourceRequest request) { + return null; + } + + ///Event fired when the [PlatformInAppBrowser] webview requests the host application to create a new window, + ///for example when trying to open a link with `target="_blank"` or when `window.open()` is called by JavaScript side. + ///If the host application chooses to honor this request, it should return `true` from this method, create a new WebView to host the window. + ///If the host application chooses not to honor the request, it should return `false` from this method. + ///The default implementation of this method does nothing and hence returns `false`. + /// + ///[createWindowAction] represents the request. + /// + ///**NOTE**: to allow JavaScript to open windows, you need to set [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically] setting to `true`. + /// + ///**NOTE**: on Android you need to set [InAppWebViewSettings.supportMultipleWindows] setting to `true`. + /// + ///**NOTE**: on iOS and MacOS, setting these initial settings: [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest], + ///[InAppWebViewSettings.useShouldInterceptFetchRequest], [InAppWebViewSettings.applicationNameForUserAgent], [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically], + ///[InAppWebViewSettings.javaScriptEnabled], [InAppWebViewSettings.minimumFontSize], [InAppWebViewSettings.preferredContentMode], [InAppWebViewSettings.incognito], + ///[InAppWebViewSettings.cacheEnabled], [InAppWebViewSettings.mediaPlaybackRequiresUserGesture], + ///[InAppWebViewSettings.resourceCustomSchemes], [InAppWebViewSettings.sharedCookiesEnabled], + ///[InAppWebViewSettings.enableViewportScale], [InAppWebViewSettings.allowsAirPlayForMediaPlayback], + ///[InAppWebViewSettings.allowsPictureInPictureMediaPlayback], [InAppWebViewSettings.isFraudulentWebsiteWarningEnabled], + ///[InAppWebViewSettings.allowsInlineMediaPlayback], [InAppWebViewSettings.suppressesIncrementalRendering], [InAppWebViewSettings.selectionGranularity], + ///[InAppWebViewSettings.ignoresViewportScaleLimits], [InAppWebViewSettings.limitsNavigationsToAppBoundDomains], + ///[InAppWebViewSettings.upgradeKnownHostsToHTTPS], + ///will have no effect due to a `WKWebView` limitation when creating a new window WebView: it's impossible to return a new `WKWebView` + ///with a different `WKWebViewConfiguration` instance (see https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview). + ///So, these options will be inherited from the caller WebView. + ///Also, note that calling [PlatformInAppWebViewController.setSettings] method using the controller of the new created WebView, + ///it will update also the WebView options of the caller WebView. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onCreateWindow](https://developer.android.com/reference/android/webkit/WebChromeClient#onCreateWindow(android.webkit.WebView,%20boolean,%20boolean,%20android.os.Message))) + ///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview)) + ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview)) + Future? onCreateWindow(CreateWindowAction createWindowAction) { + return null; + } + + ///Event fired when the host application should close the given WebView and remove it from the view system if necessary. + ///At this point, WebCore has stopped any loading in this window and has removed any cross-scripting ability in javascript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onCloseWindow](https://developer.android.com/reference/android/webkit/WebChromeClient#onCloseWindow(android.webkit.WebView))) + ///- iOS ([Official API - WKUIDelegate.webViewDidClose](https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose)) + ///- MacOS ([Official API - WKUIDelegate.webViewDidClose](https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose)) + void onCloseWindow() {} + + ///Event fired when the JavaScript `window` object of the WebView has received focus. + ///This is the result of the `focus` javascript event applied to the `window` object. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + void onWindowFocus() {} + + ///Event fired when the JavaScript `window` object of the WebView has lost focus. + ///This is the result of the `blur` javascript event applied to the `window` object. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + void onWindowBlur() {} + + ///Event fired when javascript calls the `alert()` method to display an alert dialog. + ///If [JsAlertResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog. + /// + ///[jsAlertRequest] contains the message to be displayed in the alert dialog and the of the page requesting the dialog. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onJsAlert](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsAlert(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult))) + ///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview)) + ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview)) + Future? onJsAlert(JsAlertRequest jsAlertRequest) { + return null; + } + + ///Event fired when javascript calls the `confirm()` method to display a confirm dialog. + ///If [JsConfirmResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog. + /// + ///[jsConfirmRequest] contains the message to be displayed in the confirm dialog and the of the page requesting the dialog. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onJsConfirm](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsConfirm(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult))) + ///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview)) + ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview)) + Future? onJsConfirm(JsConfirmRequest jsConfirmRequest) { + return null; + } + + ///Event fired when javascript calls the `prompt()` method to display a prompt dialog. + ///If [JsPromptResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog. + /// + ///[jsPromptRequest] contains the message to be displayed in the prompt dialog, the default value displayed in the prompt dialog, and the of the page requesting the dialog. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onJsPrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsPrompt(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20android.webkit.JsPromptResult))) + ///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview)) + ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview)) + Future? onJsPrompt(JsPromptRequest jsPromptRequest) { + return null; + } + + ///Event fired when the WebView received an HTTP authentication request. The default behavior is to cancel the request. + /// + ///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [URLAuthenticationChallenge]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.onReceivedHttpAuthRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpAuthRequest(android.webkit.WebView,%20android.webkit.HttpAuthHandler,%20java.lang.String,%20java.lang.String))) + ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) + ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) + Future? onReceivedHttpAuthRequest( + URLAuthenticationChallenge challenge) { + return null; + } + + ///Event fired when the WebView need to perform server trust authentication (certificate validation). + ///The host application must return either [ServerTrustAuthResponse] instance with [ServerTrustAuthResponseAction.CANCEL] or [ServerTrustAuthResponseAction.PROCEED]. + /// + ///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ServerTrustChallenge]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.onReceivedSslError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedSslError(android.webkit.WebView,%20android.webkit.SslErrorHandler,%20android.net.http.SslError))) + ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) + ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) + Future? onReceivedServerTrustAuthRequest( + URLAuthenticationChallenge challenge) { + return null; + } + + ///Notify the host application to handle an SSL client certificate request. + ///Webview stores the response in memory (for the life of the application) if [ClientCertResponseAction.PROCEED] or [ClientCertResponseAction.CANCEL] + ///is called and does not call [onReceivedClientCertRequest] again for the same host and port pair. + ///Note that, multiple layers in chromium network stack might be caching the responses. + /// + ///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ClientCertChallenge]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.onReceivedClientCertRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedClientCertRequest(android.webkit.WebView,%20android.webkit.ClientCertRequest))) + ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) + ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) + Future? onReceivedClientCertRequest( + URLAuthenticationChallenge challenge) { + return null; + } + + ///Use [FindInteractionController.onFindResultReceived] instead. + @Deprecated('Use FindInteractionController.onFindResultReceived instead') + void onFindResultReceived( + int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting) {} + + ///Event fired when an `XMLHttpRequest` is sent to a server. + ///It gives the host application a chance to take control over the request before sending it. + /// + ///[ajaxRequest] represents the `XMLHttpRequest`. + /// + ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting to `true`. + ///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that + ///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code + ///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms). + ///Inside the `window.addEventListener("flutterInAppWebViewPlatformReady")` event, the ajax requests will be intercept for sure. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future? shouldInterceptAjaxRequest(AjaxRequest ajaxRequest) { + return null; + } + + ///Event fired whenever the `readyState` attribute of an `XMLHttpRequest` changes. + ///It gives the host application a chance to abort the request. + /// + ///[ajaxRequest] represents the [XMLHttpRequest]. + /// + ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting to `true`. + ///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that + ///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code + ///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms). + ///Inside the `window.addEventListener("flutterInAppWebViewPlatformReady")` event, the ajax requests will be intercept for sure. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future? onAjaxReadyStateChange(AjaxRequest ajaxRequest) { + return null; + } + + ///Event fired as an `XMLHttpRequest` progress. + ///It gives the host application a chance to abort the request. + /// + ///[ajaxRequest] represents the [XMLHttpRequest]. + /// + ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting to `true`. + ///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that + ///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code + ///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms). + ///Inside the `window.addEventListener("flutterInAppWebViewPlatformReady")` event, the ajax requests will be intercept for sure. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future? onAjaxProgress(AjaxRequest ajaxRequest) { + return null; + } + + ///Event fired when a request is sent to a server through [Fetch API](https://developer.mozilla.org/it/docs/Web/API/Fetch_API). + ///It gives the host application a chance to take control over the request before sending it. + /// + ///[fetchRequest] represents a resource request. + /// + ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptFetchRequest] setting to `true`. + ///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that + ///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code + ///used to intercept fetch requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms). + ///Inside the `window.addEventListener("flutterInAppWebViewPlatformReady")` event, the fetch requests will be intercept for sure. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future? shouldInterceptFetchRequest( + FetchRequest fetchRequest) { + return null; + } + + ///Event fired when the host application updates its visited links database. + ///This event is also fired when the navigation state of the [InAppWebView] changes through the usage of + ///javascript **[History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API)** functions (`pushState()`, `replaceState()`) and `onpopstate` event + ///or, also, when the javascript `window.location` changes without reloading the webview (for example appending or modifying an hash to the url). + /// + ///[url] represents the url being visited. + /// + ///[isReload] indicates if this url is being reloaded. Available only on Android. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.doUpdateVisitedHistory](https://developer.android.com/reference/android/webkit/WebViewClient#doUpdateVisitedHistory(android.webkit.WebView,%20java.lang.String,%20boolean))) + ///- iOS + ///- MacOS + void onUpdateVisitedHistory(WebUri? url, bool? isReload) {} + + ///Use [onPrintRequest] instead + @Deprecated("Use onPrintRequest instead") + void onPrint(Uri? url) {} + + ///Event fired when `window.print()` is called from JavaScript side. + ///Return `true` if you want to handle the print job. + ///Otherwise return `false`, so the [PlatformPrintJobController] will be handled and disposed automatically by the system. + /// + ///[url] represents the url on which is called. + /// + ///[printJobController] represents the controller of the print job created. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future? onPrintRequest( + WebUri? url, PlatformPrintJobController? printJobController) { + return null; + } + + ///Event fired when an HTML element of the webview has been clicked and held. + /// + ///[hitTestResult] represents the hit result for hitting an HTML elements. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - View.setOnLongClickListener](https://developer.android.com/reference/android/view/View#setOnLongClickListener(android.view.View.OnLongClickListener))) + ///- iOS ([Official API - UILongPressGestureRecognizer](https://developer.apple.com/documentation/uikit/uilongpressgesturerecognizer)) + void onLongPressHitTestResult(InAppWebViewHitTestResult hitTestResult) {} + + ///Event fired when the current page has entered full screen mode. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onShowCustomView](https://developer.android.com/reference/android/webkit/WebChromeClient#onShowCustomView(android.view.View,%20android.webkit.WebChromeClient.CustomViewCallback))) + ///- iOS ([Official API - UIWindow.didBecomeVisibleNotification](https://developer.apple.com/documentation/uikit/uiwindow/1621621-didbecomevisiblenotification)) + ///- MacOS ([Official API - NSWindow.didEnterFullScreenNotification](https://developer.apple.com/documentation/appkit/nswindow/1419651-didenterfullscreennotification)) + void onEnterFullscreen() {} + + ///Event fired when the current page has exited full screen mode. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onHideCustomView](https://developer.android.com/reference/android/webkit/WebChromeClient#onHideCustomView())) + ///- iOS ([Official API - UIWindow.didBecomeHiddenNotification](https://developer.apple.com/documentation/uikit/uiwindow/1621617-didbecomehiddennotification)) + ///- MacOS ([Official API - NSWindow.didExitFullScreenNotification](https://developer.apple.com/documentation/appkit/nswindow/1419177-didexitfullscreennotification)) + void onExitFullscreen() {} + + ///Called when the web view begins to receive web content. + /// + ///This event occurs early in the document loading process, and as such + ///you should expect that linked resources (for example, CSS and images) may not be available. + /// + ///[url] represents the URL corresponding to the page navigation that triggered this callback. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.onPageCommitVisible](https://developer.android.com/reference/android/webkit/WebViewClient#onPageCommitVisible(android.webkit.WebView,%20java.lang.String))) + ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview)) + ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview)) + void onPageCommitVisible(WebUri? url) {} + + ///Event fired when a change in the document title occurred. + /// + ///[title] represents the string containing the new title of the document. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onReceivedTitle](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTitle(android.webkit.WebView,%20java.lang.String))) + ///- iOS + ///- MacOS + void onTitleChanged(String? title) {} + + ///Event fired to respond to the results of an over-scroll operation. + /// + ///[x] represents the new X scroll value in pixels. + /// + ///[y] represents the new Y scroll value in pixels. + /// + ///[clampedX] is `true` if [x] was clamped to an over-scroll boundary. + /// + ///[clampedY] is `true` if [y] was clamped to an over-scroll boundary. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.onOverScrolled](https://developer.android.com/reference/android/webkit/WebView#onOverScrolled(int,%20int,%20boolean,%20boolean))) + ///- iOS + void onOverScrolled(int x, int y, bool clampedX, bool clampedY) {} + + ///Event fired when the zoom scale of the WebView has changed. + /// + ///[oldScale] The old zoom scale factor. + /// + ///[newScale] The new zoom scale factor.ì + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.onScaleChanged](https://developer.android.com/reference/android/webkit/WebViewClient#onScaleChanged(android.webkit.WebView,%20float,%20float))) + ///- iOS ([Official API - UIScrollViewDelegate.scrollViewDidZoom](https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619409-scrollviewdidzoom)) + void onZoomScaleChanged(double oldScale, double newScale) {} + + ///Use [onSafeBrowsingHit] instead. + @Deprecated("Use onSafeBrowsingHit instead") + Future? androidOnSafeBrowsingHit( + Uri url, SafeBrowsingThreat? threatType) { + return null; + } + + ///Event fired when the WebView notifies that a loading URL has been flagged by Safe Browsing. + ///The default behavior is to show an interstitial to the user, with the reporting checkbox visible. + /// + ///[url] represents the url of the request. + /// + ///[threatType] represents the reason the resource was caught by Safe Browsing, corresponding to a [SafeBrowsingThreat]. + /// + ///**NOTE**: available only on Android 27+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.onSafeBrowsingHit](https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse))) + Future? onSafeBrowsingHit( + WebUri url, SafeBrowsingThreat? threatType) { + return null; + } + + ///Use [onPermissionRequest] instead. + @Deprecated("Use onPermissionRequest instead") + Future? androidOnPermissionRequest( + String origin, List resources) { + return null; + } + + ///Event fired when the WebView is requesting permission to access the specified resources and the permission currently isn't granted or denied. + /// + ///[permissionRequest] represents the permission request with an array of resources the web content wants to access + ///and the origin of the web page which is trying to access the restricted resources. + /// + ///**NOTE for Android**: available only on Android 21+. + /// + ///**NOTE for iOS**: available only on iOS 15.0+. The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT]. + /// + ///**NOTE for MacOS**: available only on iOS 12.0+. The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onPermissionRequest](https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest))) + ///- iOS + ///- MacOS + Future? onPermissionRequest( + PermissionRequest permissionRequest) { + return null; + } + + ///Use [onGeolocationPermissionsShowPrompt] instead. + @Deprecated("Use onGeolocationPermissionsShowPrompt instead") + Future? + androidOnGeolocationPermissionsShowPrompt(String origin) { + return null; + } + + ///Event that notifies the host application that web content from the specified origin is attempting to use the Geolocation API, but no permission state is currently set for that origin. + ///Note that for applications targeting Android N and later SDKs (API level > `Build.VERSION_CODES.M`) this method is only called for requests originating from secure origins such as https. + ///On non-secure origins geolocation requests are automatically denied. + /// + ///[origin] represents the origin of the web content attempting to use the Geolocation API. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsShowPrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback))) + Future? + onGeolocationPermissionsShowPrompt(String origin) { + return null; + } + + ///Use [onGeolocationPermissionsHidePrompt] instead. + @Deprecated("Use onGeolocationPermissionsHidePrompt instead") + void androidOnGeolocationPermissionsHidePrompt() {} + + ///Notify the host application that a request for Geolocation permissions, made with a previous call to [onGeolocationPermissionsShowPrompt] has been canceled. + ///Any related UI should therefore be hidden. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsHidePrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsHidePrompt())) + void onGeolocationPermissionsHidePrompt() {} + + ///Use [shouldInterceptRequest] instead. + @Deprecated("Use shouldInterceptRequest instead") + Future? androidShouldInterceptRequest( + WebResourceRequest request) { + return null; + } + + ///Notify the host application of a resource request and allow the application to return the data. + ///If the return value is `null`, the WebView will continue to load the resource as usual. + ///Otherwise, the return response and data will be used. + /// + ///This callback is invoked for a variety of URL schemes (e.g., `http(s):`, `data:`, `file:`, etc.), + ///not only those schemes which send requests over the network. + ///This is not called for `javascript:` URLs, `blob:` URLs, or for assets accessed via `file:///android_asset/` or `file:///android_res/` URLs. + /// + ///In the case of redirects, this is only called for the initial resource URL, not any subsequent redirect URLs. + /// + ///[request] Object containing the details of the request. + /// + ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptRequest] option to `true`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.shouldInterceptRequest](https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest))) + Future? shouldInterceptRequest( + WebResourceRequest request) { + return null; + } + + ///Use [onRenderProcessUnresponsive] instead. + @Deprecated("Use onRenderProcessUnresponsive instead") + Future? androidOnRenderProcessUnresponsive( + Uri? url) { + return null; + } + + ///Event called when the renderer currently associated with the WebView becomes unresponsive as a result of a long running blocking task such as the execution of JavaScript. + /// + ///If a WebView fails to process an input event, or successfully navigate to a new URL within a reasonable time frame, the renderer is considered to be unresponsive, and this callback will be called. + /// + ///This callback will continue to be called at regular intervals as long as the renderer remains unresponsive. + ///If the renderer becomes responsive again, [onRenderProcessResponsive] will be called once, + ///and this method will not subsequently be called unless another period of unresponsiveness is detected. + /// + ///The minimum interval between successive calls to [onRenderProcessUnresponsive] is 5 seconds. + /// + ///No action is taken by WebView as a result of this method call. + ///Applications may choose to terminate the associated renderer via the object that is passed to this callback, + ///if in multiprocess mode, however this must be accompanied by correctly handling [onRenderProcessGone] for this WebView, + ///and all other WebViews associated with the same renderer. Failure to do so will result in application termination. + /// + ///**NOTE**: available only on Android 29+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessUnresponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) + Future? onRenderProcessUnresponsive( + WebUri? url) { + return null; + } + + ///Use [onRenderProcessResponsive] instead. + @Deprecated("Use onRenderProcessResponsive instead") + Future? androidOnRenderProcessResponsive( + Uri? url) { + return null; + } + + ///Event called once when an unresponsive renderer currently associated with the WebView becomes responsive. + /// + ///After a WebView renderer becomes unresponsive, which is notified to the application by [onRenderProcessUnresponsive], + ///it is possible for the blocking renderer task to complete, returning the renderer to a responsive state. + ///In that case, this method is called once to indicate responsiveness. + /// + ///No action is taken by WebView as a result of this method call. + /// + ///**NOTE**: available only on Android 29+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessResponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) + Future? onRenderProcessResponsive(WebUri? url) { + return null; + } + + ///Use [onRenderProcessGone] instead. + @Deprecated("Use onRenderProcessGone instead") + void androidOnRenderProcessGone(RenderProcessGoneDetail detail) {} + + ///Event fired when the given WebView's render process has exited. + ///The application's implementation of this callback should only attempt to clean up the WebView. + ///The WebView should be removed from the view hierarchy, all references to it should be cleaned up. + /// + ///[detail] the reason why it exited. + /// + ///**NOTE**: available only on Android 26+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.onRenderProcessGone](https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail))) + void onRenderProcessGone(RenderProcessGoneDetail detail) {} + + ///Use [onFormResubmission] instead. + @Deprecated('Use onFormResubmission instead') + Future? androidOnFormResubmission(Uri? url) { + return null; + } + + ///As the host application if the browser should resend data as the requested page was a result of a POST. The default is to not resend the data. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.onFormResubmission](https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message))) + Future? onFormResubmission(WebUri? url) { + return null; + } + + ///Use [onZoomScaleChanged] instead. + @Deprecated('Use onZoomScaleChanged instead') + void androidOnScaleChanged(double oldScale, double newScale) {} + + ///Use [onReceivedIcon] instead. + @Deprecated('Use onReceivedIcon instead') + void androidOnReceivedIcon(Uint8List icon) {} + + ///Event fired when there is new favicon for the current page. + /// + ///[icon] represents the favicon for the current page. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onReceivedIcon](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap))) + void onReceivedIcon(Uint8List icon) {} + + ///Use [onReceivedTouchIconUrl] instead. + @Deprecated('Use onReceivedTouchIconUrl instead') + void androidOnReceivedTouchIconUrl(Uri url, bool precomposed) {} + + ///Event fired when there is an url for an apple-touch-icon. + /// + ///[url] represents the icon url. + /// + ///[precomposed] is `true` if the url is for a precomposed touch icon. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onReceivedTouchIconUrl](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean))) + void onReceivedTouchIconUrl(WebUri url, bool precomposed) {} + + ///Use [onJsBeforeUnload] instead. + @Deprecated('Use onJsBeforeUnload instead') + Future? androidOnJsBeforeUnload( + JsBeforeUnloadRequest jsBeforeUnloadRequest) { + return null; + } + + ///Event fired when the client should display a dialog to confirm navigation away from the current page. + ///This is the result of the `onbeforeunload` javascript event. + ///If [JsBeforeUnloadResponse.handledByClient] is `true`, WebView will assume that the client will handle the confirm dialog. + ///If [JsBeforeUnloadResponse.handledByClient] is `false`, a default value of `true` will be returned to javascript to accept navigation away from the current page. + ///The default behavior is to return `false`. + ///Setting the [JsBeforeUnloadResponse.action] to [JsBeforeUnloadResponseAction.CONFIRM] will navigate away from the current page, + ///[JsBeforeUnloadResponseAction.CANCEL] will cancel the navigation. + /// + ///[jsBeforeUnloadRequest] contains the message to be displayed in the alert dialog and the of the page requesting the dialog. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onJsBeforeUnload](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsBeforeUnload(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult))) + Future? onJsBeforeUnload( + JsBeforeUnloadRequest jsBeforeUnloadRequest) { + return null; + } + + ///Use [onReceivedLoginRequest] instead. + @Deprecated('Use onReceivedLoginRequest instead') + void androidOnReceivedLoginRequest(LoginRequest loginRequest) {} + + ///Event fired when a request to automatically log in the user has been processed. + /// + ///[loginRequest] contains the realm, account and args of the login request. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewClient.onReceivedLoginRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedLoginRequest(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String))) + void onReceivedLoginRequest(LoginRequest loginRequest) {} + + ///Notify the host application that the given permission request has been canceled. Any related UI should therefore be hidden. + /// + ///[permissionRequest] represents the permission request that needs be canceled + ///with an array of resources the web content wants to access + ///and the origin of the web page which is trying to access the restricted resources. + /// + ///**NOTE for Android**: available only on Android 21+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onPermissionRequestCanceled](https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequestCanceled(android.webkit.PermissionRequest))) + void onPermissionRequestCanceled(PermissionRequest permissionRequest) {} + + ///Request display and focus for this WebView. + ///This may happen due to another WebView opening a link in this WebView and requesting that this WebView be displayed. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebChromeClient.onRequestFocus](https://developer.android.com/reference/android/webkit/WebChromeClient#onRequestFocus(android.webkit.WebView))) + void onRequestFocus() {} + + ///Use [onWebContentProcessDidTerminate] instead. + @Deprecated('Use onWebContentProcessDidTerminate instead') + void iosOnWebContentProcessDidTerminate() {} + + ///Invoked when the web view's web content process is terminated. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi)) + ///- MacOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi)) + void onWebContentProcessDidTerminate() {} + + ///Use [onDidReceiveServerRedirectForProvisionalNavigation] instead. + @Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead') + void iosOnDidReceiveServerRedirectForProvisionalNavigation() {} + + ///Called when a web view receives a server redirect. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview)) + ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview)) + void onDidReceiveServerRedirectForProvisionalNavigation() {} + + ///Use [onNavigationResponse] instead. + @Deprecated('Use onNavigationResponse instead') + Future? iosOnNavigationResponse( + IOSWKNavigationResponse navigationResponse) { + return null; + } + + ///Called when a web view asks for permission to navigate to new content after the response to the navigation request is known. + /// + ///[navigationResponse] represents the navigation response. + /// + ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnNavigationResponse] setting to `true`. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview)) + ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview)) + Future? onNavigationResponse( + NavigationResponse navigationResponse) { + return null; + } + + ///Use [shouldAllowDeprecatedTLS] instead. + @Deprecated('Use shouldAllowDeprecatedTLS instead') + Future? iosShouldAllowDeprecatedTLS( + URLAuthenticationChallenge challenge) { + return null; + } + + ///Called when a web view asks whether to continue with a connection that uses a deprecated version of TLS (v1.0 and v1.1). + /// + ///[challenge] represents the authentication challenge. + /// + ///**NOTE for iOS**: available only on iOS 14.0+. + /// + ///**NOTE for MacOS**: available only on MacOS 11.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview)) + ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview)) + Future? shouldAllowDeprecatedTLS( + URLAuthenticationChallenge challenge) { + return null; + } + + ///Event fired when a change in the camera capture state occurred. + /// + ///**NOTE for iOS**: available only on iOS 15.0+. + /// + ///**NOTE for MacOS**: available only on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + ///- MacOS + void onCameraCaptureStateChanged( + MediaCaptureState? oldState, + MediaCaptureState? newState, + ) {} + + ///Event fired when a change in the microphone capture state occurred. + ///Event fired when a change in the microphone capture state occurred. + /// + ///**NOTE for iOS**: available only on iOS 15.0+. + /// + ///**NOTE for MacOS**: available only on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + ///- MacOS + void onMicrophoneCaptureStateChanged( + MediaCaptureState? oldState, + MediaCaptureState? newState, + ) {} + + ///Event fired when the content size of the `WebView` changes. + /// + ///[oldContentSize] represents the old content size value. + /// + ///[newContentSize] represents the new content size value. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + void onContentSizeChanged(Size oldContentSize, Size newContentSize) {} +} \ No newline at end of file diff --git a/lib/src/in_app_localhost_server.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_localhost_server.dart similarity index 100% rename from lib/src/in_app_localhost_server.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_localhost_server.dart diff --git a/lib/src/in_app_webview/android/in_app_webview_options.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/android/in_app_webview_options.dart similarity index 99% rename from lib/src/in_app_webview/android/in_app_webview_options.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_webview/android/in_app_webview_options.dart index 18e4e958..044076ba 100755 --- a/lib/src/in_app_webview/android/in_app_webview_options.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/android/in_app_webview_options.dart @@ -4,7 +4,6 @@ import '../../util.dart'; import '../../types/main.dart'; import '../../in_app_browser/in_app_browser_settings.dart'; import '../in_app_webview_settings.dart'; -import '../webview.dart'; class AndroidOptions {} diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/android/main.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/android/main.dart new file mode 100644 index 00000000..da217a86 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/android/main.dart @@ -0,0 +1 @@ +export 'in_app_webview_options.dart'; diff --git a/lib/src/in_app_webview/apple/in_app_webview_options.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/apple/in_app_webview_options.dart similarity index 91% rename from lib/src/in_app_webview/apple/in_app_webview_options.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_webview/apple/in_app_webview_options.dart index 63a1caf7..da42cc02 100755 --- a/lib/src/in_app_webview/apple/in_app_webview_options.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/apple/in_app_webview_options.dart @@ -3,8 +3,7 @@ import '../../types/main.dart'; import '../../in_app_browser/in_app_browser_settings.dart'; import '../in_app_webview_settings.dart'; -import '../webview.dart'; -import '../in_app_webview_controller.dart'; +import '../platform_inappwebview_controller.dart'; class IosOptions {} @@ -156,36 +155,36 @@ class IOSInAppWebViewOptions ///Set to `true` to be able to listen to the [WebView.iosOnNavigationResponse] event. The default value is `false`. bool useOnNavigationResponse; - ///Set to `true` to enable Apple Pay API for the [WebView] at its first page load or on the next page load (using [InAppWebViewController.setOptions]). The default value is `false`. + ///Set to `true` to enable Apple Pay API for the `WebView` at its first page load or on the next page load (using [PlatformInAppWebViewController.setOptions]). The default value is `false`. /// ///**IMPORTANT NOTE**: As written in the official [Safari 13 Release Notes](https://developer.apple.com/documentation/safari-release-notes/safari-13-release-notes#Payment-Request-API), - ///it won't work if any script injection APIs are used (such as [InAppWebViewController.evaluateJavascript] or [UserScript]). + ///it won't work if any script injection APIs are used (such as [PlatformInAppWebViewController.evaluateJavascript] or [UserScript]). ///So, when this attribute is `true`, all the methods, options, and events implemented using JavaScript won't be called or won't do anything and the result will always be `null`. /// ///Methods affected: - ///- [InAppWebViewController.addUserScript] - ///- [InAppWebViewController.addUserScripts] - ///- [InAppWebViewController.removeUserScript] - ///- [InAppWebViewController.removeUserScripts] - ///- [InAppWebViewController.removeAllUserScripts] - ///- [InAppWebViewController.evaluateJavascript] - ///- [InAppWebViewController.callAsyncJavaScript] - ///- [InAppWebViewController.injectJavascriptFileFromUrl] - ///- [InAppWebViewController.injectJavascriptFileFromAsset] - ///- [InAppWebViewController.injectCSSCode] - ///- [InAppWebViewController.injectCSSFileFromUrl] - ///- [InAppWebViewController.injectCSSFileFromAsset] - ///- [InAppWebViewController.findAllAsync] - ///- [InAppWebViewController.findNext] - ///- [InAppWebViewController.clearMatches] - ///- [InAppWebViewController.pauseTimers] - ///- [InAppWebViewController.getSelectedText] - ///- [InAppWebViewController.getHitTestResult] - ///- [InAppWebViewController.requestFocusNodeHref] - ///- [InAppWebViewController.requestImageRef] - ///- [InAppWebViewController.postWebMessage] - ///- [InAppWebViewController.createWebMessageChannel] - ///- [InAppWebViewController.addWebMessageListener] + ///- [PlatformInAppWebViewController.addUserScript] + ///- [PlatformInAppWebViewController.addUserScripts] + ///- [PlatformInAppWebViewController.removeUserScript] + ///- [PlatformInAppWebViewController.removeUserScripts] + ///- [PlatformInAppWebViewController.removeAllUserScripts] + ///- [PlatformInAppWebViewController.evaluateJavascript] + ///- [PlatformInAppWebViewController.callAsyncJavaScript] + ///- [PlatformInAppWebViewController.injectJavascriptFileFromUrl] + ///- [PlatformInAppWebViewController.injectJavascriptFileFromAsset] + ///- [PlatformInAppWebViewController.injectCSSCode] + ///- [PlatformInAppWebViewController.injectCSSFileFromUrl] + ///- [PlatformInAppWebViewController.injectCSSFileFromAsset] + ///- [PlatformInAppWebViewController.findAllAsync] + ///- [PlatformInAppWebViewController.findNext] + ///- [PlatformInAppWebViewController.clearMatches] + ///- [PlatformInAppWebViewController.pauseTimers] + ///- [PlatformInAppWebViewController.getSelectedText] + ///- [PlatformInAppWebViewController.getHitTestResult] + ///- [PlatformInAppWebViewController.requestFocusNodeHref] + ///- [PlatformInAppWebViewController.requestImageRef] + ///- [PlatformInAppWebViewController.postWebMessage] + ///- [PlatformInAppWebViewController.createWebMessageChannel] + ///- [PlatformInAppWebViewController.addWebMessageListener] /// ///Options affected: ///- [WebView.initialUserScripts] diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/apple/main.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/apple/main.dart new file mode 100644 index 00000000..da217a86 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/apple/main.dart @@ -0,0 +1 @@ +export 'in_app_webview_options.dart'; diff --git a/lib/src/in_app_webview/in_app_webview_keep_alive.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_keep_alive.dart similarity index 64% rename from lib/src/in_app_webview/in_app_webview_keep_alive.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_keep_alive.dart index ccd752b1..e026022f 100644 --- a/lib/src/in_app_webview/in_app_webview_keep_alive.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_keep_alive.dart @@ -1,33 +1,33 @@ import '../types/main.dart'; import '../util.dart'; -import '../web_message/web_message_channel.dart'; -import '../web_message/web_message_listener.dart'; -import 'in_app_webview.dart'; -import 'in_app_webview_controller.dart'; +import '../web_message/platform_web_message_channel.dart'; +import '../web_message/platform_web_message_listener.dart'; +import 'platform_inappwebview_widget.dart'; +import 'platform_inappwebview_controller.dart'; -///Class used to keep alive a [InAppWebView]. +///Class used to keep alive a [PlatformInAppWebViewWidget]. class InAppWebViewKeepAlive { String _id = IdGenerator.generate(); } ///Used internally extension InternalInAppWebViewKeepAlive on InAppWebViewKeepAlive { + String get id => _id; + set id(String id) { _id = id; } - - String get id => _id; } -///Used internally to save and restore [InAppWebViewController] properties +///Used internally to save and restore [PlatformInAppWebViewController] properties ///for the keep alive feature. class InAppWebViewControllerKeepAliveProps { Map javaScriptHandlersMap; Map> userScripts; Set webMessageListenerObjNames; Map injectedScriptsFromURL; - Set webMessageChannels = Set(); - Set webMessageListeners = Set(); + Set webMessageChannels = Set(); + Set webMessageListeners = Set(); InAppWebViewControllerKeepAliveProps( {required this.javaScriptHandlersMap, diff --git a/lib/src/in_app_webview/in_app_webview_settings.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart similarity index 96% rename from lib/src/in_app_webview/in_app_webview_settings.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart index 74be44c0..dad28a65 100755 --- a/lib/src/in_app_webview/in_app_webview_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart @@ -1,10 +1,9 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; -import 'package:flutter_inappwebview/src/types/user_preferred_content_mode.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'dart:typed_data'; -import '../android/webview_asset_loader.dart'; +import '../platform_webview_asset_loader.dart'; import '../types/action_mode_menu_item.dart'; import '../types/cache_mode.dart'; import '../types/data_detector_types.dart'; @@ -20,6 +19,7 @@ import '../types/scrollbar_style.dart'; import '../types/scrollview_content_inset_adjustment_behavior.dart'; import '../types/scrollview_deceleration_rate.dart'; import '../types/selection_granularity.dart'; +import '../types/user_preferred_content_mode.dart'; import '../types/vertical_scrollbar_position.dart'; import '../web_uri.dart'; import 'android/in_app_webview_options.dart'; @@ -28,11 +28,10 @@ import '../content_blocker.dart'; import '../types/main.dart'; import '../util.dart'; import '../in_app_browser/in_app_browser_settings.dart'; -import 'webview.dart'; -import '../android/webview_feature.dart'; -import '../in_app_webview/in_app_webview_controller.dart'; +import '../platform_webview_feature.dart'; +import '../in_app_webview/platform_inappwebview_controller.dart'; import '../context_menu/context_menu.dart'; -import '../in_app_browser/in_app_browser.dart'; +import '../in_app_browser/platform_in_app_browser.dart'; part 'in_app_webview_settings.g.dart'; @@ -56,7 +55,7 @@ class InAppWebViewSettings_ { /// ///If the [WebView.shouldOverrideUrlLoading] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms( platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()]) bool? useShouldOverrideUrlLoading; @@ -65,7 +64,7 @@ class InAppWebViewSettings_ { /// ///If the [WebView.onLoadResource] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms( platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()]) bool? useOnLoadResource; @@ -74,7 +73,7 @@ class InAppWebViewSettings_ { /// ///If the [WebView.onDownloadStartRequest] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms( platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()]) bool? useOnDownloadStart; @@ -257,7 +256,7 @@ class InAppWebViewSettings_ { /// ///If the [WebView.shouldInterceptAjaxRequest] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms( platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()]) bool? useShouldInterceptAjaxRequest; @@ -266,7 +265,7 @@ class InAppWebViewSettings_ { /// ///If the [WebView.shouldInterceptFetchRequest] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms( platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()]) bool? useShouldInterceptFetchRequest; @@ -361,7 +360,7 @@ because there isn't any way to make the website data store non-persistent for th ///Set to `true` to allow audio playing when the app goes in background or the screen is locked or another app is opened. ///However, there will be no controls in the notification bar or on the lockscreen. - ///Also, make sure to not call [InAppWebViewController.pause], otherwise it will stop audio playing. + ///Also, make sure to not call [PlatformInAppWebViewController.pause], otherwise it will stop audio playing. ///The default value is `false`. /// ///**IMPORTANT NOTE**: if you use this setting, your app could be rejected by the Google Play Store. @@ -372,7 +371,7 @@ because there isn't any way to make the website data store non-persistent for th ///Use a [WebViewAssetLoader] instance to load local files including application's static assets and resources using http(s):// URLs. ///Loading local files using web-like URLs instead of `file://` is desirable as it is compatible with the Same-Origin policy. @SupportedPlatforms(platforms: [AndroidPlatform()]) - WebViewAssetLoader_? webViewAssetLoader; + PlatformWebViewAssetLoader? webViewAssetLoader; ///Sets the text zoom of the page in percent. The default value is `100`. @SupportedPlatforms(platforms: [ @@ -774,7 +773,7 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri /// ///If the [WebView.shouldInterceptRequest] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms(platforms: [AndroidPlatform()]) bool? useShouldInterceptRequest; @@ -782,7 +781,7 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri /// ///If the [WebView.onRenderProcessGone] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms(platforms: [AndroidPlatform()]) bool? useOnRenderProcessGone; @@ -963,7 +962,7 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri /// ///Apps can use this method to restore the legacy behavior for servers that still rely on the deprecated header, but it should not be used to identify the webview to first-party servers under the control of the app developer. /// - ///The format of the strings in the allow-list follows the origin rules of [InAppWebViewController.addWebMessageListener]. + ///The format of the strings in the allow-list follows the origin rules of [PlatformInAppWebViewController.addWebMessageListener]. @SupportedPlatforms(platforms: [ AndroidPlatform( apiName: "WebSettingsCompat.setRequestedWithHeaderOriginAllowList", @@ -1293,50 +1292,50 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri /// ///If the [WebView.onNavigationResponse] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms(platforms: [IOSPlatform(), MacOSPlatform()]) bool? useOnNavigationResponse; - ///Set to `true` to enable Apple Pay API for the [WebView] at its first page load or on the next page load (using [InAppWebViewController.setOptions]). The default value is `false`. + ///Set to `true` to enable Apple Pay API for the `WebView` at its first page load or on the next page load (using [PlatformInAppWebViewController.setOptions]). The default value is `false`. /// ///**IMPORTANT NOTE**: As written in the official [Safari 13 Release Notes](https://developer.apple.com/documentation/safari-release-notes/safari-13-release-notes#Payment-Request-API), - ///it won't work if any script injection APIs are used (such as [InAppWebViewController.evaluateJavascript] or [UserScript]). + ///it won't work if any script injection APIs are used (such as [PlatformInAppWebViewController.evaluateJavascript] or [UserScript]). ///So, when this attribute is `true`, all the methods, options, and events implemented using JavaScript won't be called or won't do anything and the result will always be `null`. /// ///Methods affected: - ///- [InAppWebViewController.addUserScript] - ///- [InAppWebViewController.addUserScripts] - ///- [InAppWebViewController.removeUserScript] - ///- [InAppWebViewController.removeUserScripts] - ///- [InAppWebViewController.removeAllUserScripts] - ///- [InAppWebViewController.evaluateJavascript] - ///- [InAppWebViewController.callAsyncJavaScript] - ///- [InAppWebViewController.injectJavascriptFileFromUrl] - ///- [InAppWebViewController.injectJavascriptFileFromAsset] - ///- [InAppWebViewController.injectCSSCode] - ///- [InAppWebViewController.injectCSSFileFromUrl] - ///- [InAppWebViewController.injectCSSFileFromAsset] - ///- [InAppWebViewController.findAllAsync] - ///- [InAppWebViewController.findNext] - ///- [InAppWebViewController.clearMatches] - ///- [InAppWebViewController.pauseTimers] - ///- [InAppWebViewController.getSelectedText] - ///- [InAppWebViewController.getHitTestResult] - ///- [InAppWebViewController.requestFocusNodeHref] - ///- [InAppWebViewController.requestImageRef] - ///- [InAppWebViewController.postWebMessage] - ///- [InAppWebViewController.createWebMessageChannel] - ///- [InAppWebViewController.addWebMessageListener] + ///- [PlatformInAppWebViewController.addUserScript] + ///- [PlatformInAppWebViewController.addUserScripts] + ///- [PlatformInAppWebViewController.removeUserScript] + ///- [PlatformInAppWebViewController.removeUserScripts] + ///- [PlatformInAppWebViewController.removeAllUserScripts] + ///- [PlatformInAppWebViewController.evaluateJavascript] + ///- [PlatformInAppWebViewController.callAsyncJavaScript] + ///- [PlatformInAppWebViewController.injectJavascriptFileFromUrl] + ///- [PlatformInAppWebViewController.injectJavascriptFileFromAsset] + ///- [PlatformInAppWebViewController.injectCSSCode] + ///- [PlatformInAppWebViewController.injectCSSFileFromUrl] + ///- [PlatformInAppWebViewController.injectCSSFileFromAsset] + ///- [PlatformInAppWebViewController.findAllAsync] + ///- [PlatformInAppWebViewController.findNext] + ///- [PlatformInAppWebViewController.clearMatches] + ///- [PlatformInAppWebViewController.pauseTimers] + ///- [PlatformInAppWebViewController.getSelectedText] + ///- [PlatformInAppWebViewController.getHitTestResult] + ///- [PlatformInAppWebViewController.requestFocusNodeHref] + ///- [PlatformInAppWebViewController.requestImageRef] + ///- [PlatformInAppWebViewController.postWebMessage] + ///- [PlatformInAppWebViewController.createWebMessageChannel] + ///- [PlatformInAppWebViewController.addWebMessageListener] /// ///Also, on MacOS: - ///- [InAppWebViewController.getScrollX] - ///- [InAppWebViewController.getScrollY] - ///- [InAppWebViewController.scrollTo] - ///- [InAppWebViewController.scrollBy] - ///- [InAppWebViewController.getContentHeight] - ///- [InAppWebViewController.getContentWidth] - ///- [InAppWebViewController.canScrollVertically] - ///- [InAppWebViewController.canScrollHorizontally] + ///- [PlatformInAppWebViewController.getScrollX] + ///- [PlatformInAppWebViewController.getScrollY] + ///- [PlatformInAppWebViewController.scrollTo] + ///- [PlatformInAppWebViewController.scrollBy] + ///- [PlatformInAppWebViewController.getContentHeight] + ///- [PlatformInAppWebViewController.getContentWidth] + ///- [PlatformInAppWebViewController.canScrollVertically] + ///- [PlatformInAppWebViewController.canScrollHorizontally] /// ///Settings affected: ///- [WebView.initialUserScripts] @@ -1767,7 +1766,7 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri } } -///Class that represents the options that can be used for a [WebView]. +///Class that represents the options that can be used for a `WebView`. ///Use [InAppWebViewSettings] instead. @Deprecated('Use InAppWebViewSettings instead') class InAppWebViewGroupOptions { diff --git a/lib/src/in_app_webview/in_app_webview_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart similarity index 96% rename from lib/src/in_app_webview/in_app_webview_settings.g.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart index b0fbad4f..5654f1b9 100644 --- a/lib/src/in_app_webview/in_app_webview_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart @@ -35,7 +35,7 @@ class InAppWebViewSettings { ///Set to `true` to allow audio playing when the app goes in background or the screen is locked or another app is opened. ///However, there will be no controls in the notification bar or on the lockscreen. - ///Also, make sure to not call [InAppWebViewController.pause], otherwise it will stop audio playing. + ///Also, make sure to not call [PlatformInAppWebViewController.pause], otherwise it will stop audio playing. ///The default value is `false`. /// ///**IMPORTANT NOTE**: if you use this setting, your app could be rejected by the Google Play Store. @@ -160,46 +160,46 @@ class InAppWebViewSettings { ///- Android native WebView (Official API - WebSettings.setAppCachePath) String? appCachePath; - ///Set to `true` to enable Apple Pay API for the [WebView] at its first page load or on the next page load (using [InAppWebViewController.setOptions]). The default value is `false`. + ///Set to `true` to enable Apple Pay API for the `WebView` at its first page load or on the next page load (using [PlatformInAppWebViewController.setOptions]). The default value is `false`. /// ///**IMPORTANT NOTE**: As written in the official [Safari 13 Release Notes](https://developer.apple.com/documentation/safari-release-notes/safari-13-release-notes#Payment-Request-API), - ///it won't work if any script injection APIs are used (such as [InAppWebViewController.evaluateJavascript] or [UserScript]). + ///it won't work if any script injection APIs are used (such as [PlatformInAppWebViewController.evaluateJavascript] or [UserScript]). ///So, when this attribute is `true`, all the methods, options, and events implemented using JavaScript won't be called or won't do anything and the result will always be `null`. /// ///Methods affected: - ///- [InAppWebViewController.addUserScript] - ///- [InAppWebViewController.addUserScripts] - ///- [InAppWebViewController.removeUserScript] - ///- [InAppWebViewController.removeUserScripts] - ///- [InAppWebViewController.removeAllUserScripts] - ///- [InAppWebViewController.evaluateJavascript] - ///- [InAppWebViewController.callAsyncJavaScript] - ///- [InAppWebViewController.injectJavascriptFileFromUrl] - ///- [InAppWebViewController.injectJavascriptFileFromAsset] - ///- [InAppWebViewController.injectCSSCode] - ///- [InAppWebViewController.injectCSSFileFromUrl] - ///- [InAppWebViewController.injectCSSFileFromAsset] - ///- [InAppWebViewController.findAllAsync] - ///- [InAppWebViewController.findNext] - ///- [InAppWebViewController.clearMatches] - ///- [InAppWebViewController.pauseTimers] - ///- [InAppWebViewController.getSelectedText] - ///- [InAppWebViewController.getHitTestResult] - ///- [InAppWebViewController.requestFocusNodeHref] - ///- [InAppWebViewController.requestImageRef] - ///- [InAppWebViewController.postWebMessage] - ///- [InAppWebViewController.createWebMessageChannel] - ///- [InAppWebViewController.addWebMessageListener] + ///- [PlatformInAppWebViewController.addUserScript] + ///- [PlatformInAppWebViewController.addUserScripts] + ///- [PlatformInAppWebViewController.removeUserScript] + ///- [PlatformInAppWebViewController.removeUserScripts] + ///- [PlatformInAppWebViewController.removeAllUserScripts] + ///- [PlatformInAppWebViewController.evaluateJavascript] + ///- [PlatformInAppWebViewController.callAsyncJavaScript] + ///- [PlatformInAppWebViewController.injectJavascriptFileFromUrl] + ///- [PlatformInAppWebViewController.injectJavascriptFileFromAsset] + ///- [PlatformInAppWebViewController.injectCSSCode] + ///- [PlatformInAppWebViewController.injectCSSFileFromUrl] + ///- [PlatformInAppWebViewController.injectCSSFileFromAsset] + ///- [PlatformInAppWebViewController.findAllAsync] + ///- [PlatformInAppWebViewController.findNext] + ///- [PlatformInAppWebViewController.clearMatches] + ///- [PlatformInAppWebViewController.pauseTimers] + ///- [PlatformInAppWebViewController.getSelectedText] + ///- [PlatformInAppWebViewController.getHitTestResult] + ///- [PlatformInAppWebViewController.requestFocusNodeHref] + ///- [PlatformInAppWebViewController.requestImageRef] + ///- [PlatformInAppWebViewController.postWebMessage] + ///- [PlatformInAppWebViewController.createWebMessageChannel] + ///- [PlatformInAppWebViewController.addWebMessageListener] /// ///Also, on MacOS: - ///- [InAppWebViewController.getScrollX] - ///- [InAppWebViewController.getScrollY] - ///- [InAppWebViewController.scrollTo] - ///- [InAppWebViewController.scrollBy] - ///- [InAppWebViewController.getContentHeight] - ///- [InAppWebViewController.getContentWidth] - ///- [InAppWebViewController.canScrollVertically] - ///- [InAppWebViewController.canScrollHorizontally] + ///- [PlatformInAppWebViewController.getScrollX] + ///- [PlatformInAppWebViewController.getScrollY] + ///- [PlatformInAppWebViewController.scrollTo] + ///- [PlatformInAppWebViewController.scrollBy] + ///- [PlatformInAppWebViewController.getContentHeight] + ///- [PlatformInAppWebViewController.getContentWidth] + ///- [PlatformInAppWebViewController.canScrollVertically] + ///- [PlatformInAppWebViewController.canScrollHorizontally] /// ///Settings affected: ///- [WebView.initialUserScripts] @@ -843,7 +843,7 @@ class InAppWebViewSettings { /// ///Apps can use this method to restore the legacy behavior for servers that still rely on the deprecated header, but it should not be used to identify the webview to first-party servers under the control of the app developer. /// - ///The format of the strings in the allow-list follows the origin rules of [InAppWebViewController.addWebMessageListener]. + ///The format of the strings in the allow-list follows the origin rules of [PlatformInAppWebViewController.addWebMessageListener]. /// ///**NOTE for Android native WebView**: available on Android only if [WebViewFeature.REQUESTED_WITH_HEADER_ALLOW_LIST] feature is supported. /// @@ -1032,7 +1032,7 @@ class InAppWebViewSettings { /// ///If the [WebView.onDownloadStartRequest] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -1044,7 +1044,7 @@ class InAppWebViewSettings { /// ///If the [WebView.onLoadResource] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -1056,7 +1056,7 @@ class InAppWebViewSettings { /// ///If the [WebView.onNavigationResponse] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- iOS @@ -1067,7 +1067,7 @@ class InAppWebViewSettings { /// ///If the [WebView.onRenderProcessGone] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -1077,7 +1077,7 @@ class InAppWebViewSettings { /// ///If the [WebView.shouldInterceptAjaxRequest] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -1089,7 +1089,7 @@ class InAppWebViewSettings { /// ///If the [WebView.shouldInterceptFetchRequest] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -1101,7 +1101,7 @@ class InAppWebViewSettings { /// ///If the [WebView.shouldInterceptRequest] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -1111,7 +1111,7 @@ class InAppWebViewSettings { /// ///If the [WebView.shouldOverrideUrlLoading] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. - ///This logic will not be applied for [InAppBrowser], where you must set the value manually. + ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -1170,7 +1170,7 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - WebViewAssetLoader? webViewAssetLoader; + PlatformWebViewAssetLoader? webViewAssetLoader; InAppWebViewSettings( {this.useShouldOverrideUrlLoading, this.useOnLoadResource, @@ -1404,8 +1404,7 @@ class InAppWebViewSettings { ? UtilColor.fromStringRepresentation( map['verticalScrollbarTrackColor']) : null, - webViewAssetLoader: WebViewAssetLoader.fromMap( - map['webViewAssetLoader']?.cast()), + webViewAssetLoader: map['webViewAssetLoader'], ); instance.accessibilityIgnoresInvertColors = map['accessibilityIgnoresInvertColors']; @@ -1687,7 +1686,7 @@ class InAppWebViewSettings { "verticalScrollbarPosition": verticalScrollbarPosition?.toNativeValue(), "verticalScrollbarThumbColor": verticalScrollbarThumbColor?.toHex(), "verticalScrollbarTrackColor": verticalScrollbarTrackColor?.toHex(), - "webViewAssetLoader": webViewAssetLoader?.toMap(), + "webViewAssetLoader": webViewAssetLoader, }; } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/main.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/main.dart new file mode 100644 index 00000000..2461129b --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/main.dart @@ -0,0 +1,11 @@ +export 'platform_inappwebview_controller.dart'; +export 'platform_inappwebview_widget.dart'; +export 'platform_webview.dart'; +export 'in_app_webview_settings.dart' + show + InAppWebViewSettings, + InAppWebViewGroupOptions, + WebViewOptions, + InAppWebViewOptions; +export 'platform_headless_in_app_webview.dart'; +export 'in_app_webview_keep_alive.dart'; diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.dart new file mode 100644 index 00000000..dda312c9 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.dart @@ -0,0 +1,265 @@ +import 'dart:ui'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +import '../inappwebview_platform.dart'; +import '../types/disposable.dart'; +import 'platform_inappwebview_controller.dart'; +import 'platform_webview.dart'; + +/// Object specifying creation parameters for creating a [PlatformInAppWebViewWidget]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +class PlatformHeadlessInAppWebViewCreationParams + extends PlatformWebViewCreationParams { + /// Used by the platform implementation to create a new [PlatformHeadlessInAppWebView]. + const PlatformHeadlessInAppWebViewCreationParams( + {this.initialSize = const Size(-1, -1), + super.windowId, + super.onWebViewCreated, + super.onLoadStart, + super.onLoadStop, + @Deprecated('Use onReceivedError instead') super.onLoadError, + super.onReceivedError, + @Deprecated("Use onReceivedHttpError instead") super.onLoadHttpError, + super.onReceivedHttpError, + super.onProgressChanged, + super.onConsoleMessage, + super.shouldOverrideUrlLoading, + super.onLoadResource, + super.onScrollChanged, + @Deprecated('Use onDownloadStartRequest instead') super.onDownloadStart, + super.onDownloadStartRequest, + @Deprecated('Use onLoadResourceWithCustomScheme instead') + super.onLoadResourceCustomScheme, + super.onLoadResourceWithCustomScheme, + super.onCreateWindow, + super.onCloseWindow, + super.onJsAlert, + super.onJsConfirm, + super.onJsPrompt, + super.onReceivedHttpAuthRequest, + super.onReceivedServerTrustAuthRequest, + super.onReceivedClientCertRequest, + @Deprecated('Use FindInteractionController.onFindResultReceived instead') + super.onFindResultReceived, + super.shouldInterceptAjaxRequest, + super.onAjaxReadyStateChange, + super.onAjaxProgress, + super.shouldInterceptFetchRequest, + super.onUpdateVisitedHistory, + @Deprecated("Use onPrintRequest instead") super.onPrint, + super.onPrintRequest, + super.onLongPressHitTestResult, + super.onEnterFullscreen, + super.onExitFullscreen, + super.onPageCommitVisible, + super.onTitleChanged, + super.onWindowFocus, + super.onWindowBlur, + super.onOverScrolled, + super.onZoomScaleChanged, + @Deprecated('Use onSafeBrowsingHit instead') + super.androidOnSafeBrowsingHit, + super.onSafeBrowsingHit, + @Deprecated('Use onPermissionRequest instead') + super.androidOnPermissionRequest, + super.onPermissionRequest, + @Deprecated('Use onGeolocationPermissionsShowPrompt instead') + super.androidOnGeolocationPermissionsShowPrompt, + super.onGeolocationPermissionsShowPrompt, + @Deprecated('Use onGeolocationPermissionsHidePrompt instead') + super.androidOnGeolocationPermissionsHidePrompt, + super.onGeolocationPermissionsHidePrompt, + @Deprecated('Use shouldInterceptRequest instead') + super.androidShouldInterceptRequest, + super.shouldInterceptRequest, + @Deprecated('Use onRenderProcessGone instead') + super.androidOnRenderProcessGone, + super.onRenderProcessGone, + @Deprecated('Use onRenderProcessResponsive instead') + super.androidOnRenderProcessResponsive, + super.onRenderProcessResponsive, + @Deprecated('Use onRenderProcessUnresponsive instead') + super.androidOnRenderProcessUnresponsive, + super.onRenderProcessUnresponsive, + @Deprecated('Use onFormResubmission instead') + super.androidOnFormResubmission, + super.onFormResubmission, + @Deprecated('Use onZoomScaleChanged instead') super.androidOnScaleChanged, + @Deprecated('Use onReceivedIcon instead') super.androidOnReceivedIcon, + super.onReceivedIcon, + @Deprecated('Use onReceivedTouchIconUrl instead') + super.androidOnReceivedTouchIconUrl, + super.onReceivedTouchIconUrl, + @Deprecated('Use onJsBeforeUnload instead') super.androidOnJsBeforeUnload, + super.onJsBeforeUnload, + @Deprecated('Use onReceivedLoginRequest instead') + super.androidOnReceivedLoginRequest, + super.onReceivedLoginRequest, + super.onPermissionRequestCanceled, + super.onRequestFocus, + @Deprecated('Use onWebContentProcessDidTerminate instead') + super.iosOnWebContentProcessDidTerminate, + super.onWebContentProcessDidTerminate, + @Deprecated( + 'Use onDidReceiveServerRedirectForProvisionalNavigation instead') + super.iosOnDidReceiveServerRedirectForProvisionalNavigation, + super.onDidReceiveServerRedirectForProvisionalNavigation, + @Deprecated('Use onNavigationResponse instead') + super.iosOnNavigationResponse, + super.onNavigationResponse, + @Deprecated('Use shouldAllowDeprecatedTLS instead') + super.iosShouldAllowDeprecatedTLS, + super.shouldAllowDeprecatedTLS, + super.onCameraCaptureStateChanged, + super.onMicrophoneCaptureStateChanged, + super.onContentSizeChanged, + super.initialUrlRequest, + super.initialFile, + super.initialData, + @Deprecated('Use initialSettings instead') super.initialOptions, + super.initialSettings, + super.contextMenu, + super.initialUserScripts, + super.pullToRefreshController, + super.findInteractionController}); + + ///The WebView initial size in pixels. + /// + ///Set `-1` to match the corresponding width or height of the current device screen size. + ///`Size(-1, -1)` will match both width and height of the current device screen size. + /// + ///**NOTE for Android**: `Size` width and height values will be converted to `int` values because they cannot have `double` values. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + ///- MacOS + final Size initialSize; +} + +///{@template flutter_inappwebview.HeadlessInAppWebView} +///Class that represents a WebView in headless mode. +///It can be used to run a WebView in background without attaching an `InAppWebView` to the widget tree. +/// +///**NOTE**: Remember to dispose it when you don't need it anymore. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- Web +///- MacOS +///{@endtemplate} +abstract class PlatformHeadlessInAppWebView extends PlatformInterface implements Disposable { + /// Creates a new [PlatformHeadlessInAppWebView] + factory PlatformHeadlessInAppWebView( + PlatformHeadlessInAppWebViewCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformHeadlessInAppWebView webViewControllerDelegate = + InAppWebViewPlatform.instance!.createPlatformHeadlessInAppWebView(params); + PlatformInterface.verify(webViewControllerDelegate, _token); + return webViewControllerDelegate; + } + + /// Used by the platform implementation to create a new [PlatformHeadlessInAppWebView]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformHeadlessInAppWebView.implementation(this.params) : super(token: _token); + + static final Object _token = Object(); + + /// The parameters used to initialize the [PlatformHeadlessInAppWebView]. + final PlatformHeadlessInAppWebViewCreationParams params; + + ///WebView Controller that can be used to access the [InAppWebViewController] API. + PlatformInAppWebViewController? get webViewController => throw UnimplementedError( + 'webViewController is not implemented on the current platform'); + + ///View ID. + String get id => throw UnimplementedError( + 'id is not implemented on the current platform'); + + ///Runs the headless WebView. + /// + ///**NOTE for Web**: it will append a new `iframe` to the body. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + ///- MacOS + Future run() { + throw UnimplementedError( + 'run is not implemented on the current platform'); + } + + ///Indicates if the headless WebView is running or not. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + ///- MacOS + bool isRunning() { + throw UnimplementedError( + 'isRunning is not implemented on the current platform'); + } + + ///Set the size of the WebView in pixels. + /// + ///Set `-1` to match the corresponding width or height of the current device screen size. + ///`Size(-1, -1)` will match both width and height of the current device screen size. + /// + ///Note that if the [PlatformHeadlessInAppWebView] is not running, this method won't have effect. + /// + ///**NOTE for Android**: `Size` width and height values will be converted to `int` values because they cannot have `double` values. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + ///- MacOS + Future setSize(Size size) { + throw UnimplementedError( + 'setSize is not implemented on the current platform'); + } + + ///Gets the current size in pixels of the WebView. + /// + ///Note that if the [PlatformHeadlessInAppWebView] is not running, this method will return `null`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + ///- MacOS + Future getSize() { + throw UnimplementedError( + 'getSize is not implemented on the current platform'); + } + + ///Disposes the headless WebView. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + ///- MacOS + Future dispose() { + throw UnimplementedError( + 'dispose is not implemented on the current platform'); + } +} + diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart new file mode 100644 index 00000000..993d294d --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart @@ -0,0 +1,2086 @@ +import 'dart:convert'; +import 'dart:core'; +import 'dart:typed_data'; +import 'dart:ui'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import '../context_menu/main.dart'; +import '../debug_logging_settings.dart'; +import '../inappwebview_platform.dart'; +import '../web_message/main.dart'; +import '../web_storage/platform_web_storage.dart'; +import '../web_uri.dart'; + +import '../types/main.dart'; +import '../in_app_browser/platform_in_app_browser.dart'; +import 'platform_headless_in_app_webview.dart'; +import 'platform_inappwebview_widget.dart'; +import '../platform_webview_feature.dart'; + +import 'platform_webview.dart'; +import 'in_app_webview_keep_alive.dart'; +import 'in_app_webview_settings.dart'; + +import '../print_job/main.dart'; + +/// Object specifying creation parameters for creating a [PlatformInAppWebViewController]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformInAppWebViewControllerCreationParams { + /// Used by the platform implementation to create a new [PlatformInAppWebViewController]. + const PlatformInAppWebViewControllerCreationParams( + {required this.id, this.webviewParams}); + + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.id} + final dynamic id; + + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.webviewParams} + final PlatformWebViewCreationParams? webviewParams; +} + +///Controls a WebView, such as an [InAppWebView] widget instance, a [HeadlessInAppWebView] instance or [PlatformInAppBrowser] WebView instance. +/// +///If you are using the [InAppWebView] widget, an [PlatformInAppWebViewController] instance can be obtained by setting the [InAppWebView.onWebViewCreated] +///callback. Instead, if you are using an [PlatformInAppBrowser] instance, you can get it through the [PlatformInAppBrowser.webViewController] attribute. +abstract class PlatformInAppWebViewController extends PlatformInterface implements Disposable { + ///Debug settings used by [PlatformInAppWebViewWidget], [PlatformHeadlessInAppWebView] and [PlatformInAppBrowser]. + ///The default value excludes the [WebView.onScrollChanged], [WebView.onOverScrolled] and [WebView.onReceivedIcon] events. + static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings( + maxLogMessageLength: 1000, + excludeFilter: [ + RegExp(r"onScrollChanged"), + RegExp(r"onOverScrolled"), + RegExp(r"onReceivedIcon") + ]); + + /// Creates a new [PlatformInAppWebViewController] + factory PlatformInAppWebViewController( + PlatformInAppWebViewControllerCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformInAppWebViewController inAppWebViewController = + InAppWebViewPlatform.instance! + .createPlatformInAppWebViewController(params); + PlatformInterface.verify(inAppWebViewController, _token); + return inAppWebViewController; + } + + /// Creates a new [PlatformInAppWebViewController] to access static methods. + factory PlatformInAppWebViewController.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformInAppWebViewController inAppWebViewControllerStatic = + InAppWebViewPlatform.instance!.createPlatformInAppWebViewControllerStatic(); + PlatformInterface.verify(inAppWebViewControllerStatic, _token); + return inAppWebViewControllerStatic; + } + + /// Used by the platform implementation to create a new [PlatformInAppWebViewController]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformInAppWebViewController.implementation(this.params) + : super(token: _token); + + static final Object _token = Object(); + + /// The parameters used to initialize the [PlatformInAppWebViewController]. + final PlatformInAppWebViewControllerCreationParams params; + + ///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.id} + /// WebView ID. + ///@{endtemplate} + dynamic get id => params.id; + + ///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.webviewParams} + /// WebView params. + ///@{endtemplate} + PlatformWebViewCreationParams? get webviewParams => params.webviewParams; + + ///Provides access to the JavaScript [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API): `window.sessionStorage` and `window.localStorage`. + PlatformWebStorage get webStorage => throw UnimplementedError( + 'webStorage is not implemented on the current platform'); + + ///Gets the URL for the current page. + ///This is not always the same as the URL passed to [WebView.onLoadStart] because although the load for that URL has begun, the current page may not have changed. + /// + ///**NOTE for Web**: If `window.location.href` isn't accessible inside the iframe, + ///it will return the current value of the `iframe.src` attribute. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getUrl](https://developer.android.com/reference/android/webkit/WebView#getUrl())) + ///- iOS ([Official API - WKWebView.url](https://developer.apple.com/documentation/webkit/wkwebview/1415005-url)) + ///- MacOS ([Official API - WKWebView.url](https://developer.apple.com/documentation/webkit/wkwebview/1415005-url)) + ///- Web + Future getUrl() { + throw UnimplementedError( + 'getUrl is not implemented on the current platform'); + } + + ///Gets the title for the current page. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getTitle](https://developer.android.com/reference/android/webkit/WebView#getTitle())) + ///- iOS ([Official API - WKWebView.title](https://developer.apple.com/documentation/webkit/wkwebview/1415015-title)) + ///- MacOS ([Official API - WKWebView.title](https://developer.apple.com/documentation/webkit/wkwebview/1415015-title)) + ///- Web + Future getTitle() { + throw UnimplementedError( + 'getTitle is not implemented on the current platform'); + } + + ///Gets the progress for the current page. The progress value is between 0 and 100. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getProgress](https://developer.android.com/reference/android/webkit/WebView#getProgress())) + ///- iOS ([Official API - WKWebView.estimatedProgress](https://developer.apple.com/documentation/webkit/wkwebview/1415007-estimatedprogress)) + ///- MacOS ([Official API - WKWebView.estimatedProgress](https://developer.apple.com/documentation/webkit/wkwebview/1415007-estimatedprogress)) + Future getProgress() { + throw UnimplementedError( + 'getProgress is not implemented on the current platform'); + } + + ///Gets the content html of the page. It first tries to get the content through javascript. + ///If this doesn't work, it tries to get the content reading the file: + ///- checking if it is an asset (`file:///`) or + ///- downloading it using an `HttpClient` through the WebView's current url. + /// + ///Returns `null` if it was unable to get it. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future getHtml() { + throw UnimplementedError( + 'getHtml is not implemented on the current platform'); + } + + ///Gets the list of all favicons for the current page. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future> getFavicons() { + throw UnimplementedError( + 'getFavicons is not implemented on the current platform'); + } + + ///Loads the given [urlRequest]. + /// + ///- [allowingReadAccessTo], used in combination with [urlRequest] (using the `file://` scheme), + ///it represents the URL from which to read the web content. + ///This URL must be a file-based URL (using the `file://` scheme). + ///Specify the same value as the URL parameter to prevent WebView from reading any other content. + ///Specify a directory to give WebView permission to read additional files in the specified directory. + ///**NOTE**: available only on iOS and MacOS. + /// + ///**NOTE for Android**: when loading an URL Request using "POST" method, headers are ignored. + /// + ///**NOTE for Web**: if method is "GET" and headers are empty, it will change the `src` of the iframe. + ///For all other cases it will try to create an XMLHttpRequest and load the result inside the iframe. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.loadUrl](https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String))). If method is "POST", [Official API - WebView.postUrl](https://developer.android.com/reference/android/webkit/WebView#postUrl(java.lang.String,%20byte[])) + ///- iOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load). If [allowingReadAccessTo] is used, [Official API - WKWebView.loadFileURL](https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl)) + ///- MacOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load). If [allowingReadAccessTo] is used, [Official API - WKWebView.loadFileURL](https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl)) + ///- Web + Future loadUrl( + {required URLRequest urlRequest, + @Deprecated('Use allowingReadAccessTo instead') + Uri? iosAllowingReadAccessTo, + WebUri? allowingReadAccessTo}) { + throw UnimplementedError( + 'loadUrl is not implemented on the current platform'); + } + + ///Loads the given [url] with [postData] (x-www-form-urlencoded) using `POST` method into this WebView. + /// + ///Example: + ///```dart + ///var postData = Uint8List.fromList(utf8.encode("firstname=Foo&surname=Bar")); + ///controller.postUrl(url: WebUri("https://www.example.com/"), postData: postData); + ///``` + /// + ///**NOTE for Web**: it will try to create an XMLHttpRequest and load the result inside the iframe. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.postUrl](https://developer.android.com/reference/android/webkit/WebView#postUrl(java.lang.String,%20byte[]))) + ///- iOS + ///- MacOS + ///- Web + Future postUrl({required WebUri url, required Uint8List postData}) { + throw UnimplementedError( + 'postUrl is not implemented on the current platform'); + } + + ///Loads the given [data] into this WebView, using [baseUrl] as the base URL for the content. + /// + ///- [mimeType] argument specifies the format of the data. The default value is `"text/html"`. + ///- [encoding] argument specifies the encoding of the data. The default value is `"utf8"`. + ///**NOTE**: not used on Web. + ///- [historyUrl] is an Android-specific argument that represents the URL to use as the history entry. The default value is `about:blank`. If non-null, this must be a valid URL. + ///**NOTE**: not used on Web. + ///- [allowingReadAccessTo], used in combination with [baseUrl] (using the `file://` scheme), + ///it represents the URL from which to read the web content. + ///This [baseUrl] must be a file-based URL (using the `file://` scheme). + ///Specify the same value as the [baseUrl] parameter to prevent WebView from reading any other content. + ///Specify a directory to give WebView permission to read additional files in the specified directory. + ///**NOTE**: available only on iOS and MacOS. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.loadDataWithBaseURL](https://developer.android.com/reference/android/webkit/WebView#loadDataWithBaseURL(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String))) + ///- iOS ([Official API - WKWebView.loadHTMLString](https://developer.apple.com/documentation/webkit/wkwebview/1415004-loadhtmlstring) or [Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1415011-load)) + ///- MacOS ([Official API - WKWebView.loadHTMLString](https://developer.apple.com/documentation/webkit/wkwebview/1415004-loadhtmlstring) or [Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1415011-load)) + ///- Web + Future loadData( + {required String data, + String mimeType = "text/html", + String encoding = "utf8", + WebUri? baseUrl, + @Deprecated('Use historyUrl instead') Uri? androidHistoryUrl, + WebUri? historyUrl, + @Deprecated('Use allowingReadAccessTo instead') + Uri? iosAllowingReadAccessTo, + WebUri? allowingReadAccessTo}) { + throw UnimplementedError( + 'loadData is not implemented on the current platform'); + } + + ///Loads the given [assetFilePath]. + /// + ///To be able to load your local files (assets, js, css, etc.), you need to add them in the `assets` section of the `pubspec.yaml` file, otherwise they cannot be found! + /// + ///Example of a `pubspec.yaml` file: + ///```yaml + ///... + /// + ///# The following section is specific to Flutter. + ///flutter: + /// + /// # The following line ensures that the Material Icons font is + /// # included with your application, so that you can use the icons in + /// # the material Icons class. + /// uses-material-design: true + /// + /// assets: + /// - assets/index.html + /// - assets/css/ + /// - assets/images/ + /// + ///... + ///``` + ///Example: + ///```dart + ///... + ///controller.loadFile(assetFilePath: "assets/index.html"); + ///... + ///``` + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.loadUrl](https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String))) + ///- iOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load)) + ///- MacOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load)) + ///- Web + Future loadFile({required String assetFilePath}) { + throw UnimplementedError( + 'loadFile is not implemented on the current platform'); + } + + ///Reloads the WebView. + /// + ///**NOTE for Web**: if `window.location.reload()` is not accessible inside the iframe, it will reload using the iframe `src` attribute. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.reload](https://developer.android.com/reference/android/webkit/WebView#reload())) + ///- iOS ([Official API - WKWebView.reload](https://developer.apple.com/documentation/webkit/wkwebview/1414969-reload)) + ///- MacOS ([Official API - WKWebView.reload](https://developer.apple.com/documentation/webkit/wkwebview/1414969-reload)) + ///- Web ([Official API - Location.reload](https://developer.mozilla.org/en-US/docs/Web/API/Location/reload)) + Future reload() { + throw UnimplementedError( + 'reload is not implemented on the current platform'); + } + + ///Goes back in the history of the WebView. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.goBack](https://developer.android.com/reference/android/webkit/WebView#goBack())) + ///- iOS ([Official API - WKWebView.goBack](https://developer.apple.com/documentation/webkit/wkwebview/1414952-goback)) + ///- MacOS ([Official API - WKWebView.goBack](https://developer.apple.com/documentation/webkit/wkwebview/1414952-goback)) + ///- Web ([Official API - History.back](https://developer.mozilla.org/en-US/docs/Web/API/History/back)) + Future goBack() { + throw UnimplementedError( + 'goBack is not implemented on the current platform'); + } + + ///Returns a boolean value indicating whether the WebView can move backward. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.canGoBack](https://developer.android.com/reference/android/webkit/WebView#canGoBack())) + ///- iOS ([Official API - WKWebView.canGoBack](https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback)) + ///- MacOS ([Official API - WKWebView.canGoBack](https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback)) + Future canGoBack() { + throw UnimplementedError( + 'canGoBack is not implemented on the current platform'); + } + + ///Goes forward in the history of the WebView. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.goForward](https://developer.android.com/reference/android/webkit/WebView#goForward())) + ///- iOS ([Official API - WKWebView.goForward](https://developer.apple.com/documentation/webkit/wkwebview/1414993-goforward)) + ///- MacOS ([Official API - WKWebView.goForward](https://developer.apple.com/documentation/webkit/wkwebview/1414993-goforward)) + ///- Web ([Official API - History.forward](https://developer.mozilla.org/en-US/docs/Web/API/History/forward)) + Future goForward() { + throw UnimplementedError( + 'goForward is not implemented on the current platform'); + } + + ///Returns a boolean value indicating whether the WebView can move forward. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.canGoForward](https://developer.android.com/reference/android/webkit/WebView#canGoForward())) + ///- iOS ([Official API - WKWebView.canGoForward](https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward)) + ///- MacOS ([Official API - WKWebView.canGoForward](https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward)) + Future canGoForward() { + throw UnimplementedError( + 'canGoForward is not implemented on the current platform'); + } + + ///Goes to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.goBackOrForward](https://developer.android.com/reference/android/webkit/WebView#goBackOrForward(int))) + ///- iOS ([Official API - WKWebView.go](https://developer.apple.com/documentation/webkit/wkwebview/1414991-go)) + ///- MacOS ([Official API - WKWebView.go](https://developer.apple.com/documentation/webkit/wkwebview/1414991-go)) + ///- Web ([Official API - History.go](https://developer.mozilla.org/en-US/docs/Web/API/History/go)) + Future goBackOrForward({required int steps}) { + throw UnimplementedError( + 'goBackOrForward is not implemented on the current platform'); + } + + ///Returns a boolean value indicating whether the WebView can go back or forward the given number of steps. Steps is negative if backward and positive if forward. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.canGoBackOrForward](https://developer.android.com/reference/android/webkit/WebView#canGoBackOrForward(int))) + ///- iOS + ///- MacOS + Future canGoBackOrForward({required int steps}) { + throw UnimplementedError( + 'canGoBackOrForward is not implemented on the current platform'); + } + + ///Navigates to a [WebHistoryItem] from the back-forward [WebHistory.list] and sets it as the current item. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future goTo({required WebHistoryItem historyItem}) { + throw UnimplementedError('goTo is not implemented on the current platform'); + } + + ///Check if the WebView instance is in a loading state. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future isLoading() { + throw UnimplementedError( + 'isLoading is not implemented on the current platform'); + } + + ///Stops the WebView from loading. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.stopLoading](https://developer.android.com/reference/android/webkit/WebView#stopLoading())) + ///- iOS ([Official API - WKWebView.stopLoading](https://developer.apple.com/documentation/webkit/wkwebview/1414981-stoploading)) + ///- MacOS ([Official API - WKWebView.stopLoading](https://developer.apple.com/documentation/webkit/wkwebview/1414981-stoploading)) + ///- Web ([Official API - Window.stop](https://developer.mozilla.org/en-US/docs/Web/API/Window/stop)) + Future stopLoading() { + throw UnimplementedError( + 'stopLoading is not implemented on the current platform'); + } + + ///Evaluates JavaScript [source] code into the WebView and returns the result of the evaluation. + /// + ///[contentWorld], on iOS, it represents the namespace in which to evaluate the JavaScript [source] code. + ///Instead, on Android, it will run the [source] code into an iframe, using `eval(source);` to get and return the result. + ///This parameter doesn’t apply to changes you make to the underlying web content, such as the document’s DOM structure. + ///Those changes remain visible to all scripts, regardless of which content world you specify. + ///For more information about content worlds, see [ContentWorld]. + ///Available on iOS 14.0+ and MacOS 11.0+. + ///**NOTE**: not used on Web. + /// + ///**NOTE**: This method shouldn't be called in the [WebView.onWebViewCreated] or [WebView.onLoadStart] events, + ///because, in these events, the `WebView` is not ready to handle it yet. + ///Instead, you should call this method, for example, inside the [WebView.onLoadStop] event or in any other events + ///where you know the page is ready "enough". + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.evaluateJavascript](https://developer.android.com/reference/android/webkit/WebView#evaluateJavascript(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.String%3E))) + ///- iOS ([Official API - WKWebView.evaluateJavascript](https://developer.apple.com/documentation/webkit/wkwebview/3656442-evaluatejavascript)) + ///- MacOS ([Official API - WKWebView.evaluateJavascript](https://developer.apple.com/documentation/webkit/wkwebview/3656442-evaluatejavascript)) + ///- Web ([Official API - Window.eval](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval?retiredLocale=it)) + Future evaluateJavascript( + {required String source, ContentWorld? contentWorld}) { + throw UnimplementedError( + 'evaluateJavascript is not implemented on the current platform'); + } + + ///Injects an external JavaScript file into the WebView from a defined url. + /// + ///[scriptHtmlTagAttributes] represents the possible the ` + ///``` + /// + ///Instead, on the `onLoadStop` WebView event, you can use `callHandler` directly: + ///```dart + /// // Inject JavaScript that will receive data back from Flutter + /// inAppWebViewController.evaluateJavascript(source: """ + /// window.flutter_inappwebview.callHandler('test', 'Text from Javascript').then(function(result) { + /// console.log(result); + /// }); + /// """); + ///``` + /// + ///Forbidden names for JavaScript handlers are defined in [_JAVASCRIPT_HANDLER_FORBIDDEN_NAMES]. + /// + ///**NOTE**: This method should be called, for example, in the [WebView.onWebViewCreated] or [WebView.onLoadStart] events or, at least, + ///before you know that your JavaScript code will call the `window.flutter_inappwebview.callHandler` method, + ///otherwise you won't be able to intercept the JavaScript message. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + void addJavaScriptHandler( + {required String handlerName, + required JavaScriptHandlerCallback callback}) { + throw UnimplementedError( + 'addJavaScriptHandler is not implemented on the current platform'); + } + + ///Removes a JavaScript message handler previously added with the [addJavaScriptHandler] associated to [handlerName] key. + ///Returns the value associated with [handlerName] before it was removed. + ///Returns `null` if [handlerName] was not found. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + JavaScriptHandlerCallback? removeJavaScriptHandler( + {required String handlerName}) { + throw UnimplementedError( + 'removeJavaScriptHandler is not implemented on the current platform'); + } + + ///Returns `true` if a JavaScript handler with [handlerName] already exists, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + bool hasJavaScriptHandler({required String handlerName}) { + throw UnimplementedError( + 'hasJavaScriptHandler is not implemented on the current platform'); + } + + ///Takes a screenshot of the WebView's visible viewport and returns a [Uint8List]. Returns `null` if it wasn't be able to take it. + /// + ///[screenshotConfiguration] represents the configuration data to use when generating an image from a web view’s contents. + /// + ///**NOTE for iOS**: available on iOS 11.0+. + /// + ///**NOTE for MacOS**: available on MacOS 10.13+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - WKWebView.takeSnapshot](https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot)) + ///- MacOS ([Official API - WKWebView.takeSnapshot](https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot)) + Future takeScreenshot( + {ScreenshotConfiguration? screenshotConfiguration}) { + throw UnimplementedError( + 'takeScreenshot is not implemented on the current platform'); + } + + ///Sets the WebView settings with the new [settings] and evaluates them. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future setSettings({required InAppWebViewSettings settings}) { + throw UnimplementedError( + 'setSettings is not implemented on the current platform'); + } + + ///Gets the current WebView settings. Returns `null` if it wasn't able to get them. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future getSettings() { + throw UnimplementedError( + 'getSettings is not implemented on the current platform'); + } + + ///Gets the WebHistory for this WebView. This contains the back/forward list for use in querying each item in the history stack. + ///This contains only a snapshot of the current state. + ///Multiple calls to this method may return different objects. + ///The object returned from this method will not be updated to reflect any new state. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.copyBackForwardList](https://developer.android.com/reference/android/webkit/WebView#copyBackForwardList())) + ///- iOS ([Official API - WKWebView.backForwardList](https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist)) + ///- MacOS ([Official API - WKWebView.backForwardList](https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist)) + Future getCopyBackForwardList() { + throw UnimplementedError( + 'getCopyBackForwardList is not implemented on the current platform'); + } + + ///Clears all the WebView's cache. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future clearCache() { + throw UnimplementedError( + 'clearCache is not implemented on the current platform'); + } + + ///Scrolls the WebView to the position. + /// + ///[x] represents the x position to scroll to. + /// + ///[y] represents the y position to scroll to. + /// + ///[animated] `true` to animate the scroll transition, `false` to make the scoll transition immediate. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: this method is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - View.scrollTo](https://developer.android.com/reference/android/view/View#scrollTo(int,%20int))) + ///- iOS ([Official API - UIScrollView.setContentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset)) + ///- MacOS + ///- Web ([Official API - Window.scrollTo](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo)) + Future scrollTo( + {required int x, required int y, bool animated = false}) { + throw UnimplementedError( + 'scrollTo is not implemented on the current platform'); + } + + ///Moves the scrolled position of the WebView. + /// + ///[x] represents the amount of pixels to scroll by horizontally. + /// + ///[y] represents the amount of pixels to scroll by vertically. + /// + ///[animated] `true` to animate the scroll transition, `false` to make the scoll transition immediate. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: this method is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - View.scrollBy](https://developer.android.com/reference/android/view/View#scrollBy(int,%20int))) + ///- iOS ([Official API - UIScrollView.setContentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset)) + ///- MacOS + ///- Web ([Official API - Window.scrollBy](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy)) + Future scrollBy( + {required int x, required int y, bool animated = false}) { + throw UnimplementedError( + 'scrollBy is not implemented on the current platform'); + } + + ///On Android native WebView, it pauses all layout, parsing, and JavaScript timers for all WebViews. + ///This is a global requests, not restricted to just this WebView. This can be useful if the application has been paused. + /// + ///**NOTE for iOS**: it is implemented using JavaScript and it is restricted to just this WebView. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript and it is restricted to just this WebView. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.pauseTimers](https://developer.android.com/reference/android/webkit/WebView#pauseTimers())) + ///- iOS + ///- MacOS + Future pauseTimers() { + throw UnimplementedError( + 'pauseTimers is not implemented on the current platform'); + } + + ///On Android, it resumes all layout, parsing, and JavaScript timers for all WebViews. This will resume dispatching all timers. + /// + ///**NOTE for iOS**: it is implemented using JavaScript and it is restricted to just this WebView. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript and it is restricted to just this WebView. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.resumeTimers](https://developer.android.com/reference/android/webkit/WebView#resumeTimers())) + ///- iOS + ///- MacOS + Future resumeTimers() { + throw UnimplementedError( + 'resumeTimers is not implemented on the current platform'); + } + + ///Prints the current page. + /// + ///To obtain the [PlatformPrintJobController], use [settings] argument with [PrintJobSettings.handledByClient] to `true`. + ///Otherwise this method will return `null` and the [PlatformPrintJobController] will be handled and disposed automatically by the system. + /// + ///**NOTE for Android**: available on Android 19+. + /// + ///**NOTE for MacOS**: [PlatformPrintJobController] is available on MacOS 11.0+. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. Also, [PlatformPrintJobController] is always `null`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintManager.print](https://developer.android.com/reference/android/print/PrintManager#print(java.lang.String,%20android.print.PrintDocumentAdapter,%20android.print.PrintAttributes))) + ///- iOS ([Official API - UIPrintInteractionController.present](https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/1618149-present)) + ///- MacOS (if 11.0+, [Official API - WKWebView.printOperation](https://developer.apple.com/documentation/webkit/wkwebview/3516861-printoperation), else [Official API - NSView.printView](https://developer.apple.com/documentation/appkit/nsview/1483705-printview)) + ///- Web ([Official API - Window.print](https://developer.mozilla.org/en-US/docs/Web/API/Window/print)) + Future printCurrentPage( + {PrintJobSettings? settings}) { + throw UnimplementedError( + 'printCurrentPage is not implemented on the current platform'); + } + + ///Gets the height of the HTML content. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getContentHeight](https://developer.android.com/reference/android/webkit/WebView#getContentHeight())) + ///- iOS ([Official API - UIScrollView.contentSize](https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize)) + ///- MacOS + ///- Web ([Official API - Document.documentElement.scrollHeight](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight)) + Future getContentHeight() { + throw UnimplementedError( + 'getContentHeight is not implemented on the current platform'); + } + + ///Gets the width of the HTML content. + /// + ///**NOTE for Android**: it is implemented using JavaScript. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - UIScrollView.contentSize](https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize)) + ///- MacOS + ///- Web ([Official API - Document.documentElement.scrollWidth](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth)) + Future getContentWidth() { + throw UnimplementedError( + 'getContentWidth is not implemented on the current platform'); + } + + ///Performs a zoom operation in this WebView. + /// + ///[zoomFactor] represents the zoom factor to apply. On Android, the zoom factor will be clamped to the Webview's zoom limits and, also, this value must be in the range 0.01 (excluded) to 100.0 (included). + /// + ///[animated] `true` to animate the transition to the new scale, `false` to make the transition immediate. + ///**NOTE**: available only on iOS. + /// + ///**NOTE**: available on Android 21+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.zoomBy](https://developer.android.com/reference/android/webkit/WebView#zoomBy(float))) + ///- iOS ([Official API - UIScrollView.setZoomScale](https://developer.apple.com/documentation/uikit/uiscrollview/1619412-setzoomscale)) + Future zoomBy( + {required double zoomFactor, + @Deprecated('Use animated instead') bool? iosAnimated, + bool animated = false}) { + throw UnimplementedError( + 'zoomBy is not implemented on the current platform'); + } + + ///Gets the URL that was originally requested for the current page. + ///This is not always the same as the URL passed to [InAppWebView.onLoadStart] because although the load for that URL has begun, + ///the current page may not have changed. Also, there may have been redirects resulting in a different URL to that originally requested. + /// + ///**NOTE for Web**: it will return the current value of the `iframe.src` attribute. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getOriginalUrl](https://developer.android.com/reference/android/webkit/WebView#getOriginalUrl())) + ///- iOS + ///- MacOS + ///- Web + Future getOriginalUrl() { + throw UnimplementedError( + 'getOriginalUrl is not implemented on the current platform'); + } + + ///Gets the current zoom scale of the WebView. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - UIScrollView.zoomScale](https://developer.apple.com/documentation/uikit/uiscrollview/1619419-zoomscale)) + Future getZoomScale() { + throw UnimplementedError( + 'getZoomScale is not implemented on the current platform'); + } + + ///Gets the selected text. + /// + ///**NOTE**: this method is implemented with using JavaScript. + /// + ///**NOTE for Android native WebView**: available only on Android 19+. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future getSelectedText() { + throw UnimplementedError( + 'getSelectedText is not implemented on the current platform'); + } + + ///Gets the hit result for hitting an HTML elements. + /// + ///**NOTE**: On iOS, it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getHitTestResult](https://developer.android.com/reference/android/webkit/WebView#getHitTestResult())) + ///- iOS + Future getHitTestResult() { + throw UnimplementedError( + 'getHitTestResult is not implemented on the current platform'); + } + + ///Clears the current focus. On iOS and Android native WebView, it will clear also, for example, the current text selection. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - ViewGroup.clearFocus](https://developer.android.com/reference/android/view/ViewGroup#clearFocus())) + ///- iOS ([Official API - UIResponder.resignFirstResponder](https://developer.apple.com/documentation/uikit/uiresponder/1621097-resignfirstresponder)) + Future clearFocus() { + throw UnimplementedError( + 'clearFocus is not implemented on the current platform'); + } + + ///Sets or updates the WebView context menu to be used next time it will appear. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + Future setContextMenu(ContextMenu? contextMenu) { + throw UnimplementedError( + 'setContextMenu is not implemented on the current platform'); + } + + ///Requests the anchor or image element URL at the last tapped point. + /// + ///**NOTE**: On iOS, it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.requestFocusNodeHref](https://developer.android.com/reference/android/webkit/WebView#requestFocusNodeHref(android.os.Message))) + ///- iOS + Future requestFocusNodeHref() { + throw UnimplementedError( + 'requestFocusNodeHref is not implemented on the current platform'); + } + + ///Requests the URL of the image last touched by the user. + /// + ///**NOTE**: On iOS, it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.requestImageRef](https://developer.android.com/reference/android/webkit/WebView#requestImageRef(android.os.Message))) + ///- iOS + Future requestImageRef() { + throw UnimplementedError( + 'requestImageRef is not implemented on the current platform'); + } + + ///Returns the list of `` tags of the current WebView. + /// + ///**NOTE**: It is implemented using JavaScript. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future> getMetaTags() { + throw UnimplementedError( + 'getMetaTags is not implemented on the current platform'); + } + + ///Returns an instance of [Color] representing the `content` value of the + ///`` tag of the current WebView, if available, otherwise `null`. + /// + ///**NOTE**: on Android, Web, iOS < 15.0 and MacOS < 12.0, it is implemented using JavaScript. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - WKWebView.themeColor](https://developer.apple.com/documentation/webkit/wkwebview/3794258-themecolor)) + ///- MacOS ([Official API - WKWebView.themeColor](https://developer.apple.com/documentation/webkit/wkwebview/3794258-themecolor)) + ///- Web + Future getMetaThemeColor() { + throw UnimplementedError( + 'getMetaThemeColor is not implemented on the current platform'); + } + + ///Returns the scrolled left position of the current WebView. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - View.getScrollX](https://developer.android.com/reference/android/view/View#getScrollX())) + ///- iOS ([Official API - UIScrollView.contentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset)) + ///- MacOS + ///- Web ([Official API - Window.scrollX](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX)) + Future getScrollX() { + throw UnimplementedError( + 'getScrollX is not implemented on the current platform'); + } + + ///Returns the scrolled top position of the current WebView. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - View.getScrollY](https://developer.android.com/reference/android/view/View#getScrollY())) + ///- iOS ([Official API - UIScrollView.contentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset)) + ///- MacOS + ///- Web ([Official API - Window.scrollY](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY)) + Future getScrollY() { + throw UnimplementedError( + 'getScrollY is not implemented on the current platform'); + } + + ///Gets the SSL certificate for the main top-level page or null if there is no certificate (the site is not secure). + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getCertificate](https://developer.android.com/reference/android/webkit/WebView#getCertificate())) + ///- iOS + ///- MacOS + Future getCertificate() { + throw UnimplementedError( + 'getCertificate is not implemented on the current platform'); + } + + ///Injects the specified [userScript] into the webpage’s content. + /// + ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. + ///There isn't any way to add/remove user scripts specific to window WebViews. + ///This is a limitation of the native WebKit APIs. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - WKUserContentController.addUserScript](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript)) + ///- MacOS ([Official API - WKUserContentController.addUserScript](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript)) + Future addUserScript({required UserScript userScript}) { + throw UnimplementedError( + 'addUserScript is not implemented on the current platform'); + } + + ///Injects the [userScripts] into the webpage’s content. + /// + ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. + ///There isn't any way to add/remove user scripts specific to window WebViews. + ///This is a limitation of the native WebKit APIs. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future addUserScripts({required List userScripts}) { + throw UnimplementedError( + 'addUserScripts is not implemented on the current platform'); + } + + ///Removes the specified [userScript] from the webpage’s content. + ///User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load. + ///Returns `true` if [userScript] was in the list, `false` otherwise. + /// + ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. + ///There isn't any way to add/remove user scripts specific to window WebViews. + ///This is a limitation of the native WebKit APIs. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future removeUserScript({required UserScript userScript}) { + throw UnimplementedError( + 'removeUserScript is not implemented on the current platform'); + } + + ///Removes all the [UserScript]s with [groupName] as group name from the webpage’s content. + ///User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load. + /// + ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. + ///There isn't any way to add/remove user scripts specific to window WebViews. + ///This is a limitation of the native WebKit APIs. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future removeUserScriptsByGroupName({required String groupName}) { + throw UnimplementedError( + 'removeUserScriptsByGroupName is not implemented on the current platform'); + } + + ///Removes the [userScripts] from the webpage’s content. + ///User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load. + /// + ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. + ///There isn't any way to add/remove user scripts specific to window WebViews. + ///This is a limitation of the native WebKit APIs. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future removeUserScripts({required List userScripts}) { + throw UnimplementedError( + 'removeUserScripts is not implemented on the current platform'); + } + + ///Removes all the user scripts from the webpage’s content. + /// + ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. + ///There isn't any way to add/remove user scripts specific to window WebViews. + ///This is a limitation of the native WebKit APIs. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - WKUserContentController.removeAllUserScripts](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts)) + ///- MacOS ([Official API - WKUserContentController.removeAllUserScripts](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts)) + Future removeAllUserScripts() { + throw UnimplementedError( + 'removeAllUserScripts is not implemented on the current platform'); + } + + ///Returns `true` if the [userScript] has been already added, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + bool hasUserScript({required UserScript userScript}) { + throw UnimplementedError( + 'hasUserScript is not implemented on the current platform'); + } + + ///Executes the specified string as an asynchronous JavaScript function. + /// + ///[functionBody] is the JavaScript string to use as the function body. + ///This method treats the string as an anonymous JavaScript function body and calls it with the named arguments in the arguments parameter. + /// + ///[arguments] is a `Map` of the arguments to pass to the function call. + ///Each key in the `Map` corresponds to the name of an argument in the [functionBody] string, + ///and the value of that key is the value to use during the evaluation of the code. + ///Supported value types can be found in the official Flutter docs: + ///[Platform channel data types support and codecs](https://flutter.dev/docs/development/platform-integration/platform-channels#codec), + ///except for [Uint8List], [Int32List], [Int64List], and [Float64List] that should be converted into a [List]. + ///All items in a `List` or `Map` must also be one of the supported types. + /// + ///[contentWorld], on iOS, it represents the namespace in which to evaluate the JavaScript [source] code. + ///Instead, on Android, it will run the [source] code into an iframe. + ///This parameter doesn’t apply to changes you make to the underlying web content, such as the document’s DOM structure. + ///Those changes remain visible to all scripts, regardless of which content world you specify. + ///For more information about content worlds, see [ContentWorld]. + ///Available on iOS 14.3+. + /// + ///**NOTE**: This method shouldn't be called in the [WebView.onWebViewCreated] or [WebView.onLoadStart] events, + ///because, in these events, the `WebView` is not ready to handle it yet. + ///Instead, you should call this method, for example, inside the [WebView.onLoadStop] event or in any other events + ///where you know the page is ready "enough". + /// + ///**NOTE for iOS**: available only on iOS 10.3+. + /// + ///**NOTE for Android**: available only on Android 21+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - WKWebView.callAsyncJavaScript](https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript)) + ///- MacOS ([Official API - WKWebView.callAsyncJavaScript](https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript)) + Future callAsyncJavaScript( + {required String functionBody, + Map arguments = const {}, + ContentWorld? contentWorld}) { + throw UnimplementedError( + 'callAsyncJavaScript is not implemented on the current platform'); + } + + ///Saves the current WebView as a web archive. + ///Returns the file path under which the web archive file was saved, or `null` if saving the file failed. + /// + ///[filePath] represents the file path where the archive should be placed. This value cannot be `null`. + /// + ///[autoname] if `false`, takes [filePath] to be a file. + ///If `true`, [filePath] is assumed to be a directory in which a filename will be chosen according to the URL of the current page. + /// + ///**NOTE for iOS**: Available on iOS 14.0+. If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension. + /// + ///**NOTE for MacOS**: Available on MacOS 11.0+. If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension. + /// + ///**NOTE for Android**: if [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.MHT] file extension. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.saveWebArchive](https://developer.android.com/reference/android/webkit/WebView#saveWebArchive(java.lang.String,%20boolean,%20android.webkit.ValueCallback%3Cjava.lang.String%3E))) + ///- iOS + ///- MacOS + Future saveWebArchive( + {required String filePath, bool autoname = false}) { + throw UnimplementedError( + 'saveWebArchive is not implemented on the current platform'); + } + + ///Indicates whether the webpage context is capable of using features that require [secure contexts](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts). + ///This is implemented using Javascript (see [window.isSecureContext](https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext)). + /// + ///**NOTE for Android**: available Android 21.0+. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. Returns `false` otherwise. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web ([Official API - Window.isSecureContext](https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext)) + Future isSecureContext() { + throw UnimplementedError( + 'isSecureContext is not implemented on the current platform'); + } + + ///Creates a message channel to communicate with JavaScript and returns the message channel with ports that represent the endpoints of this message channel. + ///The HTML5 message channel functionality is described [here](https://html.spec.whatwg.org/multipage/comms.html#messagechannel). + /// + ///The returned message channels are entangled and already in started state. + /// + ///This method should be called when the page is loaded, for example, when the [WebView.onLoadStop] is fired, otherwise the [PlatformWebMessageChannel] won't work. + /// + ///**NOTE for Android native WebView**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.CREATE_WEB_MESSAGE_CHANNEL]. + /// + ///**NOTE for iOS**: it is implemented using JavaScript. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.createWebMessageChannel](https://developer.android.com/reference/androidx/webkit/WebViewCompat#createWebMessageChannel(android.webkit.WebView))) + ///- iOS + ///- MacOS + Future createWebMessageChannel() { + throw UnimplementedError( + 'createWebMessageChannel is not implemented on the current platform'); + } + + ///Post a message to main frame. The embedded application can restrict the messages to a certain target origin. + ///See [HTML5 spec](https://html.spec.whatwg.org/multipage/comms.html#posting-messages) for how target origin can be used. + /// + ///A target origin can be set as a wildcard ("*"). However this is not recommended. + /// + ///**NOTE for Android native WebView**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.POST_WEB_MESSAGE]. + /// + ///**NOTE for iOS**: it is implemented using JavaScript. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.postWebMessage](https://developer.android.com/reference/androidx/webkit/WebViewCompat#postWebMessage(android.webkit.WebView,%20androidx.webkit.WebMessageCompat,%20android.net.Uri))) + ///- iOS + ///- MacOS + Future postWebMessage( + {required WebMessage message, WebUri? targetOrigin}) { + throw UnimplementedError( + 'postWebMessage is not implemented on the current platform'); + } + + ///Adds a [PlatformWebMessageListener] to the WebView and injects a JavaScript object into each frame that the [PlatformWebMessageListener] will listen on. + /// + ///The injected JavaScript object will be named [PlatformWebMessageListener.jsObjectName] in the global scope. + ///This will inject the JavaScript object in any frame whose origin matches [PlatformWebMessageListener.allowedOriginRules] + ///for every navigation after this call, and the JavaScript object will be available immediately when the page begins to load. + /// + ///Each [PlatformWebMessageListener.allowedOriginRules] entry must follow the format `SCHEME "://" [ HOSTNAME_PATTERN [ ":" PORT ] ]`, each part is explained in the below table: + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + ///
RuleDescriptionExample
http/https with hostnameSCHEME is http or https; HOSTNAME_PATTERN is a regular hostname; PORT is optional, when not present, the rule will match port 80 for http and port + /// 443 for https. + /// + ///
    + ///
  • https://foobar.com:8080 - Matches https:// URL on port 8080, whose normalized + /// host is foobar.com. + ///
  • + ///
  • https://www.example.com - Matches https:// URL on port 443, whose normalized host + /// is www.example.com. + ///
  • + ///
+ ///
http/https with pattern matchingSCHEME is http or https; HOSTNAME_PATTERN is a sub-domain matching + /// pattern with a leading *.; PORT is optional, when not present, the rule will + /// match port 80 for http and port 443 for https. + /// + ///
    + ///
  • https://*.example.com - Matches https://calendar.example.com and + /// https://foo.bar.example.com but not https://example.com. + ///
  • + ///
  • https://*.example.com:8080 - Matches https://calendar.example.com:8080
  • + ///
+ ///
http/https with IP literalSCHEME is https or https; HOSTNAME_PATTERN is IP literal; PORT is + /// optional, when not present, the rule will match port 80 for http and port 443 + /// for https. + /// + ///
    + ///
  • https://127.0.0.1 - Matches https:// URL on port 443, whose IPv4 address is + /// 127.0.0.1 + ///
  • + ///
  • https://[::1] or https://[0:0::1]- Matches any URL to the IPv6 loopback + /// address with port 443. + ///
  • + ///
  • https://[::1]:99 - Matches any https:// URL to the IPv6 loopback on port 99.
  • + ///
+ ///
Custom schemeSCHEME is a custom scheme; HOSTNAME_PATTERN and PORT must not be + /// present. + /// + ///
    + ///
  • my-app-scheme:// - Matches any my-app-scheme:// URL.
  • + ///
+ ///
*Wildcard rule, matches any origin. + ///
    + ///
  • *
  • + ///
+ ///
+ /// + ///Note that this is a powerful API, as the JavaScript object will be injected when the frame's origin matches any one of the allowed origins. + ///The HTTPS scheme is strongly recommended for security; allowing HTTP origins exposes the injected object to any potential network-based attackers. + ///If a wildcard "*" is provided, it will inject the JavaScript object to all frames. + ///A wildcard should only be used if the app wants **any** third party web page to be able to use the injected object. + ///When using a wildcard, the app must treat received messages as untrustworthy and validate any data carefully. + /// + ///This method can be called multiple times to inject multiple JavaScript objects. + /// + ///Let's say the injected JavaScript object is named `myObject`. We will have following methods on that object once it is available to use: + /// + ///```javascript + /// // Web page (in JavaScript) + /// // message needs to be a JavaScript String, MessagePorts is an optional parameter. + /// myObject.postMessage(message[, MessagePorts]) // on Android + /// myObject.postMessage(message) // on iOS + /// + /// // To receive messages posted from the app side, assign a function to the "onmessage" + /// // property. This function should accept a single "event" argument. "event" has a "data" + /// // property, which is the message string from the app side. + /// myObject.onmessage = function(event) { ... } + /// + /// // To be compatible with DOM EventTarget's addEventListener, it accepts type and listener + /// // parameters, where type can be only "message" type and listener can only be a JavaScript + /// // function for myObject. An event object will be passed to listener with a "data" property, + /// // which is the message string from the app side. + /// myObject.addEventListener(type, listener) + /// + /// // To be compatible with DOM EventTarget's removeEventListener, it accepts type and listener + /// // parameters, where type can be only "message" type and listener can only be a JavaScript + /// // function for myObject. + /// myObject.removeEventListener(type, listener) + ///``` + /// + ///We start the communication between JavaScript and the app from the JavaScript side. + ///In order to send message from the app to JavaScript, it needs to post a message from JavaScript first, + ///so the app will have a [PlatformJavaScriptReplyProxy] object to respond. Example: + /// + ///```javascript + /// // Web page (in JavaScript) + /// myObject.onmessage = function(event) { + /// // prints "Got it!" when we receive the app's response. + /// console.log(event.data); + /// } + /// myObject.postMessage("I'm ready!"); + ///``` + /// + ///```dart + /// // Flutter App + /// child: InAppWebView( + /// onWebViewCreated: (controller) async { + /// if (defaultTargetPlatform != TargetPlatform.android || await WebViewFeature.isFeatureSupported(WebViewFeature.WEB_MESSAGE_LISTENER)) { + /// await controller.addWebMessageListener(WebMessageListener( + /// jsObjectName: "myObject", + /// onPostMessage: (message, sourceOrigin, isMainFrame, replyProxy) { + /// // do something about message, sourceOrigin and isMainFrame. + /// replyProxy.postMessage("Got it!"); + /// }, + /// )); + /// } + /// await controller.loadUrl(urlRequest: URLRequest(url: WebUri("https://www.example.com"))); + /// }, + /// ), + ///``` + /// + ///**NOTE for Android**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.WEB_MESSAGE_LISTENER]. + /// + ///**NOTE for iOS**: it is implemented using JavaScript. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.WebMessageListener](https://developer.android.com/reference/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,%20java.lang.String,%20java.util.Set%3Cjava.lang.String%3E,%20androidx.webkit.WebViewCompat.WebMessageListener))) + ///- iOS + ///- MacOS + Future addWebMessageListener( + PlatformWebMessageListener webMessageListener) { + throw UnimplementedError( + 'addWebMessageListener is not implemented on the current platform'); + } + + ///Returns `true` if the [webMessageListener] has been already added, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + bool hasWebMessageListener(PlatformWebMessageListener webMessageListener) { + throw UnimplementedError( + 'hasWebMessageListener is not implemented on the current platform'); + } + + ///Returns `true` if the webpage can scroll vertically, otherwise `false`. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future canScrollVertically() { + throw UnimplementedError( + 'canScrollVertically is not implemented on the current platform'); + } + + ///Returns `true` if the webpage can scroll horizontally, otherwise `false`. + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + /// + ///**NOTE for MacOS**: it is implemented using JavaScript. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future canScrollHorizontally() { + throw UnimplementedError( + 'canScrollHorizontally is not implemented on the current platform'); + } + + ///Starts Safe Browsing initialization. + /// + ///URL loads are not guaranteed to be protected by Safe Browsing until after the this method returns true. + ///Safe Browsing is not fully supported on all devices. For those devices this method will returns false. + /// + ///This should not be called if Safe Browsing has been disabled by manifest tag or [AndroidInAppWebViewOptions.safeBrowsingEnabled]. + ///This prepares resources used for Safe Browsing. + /// + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.START_SAFE_BROWSING]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.startSafeBrowsing](https://developer.android.com/reference/android/webkit/WebView#startSafeBrowsing(android.content.Context,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) + Future startSafeBrowsing() { + throw UnimplementedError( + 'startSafeBrowsing is not implemented on the current platform'); + } + + ///Clears the SSL preferences table stored in response to proceeding with SSL certificate errors. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.clearSslPreferences](https://developer.android.com/reference/android/webkit/WebView#clearSslPreferences())) + Future clearSslPreferences() { + throw UnimplementedError( + 'clearSslPreferences is not implemented on the current platform'); + } + + ///Does a best-effort attempt to pause any processing that can be paused safely, such as animations and geolocation. Note that this call does not pause JavaScript. + ///To pause JavaScript globally, use [PlatformInAppWebViewController.pauseTimers]. To resume WebView, call [resume]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.onPause](https://developer.android.com/reference/android/webkit/WebView#onPause())) + Future pause() { + throw UnimplementedError( + 'pause is not implemented on the current platform'); + } + + ///Resumes a WebView after a previous call to [pause]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.onResume](https://developer.android.com/reference/android/webkit/WebView#onResume())) + Future resume() { + throw UnimplementedError( + 'resume is not implemented on the current platform'); + } + + ///Scrolls the contents of this WebView down by half the page size. + ///Returns `true` if the page was scrolled. + /// + ///[bottom] `true` to jump to bottom of page. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.pageDown](https://developer.android.com/reference/android/webkit/WebView#pageDown(boolean))) + Future pageDown({required bool bottom}) { + throw UnimplementedError( + 'pageDown is not implemented on the current platform'); + } + + ///Scrolls the contents of this WebView up by half the view size. + ///Returns `true` if the page was scrolled. + /// + ///[top] `true` to jump to the top of the page. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.pageUp](https://developer.android.com/reference/android/webkit/WebView#pageUp(boolean))) + Future pageUp({required bool top}) { + throw UnimplementedError( + 'pageUp is not implemented on the current platform'); + } + + ///Performs zoom in in this WebView. + ///Returns `true` if zoom in succeeds, `false` if no zoom changes. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.zoomIn](https://developer.android.com/reference/android/webkit/WebView#zoomIn())) + Future zoomIn() { + throw UnimplementedError( + 'zoomIn is not implemented on the current platform'); + } + + ///Performs zoom out in this WebView. + ///Returns `true` if zoom out succeeds, `false` if no zoom changes. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.zoomOut](https://developer.android.com/reference/android/webkit/WebView#zoomOut())) + Future zoomOut() { + throw UnimplementedError( + 'zoomOut is not implemented on the current platform'); + } + + ///Clears the internal back/forward list. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.clearHistory](https://developer.android.com/reference/android/webkit/WebView#clearHistory())) + Future clearHistory() { + throw UnimplementedError( + 'clearHistory is not implemented on the current platform'); + } + + ///Reloads the current page, performing end-to-end revalidation using cache-validating conditionals if possible. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.reloadFromOrigin](https://developer.apple.com/documentation/webkit/wkwebview/1414956-reloadfromorigin)) + ///- MacOS ([Official API - WKWebView.reloadFromOrigin](https://developer.apple.com/documentation/webkit/wkwebview/1414956-reloadfromorigin)) + Future reloadFromOrigin() { + throw UnimplementedError( + 'reloadFromOrigin is not implemented on the current platform'); + } + + ///Generates PDF data from the web view’s contents asynchronously. + ///Returns `null` if a problem occurred. + /// + ///[pdfConfiguration] represents the object that specifies the portion of the web view to capture as PDF data. + /// + ///**NOTE for iOS**: available only on iOS 14.0+. + /// + ///**NOTE for MacOS**: available only on MacOS 11.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.createPdf](https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf)) + ///- MacOS ([Official API - WKWebView.createPdf](https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf)) + Future createPdf( + {@Deprecated("Use pdfConfiguration instead") + // ignore: deprecated_member_use_from_same_package + IOSWKPDFConfiguration? iosWKPdfConfiguration, + PDFConfiguration? pdfConfiguration}) { + throw UnimplementedError( + 'createPdf is not implemented on the current platform'); + } + + ///Creates a web archive of the web view’s current contents asynchronously. + ///Returns `null` if a problem occurred. + /// + ///**NOTE for iOS**: available only on iOS 14.0+. + /// + ///**NOTE for MacOS**: available only on MacOS 11.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.createWebArchiveData](https://developer.apple.com/documentation/webkit/wkwebview/3650491-createwebarchivedata)) + ///- MacOS ([Official API - WKWebView.createWebArchiveData](https://developer.apple.com/documentation/webkit/wkwebview/3650491-createwebarchivedata)) + Future createWebArchiveData() { + throw UnimplementedError( + 'createWebArchiveData is not implemented on the current platform'); + } + + ///A Boolean value indicating whether all resources on the page have been loaded over securely encrypted connections. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.hasOnlySecureContent](https://developer.apple.com/documentation/webkit/wkwebview/1415002-hasonlysecurecontent)) + ///- MacOS ([Official API - WKWebView.hasOnlySecureContent](https://developer.apple.com/documentation/webkit/wkwebview/1415002-hasonlysecurecontent)) + Future hasOnlySecureContent() { + throw UnimplementedError( + 'hasOnlySecureContent is not implemented on the current platform'); + } + + ///Pauses playback of all media in the web view. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.pauseAllMediaPlayback](https://developer.apple.com/documentation/webkit/wkwebview/3752240-pauseallmediaplayback)). + ///- MacOS ([Official API - WKWebView.pauseAllMediaPlayback](https://developer.apple.com/documentation/webkit/wkwebview/3752240-pauseallmediaplayback)). + Future pauseAllMediaPlayback() { + throw UnimplementedError( + 'pauseAllMediaPlayback is not implemented on the current platform'); + } + + ///Changes whether the webpage is suspending playback of all media in the page. + ///Pass `true` to pause all media the web view is playing. Neither the user nor the webpage can resume playback until you call this method again with `false`. + /// + ///[suspended] represents a [bool] value that indicates whether the webpage should suspend media playback. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.setAllMediaPlaybackSuspended](https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended)). + ///- MacOS ([Official API - WKWebView.setAllMediaPlaybackSuspended](https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended)). + Future setAllMediaPlaybackSuspended({required bool suspended}) { + throw UnimplementedError( + 'setAllMediaPlaybackSuspended is not implemented on the current platform'); + } + + ///Closes all media the web view is presenting, including picture-in-picture video and fullscreen video. + /// + ///**NOTE for iOS**: available on iOS 14.5+. + /// + ///**NOTE for MacOS**: available on MacOS 11.3+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.closeAllMediaPresentations](https://developer.apple.com/documentation/webkit/wkwebview/3752235-closeallmediapresentations)). + ///- MacOS ([Official API - WKWebView.closeAllMediaPresentations](https://developer.apple.com/documentation/webkit/wkwebview/3752235-closeallmediapresentations)). + Future closeAllMediaPresentations() { + throw UnimplementedError( + 'closeAllMediaPresentations is not implemented on the current platform'); + } + + ///Requests the playback status of media in the web view. + ///Returns a [MediaPlaybackState] that indicates whether the media in the web view is playing, paused, or suspended. + ///If there’s no media in the web view to play, this method provides [MediaPlaybackState.NONE]. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.requestMediaPlaybackState](https://developer.apple.com/documentation/webkit/wkwebview/3752241-requestmediaplaybackstate)). + ///- MacOS ([Official API - WKWebView.requestMediaPlaybackState](https://developer.apple.com/documentation/webkit/wkwebview/3752241-requestmediaplaybackstate)). + Future requestMediaPlaybackState() { + throw UnimplementedError( + 'requestMediaPlaybackState is not implemented on the current platform'); + } + + ///Returns `true` if the `WebView` is in fullscreen mode, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future isInFullscreen() { + throw UnimplementedError( + 'isInFullscreen is not implemented on the current platform'); + } + + ///Returns a [MediaCaptureState] that indicates whether the webpage is using the camera to capture images or video. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.cameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763093-cameracapturestate)). + ///- MacOS ([Official API - WKWebView.cameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763093-cameracapturestate)). + Future getCameraCaptureState() { + throw UnimplementedError( + 'getCameraCaptureState is not implemented on the current platform'); + } + + ///Changes whether the webpage is using the camera to capture images or video. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.setCameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763097-setcameracapturestate)). + ///- MacOS ([Official API - WKWebView.setCameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763097-setcameracapturestate)). + Future setCameraCaptureState({required MediaCaptureState state}) { + throw UnimplementedError( + 'setCameraCaptureState is not implemented on the current platform'); + } + + ///Returns a [MediaCaptureState] that indicates whether the webpage is using the microphone to capture audio. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.microphoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763096-microphonecapturestate)). + ///- MacOS ([Official API - WKWebView.microphoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763096-microphonecapturestate)). + Future getMicrophoneCaptureState() { + throw UnimplementedError( + 'getMicrophoneCaptureState is not implemented on the current platform'); + } + + ///Changes whether the webpage is using the microphone to capture audio. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.setMicrophoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763098-setmicrophonecapturestate)). + ///- MacOS ([Official API - WKWebView.setMicrophoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763098-setmicrophonecapturestate)). + Future setMicrophoneCaptureState({required MediaCaptureState state}) { + throw UnimplementedError( + 'setMicrophoneCaptureState is not implemented on the current platform'); + } + + ///Loads the web content from the data you provide as if the data were the response to the request. + ///If [urlResponse] is `null`, it loads the web content from the data as an utf8 encoded HTML string as the response to the request. + /// + ///[urlRequest] represents a URL request that specifies the base URL and other loading details the system uses to interpret the data you provide. + /// + ///[urlResponse] represents a response the system uses to interpret the data you provide. + /// + ///[data] represents the data or the utf8 encoded HTML string to use as the contents of the webpage. + /// + ///Example: + ///```dart + ///controller.loadSimulateloadSimulatedRequestdRequest(urlRequest: URLRequest( + /// url: WebUri("https://flutter.dev"), + /// ), + /// data: Uint8List.fromList(utf8.encode("

Hello

")) + ///); + ///``` + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.loadSimulatedRequest(_:response:responseData:)](https://developer.apple.com/documentation/webkit/wkwebview/3763094-loadsimulatedrequest) and [Official API - WKWebView.loadSimulatedRequest(_:responseHTML:)](https://developer.apple.com/documentation/webkit/wkwebview/3763095-loadsimulatedrequest)). + ///- MacOS ([Official API - WKWebView.loadSimulatedRequest(_:response:responseData:)](https://developer.apple.com/documentation/webkit/wkwebview/3763094-loadsimulatedrequest) and [Official API - WKWebView.loadSimulatedRequest(_:responseHTML:)](https://developer.apple.com/documentation/webkit/wkwebview/3763095-loadsimulatedrequest)). + Future loadSimulatedRequest( + {required URLRequest urlRequest, + required Uint8List data, + URLResponse? urlResponse}) { + throw UnimplementedError( + 'loadSimulatedRequest is not implemented on the current platform'); + } + + ///Returns the iframe `id` attribute used on the Web platform. + /// + ///**Supported Platforms/Implementations**: + ///- Web + Future getIFrameId() { + throw UnimplementedError( + 'getIFrameId is not implemented on the current platform'); + } + + ///View ID used internally. + dynamic getViewId() { + throw UnimplementedError( + 'getViewId is not implemented on the current platform'); + } + + ///Gets the default user agent. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebSettings.getDefaultUserAgent](https://developer.android.com/reference/android/webkit/WebSettings#getDefaultUserAgent(android.content.Context))) + ///- iOS + ///- MacOS + Future getDefaultUserAgent() { + throw UnimplementedError( + 'getDefaultUserAgent is not implemented on the current platform'); + } + + ///Clears the client certificate preferences stored in response to proceeding/cancelling client cert requests. + ///Note that WebView automatically clears these preferences when the system keychain is updated. + ///The preferences are shared by all the WebViews that are created by the embedder application. + /// + ///**NOTE**: On iOS certificate-based credentials are never stored permanently. + /// + ///**NOTE**: available on Android 21+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.clearClientCertPreferences](https://developer.android.com/reference/android/webkit/WebView#clearClientCertPreferences(java.lang.Runnable))) + Future clearClientCertPreferences() { + throw UnimplementedError( + 'clearClientCertPreferences is not implemented on the current platform'); + } + + ///Returns a URL pointing to the privacy policy for Safe Browsing reporting. + /// + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SAFE_BROWSING_PRIVACY_POLICY_URL]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.getSafeBrowsingPrivacyPolicyUrl](https://developer.android.com/reference/androidx/webkit/WebViewCompat#getSafeBrowsingPrivacyPolicyUrl())) + Future getSafeBrowsingPrivacyPolicyUrl() { + throw UnimplementedError( + 'getSafeBrowsingPrivacyPolicyUrl is not implemented on the current platform'); + } + + ///Sets the list of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks. The list is global for all the WebViews. + /// + /// Each rule should take one of these: + ///| Rule | Example | Matches Subdomain | + ///| -- | -- | -- | + ///| HOSTNAME | example.com | Yes | + ///| .HOSTNAME | .example.com | No | + ///| IPV4_LITERAL | 192.168.1.1 | No | + ///| IPV6_LITERAL_WITH_BRACKETS | [10:20:30:40:50:60:70:80] | No | + /// + ///All other rules, including wildcards, are invalid. The correct syntax for hosts is defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3.2.2). + /// + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SAFE_BROWSING_ALLOWLIST]. + /// + ///[hosts] represents the list of hosts. This value must never be `null`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.setSafeBrowsingAllowlist](https://developer.android.com/reference/androidx/webkit/WebViewCompat#setSafeBrowsingAllowlist(java.util.Set%3Cjava.lang.String%3E,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) + Future setSafeBrowsingAllowlist({required List hosts}) { + throw UnimplementedError( + 'setSafeBrowsingAllowlist is not implemented on the current platform'); + } + + ///If WebView has already been loaded into the current process this method will return the package that was used to load it. + ///Otherwise, the package that would be used if the WebView was loaded right now will be returned; + ///this does not cause WebView to be loaded, so this information may become outdated at any time. + ///The WebView package changes either when the current WebView package is updated, disabled, or uninstalled. + ///It can also be changed through a Developer Setting. If the WebView package changes, any app process that + ///has loaded WebView will be killed. + ///The next time the app starts and loads WebView it will use the new WebView package instead. + /// + ///**NOTE**: available only on Android 21+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.getCurrentWebViewPackage](https://developer.android.com/reference/androidx/webkit/WebViewCompat#getCurrentWebViewPackage(android.content.Context))) + Future getCurrentWebViewPackage() { + throw UnimplementedError( + 'getCurrentWebViewPackage is not implemented on the current platform'); + } + + ///Enables debugging of web contents (HTML / CSS / JavaScript) loaded into any WebViews of this application. + ///This flag can be enabled in order to facilitate debugging of web layouts and JavaScript code running inside WebViews. + ///Please refer to WebView documentation for the debugging guide. The default is `false`. + /// + ///[debuggingEnabled] whether to enable web contents debugging. + /// + ///**NOTE**: available only on Android 19+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.setWebContentsDebuggingEnabled](https://developer.android.com/reference/android/webkit/WebView#setWebContentsDebuggingEnabled(boolean))) + Future setWebContentsDebuggingEnabled(bool debuggingEnabled) { + throw UnimplementedError( + 'setWebContentsDebuggingEnabled is not implemented on the current platform'); + } + + ///Gets the WebView variations encoded to be used as the X-Client-Data HTTP header. + /// + ///The app is responsible for adding the X-Client-Data header to any request + ///that may use variations metadata, such as requests to Google web properties. + ///The returned string will be a base64 encoded ClientVariations proto: + ///https://source.chromium.org/chromium/chromium/src/+/main:components/variations/proto/client_variations.proto + /// + ///The string may be empty if the header is not available. + /// + ///**NOTE for Android native WebView**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.GET_VARIATIONS_HEADER]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.getVariationsHeader](https://developer.android.com/reference/androidx/webkit/WebViewCompat#getVariationsHeader())) + Future getVariationsHeader() { + throw UnimplementedError( + 'getVariationsHeader is not implemented on the current platform'); + } + + ///Returns `true` if WebView is running in multi process mode. + /// + ///In Android O and above, WebView may run in "multiprocess" mode. + ///In multiprocess mode, rendering of web content is performed by a sandboxed + ///renderer process separate to the application process. + ///This renderer process may be shared with other WebViews in the application, + ///but is not shared with other application processes. + /// + ///**NOTE for Android native WebView**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.MULTI_PROCESS]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebViewCompat.isMultiProcessEnabled](https://developer.android.com/reference/androidx/webkit/WebViewCompat#isMultiProcessEnabled())) + Future isMultiProcessEnabled() { + throw UnimplementedError( + 'isMultiProcessEnabled is not implemented on the current platform'); + } + + ///Indicate that the current process does not intend to use WebView, + ///and that an exception should be thrown if a WebView is created or any other + ///methods in the `android.webkit` package are used. + /// + ///Applications with multiple processes may wish to call this in processes that + ///are not intended to use WebView to avoid accidentally incurring the memory usage + ///of initializing WebView in long-lived processes that have no need for it, + ///and to prevent potential data directory conflicts (see [ProcessGlobalConfigSettings.dataDirectorySuffix]). + /// + ///**NOTE for Android**: available only on Android 28+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.disableWebView](https://developer.android.com/reference/android/webkit/WebView.html#disableWebView())) + Future disableWebView() { + throw UnimplementedError( + 'disableWebView is not implemented on the current platform'); + } + + ///Returns a Boolean value that indicates whether WebKit natively supports resources with the specified URL scheme. + /// + ///[urlScheme] represents the URL scheme associated with the resource. + /// + ///**NOTE for iOS**: available only on iOS 11.0+. + /// + ///**NOTE for MacOS**: available only on MacOS 10.13+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWebView.handlesURLScheme](https://developer.apple.com/documentation/webkit/wkwebview/2875370-handlesurlscheme)) + ///- MacOS ([Official API - WKWebView.handlesURLScheme](https://developer.apple.com/documentation/webkit/wkwebview/2875370-handlesurlscheme)) + Future handlesURLScheme(String urlScheme) { + throw UnimplementedError( + 'handlesURLScheme is not implemented on the current platform'); + } + + ///Disposes the WebView that is using the [keepAlive] instance + ///for the keep alive feature. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + Future disposeKeepAlive(InAppWebViewKeepAlive keepAlive) { + throw UnimplementedError( + 'disposeKeepAlive is not implemented on the current platform'); + } + + ///Gets the html (with javascript) of the Chromium's t-rex runner game. Used in combination with [tRexRunnerCss]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future get tRexRunnerHtml => throw UnimplementedError( + 'tRexRunnerHtml is not implemented on the current platform'); + + ///Gets the css of the Chromium's t-rex runner game. Used in combination with [tRexRunnerHtml]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future get tRexRunnerCss => throw UnimplementedError( + 'tRexRunnerCss is not implemented on the current platform'); + + ///Use [setSettings] instead. + @Deprecated('Use setSettings instead') + Future setOptions({required InAppWebViewGroupOptions options}) { + throw UnimplementedError( + 'setOptions is not implemented on the current platform'); + } + + ///Use [getSettings] instead. + @Deprecated('Use getSettings instead') + Future getOptions() { + throw UnimplementedError( + 'getOptions is not implemented on the current platform'); + } + + ///Use [PlatformFindInteractionController.findAll] instead. + @Deprecated("Use FindInteractionController.findAll instead") + Future findAllAsync({required String find}) { + throw UnimplementedError( + 'findAllAsync is not implemented on the current platform'); + } + + ///Use [PlatformFindInteractionController.findNext] instead. + @Deprecated("Use FindInteractionController.findNext instead") + Future findNext({required bool forward}) { + throw UnimplementedError( + 'findNext is not implemented on the current platform'); + } + + ///Use [PlatformFindInteractionController.clearMatches] instead. + @Deprecated("Use FindInteractionController.clearMatches instead") + Future clearMatches() { + throw UnimplementedError( + 'clearMatches is not implemented on the current platform'); + } + + ///Use [tRexRunnerHtml] instead. + @Deprecated("Use tRexRunnerHtml instead") + Future getTRexRunnerHtml() { + throw UnimplementedError( + 'getTRexRunnerHtml is not implemented on the current platform'); + } + + ///Use [tRexRunnerCss] instead. + @Deprecated("Use tRexRunnerCss instead") + Future getTRexRunnerCss() { + throw UnimplementedError( + 'getTRexRunnerCss is not implemented on the current platform'); + } + + ///Use [getZoomScale] instead. + @Deprecated('Use getZoomScale instead') + Future getScale() { + throw UnimplementedError( + 'getScale is not implemented on the current platform'); + } + + ///Use [setSafeBrowsingAllowlist] instead. + @Deprecated("Use setSafeBrowsingAllowlist instead") + Future setSafeBrowsingWhitelist({required List hosts}) { + throw UnimplementedError( + 'setSafeBrowsingWhitelist is not implemented on the current platform'); + } + + void dispose({bool isKeepAlive = false}) { + throw UnimplementedError( + 'dispose is not implemented on the current platform'); + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_widget.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_widget.dart new file mode 100644 index 00000000..e7440b03 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_widget.dart @@ -0,0 +1,224 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/gestures.dart'; +import 'package:flutter/widgets.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import '../inappwebview_platform.dart'; +import '../types/disposable.dart'; +import 'in_app_webview_keep_alive.dart'; +import 'platform_webview.dart'; +import 'platform_headless_in_app_webview.dart'; + +/// Object specifying creation parameters for creating a [PlatformInAppWebViewWidget]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +class PlatformInAppWebViewWidgetCreationParams + extends PlatformWebViewCreationParams { + /// Used by the platform implementation to create a new [PlatformInAppWebViewWidget]. + PlatformInAppWebViewWidgetCreationParams( + {this.key, + this.layoutDirection, + this.gestureRecognizers, + this.headlessWebView, + this.keepAlive, + this.preventGestureDelay, + super.windowId, + super.onWebViewCreated, + super.onLoadStart, + super.onLoadStop, + @Deprecated('Use onReceivedError instead') super.onLoadError, + super.onReceivedError, + @Deprecated("Use onReceivedHttpError instead") super.onLoadHttpError, + super.onReceivedHttpError, + super.onProgressChanged, + super.onConsoleMessage, + super.shouldOverrideUrlLoading, + super.onLoadResource, + super.onScrollChanged, + @Deprecated('Use onDownloadStartRequest instead') super.onDownloadStart, + super.onDownloadStartRequest, + @Deprecated('Use onLoadResourceWithCustomScheme instead') + super.onLoadResourceCustomScheme, + super.onLoadResourceWithCustomScheme, + super.onCreateWindow, + super.onCloseWindow, + super.onJsAlert, + super.onJsConfirm, + super.onJsPrompt, + super.onReceivedHttpAuthRequest, + super.onReceivedServerTrustAuthRequest, + super.onReceivedClientCertRequest, + @Deprecated('Use FindInteractionController.onFindResultReceived instead') + super.onFindResultReceived, + super.shouldInterceptAjaxRequest, + super.onAjaxReadyStateChange, + super.onAjaxProgress, + super.shouldInterceptFetchRequest, + super.onUpdateVisitedHistory, + @Deprecated("Use onPrintRequest instead") super.onPrint, + super.onPrintRequest, + super.onLongPressHitTestResult, + super.onEnterFullscreen, + super.onExitFullscreen, + super.onPageCommitVisible, + super.onTitleChanged, + super.onWindowFocus, + super.onWindowBlur, + super.onOverScrolled, + super.onZoomScaleChanged, + @Deprecated('Use onSafeBrowsingHit instead') + super.androidOnSafeBrowsingHit, + super.onSafeBrowsingHit, + @Deprecated('Use onPermissionRequest instead') + super.androidOnPermissionRequest, + super.onPermissionRequest, + @Deprecated('Use onGeolocationPermissionsShowPrompt instead') + super.androidOnGeolocationPermissionsShowPrompt, + super.onGeolocationPermissionsShowPrompt, + @Deprecated('Use onGeolocationPermissionsHidePrompt instead') + super.androidOnGeolocationPermissionsHidePrompt, + super.onGeolocationPermissionsHidePrompt, + @Deprecated('Use shouldInterceptRequest instead') + super.androidShouldInterceptRequest, + super.shouldInterceptRequest, + @Deprecated('Use onRenderProcessGone instead') + super.androidOnRenderProcessGone, + super.onRenderProcessGone, + @Deprecated('Use onRenderProcessResponsive instead') + super.androidOnRenderProcessResponsive, + super.onRenderProcessResponsive, + @Deprecated('Use onRenderProcessUnresponsive instead') + super.androidOnRenderProcessUnresponsive, + super.onRenderProcessUnresponsive, + @Deprecated('Use onFormResubmission instead') + super.androidOnFormResubmission, + super.onFormResubmission, + @Deprecated('Use onZoomScaleChanged instead') super.androidOnScaleChanged, + @Deprecated('Use onReceivedIcon instead') super.androidOnReceivedIcon, + super.onReceivedIcon, + @Deprecated('Use onReceivedTouchIconUrl instead') + super.androidOnReceivedTouchIconUrl, + super.onReceivedTouchIconUrl, + @Deprecated('Use onJsBeforeUnload instead') super.androidOnJsBeforeUnload, + super.onJsBeforeUnload, + @Deprecated('Use onReceivedLoginRequest instead') + super.androidOnReceivedLoginRequest, + super.onReceivedLoginRequest, + super.onPermissionRequestCanceled, + super.onRequestFocus, + @Deprecated('Use onWebContentProcessDidTerminate instead') + super.iosOnWebContentProcessDidTerminate, + super.onWebContentProcessDidTerminate, + @Deprecated( + 'Use onDidReceiveServerRedirectForProvisionalNavigation instead') + super.iosOnDidReceiveServerRedirectForProvisionalNavigation, + super.onDidReceiveServerRedirectForProvisionalNavigation, + @Deprecated('Use onNavigationResponse instead') + super.iosOnNavigationResponse, + super.onNavigationResponse, + @Deprecated('Use shouldAllowDeprecatedTLS instead') + super.iosShouldAllowDeprecatedTLS, + super.shouldAllowDeprecatedTLS, + super.onCameraCaptureStateChanged, + super.onMicrophoneCaptureStateChanged, + super.onContentSizeChanged, + super.initialUrlRequest, + super.initialFile, + super.initialData, + @Deprecated('Use initialSettings instead') super.initialOptions, + super.initialSettings, + super.contextMenu, + super.initialUserScripts, + super.pullToRefreshController, + super.findInteractionController}); + + /// Controls how one widget replaces another widget in the tree. + /// + /// See also: + /// + /// * The discussions at [Key] and [GlobalKey]. + final Key? key; + + /// The layout direction to use for the embedded WebView. + final TextDirection? layoutDirection; + + /// The `gestureRecognizers` specifies which gestures should be consumed by the + /// web view. + /// + /// It is possible for other gesture recognizers to be competing with the web + /// view on pointer events, e.g. if the web view is inside a [ListView] the + /// [ListView] will want to handle vertical drags. The web view will claim + /// gestures that are recognized by any of the recognizers on this list. + /// + /// When `gestureRecognizers` is empty (default), the web view will only handle + /// pointer events for gestures that were not claimed by any other gesture + /// recognizer. + final Set>? gestureRecognizers; + + ///The [PlatformHeadlessInAppWebView] to use to initialize this widget. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- Web + final PlatformHeadlessInAppWebView? headlessWebView; + + ///Used to keep alive this WebView. + ///Remember to dispose the [InAppWebViewKeepAlive] instance + ///using [InAppWebViewController.disposeKeepAlive]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + final InAppWebViewKeepAlive? keepAlive; + + ///Used to prevent gesture delay on iOS caused by Flutter's gestures handling + ///between native/platform views. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + final bool? preventGestureDelay; +} + +/// Interface for a platform implementation of a web view widget. +abstract class PlatformInAppWebViewWidget extends PlatformInterface + implements Disposable { + + /// Creates a new [PlatformInAppWebViewWidget] + factory PlatformInAppWebViewWidget( + PlatformInAppWebViewWidgetCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformInAppWebViewWidget webViewWidgetDelegate = + InAppWebViewPlatform.instance!.createPlatformInAppWebViewWidget(params); + PlatformInterface.verify(webViewWidgetDelegate, _token); + return webViewWidgetDelegate; + } + + /// Used by the platform implementation to create a new + /// [PlatformInAppWebViewWidget]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformInAppWebViewWidget.implementation(this.params) : super(token: _token); + + static final Object _token = Object(); + + /// The parameters used to initialize the [PlatformInAppWebViewWidget]. + final PlatformInAppWebViewWidgetCreationParams params; + + /// Builds a new WebView. + /// + /// Returns a Widget tree that embeds the created web view. + Widget build(BuildContext context); + + @override + void dispose(); +} diff --git a/lib/src/in_app_webview/webview.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart similarity index 89% rename from lib/src/in_app_webview/webview.dart rename to flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart index 65ba1522..44e397a2 100644 --- a/lib/src/in_app_webview/webview.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart @@ -2,36 +2,21 @@ import 'dart:collection'; import 'dart:typed_data'; import 'dart:ui'; -import '../find_interaction/find_interaction_controller.dart'; -import '../pull_to_refresh/pull_to_refresh_controller.dart'; +import '../find_interaction/platform_find_interaction_controller.dart'; +import '../pull_to_refresh/platform_pull_to_refresh_controller.dart'; import '../context_menu/context_menu.dart'; import '../types/main.dart'; import '../web_uri.dart'; -import 'in_app_webview_controller.dart'; import 'in_app_webview_settings.dart'; -import 'headless_in_app_webview.dart'; -import 'in_app_webview.dart'; -import '../in_app_browser/in_app_browser.dart'; +import 'platform_inappwebview_controller.dart'; import '../print_job/main.dart'; -import '../debug_logging_settings.dart'; - ///{@template flutter_inappwebview.WebView} -///Abstract class that represents a WebView. Used by [InAppWebView], [HeadlessInAppWebView] and the WebView of [InAppBrowser]. +///Class that represents a WebView. Used by [InAppWebView], [HeadlessInAppWebView] and the WebView of [PlatformInAppBrowser]. ///{@endtemplate} -abstract class WebView { - ///Debug settings used by [InAppWebView], [HeadlessInAppWebView] and [InAppBrowser]. - ///The default value excludes the [WebView.onScrollChanged], [WebView.onOverScrolled] and [WebView.onReceivedIcon] events. - static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings( - maxLogMessageLength: 1000, - excludeFilter: [ - RegExp(r"onScrollChanged"), - RegExp(r"onOverScrolled"), - RegExp(r"onReceivedIcon") - ]); - +class PlatformWebViewCreationParams { ///{@template flutter_inappwebview.WebView.windowId} ///The window id of a [CreateWindowAction.windowId]. /// @@ -43,7 +28,7 @@ abstract class WebView { final int? windowId; ///{@template flutter_inappwebview.WebView.onWebViewCreated} - ///Event fired when the [WebView] is created. + ///Event fired when the `WebView` is created. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -51,10 +36,10 @@ abstract class WebView { ///- MacOS ///- Web ///{@endtemplate} - final void Function(InAppWebViewController controller)? onWebViewCreated; + final void Function(PlatformInAppWebViewController controller)? onWebViewCreated; ///{@template flutter_inappwebview.WebView.onLoadStart} - ///Event fired when the [WebView] starts to load an [url]. + ///Event fired when the `WebView` starts to load an [url]. /// ///**NOTE for Web**: it will be dispatched at the same time of [onLoadStop] event ///because there isn't any way to capture the real load start event from an iframe. @@ -67,11 +52,11 @@ abstract class WebView { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview)) ///- Web ///{@endtemplate} - final void Function(InAppWebViewController controller, WebUri? url)? + final void Function(PlatformInAppWebViewController controller, WebUri? url)? onLoadStart; ///{@template flutter_inappwebview.WebView.onLoadStop} - ///Event fired when the [WebView] finishes loading an [url]. + ///Event fired when the `WebView` finishes loading an [url]. /// ///**NOTE for Web**: If `window.location.href` isn't accessible inside the iframe, ///the [url] parameter will have the current value of the `iframe.src` attribute. @@ -82,32 +67,32 @@ abstract class WebView { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview)) ///- Web ([Official API - Window.onload](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event)) ///{@endtemplate} - final void Function(InAppWebViewController controller, WebUri? url)? + final void Function(PlatformInAppWebViewController controller, WebUri? url)? onLoadStop; ///Use [onReceivedError] instead. @Deprecated("Use onReceivedError instead") - final void Function(InAppWebViewController controller, Uri? url, int code, + final void Function(PlatformInAppWebViewController controller, Uri? url, int code, String message)? onLoadError; ///{@template flutter_inappwebview.WebView.onReceivedError} - ///Event fired when the [WebView] encounters an [error] loading a [request]. + ///Event fired when the `WebView` encounters an [error] loading a [request]. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onReceivedError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError))) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview)) ///{@endtemplate} - final void Function(InAppWebViewController controller, + final void Function(PlatformInAppWebViewController controller, WebResourceRequest request, WebResourceError error)? onReceivedError; ///Use [onReceivedHttpError] instead. @Deprecated("Use onReceivedHttpError instead") - final void Function(InAppWebViewController controller, Uri? url, + final void Function(PlatformInAppWebViewController controller, Uri? url, int statusCode, String description)? onLoadHttpError; ///{@template flutter_inappwebview.WebView.onReceivedHttpError} - ///Event fired when the [WebView] receives an HTTP error. + ///Event fired when the `WebView` receives an HTTP error. /// ///[request] represents the originating request. /// @@ -121,7 +106,7 @@ abstract class WebView { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview)) ///{@endtemplate} final void Function( - InAppWebViewController controller, + PlatformInAppWebViewController controller, WebResourceRequest request, WebResourceResponse errorResponse)? onReceivedHttpError; @@ -133,11 +118,11 @@ abstract class WebView { ///- iOS ///- MacOS ///{@endtemplate} - final void Function(InAppWebViewController controller, int progress)? + final void Function(PlatformInAppWebViewController controller, int progress)? onProgressChanged; ///{@template flutter_inappwebview.WebView.onConsoleMessage} - ///Event fired when the [WebView] receives a [ConsoleMessage]. + ///Event fired when the `WebView` receives a [ConsoleMessage]. /// ///**NOTE for Web**: this event will be called only if the iframe has the same origin. /// @@ -148,7 +133,7 @@ abstract class WebView { ///- Web ///{@endtemplate} final void Function( - InAppWebViewController controller, ConsoleMessage consoleMessage)? + PlatformInAppWebViewController controller, ConsoleMessage consoleMessage)? onConsoleMessage; ///{@template flutter_inappwebview.WebView.shouldOverrideUrlLoading} @@ -171,11 +156,11 @@ abstract class WebView { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview)) ///{@endtemplate} final Future Function( - InAppWebViewController controller, NavigationAction navigationAction)? + PlatformInAppWebViewController controller, NavigationAction navigationAction)? shouldOverrideUrlLoading; ///{@template flutter_inappwebview.WebView.onLoadResource} - ///Event fired when the [WebView] loads a resource. + ///Event fired when the `WebView` loads a resource. /// ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnLoadResource] and [InAppWebViewSettings.javaScriptEnabled] setting to `true`. /// @@ -185,11 +170,11 @@ abstract class WebView { ///- MacOS ///{@endtemplate} final void Function( - InAppWebViewController controller, LoadedResource resource)? + PlatformInAppWebViewController controller, LoadedResource resource)? onLoadResource; ///{@template flutter_inappwebview.WebView.onScrollChanged} - ///Event fired when the [WebView] scrolls. + ///Event fired when the `WebView` scrolls. /// ///[x] represents the current horizontal scroll origin in pixels. /// @@ -205,16 +190,16 @@ abstract class WebView { ///- Web ([Official API - Window.onscroll](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onscroll)) ///- MacOS ///{@endtemplate} - final void Function(InAppWebViewController controller, int x, int y)? + final void Function(PlatformInAppWebViewController controller, int x, int y)? onScrollChanged; ///Use [onDownloadStartRequest] instead @Deprecated('Use onDownloadStartRequest instead') - final void Function(InAppWebViewController controller, Uri url)? + final void Function(PlatformInAppWebViewController controller, Uri url)? onDownloadStart; ///{@template flutter_inappwebview.WebView.onDownloadStartRequest} - ///Event fired when [WebView] recognizes a downloadable file. + ///Event fired when `WebView` recognizes a downloadable file. ///To download the file, you can use the [flutter_downloader](https://pub.dev/packages/flutter_downloader) plugin. /// ///[downloadStartRequest] represents the request of the file to download. @@ -226,16 +211,16 @@ abstract class WebView { ///- iOS ///- MacOS ///{@endtemplate} - final void Function(InAppWebViewController controller, + final void Function(PlatformInAppWebViewController controller, DownloadStartRequest downloadStartRequest)? onDownloadStartRequest; ///Use [onLoadResourceWithCustomScheme] instead. @Deprecated('Use onLoadResourceWithCustomScheme instead') final Future Function( - InAppWebViewController controller, Uri url)? onLoadResourceCustomScheme; + PlatformInAppWebViewController controller, Uri url)? onLoadResourceCustomScheme; ///{@template flutter_inappwebview.WebView.onLoadResourceWithCustomScheme} - ///Event fired when the [WebView] finds the `custom-scheme` while loading a resource. + ///Event fired when the `WebView` finds the `custom-scheme` while loading a resource. ///Here you can handle the url [request] and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`. /// ///**Supported Platforms/Implementations**: @@ -244,11 +229,11 @@ abstract class WebView { ///- MacOS ([Official API - WKURLSchemeHandler](https://developer.apple.com/documentation/webkit/wkurlschemehandler)) ///{@endtemplate} final Future Function( - InAppWebViewController controller, WebResourceRequest request)? + PlatformInAppWebViewController controller, WebResourceRequest request)? onLoadResourceWithCustomScheme; ///{@template flutter_inappwebview.WebView.onCreateWindow} - ///Event fired when the [WebView] requests the host application to create a new window, + ///Event fired when the `WebView` requests the host application to create a new window, ///for example when trying to open a link with `target="_blank"` or when `window.open()` is called by JavaScript side. ///If the host application chooses to honor this request, it should return `true` from this method, create a new WebView to host the window. ///If the host application chooses not to honor the request, it should return `false` from this method. @@ -286,7 +271,7 @@ abstract class WebView { ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview)) ///- Web ///{@endtemplate} - final Future Function(InAppWebViewController controller, + final Future Function(PlatformInAppWebViewController controller, CreateWindowAction createWindowAction)? onCreateWindow; ///{@template flutter_inappwebview.WebView.onCloseWindow} @@ -298,7 +283,7 @@ abstract class WebView { ///- iOS ([Official API - WKUIDelegate.webViewDidClose](https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose)) ///- MacOS ([Official API - WKUIDelegate.webViewDidClose](https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose)) ///{@endtemplate} - final void Function(InAppWebViewController controller)? onCloseWindow; + final void Function(PlatformInAppWebViewController controller)? onCloseWindow; ///{@template flutter_inappwebview.WebView.onWindowFocus} ///Event fired when the JavaScript `window` object of the WebView has received focus. @@ -312,7 +297,7 @@ abstract class WebView { ///- MacOS ///- Web ([Official API - Window.onfocus](https://developer.mozilla.org/en-US/docs/Web/API/Window/focus_event)) ///{@endtemplate} - final void Function(InAppWebViewController controller)? onWindowFocus; + final void Function(PlatformInAppWebViewController controller)? onWindowFocus; ///{@template flutter_inappwebview.WebView.onWindowBlur} ///Event fired when the JavaScript `window` object of the WebView has lost focus. @@ -326,7 +311,7 @@ abstract class WebView { ///- MacOS ///- Web ([Official API - Window.onblur](https://developer.mozilla.org/en-US/docs/Web/API/Window/blur_event)) ///{@endtemplate} - final void Function(InAppWebViewController controller)? onWindowBlur; + final void Function(PlatformInAppWebViewController controller)? onWindowBlur; ///{@template flutter_inappwebview.WebView.onJsAlert} ///Event fired when javascript calls the `alert()` method to display an alert dialog. @@ -340,7 +325,7 @@ abstract class WebView { ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview)) ///{@endtemplate} final Future Function( - InAppWebViewController controller, JsAlertRequest jsAlertRequest)? + PlatformInAppWebViewController controller, JsAlertRequest jsAlertRequest)? onJsAlert; ///{@template flutter_inappwebview.WebView.onJsConfirm} @@ -355,7 +340,7 @@ abstract class WebView { ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview)) ///{@endtemplate} final Future Function( - InAppWebViewController controller, JsConfirmRequest jsConfirmRequest)? + PlatformInAppWebViewController controller, JsConfirmRequest jsConfirmRequest)? onJsConfirm; ///{@template flutter_inappwebview.WebView.onJsPrompt} @@ -370,7 +355,7 @@ abstract class WebView { ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview)) ///{@endtemplate} final Future Function( - InAppWebViewController controller, JsPromptRequest jsPromptRequest)? + PlatformInAppWebViewController controller, JsPromptRequest jsPromptRequest)? onJsPrompt; ///{@template flutter_inappwebview.WebView.onReceivedHttpAuthRequest} @@ -383,7 +368,7 @@ abstract class WebView { ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) ///{@endtemplate} - final Future Function(InAppWebViewController controller, + final Future Function(PlatformInAppWebViewController controller, HttpAuthenticationChallenge challenge)? onReceivedHttpAuthRequest; ///{@template flutter_inappwebview.WebView.onReceivedServerTrustAuthRequest} @@ -398,7 +383,7 @@ abstract class WebView { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) ///{@endtemplate} final Future Function( - InAppWebViewController controller, ServerTrustChallenge challenge)? + PlatformInAppWebViewController controller, ServerTrustChallenge challenge)? onReceivedServerTrustAuthRequest; ///{@template flutter_inappwebview.WebView.onReceivedClientCertRequest} @@ -415,12 +400,12 @@ abstract class WebView { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) ///{@endtemplate} final Future Function( - InAppWebViewController controller, ClientCertChallenge challenge)? + PlatformInAppWebViewController controller, ClientCertChallenge challenge)? onReceivedClientCertRequest; ///Use [FindInteractionController.onFindResultReceived] instead. @Deprecated('Use FindInteractionController.onFindResultReceived instead') - final void Function(InAppWebViewController controller, int activeMatchOrdinal, + final void Function(PlatformInAppWebViewController controller, int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting)? onFindResultReceived; ///{@template flutter_inappwebview.WebView.shouldInterceptAjaxRequest} @@ -441,7 +426,7 @@ abstract class WebView { ///- MacOS ///{@endtemplate} final Future Function( - InAppWebViewController controller, AjaxRequest ajaxRequest)? + PlatformInAppWebViewController controller, AjaxRequest ajaxRequest)? shouldInterceptAjaxRequest; ///{@template flutter_inappwebview.WebView.onAjaxReadyStateChange} @@ -462,7 +447,7 @@ abstract class WebView { ///- MacOS ///{@endtemplate} final Future Function( - InAppWebViewController controller, AjaxRequest ajaxRequest)? + PlatformInAppWebViewController controller, AjaxRequest ajaxRequest)? onAjaxReadyStateChange; ///{@template flutter_inappwebview.WebView.onAjaxProgress} @@ -483,7 +468,7 @@ abstract class WebView { ///- MacOS ///{@endtemplate} final Future Function( - InAppWebViewController controller, AjaxRequest ajaxRequest)? + PlatformInAppWebViewController controller, AjaxRequest ajaxRequest)? onAjaxProgress; ///{@template flutter_inappwebview.WebView.shouldInterceptFetchRequest} @@ -504,12 +489,12 @@ abstract class WebView { ///- MacOS ///{@endtemplate} final Future Function( - InAppWebViewController controller, FetchRequest fetchRequest)? + PlatformInAppWebViewController controller, FetchRequest fetchRequest)? shouldInterceptFetchRequest; ///{@template flutter_inappwebview.WebView.onUpdateVisitedHistory} ///Event fired when the host application updates its visited links database. - ///This event is also fired when the navigation state of the [WebView] changes through the usage of + ///This event is also fired when the navigation state of the `WebView` changes through the usage of ///javascript **[History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API)** functions (`pushState()`, `replaceState()`) and `onpopstate` event ///or, also, when the javascript `window.location` changes without reloading the webview (for example appending or modifying a hash to the url). /// @@ -526,17 +511,17 @@ abstract class WebView { ///- Web ///{@endtemplate} final void Function( - InAppWebViewController controller, WebUri? url, bool? isReload)? + PlatformInAppWebViewController controller, WebUri? url, bool? isReload)? onUpdateVisitedHistory; ///Use [onPrintRequest] instead @Deprecated("Use onPrintRequest instead") - final void Function(InAppWebViewController controller, Uri? url)? onPrint; + final void Function(PlatformInAppWebViewController controller, Uri? url)? onPrint; ///{@template flutter_inappwebview.WebView.onPrintRequest} ///Event fired when `window.print()` is called from JavaScript side. ///Return `true` if you want to handle the print job. - ///Otherwise return `false`, so the [PrintJobController] will be handled and disposed automatically by the system. + ///Otherwise return `false`, so the [PlatformPrintJobController] will be handled and disposed automatically by the system. /// ///[url] represents the url on which is called. /// @@ -551,8 +536,8 @@ abstract class WebView { ///- MacOS ///- Web ///{@endtemplate} - final Future Function(InAppWebViewController controller, WebUri? url, - PrintJobController? printJobController)? onPrintRequest; + final Future Function(PlatformInAppWebViewController controller, WebUri? url, + PlatformPrintJobController? printJobController)? onPrintRequest; ///{@template flutter_inappwebview.WebView.onLongPressHitTestResult} ///Event fired when an HTML element of the webview has been clicked and held. @@ -563,7 +548,7 @@ abstract class WebView { ///- Android native WebView ([Official API - View.setOnLongClickListener](https://developer.android.com/reference/android/view/View#setOnLongClickListener(android.view.View.OnLongClickListener))) ///- iOS ([Official API - UILongPressGestureRecognizer](https://developer.apple.com/documentation/uikit/uilongpressgesturerecognizer)) ///{@endtemplate} - final void Function(InAppWebViewController controller, + final void Function(PlatformInAppWebViewController controller, InAppWebViewHitTestResult hitTestResult)? onLongPressHitTestResult; ///{@template flutter_inappwebview.WebView.onEnterFullscreen} @@ -575,7 +560,7 @@ abstract class WebView { ///- MacOS ([Official API - NSWindow.didEnterFullScreenNotification](https://developer.apple.com/documentation/appkit/nswindow/1419651-didenterfullscreennotification)) ///- Web ([Official API - Document.onfullscreenchange](https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenchange_event)) ///{@endtemplate} - final void Function(InAppWebViewController controller)? onEnterFullscreen; + final void Function(PlatformInAppWebViewController controller)? onEnterFullscreen; ///{@template flutter_inappwebview.WebView.onExitFullscreen} ///Event fired when the current page has exited full screen mode. @@ -590,7 +575,7 @@ abstract class WebView { ///- MacOS ([Official API - NSWindow.didExitFullScreenNotification](https://developer.apple.com/documentation/appkit/nswindow/1419177-didexitfullscreennotification)) ///- Web ([Official API - Document.onfullscreenchange](https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenchange_event)) ///{@endtemplate} - final void Function(InAppWebViewController controller)? onExitFullscreen; + final void Function(PlatformInAppWebViewController controller)? onExitFullscreen; ///{@template flutter_inappwebview.WebView.onPageCommitVisible} ///Called when the web view begins to receive web content. @@ -605,7 +590,7 @@ abstract class WebView { ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview)) ///{@endtemplate} - final void Function(InAppWebViewController controller, WebUri? url)? + final void Function(PlatformInAppWebViewController controller, WebUri? url)? onPageCommitVisible; ///{@template flutter_inappwebview.WebView.onTitleChanged} @@ -621,7 +606,7 @@ abstract class WebView { ///- MacOS ///- Web ///{@endtemplate} - final void Function(InAppWebViewController controller, String? title)? + final void Function(PlatformInAppWebViewController controller, String? title)? onTitleChanged; ///{@template flutter_inappwebview.WebView.onOverScrolled} @@ -639,7 +624,7 @@ abstract class WebView { ///- Android native WebView ([Official API - WebView.onOverScrolled](https://developer.android.com/reference/android/webkit/WebView#onOverScrolled(int,%20int,%20boolean,%20boolean))) ///- iOS ///{@endtemplate} - final void Function(InAppWebViewController controller, int x, int y, + final void Function(PlatformInAppWebViewController controller, int x, int y, bool clampedX, bool clampedY)? onOverScrolled; ///{@template flutter_inappwebview.WebView.onZoomScaleChanged} @@ -657,13 +642,13 @@ abstract class WebView { ///- Web ///{@endtemplate} final void Function( - InAppWebViewController controller, double oldScale, double newScale)? + PlatformInAppWebViewController controller, double oldScale, double newScale)? onZoomScaleChanged; ///Use [onSafeBrowsingHit] instead. @Deprecated("Use onSafeBrowsingHit instead") final Future Function( - InAppWebViewController controller, + PlatformInAppWebViewController controller, Uri url, SafeBrowsingThreat? threatType)? androidOnSafeBrowsingHit; @@ -681,14 +666,14 @@ abstract class WebView { ///- Android native WebView ([Official API - WebViewClient.onSafeBrowsingHit](https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse))) ///{@endtemplate} final Future Function( - InAppWebViewController controller, + PlatformInAppWebViewController controller, WebUri url, SafeBrowsingThreat? threatType)? onSafeBrowsingHit; ///Use [onPermissionRequest] instead. @Deprecated("Use onPermissionRequest instead") final Future Function( - InAppWebViewController controller, + PlatformInAppWebViewController controller, String origin, List resources)? androidOnPermissionRequest; @@ -709,13 +694,13 @@ abstract class WebView { ///- iOS ///- MacOS ///{@endtemplate} - final Future Function(InAppWebViewController controller, + final Future Function(PlatformInAppWebViewController controller, PermissionRequest permissionRequest)? onPermissionRequest; ///Use [onGeolocationPermissionsShowPrompt] instead. @Deprecated("Use onGeolocationPermissionsShowPrompt instead") final Future Function( - InAppWebViewController controller, String origin)? + PlatformInAppWebViewController controller, String origin)? androidOnGeolocationPermissionsShowPrompt; ///{@template flutter_inappwebview.WebView.onGeolocationPermissionsShowPrompt} @@ -729,12 +714,12 @@ abstract class WebView { ///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsShowPrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback))) ///{@endtemplate} final Future Function( - InAppWebViewController controller, String origin)? + PlatformInAppWebViewController controller, String origin)? onGeolocationPermissionsShowPrompt; ///Use [onGeolocationPermissionsHidePrompt] instead. @Deprecated("Use onGeolocationPermissionsHidePrompt instead") - final void Function(InAppWebViewController controller)? + final void Function(PlatformInAppWebViewController controller)? androidOnGeolocationPermissionsHidePrompt; ///{@template flutter_inappwebview.WebView.onGeolocationPermissionsHidePrompt} @@ -744,13 +729,13 @@ abstract class WebView { ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsHidePrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsHidePrompt())) ///{@endtemplate} - final void Function(InAppWebViewController controller)? + final void Function(PlatformInAppWebViewController controller)? onGeolocationPermissionsHidePrompt; ///Use [shouldInterceptRequest] instead. @Deprecated("Use shouldInterceptRequest instead") final Future Function( - InAppWebViewController controller, WebResourceRequest request)? + PlatformInAppWebViewController controller, WebResourceRequest request)? androidShouldInterceptRequest; ///{@template flutter_inappwebview.WebView.shouldInterceptRequest} @@ -772,13 +757,13 @@ abstract class WebView { ///- Android native WebView ([Official API - WebViewClient.shouldInterceptRequest](https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest))) ///{@endtemplate} final Future Function( - InAppWebViewController controller, WebResourceRequest request)? + PlatformInAppWebViewController controller, WebResourceRequest request)? shouldInterceptRequest; ///Use [onRenderProcessUnresponsive] instead. @Deprecated("Use onRenderProcessUnresponsive instead") final Future Function( - InAppWebViewController controller, Uri? url)? + PlatformInAppWebViewController controller, Uri? url)? androidOnRenderProcessUnresponsive; ///{@template flutter_inappwebview.WebView.onRenderProcessUnresponsive} @@ -803,13 +788,13 @@ abstract class WebView { ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessUnresponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) ///{@endtemplate} final Future Function( - InAppWebViewController controller, WebUri? url)? + PlatformInAppWebViewController controller, WebUri? url)? onRenderProcessUnresponsive; ///Use [onRenderProcessResponsive] instead. @Deprecated("Use onRenderProcessResponsive instead") final Future Function( - InAppWebViewController controller, Uri? url)? + PlatformInAppWebViewController controller, Uri? url)? androidOnRenderProcessResponsive; ///{@template flutter_inappwebview.WebView.onRenderProcessResponsive} @@ -827,13 +812,13 @@ abstract class WebView { ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessResponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) ///{@endtemplate} final Future Function( - InAppWebViewController controller, WebUri? url)? + PlatformInAppWebViewController controller, WebUri? url)? onRenderProcessResponsive; ///Use [onRenderProcessGone] instead. @Deprecated("Use onRenderProcessGone instead") final void Function( - InAppWebViewController controller, RenderProcessGoneDetail detail)? + PlatformInAppWebViewController controller, RenderProcessGoneDetail detail)? androidOnRenderProcessGone; ///{@template flutter_inappwebview.WebView.onRenderProcessGone} @@ -849,13 +834,13 @@ abstract class WebView { ///- Android native WebView ([Official API - WebViewClient.onRenderProcessGone](https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail))) ///{@endtemplate} final void Function( - InAppWebViewController controller, RenderProcessGoneDetail detail)? + PlatformInAppWebViewController controller, RenderProcessGoneDetail detail)? onRenderProcessGone; ///Use [onFormResubmission] instead. @Deprecated('Use onFormResubmission instead') final Future Function( - InAppWebViewController controller, Uri? url)? androidOnFormResubmission; + PlatformInAppWebViewController controller, Uri? url)? androidOnFormResubmission; ///{@template flutter_inappwebview.WebView.onFormResubmission} ///As the host application if the browser should resend data as the requested page was a result of a POST. The default is to not resend the data. @@ -864,17 +849,17 @@ abstract class WebView { ///- Android native WebView ([Official API - WebViewClient.onFormResubmission](https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message))) ///{@endtemplate} final Future Function( - InAppWebViewController controller, WebUri? url)? onFormResubmission; + PlatformInAppWebViewController controller, WebUri? url)? onFormResubmission; ///Use [onZoomScaleChanged] instead. @Deprecated('Use onZoomScaleChanged instead') final void Function( - InAppWebViewController controller, double oldScale, double newScale)? + PlatformInAppWebViewController controller, double oldScale, double newScale)? androidOnScaleChanged; ///Use [onReceivedIcon] instead. @Deprecated('Use onReceivedIcon instead') - final void Function(InAppWebViewController controller, Uint8List icon)? + final void Function(PlatformInAppWebViewController controller, Uint8List icon)? androidOnReceivedIcon; ///{@template flutter_inappwebview.WebView.onReceivedIcon} @@ -885,13 +870,13 @@ abstract class WebView { ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onReceivedIcon](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap))) ///{@endtemplate} - final void Function(InAppWebViewController controller, Uint8List icon)? + final void Function(PlatformInAppWebViewController controller, Uint8List icon)? onReceivedIcon; ///Use [onReceivedTouchIconUrl] instead. @Deprecated('Use onReceivedTouchIconUrl instead') final void Function( - InAppWebViewController controller, Uri url, bool precomposed)? + PlatformInAppWebViewController controller, Uri url, bool precomposed)? androidOnReceivedTouchIconUrl; ///{@template flutter_inappwebview.WebView.onReceivedTouchIconUrl} @@ -905,13 +890,13 @@ abstract class WebView { ///- Android native WebView ([Official API - WebChromeClient.onReceivedTouchIconUrl](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean))) ///{@endtemplate} final void Function( - InAppWebViewController controller, WebUri url, bool precomposed)? + PlatformInAppWebViewController controller, WebUri url, bool precomposed)? onReceivedTouchIconUrl; ///Use [onJsBeforeUnload] instead. @Deprecated('Use onJsBeforeUnload instead') final Future Function( - InAppWebViewController controller, + PlatformInAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? androidOnJsBeforeUnload; ///{@template flutter_inappwebview.WebView.onJsBeforeUnload} @@ -929,13 +914,13 @@ abstract class WebView { ///- Android native WebView ([Official API - WebChromeClient.onJsBeforeUnload](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsBeforeUnload(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult))) ///{@endtemplate} final Future Function( - InAppWebViewController controller, + PlatformInAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload; ///Use [onReceivedLoginRequest] instead. @Deprecated('Use onReceivedLoginRequest instead') final void Function( - InAppWebViewController controller, LoginRequest loginRequest)? + PlatformInAppWebViewController controller, LoginRequest loginRequest)? androidOnReceivedLoginRequest; ///{@template flutter_inappwebview.WebView.onReceivedLoginRequest} @@ -947,7 +932,7 @@ abstract class WebView { ///- Android native WebView ([Official API - WebViewClient.onReceivedLoginRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedLoginRequest(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String))) ///{@endtemplate} final void Function( - InAppWebViewController controller, LoginRequest loginRequest)? + PlatformInAppWebViewController controller, LoginRequest loginRequest)? onReceivedLoginRequest; ///{@template flutter_inappwebview.WebView.onPermissionRequestCanceled} @@ -962,7 +947,7 @@ abstract class WebView { ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onPermissionRequestCanceled](https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequestCanceled(android.webkit.PermissionRequest))) ///{@endtemplate} - final void Function(InAppWebViewController controller, + final void Function(PlatformInAppWebViewController controller, PermissionRequest permissionRequest)? onPermissionRequestCanceled; ///{@template flutter_inappwebview.WebView.onRequestFocus} @@ -972,11 +957,11 @@ abstract class WebView { ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onRequestFocus](https://developer.android.com/reference/android/webkit/WebChromeClient#onRequestFocus(android.webkit.WebView))) ///{@endtemplate} - final void Function(InAppWebViewController controller)? onRequestFocus; + final void Function(PlatformInAppWebViewController controller)? onRequestFocus; ///Use [onWebContentProcessDidTerminate] instead. @Deprecated('Use onWebContentProcessDidTerminate instead') - final void Function(InAppWebViewController controller)? + final void Function(PlatformInAppWebViewController controller)? iosOnWebContentProcessDidTerminate; ///{@template flutter_inappwebview.WebView.onWebContentProcessDidTerminate} @@ -986,12 +971,12 @@ abstract class WebView { ///- iOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi)) ///- MacOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi)) ///{@endtemplate} - final void Function(InAppWebViewController controller)? + final void Function(PlatformInAppWebViewController controller)? onWebContentProcessDidTerminate; ///Use [onDidReceiveServerRedirectForProvisionalNavigation] instead. @Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead') - final void Function(InAppWebViewController controller)? + final void Function(PlatformInAppWebViewController controller)? iosOnDidReceiveServerRedirectForProvisionalNavigation; ///{@template flutter_inappwebview.WebView.onDidReceiveServerRedirectForProvisionalNavigation} @@ -1001,13 +986,13 @@ abstract class WebView { ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview)) ///{@endtemplate} - final void Function(InAppWebViewController controller)? + final void Function(PlatformInAppWebViewController controller)? onDidReceiveServerRedirectForProvisionalNavigation; ///Use [onNavigationResponse] instead. @Deprecated('Use onNavigationResponse instead') final Future Function( - InAppWebViewController controller, + PlatformInAppWebViewController controller, IOSWKNavigationResponse navigationResponse)? iosOnNavigationResponse; ///{@template flutter_inappwebview.WebView.onNavigationResponse} @@ -1022,13 +1007,13 @@ abstract class WebView { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview)) ///{@endtemplate} final Future Function( - InAppWebViewController controller, + PlatformInAppWebViewController controller, NavigationResponse navigationResponse)? onNavigationResponse; ///Use [shouldAllowDeprecatedTLS] instead. @Deprecated('Use shouldAllowDeprecatedTLS instead') final Future Function( - InAppWebViewController controller, + PlatformInAppWebViewController controller, URLAuthenticationChallenge challenge)? iosShouldAllowDeprecatedTLS; ///{@template flutter_inappwebview.WebView.shouldAllowDeprecatedTLS} @@ -1045,7 +1030,7 @@ abstract class WebView { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview)) ///{@endtemplate} final Future Function( - InAppWebViewController controller, + PlatformInAppWebViewController controller, URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS; ///{@template flutter_inappwebview.WebView.onCameraCaptureStateChanged} @@ -1060,7 +1045,7 @@ abstract class WebView { ///- MacOS ///{@endtemplate} final Future Function( - InAppWebViewController controller, + PlatformInAppWebViewController controller, MediaCaptureState? oldState, MediaCaptureState? newState, )? onCameraCaptureStateChanged; @@ -1077,13 +1062,13 @@ abstract class WebView { ///- MacOS ///{@endtemplate} final Future Function( - InAppWebViewController controller, + PlatformInAppWebViewController controller, MediaCaptureState? oldState, MediaCaptureState? newState, )? onMicrophoneCaptureStateChanged; ///{@template flutter_inappwebview.WebView.onContentSizeChanged} - ///Event fired when the content size of the [WebView] changes. + ///Event fired when the content size of the `WebView` changes. /// ///[oldContentSize] represents the old content size value. /// @@ -1092,7 +1077,7 @@ abstract class WebView { ///**Supported Platforms/Implementations**: ///- iOS ///{@endtemplate} - final void Function(InAppWebViewController controller, Size oldContentSize, + final void Function(PlatformInAppWebViewController controller, Size oldContentSize, Size newContentSize)? onContentSizeChanged; ///{@template flutter_inappwebview.WebView.initialUrlRequest} @@ -1179,7 +1164,7 @@ abstract class WebView { ///- Android native WebView ///- iOS ///{@endtemplate} - final PullToRefreshController? pullToRefreshController; + final PlatformPullToRefreshController? pullToRefreshController; ///{@template flutter_inappwebview.WebView.findInteractionController} ///Represents the find interaction feature controller. @@ -1189,10 +1174,10 @@ abstract class WebView { ///- iOS ///- MacOS ///{@endtemplate} - final FindInteractionController? findInteractionController; + final PlatformFindInteractionController? findInteractionController; ///{@macro flutter_inappwebview.WebView} - WebView( + const PlatformWebViewCreationParams( {this.windowId, this.onWebViewCreated, this.onLoadStart, diff --git a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart new file mode 100644 index 00000000..33ef634d --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart @@ -0,0 +1,430 @@ +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import 'find_interaction/platform_find_interaction_controller.dart'; +import 'in_app_browser/platform_in_app_browser.dart'; +import 'in_app_webview/platform_headless_in_app_webview.dart'; +import 'in_app_webview/platform_inappwebview_controller.dart'; +import 'in_app_webview/platform_inappwebview_widget.dart'; +import 'platform_cookie_manager.dart'; +import 'platform_http_auth_credentials_database.dart'; +import 'print_job/platform_print_job_controller.dart'; +import 'pull_to_refresh/platform_pull_to_refresh_controller.dart'; +import 'web_authentication_session/platform_web_authenticate_session.dart'; +import 'web_message/platform_web_message_channel.dart'; +import 'web_message/platform_web_message_listener.dart'; +import 'web_message/platform_web_message_port.dart'; +import 'web_storage/platform_web_storage.dart'; +import 'web_storage/platform_web_storage_manager.dart'; +import 'platform_process_global_config.dart'; +import 'platform_proxy_controller.dart'; +import 'platform_service_worker_controller.dart'; +import 'platform_tracing_controller.dart'; +import 'platform_webview_asset_loader.dart'; +import 'platform_webview_feature.dart'; + +/// Interface for a platform implementation of a WebView. +abstract class InAppWebViewPlatform extends PlatformInterface { + /// Creates a new [InAppWebViewPlatform]. + InAppWebViewPlatform() : super(token: _token); + + static final Object _token = Object(); + + static InAppWebViewPlatform? _instance; + + /// The instance of [InAppWebViewPlatform] to use. + static InAppWebViewPlatform? get instance => _instance; + + /// Platform-specific plugins should set this with their own platform-specific + /// class that extends [InAppWebViewPlatform] when they register themselves. + static set instance(InAppWebViewPlatform? instance) { + if (instance == null) { + throw AssertionError( + 'Platform interfaces can only be set to a non-null instance'); + } + + PlatformInterface.verify(instance, _token); + _instance = instance; + } + + /// Creates a new [PlatformCookieManager]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [CookieManager] in `flutter_inappwebview` instead. + PlatformCookieManager createPlatformCookieManager( + PlatformCookieManagerCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformCookieManager is not implemented on the current platform.'); + } + + /// Creates a new [PlatformInAppWebViewController]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InAppWebViewController] in `flutter_inappwebview` instead. + PlatformInAppWebViewController createPlatformInAppWebViewController( + PlatformInAppWebViewControllerCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformInAppWebViewController is not implemented on the current platform.'); + } + + /// Creates a new empty [PlatformInAppWebViewController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InAppWebViewController] in `flutter_inappwebview` instead. + PlatformInAppWebViewController createPlatformInAppWebViewControllerStatic() { + throw UnimplementedError( + 'createPlatformInAppWebViewControllerStatic is not implemented on the current platform.'); + } + + /// Creates a new [PlatformInAppWebViewWidget]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InAppWebView] in `flutter_inappwebview` instead. + PlatformInAppWebViewWidget createPlatformInAppWebViewWidget( + PlatformInAppWebViewWidgetCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformInAppWebViewWidget is not implemented on the current platform.'); + } + + /// Creates a new [PlatformFindInteractionController]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [FindInteractionController] in `flutter_inappwebview` instead. + PlatformFindInteractionController createPlatformFindInteractionController( + PlatformFindInteractionControllerCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformFindInteractionController is not implemented on the current platform.'); + } + + /// Creates a new [PlatformPrintJobController]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PrintJobController] in `flutter_inappwebview` instead. + PlatformPrintJobController createPlatformPrintJobController( + PlatformPrintJobControllerCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformPrintJobController is not implemented on the current platform.'); + } + + /// Creates a new [PlatformPullToRefreshController]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PullToRefreshController] in `flutter_inappwebview` instead. + PlatformPullToRefreshController createPlatformPullToRefreshController( + PlatformPullToRefreshControllerCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformPullToRefreshController is not implemented on the current platform.'); + } + + /// Creates a new [PlatformWebAuthenticationSession]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebAuthenticationSession] in `flutter_inappwebview` instead. + PlatformWebAuthenticationSession createPlatformWebAuthenticationSession( + PlatformWebAuthenticationSessionCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformWebAuthenticationSession is not implemented on the current platform.'); + } + + /// Creates a new empty [PlatformWebAuthenticationSession] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebAuthenticationSession] in `flutter_inappwebview` instead. + PlatformWebAuthenticationSession createPlatformWebAuthenticationSessionStatic() { + throw UnimplementedError( + 'createPlatformWebAuthenticationSessionStatic is not implemented on the current platform.'); + } + + /// Creates a new [PlatformWebMessageChannel]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessageChannel] in `flutter_inappwebview` instead. + PlatformWebMessageChannel createPlatformWebMessageChannel( + PlatformWebMessageChannelCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformWebMessageChannel is not implemented on the current platform.'); + } + + /// Creates a new empty [PlatformWebMessageChannel] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessageChannel] in `flutter_inappwebview` instead. + PlatformWebMessageChannel createPlatformWebMessageChannelStatic() { + throw UnimplementedError( + 'createPlatformWebMessageChannelStatic is not implemented on the current platform.'); + } + + /// Creates a new [PlatformWebMessageListener]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessageListener] in `flutter_inappwebview` instead. + PlatformWebMessageListener createPlatformWebMessageListener( + PlatformWebMessageListenerCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformWebMessageListener is not implemented on the current platform.'); + } + + /// Creates a new [PlatformJavaScriptReplyProxy]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [JavaScriptReplyProxy] in `flutter_inappwebview` instead. + PlatformJavaScriptReplyProxy createPlatformJavaScriptReplyProxy( + PlatformJavaScriptReplyProxyCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformJavaScriptReplyProxy is not implemented on the current platform.'); + } + + /// Creates a new [PlatformWebMessagePort]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessagePort] in `flutter_inappwebview` instead. + PlatformWebMessagePort createPlatformWebMessagePort( + PlatformWebMessagePortCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformWebMessagePort is not implemented on the current platform.'); + } + + /// Creates a new [PlatformWebStorage]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorage] in `flutter_inappwebview` instead. + PlatformWebStorage createPlatformWebStorage( + PlatformWebStorageCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformWebStorage is not implemented on the current platform.'); + } + + /// Creates a new [PlatformStorage]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [Storage] in `flutter_inappwebview` instead. + PlatformStorage createPlatformStorage( + PlatformStorageCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformStorage is not implemented on the current platform.'); + } + + /// Creates a new [PlatformLocalStorage]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [LocalStorage] in `flutter_inappwebview` instead. + PlatformLocalStorage createPlatformLocalStorage( + PlatformLocalStorageCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformLocalStorage is not implemented on the current platform.'); + } + + /// Creates a new [PlatformSessionStorage]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PlatformSessionStorage] in `flutter_inappwebview` instead. + PlatformSessionStorage createPlatformSessionStorage( + PlatformSessionStorageCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformSessionStorage is not implemented on the current platform.'); + } + + /// Creates a new [PlatformHeadlessInAppWebView]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [HeadlessInAppWebView] in `flutter_inappwebview` instead. + PlatformHeadlessInAppWebView createPlatformHeadlessInAppWebView( + PlatformHeadlessInAppWebViewCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformHeadlessInAppWebView is not implemented on the current platform.'); + } + + /// Creates a new [PlatformWebStorageManager]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [CookieManager] in `flutter_inappwebview` instead. + PlatformWebStorageManager createPlatformWebStorageManager( + PlatformWebStorageManagerCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformWebStorageManager is not implemented on the current platform.'); + } + + /// Creates a new [PlatformHttpAuthCredentialDatabase]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [HttpAuthCredentialDatabase] in `flutter_inappwebview` instead. + PlatformHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabase( + PlatformHttpAuthCredentialDatabaseCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformHttpAuthCredentialDatabase is not implemented on the current platform.'); + } + + /// Creates a new [PlatformInAppBrowser]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InAppBrowser] in `flutter_inappwebview` instead. + PlatformInAppBrowser createPlatformInAppBrowser( + PlatformInAppBrowserCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformInAppBrowser is not implemented on the current platform.'); + } + + /// Creates a new empty [PlatformInAppBrowser] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InAppBrowser] in `flutter_inappwebview` instead. + PlatformInAppBrowser createPlatformInAppBrowserStatic() { + throw UnimplementedError( + 'createPlatformInAppBrowserStatic is not implemented on the current platform.'); + } + + /// Creates a new [PlatformProcessGlobalConfig]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProcessGlobalConfig] in `flutter_inappwebview` instead. + PlatformProcessGlobalConfig createPlatformProcessGlobalConfig( + PlatformProcessGlobalConfigCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformProcessGlobalConfig is not implemented on the current platform.'); + } + + /// Creates a new [PlatformProxyController]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProxyController] in `flutter_inappwebview` instead. + PlatformProxyController createPlatformProxyController( + PlatformProxyControllerCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformProxyController is not implemented on the current platform.'); + } + + /// Creates a new [PlatformServiceWorkerController]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ServiceWorkerController] in `flutter_inappwebview` instead. + PlatformServiceWorkerController createPlatformServiceWorkerController( + PlatformServiceWorkerControllerCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformServiceWorkerController is not implemented on the current platform.'); + } + + /// Creates a new empty [PlatformServiceWorkerController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ServiceWorkerController] in `flutter_inappwebview` instead. + PlatformServiceWorkerController createPlatformServiceWorkerControllerStatic() { + throw UnimplementedError( + 'createPlatformServiceWorkerControllerStatic is not implemented on the current platform.'); + } + + /// Creates a new [PlatformTracingController]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [TracingController] in `flutter_inappwebview` instead. + PlatformTracingController createPlatformTracingController( + PlatformTracingControllerCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformTracingController is not implemented on the current platform.'); + } + + /// Creates a new [PlatformWebViewAssetLoader]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebViewAssetLoader] in `flutter_inappwebview` instead. + PlatformWebViewAssetLoader createPlatformWebViewAssetLoader( + PlatformWebViewAssetLoaderCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformWebViewAssetLoader is not implemented on the current platform.'); + } + + /// Creates a new empty [PlatformWebViewAssetLoader] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebViewAssetLoader] in `flutter_inappwebview` instead. + PlatformWebViewAssetLoader createPlatformWebViewAssetLoaderStatic() { + throw UnimplementedError( + 'createPlatformWebViewAssetLoaderStatic is not implemented on the current platform.'); + } + + /// Creates a new [PlatformPathHandler]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PathHandler] in `flutter_inappwebview` instead. + PlatformPathHandler createPlatformPathHandler( + PlatformPathHandlerCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformPathHandler is not implemented on the current platform.'); + } + + /// Creates a new [PlatformAssetsPathHandler]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [AssetsPathHandler] in `flutter_inappwebview` instead. + PlatformAssetsPathHandler createPlatformAssetsPathHandler( + PlatformAssetsPathHandlerCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformAssetsPathHandler is not implemented on the current platform.'); + } + + /// Creates a new [PlatformResourcesPathHandler]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ResourcesPathHandler] in `flutter_inappwebview` instead. + PlatformResourcesPathHandler createPlatformResourcesPathHandler( + PlatformResourcesPathHandlerCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformResourcesPathHandler is not implemented on the current platform.'); + } + + /// Creates a new [PlatformInternalStoragePathHandler]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InternalStoragePathHandler] in `flutter_inappwebview` instead. + PlatformInternalStoragePathHandler createPlatformInternalStoragePathHandler( + PlatformInternalStoragePathHandlerCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformInternalStoragePathHandler is not implemented on the current platform.'); + } + + /// Creates a new [PlatformWebViewFeature]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebViewFeature] in `flutter_inappwebview` instead. + PlatformWebViewFeature createPlatformWebViewFeature( + PlatformWebViewFeatureCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformWebViewFeature is not implemented on the current platform.'); + } + + /// Creates a new empty [PlatformWebViewFeature] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebViewFeature] in `flutter_inappwebview` instead. + PlatformWebViewFeature createPlatformWebViewFeatureStatic() { + throw UnimplementedError( + 'createPlatformWebViewFeatureStatic is not implemented on the current platform.'); + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/main.dart b/flutter_inappwebview_platform_interface/lib/src/main.dart new file mode 100644 index 00000000..8bbab06e --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/main.dart @@ -0,0 +1,34 @@ +export 'inappwebview_platform.dart'; +export 'types/main.dart'; +export 'in_app_webview/main.dart'; +export 'in_app_browser/main.dart'; +export 'chrome_safari_browser/main.dart'; +export 'x509_certificate/main.dart'; +export 'web_storage/main.dart'; +export 'platform_cookie_manager.dart'; +export 'in_app_localhost_server.dart'; +export 'content_blocker.dart'; +export 'platform_http_auth_credentials_database.dart'; +export 'context_menu/main.dart'; +export 'pull_to_refresh/main.dart'; +export 'web_message/main.dart'; +export 'web_authentication_session/main.dart'; +export 'print_job/main.dart'; +export 'find_interaction/main.dart'; +export 'web_uri.dart'; +export 'debug_logging_settings.dart'; +export 'util.dart'; +export 'platform_service_worker_controller.dart'; +export 'platform_webview_feature.dart' + hide WebViewFeature_, AndroidWebViewFeature_; +export 'platform_proxy_controller.dart' hide ProxySettings_; +export 'platform_webview_asset_loader.dart' + hide + PlatformWebViewAssetLoader_, + PlatformPathHandler_, + PlatformAssetsPathHandler_, + PlatformResourcesPathHandler_, + PlatformInternalStoragePathHandler_; +export 'platform_tracing_controller.dart' hide TracingSettings_; +export 'platform_process_global_config.dart' + hide ProcessGlobalConfigSettings_, ProcessGlobalConfigDirectoryBasePaths_; diff --git a/lib/src/mime_type_resolver.dart b/flutter_inappwebview_platform_interface/lib/src/mime_type_resolver.dart similarity index 100% rename from lib/src/mime_type_resolver.dart rename to flutter_inappwebview_platform_interface/lib/src/mime_type_resolver.dart diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart b/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart new file mode 100755 index 00000000..cb87a1da --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart @@ -0,0 +1,253 @@ +import 'dart:async'; + +import 'package:flutter/foundation.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import 'in_app_webview/platform_inappwebview_controller.dart'; +import 'types/main.dart'; +import 'web_uri.dart'; +import 'inappwebview_platform.dart'; + +/// Object specifying creation parameters for creating a [PlatformCookieManager]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformCookieManagerCreationParams { + /// Used by the platform implementation to create a new [PlatformCookieManager]. + const PlatformCookieManagerCreationParams(); +} + +///Class that implements a singleton object (shared instance) which manages the cookies used by WebView instances. +///On Android, it is implemented using [CookieManager](https://developer.android.com/reference/android/webkit/CookieManager). +///On iOS, it is implemented using [WKHTTPCookieStore](https://developer.apple.com/documentation/webkit/wkhttpcookiestore). +/// +///**NOTE for iOS below 11.0 and Web platform (LIMITED SUPPORT!)**: in this case, almost all of the methods ([PlatformCookieManager.deleteAllCookies] and [PlatformCookieManager.getAllCookies] are not supported!) +///has been implemented using JavaScript because there is no other way to work with them on iOS below 11.0. +///See https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies for JavaScript restrictions. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- MacOS +///- Web +abstract class PlatformCookieManager extends PlatformInterface { + /// Creates a new [PlatformCookieManager] + factory PlatformCookieManager(PlatformCookieManagerCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformCookieManager cookieManager = + InAppWebViewPlatform.instance!.createPlatformCookieManager(params); + PlatformInterface.verify(cookieManager, _token); + return cookieManager; + } + + /// Used by the platform implementation to create a new + /// [PlatformCookieManager]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformCookieManager.implementation(this.params) + : super(token: _token); + + static final Object _token = Object(); + + /// The parameters used to initialize the [PlatformCookieManager]. + final PlatformCookieManagerCreationParams params; + + ///Sets a cookie for the given [url]. Any existing cookie with the same [host], [path] and [name] will be replaced with the new cookie. + ///The cookie being set will be ignored if it is expired. + /// + ///The default value of [path] is `"/"`. + /// + ///[webViewController] could be used if you need to set a session-only cookie using JavaScript (so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) + ///on the current URL of the `WebView` managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. In this case the [url] parameter is ignored. + /// + ///The return value indicates whether the cookie was set successfully. + ///Note that it will return always `true` for Web platform, iOS below 11.0 and MacOS below 10.13. + /// + ///**NOTE for iOS below 11.0 and MacOS below 10.13**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView] + ///to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView] + ///to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - CookieManager.setCookie](https://developer.android.com/reference/android/webkit/CookieManager#setCookie(java.lang.String,%20java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) + ///- iOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie)) + ///- MacOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie)) + ///- Web + Future setCookie( + {required WebUri url, + required String name, + required String value, + String path = "/", + String? domain, + int? expiresDate, + int? maxAge, + bool? isSecure, + bool? isHttpOnly, + HTTPCookieSameSitePolicy? sameSite, + @Deprecated("Use webViewController instead") + PlatformInAppWebViewController? iosBelow11WebViewController, + PlatformInAppWebViewController? webViewController}) { + throw UnimplementedError( + 'setCookie is not implemented on the current platform'); + } + + ///Gets all the cookies for the given [url]. + /// + ///[webViewController] is used for getting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) + ///from the current context of the `WebView` managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. JavaScript must be enabled in order to work. + ///In this case the [url] parameter is ignored. + /// + ///**NOTE for iOS below 11.0 and MacOS below 10.13**: All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. + ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView] + ///to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!). + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView] + ///to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!). + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - CookieManager.getCookie](https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String))) + ///- iOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) + ///- MacOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) + ///- Web + Future> getCookies( + {required WebUri url, + @Deprecated("Use webViewController instead") + PlatformInAppWebViewController? iosBelow11WebViewController, + PlatformInAppWebViewController? webViewController}) { + throw UnimplementedError( + 'getCookies is not implemented on the current platform'); + } + + ///Gets a cookie by its [name] for the given [url]. + /// + ///[webViewController] is used for getting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) + ///from the current context of the `WebView` managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. JavaScript must be enabled in order to work. + ///In this case the [url] parameter is ignored. + /// + ///**NOTE for iOS below 11.0 and MacOS below 10.13**: All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. + ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView] + ///to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!). + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView] + ///to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!). + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future getCookie( + {required WebUri url, + required String name, + @Deprecated("Use webViewController instead") + PlatformInAppWebViewController? iosBelow11WebViewController, + PlatformInAppWebViewController? webViewController}) { + throw UnimplementedError( + 'getCookie is not implemented on the current platform'); + } + + ///Removes a cookie by its [name] for the given [url], [domain] and [path]. + /// + ///The default value of [path] is `"/"`. + /// + ///[webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) + ///from the current context of the `WebView` managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. JavaScript must be enabled in order to work. + ///In this case the [url] parameter is ignored. + /// + ///**NOTE for iOS below 11.0 and MacOS below 10.13**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView] + ///to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView] + ///to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete) + ///- MacOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete) + ///- Web + Future deleteCookie( + {required WebUri url, + required String name, + String path = "/", + String? domain, + @Deprecated("Use webViewController instead") + PlatformInAppWebViewController? iosBelow11WebViewController, + PlatformInAppWebViewController? webViewController}) { + throw UnimplementedError( + 'deleteCookie is not implemented on the current platform'); + } + + ///Removes all cookies for the given [url], [domain] and [path]. + /// + ///The default value of [path] is `"/"`. + /// + ///[webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) + ///from the current context of the `WebView` managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. JavaScript must be enabled in order to work. + ///In this case the [url] parameter is ignored. + /// + ///**NOTE for iOS below 11.0 and MacOS below 10.13**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView] + ///to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). + /// + ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. + ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView] + ///to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + ///- Web + Future deleteCookies( + {required WebUri url, + String path = "/", + String? domain, + @Deprecated("Use webViewController instead") + PlatformInAppWebViewController? iosBelow11WebViewController, + PlatformInAppWebViewController? webViewController}) { + throw UnimplementedError( + 'deleteCookies is not implemented on the current platform'); + } + + ///Removes all cookies. + /// + ///**NOTE for iOS**: available from iOS 11.0+. + /// + ///**NOTE for MacOS**: available from iOS 10.13+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - CookieManager.removeAllCookies](https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) + ///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) + ///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) + Future deleteAllCookies() { + throw UnimplementedError( + 'deleteAllCookies is not implemented on the current platform'); + } + + ///Fetches all stored cookies. + /// + ///**NOTE for iOS**: available on iOS 11.0+. + /// + ///**NOTE for MacOS**: available from iOS 10.13+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) + ///- MacOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) + Future> getAllCookies() { + throw UnimplementedError( + 'getAllCookies is not implemented on the current platform'); + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart b/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart new file mode 100755 index 00000000..f20c0283 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart @@ -0,0 +1,132 @@ +import 'dart:async'; +import 'package:flutter/foundation.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import 'inappwebview_platform.dart'; +import 'types/main.dart'; + +/// Object specifying creation parameters for creating a [PlatformHttpAuthCredentialDatabase]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformHttpAuthCredentialDatabaseCreationParams { + /// Used by the platform implementation to create a new [PlatformHttpAuthCredentialDatabase]. + const PlatformHttpAuthCredentialDatabaseCreationParams(); +} + +///Class that implements a singleton object (shared instance) which manages the shared HTTP auth credentials cache. +///On iOS and MacOS, this class uses the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class. +///On Android, this class has a custom implementation using `android.database.sqlite.SQLiteDatabase` because +///[WebViewDatabase](https://developer.android.com/reference/android/webkit/WebViewDatabase) +///doesn't offer the same functionalities as iOS `URLCredentialStorage`. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- MacOS +abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { + /// Creates a new [PlatformHttpAuthCredentialDatabase] + factory PlatformHttpAuthCredentialDatabase(PlatformHttpAuthCredentialDatabaseCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformHttpAuthCredentialDatabase cookieManager = + InAppWebViewPlatform.instance!.createPlatformHttpAuthCredentialDatabase(params); + PlatformInterface.verify(cookieManager, _token); + return cookieManager; + } + + /// Used by the platform implementation to create a new + /// [PlatformHttpAuthCredentialDatabase]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformHttpAuthCredentialDatabase.implementation(this.params) + : super(token: _token); + + static final Object _token = Object(); + + /// The parameters used to initialize the [PlatformHttpAuthCredentialDatabase]. + final PlatformHttpAuthCredentialDatabaseCreationParams params; + + ///Gets a map list of all HTTP auth credentials saved. + ///Each map contains the key `protectionSpace` of type [URLProtectionSpace] + ///and the key `credentials` of type List<[URLCredential]> that contains all the HTTP auth credentials saved for that `protectionSpace`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - URLCredentialStorage.allCredentials](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials)) + ///- MacOS ([Official API - URLCredentialStorage.allCredentials](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials)) + Future> + getAllAuthCredentials() { + throw UnimplementedError( + 'getAllAuthCredentials is not implemented on the current platform'); + } + + ///Gets all the HTTP auth credentials saved for that [protectionSpace]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future> getHttpAuthCredentials( + {required URLProtectionSpace protectionSpace}) { + throw UnimplementedError( + 'getHttpAuthCredentials is not implemented on the current platform'); + } + + ///Saves an HTTP auth [credential] for that [protectionSpace]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - URLCredentialStorage.set](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set)) + ///- MacOS ([Official API - URLCredentialStorage.set](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set)) + Future setHttpAuthCredential( + {required URLProtectionSpace protectionSpace, + required URLCredential credential}) { + throw UnimplementedError( + 'setHttpAuthCredential is not implemented on the current platform'); + } + + ///Removes an HTTP auth [credential] for that [protectionSpace]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS ([Official API - URLCredentialStorage.remove](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove)) + ///- MacOS ([Official API - URLCredentialStorage.remove](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove)) + Future removeHttpAuthCredential( + {required URLProtectionSpace protectionSpace, + required URLCredential credential}) { + throw UnimplementedError( + 'removeHttpAuthCredential is not implemented on the current platform'); + } + + ///Removes all the HTTP auth credentials saved for that [protectionSpace]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future removeHttpAuthCredentials( + {required URLProtectionSpace protectionSpace}) { + throw UnimplementedError( + 'removeHttpAuthCredentials is not implemented on the current platform'); + } + + ///Removes all the HTTP auth credentials saved in the database. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + Future clearAllAuthCredentials() { + throw UnimplementedError( + 'clearAllAuthCredentials is not implemented on the current platform'); + } +} diff --git a/lib/src/android/process_global_config.dart b/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.dart similarity index 61% rename from lib/src/android/process_global_config.dart rename to flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.dart index 9f367c54..5603d24a 100644 --- a/lib/src/android/process_global_config.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.dart @@ -1,14 +1,24 @@ import 'dart:async'; -import 'package:flutter/services.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import 'webview_feature.dart'; -import '../in_app_webview/webview.dart'; -import '../in_app_webview/in_app_webview_controller.dart'; -import '../cookie_manager.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +import 'inappwebview_platform.dart'; +import 'in_app_webview/platform_inappwebview_controller.dart'; +import 'platform_webview_feature.dart'; -part 'process_global_config.g.dart'; +part 'platform_process_global_config.g.dart'; -///Process Global Configuration for [WebView]. +/// Object specifying creation parameters for creating a [PlatformProcessGlobalConfig]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformProcessGlobalConfigCreationParams { + /// Used by the platform implementation to create a new [PlatformProcessGlobalConfig]. + const PlatformProcessGlobalConfigCreationParams(); +} + +///Process Global Configuration for `WebView`. ///WebView has some process-global configuration parameters ///that cannot be changed once WebView has been loaded. ///This class allows apps to set these parameters. @@ -26,59 +36,54 @@ part 'process_global_config.g.dart'; ///Only a single thread should access this class at a given time. /// ///The configuration should be set up as early as possible during application startup, -///to ensure that it happens before any other thread can call a method that loads [WebView]. +///to ensure that it happens before any other thread can call a method that loads `WebView`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - ProcessGlobalConfig](https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig)) -class ProcessGlobalConfig { - static ProcessGlobalConfig? _instance; - static const MethodChannel _channel = const MethodChannel( - 'com.pichillilorenzo/flutter_inappwebview_processglobalconfig'); - - ProcessGlobalConfig._(); - - ///Gets the [ProcessGlobalConfig] shared instance. - static ProcessGlobalConfig instance() { - return (_instance != null) ? _instance! : _init(); +abstract class PlatformProcessGlobalConfig extends PlatformInterface { + /// Creates a new [PlatformProcessGlobalConfig] + factory PlatformProcessGlobalConfig(PlatformProcessGlobalConfigCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformProcessGlobalConfig processGlobalConfig = + InAppWebViewPlatform.instance!.createPlatformProcessGlobalConfig(params); + PlatformInterface.verify(processGlobalConfig, _token); + return processGlobalConfig; } - static ProcessGlobalConfig _init() { - _channel.setMethodCallHandler((call) async { - try { - return await _handleMethod(call); - } on Error catch (e) { - print(e); - print(e.stackTrace); - } - }); - _instance = ProcessGlobalConfig._(); - return _instance!; - } + /// Used by the platform implementation to create a new + /// [PlatformProcessGlobalConfig]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformProcessGlobalConfig.implementation(this.params) + : super(token: _token); - static Future _handleMethod(MethodCall call) async { - // ProcessGlobalConfig controller = ProcessGlobalConfig.instance(); - switch (call.method) { - default: - throw UnimplementedError("Unimplemented ${call.method} method"); - } - // return null; - } + static final Object _token = Object(); - ///Applies the configuration to be used by [WebView] on loading. + /// The parameters used to initialize the [PlatformProcessGlobalConfig]. + final PlatformProcessGlobalConfigCreationParams params; + + ///Applies the configuration to be used by `WebView` on loading. ///This method can only be called once. /// - ///Calling this method will not cause [WebView] to be loaded and will not block the calling thread. + ///Calling this method will not cause `WebView` to be loaded and will not block the calling thread. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - ProcessGlobalConfig.apply](https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig#apply(androidx.webkit.ProcessGlobalConfig))) - Future apply({required ProcessGlobalConfigSettings settings}) async { - Map args = {}; - args.putIfAbsent("settings", () => settings.toMap()); - return await _channel.invokeMethod('apply', args); + Future apply({required ProcessGlobalConfigSettings settings}) { + throw UnimplementedError( + 'apply is not implemented on the current platform'); } } -///Class that represents the settings used to configure the [ProcessGlobalConfig]. +///Class that represents the settings used to configure the [PlatformProcessGlobalConfig]. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -95,20 +100,20 @@ class ProcessGlobalConfigSettings_ { ///only one process can use the default directory, ///and other processes must call this API to define a unique suffix. /// - ///This means that different processes in the same application cannot directly share [WebView]-related data, + ///This means that different processes in the same application cannot directly share `WebView`-related data, ///since the data directories must be distinct. ///Applications that use this API may have to explicitly pass data between processes. - ///For example, login cookies may have to be copied from one process's cookie jar to the other using [CookieManager] if both processes' WebViews are intended to be logged in. + ///For example, login cookies may have to be copied from one process's cookie jar to the other using [PlatformCookieManager] if both processes' WebViews are intended to be logged in. /// ///Most applications should simply ensure that all components of the app that rely ///on WebView are in the same process, to avoid needing multiple data directories. - ///The [InAppWebViewController.disableWebView] method can be used to ensure that the other processes do not use WebView by accident in this case. + ///The [PlatformInAppWebViewController.disableWebView] method can be used to ensure that the other processes do not use WebView by accident in this case. /// ///**NOTE**: available only if [WebViewFeature.STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX] feature is supported. String? dataDirectorySuffix; - ///Set the base directories that [WebView] will use for the current process. - ///If this method is not used, [WebView] uses the default base paths defined by the Android framework. + ///Set the base directories that `WebView` will use for the current process. + ///If this method is not used, `WebView` uses the default base paths defined by the Android framework. /// ///WebView will create and use a subdirectory under each of the base paths supplied to this method. /// @@ -122,8 +127,8 @@ class ProcessGlobalConfigSettings_ { ///Refer to [this link](https://developer.android.com/training/data-storage/app-specific#internal-remove-cache). /// ///If the specified directories already exist then they must be readable and writable by the current process. - ///If they do not already exist, [WebView] will attempt to create them during initialization, along with any missing parent directories. - ///In such a case, the directory in which [WebView] creates missing directories must be readable and writable by the current process. + ///If they do not already exist, `WebView` will attempt to create them during initialization, along with any missing parent directories. + ///In such a case, the directory in which `WebView` creates missing directories must be readable and writable by the current process. /// ///**NOTE**: available only if [WebViewFeature.STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS] feature is supported. ProcessGlobalConfigDirectoryBasePaths_? directoryBasePaths; diff --git a/lib/src/android/process_global_config.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.g.dart similarity index 88% rename from lib/src/android/process_global_config.g.dart rename to flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.g.dart index ec44d74e..5c8ad690 100644 --- a/lib/src/android/process_global_config.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.g.dart @@ -1,12 +1,12 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'process_global_config.dart'; +part of 'platform_process_global_config.dart'; // ************************************************************************** // ExchangeableObjectGenerator // ************************************************************************** -///Class that represents the settings used to configure the [ProcessGlobalConfig]. +///Class that represents the settings used to configure the [PlatformProcessGlobalConfig]. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -22,20 +22,20 @@ class ProcessGlobalConfigSettings { ///only one process can use the default directory, ///and other processes must call this API to define a unique suffix. /// - ///This means that different processes in the same application cannot directly share [WebView]-related data, + ///This means that different processes in the same application cannot directly share `WebView`-related data, ///since the data directories must be distinct. ///Applications that use this API may have to explicitly pass data between processes. - ///For example, login cookies may have to be copied from one process's cookie jar to the other using [CookieManager] if both processes' WebViews are intended to be logged in. + ///For example, login cookies may have to be copied from one process's cookie jar to the other using [PlatformCookieManager] if both processes' WebViews are intended to be logged in. /// ///Most applications should simply ensure that all components of the app that rely ///on WebView are in the same process, to avoid needing multiple data directories. - ///The [InAppWebViewController.disableWebView] method can be used to ensure that the other processes do not use WebView by accident in this case. + ///The [PlatformInAppWebViewController.disableWebView] method can be used to ensure that the other processes do not use WebView by accident in this case. /// ///**NOTE**: available only if [WebViewFeature.STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX] feature is supported. String? dataDirectorySuffix; - ///Set the base directories that [WebView] will use for the current process. - ///If this method is not used, [WebView] uses the default base paths defined by the Android framework. + ///Set the base directories that `WebView` will use for the current process. + ///If this method is not used, `WebView` uses the default base paths defined by the Android framework. /// ///WebView will create and use a subdirectory under each of the base paths supplied to this method. /// @@ -49,8 +49,8 @@ class ProcessGlobalConfigSettings { ///Refer to [this link](https://developer.android.com/training/data-storage/app-specific#internal-remove-cache). /// ///If the specified directories already exist then they must be readable and writable by the current process. - ///If they do not already exist, [WebView] will attempt to create them during initialization, along with any missing parent directories. - ///In such a case, the directory in which [WebView] creates missing directories must be readable and writable by the current process. + ///If they do not already exist, `WebView` will attempt to create them during initialization, along with any missing parent directories. + ///In such a case, the directory in which `WebView` creates missing directories must be readable and writable by the current process. /// ///**NOTE**: available only if [WebViewFeature.STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS] feature is supported. ProcessGlobalConfigDirectoryBasePaths? directoryBasePaths; diff --git a/lib/src/android/proxy_controller.dart b/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.dart similarity index 68% rename from lib/src/android/proxy_controller.dart rename to flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.dart index b2abac7c..2f0fe261 100644 --- a/lib/src/android/proxy_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.dart @@ -1,15 +1,26 @@ import 'dart:async'; -import 'package:flutter/services.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../types/proxy_rule.dart'; -import 'webview_feature.dart'; -import '../in_app_webview/webview.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +import 'inappwebview_platform.dart'; +import 'types/proxy_rule.dart'; +import 'platform_webview_feature.dart'; -part 'proxy_controller.g.dart'; +part 'platform_proxy_controller.g.dart'; -///Manages setting and clearing a process-specific override for the Android system-wide proxy settings that govern network requests made by [WebView]. +/// Object specifying creation parameters for creating a [PlatformProxyController]. /// -///[WebView] may make network requests in order to fetch content that is not otherwise read from the file system or provided directly by application code. +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformProxyControllerCreationParams { + /// Used by the platform implementation to create a new [PlatformProxyController]. + const PlatformProxyControllerCreationParams(); +} + +///Manages setting and clearing a process-specific override for the Android system-wide proxy settings that govern network requests made by `WebView`. +/// +///`WebView` may make network requests in order to fetch content that is not otherwise read from the file system or provided directly by application code. ///In this case by default the system-wide Android network proxy settings are used to redirect requests to appropriate proxy servers. /// ///In the rare case that it is necessary for an application to explicitly specify its proxy configuration, @@ -17,53 +28,46 @@ part 'proxy_controller.g.dart'; /// ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - ProxyController](https://developer.android.com/reference/androidx/webkit/ProxyController)) -class ProxyController { - static ProxyController? _instance; - static const MethodChannel _channel = const MethodChannel( - 'com.pichillilorenzo/flutter_inappwebview_proxycontroller'); +abstract class PlatformProxyController extends PlatformInterface { + /// Creates a new [PlatformProxyController] + factory PlatformProxyController(PlatformProxyControllerCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformProxyController proxyController = + InAppWebViewPlatform.instance!.createPlatformProxyController(params); + PlatformInterface.verify(proxyController, _token); + return proxyController; + } - ProxyController._(); - - ///Gets the [ProxyController] shared instance. + /// Used by the platform implementation to create a new + /// [PlatformProxyController]. /// - ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.PROXY_OVERRIDE]. - static ProxyController instance() { - return (_instance != null) ? _instance! : _init(); - } + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformProxyController.implementation(this.params) + : super(token: _token); - static ProxyController _init() { - _channel.setMethodCallHandler((call) async { - try { - return await _handleMethod(call); - } on Error catch (e) { - print(e); - print(e.stackTrace); - } - }); - _instance = ProxyController._(); - return _instance!; - } + static final Object _token = Object(); - static Future _handleMethod(MethodCall call) async { - // ProxyController controller = ProxyController.instance(); - switch (call.method) { - default: - throw UnimplementedError("Unimplemented ${call.method} method"); - } - // return null; - } + /// The parameters used to initialize the [PlatformProxyController]. + final PlatformProxyControllerCreationParams params; - ///Sets [ProxySettings] which will be used by all [WebView]s in the app. + ///Sets [ProxySettings] which will be used by all `WebView`s in the app. ///URLs that match patterns in the bypass list will not be directed to any proxy. ///Instead, the request will be made directly to the origin specified by the URL. ///Network connections are not guaranteed to immediately use the new proxy setting; wait for the method to return before loading a page. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - ProxyController.setProxyOverride](https://developer.android.com/reference/androidx/webkit/ProxyController#setProxyOverride(androidx.webkit.ProxyConfig,%20java.util.concurrent.Executor,%20java.lang.Runnable))) - Future setProxyOverride({required ProxySettings settings}) async { - Map args = {}; - args.putIfAbsent("settings", () => settings.toMap()); - return await _channel.invokeMethod('setProxyOverride', args); + Future setProxyOverride({required ProxySettings settings}) { + throw UnimplementedError( + 'setProxyOverride is not implemented on the current platform'); } ///Clears the proxy settings. @@ -71,13 +75,13 @@ class ProxyController { /// ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - ProxyController.clearProxyOverride](https://developer.android.com/reference/androidx/webkit/ProxyController#clearProxyOverride(java.util.concurrent.Executor,%20java.lang.Runnable))) - Future clearProxyOverride() async { - Map args = {}; - return await _channel.invokeMethod('clearProxyOverride', args); + Future clearProxyOverride() { + throw UnimplementedError( + 'clearProxyOverride is not implemented on the current platform'); } } -///Class that represents the settings used to configure the [ProxyController]. +///Class that represents the settings used to configure the [PlatformProxyController]. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - ProxyConfig](https://developer.android.com/reference/androidx/webkit/ProxyConfig)) diff --git a/lib/src/android/proxy_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart similarity index 97% rename from lib/src/android/proxy_controller.g.dart rename to flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart index 418215bf..dc2da5d4 100644 --- a/lib/src/android/proxy_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart @@ -1,12 +1,12 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'proxy_controller.dart'; +part of 'platform_proxy_controller.dart'; // ************************************************************************** // ExchangeableObjectGenerator // ************************************************************************** -///Class that represents the settings used to configure the [ProxyController]. +///Class that represents the settings used to configure the [PlatformProxyController]. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - ProxyConfig](https://developer.android.com/reference/androidx/webkit/ProxyConfig)) diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.dart b/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.dart new file mode 100644 index 00000000..f7d134bc --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.dart @@ -0,0 +1,191 @@ +import 'dart:async'; +import 'package:flutter/foundation.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +import 'inappwebview_platform.dart'; +import 'types/main.dart'; + +/// Object specifying creation parameters for creating a [PlatformServiceWorkerController]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformServiceWorkerControllerCreationParams { + /// Used by the platform implementation to create a new [PlatformServiceWorkerController]. + const PlatformServiceWorkerControllerCreationParams(); +} + +///Class that manages Service Workers used by `WebView`. +/// +///**NOTE**: available on Android 24+. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView ([Official API - ServiceWorkerControllerCompat](https://developer.android.com/reference/androidx/webkit/ServiceWorkerControllerCompat)) +abstract class PlatformServiceWorkerController extends PlatformInterface { + /// Creates a new [PlatformServiceWorkerController] + factory PlatformServiceWorkerController(PlatformServiceWorkerControllerCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformServiceWorkerController serviceWorkerController = + InAppWebViewPlatform.instance!.createPlatformServiceWorkerController(params); + PlatformInterface.verify(serviceWorkerController, _token); + return serviceWorkerController; + } + + /// Creates a new [PlatformServiceWorkerController] + factory PlatformServiceWorkerController.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformServiceWorkerController serviceWorkerControllerStatic = + InAppWebViewPlatform.instance!.createPlatformServiceWorkerControllerStatic(); + PlatformInterface.verify(serviceWorkerControllerStatic, _token); + return serviceWorkerControllerStatic; + } + + /// Used by the platform implementation to create a new + /// [PlatformServiceWorkerController]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformServiceWorkerController.implementation(this.params) + : super(token: _token); + + static final Object _token = Object(); + + /// The parameters used to initialize the [PlatformServiceWorkerController]. + final PlatformServiceWorkerControllerCreationParams params; + + ServiceWorkerClient? get serviceWorkerClient; + + ///Sets the client to capture service worker related callbacks. + ///A [ServiceWorkerClient] should be set before any service workers are active, e.g. a safe place is before any WebView instances are created or pages loaded. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - ServiceWorkerControllerCompat.setServiceWorkerClient](https://developer.android.com/reference/androidx/webkit/ServiceWorkerControllerCompat#setServiceWorkerClient(androidx.webkit.ServiceWorkerClientCompat))) + Future setServiceWorkerClient(ServiceWorkerClient? value) { + throw UnimplementedError( + 'setServiceWorkerClient is not implemented on the current platform'); + } + + ///Gets whether Service Workers support content URL access. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CONTENT_ACCESS]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowContentAccess() + Future getAllowContentAccess() { + throw UnimplementedError( + 'getAllowContentAccess is not implemented on the current platform'); + } + + ///Gets whether Service Workers support file access. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_FILE_ACCESS]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowFileAccess() + Future getAllowFileAccess() { + throw UnimplementedError( + 'getAllowFileAccess is not implemented on the current platform'); + } + + ///Gets whether Service Workers are prohibited from loading any resources from the network. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getBlockNetworkLoads() + Future getBlockNetworkLoads() { + throw UnimplementedError( + 'getBlockNetworkLoads is not implemented on the current platform'); + } + + ///Gets the current setting for overriding the cache mode. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CACHE_MODE]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getCacheMode() + Future getCacheMode() { + throw UnimplementedError( + 'getCacheMode is not implemented on the current platform'); + } + + ///Enables or disables content URL access from Service Workers. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CONTENT_ACCESS]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowContentAccess(boolean) + Future setAllowContentAccess(bool allow) { + throw UnimplementedError( + 'setAllowContentAccess is not implemented on the current platform'); + } + + ///Enables or disables file access within Service Workers. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_FILE_ACCESS]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowFileAccess(boolean) + Future setAllowFileAccess(bool allow) { + throw UnimplementedError( + 'setAllowFileAccess is not implemented on the current platform'); + } + + ///Sets whether Service Workers should not load resources from the network. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setBlockNetworkLoads(boolean) + Future setBlockNetworkLoads(bool flag) { + throw UnimplementedError( + 'setBlockNetworkLoads is not implemented on the current platform'); + } + + ///Overrides the way the cache is used. + ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CACHE_MODE]. + /// + ///**NOTE**: available on Android 24+. + /// + ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setCacheMode(int) + Future setCacheMode(CacheMode mode) { + throw UnimplementedError( + 'setCacheMode is not implemented on the current platform'); + } +} + +///Class used by clients to capture Service Worker related callbacks. +/// +///**NOTE**: available on Android 24+. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView ([Official API - ServiceWorkerClientCompat](https://developer.android.com/reference/androidx/webkit/ServiceWorkerClientCompat)) +class ServiceWorkerClient { + ///Notify the host application of a resource request and allow the application to return the data. + ///If the return value is `null`, the Service Worker will continue to load the resource as usual. + ///Otherwise, the return response and data will be used. + /// + ///This method is called only if [WebViewFeature.SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST] is supported. + ///You can check whether that flag is supported using [WebViewFeature.isFeatureSupported]. + /// + ///[request] represents an object containing the details of the request. + /// + ///**NOTE**: available on Android 24+. + final Future Function(WebResourceRequest request)? + shouldInterceptRequest; + + ServiceWorkerClient({this.shouldInterceptRequest}); +} + diff --git a/lib/src/android/tracing_controller.dart b/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.dart similarity index 63% rename from lib/src/android/tracing_controller.dart rename to flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.dart index 26d30378..e0e185c7 100644 --- a/lib/src/android/tracing_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.dart @@ -1,14 +1,24 @@ import 'dart:async'; -import 'package:flutter/services.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../types/tracing_mode.dart'; -import 'webview_feature.dart'; -import '../in_app_webview/webview.dart'; -import '../types/main.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +import 'inappwebview_platform.dart'; +import 'types/tracing_mode.dart'; +import 'types/main.dart'; -part 'tracing_controller.g.dart'; +part 'platform_tracing_controller.g.dart'; -///Manages tracing of [WebView]s. +/// Object specifying creation parameters for creating a [PlatformTracingController]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformTracingControllerCreationParams { + /// Used by the platform implementation to create a new [PlatformTracingController]. + const PlatformTracingControllerCreationParams(); +} + +///Manages tracing of `WebView`s. ///In particular provides functionality for the app to enable/disable tracing of parts of code and to collect tracing data. ///This is useful for profiling performance issues, debugging and memory usage analysis in production and real life scenarios. /// @@ -17,44 +27,37 @@ part 'tracing_controller.g.dart'; /// ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - TracingController](https://developer.android.com/reference/androidx/webkit/TracingController)) -class TracingController { - static TracingController? _instance; - static const MethodChannel _channel = const MethodChannel( - 'com.pichillilorenzo/flutter_inappwebview_tracingcontroller'); +abstract class PlatformTracingController extends PlatformInterface { + /// Creates a new [PlatformTracingController] + factory PlatformTracingController(PlatformTracingControllerCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformTracingController tracingController = + InAppWebViewPlatform.instance!.createPlatformTracingController(params); + PlatformInterface.verify(tracingController, _token); + return tracingController; + } - TracingController._(); - - ///Gets the [TracingController] shared instance. + /// Used by the platform implementation to create a new + /// [PlatformTracingController]. /// - ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` - ///for [WebViewFeature.TRACING_CONTROLLER_BASIC_USAGE]. - static TracingController instance() { - return (_instance != null) ? _instance! : _init(); - } + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformTracingController.implementation(this.params) + : super(token: _token); - static TracingController _init() { - _channel.setMethodCallHandler((call) async { - try { - return await _handleMethod(call); - } on Error catch (e) { - print(e); - print(e.stackTrace); - } - }); - _instance = TracingController._(); - return _instance!; - } + static final Object _token = Object(); - static Future _handleMethod(MethodCall call) async { - // TracingController controller = TracingController.instance(); - switch (call.method) { - default: - throw UnimplementedError("Unimplemented ${call.method} method"); - } - // return null; - } + /// The parameters used to initialize the [PlatformTracingController]. + final PlatformTracingControllerCreationParams params; - ///Starts tracing all [WebView]s. + ///Starts tracing all `WebView`s. ///Depending on the trace mode in trace config specifies how the trace events are recorded. ///For tracing modes [TracingMode.RECORD_UNTIL_FULL] and [TracingMode.RECORD_CONTINUOUSLY] ///the events are recorded using an internal buffer and flushed to the outputStream @@ -62,10 +65,9 @@ class TracingController { /// ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - TracingController.start](https://developer.android.com/reference/android/webkit/TracingController#start(android.webkit.TracingConfig))) - Future start({required TracingSettings settings}) async { - Map args = {}; - args.putIfAbsent("settings", () => settings.toMap()); - await _channel.invokeMethod('start', args); + Future start({required TracingSettings settings}) { + throw UnimplementedError( + 'start is not implemented on the current platform'); } ///Stops tracing and flushes tracing data to the specified output stream. @@ -77,19 +79,18 @@ class TracingController { /// ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - TracingController.stop](https://developer.android.com/reference/android/webkit/TracingController#stop(java.io.OutputStream,%20java.util.concurrent.Executor))) - Future stop({String? filePath}) async { - Map args = {}; - args.putIfAbsent("filePath", () => filePath); - return await _channel.invokeMethod('stop', args); + Future stop({String? filePath}) { + throw UnimplementedError( + 'stop is not implemented on the current platform'); } ///Returns whether the WebView framework is tracing. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - TracingController.isTracing](https://developer.android.com/reference/android/webkit/TracingController#isTracing())) - Future isTracing() async { - Map args = {}; - return await _channel.invokeMethod('isTracing', args); + Future isTracing() { + throw UnimplementedError( + 'isTracing is not implemented on the current platform'); } } @@ -120,7 +121,7 @@ List _serializeCategories(List categories) { return serializedCategories; } -///Class that represents the settings used to configure the [TracingController]. +///Class that represents the settings used to configure the [PlatformTracingController]. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - TracingConfig](https://developer.android.com/reference/androidx/webkit/TracingConfig)) diff --git a/lib/src/android/tracing_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart similarity index 94% rename from lib/src/android/tracing_controller.g.dart rename to flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart index f9695db8..6f87ff47 100644 --- a/lib/src/android/tracing_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart @@ -1,12 +1,12 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'tracing_controller.dart'; +part of 'platform_tracing_controller.dart'; // ************************************************************************** // ExchangeableObjectGenerator // ************************************************************************** -///Class that represents the settings used to configure the [TracingController]. +///Class that represents the settings used to configure the [PlatformTracingController]. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - TracingConfig](https://developer.android.com/reference/androidx/webkit/TracingConfig)) diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.dart b/flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.dart new file mode 100644 index 00000000..2bc3ca87 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.dart @@ -0,0 +1,430 @@ +import 'package:flutter/foundation.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import 'inappwebview_platform.dart'; +import 'types/web_resource_response.dart'; + +/// Object specifying creation parameters for creating a [PlatformWebViewAssetLoader]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformWebViewAssetLoaderCreationParams { + /// Used by the platform implementation to create a new [PlatformWebViewAssetLoader]. + const PlatformWebViewAssetLoaderCreationParams( + {this.domain, this.httpAllowed, this.pathHandlers}); + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewAssetLoader.domain} + final String? domain; + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewAssetLoader.httpAllowed} + final bool? httpAllowed; + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewAssetLoader.pathHandlers} + final List? pathHandlers; +} + +///Helper class to load local files including application's static assets and resources using http(s):// URLs inside a `WebView` class. +///Loading local files using web-like URLs instead of `file://` is desirable as it is compatible with the Same-Origin policy. +/// +///For more context about application's assets and resources and how to normally access them please refer to +///[Android Developer Docs: App resources overview](https://developer.android.com/guide/topics/resources/providing-resources). +/// +///Using http(s):// URLs to access local resources may conflict with a real website. +///This means that local files should only be hosted on domains your organization owns +///(at paths reserved for this purpose) or the default domain reserved for this: `appassets.androidplatform.net`. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +abstract class PlatformWebViewAssetLoader extends PlatformInterface { + ///An unused domain reserved for Android applications to intercept requests for app assets. + /// + ///It is used by default unless the user specified a different domain. + static final String DEFAULT_DOMAIN = "appassets.androidplatform.net"; + + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewAssetLoader.domain} + ///Set the domain under which app assets can be accessed. The default domain is `appassets.androidplatform.net`. + ///{@endtemplate} + String? get domain => params.domain; + + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewAssetLoader.httpAllowed} + ///Allow using the HTTP scheme in addition to HTTPS. The default is to not allow HTTP. + ///{@endtemplate} + bool? get httpAllowed => params.httpAllowed; + + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewAssetLoader.pathHandlers} + ///List of registered path handlers. + /// + ///[WebViewAssetLoader] will try Path Handlers in the order they're registered, + ///and will use whichever is the first to return a non-null. + ///{@endtemplate} + List? get pathHandlers => params.pathHandlers; + + /// Creates a new [PlatformWebViewAssetLoader] + factory PlatformWebViewAssetLoader( + PlatformWebViewAssetLoaderCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformWebViewAssetLoader webViewAssetLoader = + InAppWebViewPlatform.instance!.createPlatformWebViewAssetLoader(params); + PlatformInterface.verify(webViewAssetLoader, _token); + return webViewAssetLoader; + } + + /// Creates a new [PlatformWebViewAssetLoader] to access static methods. + factory PlatformWebViewAssetLoader.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformWebViewAssetLoader webViewAssetLoader = + InAppWebViewPlatform.instance!.createPlatformWebViewAssetLoaderStatic(); + PlatformInterface.verify(webViewAssetLoader, _token); + return webViewAssetLoader; + } + + /// Used by the platform implementation to create a new + /// [PlatformWebViewAssetLoader]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformWebViewAssetLoader.implementation(this.params) : super(token: _token); + + static final Object _token = Object(); + + /// The parameters used to initialize the [PlatformWebViewAssetLoader]. + final PlatformWebViewAssetLoaderCreationParams params; + + PlatformWebViewAssetLoader? fromMap(Map map) { + throw UnimplementedError( + 'fromMap is not implemented on the current platform'); + } + + Map toMap() { + throw UnimplementedError( + 'toMap is not implemented on the current platform'); + } + + Map toJson() { + throw UnimplementedError( + 'toJson is not implemented on the current platform'); + } + + PlatformWebViewAssetLoader copy() { + throw UnimplementedError( + 'copy is not implemented on the current platform'); + } +} + +/// Object specifying creation parameters for creating a [PlatformPathHandler]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformPathHandlerCreationParams { + /// Used by the platform implementation to create a new [PlatformPathHandler]. + const PlatformPathHandlerCreationParams({required this.path}); + + ///{@macro flutter_inappwebview_platform_interface.PlatformPathHandler.path} + final String path; +} + +///A handler that produces responses for a registered path. +/// +///Implement this interface to handle other use-cases according to your app's needs. +abstract class PlatformPathHandler extends PlatformInterface { + /// Creates a new [PlatformWebViewAssetLoader] + factory PlatformPathHandler(PlatformPathHandlerCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformPathHandler pathHandler = + InAppWebViewPlatform.instance!.createPlatformPathHandler(params); + PlatformInterface.verify(pathHandler, _token); + return pathHandler; + } + + /// Used by the platform implementation to create a new + /// [PlatformPathHandler]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformPathHandler.implementation(this.params) : super(token: _token); + + static final Object _token = Object(); + + /// The parameters used to initialize the [PlatformPathHandler]. + final PlatformPathHandlerCreationParams params; + + /// Event handler object that handles the [PlatformPathHandler] events. + PlatformPathHandlerEvents? eventHandler; + + ///{@template flutter_inappwebview_platform_interface.PlatformPathHandler.path} + ///The suffix path to be handled. + /// + ///The path should start and end with a `"/"` and it shouldn't collide with a real web path. + ///{@endtemplate} + String get path => params.path; + + Map toMap() { + throw UnimplementedError( + 'toMap is not implemented on the current platform'); + } + + Map toJson() { + throw UnimplementedError( + 'toJson is not implemented on the current platform'); + } +} + +abstract class PlatformPathHandlerEvents { + ///Handles the requested URL by returning the appropriate response. + /// + ///Returning a `null` value means that the handler decided not to handle this path. + ///In this case, [WebViewAssetLoader] will try the next handler registered on this path or pass to `WebView` that will fall back to network to try to resolve the URL. + /// + ///However, if the handler wants to save unnecessary processing either by another handler or by falling back to network, + ///in cases like a file cannot be found, it may return a `WebResourceResponse(data: null)` + ///which is received as an HTTP response with status code `404` and no body. + Future handle(String path) { + throw UnimplementedError( + 'handle is not implemented on the current platform'); + } +} + +/// Object specifying creation parameters for creating a [PlatformAssetsPathHandler]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformAssetsPathHandlerCreationParams + extends PlatformPathHandlerCreationParams { + /// Used by the platform implementation to create a new [PlatformAssetsPathHandler]. + PlatformAssetsPathHandlerCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformPathHandlerCreationParams params, + ) : super(path: params.path); + + /// Creates a [AndroidCookieManagerCreationParams] instance based on [PlatformCookieManagerCreationParams]. + factory PlatformAssetsPathHandlerCreationParams.fromPlatformPathHandlerCreationParams( + PlatformPathHandlerCreationParams params) { + return PlatformAssetsPathHandlerCreationParams(params); + } +} + +///Handler class to open a file from assets directory in the application APK. +/// +///Opens the requested file from the application's assets directory. +/// +///The matched prefix path used shouldn't be a prefix of a real web path. +///Thus, if the requested file cannot be found a [WebResourceResponse] object with a `null` data will be returned instead of `null`. +///This saves the time of falling back to network and trying to resolve a path that doesn't exist. +///A [WebResourceResponse] with `null` data will be received as an HTTP response with status code `404` and no body. +/// +///The MIME type for the file will be determined from the file's extension using +///[guessContentTypeFromName](https://developer.android.com/reference/java/net/URLConnection.html#guessContentTypeFromName-java.lang.String-). +///Developers should ensure that asset files are named using standard file extensions. +///If the file does not have a recognised extension, `text/plain` will be used by default. +class PlatformAssetsPathHandler extends PlatformPathHandler { + /// Creates a new [PlatformAssetsPathHandler] + factory PlatformAssetsPathHandler( + PlatformAssetsPathHandlerCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformAssetsPathHandler assetsPathHandler = + InAppWebViewPlatform.instance!.createPlatformAssetsPathHandler(params); + PlatformInterface.verify(assetsPathHandler, _token); + return assetsPathHandler; + } + + /// Used by the platform implementation to create a new [PlatformAssetsPathHandler]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformAssetsPathHandler.implementation( + PlatformPathHandlerCreationParams params) + : super.implementation( + params is PlatformAssetsPathHandlerCreationParams + ? params + : PlatformAssetsPathHandlerCreationParams + .fromPlatformPathHandlerCreationParams(params), + ); + + static final Object _token = Object(); +} + +/// Object specifying creation parameters for creating a [PlatformResourcesPathHandler]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformResourcesPathHandlerCreationParams + extends PlatformPathHandlerCreationParams { + /// Used by the platform implementation to create a new [PlatformResourcesPathHandler]. + PlatformResourcesPathHandlerCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformPathHandlerCreationParams params, + ) : super(path: params.path); + + /// Creates a [AndroidCookieManagerCreationParams] instance based on [PlatformCookieManagerCreationParams]. + factory PlatformResourcesPathHandlerCreationParams.fromPlatformPathHandlerCreationParams( + PlatformPathHandlerCreationParams params) { + return PlatformResourcesPathHandlerCreationParams(params); + } +} + +///Handler class to open a file from resources directory in the application APK. +/// +///Opens the requested file from application's resources directory. +/// +///The matched prefix path used shouldn't be a prefix of a real web path. +///Thus, if the requested file cannot be found a [WebResourceResponse] object with a `null` data will be returned instead of `null`. +///This saves the time of falling back to network and trying to resolve a path that doesn't exist. +///A [WebResourceResponse] with `null` data will be received as an HTTP response with status code `404` and no body. +/// +///The MIME type for the file will be determined from the file's extension using +///[guessContentTypeFromName](https://developer.android.com/reference/java/net/URLConnection.html#guessContentTypeFromName-java.lang.String-). +///Developers should ensure that asset files are named using standard file extensions. +///If the file does not have a recognised extension, `text/plain` will be used by default. +class PlatformResourcesPathHandler extends PlatformPathHandler { + /// Creates a new [PlatformResourcesPathHandler] + factory PlatformResourcesPathHandler( + PlatformResourcesPathHandlerCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformResourcesPathHandler resourcesPathHandler = + InAppWebViewPlatform.instance! + .createPlatformResourcesPathHandler(params); + PlatformInterface.verify(resourcesPathHandler, _token); + return resourcesPathHandler; + } + + /// Used by the platform implementation to create a new [PlatformResourcesPathHandler]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformResourcesPathHandler.implementation( + PlatformPathHandlerCreationParams params) + : super.implementation( + params is PlatformResourcesPathHandlerCreationParams + ? params + : PlatformResourcesPathHandlerCreationParams + .fromPlatformPathHandlerCreationParams(params), + ); + + static final Object _token = Object(); +} + +/// Object specifying creation parameters for creating a [PlatformInternalStoragePathHandler]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformInternalStoragePathHandlerCreationParams + extends PlatformPathHandlerCreationParams { + /// Used by the platform implementation to create a new [PlatformInternalStoragePathHandler]. + PlatformInternalStoragePathHandlerCreationParams( + // This parameter prevents breaking changes later. + // ignore: avoid_unused_constructor_parameters + PlatformPathHandlerCreationParams params, + {required this.directory}) + : super(path: params.path); + + /// Creates a [AndroidCookieManagerCreationParams] instance based on [PlatformCookieManagerCreationParams]. + factory PlatformInternalStoragePathHandlerCreationParams.fromPlatformPathHandlerCreationParams( + PlatformPathHandlerCreationParams params, + {required String directory}) { + return PlatformInternalStoragePathHandlerCreationParams(params, + directory: directory); + } + + final String directory; +} + +///Handler class to open files from application internal storage. +///For more information about android storage please refer to +///[Android Developers Docs: Data and file storage overview](https://developer.android.com/guide/topics/data/data-storage). +/// +///To avoid leaking user or app data to the web, make sure to choose [directory] carefully, +///and assume any file under this directory could be accessed by any web page subject to same-origin rules. +/// +///Opens the requested file from the exposed data directory. +/// +///The matched prefix path used shouldn't be a prefix of a real web path. +///Thus, if the requested file cannot be found a [WebResourceResponse] object with a `null` data will be returned instead of `null`. +///This saves the time of falling back to network and trying to resolve a path that doesn't exist. +///A [WebResourceResponse] with `null` data will be received as an HTTP response with status code `404` and no body. +/// +///The MIME type for the file will be determined from the file's extension using +///[guessContentTypeFromName](https://developer.android.com/reference/java/net/URLConnection.html#guessContentTypeFromName-java.lang.String-). +///Developers should ensure that asset files are named using standard file extensions. +///If the file does not have a recognised extension, `text/plain` will be used by default. +class PlatformInternalStoragePathHandler extends PlatformPathHandler { + /// Creates a new [PlatformResourcesPathHandler] + factory PlatformInternalStoragePathHandler( + PlatformInternalStoragePathHandlerCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformInternalStoragePathHandler internalStoragePathHandler = + InAppWebViewPlatform.instance! + .createPlatformInternalStoragePathHandler(params); + PlatformInterface.verify(internalStoragePathHandler, _token); + return internalStoragePathHandler; + } + + /// Used by the platform implementation to create a new [PlatformInternalStoragePathHandler]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformInternalStoragePathHandler.implementation( + PlatformPathHandlerCreationParams params, + {required String directory}) + : super.implementation( + params is PlatformInternalStoragePathHandlerCreationParams + ? params + : PlatformInternalStoragePathHandlerCreationParams + .fromPlatformPathHandlerCreationParams(params, + directory: directory), + ); + + static final Object _token = Object(); + + PlatformInternalStoragePathHandlerCreationParams get _internalParams => + params as PlatformInternalStoragePathHandlerCreationParams; + + String get directory => _internalParams.directory; +} diff --git a/lib/src/android/webview_feature.dart b/flutter_inappwebview_platform_interface/lib/src/platform_webview_feature.dart similarity index 55% rename from lib/src/android/webview_feature.dart rename to flutter_inappwebview_platform_interface/lib/src/platform_webview_feature.dart index 9b502643..cda9d23a 100644 --- a/lib/src/android/webview_feature.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_webview_feature.dart @@ -1,247 +1,69 @@ import 'dart:async'; -import 'package:flutter/services.dart'; +import 'package:flutter/foundation.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import 'process_global_config.dart'; -import '../cookie_manager.dart'; -import '../in_app_webview/in_app_webview_controller.dart'; -import '../in_app_webview/in_app_webview_settings.dart'; -import 'proxy_controller.dart'; -import 'service_worker_controller.dart'; -import '../web_message/main.dart'; -import '../types/user_script_injection_time.dart'; +import 'inappwebview_platform.dart'; -part 'webview_feature.g.dart'; +part 'platform_webview_feature.g.dart'; + +/// Object specifying creation parameters for creating a [PlatformWebViewFeature]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformWebViewFeatureCreationParams { + /// Used by the platform implementation to create a new [PlatformWebViewFeature]. + const PlatformWebViewFeatureCreationParams(); +} ///Class that represents an Android-specific utility class for checking which WebView Support Library features are supported on the device. /// ///**Supported Platforms/Implementations**: ///- Android native WebView -@ExchangeableEnum() -class WebViewFeature_ { - @ExchangeableEnumCustomValue() - static const MethodChannel _channel = const MethodChannel( - 'com.pichillilorenzo/flutter_inappwebview_webviewfeature'); +abstract class PlatformWebViewFeature extends PlatformInterface { + /// Creates a new [PlatformWebViewFeature] + factory PlatformWebViewFeature(PlatformWebViewFeatureCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformWebViewFeature webViewFeature = + InAppWebViewPlatform.instance!.createPlatformWebViewFeature(params); + PlatformInterface.verify(webViewFeature, _token); + return webViewFeature; + } - // ignore: unused_field - final String _value; - - const WebViewFeature_._internal(this._value); - - @ExchangeableObjectMethod(ignore: true) - String toNativeValue() => _value; - - ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewController.createWebMessageChannel]. - static const CREATE_WEB_MESSAGE_CHANNEL = - const WebViewFeature_._internal("CREATE_WEB_MESSAGE_CHANNEL"); - - ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.disabledActionModeMenuItems]. - static const DISABLED_ACTION_MODE_MENU_ITEMS = - const WebViewFeature_._internal("DISABLED_ACTION_MODE_MENU_ITEMS"); - - ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.forceDark]. - static const FORCE_DARK = const WebViewFeature_._internal("FORCE_DARK"); - - ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.forceDarkStrategy]. - static const FORCE_DARK_STRATEGY = - const WebViewFeature_._internal("FORCE_DARK_STRATEGY"); + /// Creates a new empty [PlatformWebViewFeature] to access static methods. + factory PlatformWebViewFeature.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformWebViewFeature webViewFeatureStatic = + InAppWebViewPlatform.instance!.createPlatformWebViewFeatureStatic(); + PlatformInterface.verify(webViewFeatureStatic, _token); + return webViewFeatureStatic; + } + /// Used by the platform implementation to create a new + /// [PlatformWebViewFeature]. /// - static const GET_WEB_CHROME_CLIENT = - const WebViewFeature_._internal("GET_WEB_CHROME_CLIENT"); + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformWebViewFeature.implementation(this.params) + : super(token: _token); - /// - static const GET_WEB_VIEW_CLIENT = - const WebViewFeature_._internal("GET_WEB_VIEW_CLIENT"); + static final Object _token = Object(); - /// - static const GET_WEB_VIEW_RENDERER = - const WebViewFeature_._internal("GET_WEB_VIEW_RENDERER"); - - /// - static const MULTI_PROCESS = const WebViewFeature_._internal("MULTI_PROCESS"); - - ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.offscreenPreRaster]. - static const OFF_SCREEN_PRERASTER = - const WebViewFeature_._internal("OFF_SCREEN_PRERASTER"); - - ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewController.postWebMessage]. - static const POST_WEB_MESSAGE = - const WebViewFeature_._internal("POST_WEB_MESSAGE"); - - ///Feature for [isFeatureSupported]. This feature covers [ProxyController.setProxyOverride] and [ProxyController.clearProxyOverride]. - static const PROXY_OVERRIDE = - const WebViewFeature_._internal("PROXY_OVERRIDE"); - - ///Feature for [isFeatureSupported]. This feature covers [ProxySettings.reverseBypassEnabled]. - static const PROXY_OVERRIDE_REVERSE_BYPASS = - const WebViewFeature_._internal("PROXY_OVERRIDE_REVERSE_BYPASS"); - - /// - static const RECEIVE_HTTP_ERROR = - const WebViewFeature_._internal("RECEIVE_HTTP_ERROR"); - - /// - static const RECEIVE_WEB_RESOURCE_ERROR = - const WebViewFeature_._internal("RECEIVE_WEB_RESOURCE_ERROR"); - - ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewController.setSafeBrowsingAllowlist]. - static const SAFE_BROWSING_ALLOWLIST = - const WebViewFeature_._internal("SAFE_BROWSING_ALLOWLIST"); - - ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.safeBrowsingEnabled]. - static const SAFE_BROWSING_ENABLE = - const WebViewFeature_._internal("SAFE_BROWSING_ENABLE"); - - /// - static const SAFE_BROWSING_HIT = - const WebViewFeature_._internal("SAFE_BROWSING_HIT"); - - ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl]. - static const SAFE_BROWSING_PRIVACY_POLICY_URL = - const WebViewFeature_._internal("SAFE_BROWSING_PRIVACY_POLICY_URL"); - - /// - static const SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY = - const WebViewFeature_._internal("SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY"); - - /// - static const SAFE_BROWSING_RESPONSE_PROCEED = - const WebViewFeature_._internal("SAFE_BROWSING_RESPONSE_PROCEED"); - - /// - static const SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL = - const WebViewFeature_._internal( - "SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL"); - - ///Use [SAFE_BROWSING_ALLOWLIST] instead. - @Deprecated('Use SAFE_BROWSING_ALLOWLIST instead') - static const SAFE_BROWSING_WHITELIST = - const WebViewFeature_._internal("SAFE_BROWSING_WHITELIST"); - - ///Feature for [isFeatureSupported]. This feature covers [ServiceWorkerController]. - static const SERVICE_WORKER_BASIC_USAGE = - const WebViewFeature_._internal("SERVICE_WORKER_BASIC_USAGE"); - - ///Feature for [isFeatureSupported]. This feature covers [ServiceWorkerController.setBlockNetworkLoads] and [ServiceWorkerController.getBlockNetworkLoads]. - static const SERVICE_WORKER_BLOCK_NETWORK_LOADS = - const WebViewFeature_._internal("SERVICE_WORKER_BLOCK_NETWORK_LOADS"); - - ///Feature for [isFeatureSupported]. This feature covers [ServiceWorkerController.setCacheMode] and [ServiceWorkerController.getCacheMode]. - static const SERVICE_WORKER_CACHE_MODE = - const WebViewFeature_._internal("SERVICE_WORKER_CACHE_MODE"); - - ///Feature for [isFeatureSupported]. This feature covers [ServiceWorkerController.setAllowContentAccess] and [ServiceWorkerController.getAllowContentAccess]. - static const SERVICE_WORKER_CONTENT_ACCESS = - const WebViewFeature_._internal("SERVICE_WORKER_CONTENT_ACCESS"); - - ///Feature for [isFeatureSupported]. This feature covers [ServiceWorkerController.setAllowFileAccess] and [ServiceWorkerController.getAllowFileAccess]. - static const SERVICE_WORKER_FILE_ACCESS = - const WebViewFeature_._internal("SERVICE_WORKER_FILE_ACCESS"); - - ///Feature for [isFeatureSupported]. This feature covers [ServiceWorkerClient.shouldInterceptRequest]. - static const SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST = - const WebViewFeature_._internal( - "SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST"); - - /// - static const SHOULD_OVERRIDE_WITH_REDIRECTS = - const WebViewFeature_._internal("SHOULD_OVERRIDE_WITH_REDIRECTS"); - - ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewController.startSafeBrowsing]. - static const START_SAFE_BROWSING = - const WebViewFeature_._internal("START_SAFE_BROWSING"); - - /// - static const TRACING_CONTROLLER_BASIC_USAGE = - const WebViewFeature_._internal("TRACING_CONTROLLER_BASIC_USAGE"); - - /// - static const VISUAL_STATE_CALLBACK = - const WebViewFeature_._internal("VISUAL_STATE_CALLBACK"); - - /// - static const WEB_MESSAGE_CALLBACK_ON_MESSAGE = - const WebViewFeature_._internal("WEB_MESSAGE_CALLBACK_ON_MESSAGE"); - - ///Feature for [isFeatureSupported]. This feature covers [WebMessageListener]. - static const WEB_MESSAGE_LISTENER = - const WebViewFeature_._internal("WEB_MESSAGE_LISTENER"); - - /// - static const WEB_MESSAGE_PORT_CLOSE = - const WebViewFeature_._internal("WEB_MESSAGE_PORT_CLOSE"); - - /// - static const WEB_MESSAGE_PORT_POST_MESSAGE = - const WebViewFeature_._internal("WEB_MESSAGE_PORT_POST_MESSAGE"); - - /// - static const WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK = - const WebViewFeature_._internal("WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK"); - - /// - static const WEB_RESOURCE_ERROR_GET_CODE = - const WebViewFeature_._internal("WEB_RESOURCE_ERROR_GET_CODE"); - - /// - static const WEB_RESOURCE_ERROR_GET_DESCRIPTION = - const WebViewFeature_._internal("WEB_RESOURCE_ERROR_GET_DESCRIPTION"); - - /// - static const WEB_RESOURCE_REQUEST_IS_REDIRECT = - const WebViewFeature_._internal("WEB_RESOURCE_REQUEST_IS_REDIRECT"); - - /// - static const WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE = - const WebViewFeature_._internal("WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE"); - - /// - static const WEB_VIEW_RENDERER_TERMINATE = - const WebViewFeature_._internal("WEB_VIEW_RENDERER_TERMINATE"); - - ///Feature for [isFeatureSupported]. This feature covers [UserScriptInjectionTime.AT_DOCUMENT_START]. - static const DOCUMENT_START_SCRIPT = - const WebViewFeature_._internal("DOCUMENT_START_SCRIPT"); - - ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.willSuppressErrorPage]. - static const SUPPRESS_ERROR_PAGE = - const WebViewFeature_._internal("SUPPRESS_ERROR_PAGE"); - - ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.algorithmicDarkeningAllowed]. - static const ALGORITHMIC_DARKENING = - const WebViewFeature_._internal("ALGORITHMIC_DARKENING"); - - ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.enterpriseAuthenticationAppLinkPolicyEnabled]. - static const ENTERPRISE_AUTHENTICATION_APP_LINK_POLICY = - const WebViewFeature_._internal( - "ENTERPRISE_AUTHENTICATION_APP_LINK_POLICY"); - - ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewController.getVariationsHeader]. - static const GET_VARIATIONS_HEADER = - const WebViewFeature_._internal("GET_VARIATIONS_HEADER"); - - ///Feature for [isFeatureSupported]. This feature covers cookie attributes of [CookieManager.getCookie] and [CookieManager.getCookies] methods. - static const GET_COOKIE_INFO = - const WebViewFeature_._internal("GET_COOKIE_INFO"); - - ///Feature for [isFeatureSupported]. This feature covers cookie attributes of [CookieManager.getCookie] and [CookieManager.getCookies] methods. - static const REQUESTED_WITH_HEADER_ALLOW_LIST = - const WebViewFeature_._internal("REQUESTED_WITH_HEADER_ALLOW_LIST"); - - ///Feature for [isFeatureSupported]. This feature covers [WebMessagePort.postMessage] with `ArrayBuffer` type, - ///[InAppWebViewController.postWebMessage] with `ArrayBuffer` type, and [JavaScriptReplyProxy.postMessage] with `ArrayBuffer` type. - static const WEB_MESSAGE_ARRAY_BUFFER = - const WebViewFeature_._internal("WEB_MESSAGE_ARRAY_BUFFER"); - - ///Feature for [isStartupFeatureSupported]. This feature covers [ProcessGlobalConfigSettings.dataDirectorySuffix]. - static const STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX = - const WebViewFeature_._internal( - "STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX"); - - ///Feature for [isStartupFeatureSupported]. This feature covers [ProcessGlobalConfigSettings.directoryBasePaths]. - static const STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS = - const WebViewFeature_._internal( - "STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS"); + /// The parameters used to initialize the [PlatformWebViewFeature]. + final PlatformWebViewFeatureCreationParams params; ///Return whether a feature is supported at run-time. On devices running Android version `Build.VERSION_CODES.LOLLIPOP` and higher, ///this will check whether a feature is supported, depending on the combination of the desired feature, the Android version of device, @@ -256,10 +78,9 @@ class WebViewFeature_ { ///Furthermore, if this method returns `false` for a particular feature, any callback guarded by that feature will not be invoked. /// ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String) - static Future isFeatureSupported(WebViewFeature_ feature) async { - Map args = {}; - args.putIfAbsent("feature", () => feature.toNativeValue()); - return await _channel.invokeMethod('isFeatureSupported', args); + Future isFeatureSupported(WebViewFeature feature) { + throw UnimplementedError( + 'isFeatureSupported is not implemented on the current platform'); } ///Return whether a startup feature is supported at run-time. @@ -277,23 +98,246 @@ class WebViewFeature_ { ///any callback guarded by that feature will not be invoked. /// ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String) - static Future isStartupFeatureSupported( - WebViewFeature_ startupFeature) async { - Map args = {}; - args.putIfAbsent("startupFeature", () => startupFeature.toNativeValue()); - return await _channel.invokeMethod('isStartupFeatureSupported', args); + Future isStartupFeatureSupported( + WebViewFeature startupFeature) { + throw UnimplementedError( + 'isStartupFeatureSupported is not implemented on the current platform'); } } +///Class that represents an Android-specific utility class for checking which WebView Support Library features are supported on the device. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +@ExchangeableEnum() +class WebViewFeature_ { + // ignore: unused_field + final String _value; + + const WebViewFeature_._internal(this._value); + + @ExchangeableObjectMethod(ignore: true) + String toNativeValue() => _value; + + ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewController.createWebMessageChannel]. + static const CREATE_WEB_MESSAGE_CHANNEL = + const WebViewFeature_._internal("CREATE_WEB_MESSAGE_CHANNEL"); + + ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.disabledActionModeMenuItems]. + static const DISABLED_ACTION_MODE_MENU_ITEMS = + const WebViewFeature_._internal("DISABLED_ACTION_MODE_MENU_ITEMS"); + + ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.forceDark]. + static const FORCE_DARK = const WebViewFeature_._internal("FORCE_DARK"); + + ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.forceDarkStrategy]. + static const FORCE_DARK_STRATEGY = + const WebViewFeature_._internal("FORCE_DARK_STRATEGY"); + + /// + static const GET_WEB_CHROME_CLIENT = + const WebViewFeature_._internal("GET_WEB_CHROME_CLIENT"); + + /// + static const GET_WEB_VIEW_CLIENT = + const WebViewFeature_._internal("GET_WEB_VIEW_CLIENT"); + + /// + static const GET_WEB_VIEW_RENDERER = + const WebViewFeature_._internal("GET_WEB_VIEW_RENDERER"); + + /// + static const MULTI_PROCESS = const WebViewFeature_._internal("MULTI_PROCESS"); + + ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.offscreenPreRaster]. + static const OFF_SCREEN_PRERASTER = + const WebViewFeature_._internal("OFF_SCREEN_PRERASTER"); + + ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewController.postWebMessage]. + static const POST_WEB_MESSAGE = + const WebViewFeature_._internal("POST_WEB_MESSAGE"); + + ///Feature for [isFeatureSupported]. This feature covers [ProxyController.setProxyOverride] and [ProxyController.clearProxyOverride]. + static const PROXY_OVERRIDE = + const WebViewFeature_._internal("PROXY_OVERRIDE"); + + ///Feature for [isFeatureSupported]. This feature covers [ProxySettings.reverseBypassEnabled]. + static const PROXY_OVERRIDE_REVERSE_BYPASS = + const WebViewFeature_._internal("PROXY_OVERRIDE_REVERSE_BYPASS"); + + /// + static const RECEIVE_HTTP_ERROR = + const WebViewFeature_._internal("RECEIVE_HTTP_ERROR"); + + /// + static const RECEIVE_WEB_RESOURCE_ERROR = + const WebViewFeature_._internal("RECEIVE_WEB_RESOURCE_ERROR"); + + ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewController.setSafeBrowsingAllowlist]. + static const SAFE_BROWSING_ALLOWLIST = + const WebViewFeature_._internal("SAFE_BROWSING_ALLOWLIST"); + + ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.safeBrowsingEnabled]. + static const SAFE_BROWSING_ENABLE = + const WebViewFeature_._internal("SAFE_BROWSING_ENABLE"); + + /// + static const SAFE_BROWSING_HIT = + const WebViewFeature_._internal("SAFE_BROWSING_HIT"); + + ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl]. + static const SAFE_BROWSING_PRIVACY_POLICY_URL = + const WebViewFeature_._internal("SAFE_BROWSING_PRIVACY_POLICY_URL"); + + /// + static const SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY = + const WebViewFeature_._internal("SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY"); + + /// + static const SAFE_BROWSING_RESPONSE_PROCEED = + const WebViewFeature_._internal("SAFE_BROWSING_RESPONSE_PROCEED"); + + /// + static const SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL = + const WebViewFeature_._internal( + "SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL"); + + ///Use [SAFE_BROWSING_ALLOWLIST] instead. + @Deprecated('Use SAFE_BROWSING_ALLOWLIST instead') + static const SAFE_BROWSING_WHITELIST = + const WebViewFeature_._internal("SAFE_BROWSING_WHITELIST"); + + ///Feature for [isFeatureSupported]. This feature covers [ServiceWorkerController]. + static const SERVICE_WORKER_BASIC_USAGE = + const WebViewFeature_._internal("SERVICE_WORKER_BASIC_USAGE"); + + ///Feature for [isFeatureSupported]. This feature covers [ServiceWorkerController.setBlockNetworkLoads] and [ServiceWorkerController.getBlockNetworkLoads]. + static const SERVICE_WORKER_BLOCK_NETWORK_LOADS = + const WebViewFeature_._internal("SERVICE_WORKER_BLOCK_NETWORK_LOADS"); + + ///Feature for [isFeatureSupported]. This feature covers [ServiceWorkerController.setCacheMode] and [ServiceWorkerController.getCacheMode]. + static const SERVICE_WORKER_CACHE_MODE = + const WebViewFeature_._internal("SERVICE_WORKER_CACHE_MODE"); + + ///Feature for [isFeatureSupported]. This feature covers [ServiceWorkerController.setAllowContentAccess] and [ServiceWorkerController.getAllowContentAccess]. + static const SERVICE_WORKER_CONTENT_ACCESS = + const WebViewFeature_._internal("SERVICE_WORKER_CONTENT_ACCESS"); + + ///Feature for [isFeatureSupported]. This feature covers [ServiceWorkerController.setAllowFileAccess] and [ServiceWorkerController.getAllowFileAccess]. + static const SERVICE_WORKER_FILE_ACCESS = + const WebViewFeature_._internal("SERVICE_WORKER_FILE_ACCESS"); + + ///Feature for [isFeatureSupported]. This feature covers [ServiceWorkerClient.shouldInterceptRequest]. + static const SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST = + const WebViewFeature_._internal( + "SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST"); + + /// + static const SHOULD_OVERRIDE_WITH_REDIRECTS = + const WebViewFeature_._internal("SHOULD_OVERRIDE_WITH_REDIRECTS"); + + ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewController.startSafeBrowsing]. + static const START_SAFE_BROWSING = + const WebViewFeature_._internal("START_SAFE_BROWSING"); + + /// + static const TRACING_CONTROLLER_BASIC_USAGE = + const WebViewFeature_._internal("TRACING_CONTROLLER_BASIC_USAGE"); + + /// + static const VISUAL_STATE_CALLBACK = + const WebViewFeature_._internal("VISUAL_STATE_CALLBACK"); + + /// + static const WEB_MESSAGE_CALLBACK_ON_MESSAGE = + const WebViewFeature_._internal("WEB_MESSAGE_CALLBACK_ON_MESSAGE"); + + ///Feature for [isFeatureSupported]. This feature covers [WebMessageListener]. + static const WEB_MESSAGE_LISTENER = + const WebViewFeature_._internal("WEB_MESSAGE_LISTENER"); + + /// + static const WEB_MESSAGE_PORT_CLOSE = + const WebViewFeature_._internal("WEB_MESSAGE_PORT_CLOSE"); + + /// + static const WEB_MESSAGE_PORT_POST_MESSAGE = + const WebViewFeature_._internal("WEB_MESSAGE_PORT_POST_MESSAGE"); + + /// + static const WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK = + const WebViewFeature_._internal("WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK"); + + /// + static const WEB_RESOURCE_ERROR_GET_CODE = + const WebViewFeature_._internal("WEB_RESOURCE_ERROR_GET_CODE"); + + /// + static const WEB_RESOURCE_ERROR_GET_DESCRIPTION = + const WebViewFeature_._internal("WEB_RESOURCE_ERROR_GET_DESCRIPTION"); + + /// + static const WEB_RESOURCE_REQUEST_IS_REDIRECT = + const WebViewFeature_._internal("WEB_RESOURCE_REQUEST_IS_REDIRECT"); + + /// + static const WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE = + const WebViewFeature_._internal("WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE"); + + /// + static const WEB_VIEW_RENDERER_TERMINATE = + const WebViewFeature_._internal("WEB_VIEW_RENDERER_TERMINATE"); + + ///Feature for [isFeatureSupported]. This feature covers [UserScriptInjectionTime.AT_DOCUMENT_START]. + static const DOCUMENT_START_SCRIPT = + const WebViewFeature_._internal("DOCUMENT_START_SCRIPT"); + + ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.willSuppressErrorPage]. + static const SUPPRESS_ERROR_PAGE = + const WebViewFeature_._internal("SUPPRESS_ERROR_PAGE"); + + ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.algorithmicDarkeningAllowed]. + static const ALGORITHMIC_DARKENING = + const WebViewFeature_._internal("ALGORITHMIC_DARKENING"); + + ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.enterpriseAuthenticationAppLinkPolicyEnabled]. + static const ENTERPRISE_AUTHENTICATION_APP_LINK_POLICY = + const WebViewFeature_._internal( + "ENTERPRISE_AUTHENTICATION_APP_LINK_POLICY"); + + ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewController.getVariationsHeader]. + static const GET_VARIATIONS_HEADER = + const WebViewFeature_._internal("GET_VARIATIONS_HEADER"); + + ///Feature for [isFeatureSupported]. This feature covers cookie attributes of [CookieManager.getCookie] and [CookieManager.getCookies] methods. + static const GET_COOKIE_INFO = + const WebViewFeature_._internal("GET_COOKIE_INFO"); + + ///Feature for [isFeatureSupported]. This feature covers cookie attributes of [CookieManager.getCookie] and [CookieManager.getCookies] methods. + static const REQUESTED_WITH_HEADER_ALLOW_LIST = + const WebViewFeature_._internal("REQUESTED_WITH_HEADER_ALLOW_LIST"); + + ///Feature for [isFeatureSupported]. This feature covers [WebMessagePort.postMessage] with `ArrayBuffer` type, + ///[InAppWebViewController.postWebMessage] with `ArrayBuffer` type, and [JavaScriptReplyProxy.postMessage] with `ArrayBuffer` type. + static const WEB_MESSAGE_ARRAY_BUFFER = + const WebViewFeature_._internal("WEB_MESSAGE_ARRAY_BUFFER"); + + ///Feature for [isStartupFeatureSupported]. This feature covers [ProcessGlobalConfigSettings.dataDirectorySuffix]. + static const STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX = + const WebViewFeature_._internal( + "STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX"); + + ///Feature for [isStartupFeatureSupported]. This feature covers [ProcessGlobalConfigSettings.directoryBasePaths]. + static const STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS = + const WebViewFeature_._internal( + "STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS"); +} + ///Class that represents an Android-specific utility class for checking which WebView Support Library features are supported on the device. ///Use [WebViewFeature] instead. @Deprecated("Use WebViewFeature instead") @ExchangeableEnum() class AndroidWebViewFeature_ { - @ExchangeableEnumCustomValue() - static const MethodChannel _channel = const MethodChannel( - 'com.pichillilorenzo/flutter_inappwebview_webviewfeature'); - // ignore: unused_field final String _value; @@ -304,207 +348,196 @@ class AndroidWebViewFeature_ { /// static const CREATE_WEB_MESSAGE_CHANNEL = - const AndroidWebViewFeature_._internal("CREATE_WEB_MESSAGE_CHANNEL"); + const AndroidWebViewFeature_._internal("CREATE_WEB_MESSAGE_CHANNEL"); /// static const DISABLED_ACTION_MODE_MENU_ITEMS = - const AndroidWebViewFeature_._internal("DISABLED_ACTION_MODE_MENU_ITEMS"); + const AndroidWebViewFeature_._internal("DISABLED_ACTION_MODE_MENU_ITEMS"); /// static const FORCE_DARK = - const AndroidWebViewFeature_._internal("FORCE_DARK"); + const AndroidWebViewFeature_._internal("FORCE_DARK"); /// static const FORCE_DARK_STRATEGY = - const AndroidWebViewFeature_._internal("FORCE_DARK_STRATEGY"); + const AndroidWebViewFeature_._internal("FORCE_DARK_STRATEGY"); /// static const GET_WEB_CHROME_CLIENT = - const AndroidWebViewFeature_._internal("GET_WEB_CHROME_CLIENT"); + const AndroidWebViewFeature_._internal("GET_WEB_CHROME_CLIENT"); /// static const GET_WEB_VIEW_CLIENT = - const AndroidWebViewFeature_._internal("GET_WEB_VIEW_CLIENT"); + const AndroidWebViewFeature_._internal("GET_WEB_VIEW_CLIENT"); /// static const GET_WEB_VIEW_RENDERER = - const AndroidWebViewFeature_._internal("GET_WEB_VIEW_RENDERER"); + const AndroidWebViewFeature_._internal("GET_WEB_VIEW_RENDERER"); /// static const MULTI_PROCESS = - const AndroidWebViewFeature_._internal("MULTI_PROCESS"); + const AndroidWebViewFeature_._internal("MULTI_PROCESS"); /// static const OFF_SCREEN_PRERASTER = - const AndroidWebViewFeature_._internal("OFF_SCREEN_PRERASTER"); + const AndroidWebViewFeature_._internal("OFF_SCREEN_PRERASTER"); /// static const POST_WEB_MESSAGE = - const AndroidWebViewFeature_._internal("POST_WEB_MESSAGE"); + const AndroidWebViewFeature_._internal("POST_WEB_MESSAGE"); /// static const PROXY_OVERRIDE = - const AndroidWebViewFeature_._internal("PROXY_OVERRIDE"); + const AndroidWebViewFeature_._internal("PROXY_OVERRIDE"); /// static const RECEIVE_HTTP_ERROR = - const AndroidWebViewFeature_._internal("RECEIVE_HTTP_ERROR"); + const AndroidWebViewFeature_._internal("RECEIVE_HTTP_ERROR"); /// static const RECEIVE_WEB_RESOURCE_ERROR = - const AndroidWebViewFeature_._internal("RECEIVE_WEB_RESOURCE_ERROR"); + const AndroidWebViewFeature_._internal("RECEIVE_WEB_RESOURCE_ERROR"); /// static const SAFE_BROWSING_ALLOWLIST = - const AndroidWebViewFeature_._internal("SAFE_BROWSING_ALLOWLIST"); + const AndroidWebViewFeature_._internal("SAFE_BROWSING_ALLOWLIST"); /// static const SAFE_BROWSING_ENABLE = - const AndroidWebViewFeature_._internal("SAFE_BROWSING_ENABLE"); + const AndroidWebViewFeature_._internal("SAFE_BROWSING_ENABLE"); /// static const SAFE_BROWSING_HIT = - const AndroidWebViewFeature_._internal("SAFE_BROWSING_HIT"); + const AndroidWebViewFeature_._internal("SAFE_BROWSING_HIT"); /// static const SAFE_BROWSING_PRIVACY_POLICY_URL = - const AndroidWebViewFeature_._internal( - "SAFE_BROWSING_PRIVACY_POLICY_URL"); + const AndroidWebViewFeature_._internal( + "SAFE_BROWSING_PRIVACY_POLICY_URL"); /// static const SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY = - const AndroidWebViewFeature_._internal( - "SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY"); + const AndroidWebViewFeature_._internal( + "SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY"); /// static const SAFE_BROWSING_RESPONSE_PROCEED = - const AndroidWebViewFeature_._internal("SAFE_BROWSING_RESPONSE_PROCEED"); + const AndroidWebViewFeature_._internal("SAFE_BROWSING_RESPONSE_PROCEED"); /// static const SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL = - const AndroidWebViewFeature_._internal( - "SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL"); + const AndroidWebViewFeature_._internal( + "SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL"); ///Use [SAFE_BROWSING_ALLOWLIST] instead. @Deprecated('Use SAFE_BROWSING_ALLOWLIST instead') static const SAFE_BROWSING_WHITELIST = - const AndroidWebViewFeature_._internal("SAFE_BROWSING_WHITELIST"); + const AndroidWebViewFeature_._internal("SAFE_BROWSING_WHITELIST"); /// static const SERVICE_WORKER_BASIC_USAGE = - const AndroidWebViewFeature_._internal("SERVICE_WORKER_BASIC_USAGE"); + const AndroidWebViewFeature_._internal("SERVICE_WORKER_BASIC_USAGE"); /// static const SERVICE_WORKER_BLOCK_NETWORK_LOADS = - const AndroidWebViewFeature_._internal( - "SERVICE_WORKER_BLOCK_NETWORK_LOADS"); + const AndroidWebViewFeature_._internal( + "SERVICE_WORKER_BLOCK_NETWORK_LOADS"); /// static const SERVICE_WORKER_CACHE_MODE = - const AndroidWebViewFeature_._internal("SERVICE_WORKER_CACHE_MODE"); + const AndroidWebViewFeature_._internal("SERVICE_WORKER_CACHE_MODE"); /// static const SERVICE_WORKER_CONTENT_ACCESS = - const AndroidWebViewFeature_._internal("SERVICE_WORKER_CONTENT_ACCESS"); + const AndroidWebViewFeature_._internal("SERVICE_WORKER_CONTENT_ACCESS"); /// static const SERVICE_WORKER_FILE_ACCESS = - const AndroidWebViewFeature_._internal("SERVICE_WORKER_FILE_ACCESS"); + const AndroidWebViewFeature_._internal("SERVICE_WORKER_FILE_ACCESS"); /// static const SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST = - const AndroidWebViewFeature_._internal( - "SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST"); + const AndroidWebViewFeature_._internal( + "SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST"); /// static const SHOULD_OVERRIDE_WITH_REDIRECTS = - const AndroidWebViewFeature_._internal("SHOULD_OVERRIDE_WITH_REDIRECTS"); + const AndroidWebViewFeature_._internal("SHOULD_OVERRIDE_WITH_REDIRECTS"); /// static const START_SAFE_BROWSING = - const AndroidWebViewFeature_._internal("START_SAFE_BROWSING"); + const AndroidWebViewFeature_._internal("START_SAFE_BROWSING"); /// static const TRACING_CONTROLLER_BASIC_USAGE = - const AndroidWebViewFeature_._internal("TRACING_CONTROLLER_BASIC_USAGE"); + const AndroidWebViewFeature_._internal("TRACING_CONTROLLER_BASIC_USAGE"); /// static const VISUAL_STATE_CALLBACK = - const AndroidWebViewFeature_._internal("VISUAL_STATE_CALLBACK"); + const AndroidWebViewFeature_._internal("VISUAL_STATE_CALLBACK"); /// static const WEB_MESSAGE_CALLBACK_ON_MESSAGE = - const AndroidWebViewFeature_._internal("WEB_MESSAGE_CALLBACK_ON_MESSAGE"); + const AndroidWebViewFeature_._internal("WEB_MESSAGE_CALLBACK_ON_MESSAGE"); /// static const WEB_MESSAGE_LISTENER = - const AndroidWebViewFeature_._internal("WEB_MESSAGE_LISTENER"); + const AndroidWebViewFeature_._internal("WEB_MESSAGE_LISTENER"); /// static const WEB_MESSAGE_PORT_CLOSE = - const AndroidWebViewFeature_._internal("WEB_MESSAGE_PORT_CLOSE"); + const AndroidWebViewFeature_._internal("WEB_MESSAGE_PORT_CLOSE"); /// static const WEB_MESSAGE_PORT_POST_MESSAGE = - const AndroidWebViewFeature_._internal("WEB_MESSAGE_PORT_POST_MESSAGE"); + const AndroidWebViewFeature_._internal("WEB_MESSAGE_PORT_POST_MESSAGE"); /// static const WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK = - const AndroidWebViewFeature_._internal( - "WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK"); + const AndroidWebViewFeature_._internal( + "WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK"); /// static const WEB_RESOURCE_ERROR_GET_CODE = - const AndroidWebViewFeature_._internal("WEB_RESOURCE_ERROR_GET_CODE"); + const AndroidWebViewFeature_._internal("WEB_RESOURCE_ERROR_GET_CODE"); /// static const WEB_RESOURCE_ERROR_GET_DESCRIPTION = - const AndroidWebViewFeature_._internal( - "WEB_RESOURCE_ERROR_GET_DESCRIPTION"); + const AndroidWebViewFeature_._internal( + "WEB_RESOURCE_ERROR_GET_DESCRIPTION"); /// static const WEB_RESOURCE_REQUEST_IS_REDIRECT = - const AndroidWebViewFeature_._internal( - "WEB_RESOURCE_REQUEST_IS_REDIRECT"); + const AndroidWebViewFeature_._internal( + "WEB_RESOURCE_REQUEST_IS_REDIRECT"); /// static const WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE = - const AndroidWebViewFeature_._internal( - "WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE"); + const AndroidWebViewFeature_._internal( + "WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE"); /// static const WEB_VIEW_RENDERER_TERMINATE = - const AndroidWebViewFeature_._internal("WEB_VIEW_RENDERER_TERMINATE"); + const AndroidWebViewFeature_._internal("WEB_VIEW_RENDERER_TERMINATE"); ///Feature for [isFeatureSupported]. This feature covers [UserScriptInjectionTime.AT_DOCUMENT_START]. static const DOCUMENT_START_SCRIPT = - const AndroidWebViewFeature_._internal("DOCUMENT_START_SCRIPT"); + const AndroidWebViewFeature_._internal("DOCUMENT_START_SCRIPT"); ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.willSuppressErrorPage]. static const SUPPRESS_ERROR_PAGE = - const AndroidWebViewFeature_._internal("SUPPRESS_ERROR_PAGE"); + const AndroidWebViewFeature_._internal("SUPPRESS_ERROR_PAGE"); ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.algorithmicDarkeningAllowed]. static const ALGORITHMIC_DARKENING = - const AndroidWebViewFeature_._internal("ALGORITHMIC_DARKENING"); + const AndroidWebViewFeature_._internal("ALGORITHMIC_DARKENING"); ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.requestedWithHeaderMode]. static const REQUESTED_WITH_HEADER_CONTROL = - const AndroidWebViewFeature_._internal("REQUESTED_WITH_HEADER_CONTROL"); + const AndroidWebViewFeature_._internal("REQUESTED_WITH_HEADER_CONTROL"); ///Feature for [isFeatureSupported]. This feature covers [InAppWebViewSettings.enterpriseAuthenticationAppLinkPolicyEnabled]. static const ENTERPRISE_AUTHENTICATION_APP_LINK_POLICY = - const AndroidWebViewFeature_._internal( - "ENTERPRISE_AUTHENTICATION_APP_LINK_POLICY"); - - ///Return whether a feature is supported at run-time. On devices running Android version `Build.VERSION_CODES.LOLLIPOP` and higher, - ///this will check whether a feature is supported, depending on the combination of the desired feature, the Android version of device, - ///and the WebView APK on the device. If running on a device with a lower API level, this will always return `false`. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String) - static Future isFeatureSupported(AndroidWebViewFeature_ feature) async { - Map args = {}; - args.putIfAbsent("feature", () => feature.toNativeValue()); - return await _channel.invokeMethod('isFeatureSupported', args); - } -} + const AndroidWebViewFeature_._internal( + "ENTERPRISE_AUTHENTICATION_APP_LINK_POLICY"); +} \ No newline at end of file diff --git a/lib/src/android/webview_feature.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_webview_feature.g.dart similarity index 87% rename from lib/src/android/webview_feature.g.dart rename to flutter_inappwebview_platform_interface/lib/src/platform_webview_feature.g.dart index 84cfe09c..2a58157b 100644 --- a/lib/src/android/webview_feature.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_webview_feature.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'webview_feature.dart'; +part of 'platform_webview_feature.dart'; // ************************************************************************** // ExchangeableEnumGenerator @@ -237,8 +237,6 @@ class WebViewFeature { /// static const WEB_VIEW_RENDERER_TERMINATE = WebViewFeature._internal( 'WEB_VIEW_RENDERER_TERMINATE', 'WEB_VIEW_RENDERER_TERMINATE'); - static const _channel = const MethodChannel( - 'com.pichillilorenzo/flutter_inappwebview_webviewfeature'); ///Set of all values of [WebViewFeature]. static final Set values = [ @@ -322,47 +320,6 @@ class WebViewFeature { return null; } - ///Return whether a feature is supported at run-time. On devices running Android version `Build.VERSION_CODES.LOLLIPOP` and higher, - ///this will check whether a feature is supported, depending on the combination of the desired feature, the Android version of device, - ///and the WebView APK on the device. If running on a device with a lower API level, this will always return `false`. - /// - ///**Note**: This method is different from [isStartupFeatureSupported] and this - ///method only accepts certain features. - ///Please verify that the correct feature checking method is used for a particular feature. - /// - ///**Note**: If this method returns `false`, it is not safe to invoke the methods - ///requiring the desired feature. - ///Furthermore, if this method returns `false` for a particular feature, any callback guarded by that feature will not be invoked. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String) - static Future isFeatureSupported(WebViewFeature feature) async { - Map args = {}; - args.putIfAbsent("feature", () => feature.toNativeValue()); - return await _channel.invokeMethod('isFeatureSupported', args); - } - - ///Return whether a startup feature is supported at run-time. - ///On devices running Android version `Build.VERSION_CODES.LOLLIPOP` and higher, - ///this will check whether a startup feature is supported, - ///depending on the combination of the desired feature, - ///the Android version of device, and the WebView APK on the device. - ///If running on a device with a lower API level, this will always return `false`. - /// - ///**Note**: This method is different from [isFeatureSupported] and this method only accepts startup features. - ///Please verify that the correct feature checking method is used for a particular feature. - /// - ///**Note**: If this method returns `false`, it is not safe to invoke the methods requiring the desired feature. - ///Furthermore, if this method returns `false` for a particular feature, - ///any callback guarded by that feature will not be invoked. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String) - static Future isStartupFeatureSupported( - WebViewFeature startupFeature) async { - Map args = {}; - args.putIfAbsent("startupFeature", () => startupFeature.toNativeValue()); - return await _channel.invokeMethod('isStartupFeatureSupported', args); - } - ///Gets [String] value. String toValue() => _value; @@ -590,8 +547,6 @@ class AndroidWebViewFeature { /// static const WEB_VIEW_RENDERER_TERMINATE = AndroidWebViewFeature._internal( 'WEB_VIEW_RENDERER_TERMINATE', 'WEB_VIEW_RENDERER_TERMINATE'); - static const _channel = const MethodChannel( - 'com.pichillilorenzo/flutter_inappwebview_webviewfeature'); ///Set of all values of [AndroidWebViewFeature]. static final Set values = [ @@ -669,17 +624,6 @@ class AndroidWebViewFeature { return null; } - ///Return whether a feature is supported at run-time. On devices running Android version `Build.VERSION_CODES.LOLLIPOP` and higher, - ///this will check whether a feature is supported, depending on the combination of the desired feature, the Android version of device, - ///and the WebView APK on the device. If running on a device with a lower API level, this will always return `false`. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String) - static Future isFeatureSupported(AndroidWebViewFeature feature) async { - Map args = {}; - args.putIfAbsent("feature", () => feature.toNativeValue()); - return await _channel.invokeMethod('isFeatureSupported', args); - } - ///Gets [String] value. String toValue() => _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/print_job/main.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/main.dart new file mode 100644 index 00000000..2c363891 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/main.dart @@ -0,0 +1,2 @@ +export 'platform_print_job_controller.dart'; +export 'print_job_settings.dart' show PrintJobSettings; diff --git a/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart new file mode 100644 index 00000000..c8db38b7 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart @@ -0,0 +1,133 @@ +import 'package:flutter/foundation.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +import '../in_app_webview/platform_inappwebview_controller.dart'; +import '../inappwebview_platform.dart'; +import '../types/disposable.dart'; +import '../types/print_job_info.dart'; + +///A completion handler for the [PlatformPrintJobController]. +typedef PrintJobCompletionHandler = Future Function( + bool completed, String? error)?; + +/// Object specifying creation parameters for creating a [PlatformPrintJobController]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformPrintJobControllerCreationParams { + /// Used by the platform implementation to create a new [PlatformPrintJobController]. + const PlatformPrintJobControllerCreationParams( + {required this.id, this.onComplete}); + + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.id} + final String id; + + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.onComplete} + final PrintJobCompletionHandler? onComplete; +} + +///Class representing a print job eventually returned by [PlatformInAppWebViewController.printCurrentPage]. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +///- MacOS +abstract class PlatformPrintJobController extends PlatformInterface + implements Disposable { + /// Creates a new [PlatformPrintJobController] + factory PlatformPrintJobController( + PlatformPrintJobControllerCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformPrintJobController printJobController = + InAppWebViewPlatform.instance!.createPlatformPrintJobController(params); + PlatformInterface.verify(printJobController, _token); + return printJobController; + } + + /// Used by the platform implementation to create a new [PlatformPrintJobController]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformPrintJobController.implementation(this.params) : super(token: _token); + + static final Object _token = Object(); + + /// The parameters used to initialize the [PlatformPrintJobController]. + final PlatformPrintJobControllerCreationParams params; + + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.id} + ///Print job ID. + ///{@endtemplate} + String get id => params.id; + + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.onComplete} + ///A completion handler used to handle the conclusion of the print job (for instance, to reset state) and to handle any errors encountered in printing. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - UIPrintInteractionController.CompletionHandler](https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/completionhandler)) + ///- MacOS ([Official API - NSPrintOperation.runModal](https://developer.apple.com/documentation/appkit/nsprintoperation/1532065-runmodal)) + ///{@endtemplate} + PrintJobCompletionHandler? get onComplete => params.onComplete; + + ///Cancels this print job. + ///You can request cancellation of a queued, started, blocked, or failed print job. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintJob.cancel](https://developer.android.com/reference/android/print/PrintJob#cancel())) + Future cancel() { + throw UnimplementedError( + 'cancel is not implemented on the current platform'); + } + + ///Restarts this print job. + ///You can request restart of a failed print job. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintJob.restart](https://developer.android.com/reference/android/print/PrintJob#restart())) + Future restart() { + throw UnimplementedError( + 'restart is not implemented on the current platform'); + } + + ///Dismisses the printing-options sheet or popover. + /// + ///You should dismiss the printing options when they are presented in a sheet or + ///animated from a rectangle and the user changes the orientation of the device. + ///(This, of course, assumes your application responds to orientation changes.) + ///You should then present the printing options again once the new orientation takes effect. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + Future dismiss({bool animated = true}) { + throw UnimplementedError( + 'dismiss is not implemented on the current platform'); + } + + ///Gets the [PrintJobInfo] that describes this job. + /// + ///**NOTE**: The returned info object is a snapshot of the + ///current print job state. Every call to this method returns a fresh + ///info object that reflects the current print job state. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintJob.getInfo](https://developer.android.com/reference/android/print/PrintJob#getInfo())) + ///- iOS + ///- MacOS + Future getInfo() { + throw UnimplementedError( + 'getInfo is not implemented on the current platform'); + } + + @override + void dispose() { + throw UnimplementedError( + 'dispose is not implemented on the current platform'); + } +} diff --git a/lib/src/print_job/print_job_settings.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.dart similarity index 98% rename from lib/src/print_job/print_job_settings.dart rename to flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.dart index 622ee78a..084e78c6 100644 --- a/lib/src/print_job/print_job_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.dart @@ -14,14 +14,14 @@ import '../types/print_job_rendering_quality.dart'; import '../types/print_job_resolution.dart'; import '../util.dart'; import '../web_uri.dart'; -import 'print_job_controller.dart'; +import 'platform_print_job_controller.dart'; part 'print_job_settings.g.dart'; -///Class that represents the settings of a [PrintJobController]. +///Class that represents the settings of a [PlatformPrintJobController]. @ExchangeableObject(copyMethod: true) class PrintJobSettings_ { - ///Set this to `true` to handle the [PrintJobController]. + ///Set this to `true` to handle the [PlatformPrintJobController]. ///Otherwise, it will be handled and disposed automatically by the system. ///The default value is `false`. /// diff --git a/lib/src/print_job/print_job_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.g.dart similarity index 99% rename from lib/src/print_job/print_job_settings.g.dart rename to flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.g.dart index 11c6a955..e86cd175 100644 --- a/lib/src/print_job/print_job_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.g.dart @@ -6,7 +6,7 @@ part of 'print_job_settings.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Class that represents the settings of a [PrintJobController]. +///Class that represents the settings of a [PlatformPrintJobController]. class PrintJobSettings { ///`true` to animate the display of the sheet, `false` to display the sheet immediately. /// @@ -80,7 +80,7 @@ class PrintJobSettings { ///- iOS PrintJobRenderingQuality? forceRenderingQuality; - ///Set this to `true` to handle the [PrintJobController]. + ///Set this to `true` to handle the [PlatformPrintJobController]. ///Otherwise, it will be handled and disposed automatically by the system. ///The default value is `false`. /// diff --git a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/main.dart b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/main.dart new file mode 100644 index 00000000..b3bf2b8f --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/main.dart @@ -0,0 +1,3 @@ +export 'platform_pull_to_refresh_controller.dart'; +export 'pull_to_refresh_settings.dart' + show PullToRefreshSettings, PullToRefreshOptions; diff --git a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.dart b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.dart new file mode 100644 index 00000000..ab685ab4 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.dart @@ -0,0 +1,227 @@ +import 'dart:ui'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_platform_interface/src/types/disposable.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +import '../in_app_webview/in_app_webview_settings.dart'; +import '../debug_logging_settings.dart'; +import '../inappwebview_platform.dart'; +import '../types/main.dart'; +import 'pull_to_refresh_settings.dart'; + +/// Object specifying creation parameters for creating a [PlatformPullToRefreshController]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +class PlatformPullToRefreshControllerCreationParams { + /// Used by the platform implementation to create a new [PlatformPullToRefreshController]. + PlatformPullToRefreshControllerCreationParams({ + @Deprecated("Use settings instead") PullToRefreshOptions? options, + PullToRefreshSettings? settings, + this.onRefresh}) : this.options = options ?? PullToRefreshOptions(), + this.settings = settings ?? PullToRefreshSettings(); + + @Deprecated("Use settings instead") + late PullToRefreshOptions options; + late PullToRefreshSettings settings; + + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.onRefresh} + final void Function()? onRefresh; +} + +///A standard controller that can initiate the refreshing of a scroll view’s contents. +///This should be used whenever the user can refresh the contents of a WebView via a vertical swipe gesture. +/// +///All the methods should be called only when the WebView has been created or is already running +///(for example [WebView.onWebViewCreated] or [InAppBrowser.onBrowserCreated]). +/// +///**NOTE for Android**: to be able to use the "pull-to-refresh" feature, [InAppWebViewSettings.useHybridComposition] must be `true`. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS +abstract class PlatformPullToRefreshController extends PlatformInterface implements Disposable { + ///Debug settings. + static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings(); + + /// Creates a new [PlatformPullToRefreshController] + factory PlatformPullToRefreshController( + PlatformPullToRefreshControllerCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformPullToRefreshController webViewControllerDelegate = + InAppWebViewPlatform.instance!.createPlatformPullToRefreshController(params); + PlatformInterface.verify(webViewControllerDelegate, _token); + return webViewControllerDelegate; + } + + /// Used by the platform implementation to create a new [PlatformPullToRefreshController]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformPullToRefreshController.implementation(this.params) : super(token: _token); + + static final Object _token = Object(); + + /// The parameters used to initialize the [PlatformPullToRefreshController]. + final PlatformPullToRefreshControllerCreationParams params; + + @Deprecated("Use settings instead") + PullToRefreshOptions get options => params.options; + PullToRefreshSettings get settings => params.settings; + + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.onRefresh} + ///Event called when a swipe gesture triggers a refresh. + ///{@endtemplate} + void Function()? get onRefresh => params.onRefresh; + + ///Sets whether the pull-to-refresh feature is enabled or not. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.setEnabled](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setEnabled(boolean))) + ///- iOS ([Official API - UIScrollView.refreshControl](https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol)) + Future setEnabled(bool enabled) { + throw UnimplementedError( + 'setEnabled is not implemented on the current platform'); + } + + ///Returns `true` is pull-to-refresh feature is enabled, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - View.isEnabled](https://developer.android.com/reference/android/view/View#isEnabled())) + ///- iOS ([Official API - UIScrollView.refreshControl](https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol)) + Future isEnabled() { + throw UnimplementedError( + 'isEnabled is not implemented on the current platform'); + } + + ///Tells the controller that a refresh operation was started programmatically. + /// + ///Call this method when an external event source triggers a programmatic refresh of your scrolling view. + ///This method updates the state of the refresh control to reflect the in-progress refresh operation. + ///When the refresh operation ends, be sure to call the [endRefreshing] method to return the controller to its default state. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + Future beginRefreshing() { + throw UnimplementedError( + 'beginRefreshing is not implemented on the current platform'); + } + + ///Tells the controller that a refresh operation has ended. + /// + ///Call this method at the end of any refresh operation (whether it was initiated programmatically or by the user) + ///to return the refresh control to its default state. + ///If the refresh control is at least partially visible, calling this method also hides it. + ///If animations are also enabled, the control is hidden using an animation. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + Future endRefreshing() { + throw UnimplementedError( + 'endRefreshing is not implemented on the current platform'); + } + + ///Returns whether a refresh operation has been triggered and is in progress. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.isRefreshing](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#isRefreshing())) + ///- iOS ([Official API - UIRefreshControl.isRefreshing](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624844-isrefreshing)) + Future isRefreshing() { + throw UnimplementedError( + 'isRefreshing is not implemented on the current platform'); + } + + ///Sets the color of the refresh control. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.setColorSchemeColors](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setColorSchemeColors(int...))) + ///- iOS ([Official API - UIRefreshControl.tintColor](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624847-tintcolor)) + Future setColor(Color color) { + throw UnimplementedError( + 'setColor is not implemented on the current platform'); + } + + ///Sets the background color of the refresh control. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.setProgressBackgroundColorSchemeColor](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setProgressBackgroundColorSchemeColor(int))) + ///- iOS ([Official API - UIView.backgroundColor](https://developer.apple.com/documentation/uikit/uiview/1622591-backgroundcolor)) + Future setBackgroundColor(Color color) { + throw UnimplementedError( + 'setBackgroundColor is not implemented on the current platform'); + } + + ///Set the distance to trigger a sync in dips. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.setDistanceToTriggerSync](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setDistanceToTriggerSync(int))) + Future setDistanceToTriggerSync(int distanceToTriggerSync) { + throw UnimplementedError( + 'setDistanceToTriggerSync is not implemented on the current platform'); + } + + ///Sets the distance that the refresh indicator can be pulled beyond its resting position during a swipe gesture. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.setSlingshotDistance](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setSlingshotDistance(int))) + Future setSlingshotDistance(int slingshotDistance) { + throw UnimplementedError( + 'setSlingshotDistance is not implemented on the current platform'); + } + + ///Gets the default distance that the refresh indicator can be pulled beyond its resting position during a swipe gesture. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.DEFAULT_SLINGSHOT_DISTANCE](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#DEFAULT_SLINGSHOT_DISTANCE())) + Future getDefaultSlingshotDistance() { + throw UnimplementedError( + 'getDefaultSlingshotDistance is not implemented on the current platform'); + } + + ///Use [setIndicatorSize] instead. + @Deprecated("Use setIndicatorSize instead") + Future setSize(AndroidPullToRefreshSize size) { + throw UnimplementedError( + 'setSize is not implemented on the current platform'); + } + + ///Sets the size of the refresh indicator. One of [PullToRefreshSize.DEFAULT], or [PullToRefreshSize.LARGE]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - SwipeRefreshLayout.setSize](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setSize(int))) + Future setIndicatorSize(PullToRefreshSize size) { + throw UnimplementedError( + 'setIndicatorSize is not implemented on the current platform'); + } + + ///Use [setStyledTitle] instead. + @Deprecated("Use setStyledTitle instead") + Future setAttributedTitle(IOSNSAttributedString attributedTitle) { + throw UnimplementedError( + 'setAttributedTitle is not implemented on the current platform'); + } + + ///Sets the styled title text to display in the refresh control. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - UIRefreshControl.attributedTitle](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624845-attributedtitle)) + Future setStyledTitle(AttributedString attributedTitle) { + throw UnimplementedError( + 'setStyledTitle is not implemented on the current platform'); + } + + @override + void dispose({bool isKeepAlive = false}) { + throw UnimplementedError( + 'dispose is not implemented on the current platform'); + } +} diff --git a/lib/src/pull_to_refresh/pull_to_refresh_settings.dart b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.dart similarity index 100% rename from lib/src/pull_to_refresh/pull_to_refresh_settings.dart rename to flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.dart diff --git a/lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart similarity index 100% rename from lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart rename to flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart diff --git a/lib/src/types/action_mode_menu_item.dart b/flutter_inappwebview_platform_interface/lib/src/types/action_mode_menu_item.dart similarity index 100% rename from lib/src/types/action_mode_menu_item.dart rename to flutter_inappwebview_platform_interface/lib/src/types/action_mode_menu_item.dart diff --git a/lib/src/types/action_mode_menu_item.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/action_mode_menu_item.g.dart similarity index 100% rename from lib/src/types/action_mode_menu_item.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/action_mode_menu_item.g.dart diff --git a/lib/src/types/activity_button.dart b/flutter_inappwebview_platform_interface/lib/src/types/activity_button.dart similarity index 100% rename from lib/src/types/activity_button.dart rename to flutter_inappwebview_platform_interface/lib/src/types/activity_button.dart diff --git a/lib/src/types/activity_button.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/activity_button.g.dart similarity index 100% rename from lib/src/types/activity_button.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/activity_button.g.dart diff --git a/lib/src/types/ajax_request.dart b/flutter_inappwebview_platform_interface/lib/src/types/ajax_request.dart similarity index 100% rename from lib/src/types/ajax_request.dart rename to flutter_inappwebview_platform_interface/lib/src/types/ajax_request.dart diff --git a/lib/src/types/ajax_request.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/ajax_request.g.dart similarity index 100% rename from lib/src/types/ajax_request.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/ajax_request.g.dart diff --git a/lib/src/types/ajax_request_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/ajax_request_action.dart similarity index 100% rename from lib/src/types/ajax_request_action.dart rename to flutter_inappwebview_platform_interface/lib/src/types/ajax_request_action.dart diff --git a/lib/src/types/ajax_request_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/ajax_request_action.g.dart similarity index 100% rename from lib/src/types/ajax_request_action.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/ajax_request_action.g.dart diff --git a/lib/src/types/ajax_request_event.dart b/flutter_inappwebview_platform_interface/lib/src/types/ajax_request_event.dart similarity index 100% rename from lib/src/types/ajax_request_event.dart rename to flutter_inappwebview_platform_interface/lib/src/types/ajax_request_event.dart diff --git a/lib/src/types/ajax_request_event.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/ajax_request_event.g.dart similarity index 100% rename from lib/src/types/ajax_request_event.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/ajax_request_event.g.dart diff --git a/lib/src/types/ajax_request_event_type.dart b/flutter_inappwebview_platform_interface/lib/src/types/ajax_request_event_type.dart similarity index 100% rename from lib/src/types/ajax_request_event_type.dart rename to flutter_inappwebview_platform_interface/lib/src/types/ajax_request_event_type.dart diff --git a/lib/src/types/ajax_request_event_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/ajax_request_event_type.g.dart similarity index 100% rename from lib/src/types/ajax_request_event_type.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/ajax_request_event_type.g.dart diff --git a/lib/src/types/ajax_request_headers.dart b/flutter_inappwebview_platform_interface/lib/src/types/ajax_request_headers.dart similarity index 100% rename from lib/src/types/ajax_request_headers.dart rename to flutter_inappwebview_platform_interface/lib/src/types/ajax_request_headers.dart diff --git a/lib/src/types/ajax_request_headers.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/ajax_request_headers.g.dart similarity index 100% rename from lib/src/types/ajax_request_headers.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/ajax_request_headers.g.dart diff --git a/lib/src/types/ajax_request_ready_state.dart b/flutter_inappwebview_platform_interface/lib/src/types/ajax_request_ready_state.dart similarity index 100% rename from lib/src/types/ajax_request_ready_state.dart rename to flutter_inappwebview_platform_interface/lib/src/types/ajax_request_ready_state.dart diff --git a/lib/src/types/ajax_request_ready_state.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/ajax_request_ready_state.g.dart similarity index 100% rename from lib/src/types/ajax_request_ready_state.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/ajax_request_ready_state.g.dart diff --git a/lib/src/types/android_resource.dart b/flutter_inappwebview_platform_interface/lib/src/types/android_resource.dart similarity index 100% rename from lib/src/types/android_resource.dart rename to flutter_inappwebview_platform_interface/lib/src/types/android_resource.dart diff --git a/lib/src/types/android_resource.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/android_resource.g.dart similarity index 100% rename from lib/src/types/android_resource.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/android_resource.g.dart diff --git a/lib/src/types/attributed_string.dart b/flutter_inappwebview_platform_interface/lib/src/types/attributed_string.dart similarity index 98% rename from lib/src/types/attributed_string.dart rename to flutter_inappwebview_platform_interface/lib/src/types/attributed_string.dart index 3dede083..22855ffc 100644 --- a/lib/src/types/attributed_string.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/attributed_string.dart @@ -10,7 +10,7 @@ import '../util.dart'; part 'attributed_string.g.dart'; ///Class that represents a string with associated attributes -///used by the [PullToRefreshController] and [PullToRefreshSettings] classes. +///used by the [PlatformPullToRefreshController] and [PullToRefreshSettings] classes. @ExchangeableObject() class AttributedString_ { ///The characters for the new object. @@ -131,7 +131,7 @@ class AttributedString_ { } ///An iOS-specific class that represents a string with associated attributes -///used by the [PullToRefreshController] and [PullToRefreshOptions] classes. +///used by the [PlatformPullToRefreshController] and [PullToRefreshOptions] classes. ///Use [AttributedString] instead. @Deprecated("Use AttributedString instead") @ExchangeableObject() diff --git a/lib/src/types/attributed_string.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/attributed_string.g.dart similarity index 98% rename from lib/src/types/attributed_string.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/attributed_string.g.dart index 43eb49e8..64d5fc09 100644 --- a/lib/src/types/attributed_string.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/attributed_string.g.dart @@ -7,7 +7,7 @@ part of 'attributed_string.dart'; // ************************************************************************** ///Class that represents a string with associated attributes -///used by the [PullToRefreshController] and [PullToRefreshSettings] classes. +///used by the [PlatformPullToRefreshController] and [PullToRefreshSettings] classes. class AttributedString { ///The color of the background behind the text. /// @@ -193,7 +193,7 @@ class AttributedString { } ///An iOS-specific class that represents a string with associated attributes -///used by the [PullToRefreshController] and [PullToRefreshOptions] classes. +///used by the [PlatformPullToRefreshController] and [PullToRefreshOptions] classes. ///Use [AttributedString] instead. @Deprecated('Use AttributedString instead') class IOSNSAttributedString { diff --git a/lib/src/types/attributed_string_text_effect_style.dart b/flutter_inappwebview_platform_interface/lib/src/types/attributed_string_text_effect_style.dart similarity index 100% rename from lib/src/types/attributed_string_text_effect_style.dart rename to flutter_inappwebview_platform_interface/lib/src/types/attributed_string_text_effect_style.dart diff --git a/lib/src/types/attributed_string_text_effect_style.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/attributed_string_text_effect_style.g.dart similarity index 100% rename from lib/src/types/attributed_string_text_effect_style.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/attributed_string_text_effect_style.g.dart diff --git a/lib/src/types/cache_mode.dart b/flutter_inappwebview_platform_interface/lib/src/types/cache_mode.dart similarity index 100% rename from lib/src/types/cache_mode.dart rename to flutter_inappwebview_platform_interface/lib/src/types/cache_mode.dart diff --git a/lib/src/types/cache_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/cache_mode.g.dart similarity index 100% rename from lib/src/types/cache_mode.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/cache_mode.g.dart diff --git a/lib/src/types/call_async_javascript_result.dart b/flutter_inappwebview_platform_interface/lib/src/types/call_async_javascript_result.dart similarity index 73% rename from lib/src/types/call_async_javascript_result.dart rename to flutter_inappwebview_platform_interface/lib/src/types/call_async_javascript_result.dart index e6427e5d..05bd6b68 100644 --- a/lib/src/types/call_async_javascript_result.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/call_async_javascript_result.dart @@ -1,10 +1,10 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/in_app_webview_controller.dart'; +import '../in_app_webview/platform_inappwebview_controller.dart'; part 'call_async_javascript_result.g.dart'; -///Class that represents either a success or a failure, including an associated value in each case for [InAppWebViewController.callAsyncJavaScript]. +///Class that represents either a success or a failure, including an associated value in each case for [PlatformInAppWebViewController.callAsyncJavaScript]. @ExchangeableObject() class CallAsyncJavaScriptResult_ { ///It contains the success value. diff --git a/lib/src/types/call_async_javascript_result.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/call_async_javascript_result.g.dart similarity index 100% rename from lib/src/types/call_async_javascript_result.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/call_async_javascript_result.g.dart diff --git a/lib/src/types/client_cert_challenge.dart b/flutter_inappwebview_platform_interface/lib/src/types/client_cert_challenge.dart similarity index 97% rename from lib/src/types/client_cert_challenge.dart rename to flutter_inappwebview_platform_interface/lib/src/types/client_cert_challenge.dart index c0e2f4c2..09dc3233 100644 --- a/lib/src/types/client_cert_challenge.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/client_cert_challenge.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'url_authentication_challenge.dart'; import 'url_protection_space.dart'; diff --git a/lib/src/types/client_cert_challenge.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/client_cert_challenge.g.dart similarity index 100% rename from lib/src/types/client_cert_challenge.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/client_cert_challenge.g.dart diff --git a/lib/src/types/client_cert_response.dart b/flutter_inappwebview_platform_interface/lib/src/types/client_cert_response.dart similarity index 97% rename from lib/src/types/client_cert_response.dart rename to flutter_inappwebview_platform_interface/lib/src/types/client_cert_response.dart index 1b8d64c4..74372b9c 100644 --- a/lib/src/types/client_cert_response.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/client_cert_response.dart @@ -1,7 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import '../util.dart'; import 'client_cert_response_action.dart'; diff --git a/lib/src/types/client_cert_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/client_cert_response.g.dart similarity index 100% rename from lib/src/types/client_cert_response.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/client_cert_response.g.dart diff --git a/lib/src/types/client_cert_response_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/client_cert_response_action.dart similarity index 100% rename from lib/src/types/client_cert_response_action.dart rename to flutter_inappwebview_platform_interface/lib/src/types/client_cert_response_action.dart diff --git a/lib/src/types/client_cert_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/client_cert_response_action.g.dart similarity index 100% rename from lib/src/types/client_cert_response_action.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/client_cert_response_action.g.dart diff --git a/lib/src/types/compress_format.dart b/flutter_inappwebview_platform_interface/lib/src/types/compress_format.dart similarity index 100% rename from lib/src/types/compress_format.dart rename to flutter_inappwebview_platform_interface/lib/src/types/compress_format.dart diff --git a/lib/src/types/compress_format.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/compress_format.g.dart similarity index 100% rename from lib/src/types/compress_format.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/compress_format.g.dart diff --git a/lib/src/types/console_message.dart b/flutter_inappwebview_platform_interface/lib/src/types/console_message.dart similarity index 94% rename from lib/src/types/console_message.dart rename to flutter_inappwebview_platform_interface/lib/src/types/console_message.dart index bb6e6728..e6490153 100644 --- a/lib/src/types/console_message.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/console_message.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'console_message_level.dart'; diff --git a/lib/src/types/console_message.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/console_message.g.dart similarity index 100% rename from lib/src/types/console_message.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/console_message.g.dart diff --git a/lib/src/types/console_message_level.dart b/flutter_inappwebview_platform_interface/lib/src/types/console_message_level.dart similarity index 100% rename from lib/src/types/console_message_level.dart rename to flutter_inappwebview_platform_interface/lib/src/types/console_message_level.dart diff --git a/lib/src/types/console_message_level.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/console_message_level.g.dart similarity index 100% rename from lib/src/types/console_message_level.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/console_message_level.g.dart diff --git a/lib/src/types/content_blocker_action_type.dart b/flutter_inappwebview_platform_interface/lib/src/types/content_blocker_action_type.dart similarity index 100% rename from lib/src/types/content_blocker_action_type.dart rename to flutter_inappwebview_platform_interface/lib/src/types/content_blocker_action_type.dart diff --git a/lib/src/types/content_blocker_action_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/content_blocker_action_type.g.dart similarity index 100% rename from lib/src/types/content_blocker_action_type.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/content_blocker_action_type.g.dart diff --git a/lib/src/types/content_blocker_trigger_load_context.dart b/flutter_inappwebview_platform_interface/lib/src/types/content_blocker_trigger_load_context.dart similarity index 100% rename from lib/src/types/content_blocker_trigger_load_context.dart rename to flutter_inappwebview_platform_interface/lib/src/types/content_blocker_trigger_load_context.dart diff --git a/lib/src/types/content_blocker_trigger_load_context.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/content_blocker_trigger_load_context.g.dart similarity index 100% rename from lib/src/types/content_blocker_trigger_load_context.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/content_blocker_trigger_load_context.g.dart diff --git a/lib/src/types/content_blocker_trigger_load_type.dart b/flutter_inappwebview_platform_interface/lib/src/types/content_blocker_trigger_load_type.dart similarity index 100% rename from lib/src/types/content_blocker_trigger_load_type.dart rename to flutter_inappwebview_platform_interface/lib/src/types/content_blocker_trigger_load_type.dart diff --git a/lib/src/types/content_blocker_trigger_load_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/content_blocker_trigger_load_type.g.dart similarity index 100% rename from lib/src/types/content_blocker_trigger_load_type.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/content_blocker_trigger_load_type.g.dart diff --git a/lib/src/types/content_blocker_trigger_resource_type.dart b/flutter_inappwebview_platform_interface/lib/src/types/content_blocker_trigger_resource_type.dart similarity index 100% rename from lib/src/types/content_blocker_trigger_resource_type.dart rename to flutter_inappwebview_platform_interface/lib/src/types/content_blocker_trigger_resource_type.dart diff --git a/lib/src/types/content_blocker_trigger_resource_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/content_blocker_trigger_resource_type.g.dart similarity index 100% rename from lib/src/types/content_blocker_trigger_resource_type.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/content_blocker_trigger_resource_type.g.dart diff --git a/lib/src/types/content_world.dart b/flutter_inappwebview_platform_interface/lib/src/types/content_world.dart similarity index 100% rename from lib/src/types/content_world.dart rename to flutter_inappwebview_platform_interface/lib/src/types/content_world.dart diff --git a/lib/src/types/cookie.dart b/flutter_inappwebview_platform_interface/lib/src/types/cookie.dart similarity index 94% rename from lib/src/types/cookie.dart rename to flutter_inappwebview_platform_interface/lib/src/types/cookie.dart index 78883832..d0edfb4b 100644 --- a/lib/src/types/cookie.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/cookie.dart @@ -1,12 +1,12 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../cookie_manager.dart'; -import '../android/webview_feature.dart'; +import '../platform_cookie_manager.dart'; +import '../platform_webview_feature.dart'; import 'http_cookie_same_site_policy.dart'; part 'cookie.g.dart'; -///Class that represents a cookie returned by the [CookieManager]. +///Class that represents a cookie returned by the [PlatformCookieManager]. @ExchangeableObject() class Cookie_ { ///The cookie name. diff --git a/lib/src/types/cookie.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/cookie.g.dart similarity index 98% rename from lib/src/types/cookie.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/cookie.g.dart index 903b297c..05c61dd2 100644 --- a/lib/src/types/cookie.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/cookie.g.dart @@ -6,7 +6,7 @@ part of 'cookie.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Class that represents a cookie returned by the [CookieManager]. +///Class that represents a cookie returned by the [PlatformCookieManager]. class Cookie { ///The cookie domain. /// diff --git a/lib/src/types/create_window_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/create_window_action.dart similarity index 96% rename from lib/src/types/create_window_action.dart rename to flutter_inappwebview_platform_interface/lib/src/types/create_window_action.dart index c8f4c0e3..6499bd8c 100644 --- a/lib/src/types/create_window_action.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/create_window_action.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'navigation_action.dart'; import 'window_features.dart'; import 'url_request.dart'; @@ -12,7 +12,7 @@ part 'create_window_action.g.dart'; ///Class that represents the navigation request used by the [WebView.onCreateWindow] event. @ExchangeableObject() class CreateWindowAction_ extends NavigationAction_ { - ///The window id. Used by [WebView] to create a new WebView. + ///The window id. Used by `WebView` to create a new WebView. int windowId; ///Use [isDialog] instead. diff --git a/lib/src/types/create_window_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/create_window_action.g.dart similarity index 98% rename from lib/src/types/create_window_action.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/create_window_action.g.dart index ed616a63..85526492 100644 --- a/lib/src/types/create_window_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/create_window_action.g.dart @@ -29,7 +29,7 @@ class CreateWindowAction extends NavigationAction { ///- MacOS ([Official API - WKWindowFeatures](https://developer.apple.com/documentation/webkit/wkwindowfeatures)) WindowFeatures? windowFeatures; - ///The window id. Used by [WebView] to create a new WebView. + ///The window id. Used by `WebView` to create a new WebView. int windowId; CreateWindowAction( {@Deprecated('Use isDialog instead') this.androidIsDialog, diff --git a/lib/src/types/cross_origin.dart b/flutter_inappwebview_platform_interface/lib/src/types/cross_origin.dart similarity index 100% rename from lib/src/types/cross_origin.dart rename to flutter_inappwebview_platform_interface/lib/src/types/cross_origin.dart diff --git a/lib/src/types/cross_origin.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/cross_origin.g.dart similarity index 100% rename from lib/src/types/cross_origin.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/cross_origin.g.dart diff --git a/lib/src/types/css_link_html_tag_attributes.dart b/flutter_inappwebview_platform_interface/lib/src/types/css_link_html_tag_attributes.dart similarity index 93% rename from lib/src/types/css_link_html_tag_attributes.dart rename to flutter_inappwebview_platform_interface/lib/src/types/css_link_html_tag_attributes.dart index 9c866bdd..fdfab74c 100644 --- a/lib/src/types/css_link_html_tag_attributes.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/css_link_html_tag_attributes.dart @@ -1,12 +1,12 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/in_app_webview_controller.dart'; +import '../in_app_webview/platform_inappwebview_controller.dart'; import 'cross_origin.dart'; import 'referrer_policy.dart'; part 'css_link_html_tag_attributes.g.dart'; -///Class that represents the possible CSS stylesheet `` HTML attributes to be set used by [InAppWebViewController.injectCSSFileFromUrl]. +///Class that represents the possible CSS stylesheet `` HTML attributes to be set used by [PlatformInAppWebViewController.injectCSSFileFromUrl]. @ExchangeableObject() class CSSLinkHtmlTagAttributes_ { ///The HTML [id] attribute is used to specify a unique id for the `` HTML element. diff --git a/lib/src/types/css_link_html_tag_attributes.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/css_link_html_tag_attributes.g.dart similarity index 100% rename from lib/src/types/css_link_html_tag_attributes.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/css_link_html_tag_attributes.g.dart diff --git a/lib/src/types/custom_scheme_response.dart b/flutter_inappwebview_platform_interface/lib/src/types/custom_scheme_response.dart similarity index 94% rename from lib/src/types/custom_scheme_response.dart rename to flutter_inappwebview_platform_interface/lib/src/types/custom_scheme_response.dart index 3e608ed1..79496520 100644 --- a/lib/src/types/custom_scheme_response.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/custom_scheme_response.dart @@ -2,7 +2,7 @@ import 'dart:typed_data'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + part 'custom_scheme_response.g.dart'; diff --git a/lib/src/types/custom_scheme_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/custom_scheme_response.g.dart similarity index 100% rename from lib/src/types/custom_scheme_response.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/custom_scheme_response.g.dart diff --git a/lib/src/types/custom_tabs_navigation_event_type.dart b/flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_navigation_event_type.dart similarity index 90% rename from lib/src/types/custom_tabs_navigation_event_type.dart rename to flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_navigation_event_type.dart index 57c58efd..f491551e 100644 --- a/lib/src/types/custom_tabs_navigation_event_type.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_navigation_event_type.dart @@ -1,10 +1,10 @@ import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../chrome_safari_browser/chrome_safari_browser.dart'; +import '../chrome_safari_browser/platform_chrome_safari_browser.dart'; part 'custom_tabs_navigation_event_type.g.dart'; -///The type corresponding to the navigation event of [ChromeSafariBrowser.onNavigationEvent]. +///The type corresponding to the navigation event of [PlatformChromeSafariBrowser.onNavigationEvent]. @ExchangeableEnum() class CustomTabsNavigationEventType_ { // ignore: unused_field diff --git a/lib/src/types/custom_tabs_navigation_event_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_navigation_event_type.g.dart similarity index 97% rename from lib/src/types/custom_tabs_navigation_event_type.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_navigation_event_type.g.dart index 8aaa9871..4c90a823 100644 --- a/lib/src/types/custom_tabs_navigation_event_type.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_navigation_event_type.g.dart @@ -6,7 +6,7 @@ part of 'custom_tabs_navigation_event_type.dart'; // ExchangeableEnumGenerator // ************************************************************************** -///The type corresponding to the navigation event of [ChromeSafariBrowser.onNavigationEvent]. +///The type corresponding to the navigation event of [PlatformChromeSafariBrowser.onNavigationEvent]. class CustomTabsNavigationEventType { final int _value; final int? _nativeValue; diff --git a/lib/src/types/custom_tabs_post_message_result_type.dart b/flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_post_message_result_type.dart similarity index 100% rename from lib/src/types/custom_tabs_post_message_result_type.dart rename to flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_post_message_result_type.dart diff --git a/lib/src/types/custom_tabs_post_message_result_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_post_message_result_type.g.dart similarity index 100% rename from lib/src/types/custom_tabs_post_message_result_type.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_post_message_result_type.g.dart diff --git a/lib/src/types/custom_tabs_relation_type.dart b/flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_relation_type.dart similarity index 100% rename from lib/src/types/custom_tabs_relation_type.dart rename to flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_relation_type.dart diff --git a/lib/src/types/custom_tabs_relation_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_relation_type.g.dart similarity index 100% rename from lib/src/types/custom_tabs_relation_type.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_relation_type.g.dart diff --git a/lib/src/types/custom_tabs_share_state.dart b/flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_share_state.dart similarity index 100% rename from lib/src/types/custom_tabs_share_state.dart rename to flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_share_state.dart diff --git a/lib/src/types/custom_tabs_share_state.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_share_state.g.dart similarity index 100% rename from lib/src/types/custom_tabs_share_state.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/custom_tabs_share_state.g.dart diff --git a/lib/src/types/data_detector_types.dart b/flutter_inappwebview_platform_interface/lib/src/types/data_detector_types.dart similarity index 100% rename from lib/src/types/data_detector_types.dart rename to flutter_inappwebview_platform_interface/lib/src/types/data_detector_types.dart diff --git a/lib/src/types/data_detector_types.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/data_detector_types.g.dart similarity index 100% rename from lib/src/types/data_detector_types.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/data_detector_types.g.dart diff --git a/lib/src/types/dismiss_button_style.dart b/flutter_inappwebview_platform_interface/lib/src/types/dismiss_button_style.dart similarity index 100% rename from lib/src/types/dismiss_button_style.dart rename to flutter_inappwebview_platform_interface/lib/src/types/dismiss_button_style.dart diff --git a/lib/src/types/dismiss_button_style.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/dismiss_button_style.g.dart similarity index 100% rename from lib/src/types/dismiss_button_style.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/dismiss_button_style.g.dart diff --git a/lib/src/types/disposable.dart b/flutter_inappwebview_platform_interface/lib/src/types/disposable.dart similarity index 100% rename from lib/src/types/disposable.dart rename to flutter_inappwebview_platform_interface/lib/src/types/disposable.dart diff --git a/lib/src/types/download_start_request.dart b/flutter_inappwebview_platform_interface/lib/src/types/download_start_request.dart similarity index 96% rename from lib/src/types/download_start_request.dart rename to flutter_inappwebview_platform_interface/lib/src/types/download_start_request.dart index 279e103c..70d1d434 100644 --- a/lib/src/types/download_start_request.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/download_start_request.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import '../web_uri.dart'; part 'download_start_request.g.dart'; diff --git a/lib/src/types/download_start_request.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/download_start_request.g.dart similarity index 100% rename from lib/src/types/download_start_request.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/download_start_request.g.dart diff --git a/lib/src/types/favicon.dart b/flutter_inappwebview_platform_interface/lib/src/types/favicon.dart similarity index 83% rename from lib/src/types/favicon.dart rename to flutter_inappwebview_platform_interface/lib/src/types/favicon.dart index 3a7282f4..501d20ad 100644 --- a/lib/src/types/favicon.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/favicon.dart @@ -1,11 +1,11 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/in_app_webview_controller.dart'; +import '../in_app_webview/platform_inappwebview_controller.dart'; import '../web_uri.dart'; part 'favicon.g.dart'; -///Class that represents a favicon of a website. It is used by [InAppWebViewController.getFavicons] method. +///Class that represents a favicon of a website. It is used by [PlatformInAppWebViewController.getFavicons] method. @ExchangeableObject() class Favicon_ { ///The url of the favicon image. diff --git a/lib/src/types/favicon.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/favicon.g.dart similarity index 100% rename from lib/src/types/favicon.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/favicon.g.dart diff --git a/lib/src/types/fetch_request.dart b/flutter_inappwebview_platform_interface/lib/src/types/fetch_request.dart similarity index 100% rename from lib/src/types/fetch_request.dart rename to flutter_inappwebview_platform_interface/lib/src/types/fetch_request.dart diff --git a/lib/src/types/fetch_request.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/fetch_request.g.dart similarity index 100% rename from lib/src/types/fetch_request.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/fetch_request.g.dart diff --git a/lib/src/types/fetch_request_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/fetch_request_action.dart similarity index 100% rename from lib/src/types/fetch_request_action.dart rename to flutter_inappwebview_platform_interface/lib/src/types/fetch_request_action.dart diff --git a/lib/src/types/fetch_request_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/fetch_request_action.g.dart similarity index 100% rename from lib/src/types/fetch_request_action.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/fetch_request_action.g.dart diff --git a/lib/src/types/fetch_request_credential.dart b/flutter_inappwebview_platform_interface/lib/src/types/fetch_request_credential.dart similarity index 100% rename from lib/src/types/fetch_request_credential.dart rename to flutter_inappwebview_platform_interface/lib/src/types/fetch_request_credential.dart diff --git a/lib/src/types/fetch_request_credential.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/fetch_request_credential.g.dart similarity index 100% rename from lib/src/types/fetch_request_credential.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/fetch_request_credential.g.dart diff --git a/lib/src/types/fetch_request_credential_default.dart b/flutter_inappwebview_platform_interface/lib/src/types/fetch_request_credential_default.dart similarity index 100% rename from lib/src/types/fetch_request_credential_default.dart rename to flutter_inappwebview_platform_interface/lib/src/types/fetch_request_credential_default.dart diff --git a/lib/src/types/fetch_request_credential_default.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/fetch_request_credential_default.g.dart similarity index 100% rename from lib/src/types/fetch_request_credential_default.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/fetch_request_credential_default.g.dart diff --git a/lib/src/types/fetch_request_federated_credential.dart b/flutter_inappwebview_platform_interface/lib/src/types/fetch_request_federated_credential.dart similarity index 100% rename from lib/src/types/fetch_request_federated_credential.dart rename to flutter_inappwebview_platform_interface/lib/src/types/fetch_request_federated_credential.dart diff --git a/lib/src/types/fetch_request_federated_credential.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/fetch_request_federated_credential.g.dart similarity index 100% rename from lib/src/types/fetch_request_federated_credential.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/fetch_request_federated_credential.g.dart diff --git a/lib/src/types/fetch_request_password_credential.dart b/flutter_inappwebview_platform_interface/lib/src/types/fetch_request_password_credential.dart similarity index 100% rename from lib/src/types/fetch_request_password_credential.dart rename to flutter_inappwebview_platform_interface/lib/src/types/fetch_request_password_credential.dart diff --git a/lib/src/types/fetch_request_password_credential.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/fetch_request_password_credential.g.dart similarity index 100% rename from lib/src/types/fetch_request_password_credential.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/fetch_request_password_credential.g.dart diff --git a/lib/src/types/find_session.dart b/flutter_inappwebview_platform_interface/lib/src/types/find_session.dart similarity index 100% rename from lib/src/types/find_session.dart rename to flutter_inappwebview_platform_interface/lib/src/types/find_session.dart diff --git a/lib/src/types/find_session.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/find_session.g.dart similarity index 100% rename from lib/src/types/find_session.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/find_session.g.dart diff --git a/lib/src/types/force_dark.dart b/flutter_inappwebview_platform_interface/lib/src/types/force_dark.dart similarity index 100% rename from lib/src/types/force_dark.dart rename to flutter_inappwebview_platform_interface/lib/src/types/force_dark.dart diff --git a/lib/src/types/force_dark.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/force_dark.g.dart similarity index 100% rename from lib/src/types/force_dark.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/force_dark.g.dart diff --git a/lib/src/types/force_dark_strategy.dart b/flutter_inappwebview_platform_interface/lib/src/types/force_dark_strategy.dart similarity index 74% rename from lib/src/types/force_dark_strategy.dart rename to flutter_inappwebview_platform_interface/lib/src/types/force_dark_strategy.dart index 44146c82..337f5be7 100644 --- a/lib/src/types/force_dark_strategy.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/force_dark_strategy.dart @@ -1,33 +1,33 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + part 'force_dark_strategy.g.dart'; -///Class used to indicate how [WebView] content should be darkened. +///Class used to indicate how `WebView` content should be darkened. @ExchangeableEnum() class ForceDarkStrategy_ { // ignore: unused_field final int _value; const ForceDarkStrategy_._internal(this._value); - ///In this mode [WebView] content will be darkened by a user agent and it will ignore the web page's dark theme if it exists. + ///In this mode `WebView` content will be darkened by a user agent and it will ignore the web page's dark theme if it exists. ///To avoid mixing two different darkening strategies, the `prefers-color-scheme` media query will evaluate to light. /// ///See [specification](https://drafts.csswg.org/css-color-adjust-1/) for more information. static const USER_AGENT_DARKENING_ONLY = const ForceDarkStrategy_._internal(0); - ///In this mode [WebView] content will always be darkened using dark theme provided by web page. - ///If web page does not provide dark theme support [WebView] content will be rendered with a default theme. + ///In this mode `WebView` content will always be darkened using dark theme provided by web page. + ///If web page does not provide dark theme support `WebView` content will be rendered with a default theme. /// ///See [specification](https://drafts.csswg.org/css-color-adjust-1/) for more information. static const WEB_THEME_DARKENING_ONLY = const ForceDarkStrategy_._internal(1); - ///In this mode [WebView] content will be darkened by a user agent unless web page supports dark theme. - ///[WebView] determines whether web pages supports dark theme by the presence of `color-scheme` metadata containing `"dark"` value. + ///In this mode `WebView` content will be darkened by a user agent unless web page supports dark theme. + ///`WebView` determines whether web pages supports dark theme by the presence of `color-scheme` metadata containing `"dark"` value. ///For example, ``. - ///If the metadata is not presented [WebView] content will be darkened by a user agent and `prefers-color-scheme` media query will evaluate to light. + ///If the metadata is not presented `WebView` content will be darkened by a user agent and `prefers-color-scheme` media query will evaluate to light. /// ///See [specification](https://drafts.csswg.org/css-color-adjust-1/) for more information. static const PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING = diff --git a/lib/src/types/force_dark_strategy.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/force_dark_strategy.g.dart similarity index 87% rename from lib/src/types/force_dark_strategy.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/force_dark_strategy.g.dart index 36758864..2ed0691b 100644 --- a/lib/src/types/force_dark_strategy.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/force_dark_strategy.g.dart @@ -6,7 +6,7 @@ part of 'force_dark_strategy.dart'; // ExchangeableEnumGenerator // ************************************************************************** -///Class used to indicate how [WebView] content should be darkened. +///Class used to indicate how `WebView` content should be darkened. class ForceDarkStrategy { final int _value; final int _nativeValue; @@ -16,23 +16,23 @@ class ForceDarkStrategy { int value, Function nativeValue) => ForceDarkStrategy._internal(value, nativeValue()); - ///In this mode [WebView] content will be darkened by a user agent unless web page supports dark theme. - ///[WebView] determines whether web pages supports dark theme by the presence of `color-scheme` metadata containing `"dark"` value. + ///In this mode `WebView` content will be darkened by a user agent unless web page supports dark theme. + ///`WebView` determines whether web pages supports dark theme by the presence of `color-scheme` metadata containing `"dark"` value. ///For example, ``. - ///If the metadata is not presented [WebView] content will be darkened by a user agent and `prefers-color-scheme` media query will evaluate to light. + ///If the metadata is not presented `WebView` content will be darkened by a user agent and `prefers-color-scheme` media query will evaluate to light. /// ///See [specification](https://drafts.csswg.org/css-color-adjust-1/) for more information. static const PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING = ForceDarkStrategy._internal(2, 2); - ///In this mode [WebView] content will be darkened by a user agent and it will ignore the web page's dark theme if it exists. + ///In this mode `WebView` content will be darkened by a user agent and it will ignore the web page's dark theme if it exists. ///To avoid mixing two different darkening strategies, the `prefers-color-scheme` media query will evaluate to light. /// ///See [specification](https://drafts.csswg.org/css-color-adjust-1/) for more information. static const USER_AGENT_DARKENING_ONLY = ForceDarkStrategy._internal(0, 0); - ///In this mode [WebView] content will always be darkened using dark theme provided by web page. - ///If web page does not provide dark theme support [WebView] content will be rendered with a default theme. + ///In this mode `WebView` content will always be darkened using dark theme provided by web page. + ///If web page does not provide dark theme support `WebView` content will be rendered with a default theme. /// ///See [specification](https://drafts.csswg.org/css-color-adjust-1/) for more information. static const WEB_THEME_DARKENING_ONLY = ForceDarkStrategy._internal(1, 1); diff --git a/lib/src/types/form_resubmission_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/form_resubmission_action.dart similarity index 93% rename from lib/src/types/form_resubmission_action.dart rename to flutter_inappwebview_platform_interface/lib/src/types/form_resubmission_action.dart index 9c807aff..8d30460d 100644 --- a/lib/src/types/form_resubmission_action.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/form_resubmission_action.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + part 'form_resubmission_action.g.dart'; diff --git a/lib/src/types/form_resubmission_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/form_resubmission_action.g.dart similarity index 100% rename from lib/src/types/form_resubmission_action.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/form_resubmission_action.g.dart diff --git a/lib/src/types/frame_info.dart b/flutter_inappwebview_platform_interface/lib/src/types/frame_info.dart similarity index 100% rename from lib/src/types/frame_info.dart rename to flutter_inappwebview_platform_interface/lib/src/types/frame_info.dart diff --git a/lib/src/types/frame_info.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/frame_info.g.dart similarity index 100% rename from lib/src/types/frame_info.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/frame_info.g.dart diff --git a/lib/src/types/geolocation_permission_show_prompt_response.dart b/flutter_inappwebview_platform_interface/lib/src/types/geolocation_permission_show_prompt_response.dart similarity index 95% rename from lib/src/types/geolocation_permission_show_prompt_response.dart rename to flutter_inappwebview_platform_interface/lib/src/types/geolocation_permission_show_prompt_response.dart index e39fa653..81413380 100644 --- a/lib/src/types/geolocation_permission_show_prompt_response.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/geolocation_permission_show_prompt_response.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + part 'geolocation_permission_show_prompt_response.g.dart'; diff --git a/lib/src/types/geolocation_permission_show_prompt_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/geolocation_permission_show_prompt_response.g.dart similarity index 100% rename from lib/src/types/geolocation_permission_show_prompt_response.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/geolocation_permission_show_prompt_response.g.dart diff --git a/lib/src/types/http_auth_response.dart b/flutter_inappwebview_platform_interface/lib/src/types/http_auth_response.dart similarity index 96% rename from lib/src/types/http_auth_response.dart rename to flutter_inappwebview_platform_interface/lib/src/types/http_auth_response.dart index 8e63df22..17202e14 100644 --- a/lib/src/types/http_auth_response.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/http_auth_response.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'http_auth_response_action.dart'; part 'http_auth_response.g.dart'; diff --git a/lib/src/types/http_auth_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/http_auth_response.g.dart similarity index 100% rename from lib/src/types/http_auth_response.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/http_auth_response.g.dart diff --git a/lib/src/types/http_auth_response_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/http_auth_response_action.dart similarity index 100% rename from lib/src/types/http_auth_response_action.dart rename to flutter_inappwebview_platform_interface/lib/src/types/http_auth_response_action.dart diff --git a/lib/src/types/http_auth_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/http_auth_response_action.g.dart similarity index 100% rename from lib/src/types/http_auth_response_action.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/http_auth_response_action.g.dart diff --git a/lib/src/types/http_authentication_challenge.dart b/flutter_inappwebview_platform_interface/lib/src/types/http_authentication_challenge.dart similarity index 98% rename from lib/src/types/http_authentication_challenge.dart rename to flutter_inappwebview_platform_interface/lib/src/types/http_authentication_challenge.dart index d8245251..d17905ec 100644 --- a/lib/src/types/http_authentication_challenge.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/http_authentication_challenge.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'url_credential.dart'; import 'url_response.dart'; import 'url_authentication_challenge.dart'; diff --git a/lib/src/types/http_authentication_challenge.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/http_authentication_challenge.g.dart similarity index 100% rename from lib/src/types/http_authentication_challenge.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/http_authentication_challenge.g.dart diff --git a/lib/src/types/http_cookie_same_site_policy.dart b/flutter_inappwebview_platform_interface/lib/src/types/http_cookie_same_site_policy.dart similarity index 100% rename from lib/src/types/http_cookie_same_site_policy.dart rename to flutter_inappwebview_platform_interface/lib/src/types/http_cookie_same_site_policy.dart diff --git a/lib/src/types/http_cookie_same_site_policy.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/http_cookie_same_site_policy.g.dart similarity index 100% rename from lib/src/types/http_cookie_same_site_policy.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/http_cookie_same_site_policy.g.dart diff --git a/lib/src/types/in_app_webview_hit_test_result.dart b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_hit_test_result.dart similarity index 100% rename from lib/src/types/in_app_webview_hit_test_result.dart rename to flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_hit_test_result.dart diff --git a/lib/src/types/in_app_webview_hit_test_result.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_hit_test_result.g.dart similarity index 100% rename from lib/src/types/in_app_webview_hit_test_result.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_hit_test_result.g.dart diff --git a/lib/src/types/in_app_webview_hit_test_result_type.dart b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_hit_test_result_type.dart similarity index 100% rename from lib/src/types/in_app_webview_hit_test_result_type.dart rename to flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_hit_test_result_type.dart diff --git a/lib/src/types/in_app_webview_hit_test_result_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_hit_test_result_type.g.dart similarity index 100% rename from lib/src/types/in_app_webview_hit_test_result_type.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_hit_test_result_type.g.dart diff --git a/lib/src/types/in_app_webview_initial_data.dart b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_initial_data.dart similarity index 91% rename from lib/src/types/in_app_webview_initial_data.dart rename to flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_initial_data.dart index 152e2b9b..fb76b5b5 100644 --- a/lib/src/types/in_app_webview_initial_data.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_initial_data.dart @@ -1,11 +1,11 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import '../web_uri.dart'; part 'in_app_webview_initial_data.g.dart'; -///Initial [data] as a content for an [WebView] instance, using [baseUrl] as the base URL for it. +///Initial [data] as a content for an `WebView` instance, using [baseUrl] as the base URL for it. @ExchangeableObject() class InAppWebViewInitialData_ { ///A String of data in the given encoding. diff --git a/lib/src/types/in_app_webview_initial_data.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_initial_data.g.dart similarity index 97% rename from lib/src/types/in_app_webview_initial_data.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_initial_data.g.dart index a234a66d..d19d5945 100644 --- a/lib/src/types/in_app_webview_initial_data.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_initial_data.g.dart @@ -6,7 +6,7 @@ part of 'in_app_webview_initial_data.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Initial [data] as a content for an [WebView] instance, using [baseUrl] as the base URL for it. +///Initial [data] as a content for an `WebView` instance, using [baseUrl] as the base URL for it. class InAppWebViewInitialData { ///Use [historyUrl] instead. @Deprecated('Use historyUrl instead') diff --git a/lib/src/types/in_app_webview_rect.dart b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_rect.dart similarity index 100% rename from lib/src/types/in_app_webview_rect.dart rename to flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_rect.dart diff --git a/lib/src/types/in_app_webview_rect.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_rect.g.dart similarity index 100% rename from lib/src/types/in_app_webview_rect.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_rect.g.dart diff --git a/lib/src/types/javascript_handler_callback.dart b/flutter_inappwebview_platform_interface/lib/src/types/javascript_handler_callback.dart similarity index 83% rename from lib/src/types/javascript_handler_callback.dart rename to flutter_inappwebview_platform_interface/lib/src/types/javascript_handler_callback.dart index f2cf3920..c0a7a760 100644 --- a/lib/src/types/javascript_handler_callback.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/javascript_handler_callback.dart @@ -1,8 +1,8 @@ import 'dart:convert'; -import '../in_app_webview/in_app_webview_controller.dart'; +import '../in_app_webview/platform_inappwebview_controller.dart'; -///This type represents a callback, added with [InAppWebViewController.addJavaScriptHandler], that listens to post messages sent from JavaScript. +///This type represents a callback, added with [PlatformInAppWebViewController.addJavaScriptHandler], that listens to post messages sent from JavaScript. /// ///The Android implementation uses [addJavascriptInterface](https://developer.android.com/reference/android/webkit/WebView#addJavascriptInterface(java.lang.Object,%20java.lang.String)). ///The iOS implementation uses [addScriptMessageHandler](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537172-addscriptmessagehandler?language=objc) diff --git a/lib/src/types/js_alert_request.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_alert_request.dart similarity index 95% rename from lib/src/types/js_alert_request.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_alert_request.dart index e82a53e3..56aeaeb6 100644 --- a/lib/src/types/js_alert_request.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_alert_request.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import '../web_uri.dart'; part 'js_alert_request.g.dart'; diff --git a/lib/src/types/js_alert_request.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_alert_request.g.dart similarity index 100% rename from lib/src/types/js_alert_request.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_alert_request.g.dart diff --git a/lib/src/types/js_alert_response.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_alert_response.dart similarity index 95% rename from lib/src/types/js_alert_response.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_alert_response.dart index 41e22fa8..3600fc76 100644 --- a/lib/src/types/js_alert_response.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_alert_response.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'js_alert_response_action.dart'; diff --git a/lib/src/types/js_alert_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_alert_response.g.dart similarity index 100% rename from lib/src/types/js_alert_response.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_alert_response.g.dart diff --git a/lib/src/types/js_alert_response_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_alert_response_action.dart similarity index 100% rename from lib/src/types/js_alert_response_action.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_alert_response_action.dart diff --git a/lib/src/types/js_alert_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_alert_response_action.g.dart similarity index 100% rename from lib/src/types/js_alert_response_action.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_alert_response_action.g.dart diff --git a/lib/src/types/js_before_unload_request.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_request.dart similarity index 92% rename from lib/src/types/js_before_unload_request.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_request.dart index a91cb4b4..f8b14379 100644 --- a/lib/src/types/js_before_unload_request.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_request.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import '../web_uri.dart'; part 'js_before_unload_request.g.dart'; diff --git a/lib/src/types/js_before_unload_request.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_request.g.dart similarity index 100% rename from lib/src/types/js_before_unload_request.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_request.g.dart diff --git a/lib/src/types/js_before_unload_response.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response.dart similarity index 95% rename from lib/src/types/js_before_unload_response.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response.dart index 7afd3049..3076bdfb 100644 --- a/lib/src/types/js_before_unload_response.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'js_before_unload_response_action.dart'; diff --git a/lib/src/types/js_before_unload_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response.g.dart similarity index 100% rename from lib/src/types/js_before_unload_response.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response.g.dart diff --git a/lib/src/types/js_before_unload_response_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response_action.dart similarity index 100% rename from lib/src/types/js_before_unload_response_action.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response_action.dart diff --git a/lib/src/types/js_before_unload_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response_action.g.dart similarity index 100% rename from lib/src/types/js_before_unload_response_action.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response_action.g.dart diff --git a/lib/src/types/js_confirm_request.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_request.dart similarity index 95% rename from lib/src/types/js_confirm_request.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_confirm_request.dart index 72c9f19b..6ad92c4d 100644 --- a/lib/src/types/js_confirm_request.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_request.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import '../web_uri.dart'; part 'js_confirm_request.g.dart'; diff --git a/lib/src/types/js_confirm_request.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_request.g.dart similarity index 100% rename from lib/src/types/js_confirm_request.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_confirm_request.g.dart diff --git a/lib/src/types/js_confirm_response.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response.dart similarity index 95% rename from lib/src/types/js_confirm_response.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response.dart index 12808768..0ec3a610 100644 --- a/lib/src/types/js_confirm_response.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'js_confirm_response_action.dart'; diff --git a/lib/src/types/js_confirm_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response.g.dart similarity index 100% rename from lib/src/types/js_confirm_response.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response.g.dart diff --git a/lib/src/types/js_confirm_response_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response_action.dart similarity index 100% rename from lib/src/types/js_confirm_response_action.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response_action.dart diff --git a/lib/src/types/js_confirm_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response_action.g.dart similarity index 100% rename from lib/src/types/js_confirm_response_action.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response_action.g.dart diff --git a/lib/src/types/js_prompt_request.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_request.dart similarity index 95% rename from lib/src/types/js_prompt_request.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_prompt_request.dart index 16cb970b..a9d13ad0 100644 --- a/lib/src/types/js_prompt_request.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_request.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import '../web_uri.dart'; part 'js_prompt_request.g.dart'; diff --git a/lib/src/types/js_prompt_request.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_request.g.dart similarity index 100% rename from lib/src/types/js_prompt_request.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_prompt_request.g.dart diff --git a/lib/src/types/js_prompt_response.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response.dart similarity index 96% rename from lib/src/types/js_prompt_response.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response.dart index e13c31a9..f07254b9 100644 --- a/lib/src/types/js_prompt_response.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'js_prompt_response_action.dart'; diff --git a/lib/src/types/js_prompt_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response.g.dart similarity index 100% rename from lib/src/types/js_prompt_response.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response.g.dart diff --git a/lib/src/types/js_prompt_response_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response_action.dart similarity index 100% rename from lib/src/types/js_prompt_response_action.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response_action.dart diff --git a/lib/src/types/js_prompt_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response_action.g.dart similarity index 100% rename from lib/src/types/js_prompt_response_action.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response_action.g.dart diff --git a/lib/src/types/layout_algorithm.dart b/flutter_inappwebview_platform_interface/lib/src/types/layout_algorithm.dart similarity index 100% rename from lib/src/types/layout_algorithm.dart rename to flutter_inappwebview_platform_interface/lib/src/types/layout_algorithm.dart diff --git a/lib/src/types/layout_algorithm.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/layout_algorithm.g.dart similarity index 100% rename from lib/src/types/layout_algorithm.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/layout_algorithm.g.dart diff --git a/lib/src/types/layout_in_display_cutout_mode.dart b/flutter_inappwebview_platform_interface/lib/src/types/layout_in_display_cutout_mode.dart similarity index 100% rename from lib/src/types/layout_in_display_cutout_mode.dart rename to flutter_inappwebview_platform_interface/lib/src/types/layout_in_display_cutout_mode.dart diff --git a/lib/src/types/layout_in_display_cutout_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/layout_in_display_cutout_mode.g.dart similarity index 100% rename from lib/src/types/layout_in_display_cutout_mode.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/layout_in_display_cutout_mode.g.dart diff --git a/lib/src/types/loaded_resource.dart b/flutter_inappwebview_platform_interface/lib/src/types/loaded_resource.dart similarity index 88% rename from lib/src/types/loaded_resource.dart rename to flutter_inappwebview_platform_interface/lib/src/types/loaded_resource.dart index b2de6727..1ec2d945 100644 --- a/lib/src/types/loaded_resource.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/loaded_resource.dart @@ -1,11 +1,11 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import '../web_uri.dart'; part 'loaded_resource.g.dart'; -///Class representing a resource response of the [WebView]. +///Class representing a resource response of the `WebView`. ///It is used by the method [WebView.onLoadResource]. @ExchangeableObject() class LoadedResource_ { diff --git a/lib/src/types/loaded_resource.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/loaded_resource.g.dart similarity index 96% rename from lib/src/types/loaded_resource.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/loaded_resource.g.dart index 314af1c3..db862863 100644 --- a/lib/src/types/loaded_resource.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/loaded_resource.g.dart @@ -6,7 +6,7 @@ part of 'loaded_resource.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Class representing a resource response of the [WebView]. +///Class representing a resource response of the `WebView`. ///It is used by the method [WebView.onLoadResource]. class LoadedResource { ///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) duration to fetch a resource. diff --git a/lib/src/types/login_request.dart b/flutter_inappwebview_platform_interface/lib/src/types/login_request.dart similarity index 94% rename from lib/src/types/login_request.dart rename to flutter_inappwebview_platform_interface/lib/src/types/login_request.dart index 5f137000..422c2a60 100644 --- a/lib/src/types/login_request.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/login_request.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + part 'login_request.g.dart'; diff --git a/lib/src/types/login_request.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/login_request.g.dart similarity index 100% rename from lib/src/types/login_request.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/login_request.g.dart diff --git a/lib/src/types/main.dart b/flutter_inappwebview_platform_interface/lib/src/types/main.dart similarity index 99% rename from lib/src/types/main.dart rename to flutter_inappwebview_platform_interface/lib/src/types/main.dart index 5c167f3b..cc320565 100644 --- a/lib/src/types/main.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/main.dart @@ -225,3 +225,4 @@ export 'tracing_mode.dart' show TracingMode; export 'tracing_category.dart' show TracingCategory; export 'custom_tabs_post_message_result_type.dart' show CustomTabsPostMessageResultType; +export 'disposable.dart'; \ No newline at end of file diff --git a/lib/src/types/media_capture_state.dart b/flutter_inappwebview_platform_interface/lib/src/types/media_capture_state.dart similarity index 100% rename from lib/src/types/media_capture_state.dart rename to flutter_inappwebview_platform_interface/lib/src/types/media_capture_state.dart diff --git a/lib/src/types/media_capture_state.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/media_capture_state.g.dart similarity index 100% rename from lib/src/types/media_capture_state.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/media_capture_state.g.dart diff --git a/lib/src/types/media_playback_state.dart b/flutter_inappwebview_platform_interface/lib/src/types/media_playback_state.dart similarity index 100% rename from lib/src/types/media_playback_state.dart rename to flutter_inappwebview_platform_interface/lib/src/types/media_playback_state.dart diff --git a/lib/src/types/media_playback_state.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/media_playback_state.g.dart similarity index 100% rename from lib/src/types/media_playback_state.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/media_playback_state.g.dart diff --git a/lib/src/types/meta_tag.dart b/flutter_inappwebview_platform_interface/lib/src/types/meta_tag.dart similarity index 80% rename from lib/src/types/meta_tag.dart rename to flutter_inappwebview_platform_interface/lib/src/types/meta_tag.dart index 0103245b..892e4688 100644 --- a/lib/src/types/meta_tag.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/meta_tag.dart @@ -1,11 +1,11 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/in_app_webview_controller.dart'; +import '../in_app_webview/platform_inappwebview_controller.dart'; import 'meta_tag_attribute.dart'; part 'meta_tag.g.dart'; -///Class that represents a `` HTML tag. It is used by the [InAppWebViewController.getMetaTags] method. +///Class that represents a `` HTML tag. It is used by the [PlatformInAppWebViewController.getMetaTags] method. @ExchangeableObject() class MetaTag_ { ///The meta tag name value. diff --git a/lib/src/types/meta_tag.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/meta_tag.g.dart similarity index 100% rename from lib/src/types/meta_tag.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/meta_tag.g.dart diff --git a/lib/src/types/meta_tag_attribute.dart b/flutter_inappwebview_platform_interface/lib/src/types/meta_tag_attribute.dart similarity index 100% rename from lib/src/types/meta_tag_attribute.dart rename to flutter_inappwebview_platform_interface/lib/src/types/meta_tag_attribute.dart diff --git a/lib/src/types/meta_tag_attribute.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/meta_tag_attribute.g.dart similarity index 100% rename from lib/src/types/meta_tag_attribute.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/meta_tag_attribute.g.dart diff --git a/lib/src/types/mixed_content_mode.dart b/flutter_inappwebview_platform_interface/lib/src/types/mixed_content_mode.dart similarity index 100% rename from lib/src/types/mixed_content_mode.dart rename to flutter_inappwebview_platform_interface/lib/src/types/mixed_content_mode.dart diff --git a/lib/src/types/mixed_content_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/mixed_content_mode.g.dart similarity index 100% rename from lib/src/types/mixed_content_mode.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/mixed_content_mode.g.dart diff --git a/lib/src/types/modal_presentation_style.dart b/flutter_inappwebview_platform_interface/lib/src/types/modal_presentation_style.dart similarity index 100% rename from lib/src/types/modal_presentation_style.dart rename to flutter_inappwebview_platform_interface/lib/src/types/modal_presentation_style.dart diff --git a/lib/src/types/modal_presentation_style.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/modal_presentation_style.g.dart similarity index 100% rename from lib/src/types/modal_presentation_style.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/modal_presentation_style.g.dart diff --git a/lib/src/types/modal_transition_style.dart b/flutter_inappwebview_platform_interface/lib/src/types/modal_transition_style.dart similarity index 100% rename from lib/src/types/modal_transition_style.dart rename to flutter_inappwebview_platform_interface/lib/src/types/modal_transition_style.dart diff --git a/lib/src/types/modal_transition_style.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/modal_transition_style.g.dart similarity index 100% rename from lib/src/types/modal_transition_style.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/modal_transition_style.g.dart diff --git a/lib/src/types/navigation_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_action.dart similarity index 99% rename from lib/src/types/navigation_action.dart rename to flutter_inappwebview_platform_interface/lib/src/types/navigation_action.dart index c48da65e..cf312003 100644 --- a/lib/src/types/navigation_action.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/navigation_action.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'url_request.dart'; import 'navigation_type.dart'; import 'frame_info.dart'; diff --git a/lib/src/types/navigation_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_action.g.dart similarity index 100% rename from lib/src/types/navigation_action.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/navigation_action.g.dart diff --git a/lib/src/types/navigation_action_policy.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_action_policy.dart similarity index 95% rename from lib/src/types/navigation_action_policy.dart rename to flutter_inappwebview_platform_interface/lib/src/types/navigation_action_policy.dart index 4cc954fe..5f031647 100644 --- a/lib/src/types/navigation_action_policy.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/navigation_action_policy.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + part 'navigation_action_policy.g.dart'; diff --git a/lib/src/types/navigation_action_policy.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_action_policy.g.dart similarity index 100% rename from lib/src/types/navigation_action_policy.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/navigation_action_policy.g.dart diff --git a/lib/src/types/navigation_response.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_response.dart similarity index 97% rename from lib/src/types/navigation_response.dart rename to flutter_inappwebview_platform_interface/lib/src/types/navigation_response.dart index 7f57adde..95d8fc0c 100644 --- a/lib/src/types/navigation_response.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/navigation_response.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'url_response.dart'; part 'navigation_response.g.dart'; diff --git a/lib/src/types/navigation_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_response.g.dart similarity index 100% rename from lib/src/types/navigation_response.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/navigation_response.g.dart diff --git a/lib/src/types/navigation_response_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_response_action.dart similarity index 97% rename from lib/src/types/navigation_response_action.dart rename to flutter_inappwebview_platform_interface/lib/src/types/navigation_response_action.dart index 9a2a4ed0..871a61c8 100644 --- a/lib/src/types/navigation_response_action.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/navigation_response_action.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + part 'navigation_response_action.g.dart'; diff --git a/lib/src/types/navigation_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_response_action.g.dart similarity index 100% rename from lib/src/types/navigation_response_action.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/navigation_response_action.g.dart diff --git a/lib/src/types/navigation_type.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_type.dart similarity index 98% rename from lib/src/types/navigation_type.dart rename to flutter_inappwebview_platform_interface/lib/src/types/navigation_type.dart index 82680b97..9089a844 100644 --- a/lib/src/types/navigation_type.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/navigation_type.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + part 'navigation_type.g.dart'; diff --git a/lib/src/types/navigation_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_type.g.dart similarity index 100% rename from lib/src/types/navigation_type.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/navigation_type.g.dart diff --git a/flutter_inappwebview_platform_interface/lib/src/types/on_post_message_callback.dart b/flutter_inappwebview_platform_interface/lib/src/types/on_post_message_callback.dart new file mode 100644 index 00000000..eff4745b --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/types/on_post_message_callback.dart @@ -0,0 +1,6 @@ +import '../web_message/main.dart'; +import '../web_uri.dart'; + +///The listener for handling [PlatformWebMessageListener] events sent by a `postMessage()` on the injected JavaScript object. +typedef void OnPostMessageCallback(WebMessage? message, WebUri? sourceOrigin, + bool isMainFrame, PlatformJavaScriptReplyProxy replyProxy); diff --git a/lib/src/types/over_scroll_mode.dart b/flutter_inappwebview_platform_interface/lib/src/types/over_scroll_mode.dart similarity index 86% rename from lib/src/types/over_scroll_mode.dart rename to flutter_inappwebview_platform_interface/lib/src/types/over_scroll_mode.dart index b542d292..dac1a582 100644 --- a/lib/src/types/over_scroll_mode.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/over_scroll_mode.dart @@ -1,11 +1,11 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + part 'over_scroll_mode.g.dart'; -///Class used to configure the [WebView]'s over-scroll mode. -///Setting the over-scroll mode of a WebView will have an effect only if the [WebView] is capable of scrolling. +///Class used to configure the `WebView`'s over-scroll mode. +///Setting the over-scroll mode of a WebView will have an effect only if the `WebView` is capable of scrolling. @ExchangeableEnum() class OverScrollMode_ { // ignore: unused_field @@ -22,8 +22,8 @@ class OverScrollMode_ { static const NEVER = const OverScrollMode_._internal(2); } -///An Android-specific class used to configure the [WebView]'s over-scroll mode. -///Setting the over-scroll mode of a WebView will have an effect only if the [WebView] is capable of scrolling. +///An Android-specific class used to configure the `WebView`'s over-scroll mode. +///Setting the over-scroll mode of a WebView will have an effect only if the `WebView` is capable of scrolling. ///Use [OverScrollMode] instead. @Deprecated("Use OverScrollMode instead") @ExchangeableEnum() diff --git a/lib/src/types/over_scroll_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/over_scroll_mode.g.dart similarity index 95% rename from lib/src/types/over_scroll_mode.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/over_scroll_mode.g.dart index 8f277823..7e4b5e43 100644 --- a/lib/src/types/over_scroll_mode.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/over_scroll_mode.g.dart @@ -6,8 +6,8 @@ part of 'over_scroll_mode.dart'; // ExchangeableEnumGenerator // ************************************************************************** -///Class used to configure the [WebView]'s over-scroll mode. -///Setting the over-scroll mode of a WebView will have an effect only if the [WebView] is capable of scrolling. +///Class used to configure the `WebView`'s over-scroll mode. +///Setting the over-scroll mode of a WebView will have an effect only if the `WebView` is capable of scrolling. class OverScrollMode { final int _value; final int _nativeValue; @@ -85,8 +85,8 @@ class OverScrollMode { } } -///An Android-specific class used to configure the [WebView]'s over-scroll mode. -///Setting the over-scroll mode of a WebView will have an effect only if the [WebView] is capable of scrolling. +///An Android-specific class used to configure the `WebView`'s over-scroll mode. +///Setting the over-scroll mode of a WebView will have an effect only if the `WebView` is capable of scrolling. ///Use [OverScrollMode] instead. @Deprecated('Use OverScrollMode instead') class AndroidOverScrollMode { diff --git a/lib/src/types/pdf_configuration.dart b/flutter_inappwebview_platform_interface/lib/src/types/pdf_configuration.dart similarity index 91% rename from lib/src/types/pdf_configuration.dart rename to flutter_inappwebview_platform_interface/lib/src/types/pdf_configuration.dart index 38fc0d65..14afbeca 100644 --- a/lib/src/types/pdf_configuration.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/pdf_configuration.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'in_app_webview_rect.dart'; part 'pdf_configuration.g.dart'; @@ -10,7 +10,7 @@ part 'pdf_configuration.g.dart'; class PDFConfiguration_ { ///The portion of your web view to capture, specified as a rectangle in the view’s coordinate system. ///The default value of this property is `null`, which captures everything in the view’s bounds rectangle. - ///If you specify a custom rectangle, it must lie within the bounds rectangle of the [WebView] object. + ///If you specify a custom rectangle, it must lie within the bounds rectangle of the `WebView` object. InAppWebViewRect_? rect; PDFConfiguration_({this.rect}); @@ -26,7 +26,7 @@ class PDFConfiguration_ { class IOSWKPDFConfiguration_ { ///The portion of your web view to capture, specified as a rectangle in the view’s coordinate system. ///The default value of this property is `null`, which captures everything in the view’s bounds rectangle. - ///If you specify a custom rectangle, it must lie within the bounds rectangle of the [WebView] object. + ///If you specify a custom rectangle, it must lie within the bounds rectangle of the `WebView` object. InAppWebViewRect_? rect; IOSWKPDFConfiguration_({this.rect}); diff --git a/lib/src/types/pdf_configuration.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/pdf_configuration.g.dart similarity index 97% rename from lib/src/types/pdf_configuration.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/pdf_configuration.g.dart index dfcdc54c..b4c06945 100644 --- a/lib/src/types/pdf_configuration.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/pdf_configuration.g.dart @@ -10,7 +10,7 @@ part of 'pdf_configuration.dart'; class PDFConfiguration { ///The portion of your web view to capture, specified as a rectangle in the view’s coordinate system. ///The default value of this property is `null`, which captures everything in the view’s bounds rectangle. - ///If you specify a custom rectangle, it must lie within the bounds rectangle of the [WebView] object. + ///If you specify a custom rectangle, it must lie within the bounds rectangle of the `WebView` object. InAppWebViewRect? rect; PDFConfiguration({this.rect}); @@ -52,7 +52,7 @@ class PDFConfiguration { class IOSWKPDFConfiguration { ///The portion of your web view to capture, specified as a rectangle in the view’s coordinate system. ///The default value of this property is `null`, which captures everything in the view’s bounds rectangle. - ///If you specify a custom rectangle, it must lie within the bounds rectangle of the [WebView] object. + ///If you specify a custom rectangle, it must lie within the bounds rectangle of the `WebView` object. InAppWebViewRect? rect; IOSWKPDFConfiguration({this.rect}); diff --git a/lib/src/types/permission_request.dart b/flutter_inappwebview_platform_interface/lib/src/types/permission_request.dart similarity index 95% rename from lib/src/types/permission_request.dart rename to flutter_inappwebview_platform_interface/lib/src/types/permission_request.dart index d47f93bc..c581464e 100644 --- a/lib/src/types/permission_request.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/permission_request.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import '../web_uri.dart'; import 'permission_resource_type.dart'; import 'permission_response.dart'; diff --git a/lib/src/types/permission_request.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/permission_request.g.dart similarity index 100% rename from lib/src/types/permission_request.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/permission_request.g.dart diff --git a/lib/src/types/permission_resource_type.dart b/flutter_inappwebview_platform_interface/lib/src/types/permission_resource_type.dart similarity index 100% rename from lib/src/types/permission_resource_type.dart rename to flutter_inappwebview_platform_interface/lib/src/types/permission_resource_type.dart diff --git a/lib/src/types/permission_resource_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/permission_resource_type.g.dart similarity index 100% rename from lib/src/types/permission_resource_type.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/permission_resource_type.g.dart diff --git a/lib/src/types/permission_response.dart b/flutter_inappwebview_platform_interface/lib/src/types/permission_response.dart similarity index 97% rename from lib/src/types/permission_response.dart rename to flutter_inappwebview_platform_interface/lib/src/types/permission_response.dart index 58538a05..3d6160d7 100644 --- a/lib/src/types/permission_response.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/permission_response.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'permission_resource_type.dart'; import 'permission_response_action.dart'; diff --git a/lib/src/types/permission_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/permission_response.g.dart similarity index 100% rename from lib/src/types/permission_response.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/permission_response.g.dart diff --git a/lib/src/types/permission_response_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/permission_response_action.dart similarity index 100% rename from lib/src/types/permission_response_action.dart rename to flutter_inappwebview_platform_interface/lib/src/types/permission_response_action.dart diff --git a/lib/src/types/permission_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/permission_response_action.g.dart similarity index 100% rename from lib/src/types/permission_response_action.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/permission_response_action.g.dart diff --git a/lib/src/types/prewarming_token.dart b/flutter_inappwebview_platform_interface/lib/src/types/prewarming_token.dart similarity index 60% rename from lib/src/types/prewarming_token.dart rename to flutter_inappwebview_platform_interface/lib/src/types/prewarming_token.dart index 605f9a5c..583ba2b9 100644 --- a/lib/src/types/prewarming_token.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/prewarming_token.dart @@ -1,10 +1,10 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../chrome_safari_browser/chrome_safari_browser.dart'; +import '../chrome_safari_browser/platform_chrome_safari_browser.dart'; part 'prewarming_token.g.dart'; -///Class that represents the Prewarming Token returned by [ChromeSafariBrowser.prewarmConnections]. +///Class that represents the Prewarming Token returned by [PlatformChromeSafariBrowser.prewarmConnections]. @ExchangeableObject() class PrewarmingToken_ { ///Prewarming Token id. diff --git a/lib/src/types/prewarming_token.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/prewarming_token.g.dart similarity index 89% rename from lib/src/types/prewarming_token.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/prewarming_token.g.dart index 92cf7130..334482b8 100644 --- a/lib/src/types/prewarming_token.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/prewarming_token.g.dart @@ -6,7 +6,7 @@ part of 'prewarming_token.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Class that represents the Prewarming Token returned by [ChromeSafariBrowser.prewarmConnections]. +///Class that represents the Prewarming Token returned by [PlatformChromeSafariBrowser.prewarmConnections]. class PrewarmingToken { ///Prewarming Token id. final String id; diff --git a/lib/src/types/print_job_attributes.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_attributes.dart similarity index 98% rename from lib/src/types/print_job_attributes.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_attributes.dart index 6ef0f81c..db5c0924 100644 --- a/lib/src/types/print_job_attributes.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_attributes.dart @@ -15,7 +15,7 @@ import 'print_job_disposition.dart'; part 'print_job_attributes.g.dart'; -///Class representing the attributes of a [PrintJobController]. +///Class representing the attributes of a [PlatformPrintJobController]. ///These attributes describe how the printed content should be laid out. @ExchangeableObject() class PrintJobAttributes_ { diff --git a/lib/src/types/print_job_attributes.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_attributes.g.dart similarity index 99% rename from lib/src/types/print_job_attributes.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_attributes.g.dart index f275020d..1f763dec 100644 --- a/lib/src/types/print_job_attributes.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_attributes.g.dart @@ -6,7 +6,7 @@ part of 'print_job_attributes.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Class representing the attributes of a [PrintJobController]. +///Class representing the attributes of a [PlatformPrintJobController]. ///These attributes describe how the printed content should be laid out. class PrintJobAttributes { ///The color mode. diff --git a/lib/src/types/print_job_color_mode.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_color_mode.dart similarity index 90% rename from lib/src/types/print_job_color_mode.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_color_mode.dart index 76693bfb..6e4abcb3 100644 --- a/lib/src/types/print_job_color_mode.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_color_mode.dart @@ -5,7 +5,7 @@ import '../print_job/main.dart'; part 'print_job_color_mode.g.dart'; -///Class representing how the printed content of a [PrintJobController] should be laid out. +///Class representing how the printed content of a [PlatformPrintJobController] should be laid out. @ExchangeableEnum() class PrintJobColorMode_ { // ignore: unused_field diff --git a/lib/src/types/print_job_color_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_color_mode.g.dart similarity index 96% rename from lib/src/types/print_job_color_mode.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_color_mode.g.dart index 11cd5ff0..0049daa5 100644 --- a/lib/src/types/print_job_color_mode.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_color_mode.g.dart @@ -6,7 +6,7 @@ part of 'print_job_color_mode.dart'; // ExchangeableEnumGenerator // ************************************************************************** -///Class representing how the printed content of a [PrintJobController] should be laid out. +///Class representing how the printed content of a [PlatformPrintJobController] should be laid out. class PrintJobColorMode { final int _value; final dynamic _nativeValue; diff --git a/lib/src/types/print_job_disposition.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_disposition.dart similarity index 95% rename from lib/src/types/print_job_disposition.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_disposition.dart index 645e2fac..bf44ac3a 100644 --- a/lib/src/types/print_job_disposition.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_disposition.dart @@ -5,7 +5,7 @@ import '../print_job/main.dart'; part 'print_job_disposition.g.dart'; -///Class representing the constants that specify values for the print job disposition of a [PrintJobController]. +///Class representing the constants that specify values for the print job disposition of a [PlatformPrintJobController]. @ExchangeableEnum() class PrintJobDisposition_ { // ignore: unused_field diff --git a/lib/src/types/print_job_disposition.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_disposition.g.dart similarity index 98% rename from lib/src/types/print_job_disposition.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_disposition.g.dart index 7500723e..82848a4a 100644 --- a/lib/src/types/print_job_disposition.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_disposition.g.dart @@ -6,7 +6,7 @@ part of 'print_job_disposition.dart'; // ExchangeableEnumGenerator // ************************************************************************** -///Class representing the constants that specify values for the print job disposition of a [PrintJobController]. +///Class representing the constants that specify values for the print job disposition of a [PlatformPrintJobController]. class PrintJobDisposition { final String _value; final String _nativeValue; diff --git a/lib/src/types/print_job_duplex_mode.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_duplex_mode.dart similarity index 95% rename from lib/src/types/print_job_duplex_mode.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_duplex_mode.dart index e6e29d2e..99390f2b 100644 --- a/lib/src/types/print_job_duplex_mode.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_duplex_mode.dart @@ -5,7 +5,7 @@ import '../print_job/main.dart'; part 'print_job_duplex_mode.g.dart'; -///Class representing the orientation of a [PrintJobController]. +///Class representing the orientation of a [PlatformPrintJobController]. @ExchangeableEnum() class PrintJobDuplexMode_ { // ignore: unused_field diff --git a/lib/src/types/print_job_duplex_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_duplex_mode.g.dart similarity index 97% rename from lib/src/types/print_job_duplex_mode.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_duplex_mode.g.dart index 33db7136..6a4f8392 100644 --- a/lib/src/types/print_job_duplex_mode.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_duplex_mode.g.dart @@ -6,7 +6,7 @@ part of 'print_job_duplex_mode.dart'; // ExchangeableEnumGenerator // ************************************************************************** -///Class representing the orientation of a [PrintJobController]. +///Class representing the orientation of a [PlatformPrintJobController]. class PrintJobDuplexMode { final String _value; final int? _nativeValue; diff --git a/lib/src/types/print_job_info.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_info.dart similarity index 98% rename from lib/src/types/print_job_info.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_info.dart index 572f5711..7ff6e9e8 100644 --- a/lib/src/types/print_job_info.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_info.dart @@ -9,7 +9,7 @@ import 'printer.dart'; part 'print_job_info.g.dart'; -///Class representing the description of a [PrintJobController]. +///Class representing the description of a [PlatformPrintJobController]. ///Note that the print jobs state may change over time and this class represents a snapshot of this state. @ExchangeableObject() class PrintJobInfo_ { diff --git a/lib/src/types/print_job_info.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_info.g.dart similarity index 98% rename from lib/src/types/print_job_info.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_info.g.dart index e470d13b..a77112ff 100644 --- a/lib/src/types/print_job_info.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_info.g.dart @@ -6,7 +6,7 @@ part of 'print_job_info.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Class representing the description of a [PrintJobController]. +///Class representing the description of a [PlatformPrintJobController]. ///Note that the print jobs state may change over time and this class represents a snapshot of this state. class PrintJobInfo { ///The attributes of a print job. diff --git a/lib/src/types/print_job_media_size.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_media_size.dart similarity index 99% rename from lib/src/types/print_job_media_size.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_media_size.dart index 2a3dd53f..828f8660 100644 --- a/lib/src/types/print_job_media_size.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_media_size.dart @@ -4,7 +4,7 @@ import '../print_job/main.dart'; part 'print_job_media_size.g.dart'; -///Class representing the supported media size for a [PrintJobController]. +///Class representing the supported media size for a [PlatformPrintJobController]. ///Media size is the dimension of the media on which the content is printed. @ExchangeableObject() class PrintJobMediaSize_ { diff --git a/lib/src/types/print_job_media_size.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_media_size.g.dart similarity index 99% rename from lib/src/types/print_job_media_size.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_media_size.g.dart index d7ecb219..038449c1 100644 --- a/lib/src/types/print_job_media_size.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_media_size.g.dart @@ -6,7 +6,7 @@ part of 'print_job_media_size.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Class representing the supported media size for a [PrintJobController]. +///Class representing the supported media size for a [PlatformPrintJobController]. ///Media size is the dimension of the media on which the content is printed. class PrintJobMediaSize { ///North America ANSI C media size: 17" x 22" (432mm x 559mm) diff --git a/lib/src/types/print_job_orientation.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_orientation.dart similarity index 91% rename from lib/src/types/print_job_orientation.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_orientation.dart index 28713342..259125ff 100644 --- a/lib/src/types/print_job_orientation.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_orientation.dart @@ -5,7 +5,7 @@ import '../print_job/main.dart'; part 'print_job_orientation.g.dart'; -///Class representing the orientation of a [PrintJobController]. +///Class representing the orientation of a [PlatformPrintJobController]. @ExchangeableEnum() class PrintJobOrientation_ { // ignore: unused_field diff --git a/lib/src/types/print_job_orientation.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_orientation.g.dart similarity index 97% rename from lib/src/types/print_job_orientation.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_orientation.g.dart index 191ad0b9..cbe1ff4d 100644 --- a/lib/src/types/print_job_orientation.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_orientation.g.dart @@ -6,7 +6,7 @@ part of 'print_job_orientation.dart'; // ExchangeableEnumGenerator // ************************************************************************** -///Class representing the orientation of a [PrintJobController]. +///Class representing the orientation of a [PlatformPrintJobController]. class PrintJobOrientation { final int _value; final int _nativeValue; diff --git a/lib/src/types/print_job_output_type.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_output_type.dart similarity index 94% rename from lib/src/types/print_job_output_type.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_output_type.dart index f0a9a1e1..73a7e1b8 100644 --- a/lib/src/types/print_job_output_type.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_output_type.dart @@ -4,7 +4,7 @@ import '../print_job/main.dart'; part 'print_job_output_type.g.dart'; -///Class representing the kind of printable content of a [PrintJobController]. +///Class representing the kind of printable content of a [PlatformPrintJobController]. @ExchangeableEnum() class PrintJobOutputType_ { // ignore: unused_field diff --git a/lib/src/types/print_job_output_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_output_type.g.dart similarity index 97% rename from lib/src/types/print_job_output_type.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_output_type.g.dart index 4b36b201..c4b7ca7f 100644 --- a/lib/src/types/print_job_output_type.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_output_type.g.dart @@ -6,7 +6,7 @@ part of 'print_job_output_type.dart'; // ExchangeableEnumGenerator // ************************************************************************** -///Class representing the kind of printable content of a [PrintJobController]. +///Class representing the kind of printable content of a [PlatformPrintJobController]. class PrintJobOutputType { final int _value; final int _nativeValue; diff --git a/lib/src/types/print_job_page_order.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_page_order.dart similarity index 96% rename from lib/src/types/print_job_page_order.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_page_order.dart index 8b1630eb..811b3bc3 100644 --- a/lib/src/types/print_job_page_order.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_page_order.dart @@ -5,7 +5,7 @@ import '../print_job/main.dart'; part 'print_job_page_order.g.dart'; -///Class representing the page order that will be used to generate the pages of a [PrintJobController]. +///Class representing the page order that will be used to generate the pages of a [PlatformPrintJobController]. @ExchangeableEnum() class PrintJobPageOrder_ { // ignore: unused_field diff --git a/lib/src/types/print_job_page_order.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_page_order.g.dart similarity index 98% rename from lib/src/types/print_job_page_order.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_page_order.g.dart index 9a308626..84d90d22 100644 --- a/lib/src/types/print_job_page_order.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_page_order.g.dart @@ -6,7 +6,7 @@ part of 'print_job_page_order.dart'; // ExchangeableEnumGenerator // ************************************************************************** -///Class representing the page order that will be used to generate the pages of a [PrintJobController]. +///Class representing the page order that will be used to generate the pages of a [PlatformPrintJobController]. class PrintJobPageOrder { final int _value; final int _nativeValue; diff --git a/lib/src/types/print_job_pagination_mode.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_pagination_mode.dart similarity index 92% rename from lib/src/types/print_job_pagination_mode.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_pagination_mode.dart index 31c9bafa..eae72d12 100644 --- a/lib/src/types/print_job_pagination_mode.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_pagination_mode.dart @@ -5,7 +5,7 @@ import '../print_job/main.dart'; part 'print_job_pagination_mode.g.dart'; -///Class representing the constants that specify the different ways in which an image is divided into pages of a [PrintJobController]. +///Class representing the constants that specify the different ways in which an image is divided into pages of a [PlatformPrintJobController]. @ExchangeableEnum() class PrintJobPaginationMode_ { // ignore: unused_field diff --git a/lib/src/types/print_job_pagination_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_pagination_mode.g.dart similarity index 97% rename from lib/src/types/print_job_pagination_mode.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_pagination_mode.g.dart index 5b0033f0..dfd8db9f 100644 --- a/lib/src/types/print_job_pagination_mode.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_pagination_mode.g.dart @@ -6,7 +6,7 @@ part of 'print_job_pagination_mode.dart'; // ExchangeableEnumGenerator // ************************************************************************** -///Class representing the constants that specify the different ways in which an image is divided into pages of a [PrintJobController]. +///Class representing the constants that specify the different ways in which an image is divided into pages of a [PlatformPrintJobController]. class PrintJobPaginationMode { final String _value; final int? _nativeValue; diff --git a/lib/src/types/print_job_rendering_quality.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_rendering_quality.dart similarity index 93% rename from lib/src/types/print_job_rendering_quality.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_rendering_quality.dart index da41dd9f..2fc11475 100644 --- a/lib/src/types/print_job_rendering_quality.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_rendering_quality.dart @@ -5,7 +5,7 @@ import '../print_job/main.dart'; part 'print_job_rendering_quality.g.dart'; -///Class representing the rendering quality of a [PrintJobController]. +///Class representing the rendering quality of a [PlatformPrintJobController]. @ExchangeableEnum() class PrintJobRenderingQuality_ { // ignore: unused_field diff --git a/lib/src/types/print_job_rendering_quality.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_rendering_quality.g.dart similarity index 97% rename from lib/src/types/print_job_rendering_quality.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_rendering_quality.g.dart index b836c8fc..d002950b 100644 --- a/lib/src/types/print_job_rendering_quality.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_rendering_quality.g.dart @@ -6,7 +6,7 @@ part of 'print_job_rendering_quality.dart'; // ExchangeableEnumGenerator // ************************************************************************** -///Class representing the rendering quality of a [PrintJobController]. +///Class representing the rendering quality of a [PlatformPrintJobController]. class PrintJobRenderingQuality { final int _value; final int _nativeValue; diff --git a/lib/src/types/print_job_resolution.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_resolution.dart similarity index 96% rename from lib/src/types/print_job_resolution.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_resolution.dart index 52818196..cbbfd3c0 100644 --- a/lib/src/types/print_job_resolution.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_resolution.dart @@ -4,7 +4,7 @@ import '../print_job/main.dart'; part 'print_job_resolution.g.dart'; -///Class representing the supported resolution in DPI (dots per inch) for a [PrintJobController]. +///Class representing the supported resolution in DPI (dots per inch) for a [PlatformPrintJobController]. ///Resolution defines how many points with different color can be placed ///on one inch in horizontal or vertical direction of the target media. ///For example, a printer with 600 DPI can produce higher quality images diff --git a/lib/src/types/print_job_resolution.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_resolution.g.dart similarity index 98% rename from lib/src/types/print_job_resolution.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_resolution.g.dart index 3d11c801..d5827269 100644 --- a/lib/src/types/print_job_resolution.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_resolution.g.dart @@ -6,7 +6,7 @@ part of 'print_job_resolution.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Class representing the supported resolution in DPI (dots per inch) for a [PrintJobController]. +///Class representing the supported resolution in DPI (dots per inch) for a [PlatformPrintJobController]. ///Resolution defines how many points with different color can be placed ///on one inch in horizontal or vertical direction of the target media. ///For example, a printer with 600 DPI can produce higher quality images diff --git a/lib/src/types/print_job_state.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_state.dart similarity index 98% rename from lib/src/types/print_job_state.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_state.dart index 84f5438f..ecde333f 100644 --- a/lib/src/types/print_job_state.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_state.dart @@ -5,7 +5,7 @@ import '../print_job/main.dart'; part 'print_job_state.g.dart'; -///Class representing the state of a [PrintJobController]. +///Class representing the state of a [PlatformPrintJobController]. @ExchangeableEnum() class PrintJobState_ { // ignore: unused_field diff --git a/lib/src/types/print_job_state.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_state.g.dart similarity index 98% rename from lib/src/types/print_job_state.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/print_job_state.g.dart index 917740a3..17126173 100644 --- a/lib/src/types/print_job_state.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_state.g.dart @@ -6,7 +6,7 @@ part of 'print_job_state.dart'; // ExchangeableEnumGenerator // ************************************************************************** -///Class representing the state of a [PrintJobController]. +///Class representing the state of a [PlatformPrintJobController]. class PrintJobState { final int _value; final int? _nativeValue; diff --git a/lib/src/types/printer.dart b/flutter_inappwebview_platform_interface/lib/src/types/printer.dart similarity index 90% rename from lib/src/types/printer.dart rename to flutter_inappwebview_platform_interface/lib/src/types/printer.dart index e54a99e4..f66c67b9 100644 --- a/lib/src/types/printer.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/printer.dart @@ -4,7 +4,7 @@ import '../print_job/main.dart'; part 'printer.g.dart'; -///Class representing the printer used by a [PrintJobController]. +///Class representing the printer used by a [PlatformPrintJobController]. @ExchangeableObject() class Printer_ { ///The unique id of the printer. diff --git a/lib/src/types/printer.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/printer.g.dart similarity index 95% rename from lib/src/types/printer.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/printer.g.dart index 6318586d..cd7451a9 100644 --- a/lib/src/types/printer.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/printer.g.dart @@ -6,7 +6,7 @@ part of 'printer.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Class representing the printer used by a [PrintJobController]. +///Class representing the printer used by a [PlatformPrintJobController]. class Printer { ///The unique id of the printer. /// diff --git a/lib/src/types/proxy_rule.dart b/flutter_inappwebview_platform_interface/lib/src/types/proxy_rule.dart similarity index 100% rename from lib/src/types/proxy_rule.dart rename to flutter_inappwebview_platform_interface/lib/src/types/proxy_rule.dart diff --git a/lib/src/types/proxy_rule.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/proxy_rule.g.dart similarity index 100% rename from lib/src/types/proxy_rule.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/proxy_rule.g.dart diff --git a/lib/src/types/proxy_scheme_filter.dart b/flutter_inappwebview_platform_interface/lib/src/types/proxy_scheme_filter.dart similarity index 83% rename from lib/src/types/proxy_scheme_filter.dart rename to flutter_inappwebview_platform_interface/lib/src/types/proxy_scheme_filter.dart index fe526e82..a090d6be 100644 --- a/lib/src/types/proxy_scheme_filter.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/proxy_scheme_filter.dart @@ -1,10 +1,10 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../android/proxy_controller.dart'; +import '../platform_proxy_controller.dart'; part 'proxy_scheme_filter.g.dart'; -///Class that represent scheme filters used by [ProxyController]. +///Class that represent scheme filters used by [PlatformProxyController]. @ExchangeableEnum() class ProxySchemeFilter_ { // ignore: unused_field diff --git a/lib/src/types/proxy_scheme_filter.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/proxy_scheme_filter.g.dart similarity index 96% rename from lib/src/types/proxy_scheme_filter.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/proxy_scheme_filter.g.dart index 6393a5d4..7abc64a0 100644 --- a/lib/src/types/proxy_scheme_filter.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/proxy_scheme_filter.g.dart @@ -6,7 +6,7 @@ part of 'proxy_scheme_filter.dart'; // ExchangeableEnumGenerator // ************************************************************************** -///Class that represent scheme filters used by [ProxyController]. +///Class that represent scheme filters used by [PlatformProxyController]. class ProxySchemeFilter { final String _value; final String _nativeValue; diff --git a/lib/src/types/pull_to_refresh_size.dart b/flutter_inappwebview_platform_interface/lib/src/types/pull_to_refresh_size.dart similarity index 100% rename from lib/src/types/pull_to_refresh_size.dart rename to flutter_inappwebview_platform_interface/lib/src/types/pull_to_refresh_size.dart diff --git a/lib/src/types/pull_to_refresh_size.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/pull_to_refresh_size.g.dart similarity index 100% rename from lib/src/types/pull_to_refresh_size.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/pull_to_refresh_size.g.dart diff --git a/lib/src/types/referrer_policy.dart b/flutter_inappwebview_platform_interface/lib/src/types/referrer_policy.dart similarity index 100% rename from lib/src/types/referrer_policy.dart rename to flutter_inappwebview_platform_interface/lib/src/types/referrer_policy.dart diff --git a/lib/src/types/referrer_policy.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/referrer_policy.g.dart similarity index 100% rename from lib/src/types/referrer_policy.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/referrer_policy.g.dart diff --git a/lib/src/types/render_process_gone_detail.dart b/flutter_inappwebview_platform_interface/lib/src/types/render_process_gone_detail.dart similarity index 90% rename from lib/src/types/render_process_gone_detail.dart rename to flutter_inappwebview_platform_interface/lib/src/types/render_process_gone_detail.dart index 89bf2149..961931c3 100644 --- a/lib/src/types/render_process_gone_detail.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/render_process_gone_detail.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'renderer_priority.dart'; part 'render_process_gone_detail.g.dart'; @@ -15,7 +15,7 @@ class RenderProcessGoneDetail_ { bool didCrash; /// Returns the renderer priority that was set at the time that the renderer exited. This may be greater than the priority that - /// any individual [WebView] requested using []. + /// any individual `WebView` requested using []. RendererPriority_? rendererPriorityAtExit; RenderProcessGoneDetail_( diff --git a/lib/src/types/render_process_gone_detail.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/render_process_gone_detail.g.dart similarity index 97% rename from lib/src/types/render_process_gone_detail.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/render_process_gone_detail.g.dart index addc5862..c0656db8 100644 --- a/lib/src/types/render_process_gone_detail.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/render_process_gone_detail.g.dart @@ -15,7 +15,7 @@ class RenderProcessGoneDetail { bool didCrash; /// Returns the renderer priority that was set at the time that the renderer exited. This may be greater than the priority that - /// any individual [WebView] requested using []. + /// any individual `WebView` requested using []. RendererPriority? rendererPriorityAtExit; RenderProcessGoneDetail( {required this.didCrash, this.rendererPriorityAtExit}); diff --git a/lib/src/types/renderer_priority.dart b/flutter_inappwebview_platform_interface/lib/src/types/renderer_priority.dart similarity index 100% rename from lib/src/types/renderer_priority.dart rename to flutter_inappwebview_platform_interface/lib/src/types/renderer_priority.dart diff --git a/lib/src/types/renderer_priority.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/renderer_priority.g.dart similarity index 100% rename from lib/src/types/renderer_priority.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/renderer_priority.g.dart diff --git a/lib/src/types/renderer_priority_policy.dart b/flutter_inappwebview_platform_interface/lib/src/types/renderer_priority_policy.dart similarity index 97% rename from lib/src/types/renderer_priority_policy.dart rename to flutter_inappwebview_platform_interface/lib/src/types/renderer_priority_policy.dart index 371f1461..6a662df4 100644 --- a/lib/src/types/renderer_priority_policy.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/renderer_priority_policy.dart @@ -1,6 +1,6 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; + import 'renderer_priority.dart'; part 'renderer_priority_policy.g.dart'; diff --git a/lib/src/types/renderer_priority_policy.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/renderer_priority_policy.g.dart similarity index 100% rename from lib/src/types/renderer_priority_policy.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/renderer_priority_policy.g.dart diff --git a/lib/src/types/request_focus_node_href_result.dart b/flutter_inappwebview_platform_interface/lib/src/types/request_focus_node_href_result.dart similarity index 71% rename from lib/src/types/request_focus_node_href_result.dart rename to flutter_inappwebview_platform_interface/lib/src/types/request_focus_node_href_result.dart index 37805ff1..77f56c00 100644 --- a/lib/src/types/request_focus_node_href_result.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/request_focus_node_href_result.dart @@ -1,11 +1,11 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/in_app_webview_controller.dart'; +import '../in_app_webview/platform_inappwebview_controller.dart'; import '../web_uri.dart'; part 'request_focus_node_href_result.g.dart'; -///Class that represents the result used by the [InAppWebViewController.requestFocusNodeHref] method. +///Class that represents the result used by the [PlatformInAppWebViewController.requestFocusNodeHref] method. @ExchangeableObject() class RequestFocusNodeHrefResult_ { ///The anchor's href attribute. diff --git a/lib/src/types/request_focus_node_href_result.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/request_focus_node_href_result.g.dart similarity index 100% rename from lib/src/types/request_focus_node_href_result.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/request_focus_node_href_result.g.dart diff --git a/lib/src/types/request_image_ref_result.dart b/flutter_inappwebview_platform_interface/lib/src/types/request_image_ref_result.dart similarity index 64% rename from lib/src/types/request_image_ref_result.dart rename to flutter_inappwebview_platform_interface/lib/src/types/request_image_ref_result.dart index de288b9c..0c5c622f 100644 --- a/lib/src/types/request_image_ref_result.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/request_image_ref_result.dart @@ -1,11 +1,11 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/in_app_webview_controller.dart'; +import '../in_app_webview/platform_inappwebview_controller.dart'; import '../web_uri.dart'; part 'request_image_ref_result.g.dart'; -///Class that represents the result used by the [InAppWebViewController.requestImageRef] method. +///Class that represents the result used by the [PlatformInAppWebViewController.requestImageRef] method. @ExchangeableObject() class RequestImageRefResult_ { ///The image's url. diff --git a/lib/src/types/request_image_ref_result.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/request_image_ref_result.g.dart similarity index 100% rename from lib/src/types/request_image_ref_result.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/request_image_ref_result.g.dart diff --git a/lib/src/types/safe_browsing_response.dart b/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response.dart similarity index 78% rename from lib/src/types/safe_browsing_response.dart rename to flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response.dart index ce510265..d113e817 100644 --- a/lib/src/types/safe_browsing_response.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response.dart @@ -1,7 +1,7 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; -import '../in_app_webview/in_app_webview_controller.dart'; + +import '../in_app_webview/platform_inappwebview_controller.dart'; import 'safe_browsing_response_action.dart'; @@ -11,7 +11,7 @@ part 'safe_browsing_response.g.dart'; ///It is used to indicate an action to take when hitting a malicious URL. @ExchangeableObject() class SafeBrowsingResponse_ { - ///If reporting is enabled, all reports will be sent according to the privacy policy referenced by [InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl]. + ///If reporting is enabled, all reports will be sent according to the privacy policy referenced by [PlatformInAppWebViewController.getSafeBrowsingPrivacyPolicyUrl]. bool report; ///Indicate the [SafeBrowsingResponseAction] to take when hitting a malicious URL. diff --git a/lib/src/types/safe_browsing_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response.g.dart similarity index 100% rename from lib/src/types/safe_browsing_response.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response.g.dart diff --git a/lib/src/types/safe_browsing_response_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response_action.dart similarity index 100% rename from lib/src/types/safe_browsing_response_action.dart rename to flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response_action.dart diff --git a/lib/src/types/safe_browsing_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response_action.g.dart similarity index 100% rename from lib/src/types/safe_browsing_response_action.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response_action.g.dart diff --git a/lib/src/types/safe_browsing_threat.dart b/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_threat.dart similarity index 100% rename from lib/src/types/safe_browsing_threat.dart rename to flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_threat.dart diff --git a/lib/src/types/safe_browsing_threat.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_threat.g.dart similarity index 100% rename from lib/src/types/safe_browsing_threat.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_threat.g.dart diff --git a/lib/src/types/sandbox.dart b/flutter_inappwebview_platform_interface/lib/src/types/sandbox.dart similarity index 100% rename from lib/src/types/sandbox.dart rename to flutter_inappwebview_platform_interface/lib/src/types/sandbox.dart diff --git a/lib/src/types/sandbox.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/sandbox.g.dart similarity index 100% rename from lib/src/types/sandbox.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/sandbox.g.dart diff --git a/lib/src/types/screenshot_configuration.dart b/flutter_inappwebview_platform_interface/lib/src/types/screenshot_configuration.dart similarity index 89% rename from lib/src/types/screenshot_configuration.dart rename to flutter_inappwebview_platform_interface/lib/src/types/screenshot_configuration.dart index 61e13e93..f9a7ccc6 100644 --- a/lib/src/types/screenshot_configuration.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/screenshot_configuration.dart @@ -1,18 +1,18 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/webview.dart'; -import '../in_app_webview/in_app_webview_controller.dart'; + +import '../in_app_webview/platform_inappwebview_controller.dart'; import 'in_app_webview_rect.dart'; import 'compress_format.dart'; part 'screenshot_configuration.g.dart'; -///Class that represents the configuration data to use when generating an image from a web view’s contents using [InAppWebViewController.takeScreenshot]. +///Class that represents the configuration data to use when generating an image from a web view’s contents using [PlatformInAppWebViewController.takeScreenshot]. @ExchangeableObject() class ScreenshotConfiguration_ { ///The portion of your web view to capture, specified as a rectangle in the view’s coordinate system. ///The default value of this property is `null`, which captures everything in the view’s bounds rectangle. - ///If you specify a custom rectangle, it must lie within the bounds rectangle of the [WebView] object. + ///If you specify a custom rectangle, it must lie within the bounds rectangle of the `WebView` object. InAppWebViewRect_? rect; ///The width of the captured image, in points. @@ -36,7 +36,7 @@ class ScreenshotConfiguration_ { ///A Boolean value that indicates whether to take the snapshot after incorporating any pending screen updates. ///The default value of this property is `true`, which causes the web view to incorporate any recent changes to the view’s content and then generate the snapshot. - ///If you change the value to `false`, the [WebView] takes the snapshot immediately, and before incorporating any new changes. + ///If you change the value to `false`, the `WebView` takes the snapshot immediately, and before incorporating any new changes. /// ///**NOTE**: available only on iOS. /// diff --git a/lib/src/types/screenshot_configuration.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/screenshot_configuration.g.dart similarity index 97% rename from lib/src/types/screenshot_configuration.g.dart rename to flutter_inappwebview_platform_interface/lib/src/types/screenshot_configuration.g.dart index 73428aff..9ce7f445 100644 --- a/lib/src/types/screenshot_configuration.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/screenshot_configuration.g.dart @@ -10,7 +10,7 @@ part of 'screenshot_configuration.dart'; class ScreenshotConfiguration { ///A Boolean value that indicates whether to take the snapshot after incorporating any pending screen updates. ///The default value of this property is `true`, which causes the web view to incorporate any recent changes to the view’s content and then generate the snapshot. - ///If you change the value to `false`, the [WebView] takes the snapshot immediately, and before incorporating any new changes. + ///If you change the value to `false`, the `WebView` takes the snapshot immediately, and before incorporating any new changes. /// ///**NOTE**: available only on iOS. /// @@ -31,7 +31,7 @@ class ScreenshotConfiguration { ///The portion of your web view to capture, specified as a rectangle in the view’s coordinate system. ///The default value of this property is `null`, which captures everything in the view’s bounds rectangle. - ///If you specify a custom rectangle, it must lie within the bounds rectangle of the [WebView] object. + ///If you specify a custom rectangle, it must lie within the bounds rectangle of the `WebView` object. InAppWebViewRect? rect; ///The width of the captured image, in points. diff --git a/lib/src/types/script_html_tag_attributes.dart b/flutter_inappwebview_platform_interface/lib/src/types/script_html_tag_attributes.dart similarity index 96% rename from lib/src/types/script_html_tag_attributes.dart rename to flutter_inappwebview_platform_interface/lib/src/types/script_html_tag_attributes.dart index 589adc76..05a40266 100644 --- a/lib/src/types/script_html_tag_attributes.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/script_html_tag_attributes.dart @@ -1,12 +1,12 @@ import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import '../in_app_webview/in_app_webview_controller.dart'; +import '../in_app_webview/platform_inappwebview_controller.dart'; import 'cross_origin.dart'; import 'referrer_policy.dart'; part 'script_html_tag_attributes.g.dart'; -///Class that represents the possible the ` - ///``` - /// - ///Instead, on the `onLoadStop` WebView event, you can use `callHandler` directly: - ///```dart - /// // Inject JavaScript that will receive data back from Flutter - /// inAppWebViewController.evaluateJavascript(source: """ - /// window.flutter_inappwebview.callHandler('test', 'Text from Javascript').then(function(result) { - /// console.log(result); - /// }); - /// """); - ///``` - /// - ///Forbidden names for JavaScript handlers are defined in [_JAVASCRIPT_HANDLER_FORBIDDEN_NAMES]. - /// - ///**NOTE**: This method should be called, for example, in the [WebView.onWebViewCreated] or [WebView.onLoadStart] events or, at least, - ///before you know that your JavaScript code will call the `window.flutter_inappwebview.callHandler` method, - ///otherwise you won't be able to intercept the JavaScript message. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + @override void addJavaScriptHandler( {required String handlerName, required JavaScriptHandlerCallback callback}) { @@ -2330,41 +1990,18 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController this._javaScriptHandlersMap[handlerName] = (callback); } - ///Removes a JavaScript message handler previously added with the [addJavaScriptHandler] associated to [handlerName] key. - ///Returns the value associated with [handlerName] before it was removed. - ///Returns `null` if [handlerName] was not found. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + @override JavaScriptHandlerCallback? removeJavaScriptHandler( {required String handlerName}) { return this._javaScriptHandlersMap.remove(handlerName); } - ///Returns `true` if a JavaScript handler with [handlerName] already exists, otherwise `false`. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + @override bool hasJavaScriptHandler({required String handlerName}) { return this._javaScriptHandlersMap.containsKey(handlerName); } - ///Takes a screenshot of the WebView's visible viewport and returns a [Uint8List]. Returns `null` if it wasn't be able to take it. - /// - ///[screenshotConfiguration] represents the configuration data to use when generating an image from a web view’s contents. - /// - ///**NOTE for iOS**: available on iOS 11.0+. - /// - ///**NOTE for MacOS**: available on MacOS 10.13+. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ([Official API - WKWebView.takeSnapshot](https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot)) - ///- MacOS ([Official API - WKWebView.takeSnapshot](https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot)) + @override Future takeScreenshot( {ScreenshotConfiguration? screenshotConfiguration}) async { Map args = {}; @@ -2373,7 +2010,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return await channel?.invokeMethod('takeScreenshot', args); } - ///Use [setSettings] instead. + @override @Deprecated('Use setSettings instead') Future setOptions({required InAppWebViewGroupOptions options}) async { InAppWebViewSettings settings = @@ -2381,7 +2018,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await setSettings(settings: settings); } - ///Use [getSettings] instead. + @override @Deprecated('Use getSettings instead') Future getOptions() async { InAppWebViewSettings? settings = await getSettings(); @@ -2395,13 +2032,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return null; } - ///Sets the WebView settings with the new [settings] and evaluates them. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web + @override Future setSettings({required InAppWebViewSettings settings}) async { Map args = {}; @@ -2409,13 +2040,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await channel?.invokeMethod('setSettings', args); } - ///Gets the current WebView settings. Returns `null` if it wasn't able to get them. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web + @override Future getSettings() async { Map args = {}; @@ -2429,15 +2054,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return null; } - ///Gets the WebHistory for this WebView. This contains the back/forward list for use in querying each item in the history stack. - ///This contains only a snapshot of the current state. - ///Multiple calls to this method may return different objects. - ///The object returned from this method will not be updated to reflect any new state. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.copyBackForwardList](https://developer.android.com/reference/android/webkit/WebView#copyBackForwardList())) - ///- iOS ([Official API - WKWebView.backForwardList](https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist)) - ///- MacOS ([Official API - WKWebView.backForwardList](https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist)) + @override Future getCopyBackForwardList() async { Map args = {}; Map? result = @@ -2446,18 +2063,13 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return WebHistory.fromMap(result); } - ///Clears all the WebView's cache. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + @override Future clearCache() async { Map args = {}; await channel?.invokeMethod('clearCache', args); } - ///Use [AndroidFindInteractionController.findAll] instead. + @override @Deprecated("Use FindInteractionController.findAll instead") Future findAllAsync({required String find}) async { Map args = {}; @@ -2465,7 +2077,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await channel?.invokeMethod('findAll', args); } - ///Use [AndroidFindInteractionController.findNext] instead. + @override @Deprecated("Use FindInteractionController.findNext instead") Future findNext({required bool forward}) async { Map args = {}; @@ -2473,42 +2085,26 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await channel?.invokeMethod('findNext', args); } - ///Use [AndroidFindInteractionController.clearMatches] instead. + @override @Deprecated("Use FindInteractionController.clearMatches instead") Future clearMatches() async { Map args = {}; await channel?.invokeMethod('clearMatches', args); } - ///Use [tRexRunnerHtml] instead. + @override @Deprecated("Use tRexRunnerHtml instead") Future getTRexRunnerHtml() async { return await tRexRunnerHtml; } - ///Use [tRexRunnerCss] instead. + @override @Deprecated("Use tRexRunnerCss instead") Future getTRexRunnerCss() async { return await tRexRunnerCss; } - ///Scrolls the WebView to the position. - /// - ///[x] represents the x position to scroll to. - /// - ///[y] represents the y position to scroll to. - /// - ///[animated] `true` to animate the scroll transition, `false` to make the scoll transition immediate. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**NOTE for MacOS**: this method is implemented using JavaScript. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - View.scrollTo](https://developer.android.com/reference/android/view/View#scrollTo(int,%20int))) - ///- iOS ([Official API - UIScrollView.setContentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset)) - ///- MacOS - ///- Web ([Official API - Window.scrollTo](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo)) + @override Future scrollTo( {required int x, required int y, bool animated = false}) async { Map args = {}; @@ -2518,23 +2114,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await channel?.invokeMethod('scrollTo', args); } - ///Moves the scrolled position of the WebView. - /// - ///[x] represents the amount of pixels to scroll by horizontally. - /// - ///[y] represents the amount of pixels to scroll by vertically. - /// - ///[animated] `true` to animate the scroll transition, `false` to make the scoll transition immediate. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**NOTE for MacOS**: this method is implemented using JavaScript. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - View.scrollBy](https://developer.android.com/reference/android/view/View#scrollBy(int,%20int))) - ///- iOS ([Official API - UIScrollView.setContentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset)) - ///- MacOS - ///- Web ([Official API - Window.scrollBy](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy)) + @override Future scrollBy( {required int x, required int y, bool animated = false}) async { Map args = {}; @@ -2544,53 +2124,19 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await channel?.invokeMethod('scrollBy', args); } - ///On Android native WebView, it pauses all layout, parsing, and JavaScript timers for all WebViews. - ///This is a global requests, not restricted to just this WebView. This can be useful if the application has been paused. - /// - ///**NOTE for iOS**: it is implemented using JavaScript and it is restricted to just this WebView. - /// - ///**NOTE for MacOS**: it is implemented using JavaScript and it is restricted to just this WebView. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.pauseTimers](https://developer.android.com/reference/android/webkit/WebView#pauseTimers())) - ///- iOS - ///- MacOS + @override Future pauseTimers() async { Map args = {}; await channel?.invokeMethod('pauseTimers', args); } - ///On Android, it resumes all layout, parsing, and JavaScript timers for all WebViews. This will resume dispatching all timers. - /// - ///**NOTE for iOS**: it is implemented using JavaScript and it is restricted to just this WebView. - /// - ///**NOTE for MacOS**: it is implemented using JavaScript and it is restricted to just this WebView. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.resumeTimers](https://developer.android.com/reference/android/webkit/WebView#resumeTimers())) - ///- iOS - ///- MacOS + @override Future resumeTimers() async { Map args = {}; await channel?.invokeMethod('resumeTimers', args); } - ///Prints the current page. - /// - ///To obtain the [AndroidPrintJobController], use [settings] argument with [PrintJobSettings.handledByClient] to `true`. - ///Otherwise this method will return `null` and the [AndroidPrintJobController] will be handled and disposed automatically by the system. - /// - ///**NOTE for Android**: available on Android 19+. - /// - ///**NOTE for MacOS**: [AndroidPrintJobController] is available on MacOS 11.0+. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. Also, [AndroidPrintJobController] is always `null`. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintManager.print](https://developer.android.com/reference/android/print/PrintManager#print(java.lang.String,%20android.print.PrintDocumentAdapter,%20android.print.PrintAttributes))) - ///- iOS ([Official API - UIPrintInteractionController.present](https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/1618149-present)) - ///- MacOS (if 11.0+, [Official API - WKWebView.printOperation](https://developer.apple.com/documentation/webkit/wkwebview/3516861-printoperation), else [Official API - NSView.printView](https://developer.apple.com/documentation/appkit/nsview/1483705-printview)) - ///- Web ([Official API - Window.print](https://developer.mozilla.org/en-US/docs/Web/API/Window/print)) + @override Future printCurrentPage( {PrintJobSettings? settings}) async { Map args = {}; @@ -2604,17 +2150,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return null; } - ///Gets the height of the HTML content. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**NOTE for MacOS**: it is implemented using JavaScript. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.getContentHeight](https://developer.android.com/reference/android/webkit/WebView#getContentHeight())) - ///- iOS ([Official API - UIScrollView.contentSize](https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize)) - ///- MacOS - ///- Web ([Official API - Document.documentElement.scrollHeight](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight)) + @override Future getContentHeight() async { Map args = {}; var height = await channel?.invokeMethod('getContentHeight', args); @@ -2629,19 +2165,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return height; } - ///Gets the width of the HTML content. - /// - ///**NOTE for Android**: it is implemented using JavaScript. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**NOTE for MacOS**: it is implemented using JavaScript. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ([Official API - UIScrollView.contentSize](https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize)) - ///- MacOS - ///- Web ([Official API - Document.documentElement.scrollWidth](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth)) + @override Future getContentWidth() async { Map args = {}; var height = await channel?.invokeMethod('getContentWidth', args); @@ -2656,18 +2180,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return height; } - ///Performs a zoom operation in this WebView. - /// - ///[zoomFactor] represents the zoom factor to apply. On Android, the zoom factor will be clamped to the Webview's zoom limits and, also, this value must be in the range 0.01 (excluded) to 100.0 (included). - /// - ///[animated] `true` to animate the transition to the new scale, `false` to make the transition immediate. - ///**NOTE**: available only on iOS. - /// - ///**NOTE**: available on Android 21+. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.zoomBy](https://developer.android.com/reference/android/webkit/WebView#zoomBy(float))) - ///- iOS ([Official API - UIScrollView.setZoomScale](https://developer.apple.com/documentation/uikit/uiscrollview/1619412-setzoomscale)) + @override Future zoomBy( {required double zoomFactor, @Deprecated('Use animated instead') bool? iosAnimated, @@ -2681,64 +2194,32 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return await channel?.invokeMethod('zoomBy', args); } - ///Gets the URL that was originally requested for the current page. - ///This is not always the same as the URL passed to [InAppWebView.onLoadStart] because although the load for that URL has begun, - ///the current page may not have changed. Also, there may have been redirects resulting in a different URL to that originally requested. - /// - ///**NOTE for Web**: it will return the current value of the `iframe.src` attribute. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.getOriginalUrl](https://developer.android.com/reference/android/webkit/WebView#getOriginalUrl())) - ///- iOS - ///- MacOS - ///- Web + @override Future getOriginalUrl() async { Map args = {}; String? url = await channel?.invokeMethod('getOriginalUrl', args); return url != null ? WebUri(url) : null; } - ///Gets the current zoom scale of the WebView. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ([Official API - UIScrollView.zoomScale](https://developer.apple.com/documentation/uikit/uiscrollview/1619419-zoomscale)) + @override Future getZoomScale() async { Map args = {}; return await channel?.invokeMethod('getZoomScale', args); } - ///Use [getZoomScale] instead. + @override @Deprecated('Use getZoomScale instead') Future getScale() async { return await getZoomScale(); } - ///Gets the selected text. - /// - ///**NOTE**: this method is implemented with using JavaScript. - /// - ///**NOTE for Android native WebView**: available only on Android 19+. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web + @override Future getSelectedText() async { Map args = {}; return await channel?.invokeMethod('getSelectedText', args); } - ///Gets the hit result for hitting an HTML elements. - /// - ///**NOTE**: On iOS, it is implemented using JavaScript. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.getHitTestResult](https://developer.android.com/reference/android/webkit/WebView#getHitTestResult())) - ///- iOS + @override Future getHitTestResult() async { Map args = {}; Map? hitTestResultMap = @@ -2757,21 +2238,13 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return InAppWebViewHitTestResult(type: type, extra: extra); } - ///Clears the current focus. On iOS and Android native WebView, it will clear also, for example, the current text selection. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - ViewGroup.clearFocus](https://developer.android.com/reference/android/view/ViewGroup#clearFocus())) - ///- iOS ([Official API - UIResponder.resignFirstResponder](https://developer.apple.com/documentation/uikit/uiresponder/1621097-resignfirstresponder)) + @override Future clearFocus() async { Map args = {}; return await channel?.invokeMethod('clearFocus', args); } - ///Sets or updates the WebView context menu to be used next time it will appear. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS + @override Future setContextMenu(ContextMenu? contextMenu) async { Map args = {}; args.putIfAbsent("contextMenu", () => contextMenu?.toMap()); @@ -2779,13 +2252,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController _inAppBrowser?.setContextMenu(contextMenu); } - ///Requests the anchor or image element URL at the last tapped point. - /// - ///**NOTE**: On iOS, it is implemented using JavaScript. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.requestFocusNodeHref](https://developer.android.com/reference/android/webkit/WebView#requestFocusNodeHref(android.os.Message))) - ///- iOS + @override Future requestFocusNodeHref() async { Map args = {}; Map? result = @@ -2799,13 +2266,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController : null; } - ///Requests the URL of the image last touched by the user. - /// - ///**NOTE**: On iOS, it is implemented using JavaScript. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.requestImageRef](https://developer.android.com/reference/android/webkit/WebView#requestImageRef(android.os.Message))) - ///- iOS + @override Future requestImageRef() async { Map args = {}; Map? result = @@ -2817,17 +2278,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController : null; } - ///Returns the list of `` tags of the current WebView. - /// - ///**NOTE**: It is implemented using JavaScript. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web + @override Future> getMetaTags() async { List metaTags = []; @@ -2887,18 +2338,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return metaTags; } - ///Returns an instance of [Color] representing the `content` value of the - ///`` tag of the current WebView, if available, otherwise `null`. - /// - ///**NOTE**: on Android, Web, iOS < 15.0 and MacOS < 12.0, it is implemented using JavaScript. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ([Official API - WKWebView.themeColor](https://developer.apple.com/documentation/webkit/wkwebview/3794258-themecolor)) - ///- MacOS ([Official API - WKWebView.themeColor](https://developer.apple.com/documentation/webkit/wkwebview/3794258-themecolor)) - ///- Web + @override Future getMetaThemeColor() async { Color? themeColor; @@ -2935,44 +2375,19 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return themeColor; } - ///Returns the scrolled left position of the current WebView. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**NOTE for MacOS**: it is implemented using JavaScript. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - View.getScrollX](https://developer.android.com/reference/android/view/View#getScrollX())) - ///- iOS ([Official API - UIScrollView.contentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset)) - ///- MacOS - ///- Web ([Official API - Window.scrollX](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX)) + @override Future getScrollX() async { Map args = {}; return await channel?.invokeMethod('getScrollX', args); } - ///Returns the scrolled top position of the current WebView. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**NOTE for MacOS**: it is implemented using JavaScript. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - View.getScrollY](https://developer.android.com/reference/android/view/View#getScrollY())) - ///- iOS ([Official API - UIScrollView.contentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset)) - ///- MacOS - ///- Web ([Official API - Window.scrollY](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY)) + @override Future getScrollY() async { Map args = {}; return await channel?.invokeMethod('getScrollY', args); } - ///Gets the SSL certificate for the main top-level page or null if there is no certificate (the site is not secure). - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.getCertificate](https://developer.android.com/reference/android/webkit/WebView#getCertificate())) - ///- iOS - ///- MacOS + @override Future getCertificate() async { Map args = {}; Map? sslCertificateMap = @@ -2981,16 +2396,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return SslCertificate.fromMap(sslCertificateMap); } - ///Injects the specified [userScript] into the webpage’s content. - /// - ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. - ///There isn't any way to add/remove user scripts specific to window WebViews. - ///This is a limitation of the native WebKit APIs. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ([Official API - WKUserContentController.addUserScript](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript)) - ///- MacOS ([Official API - WKUserContentController.addUserScript](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript)) + @override Future addUserScript({required UserScript userScript}) async { assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); @@ -3003,16 +2409,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController } } - ///Injects the [userScripts] into the webpage’s content. - /// - ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. - ///There isn't any way to add/remove user scripts specific to window WebViews. - ///This is a limitation of the native WebKit APIs. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + @override Future addUserScripts({required List userScripts}) async { assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); @@ -3021,18 +2418,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController } } - ///Removes the specified [userScript] from the webpage’s content. - ///User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load. - ///Returns `true` if [userScript] was in the list, `false` otherwise. - /// - ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. - ///There isn't any way to add/remove user scripts specific to window WebViews. - ///This is a limitation of the native WebKit APIs. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + @override Future removeUserScript({required UserScript userScript}) async { assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); @@ -3050,17 +2436,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return true; } - ///Removes all the [UserScript]s with [groupName] as group name from the webpage’s content. - ///User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load. - /// - ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. - ///There isn't any way to add/remove user scripts specific to window WebViews. - ///This is a limitation of the native WebKit APIs. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + @override Future removeUserScriptsByGroupName({required String groupName}) async { assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); @@ -3085,17 +2461,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await channel?.invokeMethod('removeUserScriptsByGroupName', args); } - ///Removes the [userScripts] from the webpage’s content. - ///User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load. - /// - ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. - ///There isn't any way to add/remove user scripts specific to window WebViews. - ///This is a limitation of the native WebKit APIs. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + @override Future removeUserScripts( {required List userScripts}) async { assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); @@ -3105,16 +2471,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController } } - ///Removes all the user scripts from the webpage’s content. - /// - ///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set. - ///There isn't any way to add/remove user scripts specific to window WebViews. - ///This is a limitation of the native WebKit APIs. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ([Official API - WKUserContentController.removeAllUserScripts](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts)) - ///- MacOS ([Official API - WKUserContentController.removeAllUserScripts](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts)) + @override Future removeAllUserScripts() async { assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); @@ -3125,50 +2482,13 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await channel?.invokeMethod('removeAllUserScripts', args); } - ///Returns `true` if the [userScript] has been already added, otherwise `false`. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + @override bool hasUserScript({required UserScript userScript}) { return _userScripts[userScript.injectionTime]?.contains(userScript) ?? false; } - ///Executes the specified string as an asynchronous JavaScript function. - /// - ///[functionBody] is the JavaScript string to use as the function body. - ///This method treats the string as an anonymous JavaScript function body and calls it with the named arguments in the arguments parameter. - /// - ///[arguments] is a `Map` of the arguments to pass to the function call. - ///Each key in the `Map` corresponds to the name of an argument in the [functionBody] string, - ///and the value of that key is the value to use during the evaluation of the code. - ///Supported value types can be found in the official Flutter docs: - ///[Platform channel data types support and codecs](https://flutter.dev/docs/development/platform-integration/platform-channels#codec), - ///except for [Uint8List], [Int32List], [Int64List], and [Float64List] that should be converted into a [List]. - ///All items in a `List` or `Map` must also be one of the supported types. - /// - ///[contentWorld], on iOS, it represents the namespace in which to evaluate the JavaScript [source] code. - ///Instead, on Android, it will run the [source] code into an iframe. - ///This parameter doesn’t apply to changes you make to the underlying web content, such as the document’s DOM structure. - ///Those changes remain visible to all scripts, regardless of which content world you specify. - ///For more information about content worlds, see [ContentWorld]. - ///Available on iOS 14.3+. - /// - ///**NOTE**: This method shouldn't be called in the [WebView.onWebViewCreated] or [WebView.onLoadStart] events, - ///because, in these events, the [WebView] is not ready to handle it yet. - ///Instead, you should call this method, for example, inside the [WebView.onLoadStop] event or in any other events - ///where you know the page is ready "enough". - /// - ///**NOTE for iOS**: available only on iOS 10.3+. - /// - ///**NOTE for Android**: available only on Android 21+. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ([Official API - WKWebView.callAsyncJavaScript](https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript)) - ///- MacOS ([Official API - WKWebView.callAsyncJavaScript](https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript)) + @override Future callAsyncJavaScript( {required String functionBody, Map arguments = const {}, @@ -3188,24 +2508,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController value: data["value"], error: data["error"]); } - ///Saves the current WebView as a web archive. - ///Returns the file path under which the web archive file was saved, or `null` if saving the file failed. - /// - ///[filePath] represents the file path where the archive should be placed. This value cannot be `null`. - /// - ///[autoname] if `false`, takes [filePath] to be a file. - ///If `true`, [filePath] is assumed to be a directory in which a filename will be chosen according to the URL of the current page. - /// - ///**NOTE for iOS**: Available on iOS 14.0+. If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension. - /// - ///**NOTE for MacOS**: Available on MacOS 11.0+. If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension. - /// - ///**NOTE for Android**: if [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.MHT] file extension. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.saveWebArchive](https://developer.android.com/reference/android/webkit/WebView#saveWebArchive(java.lang.String,%20boolean,%20android.webkit.ValueCallback%3Cjava.lang.String%3E))) - ///- iOS - ///- MacOS + @override Future saveWebArchive( {required String filePath, bool autoname = false}) async { if (!autoname) { @@ -3223,40 +2526,13 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return await channel?.invokeMethod('saveWebArchive', args); } - ///Indicates whether the webpage context is capable of using features that require [secure contexts](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts). - ///This is implemented using Javascript (see [window.isSecureContext](https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext)). - /// - ///**NOTE for Android**: available Android 21.0+. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. Returns `false` otherwise. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web ([Official API - Window.isSecureContext](https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext)) + @override Future isSecureContext() async { Map args = {}; return await channel?.invokeMethod('isSecureContext', args) ?? false; } - ///Creates a message channel to communicate with JavaScript and returns the message channel with ports that represent the endpoints of this message channel. - ///The HTML5 message channel functionality is described [here](https://html.spec.whatwg.org/multipage/comms.html#messagechannel). - /// - ///The returned message channels are entangled and already in started state. - /// - ///This method should be called when the page is loaded, for example, when the [WebView.onLoadStop] is fired, otherwise the [AndroidWebMessageChannel] won't work. - /// - ///**NOTE for Android native WebView**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.CREATE_WEB_MESSAGE_CHANNEL]. - /// - ///**NOTE for iOS**: it is implemented using JavaScript. - /// - ///**NOTE for MacOS**: it is implemented using JavaScript. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewCompat.createWebMessageChannel](https://developer.android.com/reference/androidx/webkit/WebViewCompat#createWebMessageChannel(android.webkit.WebView))) - ///- iOS - ///- MacOS + @override Future createWebMessageChannel() async { Map args = {}; Map? result = @@ -3269,21 +2545,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return webMessageChannel; } - ///Post a message to main frame. The embedded application can restrict the messages to a certain target origin. - ///See [HTML5 spec](https://html.spec.whatwg.org/multipage/comms.html#posting-messages) for how target origin can be used. - /// - ///A target origin can be set as a wildcard ("*"). However this is not recommended. - /// - ///**NOTE for Android native WebView**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.POST_WEB_MESSAGE]. - /// - ///**NOTE for iOS**: it is implemented using JavaScript. - /// - ///**NOTE for MacOS**: it is implemented using JavaScript. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewCompat.postWebMessage](https://developer.android.com/reference/androidx/webkit/WebViewCompat#postWebMessage(android.webkit.WebView,%20androidx.webkit.WebMessageCompat,%20android.net.Uri))) - ///- iOS - ///- MacOS + @override Future postWebMessage( {required WebMessage message, WebUri? targetOrigin}) async { if (targetOrigin == null) { @@ -3295,170 +2557,6 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await channel?.invokeMethod('postWebMessage', args); } - ///Adds a [AndroidWebMessageListener] to the WebView and injects a JavaScript object into each frame that the [AndroidWebMessageListener] will listen on. - /// - ///The injected JavaScript object will be named [AndroidWebMessageListener.jsObjectName] in the global scope. - ///This will inject the JavaScript object in any frame whose origin matches [AndroidWebMessageListener.allowedOriginRules] - ///for every navigation after this call, and the JavaScript object will be available immediately when the page begins to load. - /// - ///Each [AndroidWebMessageListener.allowedOriginRules] entry must follow the format `SCHEME "://" [ HOSTNAME_PATTERN [ ":" PORT ] ]`, each part is explained in the below table: - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///
RuleDescriptionExample
http/https with hostnameSCHEME is http or https; HOSTNAME_PATTERN is a regular hostname; PORT is optional, when not present, the rule will match port 80 for http and port - /// 443 for https. - /// - ///
    - ///
  • https://foobar.com:8080 - Matches https:// URL on port 8080, whose normalized - /// host is foobar.com. - ///
  • - ///
  • https://www.example.com - Matches https:// URL on port 443, whose normalized host - /// is www.example.com. - ///
  • - ///
- ///
http/https with pattern matchingSCHEME is http or https; HOSTNAME_PATTERN is a sub-domain matching - /// pattern with a leading *.; PORT is optional, when not present, the rule will - /// match port 80 for http and port 443 for https. - /// - ///
    - ///
  • https://*.example.com - Matches https://calendar.example.com and - /// https://foo.bar.example.com but not https://example.com. - ///
  • - ///
  • https://*.example.com:8080 - Matches https://calendar.example.com:8080
  • - ///
- ///
http/https with IP literalSCHEME is https or https; HOSTNAME_PATTERN is IP literal; PORT is - /// optional, when not present, the rule will match port 80 for http and port 443 - /// for https. - /// - ///
    - ///
  • https://127.0.0.1 - Matches https:// URL on port 443, whose IPv4 address is - /// 127.0.0.1 - ///
  • - ///
  • https://[::1] or https://[0:0::1]- Matches any URL to the IPv6 loopback - /// address with port 443. - ///
  • - ///
  • https://[::1]:99 - Matches any https:// URL to the IPv6 loopback on port 99.
  • - ///
- ///
Custom schemeSCHEME is a custom scheme; HOSTNAME_PATTERN and PORT must not be - /// present. - /// - ///
    - ///
  • my-app-scheme:// - Matches any my-app-scheme:// URL.
  • - ///
- ///
*Wildcard rule, matches any origin. - ///
    - ///
  • *
  • - ///
- ///
- /// - ///Note that this is a powerful API, as the JavaScript object will be injected when the frame's origin matches any one of the allowed origins. - ///The HTTPS scheme is strongly recommended for security; allowing HTTP origins exposes the injected object to any potential network-based attackers. - ///If a wildcard "*" is provided, it will inject the JavaScript object to all frames. - ///A wildcard should only be used if the app wants **any** third party web page to be able to use the injected object. - ///When using a wildcard, the app must treat received messages as untrustworthy and validate any data carefully. - /// - ///This method can be called multiple times to inject multiple JavaScript objects. - /// - ///Let's say the injected JavaScript object is named `myObject`. We will have following methods on that object once it is available to use: - /// - ///```javascript - /// // Web page (in JavaScript) - /// // message needs to be a JavaScript String, MessagePorts is an optional parameter. - /// myObject.postMessage(message[, MessagePorts]) // on Android - /// myObject.postMessage(message) // on iOS - /// - /// // To receive messages posted from the app side, assign a function to the "onmessage" - /// // property. This function should accept a single "event" argument. "event" has a "data" - /// // property, which is the message string from the app side. - /// myObject.onmessage = function(event) { ... } - /// - /// // To be compatible with DOM EventTarget's addEventListener, it accepts type and listener - /// // parameters, where type can be only "message" type and listener can only be a JavaScript - /// // function for myObject. An event object will be passed to listener with a "data" property, - /// // which is the message string from the app side. - /// myObject.addEventListener(type, listener) - /// - /// // To be compatible with DOM EventTarget's removeEventListener, it accepts type and listener - /// // parameters, where type can be only "message" type and listener can only be a JavaScript - /// // function for myObject. - /// myObject.removeEventListener(type, listener) - ///``` - /// - ///We start the communication between JavaScript and the app from the JavaScript side. - ///In order to send message from the app to JavaScript, it needs to post a message from JavaScript first, - ///so the app will have a [AndroidJavaScriptReplyProxy] object to respond. Example: - /// - ///```javascript - /// // Web page (in JavaScript) - /// myObject.onmessage = function(event) { - /// // prints "Got it!" when we receive the app's response. - /// console.log(event.data); - /// } - /// myObject.postMessage("I'm ready!"); - ///``` - /// - ///```dart - /// // Flutter App - /// child: InAppWebView( - /// onWebViewCreated: (_controllerFromPlatform) async { - /// if (defaultTargetPlatform != TargetPlatform.android || await WebViewFeature.isFeatureSupported(WebViewFeature.WEB_MESSAGE_LISTENER)) { - /// await controller.addWebMessageListener(WebMessageListener( - /// jsObjectName: "myObject", - /// onPostMessage: (message, sourceOrigin, isMainFrame, replyProxy) { - /// // do something about message, sourceOrigin and isMainFrame. - /// replyProxy.postMessage("Got it!"); - /// }, - /// )); - /// } - /// await controller.loadUrl(urlRequest: URLRequest(url: WebUri("https://www.example.com"))); - /// }, - /// ), - ///``` - /// - ///**NOTE for Android**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.WEB_MESSAGE_LISTENER]. - /// - ///**NOTE for iOS**: it is implemented using JavaScript. - /// - ///**NOTE for MacOS**: it is implemented using JavaScript. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewCompat.WebMessageListener](https://developer.android.com/reference/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,%20java.lang.String,%20java.util.Set%3Cjava.lang.String%3E,%20androidx.webkit.WebViewCompat.WebMessageListener))) - ///- iOS - ///- MacOS @override Future addWebMessageListener( PlatformWebMessageListener webMessageListener) async { @@ -3476,12 +2574,6 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await channel?.invokeMethod('addWebMessageListener', args); } - ///Returns `true` if the [webMessageListener] has been already added, otherwise `false`. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS @override bool hasWebMessageListener(PlatformWebMessageListener webMessageListener) { return _webMessageListeners.contains(webMessageListener) || @@ -3489,17 +2581,6 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController .contains(webMessageListener.params.jsObjectName); } - ///Returns `true` if the webpage can scroll vertically, otherwise `false`. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**NOTE for MacOS**: it is implemented using JavaScript. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web @override Future canScrollVertically() async { Map args = {}; @@ -3507,17 +2588,6 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController false; } - ///Returns `true` if the webpage can scroll horizontally, otherwise `false`. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**NOTE for MacOS**: it is implemented using JavaScript. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web @override Future canScrollHorizontally() async { Map args = {}; @@ -3525,18 +2595,6 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController false; } - ///Starts Safe Browsing initialization. - /// - ///URL loads are not guaranteed to be protected by Safe Browsing until after the this method returns true. - ///Safe Browsing is not fully supported on all devices. For those devices this method will returns false. - /// - ///This should not be called if Safe Browsing has been disabled by manifest tag or [AndroidInAppWebViewOptions.safeBrowsingEnabled]. - ///This prepares resources used for Safe Browsing. - /// - ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.START_SAFE_BROWSING]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.startSafeBrowsing](https://developer.android.com/reference/android/webkit/WebView#startSafeBrowsing(android.content.Context,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) @override Future startSafeBrowsing() async { Map args = {}; @@ -3544,44 +2602,24 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController false; } - ///Clears the SSL preferences table stored in response to proceeding with SSL certificate errors. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.clearSslPreferences](https://developer.android.com/reference/android/webkit/WebView#clearSslPreferences())) @override Future clearSslPreferences() async { Map args = {}; await channel?.invokeMethod('clearSslPreferences', args); } - ///Does a best-effort attempt to pause any processing that can be paused safely, such as animations and geolocation. Note that this call does not pause JavaScript. - ///To pause JavaScript globally, use [InAppWebViewController.pauseTimers]. To resume WebView, call [resume]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.onPause](https://developer.android.com/reference/android/webkit/WebView#onPause())) @override Future pause() async { Map args = {}; await channel?.invokeMethod('pause', args); } - ///Resumes a WebView after a previous call to [pause]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.onResume](https://developer.android.com/reference/android/webkit/WebView#onResume())) @override Future resume() async { Map args = {}; await channel?.invokeMethod('resume', args); } - ///Scrolls the contents of this WebView down by half the page size. - ///Returns `true` if the page was scrolled. - /// - ///[bottom] `true` to jump to bottom of page. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.pageDown](https://developer.android.com/reference/android/webkit/WebView#pageDown(boolean))) @override Future pageDown({required bool bottom}) async { Map args = {}; @@ -3589,13 +2627,6 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return await channel?.invokeMethod('pageDown', args) ?? false; } - ///Scrolls the contents of this WebView up by half the view size. - ///Returns `true` if the page was scrolled. - /// - ///[top] `true` to jump to the top of the page. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.pageUp](https://developer.android.com/reference/android/webkit/WebView#pageUp(boolean))) @override Future pageUp({required bool top}) async { Map args = {}; @@ -3603,58 +2634,31 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return await channel?.invokeMethod('pageUp', args) ?? false; } - ///Performs zoom in in this WebView. - ///Returns `true` if zoom in succeeds, `false` if no zoom changes. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.zoomIn](https://developer.android.com/reference/android/webkit/WebView#zoomIn())) @override Future zoomIn() async { Map args = {}; return await channel?.invokeMethod('zoomIn', args) ?? false; } - ///Performs zoom out in this WebView. - ///Returns `true` if zoom out succeeds, `false` if no zoom changes. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.zoomOut](https://developer.android.com/reference/android/webkit/WebView#zoomOut())) + @override Future zoomOut() async { Map args = {}; return await channel?.invokeMethod('zoomOut', args) ?? false; } - ///Clears the internal back/forward list. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.clearHistory](https://developer.android.com/reference/android/webkit/WebView#clearHistory())) + @override Future clearHistory() async { Map args = {}; return await channel?.invokeMethod('clearHistory', args); } - ///Reloads the current page, performing end-to-end revalidation using cache-validating conditionals if possible. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebView.reloadFromOrigin](https://developer.apple.com/documentation/webkit/wkwebview/1414956-reloadfromorigin)) - ///- MacOS ([Official API - WKWebView.reloadFromOrigin](https://developer.apple.com/documentation/webkit/wkwebview/1414956-reloadfromorigin)) + @override Future reloadFromOrigin() async { Map args = {}; await channel?.invokeMethod('reloadFromOrigin', args); } - ///Generates PDF data from the web view’s contents asynchronously. - ///Returns `null` if a problem occurred. - /// - ///[pdfConfiguration] represents the object that specifies the portion of the web view to capture as PDF data. - /// - ///**NOTE for iOS**: available only on iOS 14.0+. - /// - ///**NOTE for MacOS**: available only on MacOS 11.0+. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebView.createPdf](https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf)) - ///- MacOS ([Official API - WKWebView.createPdf](https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf)) + @override Future createPdf( {@Deprecated("Use pdfConfiguration instead") // ignore: deprecated_member_use_from_same_package @@ -3666,160 +2670,73 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return await channel?.invokeMethod('createPdf', args); } - ///Creates a web archive of the web view’s current contents asynchronously. - ///Returns `null` if a problem occurred. - /// - ///**NOTE for iOS**: available only on iOS 14.0+. - /// - ///**NOTE for MacOS**: available only on MacOS 11.0+. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebView.createWebArchiveData](https://developer.apple.com/documentation/webkit/wkwebview/3650491-createwebarchivedata)) - ///- MacOS ([Official API - WKWebView.createWebArchiveData](https://developer.apple.com/documentation/webkit/wkwebview/3650491-createwebarchivedata)) + @override Future createWebArchiveData() async { Map args = {}; return await channel?.invokeMethod('createWebArchiveData', args); } - ///A Boolean value indicating whether all resources on the page have been loaded over securely encrypted connections. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebView.hasOnlySecureContent](https://developer.apple.com/documentation/webkit/wkwebview/1415002-hasonlysecurecontent)) - ///- MacOS ([Official API - WKWebView.hasOnlySecureContent](https://developer.apple.com/documentation/webkit/wkwebview/1415002-hasonlysecurecontent)) + @override Future hasOnlySecureContent() async { Map args = {}; return await channel?.invokeMethod('hasOnlySecureContent', args) ?? false; } - ///Pauses playback of all media in the web view. - /// - ///**NOTE for iOS**: available on iOS 15.0+. - /// - ///**NOTE for MacOS**: available on MacOS 12.0+. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebView.pauseAllMediaPlayback](https://developer.apple.com/documentation/webkit/wkwebview/3752240-pauseallmediaplayback)). - ///- MacOS ([Official API - WKWebView.pauseAllMediaPlayback](https://developer.apple.com/documentation/webkit/wkwebview/3752240-pauseallmediaplayback)). + @override Future pauseAllMediaPlayback() async { Map args = {}; return await channel?.invokeMethod('pauseAllMediaPlayback', args); } - ///Changes whether the webpage is suspending playback of all media in the page. - ///Pass `true` to pause all media the web view is playing. Neither the user nor the webpage can resume playback until you call this method again with `false`. - /// - ///[suspended] represents a [bool] value that indicates whether the webpage should suspend media playback. - /// - ///**NOTE for iOS**: available on iOS 15.0+. - /// - ///**NOTE for MacOS**: available on MacOS 12.0+. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebView.setAllMediaPlaybackSuspended](https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended)). - ///- MacOS ([Official API - WKWebView.setAllMediaPlaybackSuspended](https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended)). + @override Future setAllMediaPlaybackSuspended({required bool suspended}) async { Map args = {}; args.putIfAbsent("suspended", () => suspended); return await channel?.invokeMethod('setAllMediaPlaybackSuspended', args); } - ///Closes all media the web view is presenting, including picture-in-picture video and fullscreen video. - /// - ///**NOTE for iOS**: available on iOS 14.5+. - /// - ///**NOTE for MacOS**: available on MacOS 11.3+. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebView.closeAllMediaPresentations](https://developer.apple.com/documentation/webkit/wkwebview/3752235-closeallmediapresentations)). - ///- MacOS ([Official API - WKWebView.closeAllMediaPresentations](https://developer.apple.com/documentation/webkit/wkwebview/3752235-closeallmediapresentations)). + @override Future closeAllMediaPresentations() async { Map args = {}; return await channel?.invokeMethod('closeAllMediaPresentations', args); } - ///Requests the playback status of media in the web view. - ///Returns a [MediaPlaybackState] that indicates whether the media in the web view is playing, paused, or suspended. - ///If there’s no media in the web view to play, this method provides [MediaPlaybackState.NONE]. - /// - ///**NOTE for iOS**: available on iOS 15.0+. - /// - ///**NOTE for MacOS**: available on MacOS 12.0+. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebView.requestMediaPlaybackState](https://developer.apple.com/documentation/webkit/wkwebview/3752241-requestmediaplaybackstate)). - ///- MacOS ([Official API - WKWebView.requestMediaPlaybackState](https://developer.apple.com/documentation/webkit/wkwebview/3752241-requestmediaplaybackstate)). + @override Future requestMediaPlaybackState() async { Map args = {}; return MediaPlaybackState.fromNativeValue( await channel?.invokeMethod('requestMediaPlaybackState', args)); } - ///Returns `true` if the [WebView] is in fullscreen mode, otherwise `false`. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + @override Future isInFullscreen() async { Map args = {}; return await channel?.invokeMethod('isInFullscreen', args) ?? false; } - ///Returns a [MediaCaptureState] that indicates whether the webpage is using the camera to capture images or video. - /// - ///**NOTE for iOS**: available on iOS 15.0+. - /// - ///**NOTE for MacOS**: available on MacOS 12.0+. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebView.cameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763093-cameracapturestate)). - ///- MacOS ([Official API - WKWebView.cameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763093-cameracapturestate)). + @override Future getCameraCaptureState() async { Map args = {}; return MediaCaptureState.fromNativeValue( await channel?.invokeMethod('getCameraCaptureState', args)); } - ///Changes whether the webpage is using the camera to capture images or video. - /// - ///**NOTE for iOS**: available on iOS 15.0+. - /// - ///**NOTE for MacOS**: available on MacOS 12.0+. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebView.setCameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763097-setcameracapturestate)). - ///- MacOS ([Official API - WKWebView.setCameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763097-setcameracapturestate)). + @override Future setCameraCaptureState({required MediaCaptureState state}) async { Map args = {}; args.putIfAbsent('state', () => state.toNativeValue()); await channel?.invokeMethod('setCameraCaptureState', args); } - ///Returns a [MediaCaptureState] that indicates whether the webpage is using the microphone to capture audio. - /// - ///**NOTE for iOS**: available on iOS 15.0+. - /// - ///**NOTE for MacOS**: available on MacOS 12.0+. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebView.microphoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763096-microphonecapturestate)). - ///- MacOS ([Official API - WKWebView.microphoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763096-microphonecapturestate)). + @override Future getMicrophoneCaptureState() async { Map args = {}; return MediaCaptureState.fromNativeValue( await channel?.invokeMethod('getMicrophoneCaptureState', args)); } - ///Changes whether the webpage is using the microphone to capture audio. - /// - ///**NOTE for iOS**: available on iOS 15.0+. - /// - ///**NOTE for MacOS**: available on MacOS 12.0+. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebView.setMicrophoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763098-setmicrophonecapturestate)). - ///- MacOS ([Official API - WKWebView.setMicrophoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763098-setmicrophonecapturestate)). + @override Future setMicrophoneCaptureState( {required MediaCaptureState state}) async { Map args = {}; @@ -3827,31 +2744,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await channel?.invokeMethod('setMicrophoneCaptureState', args); } - ///Loads the web content from the data you provide as if the data were the response to the request. - ///If [urlResponse] is `null`, it loads the web content from the data as an utf8 encoded HTML string as the response to the request. - /// - ///[urlRequest] represents a URL request that specifies the base URL and other loading details the system uses to interpret the data you provide. - /// - ///[urlResponse] represents a response the system uses to interpret the data you provide. - /// - ///[data] represents the data or the utf8 encoded HTML string to use as the contents of the webpage. - /// - ///Example: - ///```dart - ///controller.loadSimulateloadSimulatedRequestdRequest(urlRequest: URLRequest( - /// url: WebUri("https://flutter.dev"), - /// ), - /// data: Uint8List.fromList(utf8.encode("

Hello

")) - ///); - ///``` - /// - ///**NOTE for iOS**: available on iOS 15.0+. - /// - ///**NOTE for MacOS**: available on MacOS 12.0+. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebView.loadSimulatedRequest(_:response:responseData:)](https://developer.apple.com/documentation/webkit/wkwebview/3763094-loadsimulatedrequest) and [Official API - WKWebView.loadSimulatedRequest(_:responseHTML:)](https://developer.apple.com/documentation/webkit/wkwebview/3763095-loadsimulatedrequest)). - ///- MacOS ([Official API - WKWebView.loadSimulatedRequest(_:response:responseData:)](https://developer.apple.com/documentation/webkit/wkwebview/3763094-loadsimulatedrequest) and [Official API - WKWebView.loadSimulatedRequest(_:responseHTML:)](https://developer.apple.com/documentation/webkit/wkwebview/3763095-loadsimulatedrequest)). + @override Future loadSimulatedRequest( {required URLRequest urlRequest, required Uint8List data, @@ -3863,21 +2756,13 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await channel?.invokeMethod('loadSimulatedRequest', args); } - ///Returns the iframe `id` attribute used on the Web platform. - /// - ///**Supported Platforms/Implementations**: - ///- Web + @override Future getIFrameId() async { Map args = {}; return await channel?.invokeMethod('getIFrameId', args); } - ///Gets the default user agent. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebSettings.getDefaultUserAgent](https://developer.android.com/reference/android/webkit/WebSettings#getDefaultUserAgent(android.content.Context))) - ///- iOS - ///- MacOS + @override Future getDefaultUserAgent() async { Map args = {}; return await _staticChannel.invokeMethod( @@ -3885,27 +2770,13 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController ''; } - ///Clears the client certificate preferences stored in response to proceeding/cancelling client cert requests. - ///Note that WebView automatically clears these preferences when the system keychain is updated. - ///The preferences are shared by all the WebViews that are created by the embedder application. - /// - ///**NOTE**: On iOS certificate-based credentials are never stored permanently. - /// - ///**NOTE**: available on Android 21+. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.clearClientCertPreferences](https://developer.android.com/reference/android/webkit/WebView#clearClientCertPreferences(java.lang.Runnable))) + @override Future clearClientCertPreferences() async { Map args = {}; await _staticChannel.invokeMethod('clearClientCertPreferences', args); } - ///Returns a URL pointing to the privacy policy for Safe Browsing reporting. - /// - ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SAFE_BROWSING_PRIVACY_POLICY_URL]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewCompat.getSafeBrowsingPrivacyPolicyUrl](https://developer.android.com/reference/androidx/webkit/WebViewCompat#getSafeBrowsingPrivacyPolicyUrl())) + @override Future getSafeBrowsingPrivacyPolicyUrl() async { Map args = {}; String? url = await _staticChannel.invokeMethod( @@ -3913,30 +2784,13 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return url != null ? WebUri(url) : null; } - ///Use [setSafeBrowsingAllowlist] instead. + @override @Deprecated("Use setSafeBrowsingAllowlist instead") Future setSafeBrowsingWhitelist({required List hosts}) async { return await setSafeBrowsingAllowlist(hosts: hosts); } - ///Sets the list of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks. The list is global for all the WebViews. - /// - /// Each rule should take one of these: - ///| Rule | Example | Matches Subdomain | - ///| -- | -- | -- | - ///| HOSTNAME | example.com | Yes | - ///| .HOSTNAME | .example.com | No | - ///| IPV4_LITERAL | 192.168.1.1 | No | - ///| IPV6_LITERAL_WITH_BRACKETS | [10:20:30:40:50:60:70:80] | No | - /// - ///All other rules, including wildcards, are invalid. The correct syntax for hosts is defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3.2.2). - /// - ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SAFE_BROWSING_ALLOWLIST]. - /// - ///[hosts] represents the list of hosts. This value must never be `null`. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewCompat.setSafeBrowsingAllowlist](https://developer.android.com/reference/androidx/webkit/WebViewCompat#setSafeBrowsingAllowlist(java.util.Set%3Cjava.lang.String%3E,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) + @override Future setSafeBrowsingAllowlist({required List hosts}) async { Map args = {}; args.putIfAbsent('hosts', () => hosts); @@ -3945,18 +2799,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController false; } - ///If WebView has already been loaded into the current process this method will return the package that was used to load it. - ///Otherwise, the package that would be used if the WebView was loaded right now will be returned; - ///this does not cause WebView to be loaded, so this information may become outdated at any time. - ///The WebView package changes either when the current WebView package is updated, disabled, or uninstalled. - ///It can also be changed through a Developer Setting. If the WebView package changes, any app process that - ///has loaded WebView will be killed. - ///The next time the app starts and loads WebView it will use the new WebView package instead. - /// - ///**NOTE**: available only on Android 21+. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewCompat.getCurrentWebViewPackage](https://developer.android.com/reference/androidx/webkit/WebViewCompat#getCurrentWebViewPackage(android.content.Context))) + @override Future getCurrentWebViewPackage() async { Map args = {}; Map? packageInfo = @@ -3965,16 +2808,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return WebViewPackageInfo.fromMap(packageInfo); } - ///Enables debugging of web contents (HTML / CSS / JavaScript) loaded into any WebViews of this application. - ///This flag can be enabled in order to facilitate debugging of web layouts and JavaScript code running inside WebViews. - ///Please refer to WebView documentation for the debugging guide. The default is `false`. - /// - ///[debuggingEnabled] whether to enable web contents debugging. - /// - ///**NOTE**: available only on Android 19+. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.setWebContentsDebuggingEnabled](https://developer.android.com/reference/android/webkit/WebView#setWebContentsDebuggingEnabled(boolean))) + @override Future setWebContentsDebuggingEnabled(bool debuggingEnabled) async { Map args = {}; args.putIfAbsent('debuggingEnabled', () => debuggingEnabled); @@ -3982,37 +2816,14 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController 'setWebContentsDebuggingEnabled', args); } - ///Gets the WebView variations encoded to be used as the X-Client-Data HTTP header. - /// - ///The app is responsible for adding the X-Client-Data header to any request - ///that may use variations metadata, such as requests to Google web properties. - ///The returned string will be a base64 encoded ClientVariations proto: - ///https://source.chromium.org/chromium/chromium/src/+/main:components/variations/proto/client_variations.proto - /// - ///The string may be empty if the header is not available. - /// - ///**NOTE for Android native WebView**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.GET_VARIATIONS_HEADER]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewCompat.getVariationsHeader](https://developer.android.com/reference/androidx/webkit/WebViewCompat#getVariationsHeader())) + @override Future getVariationsHeader() async { Map args = {}; return await _staticChannel.invokeMethod( 'getVariationsHeader', args); } - ///Returns `true` if WebView is running in multi process mode. - /// - ///In Android O and above, WebView may run in "multiprocess" mode. - ///In multiprocess mode, rendering of web content is performed by a sandboxed - ///renderer process separate to the application process. - ///This renderer process may be shared with other WebViews in the application, - ///but is not shared with other application processes. - /// - ///**NOTE for Android native WebView**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.MULTI_PROCESS]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewCompat.isMultiProcessEnabled](https://developer.android.com/reference/androidx/webkit/WebViewCompat#isMultiProcessEnabled())) + @override Future isMultiProcessEnabled() async { Map args = {}; return await _staticChannel.invokeMethod( @@ -4020,47 +2831,20 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController false; } - ///Indicate that the current process does not intend to use WebView, - ///and that an exception should be thrown if a WebView is created or any other - ///methods in the `android.webkit` package are used. - /// - ///Applications with multiple processes may wish to call this in processes that - ///are not intended to use WebView to avoid accidentally incurring the memory usage - ///of initializing WebView in long-lived processes that have no need for it, - ///and to prevent potential data directory conflicts (see [ProcessGlobalConfigSettings.dataDirectorySuffix]). - /// - ///**NOTE for Android**: available only on Android 28+. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.disableWebView](https://developer.android.com/reference/android/webkit/WebView.html#disableWebView())) + @override Future disableWebView() async { Map args = {}; await _staticChannel.invokeMethod('disableWebView', args); } - ///Returns a Boolean value that indicates whether WebKit natively supports resources with the specified URL scheme. - /// - ///[urlScheme] represents the URL scheme associated with the resource. - /// - ///**NOTE for iOS**: available only on iOS 11.0+. - /// - ///**NOTE for MacOS**: available only on MacOS 10.13+. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebView.handlesURLScheme](https://developer.apple.com/documentation/webkit/wkwebview/2875370-handlesurlscheme)) - ///- MacOS ([Official API - WKWebView.handlesURLScheme](https://developer.apple.com/documentation/webkit/wkwebview/2875370-handlesurlscheme)) + @override Future handlesURLScheme(String urlScheme) async { Map args = {}; args.putIfAbsent('urlScheme', () => urlScheme); return await _staticChannel.invokeMethod('handlesURLScheme', args); } - ///Disposes the WebView that is using the [keepAlive] instance - ///for the keep alive feature. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS + @override Future disposeKeepAlive(InAppWebViewKeepAlive keepAlive) async { Map args = {}; args.putIfAbsent('keepAliveId', () => keepAlive.id); @@ -4068,30 +2852,19 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController _keepAliveMap[keepAlive] = null; } - ///Gets the html (with javascript) of the Chromium's t-rex runner game. Used in combination with [tRexRunnerCss]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + @override Future get tRexRunnerHtml async => await rootBundle.loadString( 'packages/flutter_inappwebview/assets/t_rex_runner/t-rex.html'); - ///Gets the css of the Chromium's t-rex runner game. Used in combination with [tRexRunnerHtml]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + @override Future get tRexRunnerCss async => await rootBundle.loadString( 'packages/flutter_inappwebview/assets/t_rex_runner/t-rex.css'); - ///View ID used internally. + @override dynamic getViewId() { return id; } - ///Disposes the controller. @override void dispose({bool isKeepAlive = false}) { disposeChannel(removeMethodCallHandler: !isKeepAlive); 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 64a904df..692c847c 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 @@ -24,12 +24,7 @@ class AndroidPrintJobControllerCreationParams } } -///Class representing a print job eventually returned by [InAppWebViewController.printCurrentPage]. -/// -///**Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- MacOS +///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController} class AndroidPrintJobController extends PlatformPrintJobController with ChannelController { /// Constructs a [AndroidPrintJobController]. @@ -60,51 +55,26 @@ class AndroidPrintJobController extends PlatformPrintJobController } } - ///Cancels this print job. - ///You can request cancellation of a queued, started, blocked, or failed print job. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJob.cancel](https://developer.android.com/reference/android/print/PrintJob#cancel())) + @override Future cancel() async { Map args = {}; await channel?.invokeMethod('cancel', args); } - ///Restarts this print job. - ///You can request restart of a failed print job. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJob.restart](https://developer.android.com/reference/android/print/PrintJob#restart())) + @override Future restart() async { Map args = {}; await channel?.invokeMethod('restart', args); } - ///Dismisses the printing-options sheet or popover. - /// - ///You should dismiss the printing options when they are presented in a sheet or - ///animated from a rectangle and the user changes the orientation of the device. - ///(This, of course, assumes your application responds to orientation changes.) - ///You should then present the printing options again once the new orientation takes effect. - /// - ///**Supported Platforms/Implementations**: - ///- iOS + @override Future dismiss({bool animated: true}) async { Map args = {}; args.putIfAbsent("animated", () => animated); await channel?.invokeMethod('dismiss', args); } - ///Gets the [PrintJobInfo] that describes this job. - /// - ///**NOTE**: The returned info object is a snapshot of the - ///current print job state. Every call to this method returns a fresh - ///info object that reflects the current print job state. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJob.getInfo](https://developer.android.com/reference/android/print/PrintJob#getInfo())) - ///- iOS - ///- MacOS + @override Future getInfo() async { Map args = {}; Map? infoMap = @@ -112,12 +82,6 @@ class AndroidPrintJobController extends PlatformPrintJobController return PrintJobInfo.fromMap(infoMap); } - ///Disposes the print job. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS @override Future dispose() async { Map args = {}; diff --git a/flutter_inappwebview_android/lib/src/process_global_config.dart b/flutter_inappwebview_android/lib/src/process_global_config.dart index a8f843b3..1f4d6fe0 100644 --- a/flutter_inappwebview_android/lib/src/process_global_config.dart +++ b/flutter_inappwebview_android/lib/src/process_global_config.dart @@ -25,28 +25,7 @@ class AndroidProcessGlobalConfigCreationParams } } -///Process Global Configuration for [WebView]. -///WebView has some process-global configuration parameters -///that cannot be changed once WebView has been loaded. -///This class allows apps to set these parameters. -/// -///If it is used, the configuration should be set and apply should -///be called prior to loading WebView into the calling process. -///Most of the methods in `android.webkit` and `androidx.webkit` packages load WebView, -///so the configuration should be applied before calling any of these methods. -/// -///The following code configures the data directory suffix that WebView uses and -///then applies the configuration. WebView uses this configuration when it is loaded. -/// -///[apply] can only be called once. -/// -///Only a single thread should access this class at a given time. -/// -///The configuration should be set up as early as possible during application startup, -///to ensure that it happens before any other thread can call a method that loads [WebView]. -/// -///**Supported Platforms/Implementations**: -///- Android native WebView ([Official API - ProcessGlobalConfig](https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig)) +///{@macro flutter_inappwebview_platform_interface.PlatformProcessGlobalConfig} class AndroidProcessGlobalConfig extends PlatformProcessGlobalConfig with ChannelController { /// Creates a new [AndroidProcessGlobalConfig]. @@ -79,13 +58,7 @@ class AndroidProcessGlobalConfig extends PlatformProcessGlobalConfig Future _handleMethod(MethodCall call) async {} - ///Applies the configuration to be used by [WebView] on loading. - ///This method can only be called once. - /// - ///Calling this method will not cause [WebView] to be loaded and will not block the calling thread. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - ProcessGlobalConfig.apply](https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig#apply(androidx.webkit.ProcessGlobalConfig))) + @override Future apply({required ProcessGlobalConfigSettings settings}) async { Map args = {}; args.putIfAbsent("settings", () => settings.toMap()); diff --git a/flutter_inappwebview_android/lib/src/proxy_controller.dart b/flutter_inappwebview_android/lib/src/proxy_controller.dart index ad0d3518..07649ac8 100644 --- a/flutter_inappwebview_android/lib/src/proxy_controller.dart +++ b/flutter_inappwebview_android/lib/src/proxy_controller.dart @@ -25,16 +25,7 @@ class AndroidProxyControllerCreationParams } } -///Manages setting and clearing a process-specific override for the Android system-wide proxy settings that govern network requests made by [WebView]. -/// -///[WebView] may make network requests in order to fetch content that is not otherwise read from the file system or provided directly by application code. -///In this case by default the system-wide Android network proxy settings are used to redirect requests to appropriate proxy servers. -/// -///In the rare case that it is necessary for an application to explicitly specify its proxy configuration, -///this API may be used to explicitly specify the proxy rules that govern WebView initiated network requests. -/// -///**Supported Platforms/Implementations**: -///- Android native WebView ([Official API - ProxyController](https://developer.android.com/reference/androidx/webkit/ProxyController)) +///{@macro flutter_inappwebview_platform_interface.PlatformProxyController} class AndroidProxyController extends PlatformProxyController with ChannelController { /// Creates a new [AndroidProxyController]. @@ -66,24 +57,14 @@ class AndroidProxyController extends PlatformProxyController Future _handleMethod(MethodCall call) async {} - ///Sets [ProxySettings] which will be used by all [WebView]s in the app. - ///URLs that match patterns in the bypass list will not be directed to any proxy. - ///Instead, the request will be made directly to the origin specified by the URL. - ///Network connections are not guaranteed to immediately use the new proxy setting; wait for the method to return before loading a page. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - ProxyController.setProxyOverride](https://developer.android.com/reference/androidx/webkit/ProxyController#setProxyOverride(androidx.webkit.ProxyConfig,%20java.util.concurrent.Executor,%20java.lang.Runnable))) + @override Future setProxyOverride({required ProxySettings settings}) async { Map args = {}; args.putIfAbsent("settings", () => settings.toMap()); await channel?.invokeMethod('setProxyOverride', args); } - ///Clears the proxy settings. - ///Network connections are not guaranteed to immediately use the new proxy setting; wait for the method to return before loading a page. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - ProxyController.clearProxyOverride](https://developer.android.com/reference/androidx/webkit/ProxyController#clearProxyOverride(java.util.concurrent.Executor,%20java.lang.Runnable))) + @override Future clearProxyOverride() async { Map args = {}; await channel?.invokeMethod('clearProxyOverride', 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 c5062591..aa651ce9 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 @@ -26,17 +26,7 @@ class AndroidPullToRefreshControllerCreationParams } } -///A standard controller that can initiate the refreshing of a scroll view’s contents. -///This should be used whenever the user can refresh the contents of a WebView via a vertical swipe gesture. -/// -///All the methods should be called only when the WebView has been created or is already running -///(for example [WebView.onWebViewCreated] or [InAppBrowser.onBrowserCreated]). -/// -///**NOTE for Android**: to be able to use the "pull-to-refresh" feature, [InAppWebViewSettings.useHybridComposition] must be `true`. -/// -///**Supported Platforms/Implementations**: -///- Android native WebView -///- iOS +///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController} class AndroidPullToRefreshController extends PlatformPullToRefreshController with ChannelController { /// Constructs a [AndroidPullToRefreshController]. @@ -71,11 +61,6 @@ class AndroidPullToRefreshController extends PlatformPullToRefreshController return null; } - ///Sets whether the pull-to-refresh feature is enabled or not. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.setEnabled](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setEnabled(boolean))) - ///- iOS ([Official API - UIScrollView.refreshControl](https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol)) @override Future setEnabled(bool enabled) async { Map args = {}; @@ -83,11 +68,6 @@ class AndroidPullToRefreshController extends PlatformPullToRefreshController await channel?.invokeMethod('setEnabled', args); } - ///Returns `true` is pull-to-refresh feature is enabled, otherwise `false`. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - View.isEnabled](https://developer.android.com/reference/android/view/View#isEnabled())) - ///- iOS ([Official API - UIScrollView.refreshControl](https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol)) @override Future isEnabled() async { Map args = {}; @@ -100,51 +80,22 @@ class AndroidPullToRefreshController extends PlatformPullToRefreshController await channel?.invokeMethod('setRefreshing', args); } - ///Tells the controller that a refresh operation was started programmatically. - /// - ///Call this method when an external event source triggers a programmatic refresh of your scrolling view. - ///This method updates the state of the refresh control to reflect the in-progress refresh operation. - ///When the refresh operation ends, be sure to call the [endRefreshing] method to return the controller to its default state. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS @override Future beginRefreshing() async { return await _setRefreshing(true); } - ///Tells the controller that a refresh operation has ended. - /// - ///Call this method at the end of any refresh operation (whether it was initiated programmatically or by the user) - ///to return the refresh control to its default state. - ///If the refresh control is at least partially visible, calling this method also hides it. - ///If animations are also enabled, the control is hidden using an animation. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS @override Future endRefreshing() async { await _setRefreshing(false); } - ///Returns whether a refresh operation has been triggered and is in progress. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.isRefreshing](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#isRefreshing())) - ///- iOS ([Official API - UIRefreshControl.isRefreshing](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624844-isrefreshing)) @override Future isRefreshing() async { Map args = {}; return await channel?.invokeMethod('isRefreshing', args) ?? false; } - ///Sets the color of the refresh control. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.setColorSchemeColors](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setColorSchemeColors(int...))) - ///- iOS ([Official API - UIRefreshControl.tintColor](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624847-tintcolor)) @override Future setColor(Color color) async { Map args = {}; @@ -152,11 +103,6 @@ class AndroidPullToRefreshController extends PlatformPullToRefreshController await channel?.invokeMethod('setColor', args); } - ///Sets the background color of the refresh control. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.setProgressBackgroundColorSchemeColor](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setProgressBackgroundColorSchemeColor(int))) - ///- iOS ([Official API - UIView.backgroundColor](https://developer.apple.com/documentation/uikit/uiview/1622591-backgroundcolor)) @override Future setBackgroundColor(Color color) async { Map args = {}; @@ -164,10 +110,6 @@ class AndroidPullToRefreshController extends PlatformPullToRefreshController await channel?.invokeMethod('setBackgroundColor', args); } - ///Set the distance to trigger a sync in dips. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.setDistanceToTriggerSync](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setDistanceToTriggerSync(int))) @override Future setDistanceToTriggerSync(int distanceToTriggerSync) async { Map args = {}; @@ -175,10 +117,6 @@ class AndroidPullToRefreshController extends PlatformPullToRefreshController await channel?.invokeMethod('setDistanceToTriggerSync', args); } - ///Sets the distance that the refresh indicator can be pulled beyond its resting position during a swipe gesture. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.setSlingshotDistance](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setSlingshotDistance(int))) @override Future setSlingshotDistance(int slingshotDistance) async { Map args = {}; @@ -186,10 +124,6 @@ class AndroidPullToRefreshController extends PlatformPullToRefreshController await channel?.invokeMethod('setSlingshotDistance', args); } - ///Gets the default distance that the refresh indicator can be pulled beyond its resting position during a swipe gesture. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.DEFAULT_SLINGSHOT_DISTANCE](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#DEFAULT_SLINGSHOT_DISTANCE())) @override Future getDefaultSlingshotDistance() async { Map args = {}; @@ -198,7 +132,6 @@ class AndroidPullToRefreshController extends PlatformPullToRefreshController 0; } - ///Use [setIndicatorSize] instead. @Deprecated("Use setIndicatorSize instead") @override Future setSize(AndroidPullToRefreshSize size) async { @@ -207,10 +140,6 @@ class AndroidPullToRefreshController extends PlatformPullToRefreshController await channel?.invokeMethod('setSize', args); } - ///Sets the size of the refresh indicator. One of [PullToRefreshSize.DEFAULT], or [PullToRefreshSize.LARGE]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.setSize](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setSize(int))) @override Future setIndicatorSize(PullToRefreshSize size) async { Map args = {}; @@ -218,7 +147,6 @@ class AndroidPullToRefreshController extends PlatformPullToRefreshController await channel?.invokeMethod('setSize', args); } - ///Use [setStyledTitle] instead. @Deprecated("Use setStyledTitle instead") @override Future setAttributedTitle(IOSNSAttributedString attributedTitle) async { @@ -227,10 +155,6 @@ class AndroidPullToRefreshController extends PlatformPullToRefreshController await channel?.invokeMethod('setStyledTitle', args); } - ///Sets the styled title text to display in the refresh control. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - UIRefreshControl.attributedTitle](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624845-attributedtitle)) @override Future setStyledTitle(AttributedString attributedTitle) async { Map args = {}; @@ -238,7 +162,6 @@ class AndroidPullToRefreshController extends PlatformPullToRefreshController await channel?.invokeMethod('setStyledTitle', args); } - ///Disposes the controller. @override void dispose({bool isKeepAlive = false}) { disposeChannel(removeMethodCallHandler: !isKeepAlive); diff --git a/flutter_inappwebview_android/lib/src/service_worker_controller.dart b/flutter_inappwebview_android/lib/src/service_worker_controller.dart index 7c51306a..8a5a7919 100644 --- a/flutter_inappwebview_android/lib/src/service_worker_controller.dart +++ b/flutter_inappwebview_android/lib/src/service_worker_controller.dart @@ -25,12 +25,7 @@ class AndroidServiceWorkerControllerCreationParams } } -///Class that manages Service Workers used by [WebView]. -/// -///**NOTE**: available on Android 24+. -/// -///**Supported Platforms/Implementations**: -///- Android native WebView ([Official API - ServiceWorkerControllerCompat](https://developer.android.com/reference/androidx/webkit/ServiceWorkerControllerCompat)) +///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerController} class AndroidServiceWorkerController extends PlatformServiceWorkerController with ChannelController { /// Creates a new [AndroidServiceWorkerController]. @@ -68,13 +63,10 @@ class AndroidServiceWorkerController extends PlatformServiceWorkerController ServiceWorkerClient? _serviceWorkerClient; + @override ServiceWorkerClient? get serviceWorkerClient => _serviceWorkerClient; - ///Sets the client to capture service worker related callbacks. - ///A [ServiceWorkerClient] should be set before any service workers are active, e.g. a safe place is before any WebView instances are created or pages loaded. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - ServiceWorkerControllerCompat.setServiceWorkerClient](https://developer.android.com/reference/androidx/webkit/ServiceWorkerControllerCompat#setServiceWorkerClient(androidx.webkit.ServiceWorkerClientCompat))) + @override Future setServiceWorkerClient(ServiceWorkerClient? value) async { Map args = {}; args.putIfAbsent('isNull', () => value == null); @@ -106,96 +98,56 @@ class AndroidServiceWorkerController extends PlatformServiceWorkerController return null; } - ///Gets whether Service Workers support content URL access. - ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CONTENT_ACCESS]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowContentAccess() + @override Future getAllowContentAccess() async { Map args = {}; return await channel?.invokeMethod('getAllowContentAccess', args) ?? false; } - ///Gets whether Service Workers support file access. - ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_FILE_ACCESS]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowFileAccess() + @override Future getAllowFileAccess() async { Map args = {}; return await channel?.invokeMethod('getAllowFileAccess', args) ?? false; } - ///Gets whether Service Workers are prohibited from loading any resources from the network. - ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getBlockNetworkLoads() + @override Future getBlockNetworkLoads() async { Map args = {}; return await channel?.invokeMethod('getBlockNetworkLoads', args) ?? false; } - ///Gets the current setting for overriding the cache mode. - ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CACHE_MODE]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getCacheMode() + @override Future getCacheMode() async { Map args = {}; return CacheMode.fromNativeValue( await channel?.invokeMethod('getCacheMode', args)); } - ///Enables or disables content URL access from Service Workers. - ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CONTENT_ACCESS]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowContentAccess(boolean) + @override Future setAllowContentAccess(bool allow) async { Map args = {}; args.putIfAbsent("allow", () => allow); await channel?.invokeMethod('setAllowContentAccess', args); } - ///Enables or disables file access within Service Workers. - ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_FILE_ACCESS]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowFileAccess(boolean) + @override Future setAllowFileAccess(bool allow) async { Map args = {}; args.putIfAbsent("allow", () => allow); await channel?.invokeMethod('setAllowFileAccess', args); } - ///Sets whether Service Workers should not load resources from the network. - ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setBlockNetworkLoads(boolean) + @override Future setBlockNetworkLoads(bool flag) async { Map args = {}; args.putIfAbsent("flag", () => flag); await channel?.invokeMethod('setBlockNetworkLoads', args); } - ///Overrides the way the cache is used. - ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CACHE_MODE]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setCacheMode(int) + @override Future setCacheMode(CacheMode mode) async { Map args = {}; args.putIfAbsent("mode", () => mode.toNativeValue()); diff --git a/flutter_inappwebview_android/lib/src/tracing_controller.dart b/flutter_inappwebview_android/lib/src/tracing_controller.dart index 4eedc1d4..9d619f07 100644 --- a/flutter_inappwebview_android/lib/src/tracing_controller.dart +++ b/flutter_inappwebview_android/lib/src/tracing_controller.dart @@ -25,15 +25,7 @@ class AndroidTracingControllerCreationParams } } -///Manages tracing of [WebView]s. -///In particular provides functionality for the app to enable/disable tracing of parts of code and to collect tracing data. -///This is useful for profiling performance issues, debugging and memory usage analysis in production and real life scenarios. -/// -///The resulting trace data is sent back as a byte sequence in json format. -///This file can be loaded in "chrome://tracing" for further analysis. -/// -///**Supported Platforms/Implementations**: -///- Android native WebView ([Official API - TracingController](https://developer.android.com/reference/androidx/webkit/TracingController)) +///{@macro flutter_inappwebview_platform_interface.PlatformTracingController} class AndroidTracingController extends PlatformTracingController with ChannelController { /// Creates a new [AndroidTracingController]. @@ -65,39 +57,21 @@ class AndroidTracingController extends PlatformTracingController Future _handleMethod(MethodCall call) async {} - ///Starts tracing all [WebView]s. - ///Depending on the trace mode in trace config specifies how the trace events are recorded. - ///For tracing modes [TracingMode.RECORD_UNTIL_FULL] and [TracingMode.RECORD_CONTINUOUSLY] - ///the events are recorded using an internal buffer and flushed to the outputStream - ///when [stop] is called. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - TracingController.start](https://developer.android.com/reference/android/webkit/TracingController#start(android.webkit.TracingConfig))) + @override Future start({required TracingSettings settings}) async { Map args = {}; args.putIfAbsent("settings", () => settings.toMap()); await channel?.invokeMethod('start', args); } - ///Stops tracing and flushes tracing data to the specified output stream. - ///The data is sent to the specified output stream in json format typically in - ///chunks. - /// - ///Returns `false` if the WebView framework was not tracing at the time of the call, - ///`true` otherwise. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - TracingController.stop](https://developer.android.com/reference/android/webkit/TracingController#stop(java.io.OutputStream,%20java.util.concurrent.Executor))) + @override Future stop({String? filePath}) async { Map args = {}; args.putIfAbsent("filePath", () => filePath); return await channel?.invokeMethod('stop', args) ?? false; } - ///Returns whether the WebView framework is tracing. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - TracingController.isTracing](https://developer.android.com/reference/android/webkit/TracingController#isTracing())) + @override Future isTracing() async { Map args = {}; return await channel?.invokeMethod('isTracing', args) ?? false; diff --git a/flutter_inappwebview_android/lib/src/web_message/web_message_channel.dart b/flutter_inappwebview_android/lib/src/web_message/web_message_channel.dart index b04ce250..9af87309 100644 --- a/flutter_inappwebview_android/lib/src/web_message/web_message_channel.dart +++ b/flutter_inappwebview_android/lib/src/web_message/web_message_channel.dart @@ -30,12 +30,7 @@ class AndroidWebMessageChannelCreationParams } } -///The representation of the [HTML5 message channels](https://html.spec.whatwg.org/multipage/web-messaging.html#message-channels). -/// -///**Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- MacOS +///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannel} class AndroidWebMessageChannel extends PlatformWebMessageChannel with ChannelController { /// Constructs a [AndroidWebMessageChannel]. @@ -60,6 +55,7 @@ class AndroidWebMessageChannel extends PlatformWebMessageChannel port2: AndroidWebMessagePort( AndroidWebMessagePortCreationParams(index: 1)))); + /// Provide static access. factory AndroidWebMessageChannel.static() { return _staticValue; } @@ -108,7 +104,6 @@ class AndroidWebMessageChannel extends PlatformWebMessageChannel return _fromMap(map); } - ///Disposes the web message channel. @override void dispose() { disposeChannel(); diff --git a/flutter_inappwebview_android/lib/src/web_message/web_message_listener.dart b/flutter_inappwebview_android/lib/src/web_message/web_message_listener.dart index 2c9baa79..00307c9a 100644 --- a/flutter_inappwebview_android/lib/src/web_message/web_message_listener.dart +++ b/flutter_inappwebview_android/lib/src/web_message/web_message_listener.dart @@ -36,12 +36,7 @@ class AndroidWebMessageListenerCreationParams } } -///This listener receives messages sent on the JavaScript object which was injected by [InAppWebViewController.addWebMessageListener]. -/// -///**Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- MacOS +///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListener} class AndroidWebMessageListener extends PlatformWebMessageListener with ChannelController { /// Constructs a [AndroidWebMessageListener]. @@ -99,6 +94,7 @@ class AndroidWebMessageListener extends PlatformWebMessageListener disposeChannel(); } + @override Map toMap() { return { "id": _id, @@ -107,6 +103,7 @@ class AndroidWebMessageListener extends PlatformWebMessageListener }; } + @override Map toJson() { return this.toMap(); } @@ -139,11 +136,7 @@ class AndroidJavaScriptReplyProxyCreationParams } } -///This class represents the JavaScript object injected by [InAppWebViewController.addWebMessageListener]. -///An instance will be given by [AndroidWebMessageListener.onPostMessage]. -///The app can use `postMessage(String)` to talk to the JavaScript context. -/// -///There is a 1:1 relationship between this object and the JavaScript object in a frame. +///{@macro flutter_inappwebview_platform_interface.JavaScriptReplyProxy} class AndroidJavaScriptReplyProxy extends PlatformJavaScriptReplyProxy { /// Constructs a [AndroidWebMessageListener]. AndroidJavaScriptReplyProxy(PlatformJavaScriptReplyProxyCreationParams params) @@ -157,11 +150,7 @@ class AndroidJavaScriptReplyProxy extends PlatformJavaScriptReplyProxy { AndroidWebMessageListener get _androidWebMessageListener => params.webMessageListener as AndroidWebMessageListener; - ///Post a [message] to the injected JavaScript object which sent this [AndroidJavaScriptReplyProxy]. - /// - ///If [message] is of type [WebMessageType.ARRAY_BUFFER], be aware that large byte buffers can lead to out-of-memory crashes on low-end devices. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/JavaScriptReplyProxy#postMessage(java.lang.String) + @override Future postMessage(WebMessage message) async { Map args = {}; args.putIfAbsent('message', () => message.toMap()); diff --git a/flutter_inappwebview_android/lib/src/web_message/web_message_port.dart b/flutter_inappwebview_android/lib/src/web_message/web_message_port.dart index 8d66fdf9..f8979f5c 100644 --- a/flutter_inappwebview_android/lib/src/web_message/web_message_port.dart +++ b/flutter_inappwebview_android/lib/src/web_message/web_message_port.dart @@ -28,24 +28,7 @@ class AndroidWebMessagePortCreationParams } } -///The representation of the [HTML5 message ports](https://html.spec.whatwg.org/multipage/comms.html#messageport). -/// -///A Message port represents one endpoint of a Message Channel. In Android webview, there is no separate Message Channel object. -///When a message channel is created, both ports are tangled to each other and started. -///See [InAppWebViewController.createWebMessageChannel] for creating a message channel. -/// -///When a message port is first created or received via transfer, it does not have a [WebMessageCallback] to receive web messages. -///On Android, the messages are queued until a [WebMessageCallback] is set. -/// -///A message port should be closed when it is not used by the embedder application anymore. -///A closed port cannot be transferred or cannot be reopened to send messages. -///Close can be called multiple times. -/// -///When a port is transferred to JavaScript, it cannot be used to send or receive messages at the Dart side anymore. -///Different from HTML5 Spec, a port cannot be transferred if one of these has ever happened: i. a message callback was set, ii. a message was posted on it. -///A transferred port cannot be closed by the application, since the ownership is also transferred. -/// -///It is possible to transfer both ports of a channel to JavaScript, for example for communication between subframes. +///{@macro flutter_inappwebview_platform_interface.PlatformWebMessagePort} class AndroidWebMessagePort extends PlatformWebMessagePort { WebMessageCallback? _onMessage; late AndroidWebMessageChannel _webMessageChannel; @@ -59,7 +42,7 @@ class AndroidWebMessagePort extends PlatformWebMessagePort { .fromPlatformWebMessagePortCreationParams(params), ); - ///Sets a callback to receive message events on the main thread. + @override Future setWebMessageCallback(WebMessageCallback? onMessage) async { Map args = {}; args.putIfAbsent('index', () => params.index); @@ -68,7 +51,7 @@ class AndroidWebMessagePort extends PlatformWebMessagePort { this._onMessage = onMessage; } - ///Post a WebMessage to the entangled port. + @override Future postMessage(WebMessage message) async { Map args = {}; args.putIfAbsent('index', () => params.index); @@ -76,13 +59,14 @@ class AndroidWebMessagePort extends PlatformWebMessagePort { await _webMessageChannel.internalChannel?.invokeMethod('postMessage', args); } - ///Close the message port and free any resources associated with it. + @override Future close() async { Map args = {}; args.putIfAbsent('index', () => params.index); await _webMessageChannel.internalChannel?.invokeMethod('close', args); } + @override Map toMap() { return { "index": params.index, @@ -90,6 +74,7 @@ class AndroidWebMessagePort extends PlatformWebMessagePort { }; } + @override Map toJson() { return toMap(); } diff --git a/flutter_inappwebview_android/lib/src/web_storage/web_storage.dart b/flutter_inappwebview_android/lib/src/web_storage/web_storage.dart index fb068852..efafb429 100644 --- a/flutter_inappwebview_android/lib/src/web_storage/web_storage.dart +++ b/flutter_inappwebview_android/lib/src/web_storage/web_storage.dart @@ -25,14 +25,7 @@ class AndroidWebStorageCreationParams extends PlatformWebStorageCreationParams { } } -///Class that provides access to the JavaScript [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API): `window.sessionStorage` and `window.localStorage`. -///It used by [InAppWebViewController.webStorage]. -/// -///**Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- MacOS -///- Web +///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage} class AndroidWebStorage extends PlatformWebStorage { /// Constructs a [AndroidWebStorage]. AndroidWebStorage(PlatformWebStorageCreationParams params) @@ -43,11 +36,12 @@ class AndroidWebStorage extends PlatformWebStorage { .fromPlatformWebStorageCreationParams(params), ); + @override PlatformLocalStorage get localStorage => params.localStorage; + @override PlatformSessionStorage get sessionStorage => params.sessionStorage; - ///Disposes the web storage. @override void dispose() { localStorage.dispose(); @@ -73,8 +67,7 @@ class AndroidStorageCreationParams extends PlatformStorageCreationParams { } } -///Class that provides methods to manage the JavaScript [Storage](https://developer.mozilla.org/en-US/docs/Web/API/Storage) object. -///It is used by [AndroidLocalStorage] and [AndroidSessionStorage]. +///{@macro flutter_inappwebview_platform_interface.PlatformStorage} class AndroidStorage extends PlatformStorage { /// Constructs a [AndroidStorage]. AndroidStorage(PlatformStorageCreationParams params) @@ -87,14 +80,7 @@ class AndroidStorage extends PlatformStorage { AndroidInAppWebViewController? _controller; - ///Returns an integer representing the number of data items stored in the Storage object. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- Web + @override Future length() async { var result = await _controller?.evaluateJavascript(source: """ window.$webStorageType.length; @@ -102,14 +88,7 @@ class AndroidStorage extends PlatformStorage { return result != null ? int.parse(json.decode(result)) : null; } - ///When passed a [key] name and [value], will add that key to the storage, or update that key's value if it already exists. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- Web + @override Future setItem({required String key, required dynamic value}) async { var encodedValue = json.encode(value); await _controller?.evaluateJavascript(source: """ @@ -117,14 +96,7 @@ class AndroidStorage extends PlatformStorage { """); } - ///When passed a [key] name, will return that key's value, or `null` if the key does not exist, in the given Storage object. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- Web + @override Future getItem({required String key}) async { var itemValue = await _controller?.evaluateJavascript(source: """ window.$webStorageType.getItem("$key"); @@ -141,28 +113,14 @@ class AndroidStorage extends PlatformStorage { return itemValue; } - ///When passed a [key] name, will remove that key from the given Storage object if it exists. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- Web + @override Future removeItem({required String key}) async { await _controller?.evaluateJavascript(source: """ window.$webStorageType.removeItem("$key"); """); } - ///Returns the list of all items from the given Storage object. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- Web + @override Future> getItems() async { var webStorageItems = []; @@ -195,29 +153,14 @@ class AndroidStorage extends PlatformStorage { return webStorageItems; } - ///Clears all keys stored in a given Storage object. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- Web + @override Future clear() async { await _controller?.evaluateJavascript(source: """ window.$webStorageType.clear(); """); } - ///When passed a number [index], returns the name of the nth key in a given Storage object. - ///The order of keys is user-agent defined, so you should not rely on it. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- Web + @override Future key({required int index}) async { var result = await _controller?.evaluateJavascript(source: """ window.$webStorageType.key($index); @@ -225,7 +168,6 @@ class AndroidStorage extends PlatformStorage { return result != null ? json.decode(result) : null; } - ///Disposes the storage. @override void dispose() { _controller = null; @@ -251,8 +193,7 @@ class AndroidLocalStorageCreationParams } } -///Class that provides methods to manage the JavaScript `window.localStorage` object. -///It used by [AndroidWebStorage]. +///{@macro flutter_inappwebview_platform_interface.PlatformLocalStorage} class AndroidLocalStorage extends AndroidStorage implements PlatformLocalStorage { /// Constructs a [AndroidLocalStorage]. @@ -291,8 +232,7 @@ class AndroidSessionStorageCreationParams } } -///Class that provides methods to manage the JavaScript `window.sessionStorage` object. -///It used by [AndroidWebStorage]. +///{@macro flutter_inappwebview_platform_interface.PlatformSessionStorage} class AndroidSessionStorage extends AndroidStorage implements PlatformSessionStorage { /// Constructs a [AndroidSessionStorage]. 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 2b8b88d9..07a128dc 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 @@ -26,16 +26,7 @@ class AndroidWebStorageManagerCreationParams } } -///Class that implements a singleton object (shared instance) which manages the web storage used by WebView instances. -///On Android, it is implemented using [WebStorage](https://developer.android.com/reference/android/webkit/WebStorage.html). -///On iOS and MacOS, it is implemented using [WKWebsiteDataStore.default()](https://developer.apple.com/documentation/webkit/wkwebsitedatastore). -/// -///**NOTE for iOS**: available from iOS 9.0+. -/// -///**Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- MacOS +///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageManager} class AndroidWebStorageManager extends PlatformWebStorageManager with ChannelController { /// Creates a new [AndroidWebStorageManager]. @@ -67,10 +58,7 @@ class AndroidWebStorageManager extends PlatformWebStorageManager Future _handleMethod(MethodCall call) async {} - ///Gets the origins currently using either the Application Cache or Web SQL Database APIs. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebStorage.getOrigins](https://developer.android.com/reference/android/webkit/WebStorage#getOrigins(android.webkit.ValueCallback%3Cjava.util.Map%3E))) + @override Future> getOrigins() async { List originsList = []; @@ -90,57 +78,34 @@ class AndroidWebStorageManager extends PlatformWebStorageManager return originsList; } - ///Clears all storage currently being used by the JavaScript storage APIs. - ///This includes the Application Cache, Web SQL Database and the HTML5 Web Storage APIs. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebStorage.deleteAllData](https://developer.android.com/reference/android/webkit/WebStorage#deleteAllData())) + @override Future deleteAllData() async { Map args = {}; await channel?.invokeMethod('deleteAllData', args); } - ///Clears the storage currently being used by both the Application Cache and Web SQL Database APIs by the given [origin]. - ///The origin is specified using its string representation. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebStorage.deleteOrigin](https://developer.android.com/reference/android/webkit/WebStorage#deleteOrigin(java.lang.String))) + @override Future deleteOrigin({required String origin}) async { Map args = {}; args.putIfAbsent("origin", () => origin); await channel?.invokeMethod('deleteOrigin', args); } - ///Gets the storage quota for the Web SQL Database API for the given [origin]. - ///The quota is given in bytes and the origin is specified using its string representation. - ///Note that a quota is not enforced on a per-origin basis for the Application Cache API. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebStorage.getQuotaForOrigin](https://developer.android.com/reference/android/webkit/WebStorage#getQuotaForOrigin(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Long%3E))) + @override Future getQuotaForOrigin({required String origin}) async { Map args = {}; args.putIfAbsent("origin", () => origin); return await channel?.invokeMethod('getQuotaForOrigin', args) ?? 0; } - ///Gets the amount of storage currently being used by both the Application Cache and Web SQL Database APIs by the given [origin]. - ///The amount is given in bytes and the origin is specified using its string representation. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebStorage.getUsageForOrigin](https://developer.android.com/reference/android/webkit/WebStorage#getUsageForOrigin(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Long%3E))) + @override Future getUsageForOrigin({required String origin}) async { Map args = {}; args.putIfAbsent("origin", () => origin); return await channel?.invokeMethod('getUsageForOrigin', args) ?? 0; } - ///Fetches data records containing the given website data types. - /// - ///[dataTypes] represents the website data types to fetch records for. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebsiteDataStore.fetchDataRecords](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532932-fetchdatarecords)) - ///- MacOS ([Official API - WKWebsiteDataStore.fetchDataRecords](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532932-fetchdatarecords)) + @override Future> fetchDataRecords( {required Set dataTypes}) async { List recordList = []; @@ -169,15 +134,7 @@ class AndroidWebStorageManager extends PlatformWebStorageManager return recordList; } - ///Removes website data of the given types for the given data records. - /// - ///[dataTypes] represents the website data types that should be removed. - /// - ///[dataRecords] represents the website data records to delete website data for. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata)) - ///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata)) + @override Future removeDataFor( {required Set dataTypes, required List dataRecords}) async { @@ -197,15 +154,7 @@ class AndroidWebStorageManager extends PlatformWebStorageManager await channel?.invokeMethod('removeDataFor', args); } - ///Removes all website data of the given types that has been modified since the given date. - /// - ///[dataTypes] represents the website data types that should be removed. - /// - ///[date] represents a date. All website data modified after this date will be removed. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) - ///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) + @override Future removeDataModifiedSince( {required Set dataTypes, required DateTime date}) async { List dataTypesList = []; diff --git a/flutter_inappwebview_android/lib/src/webview_asset_loader.dart b/flutter_inappwebview_android/lib/src/webview_asset_loader.dart index cc754767..bb555364 100644 --- a/flutter_inappwebview_android/lib/src/webview_asset_loader.dart +++ b/flutter_inappwebview_android/lib/src/webview_asset_loader.dart @@ -24,9 +24,7 @@ class AndroidPathHandlerCreationParams } } -///A handler that produces responses for a registered path. -/// -///Implement this interface to handle other use-cases according to your app's needs. +///{@macro flutter_inappwebview_platform_interface.PlatformPathHandler} class AndroidPathHandler extends PlatformPathHandler with ChannelController { /// Creates a new [AndroidPathHandler]. AndroidPathHandler(PlatformPathHandlerCreationParams params) @@ -57,12 +55,12 @@ class AndroidPathHandler extends PlatformPathHandler with ChannelController { } } - ///Converts instance to a map. + @override Map toMap() { return {"path": path, "type": _type, "id": _id}; } - ///Converts instance to a map. + @override Map toJson() { return toMap(); } @@ -101,19 +99,7 @@ class AndroidAssetsPathHandlerCreationParams } } -///Handler class to open a file from assets directory in the application APK. -/// -///Opens the requested file from the application's assets directory. -/// -///The matched prefix path used shouldn't be a prefix of a real web path. -///Thus, if the requested file cannot be found a [WebResourceResponse] object with a `null` data will be returned instead of `null`. -///This saves the time of falling back to network and trying to resolve a path that doesn't exist. -///A [WebResourceResponse] with `null` data will be received as an HTTP response with status code `404` and no body. -/// -///The MIME type for the file will be determined from the file's extension using -///[guessContentTypeFromName](https://developer.android.com/reference/java/net/URLConnection.html#guessContentTypeFromName-java.lang.String-). -///Developers should ensure that asset files are named using standard file extensions. -///If the file does not have a recognised extension, `text/plain` will be used by default. +///{@macro flutter_inappwebview_platform_interface.PlatformAssetsPathHandler} class AndroidAssetsPathHandler extends AndroidPathHandler implements PlatformAssetsPathHandler { /// Constructs a [AndroidAssetsPathHandler]. @@ -148,19 +134,7 @@ class AndroidResourcesPathHandlerCreationParams } } -///Handler class to open a file from resources directory in the application APK. -/// -///Opens the requested file from application's resources directory. -/// -///The matched prefix path used shouldn't be a prefix of a real web path. -///Thus, if the requested file cannot be found a [WebResourceResponse] object with a `null` data will be returned instead of `null`. -///This saves the time of falling back to network and trying to resolve a path that doesn't exist. -///A [WebResourceResponse] with `null` data will be received as an HTTP response with status code `404` and no body. -/// -///The MIME type for the file will be determined from the file's extension using -///[guessContentTypeFromName](https://developer.android.com/reference/java/net/URLConnection.html#guessContentTypeFromName-java.lang.String-). -///Developers should ensure that asset files are named using standard file extensions. -///If the file does not have a recognised extension, `text/plain` will be used by default. +///{@macro flutter_inappwebview_platform_interface.PlatformResourcesPathHandler} class AndroidResourcesPathHandler extends AndroidPathHandler implements PlatformResourcesPathHandler { /// Constructs a [AndroidResourcesPathHandler]. @@ -195,24 +169,7 @@ class AndroidInternalStoragePathHandlerCreationParams } } -///Handler class to open files from application internal storage. -///For more information about android storage please refer to -///[Android Developers Docs: Data and file storage overview](https://developer.android.com/guide/topics/data/data-storage). -/// -///To avoid leaking user or app data to the web, make sure to choose [directory] carefully, -///and assume any file under this directory could be accessed by any web page subject to same-origin rules. -/// -///Opens the requested file from the exposed data directory. -/// -///The matched prefix path used shouldn't be a prefix of a real web path. -///Thus, if the requested file cannot be found a [WebResourceResponse] object with a `null` data will be returned instead of `null`. -///This saves the time of falling back to network and trying to resolve a path that doesn't exist. -///A [WebResourceResponse] with `null` data will be received as an HTTP response with status code `404` and no body. -/// -///The MIME type for the file will be determined from the file's extension using -///[guessContentTypeFromName](https://developer.android.com/reference/java/net/URLConnection.html#guessContentTypeFromName-java.lang.String-). -///Developers should ensure that asset files are named using standard file extensions. -///If the file does not have a recognised extension, `text/plain` will be used by default. +///{@macro flutter_inappwebview_platform_interface.PlatformInternalStoragePathHandler} class AndroidInternalStoragePathHandler extends AndroidPathHandler implements PlatformInternalStoragePathHandler { /// Constructs a [AndroidInternalStoragePathHandler]. diff --git a/flutter_inappwebview_android/lib/src/webview_feature.dart b/flutter_inappwebview_android/lib/src/webview_feature.dart index 7d2bbf3b..9b149510 100644 --- a/flutter_inappwebview_android/lib/src/webview_feature.dart +++ b/flutter_inappwebview_android/lib/src/webview_feature.dart @@ -25,10 +25,7 @@ class AndroidWebViewFeatureCreationParams } } -///Class that represents an Android-specific utility class for checking which WebView Support Library features are supported on the device. -/// -///**Supported Platforms/Implementations**: -///- Android native WebView +///{@macro flutter_inappwebview_platform_interface.PlatformWebViewFeature} class AndroidWebViewFeature extends PlatformWebViewFeature with ChannelController { /// Creates a new [AndroidWebViewFeature]. @@ -64,19 +61,7 @@ class AndroidWebViewFeature extends PlatformWebViewFeature Future _handleMethod(MethodCall call) async {} - ///Return whether a feature is supported at run-time. On devices running Android version `Build.VERSION_CODES.LOLLIPOP` and higher, - ///this will check whether a feature is supported, depending on the combination of the desired feature, the Android version of device, - ///and the WebView APK on the device. If running on a device with a lower API level, this will always return `false`. - /// - ///**Note**: This method is different from [isStartupFeatureSupported] and this - ///method only accepts certain features. - ///Please verify that the correct feature checking method is used for a particular feature. - /// - ///**Note**: If this method returns `false`, it is not safe to invoke the methods - ///requiring the desired feature. - ///Furthermore, if this method returns `false` for a particular feature, any callback guarded by that feature will not be invoked. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String) + @override Future isFeatureSupported(WebViewFeature feature) async { Map args = {}; args.putIfAbsent("feature", () => feature.toNativeValue()); @@ -84,21 +69,7 @@ class AndroidWebViewFeature extends PlatformWebViewFeature false; } - ///Return whether a startup feature is supported at run-time. - ///On devices running Android version `Build.VERSION_CODES.LOLLIPOP` and higher, - ///this will check whether a startup feature is supported, - ///depending on the combination of the desired feature, - ///the Android version of device, and the WebView APK on the device. - ///If running on a device with a lower API level, this will always return `false`. - /// - ///**Note**: This method is different from [isFeatureSupported] and this method only accepts startup features. - ///Please verify that the correct feature checking method is used for a particular feature. - /// - ///**Note**: If this method returns `false`, it is not safe to invoke the methods requiring the desired feature. - ///Furthermore, if this method returns `false` for a particular feature, - ///any callback guarded by that feature will not be invoked. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String) + @override Future isStartupFeatureSupported(WebViewFeature startupFeature) async { Map args = {}; args.putIfAbsent("startupFeature", () => startupFeature.toNativeValue()); diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart index 663b1435..ef981f4b 100644 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart @@ -10,7 +10,7 @@ part of 'chrome_safari_action_button.dart'; /// ///**NOTE for Android native WebView**: Not available in an Android Trusted Web Activity. /// -///**Supported Platforms/Implementations**: +///**Officially Supported Platforms/Implementations**: ///- Android native WebView class ChromeSafariBrowserActionButton { ///Use onClick instead. @@ -35,7 +35,7 @@ class ChromeSafariBrowserActionButton { /// ///**NOTE for Android native WebView**: Not available in an Android Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ChromeSafariBrowserActionButton( {required this.id, diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart index 7b524976..9bb9f017 100644 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart @@ -10,7 +10,7 @@ part of 'chrome_safari_browser_menu_item.dart'; /// ///**NOTE for Android native WebView**: Not available in an Android Trusted Web Activity. /// -///**Supported Platforms/Implementations**: +///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS class ChromeSafariBrowserMenuItem { @@ -33,7 +33,7 @@ class ChromeSafariBrowserMenuItem { /// ///**NOTE for Android native WebView**: Not available in an Android Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ChromeSafariBrowserMenuItem( diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart index a829e024..7b1a7a3e 100644 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart @@ -17,7 +17,7 @@ part of 'chrome_safari_browser_secondary_toolbar.dart'; /// ///**NOTE for Android native WebView**: Not available in an Android Trusted Web Activity. /// -///**Supported Platforms/Implementations**: +///**Officially Supported Platforms/Implementations**: ///- Android native WebView class ChromeSafariBrowserSecondaryToolbar { ///The IDs of clickable views. The `onClick` event of these views will be handled by custom tabs. @@ -29,7 +29,7 @@ class ChromeSafariBrowserSecondaryToolbar { /// ///**NOTE for Android native WebView**: Not available in an Android Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ChromeSafariBrowserSecondaryToolbar( {this.clickableIDs = const [], required this.layout}); @@ -74,7 +74,7 @@ class ChromeSafariBrowserSecondaryToolbar { /// ///**NOTE for Android native WebView**: Not available in an Android Trusted Web Activity. /// -///**Supported Platforms/Implementations**: +///**Officially Supported Platforms/Implementations**: ///- Android native WebView class ChromeSafariBrowserSecondaryToolbarClickableID { ///The android id resource @@ -86,7 +86,7 @@ class ChromeSafariBrowserSecondaryToolbarClickableID { /// ///**NOTE for Android native WebView**: Not available in an Android Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ChromeSafariBrowserSecondaryToolbarClickableID( {required this.id, this.onClick}); diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart index 6ba48813..b8d6610c 100755 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart @@ -62,7 +62,7 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { /// ///**NOTE**: Not available in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android CustomTabsShareState_? shareState; @@ -70,31 +70,31 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { /// ///**NOTE**: Not available in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? showTitle; ///Set the custom background color of the toolbar. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android Color_? toolbarBackgroundColor; ///Sets the navigation bar color. Has no effect on Android API versions below L. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android Color_? navigationBarColor; ///Sets the navigation bar divider color. Has no effect on Android API versions below P. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android Color_? navigationBarDividerColor; ///Sets the color of the secondary toolbar. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android Color_? secondaryToolbarColor; @@ -102,7 +102,7 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { /// ///**NOTE**: Not available in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? enableUrlBarHiding; @@ -110,7 +110,7 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { /// ///**NOTE**: Not available in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? instantAppsEnabled; @@ -120,31 +120,31 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { ///If non-null, the Intent can only match the components in the given ///application package. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android String? packageName; ///Set to `true` to enable Keep Alive. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? keepAliveEnabled; ///Set to `true` to launch the Android activity in `singleInstance` mode. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? isSingleInstance; ///Set to `true` to launch the Android intent with the flag `FLAG_ACTIVITY_NO_HISTORY`. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? noHistory; ///Set to `true` to launch the Custom Tab as a Trusted Web Activity. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? isTrustedWebActivity; @@ -152,7 +152,7 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { /// ///**NOTE**: Available only in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android List? additionalTrustedOrigins; @@ -160,7 +160,7 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { /// ///**NOTE**: Available only in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android @ExchangeableObjectProperty(deserializer: _deserializeDisplayMode) TrustedWebActivityDisplayMode_? displayMode; @@ -169,7 +169,7 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { /// ///**NOTE**: Available only in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android TrustedWebActivityScreenOrientation_? screenOrientation; @@ -177,7 +177,7 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { ///It must contain 2 [AndroidResource], where the first one represents the "enter" animation for the browser ///and the second one represents the "exit" animation for the application. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android List? startAnimations; @@ -185,7 +185,7 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { ///It must contain 2 [AndroidResource], where the first one represents the "enter" animation for the application ///and the second one represents the "exit" animation for the browser. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android List? exitAnimations; @@ -194,19 +194,19 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { ///Calling this with an intent will override any custom tabs related customizations. ///The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? alwaysUseBrowserUI; ///Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS bool? entersReaderIfAvailable; ///Set to `true` to enable bar collapsing. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS bool? barCollapsingEnabled; @@ -214,7 +214,7 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { /// ///**NOTE**: available on iOS 11.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS DismissButtonStyle_? dismissButtonStyle; @@ -222,7 +222,7 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { /// ///**NOTE**: available on iOS 10.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color_? preferredBarTintColor; @@ -230,19 +230,19 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { /// ///**NOTE**: available on iOS 10.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color_? preferredControlTintColor; ///Set the custom modal presentation style when presenting the WebView. The default value is [ModalPresentationStyle.FULL_SCREEN]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ModalPresentationStyle_? presentationStyle; ///Set to the custom transition style when presenting the WebView. The default value is [ModalTransitionStyle.COVER_VERTICAL]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ModalTransitionStyle_? transitionStyle; @@ -251,7 +251,7 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { /// ///**NOTE**: available on iOS 15.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ActivityButton_? activityButton; @@ -260,7 +260,7 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { /// ///**NOTE**: available on iOS 15.2+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS UIEventAttribution_? eventAttribution; diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart index 165d6b29..4ec95401 100644 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart @@ -13,7 +13,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { /// ///**NOTE**: available on iOS 15.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ActivityButton? activityButton; @@ -21,7 +21,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { /// ///**NOTE**: Available only in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android List? additionalTrustedOrigins; @@ -30,13 +30,13 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///Calling this with an intent will override any custom tabs related customizations. ///The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? alwaysUseBrowserUI; ///Set to `true` to enable bar collapsing. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS bool? barCollapsingEnabled; @@ -44,7 +44,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { /// ///**NOTE**: available on iOS 11.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS DismissButtonStyle? dismissButtonStyle; @@ -52,7 +52,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { /// ///**NOTE**: Available only in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android TrustedWebActivityDisplayMode? displayMode; @@ -60,13 +60,13 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { /// ///**NOTE**: Not available in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? enableUrlBarHiding; ///Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS bool? entersReaderIfAvailable; @@ -75,7 +75,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { /// ///**NOTE**: available on iOS 15.2+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS UIEventAttribution? eventAttribution; @@ -83,7 +83,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///It must contain 2 [AndroidResource], where the first one represents the "enter" animation for the application ///and the second one represents the "exit" animation for the browser. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android List? exitAnimations; @@ -91,43 +91,43 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { /// ///**NOTE**: Not available in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? instantAppsEnabled; ///Set to `true` to launch the Android activity in `singleInstance` mode. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? isSingleInstance; ///Set to `true` to launch the Custom Tab as a Trusted Web Activity. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? isTrustedWebActivity; ///Set to `true` to enable Keep Alive. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? keepAliveEnabled; ///Sets the navigation bar color. Has no effect on Android API versions below L. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android Color? navigationBarColor; ///Sets the navigation bar divider color. Has no effect on Android API versions below P. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android Color? navigationBarDividerColor; ///Set to `true` to launch the Android intent with the flag `FLAG_ACTIVITY_NO_HISTORY`. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? noHistory; @@ -137,7 +137,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///If non-null, the Intent can only match the components in the given ///application package. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android String? packageName; @@ -145,7 +145,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { /// ///**NOTE**: available on iOS 10.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color? preferredBarTintColor; @@ -153,13 +153,13 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { /// ///**NOTE**: available on iOS 10.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color? preferredControlTintColor; ///Set the custom modal presentation style when presenting the WebView. The default value is [ModalPresentationStyle.FULL_SCREEN]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ModalPresentationStyle? presentationStyle; @@ -167,13 +167,13 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { /// ///**NOTE**: Available only in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android TrustedWebActivityScreenOrientation? screenOrientation; ///Sets the color of the secondary toolbar. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android Color? secondaryToolbarColor; @@ -181,7 +181,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { /// ///**NOTE**: Not available in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android CustomTabsShareState? shareState; @@ -189,7 +189,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { /// ///**NOTE**: Not available in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android bool? showTitle; @@ -197,19 +197,19 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///It must contain 2 [AndroidResource], where the first one represents the "enter" animation for the browser ///and the second one represents the "exit" animation for the application. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android List? startAnimations; ///Set the custom background color of the toolbar. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android Color? toolbarBackgroundColor; ///Set to the custom transition style when presenting the WebView. The default value is [ModalTransitionStyle.COVER_VERTICAL]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ModalTransitionStyle? transitionStyle; ChromeSafariBrowserSettings( diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart index e0c09869..af26858d 100755 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart @@ -14,6 +14,12 @@ class PlatformChromeSafariBrowserCreationParams { const PlatformChromeSafariBrowserCreationParams(); } +///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser} +///Class that provides a visible standard interface for browsing the web. +///It presents a self-contained web interface inside your app. +/// +///If you need to customize or interact with the web content, use the `InAppWebView` widget. +/// ///This class uses native [Chrome Custom Tabs](https://developer.android.com/reference/android/support/customtabs/package-summary) on Android ///and [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) on iOS. /// @@ -21,9 +27,10 @@ class PlatformChromeSafariBrowserCreationParams { ///`android.support.customtabs.action.CustomTabsService` in your `AndroidManifest.xml` ///(you can read more about it here: https://developers.google.com/web/android/custom-tabs/best-practices#applications_targeting_android_11_api_level_30_or_above). /// -///**Supported Platforms/Implementations**: +///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS +///{@endtemplate} abstract class PlatformChromeSafariBrowser extends PlatformInterface implements Disposable { ///Debug settings. @@ -85,6 +92,7 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface /// The parameters used to initialize the [PlatformChromeSafariBrowser]. final PlatformChromeSafariBrowserCreationParams params; + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.open} ///Opens the [PlatformChromeSafariBrowser] instance with an [url]. /// ///[url] - The [url] to load. On iOS, the [url] is required and must use the `http` or `https` scheme. @@ -101,9 +109,10 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface /// ///[settings] - Settings for the [PlatformChromeSafariBrowser]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS + ///{@endtemplate} Future open( {WebUri? url, Map? headers, @@ -116,6 +125,7 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface throw UnimplementedError('open is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.launchUrl} ///Tells the browser to launch with [url]. /// ///[url] - initial url. @@ -128,8 +138,9 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface /// ///[referrer] - referrer header. Supported only on Android. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android + ///{@endtemplate} Future launchUrl({ required WebUri url, Map? headers, @@ -140,6 +151,7 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface 'launchUrl is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.mayLaunchUrl} ///Tells the browser of a likely future navigation to a URL. ///The most likely URL has to be specified first. ///Optionally, a list of other likely URLs can be provided. @@ -150,19 +162,21 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface /// ///[otherLikelyURLs] - Other likely destinations, sorted in decreasing likelihood order. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.mayLaunchUrl](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#mayLaunchUrl(android.net.Uri,android.os.Bundle,java.util.List%3Candroid.os.Bundle%3E))) + ///{@endtemplate} Future mayLaunchUrl({WebUri? url, List? otherLikelyURLs}) { throw UnimplementedError( 'mayLaunchUrl is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.validateRelationship} ///Requests to validate a relationship between the application and an origin. /// ///See [here](https://developers.google.com/digital-asset-links/v1/getting-started) for documentation about Digital Asset Links. ///This methods requests the browser to verify a relation with the calling application, to grant the associated rights. /// - ///If this method returns `true`, the validation result will be provided through [onRelationshipValidationResult]. + ///If this method returns `true`, the validation result will be provided through [PlatformChromeSafariBrowserEvents.onRelationshipValidationResult]. ///Otherwise the request didn't succeed. /// ///[relation] – Relation to check, must be one of the [CustomTabsRelationType] constants. @@ -171,95 +185,111 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface /// ///[extras] – Reserved for future use. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.validateRelationship](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#validateRelationship(int,android.net.Uri,android.os.Bundle))) + ///{@endtemplate} Future validateRelationship( {required CustomTabsRelationType relation, required WebUri origin}) { throw UnimplementedError( 'validateRelationship is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.close} ///Closes the [PlatformChromeSafariBrowser] instance. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS + ///{@endtemplate} Future close() { throw UnimplementedError( 'close is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.setActionButton} ///Set a custom action button. /// ///**NOTE**: Not available in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsIntent.Builder.setActionButton](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setActionButton(android.graphics.Bitmap,%20java.lang.String,%20android.app.PendingIntent,%20boolean))) + ///{@endtemplate} void setActionButton(ChromeSafariBrowserActionButton actionButton) { throw UnimplementedError( 'setActionButton is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.updateActionButton} ///Updates the [ChromeSafariBrowserActionButton.icon] and [ChromeSafariBrowserActionButton.description]. /// ///**NOTE**: Not available in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.setActionButton](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#setActionButton(android.graphics.Bitmap,java.lang.String))) + ///{@endtemplate} Future updateActionButton( {required Uint8List icon, required String description}) { throw UnimplementedError( 'updateActionButton is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.setSecondaryToolbar} ///Sets the remote views displayed in the secondary toolbar in a custom tab. /// ///**NOTE**: Not available in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsIntent.Builder.setSecondaryToolbarViews](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent))) + ///{@endtemplate} void setSecondaryToolbar( ChromeSafariBrowserSecondaryToolbar secondaryToolbar) { throw UnimplementedError( 'setSecondaryToolbar is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.updateSecondaryToolbar} ///Sets or updates (if already present) the Remote Views of the secondary toolbar in an existing custom tab session. /// ///**NOTE**: Not available in a Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.setSecondaryToolbarViews](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent))) + ///{@endtemplate} Future updateSecondaryToolbar( ChromeSafariBrowserSecondaryToolbar secondaryToolbar) { throw UnimplementedError( 'updateSecondaryToolbar is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.addMenuItem} ///Adds a [ChromeSafariBrowserMenuItem] to the menu. /// ///**NOTE**: Not available in an Android Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS + ///{@endtemplate} void addMenuItem(ChromeSafariBrowserMenuItem menuItem) { throw UnimplementedError( 'addMenuItem is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.addMenuItems} ///Adds a list of [ChromeSafariBrowserMenuItem] to the menu. /// ///**NOTE**: Not available in an Android Trusted Web Activity. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS + ///{@endtemplate} void addMenuItems(List menuItems) { throw UnimplementedError( 'addMenuItems is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.requestPostMessageChannel} ///Sends a request to create a two way postMessage channel between the client ///and the browser. ///If you want to specifying the target origin to communicate with, set the [targetOrigin]. @@ -275,74 +305,86 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///Note that returning true here doesn't mean an origin has already been ///assigned as the validation is asynchronous. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.requestPostMessageChannel](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#requestPostMessageChannel(android.net.Uri,android.net.Uri,android.os.Bundle))) + ///{@endtemplate} Future requestPostMessageChannel( {required WebUri sourceOrigin, WebUri? targetOrigin}) { throw UnimplementedError( 'requestPostMessageChannel is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.postMessage} ///Sends a postMessage request using the origin communicated via [requestPostMessageChannel]. - ///Fails when called before [onMessageChannelReady] event. + ///Fails when called before [PlatformChromeSafariBrowserEvents.onMessageChannelReady] event. /// ///[message] – The message that is being sent. /// ///Returns an integer constant about the postMessage request result. ///Will return CustomTabsService.RESULT_SUCCESS if successful. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.postMessage](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#postMessage(java.lang.String,android.os.Bundle))) + ///{@endtemplate} Future postMessage(String message) { throw UnimplementedError( 'postMessage is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isEngagementSignalsApiAvailable} ///Returns whether the Engagement Signals API is available. ///The availability of the Engagement Signals API may change at runtime. - ///If an EngagementSignalsCallback has been set, an [onSessionEnded] + ///If an EngagementSignalsCallback has been set, an [PlatformChromeSafariBrowserEvents.onSessionEnded] ///signal will be sent if the API becomes unavailable later. /// ///Returns whether the Engagement Signals API is available. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.isEngagementSignalsApiAvailable](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#isEngagementSignalsApiAvailable(android.os.Bundle))) + ///{@endtemplate} Future isEngagementSignalsApiAvailable() { throw UnimplementedError( 'isEngagementSignalsApiAvailable is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isOpened} ///Returns `true` if the [PlatformChromeSafariBrowser] instance is opened, otherwise `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS + ///{@endtemplate} bool isOpened() { throw UnimplementedError( 'isOpened is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isAvailable} ///On Android, returns `true` if Chrome Custom Tabs is available. ///On iOS, returns `true` if SFSafariViewController is available. ///Otherwise returns `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS + ///{@endtemplate} Future isAvailable() { throw UnimplementedError( 'isAvailable is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.getMaxToolbarItems} ///The maximum number of allowed secondary toolbar items. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android + ///{@endtemplate} Future getMaxToolbarItems() { throw UnimplementedError( 'getMaxToolbarItems is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.getPackageName} ///Returns the preferred package to use for Custom Tabs. ///The preferred package name is the default VIEW intent handler as long as it supports Custom Tabs. ///To modify this preferred behavior, set [ignoreDefault] to `true` and give a @@ -357,26 +399,30 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface /// ///Returns the preferred package name for handling Custom Tabs, or null. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsClient.getPackageName](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsClient#getPackageName(android.content.Context,java.util.List%3Cjava.lang.String%3E,boolean)))) + ///{@endtemplate} Future getPackageName( {List? packages, bool ignoreDefault = false}) { throw UnimplementedError( 'getPackageName is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.clearWebsiteData} ///Clear associated website data accrued from browsing activity within your app. ///This includes all local storage, cached resources, and cookies. /// ///**NOTE for iOS**: available on iOS 16.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - SFSafariViewController.DataStore.clearWebsiteData](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/datastore/3981117-clearwebsitedata)) + ///{@endtemplate} Future clearWebsiteData() { throw UnimplementedError( 'clearWebsiteData is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.prewarmConnections} ///Prewarms a connection to each URL. SFSafariViewController will automatically use a ///prewarmed connection if possible when loading its initial URL. /// @@ -395,25 +441,30 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface /// ///**NOTE for iOS**: available on iOS 15.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections)) + ///{@endtemplate} Future prewarmConnections(List URLs) { throw UnimplementedError( 'prewarmConnections is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.invalidatePrewarmingToken} ///Ends all prewarmed connections associated with the token, except for connections that are also kept alive by other tokens. /// ///**NOTE for iOS**: available on iOS 15.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections)) + ///{@endtemplate} Future invalidatePrewarmingToken(PrewarmingToken prewarmingToken) { throw UnimplementedError( 'invalidatePrewarmingToken is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.dispose} ///Disposes the channel. + ///{@endtemplate} @override void dispose() { throw UnimplementedError( @@ -422,87 +473,108 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface } abstract class PlatformChromeSafariBrowserEvents { + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onServiceConnected} ///Event fired when the when connecting from Android Custom Tabs Service. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android + ///{@endtemplate} void onServiceConnected() {} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onOpened} ///Event fired when the [PlatformChromeSafariBrowser] is opened. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS + ///{@endtemplate} void onOpened() {} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onCompletedInitialLoad} ///Event fired when the initial URL load is complete. /// ///[didLoadSuccessfully] - `true` if loading completed successfully; otherwise, `false`. Supported only on iOS. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS ([Official API - SFSafariViewControllerDelegate.safariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/1621215-safariviewcontroller)) + ///{@endtemplate} void onCompletedInitialLoad(bool? didLoadSuccessfully) {} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onInitialLoadDidRedirect} ///Event fired when the initial URL load is complete. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - SFSafariViewControllerDelegate.safariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/2923545-safariviewcontroller)) + ///{@endtemplate} void onInitialLoadDidRedirect(WebUri? url) {} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onNavigationEvent} ///Event fired when a navigation event happens. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsCallback.onNavigationEvent](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onNavigationEvent(int,android.os.Bundle))) + ///{@endtemplate} void onNavigationEvent(CustomTabsNavigationEventType? navigationEvent) {} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onRelationshipValidationResult} ///Event fired when a relationship validation result is available. /// - ///[relation] - Relation for which the result is available. Value previously passed to [validateRelationship]. + ///[relation] - Relation for which the result is available. Value previously passed to [PlatformChromeSafariBrowser.validateRelationship]. /// - ///[requestedOrigin] - Origin requested. Value previously passed to [validateRelationship]. + ///[requestedOrigin] - Origin requested. Value previously passed to [PlatformChromeSafariBrowser.validateRelationship]. /// ///[result] - Whether the relation was validated. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsCallback.onRelationshipValidationResult](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onRelationshipValidationResult(int,android.net.Uri,boolean,android.os.Bundle))) + ///{@endtemplate} void onRelationshipValidationResult( CustomTabsRelationType? relation, WebUri? requestedOrigin, bool result) {} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onWillOpenInBrowser} ///Event fired when the user opens the current page in the default browser by tapping the toolbar button. /// ///**NOTE for iOS**: available on iOS 14.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - SFSafariViewControllerDelegate.safariViewControllerWillOpenInBrowser](https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/3650426-safariviewcontrollerwillopeninbr)) + ///{@endtemplate} void onWillOpenInBrowser() {} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onMessageChannelReady} ///Called when the [PlatformChromeSafariBrowser] has requested a postMessage channel through - ///[requestPostMessageChannel] and the channel is ready for sending and receiving messages on both ends. + ///[PlatformChromeSafariBrowser.requestPostMessageChannel] and the channel is ready for sending and receiving messages on both ends. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsCallback.onMessageChannelReady](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onMessageChannelReady(android.os.Bundle))) + ///{@endtemplate} void onMessageChannelReady() {} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onPostMessage} ///Called when a tab controlled by this [PlatformChromeSafariBrowser] has sent a postMessage. - ///If [postMessage] is called from a single thread, then the messages will be posted in the same order. + ///If [PlatformChromeSafariBrowser.postMessage] is called from a single thread, then the messages will be posted in the same order. ///When received on the client side, it is the client's responsibility to preserve the ordering further. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsCallback.onPostMessage](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onPostMessage(java.lang.String,android.os.Bundle))) + ///{@endtemplate} void onPostMessage(String message) {} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onVerticalScrollEvent} ///Called when a user scrolls the tab. /// ///[isDirectionUp] - `false` when the user scrolls farther down the page, ///and `true` when the user scrolls back up toward the top of the page. /// - ///**NOTE**: available only if [isEngagementSignalsApiAvailable] returns `true`. + ///**NOTE**: available only if [PlatformChromeSafariBrowser.isEngagementSignalsApiAvailable] returns `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - EngagementSignalsCallback.onVerticalScrollEvent](https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onVerticalScrollEvent(boolean,android.os.Bundle))) + ///{@endtemplate} void onVerticalScrollEvent(bool isDirectionUp) {} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onGreatestScrollPercentageIncreased} ///Called when a user has reached a greater scroll percentage on the page. The greatest scroll ///percentage is reset if the user navigates to a different page. If the current page's total ///height changes, this method will be called again only if the scroll progress reaches a @@ -511,27 +583,32 @@ abstract class PlatformChromeSafariBrowserEvents { ///[scrollPercentage] - An integer indicating the percent of scrollable progress ///the user hasmade down the current page. /// - ///**NOTE**: available only if [isEngagementSignalsApiAvailable] returns `true`. + ///**NOTE**: available only if [PlatformChromeSafariBrowser.isEngagementSignalsApiAvailable] returns `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - EngagementSignalsCallback.onGreatestScrollPercentageIncreased](https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onGreatestScrollPercentageIncreased(int,android.os.Bundle))) + ///{@endtemplate} void onGreatestScrollPercentageIncreased(int scrollPercentage) {} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onSessionEnded} ///Called when a `CustomTabsSession` is ending or when no further Engagement Signals ///callbacks are expected to report whether any user action has occurred during the session. /// ///[didUserInteract] - Whether the user has interacted with the page in any way, e.g. scrolling. /// - ///**NOTE**: available only if [isEngagementSignalsApiAvailable] returns `true`. + ///**NOTE**: available only if [PlatformChromeSafariBrowser.isEngagementSignalsApiAvailable] returns `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ([Official API - EngagementSignalsCallback.onSessionEnded](https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onSessionEnded(boolean,android.os.Bundle))) + ///{@endtemplate} void onSessionEnded(bool didUserInteract) {} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onClosed} ///Event fired when the [PlatformChromeSafariBrowser] is closed. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS + ///{@endtemplate} void onClosed() {} } diff --git a/flutter_inappwebview_platform_interface/lib/src/content_blocker.dart b/flutter_inappwebview_platform_interface/lib/src/content_blocker.dart index f4f34be0..6d6a6eb7 100755 --- a/flutter_inappwebview_platform_interface/lib/src/content_blocker.dart +++ b/flutter_inappwebview_platform_interface/lib/src/content_blocker.dart @@ -44,7 +44,7 @@ class ContentBlockerTrigger { ///A list of regular expressions to match iframes URL against. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ///- MacOS List ifFrameUrl; @@ -52,7 +52,7 @@ class ContentBlockerTrigger { ///A Boolean value indicating if the URL matching should be case-sensitive. ///The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -62,7 +62,7 @@ class ContentBlockerTrigger { ///(how the browser intends to use the resource) that the rule should match. ///If not specified, the rule matches all resource types. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -72,7 +72,7 @@ class ContentBlockerTrigger { ///Values must be lowercase ASCII, or punycode for non-ASCII. ///Add * in front to match domain and subdomains. Can't be used with [ContentBlockerTrigger.unlessDomain]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -82,7 +82,7 @@ class ContentBlockerTrigger { ///Values must be lowercase ASCII, or punycode for non-ASCII. ///Add * in front to match domain and subdomains. Can't be used with [ContentBlockerTrigger.ifDomain]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -91,7 +91,7 @@ class ContentBlockerTrigger { ///A list of [ContentBlockerTriggerLoadType] that can include one of two mutually exclusive values. ///If not specified, the rule matches all load types. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -100,7 +100,7 @@ class ContentBlockerTrigger { ///A list of strings matched to the entire main document URL; limits the action to a specific list of URL patterns. ///Values must be lowercase ASCII, or punycode for non-ASCII. Can't be used with [ContentBlockerTrigger.unlessTopUrl]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -109,7 +109,7 @@ class ContentBlockerTrigger { ///An array of strings matched to the entire main document URL; acts on any site except URL patterns in provided list. ///Values must be lowercase ASCII, or punycode for non-ASCII. Can't be used with [ContentBlockerTrigger.ifTopUrl]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -117,7 +117,7 @@ class ContentBlockerTrigger { ///An array of strings that specify loading contexts. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ///- MacOS List loadContext; diff --git a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart index c3b39050..84e63405 100644 --- a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart @@ -10,7 +10,7 @@ part of 'context_menu.dart'; /// ///**NOTE for Android native WebView**: To make it work properly on Android, JavaScript should be enabled! /// -///**Supported Platforms/Implementations**: +///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS class ContextMenu { @@ -40,7 +40,7 @@ class ContextMenu { /// ///**NOTE for Android native WebView**: To make it work properly on Android, JavaScript should be enabled! /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ContextMenu( diff --git a/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart b/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart index f53d2e11..e84d2457 100644 --- a/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart @@ -24,10 +24,15 @@ class PlatformFindInteractionControllerCreationParams { bool isDoneCounting)? onFindResultReceived; } -///**Supported Platforms/Implementations**: +///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController} +///This class represents the controller used by the `WebView` to add +///text-finding capabilities, such as the "Find on page" feature. +/// +///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS +///{@endtemplate} abstract class PlatformFindInteractionController extends PlatformInterface implements Disposable { ///Debug settings. @@ -75,7 +80,7 @@ abstract class PlatformFindInteractionController extends PlatformInterface /// ///**NOTE**: on iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true`, this event will not be called. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebView.FindListener.onFindResultReceived](https://developer.android.com/reference/android/webkit/WebView.FindListener#onFindResultReceived(int,%20int,%20boolean))) ///- iOS ///- MacOS @@ -84,6 +89,7 @@ abstract class PlatformFindInteractionController extends PlatformInterface int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting)? get onFindResultReceived => params.onFindResultReceived; + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.findAll} ///Finds all instances of find on the page and highlights them. Notifies [PlatformFindInteractionController.onFindResultReceived] listener. /// ///[find] represents the string to find. @@ -94,15 +100,17 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///it uses the built-in find interaction native UI, ///otherwise this is implemented using CSS and Javascript. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebView.findAllAsync](https://developer.android.com/reference/android/webkit/WebView#findAllAsync(java.lang.String))) ///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.presentFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2) with [Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)) ///- MacOS + ///{@endtemplate} Future findAll({String? find}) { throw UnimplementedError( 'findAll is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.findNext} ///Highlights and scrolls to the next match found by [findAll]. Notifies [PlatformFindInteractionController.onFindResultReceived] listener. /// ///[forward] represents the direction to search. The default value is `true`, meaning forward. @@ -111,113 +119,133 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///it uses the built-in find interaction native UI, ///otherwise this is implemented using CSS and Javascript. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebView.findNext](https://developer.android.com/reference/android/webkit/WebView#findNext(boolean))) ///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.findNext](https://developer.apple.com/documentation/uikit/uifindinteraction/3975829-findnext?changes=_2) and ([Official API - UIFindInteraction.findPrevious](https://developer.apple.com/documentation/uikit/uifindinteraction/3975830-findprevious?changes=_2))) ///- MacOS + ///{@endtemplate} Future findNext({bool forward = true}) { throw UnimplementedError( 'findNext is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.clearMatches} ///Clears the highlighting surrounding text matches created by [findAll]. /// ///**NOTE**: on iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true`, ///it uses the built-in find interaction native UI, ///otherwise this is implemented using CSS and Javascript. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebView.clearMatches](https://developer.android.com/reference/android/webkit/WebView#clearMatches())) ///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.dismissFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2)) ///- MacOS + ///{@endtemplate} Future clearMatches() { throw UnimplementedError( 'clearMatches is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.setSearchText} ///Pre-populate the search text to be used. /// ///On iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true, ///it will pre-populate the system find panel's search text field with a search query. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ([Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)) ///- MacOS + ///{@endtemplate} Future setSearchText(String? searchText) { throw UnimplementedError( 'setSearchText is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.getSearchText} ///Get the search text used. /// ///On iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true, ///it will get the system find panel's search text field value. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ([Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)) ///- MacOS + ///{@endtemplate} Future getSearchText() { throw UnimplementedError( 'getSearchText is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.isFindNavigatorVisible} ///A Boolean value that indicates when the find panel displays onscreen. /// ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - UIFindInteraction.isFindNavigatorVisible](https://developer.apple.com/documentation/uikit/uifindinteraction/3975828-isfindnavigatorvisible?changes=_2)) + ///{@endtemplate} Future isFindNavigatorVisible() { throw UnimplementedError( 'isFindNavigatorVisible is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.updateResultCount} ///Updates the results the interface displays for the active search. /// ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - UIFindInteraction.updateResultCount](https://developer.apple.com/documentation/uikit/uifindinteraction/3975835-updateresultcount?changes=_2)) + ///{@endtemplate} Future updateResultCount() { throw UnimplementedError( 'updateResultCount is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.presentFindNavigator} ///Begins a search, displaying the find panel. /// ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - UIFindInteraction.presentFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2)) + ///{@endtemplate} Future presentFindNavigator() { throw UnimplementedError( 'presentFindNavigator is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.dismissFindNavigator} ///Dismisses the find panel, if present. /// ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - UIFindInteraction.dismissFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2)) + ///{@endtemplate} Future dismissFindNavigator() { throw UnimplementedError( 'dismissFindNavigator is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.getActiveFindSession} ///If there's a currently active find session, returns the active find session. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ([Official API - UIFindInteraction.activeFindSession](https://developer.apple.com/documentation/uikit/uifindinteraction/3975825-activefindsession?changes=_7____4_8&language=objc)) ///- MacOS + ///{@endtemplate} Future getActiveFindSession() { throw UnimplementedError( 'getActiveFindSession is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.dispose} + ///Disposes the controller. + ///{@endtemplate} @override void dispose() { throw UnimplementedError( diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_menu_item.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_menu_item.g.dart index 6fef0857..90620b74 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_menu_item.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_menu_item.g.dart @@ -8,7 +8,7 @@ part of 'in_app_browser_menu_item.dart'; ///Class that represents a custom menu item for a [PlatformInAppBrowser] instance. /// -///**Supported Platforms/Implementations**: +///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -18,7 +18,7 @@ class InAppBrowserMenuItem { ///Icon color. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS 13.0+ ///- MacOS @@ -40,7 +40,7 @@ class InAppBrowserMenuItem { String title; /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart index ab372cfe..c87aec88 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart @@ -100,7 +100,7 @@ class InAppBrowserSettings_ ///Set to `true` to create the browser and load the page, but not show it. Omit or set to `false` to have the browser open and load normally. ///The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -108,7 +108,7 @@ class InAppBrowserSettings_ ///Set to `true` to hide the toolbar at the top of the WebView. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -116,7 +116,7 @@ class InAppBrowserSettings_ ///Set the custom background color of the toolbar at the top. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -124,7 +124,7 @@ class InAppBrowserSettings_ ///Set to `true` to hide the url bar on the toolbar at the top. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -132,7 +132,7 @@ class InAppBrowserSettings_ ///Set to `true` to hide the progress bar when the WebView is loading a page. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -140,137 +140,137 @@ class InAppBrowserSettings_ ///Set to `true` to hide the default menu items. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS bool? hideDefaultMenuItems; ///Set to `true` if you want the title should be displayed. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView bool? hideTitleBar; ///Set the action bar's title. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- MacOS String? toolbarTopFixedTitle; ///Set to `false` to not close the InAppBrowser when the user click on the Android back button and the WebView cannot go back to the history. The default value is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView bool? closeOnCannotGoBack; ///Set to `false` to block the InAppBrowser WebView going back when the user click on the Android back button. The default value is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView bool? allowGoBackWithBackButton; ///Set to `true` to close the InAppBrowser when the user click on the Android back button. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView bool? shouldCloseOnBackButtonPressed; ///Set to `true` to set the toolbar at the top translucent. The default value is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS bool? toolbarTopTranslucent; ///Set the tint color to apply to the navigation bar background. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color_? toolbarTopBarTintColor; ///Set the tint color to apply to the navigation items and bar button items. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color_? toolbarTopTintColor; ///Set to `true` to hide the toolbar at the bottom of the WebView. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS bool? hideToolbarBottom; ///Set the custom background color of the toolbar at the bottom. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color_? toolbarBottomBackgroundColor; ///Set the tint color to apply to the bar button items. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color_? toolbarBottomTintColor; ///Set to `true` to set the toolbar at the bottom translucent. The default value is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS bool? toolbarBottomTranslucent; ///Set the custom text for the close button. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS String? closeButtonCaption; ///Set the custom color for the close button. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color_? closeButtonColor; ///Set to `true` to hide the close button. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS bool? hideCloseButton; ///Set the custom color for the menu button. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color_? menuButtonColor; ///Set the custom modal presentation style when presenting the WebView. The default value is [ModalPresentationStyle.FULL_SCREEN]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ModalPresentationStyle_? presentationStyle; ///Set to the custom transition style when presenting the WebView. The default value is [ModalTransitionStyle.COVER_VERTICAL]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ModalTransitionStyle_? transitionStyle; ///How the browser window should be added to the main window. ///The default value is [WindowType.CHILD]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- MacOS WindowType_? windowType; ///The window’s alpha value. ///The default value is `1.0`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- MacOS double? windowAlphaValue; ///Flags that describe the window’s current style, such as if it’s resizable or in full-screen mode. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- MacOS WindowStyleMask_? windowStyleMask; @@ -278,14 +278,14 @@ class InAppBrowserSettings_ /// ///**NOTE for MacOS**: available on MacOS 11.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- MacOS WindowTitlebarSeparatorStyle_? windowTitlebarSeparatorStyle; ///Sets the origin and size of the window’s frame rectangle according to a given frame rectangle, ///thereby setting its position and size onscreen. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- MacOS InAppWebViewRect_? windowFrame; diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart index 9d18bc54..4c2fe0f6 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart @@ -11,32 +11,32 @@ class InAppBrowserSettings implements BrowserOptions, AndroidOptions, IosOptions { ///Set to `false` to block the InAppBrowser WebView going back when the user click on the Android back button. The default value is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView bool? allowGoBackWithBackButton; ///Set the custom text for the close button. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS String? closeButtonCaption; ///Set the custom color for the close button. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color? closeButtonColor; ///Set to `false` to not close the InAppBrowser when the user click on the Android back button and the WebView cannot go back to the history. The default value is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView bool? closeOnCannotGoBack; ///Set to `true` to create the browser and load the page, but not show it. Omit or set to `false` to have the browser open and load normally. ///The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -44,20 +44,20 @@ class InAppBrowserSettings ///Set to `true` to hide the close button. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS bool? hideCloseButton; ///Set to `true` to hide the default menu items. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS bool? hideDefaultMenuItems; ///Set to `true` to hide the progress bar when the WebView is loading a page. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -65,19 +65,19 @@ class InAppBrowserSettings ///Set to `true` if you want the title should be displayed. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView bool? hideTitleBar; ///Set to `true` to hide the toolbar at the bottom of the WebView. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS bool? hideToolbarBottom; ///Set to `true` to hide the toolbar at the top of the WebView. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -85,7 +85,7 @@ class InAppBrowserSettings ///Set to `true` to hide the url bar on the toolbar at the top. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -93,43 +93,43 @@ class InAppBrowserSettings ///Set the custom color for the menu button. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color? menuButtonColor; ///Set the custom modal presentation style when presenting the WebView. The default value is [ModalPresentationStyle.FULL_SCREEN]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ModalPresentationStyle? presentationStyle; ///Set to `true` to close the InAppBrowser when the user click on the Android back button. The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView bool? shouldCloseOnBackButtonPressed; ///Set the custom background color of the toolbar at the bottom. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color? toolbarBottomBackgroundColor; ///Set the tint color to apply to the bar button items. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color? toolbarBottomTintColor; ///Set to `true` to set the toolbar at the bottom translucent. The default value is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS bool? toolbarBottomTranslucent; ///Set the custom background color of the toolbar at the top. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -137,52 +137,52 @@ class InAppBrowserSettings ///Set the tint color to apply to the navigation bar background. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color? toolbarTopBarTintColor; ///Set the action bar's title. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- MacOS String? toolbarTopFixedTitle; ///Set the tint color to apply to the navigation items and bar button items. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS Color? toolbarTopTintColor; ///Set to `true` to set the toolbar at the top translucent. The default value is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS bool? toolbarTopTranslucent; ///Set to the custom transition style when presenting the WebView. The default value is [ModalTransitionStyle.COVER_VERTICAL]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ModalTransitionStyle? transitionStyle; ///The window’s alpha value. ///The default value is `1.0`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- MacOS double? windowAlphaValue; ///Sets the origin and size of the window’s frame rectangle according to a given frame rectangle, ///thereby setting its position and size onscreen. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- MacOS InAppWebViewRect? windowFrame; ///Flags that describe the window’s current style, such as if it’s resizable or in full-screen mode. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- MacOS WindowStyleMask? windowStyleMask; @@ -190,14 +190,14 @@ class InAppBrowserSettings /// ///**NOTE for MacOS**: available on MacOS 11.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- MacOS WindowTitlebarSeparatorStyle? windowTitlebarSeparatorStyle; ///How the browser window should be added to the main window. ///The default value is [WindowType.CHILD]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- MacOS WindowType? windowType; InAppBrowserSettings( diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart index 52cc0a49..ae8f8860 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart @@ -54,13 +54,17 @@ class PlatformInAppBrowserCreationParams { final int? windowId; } -///This class uses the native WebView of the platform. +///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser} +///This class represents a native WebView displayed on top of the Flutter App, +///so it's not integrated into the Flutter widget tree. +///It uses the native WebView of the platform. ///The [webViewController] field can be used to access the [PlatformInAppWebViewController] API. /// -///**Supported Platforms/Implementations**: +///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS +///@{endtemplate} abstract class PlatformInAppBrowser extends PlatformInterface implements Disposable { ///Debug settings. @@ -72,7 +76,9 @@ abstract class PlatformInAppBrowser extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.id} ///View ID used internally. ///@{endtemplate} - String get id; + String get id { + throw UnimplementedError('id is not implemented on the current platform'); + } ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.contextMenu} ///Context menu used by the browser. It should be set before opening the browser. @@ -153,6 +159,7 @@ abstract class PlatformInAppBrowser extends PlatformInterface /// The parameters used to initialize the [PlatformInAppBrowser]. final PlatformInAppBrowserCreationParams params; + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.openUrlRequest} ///Opens the [PlatformInAppBrowser] instance with an [urlRequest]. /// ///[urlRequest]: The [urlRequest] to load. @@ -161,10 +168,11 @@ abstract class PlatformInAppBrowser extends PlatformInterface /// ///[settings]: Settings for the [PlatformInAppBrowser]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS + ///{@endtemplate} Future openUrlRequest( {required URLRequest urlRequest, // ignore: deprecated_member_use_from_same_package @@ -174,6 +182,7 @@ abstract class PlatformInAppBrowser extends PlatformInterface 'openUrlRequest is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.openFile} ///Opens the [PlatformInAppBrowser] instance with the given [assetFilePath] file. /// ///[options]: Options for the [PlatformInAppBrowser]. @@ -212,10 +221,11 @@ abstract class PlatformInAppBrowser extends PlatformInterface /// ///[settings]: Settings for the [PlatformInAppBrowser]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS + ///{@endtemplate} Future openFile( {required String assetFilePath, // ignore: deprecated_member_use_from_same_package @@ -225,6 +235,7 @@ abstract class PlatformInAppBrowser extends PlatformInterface 'openFile is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.openData} ///Opens the [PlatformInAppBrowser] instance with [data] as a content, using [baseUrl] as the base URL for it. /// ///The [mimeType] parameter specifies the format of the data. The default value is `"text/html"`. @@ -237,10 +248,11 @@ abstract class PlatformInAppBrowser extends PlatformInterface /// ///[settings]: Settings for the [PlatformInAppBrowser]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS + ///{@endtemplate} Future openData( {required String data, String mimeType = "text/html", @@ -255,178 +267,212 @@ abstract class PlatformInAppBrowser extends PlatformInterface 'openData is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.openWithSystemBrowser} ///This is a static method that opens an [url] in the system browser. You wont be able to use the [PlatformInAppBrowser] methods here! /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS + ///{@endtemplate} Future openWithSystemBrowser({required WebUri url}) { throw UnimplementedError( 'openWithSystemBrowser is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.addMenuItem} ///Adds a [InAppBrowserMenuItem] to the menu. ///If the browser is already open, ///it will take effect the next time it is opened. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS 14.0+ + ///{@endtemplate} void addMenuItem(InAppBrowserMenuItem menuItem) { throw UnimplementedError( 'addMenuItem is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.addMenuItems} ///Adds a list of [InAppBrowserMenuItem] to the menu. ///If the browser is already open, ///it will take effect the next time it is opened. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS 14.0+ + ///{@endtemplate} void addMenuItems(List menuItems) { throw UnimplementedError( 'addMenuItems is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.removeMenuItem} ///Removes the [menuItem] from the list. ///Returns `true` if it was in the list, `false` otherwise. ///If the browser is already open, ///it will take effect the next time it is opened. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS 14.0+ + ///{@endtemplate} bool removeMenuItem(InAppBrowserMenuItem menuItem) { throw UnimplementedError( 'removeMenuItem is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.removeMenuItems} ///Removes a list of [menuItems] from the list. ///If the browser is already open, ///it will take effect the next time it is opened. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS 14.0+ + ///{@endtemplate} void removeMenuItems(List menuItems) { throw UnimplementedError( 'removeMenuItems is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.removeAllMenuItem} ///Removes all the menu items from the list. ///If the browser is already open, ///it will take effect the next time it is opened. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android ///- iOS 14.0+ + ///{@endtemplate} void removeAllMenuItem() { throw UnimplementedError( 'removeAllMenuItem is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.hasMenuItem} ///Returns `true` if the [menuItem] has been already added, otherwise `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS 14.0+ + ///{@endtemplate} bool hasMenuItem(InAppBrowserMenuItem menuItem) { throw UnimplementedError( 'hasMenuItem is not implemented on the current platform'); } - ///Displays an [PlatformInAppBrowser] window that was opened hidden. Calling this has no effect if the [PlatformInAppBrowser] was already visible. + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.show} + ///Displays a [PlatformInAppBrowser] window that was opened hidden. Calling this has no effect if the [PlatformInAppBrowser] was already visible. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS + ///{@endtemplate} Future show() { throw UnimplementedError('show is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.hide} ///Hides the [PlatformInAppBrowser] window. Calling this has no effect if the [PlatformInAppBrowser] was already hidden. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS + ///{@endtemplate} Future hide() { throw UnimplementedError('hide is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.close} ///Closes the [PlatformInAppBrowser] window. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS + ///{@endtemplate} Future close() { throw UnimplementedError( 'close is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.isHidden} ///Check if the Web View of the [PlatformInAppBrowser] instance is hidden. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS + ///{@endtemplate} Future isHidden() { throw UnimplementedError( 'isHidden is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.setOptions} ///Use [setSettings] instead. + ///{@endtemplate} @Deprecated('Use setSettings instead') Future setOptions({required InAppBrowserClassOptions options}) { throw UnimplementedError( 'setOptions is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.getOptions} ///Use [getSettings] instead. + ///{@endtemplate} @Deprecated('Use getSettings instead') Future getOptions() { throw UnimplementedError( 'getOptions is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.setSettings} ///Sets the [PlatformInAppBrowser] settings with the new [settings] and evaluates them. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS + ///{@endtemplate} Future setSettings({required InAppBrowserClassSettings settings}) { throw UnimplementedError( 'setSettings is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.getSettings} ///Gets the current [PlatformInAppBrowser] settings. Returns `null` if it wasn't able to get them. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS + ///{@endtemplate} Future getSettings() { throw UnimplementedError( 'getSettings is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.isOpened} ///Returns `true` if the [PlatformInAppBrowser] instance is opened, otherwise `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS + ///{@endtemplate} bool isOpened() { throw UnimplementedError( 'isOpened is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.dispose} ///Disposes the channel and controllers. + ///{@endtemplate} @override void dispose() { throw UnimplementedError( @@ -437,7 +483,7 @@ abstract class PlatformInAppBrowser extends PlatformInterface abstract class PlatformInAppBrowserEvents { ///Event fired when the [PlatformInAppBrowser] is created. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -445,7 +491,7 @@ abstract class PlatformInAppBrowserEvents { ///Event fired when the [PlatformInAppBrowser] window is closed. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -453,7 +499,7 @@ abstract class PlatformInAppBrowserEvents { ///Event fired when the [PlatformInAppBrowser] starts to load an [url]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onPageStarted](https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap))) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview)) @@ -461,7 +507,7 @@ abstract class PlatformInAppBrowserEvents { ///Event fired when the [PlatformInAppBrowser] finishes loading an [url]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onPageFinished](https://developer.android.com/reference/android/webkit/WebViewClient#onPageFinished(android.webkit.WebView,%20java.lang.String))) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview)) @@ -473,7 +519,7 @@ abstract class PlatformInAppBrowserEvents { ///Event fired when the [PlatformInAppBrowser] encounters an [error] loading a [request]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onReceivedError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError))) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview)) @@ -491,7 +537,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE**: available on Android 23+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onReceivedHttpError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceResponse))) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview)) @@ -500,7 +546,7 @@ abstract class PlatformInAppBrowserEvents { ///Event fired when the current [progress] (range 0-100) of loading a page is changed. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onProgressChanged](https://developer.android.com/reference/android/webkit/WebChromeClient#onProgressChanged(android.webkit.WebView,%20int))) ///- iOS ///- MacOS @@ -508,7 +554,7 @@ abstract class PlatformInAppBrowserEvents { ///Event fired when the [PlatformInAppBrowser] webview receives a [ConsoleMessage]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onConsoleMessage](https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage))) ///- iOS ///- MacOS @@ -526,7 +572,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldOverrideUrlLoading] setting to `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.shouldOverrideUrlLoading](https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20java.lang.String))) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview)) @@ -539,7 +585,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnLoadResource] and [InAppWebViewSettings.javaScriptEnabled] setting to `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -553,7 +599,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE for MacOS**: this method is implemented with using JavaScript. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebView.onScrollChanged](https://developer.android.com/reference/android/webkit/WebView#onScrollChanged(int,%20int,%20int,%20int))) ///- iOS ([Official API - UIScrollViewDelegate.scrollViewDidScroll](https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619392-scrollviewdidscroll)) ///- MacOS @@ -570,7 +616,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnDownloadStart] setting to `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebView.setDownloadListener](https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener))) ///- iOS ///- MacOS @@ -585,7 +631,7 @@ abstract class PlatformInAppBrowserEvents { ///Event fired when the [PlatformInAppBrowser] webview finds the `custom-scheme` while loading a resource. ///Here you can handle the url [request] and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ([Official API - WKURLSchemeHandler](https://developer.apple.com/documentation/webkit/wkurlschemehandler)) ///- MacOS ([Official API - WKURLSchemeHandler](https://developer.apple.com/documentation/webkit/wkurlschemehandler)) @@ -622,7 +668,7 @@ abstract class PlatformInAppBrowserEvents { ///Also, note that calling [PlatformInAppWebViewController.setSettings] method using the controller of the new created WebView, ///it will update also the WebView options of the caller WebView. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onCreateWindow](https://developer.android.com/reference/android/webkit/WebChromeClient#onCreateWindow(android.webkit.WebView,%20boolean,%20boolean,%20android.os.Message))) ///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview)) ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview)) @@ -633,7 +679,7 @@ abstract class PlatformInAppBrowserEvents { ///Event fired when the host application should close the given WebView and remove it from the view system if necessary. ///At this point, WebCore has stopped any loading in this window and has removed any cross-scripting ability in javascript. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onCloseWindow](https://developer.android.com/reference/android/webkit/WebChromeClient#onCloseWindow(android.webkit.WebView))) ///- iOS ([Official API - WKUIDelegate.webViewDidClose](https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose)) ///- MacOS ([Official API - WKUIDelegate.webViewDidClose](https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose)) @@ -642,7 +688,7 @@ abstract class PlatformInAppBrowserEvents { ///Event fired when the JavaScript `window` object of the WebView has received focus. ///This is the result of the `focus` javascript event applied to the `window` object. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -651,7 +697,7 @@ abstract class PlatformInAppBrowserEvents { ///Event fired when the JavaScript `window` object of the WebView has lost focus. ///This is the result of the `blur` javascript event applied to the `window` object. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -662,7 +708,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[jsAlertRequest] contains the message to be displayed in the alert dialog and the of the page requesting the dialog. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onJsAlert](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsAlert(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult))) ///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview)) ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview)) @@ -675,7 +721,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[jsConfirmRequest] contains the message to be displayed in the confirm dialog and the of the page requesting the dialog. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onJsConfirm](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsConfirm(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult))) ///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview)) ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview)) @@ -688,7 +734,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[jsPromptRequest] contains the message to be displayed in the prompt dialog, the default value displayed in the prompt dialog, and the of the page requesting the dialog. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onJsPrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsPrompt(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20android.webkit.JsPromptResult))) ///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview)) ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview)) @@ -700,7 +746,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [URLAuthenticationChallenge]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onReceivedHttpAuthRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpAuthRequest(android.webkit.WebView,%20android.webkit.HttpAuthHandler,%20java.lang.String,%20java.lang.String))) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) @@ -714,7 +760,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ServerTrustChallenge]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onReceivedSslError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedSslError(android.webkit.WebView,%20android.webkit.SslErrorHandler,%20android.net.http.SslError))) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) @@ -730,7 +776,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ClientCertChallenge]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onReceivedClientCertRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedClientCertRequest(android.webkit.WebView,%20android.webkit.ClientCertRequest))) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) @@ -755,7 +801,7 @@ abstract class PlatformInAppBrowserEvents { ///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms). ///Inside the `window.addEventListener("flutterInAppWebViewPlatformReady")` event, the ajax requests will be intercept for sure. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -774,7 +820,7 @@ abstract class PlatformInAppBrowserEvents { ///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms). ///Inside the `window.addEventListener("flutterInAppWebViewPlatformReady")` event, the ajax requests will be intercept for sure. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -793,7 +839,7 @@ abstract class PlatformInAppBrowserEvents { ///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms). ///Inside the `window.addEventListener("flutterInAppWebViewPlatformReady")` event, the ajax requests will be intercept for sure. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -812,7 +858,7 @@ abstract class PlatformInAppBrowserEvents { ///used to intercept fetch requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms). ///Inside the `window.addEventListener("flutterInAppWebViewPlatformReady")` event, the fetch requests will be intercept for sure. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -830,7 +876,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[isReload] indicates if this url is being reloaded. Available only on Android. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.doUpdateVisitedHistory](https://developer.android.com/reference/android/webkit/WebViewClient#doUpdateVisitedHistory(android.webkit.WebView,%20java.lang.String,%20boolean))) ///- iOS ///- MacOS @@ -848,7 +894,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[printJobController] represents the controller of the print job created. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ///- MacOS @@ -861,14 +907,14 @@ abstract class PlatformInAppBrowserEvents { /// ///[hitTestResult] represents the hit result for hitting an HTML elements. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - View.setOnLongClickListener](https://developer.android.com/reference/android/view/View#setOnLongClickListener(android.view.View.OnLongClickListener))) ///- iOS ([Official API - UILongPressGestureRecognizer](https://developer.apple.com/documentation/uikit/uilongpressgesturerecognizer)) void onLongPressHitTestResult(InAppWebViewHitTestResult hitTestResult) {} ///Event fired when the current page has entered full screen mode. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onShowCustomView](https://developer.android.com/reference/android/webkit/WebChromeClient#onShowCustomView(android.view.View,%20android.webkit.WebChromeClient.CustomViewCallback))) ///- iOS ([Official API - UIWindow.didBecomeVisibleNotification](https://developer.apple.com/documentation/uikit/uiwindow/1621621-didbecomevisiblenotification)) ///- MacOS ([Official API - NSWindow.didEnterFullScreenNotification](https://developer.apple.com/documentation/appkit/nswindow/1419651-didenterfullscreennotification)) @@ -876,7 +922,7 @@ abstract class PlatformInAppBrowserEvents { ///Event fired when the current page has exited full screen mode. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onHideCustomView](https://developer.android.com/reference/android/webkit/WebChromeClient#onHideCustomView())) ///- iOS ([Official API - UIWindow.didBecomeHiddenNotification](https://developer.apple.com/documentation/uikit/uiwindow/1621617-didbecomehiddennotification)) ///- MacOS ([Official API - NSWindow.didExitFullScreenNotification](https://developer.apple.com/documentation/appkit/nswindow/1419177-didexitfullscreennotification)) @@ -889,7 +935,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[url] represents the URL corresponding to the page navigation that triggered this callback. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onPageCommitVisible](https://developer.android.com/reference/android/webkit/WebViewClient#onPageCommitVisible(android.webkit.WebView,%20java.lang.String))) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview)) @@ -899,7 +945,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[title] represents the string containing the new title of the document. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onReceivedTitle](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTitle(android.webkit.WebView,%20java.lang.String))) ///- iOS ///- MacOS @@ -915,7 +961,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[clampedY] is `true` if [y] was clamped to an over-scroll boundary. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebView.onOverScrolled](https://developer.android.com/reference/android/webkit/WebView#onOverScrolled(int,%20int,%20boolean,%20boolean))) ///- iOS void onOverScrolled(int x, int y, bool clampedX, bool clampedY) {} @@ -926,7 +972,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[newScale] The new zoom scale factor.ì /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onScaleChanged](https://developer.android.com/reference/android/webkit/WebViewClient#onScaleChanged(android.webkit.WebView,%20float,%20float))) ///- iOS ([Official API - UIScrollViewDelegate.scrollViewDidZoom](https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619409-scrollviewdidzoom)) void onZoomScaleChanged(double oldScale, double newScale) {} @@ -947,7 +993,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE**: available only on Android 27+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onSafeBrowsingHit](https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse))) Future? onSafeBrowsingHit( WebUri url, SafeBrowsingThreat? threatType) { @@ -972,7 +1018,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE for MacOS**: available only on iOS 12.0+. The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT]. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onPermissionRequest](https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest))) ///- iOS ///- MacOS @@ -994,7 +1040,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[origin] represents the origin of the web content attempting to use the Geolocation API. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsShowPrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback))) Future? onGeolocationPermissionsShowPrompt(String origin) { @@ -1008,7 +1054,7 @@ abstract class PlatformInAppBrowserEvents { ///Notify the host application that a request for Geolocation permissions, made with a previous call to [onGeolocationPermissionsShowPrompt] has been canceled. ///Any related UI should therefore be hidden. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsHidePrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsHidePrompt())) void onGeolocationPermissionsHidePrompt() {} @@ -1033,7 +1079,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptRequest] option to `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.shouldInterceptRequest](https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest))) Future? shouldInterceptRequest( WebResourceRequest request) { @@ -1064,7 +1110,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE**: available only on Android 29+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessUnresponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) Future? onRenderProcessUnresponsive( WebUri? url) { @@ -1088,7 +1134,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE**: available only on Android 29+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessResponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) Future? onRenderProcessResponsive(WebUri? url) { return null; @@ -1106,7 +1152,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE**: available only on Android 26+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onRenderProcessGone](https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail))) void onRenderProcessGone(RenderProcessGoneDetail detail) {} @@ -1118,7 +1164,7 @@ abstract class PlatformInAppBrowserEvents { ///As the host application if the browser should resend data as the requested page was a result of a POST. The default is to not resend the data. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onFormResubmission](https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message))) Future? onFormResubmission(WebUri? url) { return null; @@ -1136,7 +1182,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[icon] represents the favicon for the current page. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onReceivedIcon](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap))) void onReceivedIcon(Uint8List icon) {} @@ -1150,7 +1196,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[precomposed] is `true` if the url is for a precomposed touch icon. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onReceivedTouchIconUrl](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean))) void onReceivedTouchIconUrl(WebUri url, bool precomposed) {} @@ -1171,7 +1217,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[jsBeforeUnloadRequest] contains the message to be displayed in the alert dialog and the of the page requesting the dialog. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onJsBeforeUnload](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsBeforeUnload(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult))) Future? onJsBeforeUnload( JsBeforeUnloadRequest jsBeforeUnloadRequest) { @@ -1186,7 +1232,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[loginRequest] contains the realm, account and args of the login request. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onReceivedLoginRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedLoginRequest(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String))) void onReceivedLoginRequest(LoginRequest loginRequest) {} @@ -1198,14 +1244,14 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE for Android**: available only on Android 21+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onPermissionRequestCanceled](https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequestCanceled(android.webkit.PermissionRequest))) void onPermissionRequestCanceled(PermissionRequest permissionRequest) {} ///Request display and focus for this WebView. ///This may happen due to another WebView opening a link in this WebView and requesting that this WebView be displayed. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onRequestFocus](https://developer.android.com/reference/android/webkit/WebChromeClient#onRequestFocus(android.webkit.WebView))) void onRequestFocus() {} @@ -1215,7 +1261,7 @@ abstract class PlatformInAppBrowserEvents { ///Invoked when the web view's web content process is terminated. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi)) ///- MacOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi)) void onWebContentProcessDidTerminate() {} @@ -1226,7 +1272,7 @@ abstract class PlatformInAppBrowserEvents { ///Called when a web view receives a server redirect. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview)) void onDidReceiveServerRedirectForProvisionalNavigation() {} @@ -1244,7 +1290,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnNavigationResponse] setting to `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview)) Future? onNavigationResponse( @@ -1267,7 +1313,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE for MacOS**: available only on MacOS 11.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview)) Future? shouldAllowDeprecatedTLS( @@ -1281,7 +1327,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE for MacOS**: available only on MacOS 12.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ///- MacOS void onCameraCaptureStateChanged( @@ -1296,7 +1342,7 @@ abstract class PlatformInAppBrowserEvents { /// ///**NOTE for MacOS**: available only on MacOS 12.0+. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ///- MacOS void onMicrophoneCaptureStateChanged( @@ -1310,7 +1356,7 @@ abstract class PlatformInAppBrowserEvents { /// ///[newContentSize] represents the new content size value. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS void onContentSizeChanged(Size oldContentSize, Size newContentSize) {} } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_localhost_server.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_localhost_server.dart index 26e2814a..ffdb9abd 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_localhost_server.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_localhost_server.dart @@ -30,14 +30,7 @@ class DefaultInAppLocalhostServerCreationParams } } -///This class allows you to create a simple server on `http://localhost:[port]/` -///in order to be able to load your assets file on a local server. -///The default `port` value is `8080`. -/// -///**Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- MacOS +///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer} class DefaultInAppLocalhostServer extends PlatformInAppLocalhostServer { bool _started = false; HttpServer? _server; @@ -61,30 +54,19 @@ class DefaultInAppLocalhostServer extends PlatformInAppLocalhostServer { this._shared = shared; } - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.port} + @override int get port => _port; - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.directoryIndex} + @override String get directoryIndex => _directoryIndex; - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.documentRoot} + @override String get documentRoot => _documentRoot; - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.shared} + @override bool get shared => _shared; - ///Starts the server on `http://localhost:[port]/`. - /// - ///**NOTE for iOS**: For the iOS Platform, you need to add the `NSAllowsLocalNetworking` key with `true` in the `Info.plist` file - ///(See [ATS Configuration Basics](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW35)): - ///```xml - ///NSAppTransportSecurity - /// - /// NSAllowsLocalNetworking - /// - /// - ///``` - ///The `NSAllowsLocalNetworking` key is available since **iOS 10**. + @override Future start() async { if (this._started) { throw Exception('Server already started on http://localhost:$_port'); @@ -142,7 +124,7 @@ class DefaultInAppLocalhostServer extends PlatformInAppLocalhostServer { return completer.future; } - ///Closes the server. + @override Future close() async { if (this._server == null) { return; @@ -153,7 +135,7 @@ class DefaultInAppLocalhostServer extends PlatformInAppLocalhostServer { this._server = null; } - ///Indicates if the server is running or not. + @override bool isRunning() { return this._server != null; } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/android/in_app_webview_options.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/android/in_app_webview_options.dart index 044076ba..dc956e13 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/android/in_app_webview_options.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/android/in_app_webview_options.dart @@ -158,10 +158,10 @@ class AndroidInAppWebViewOptions bool hardwareAcceleration; ///Sets whether the WebView supports multiple windows. - ///If set to `true`, [WebView.onCreateWindow] event must be implemented by the host application. The default value is `false`. + ///If set to `true`, [PlatformWebViewCreationParams.onCreateWindow] event must be implemented by the host application. The default value is `false`. bool supportMultipleWindows; - ///Regular expression used by [WebView.shouldOverrideUrlLoading] event to cancel navigation requests for frames that are not the main frame. + ///Regular expression used by [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event to cancel navigation requests for frames that are not the main frame. ///If the url request of a subframe matches the regular expression, then the request of that subframe is canceled. String? regexToCancelSubFramesLoading; @@ -172,10 +172,10 @@ class AndroidInAppWebViewOptions ///as it can cause framerate drops on animations in Android 9 and lower (see [Hybrid-Composition#performance](https://github.com/flutter/flutter/wiki/Hybrid-Composition#performance)). bool useHybridComposition; - ///Set to `true` to be able to listen at the [WebView.androidShouldInterceptRequest] event. The default value is `false`. + ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.androidShouldInterceptRequest] event. The default value is `false`. bool useShouldInterceptRequest; - ///Set to `true` to be able to listen at the [WebView.androidOnRenderProcessGone] event. The default value is `false`. + ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.androidOnRenderProcessGone] event. The default value is `false`. bool useOnRenderProcessGone; ///Sets the WebView's over-scroll mode. diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/apple/in_app_webview_options.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/apple/in_app_webview_options.dart index da42cc02..e656a4ba 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/apple/in_app_webview_options.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/apple/in_app_webview_options.dart @@ -152,7 +152,7 @@ class IOSInAppWebViewOptions ///**NOTE**: available on iOS 14.0+. bool limitsNavigationsToAppBoundDomains; - ///Set to `true` to be able to listen to the [WebView.iosOnNavigationResponse] event. The default value is `false`. + ///Set to `true` to be able to listen to the [PlatformWebViewCreationParams.iosOnNavigationResponse] event. The default value is `false`. bool useOnNavigationResponse; ///Set to `true` to enable Apple Pay API for the `WebView` at its first page load or on the next page load (using [PlatformInAppWebViewController.setOptions]). The default value is `false`. @@ -187,7 +187,7 @@ class IOSInAppWebViewOptions ///- [PlatformInAppWebViewController.addWebMessageListener] /// ///Options affected: - ///- [WebView.initialUserScripts] + ///- [PlatformWebViewCreationParams.initialUserScripts] ///- [InAppWebViewOptions.supportZoom] ///- [InAppWebViewOptions.useOnLoadResource] ///- [InAppWebViewOptions.useShouldInterceptAjaxRequest] @@ -195,26 +195,26 @@ class IOSInAppWebViewOptions ///- [IOSInAppWebViewOptions.enableViewportScale] /// ///Events affected: - ///- the `hitTestResult` argument of [WebView.onLongPressHitTestResult] will be empty + ///- the `hitTestResult` argument of [PlatformWebViewCreationParams.onLongPressHitTestResult] will be empty ///- the `hitTestResult` argument of [ContextMenu.onCreateContextMenu] will be empty - ///- [WebView.onLoadResource] - ///- [WebView.shouldInterceptAjaxRequest] - ///- [WebView.onAjaxReadyStateChange] - ///- [WebView.onAjaxProgress] - ///- [WebView.shouldInterceptFetchRequest] - ///- [WebView.onConsoleMessage] - ///- [WebView.onPrint] - ///- [WebView.onWindowFocus] - ///- [WebView.onWindowBlur] - ///- [WebView.onFindResultReceived] + ///- [PlatformWebViewCreationParams.onLoadResource] + ///- [PlatformWebViewCreationParams.shouldInterceptAjaxRequest] + ///- [PlatformWebViewCreationParams.onAjaxReadyStateChange] + ///- [PlatformWebViewCreationParams.onAjaxProgress] + ///- [PlatformWebViewCreationParams.shouldInterceptFetchRequest] + ///- [PlatformWebViewCreationParams.onConsoleMessage] + ///- [PlatformWebViewCreationParams.onPrint] + ///- [PlatformWebViewCreationParams.onWindowFocus] + ///- [PlatformWebViewCreationParams.onWindowBlur] + ///- [PlatformWebViewCreationParams.onFindResultReceived] /// ///**NOTE**: available on iOS 13.0+. bool applePayAPIEnabled; - ///Used in combination with [WebView.initialUrlRequest] or [WebView.initialData] (using the `file://` scheme), it represents the URL from which to read the web content. + ///Used in combination with [PlatformWebViewCreationParams.initialUrlRequest] or [PlatformWebViewCreationParams.initialData] (using the `file://` scheme), it represents the URL from which to read the web content. ///This URL must be a file-based URL (using the `file://` scheme). - ///Specify the same value as the [URLRequest.url] if you are using it with the [WebView.initialUrlRequest] parameter or - ///the [InAppWebViewInitialData.baseUrl] if you are using it with the [WebView.initialData] parameter to prevent WebView from reading any other content. + ///Specify the same value as the [URLRequest.url] if you are using it with the [PlatformWebViewCreationParams.initialUrlRequest] parameter or + ///the [InAppWebViewInitialData.baseUrl] if you are using it with the [PlatformWebViewCreationParams.initialData] parameter to prevent WebView from reading any other content. ///Specify a directory to give WebView permission to read additional files in the specified directory. Uri? allowingReadAccessTo; diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart index fdec8fbe..7599b599 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart @@ -32,6 +32,7 @@ import '../platform_webview_feature.dart'; import '../in_app_webview/platform_inappwebview_controller.dart'; import '../context_menu/context_menu.dart'; import '../in_app_browser/platform_in_app_browser.dart'; +import 'platform_webview.dart'; part 'in_app_webview_settings.g.dart'; @@ -51,27 +52,27 @@ List _deserializeContentBlockers( ///This class represents all the WebView settings available. @ExchangeableObject(copyMethod: true) class InAppWebViewSettings_ { - ///Set to `true` to be able to listen at the [WebView.shouldOverrideUrlLoading] event. + ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event. /// - ///If the [WebView.shouldOverrideUrlLoading] event is implemented and this value is `null`, + ///If the [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms( platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()]) bool? useShouldOverrideUrlLoading; - ///Set to `true` to be able to listen at the [WebView.onLoadResource] event. + ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.onLoadResource] event. /// - ///If the [WebView.onLoadResource] event is implemented and this value is `null`, + ///If the [PlatformWebViewCreationParams.onLoadResource] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms( platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()]) bool? useOnLoadResource; - ///Set to `true` to be able to listen at the [WebView.onDownloadStartRequest] event. + ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.onDownloadStartRequest] event. /// - ///If the [WebView.onDownloadStartRequest] event is implemented and this value is `null`, + ///If the [PlatformWebViewCreationParams.onDownloadStartRequest] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms( @@ -219,7 +220,7 @@ class InAppWebViewSettings_ { ]) bool? horizontalScrollBarEnabled; - ///List of custom schemes that the WebView must handle. Use the [WebView.onLoadResourceWithCustomScheme] event to intercept resource requests with custom scheme. + ///List of custom schemes that the WebView must handle. Use the [PlatformWebViewCreationParams.onLoadResourceWithCustomScheme] event to intercept resource requests with custom scheme. @SupportedPlatforms(platforms: [ AndroidPlatform(), IOSPlatform(available: "11.0"), @@ -252,18 +253,18 @@ class InAppWebViewSettings_ { ]) UserPreferredContentMode_? preferredContentMode; - ///Set to `true` to be able to listen at the [WebView.shouldInterceptAjaxRequest] event. + ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.shouldInterceptAjaxRequest] event. /// - ///If the [WebView.shouldInterceptAjaxRequest] event is implemented and this value is `null`, + ///If the [PlatformWebViewCreationParams.shouldInterceptAjaxRequest] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms( platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()]) bool? useShouldInterceptAjaxRequest; - ///Set to `true` to be able to listen at the [WebView.shouldInterceptFetchRequest] event. + ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.shouldInterceptFetchRequest] event. /// - ///If the [WebView.shouldInterceptFetchRequest] event is implemented and this value is `null`, + ///If the [PlatformWebViewCreationParams.shouldInterceptFetchRequest] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms( @@ -605,7 +606,7 @@ because there isn't any way to make the website data store non-persistent for th note: """Please note that in order for the Geolocation API to be usable by a page in the WebView, the following requirements must be met: - an application must have permission to access the device location, see [Manifest.permission.ACCESS_COARSE_LOCATION](https://developer.android.com/reference/android/Manifest.permission#ACCESS_COARSE_LOCATION), [Manifest.permission.ACCESS_FINE_LOCATION](https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION); -- an application must provide an implementation of the [WebView.onGeolocationPermissionsShowPrompt] callback to receive notifications that a page is requesting access to location via the JavaScript Geolocation API.""") +- an application must provide an implementation of the [PlatformWebViewCreationParams.onGeolocationPermissionsShowPrompt] callback to receive notifications that a page is requesting access to location via the JavaScript Geolocation API.""") ]) bool? geolocationEnabled; @@ -745,7 +746,7 @@ because there isn't any way to make the website data store non-persistent for th bool? hardwareAcceleration; ///Sets whether the WebView supports multiple windows. - ///If set to `true`, [WebView.onCreateWindow] event must be implemented by the host application. The default value is `false`. + ///If set to `true`, [PlatformWebViewCreationParams.onCreateWindow] event must be implemented by the host application. The default value is `false`. @SupportedPlatforms(platforms: [ AndroidPlatform( apiName: "WebSettings.setSupportMultipleWindows", @@ -754,7 +755,7 @@ because there isn't any way to make the website data store non-persistent for th ]) bool? supportMultipleWindows; - ///Regular expression used by [WebView.shouldOverrideUrlLoading] event to cancel navigation requests for frames that are not the main frame. + ///Regular expression used by [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event to cancel navigation requests for frames that are not the main frame. ///If the url request of a subframe matches the regular expression, then the request of that subframe is canceled. @SupportedPlatforms(platforms: [AndroidPlatform()]) String? regexToCancelSubFramesLoading; @@ -769,17 +770,17 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri ]) bool? useHybridComposition; - ///Set to `true` to be able to listen at the [WebView.shouldInterceptRequest] event. + ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.shouldInterceptRequest] event. /// - ///If the [WebView.shouldInterceptRequest] event is implemented and this value is `null`, + ///If the [PlatformWebViewCreationParams.shouldInterceptRequest] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms(platforms: [AndroidPlatform()]) bool? useShouldInterceptRequest; - ///Set to `true` to be able to listen at the [WebView.onRenderProcessGone] event. + ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.onRenderProcessGone] event. /// - ///If the [WebView.onRenderProcessGone] event is implemented and this value is `null`, + ///If the [PlatformWebViewCreationParams.onRenderProcessGone] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms(platforms: [AndroidPlatform()]) @@ -1288,9 +1289,9 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri ]) bool? limitsNavigationsToAppBoundDomains; - ///Set to `true` to be able to listen to the [WebView.onNavigationResponse] event. + ///Set to `true` to be able to listen to the [PlatformWebViewCreationParams.onNavigationResponse] event. /// - ///If the [WebView.onNavigationResponse] event is implemented and this value is `null`, + ///If the [PlatformWebViewCreationParams.onNavigationResponse] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. @SupportedPlatforms(platforms: [IOSPlatform(), MacOSPlatform()]) @@ -1338,7 +1339,7 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri ///- [PlatformInAppWebViewController.canScrollHorizontally] /// ///Settings affected: - ///- [WebView.initialUserScripts] + ///- [PlatformWebViewCreationParams.initialUserScripts] ///- [InAppWebViewSettings.supportZoom] ///- [InAppWebViewSettings.useOnLoadResource] ///- [InAppWebViewSettings.useShouldInterceptAjaxRequest] @@ -1346,32 +1347,32 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri ///- [InAppWebViewSettings.enableViewportScale] /// ///Events affected: - ///- the `hitTestResult` argument of [WebView.onLongPressHitTestResult] will be empty + ///- the `hitTestResult` argument of [PlatformWebViewCreationParams.onLongPressHitTestResult] will be empty ///- the `hitTestResult` argument of [ContextMenu.onCreateContextMenu] will be empty - ///- [WebView.onLoadResource] - ///- [WebView.shouldInterceptAjaxRequest] - ///- [WebView.onAjaxReadyStateChange] - ///- [WebView.onAjaxProgress] - ///- [WebView.shouldInterceptFetchRequest] - ///- [WebView.onConsoleMessage] - ///- [WebView.onPrintRequest] - ///- [WebView.onWindowFocus] - ///- [WebView.onWindowBlur] - ///- [WebView.onFindResultReceived] + ///- [PlatformWebViewCreationParams.onLoadResource] + ///- [PlatformWebViewCreationParams.shouldInterceptAjaxRequest] + ///- [PlatformWebViewCreationParams.onAjaxReadyStateChange] + ///- [PlatformWebViewCreationParams.onAjaxProgress] + ///- [PlatformWebViewCreationParams.shouldInterceptFetchRequest] + ///- [PlatformWebViewCreationParams.onConsoleMessage] + ///- [PlatformWebViewCreationParams.onPrintRequest] + ///- [PlatformWebViewCreationParams.onWindowFocus] + ///- [PlatformWebViewCreationParams.onWindowBlur] + ///- [PlatformWebViewCreationParams.onFindResultReceived] ///- [FindInteractionController.onFindResultReceived] /// ///Also, on MacOS: - ///- [WebView.onScrollChanged] + ///- [PlatformWebViewCreationParams.onScrollChanged] @SupportedPlatforms(platforms: [ IOSPlatform(available: "13.0"), MacOSPlatform(available: "10.15") ]) bool? applePayAPIEnabled; - ///Used in combination with [WebView.initialUrlRequest] or [WebView.initialData] (using the `file://` scheme), it represents the URL from which to read the web content. + ///Used in combination with [PlatformWebViewCreationParams.initialUrlRequest] or [PlatformWebViewCreationParams.initialData] (using the `file://` scheme), it represents the URL from which to read the web content. ///This URL must be a file-based URL (using the `file://` scheme). - ///Specify the same value as the [URLRequest.url] if you are using it with the [WebView.initialUrlRequest] parameter or - ///the [InAppWebViewInitialData.baseUrl] if you are using it with the [WebView.initialData] parameter to prevent WebView from reading any other content. + ///Specify the same value as the [URLRequest.url] if you are using it with the [PlatformWebViewCreationParams.initialUrlRequest] parameter or + ///the [InAppWebViewInitialData.baseUrl] if you are using it with the [PlatformWebViewCreationParams.initialData] parameter to prevent WebView from reading any other content. ///Specify a directory to give WebView permission to read additional files in the specified directory. @SupportedPlatforms(platforms: [IOSPlatform(), MacOSPlatform()]) WebUri? allowingReadAccessTo; @@ -1854,13 +1855,13 @@ class WebViewOptions { @Deprecated('Use InAppWebViewSettings instead') class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOptions, IosOptions { - ///Set to `true` to be able to listen at the [WebView.shouldOverrideUrlLoading] event. The default value is `false`. + ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event. The default value is `false`. bool useShouldOverrideUrlLoading; - ///Set to `true` to be able to listen at the [WebView.onLoadResource] event. The default value is `false`. + ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.onLoadResource] event. The default value is `false`. bool useOnLoadResource; - ///Set to `true` to be able to listen at the [WebView.onDownloadStart] event. The default value is `false`. + ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.onDownloadStart] event. The default value is `false`. bool useOnDownloadStart; ///Set to `true` to have all the browser's cache cleared before the new WebView is opened. The default value is `false`. @@ -1896,7 +1897,7 @@ class InAppWebViewOptions ///Define whether the horizontal scrollbar should be drawn or not. The default value is `true`. bool horizontalScrollBarEnabled; - ///List of custom schemes that the WebView must handle. Use the [WebView.onLoadResourceCustomScheme] event to intercept resource requests with custom scheme. + ///List of custom schemes that the WebView must handle. Use the [PlatformWebViewCreationParams.onLoadResourceCustomScheme] event to intercept resource requests with custom scheme. /// ///**NOTE**: available on iOS 11.0+. List resourceCustomSchemes; @@ -1911,10 +1912,10 @@ class InAppWebViewOptions ///**NOTE**: available on iOS 13.0+. UserPreferredContentMode? preferredContentMode; - ///Set to `true` to be able to listen at the [WebView.shouldInterceptAjaxRequest] event. The default value is `false`. + ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.shouldInterceptAjaxRequest] event. The default value is `false`. bool useShouldInterceptAjaxRequest; - ///Set to `true` to be able to listen at the [WebView.shouldInterceptFetchRequest] event. The default value is `false`. + ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.shouldInterceptFetchRequest] event. The default value is `false`. bool useShouldInterceptFetchRequest; ///Set to `true` to open a browser window with incognito mode. The default value is `false`. diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart index f211b41d..d436b37c 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart @@ -11,7 +11,7 @@ class InAppWebViewSettings { ///A Boolean value indicating whether the WebView ignores an accessibility request to invert its colors. ///The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS 11.0+ ([Official API - UIView.accessibilityIgnoresInvertColors](https://developer.apple.com/documentation/uikit/uiview/2865843-accessibilityignoresinvertcolors)) bool? accessibilityIgnoresInvertColors; @@ -29,7 +29,7 @@ class InAppWebViewSettings { /// ///**NOTE for Android native WebView**: available on Android only if [WebViewFeature.ALGORITHMIC_DARKENING] feature is supported. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView 29+ ([Official API - WebSettingsCompat.setAlgorithmicDarkeningAllowed](https://developer.android.com/reference/androidx/webkit/WebSettingsCompat#setAlgorithmicDarkeningAllowed(android.webkit.WebSettings,boolean))) bool? algorithmicDarkeningAllowed; @@ -41,20 +41,20 @@ class InAppWebViewSettings { ///**IMPORTANT NOTE**: if you use this setting, your app could be rejected by the Google Play Store. ///For example, if you allow background playing of YouTube videos, which is a violation of the YouTube API Terms of Service. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView bool? allowBackgroundAudioPlaying; ///Enables or disables content URL access within WebView. Content URL access allows WebView to load content from a content provider installed in the system. The default value is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebSettings.setAllowContentAccess](https://developer.android.com/reference/android/webkit/WebSettings?hl=en#setAllowContentAccess(boolean))) bool? allowContentAccess; ///Enables or disables file access within WebView. Note that this enables or disables file system access only. ///Assets and resources are still accessible using `file:///android_asset` and `file:///android_res`. The default value is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebSettings.setAllowFileAccess](https://developer.android.com/reference/android/webkit/WebSettings?hl=en#setAllowFileAccess(boolean))) bool? allowFileAccess; @@ -68,7 +68,7 @@ class InAppWebViewSettings { /// ///The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebSettings.setAllowFileAccessFromFileURLs](https://developer.android.com/reference/android/webkit/WebSettings?hl=en#setAllowFileAccessFromFileURLs(boolean))) ///- iOS ///- MacOS @@ -84,33 +84,33 @@ class InAppWebViewSettings { /// ///The default value is `false`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebSettings.setAllowUniversalAccessFromFileURLs](https://developer.android.com/reference/android/webkit/WebSettings?hl=en#setAllowUniversalAccessFromFileURLs(boolean))) ///- iOS ///- MacOS bool? allowUniversalAccessFromFileURLs; - ///Used in combination with [WebView.initialUrlRequest] or [WebView.initialData] (using the `file://` scheme), it represents the URL from which to read the web content. + ///Used in combination with [PlatformWebViewCreationParams.initialUrlRequest] or [PlatformWebViewCreationParams.initialData] (using the `file://` scheme), it represents the URL from which to read the web content. ///This URL must be a file-based URL (using the `file://` scheme). - ///Specify the same value as the [URLRequest.url] if you are using it with the [WebView.initialUrlRequest] parameter or - ///the [InAppWebViewInitialData.baseUrl] if you are using it with the [WebView.initialData] parameter to prevent WebView from reading any other content. + ///Specify the same value as the [URLRequest.url] if you are using it with the [PlatformWebViewCreationParams.initialUrlRequest] parameter or + ///the [InAppWebViewInitialData.baseUrl] if you are using it with the [PlatformWebViewCreationParams.initialData] parameter to prevent WebView from reading any other content. ///Specify a directory to give WebView permission to read additional files in the specified directory. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ///- MacOS WebUri? allowingReadAccessTo; ///Set to `true` to allow AirPlay. The default value is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - WKWebViewConfiguration.allowsAirPlayForMediaPlayback](https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/1395673-allowsairplayformediaplayback)) ///- MacOS ([Official API - WKWebViewConfiguration.allowsAirPlayForMediaPlayback](https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/1395673-allowsairplayformediaplayback)) bool? allowsAirPlayForMediaPlayback; ///Set to `true` to allow the horizontal swipe gestures trigger back-forward list navigations. The default value is `true`. /// - ///**Supported Platforms/Implementations**: + ///**Officially Supported Platforms/Implementations**: ///- iOS ([Official API - WKWebView.allowsBackForwardNavigationGestures](https://developer.apple.com/documentation/webkit/wkwebview/1414995-allowsbackforwardnavigationgestu)) ///- MacOS ([Official API - WKWebView.allowsBackForwardNavigationGestures](https://developer.apple.com/documentation/webkit/wkwebview/1414995-allowsbackforwardnavigationgestu)) bool? allowsBackForwardNavigationGestures; @@ -118,20 +118,20 @@ class InAppWebViewSettings { ///Set to `true` to allow HTML5 media playback to appear inline within the screen layout, using browser-supplied controls rather than native controls. ///For this to work, add the `webkit-playsinline` attribute to any `