2019-10-26 04:42:50 +02:00
import ' dart:async ' ;
import ' dart:collection ' ;
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
import ' dart:typed_data ' ;
2019-10-26 04:42:50 +02:00
import ' package:flutter/services.dart ' ;
2021-02-22 12:16:23 +01:00
import ' ../context_menu.dart ' ;
2022-04-20 01:31:14 +02:00
import ' ../pull_to_refresh/main.dart ' ;
2022-04-27 01:03:42 +02:00
import ' ../types/main.dart ' ;
2021-02-22 12:16:23 +01:00
import ' ../in_app_webview/in_app_webview_controller.dart ' ;
2022-04-20 01:31:14 +02:00
import ' ../in_app_webview/in_app_webview_settings.dart ' ;
2021-02-22 12:16:23 +01:00
2022-04-20 01:31:14 +02:00
import ' ../util.dart ' ;
import ' in_app_browser_settings.dart ' ;
2019-10-26 04:42:50 +02:00
2021-02-22 23:38:30 +01:00
class InAppBrowserAlreadyOpenedException implements Exception {
final dynamic message ;
InAppBrowserAlreadyOpenedException ( [ this . message ] ) ;
String toString ( ) {
Object ? message = this . message ;
if ( message = = null ) return " InAppBrowserAlreadyOpenedException " ;
return " InAppBrowserAlreadyOpenedException: $ message " ;
}
}
class InAppBrowserNotOpenedException implements Exception {
final dynamic message ;
InAppBrowserNotOpenedException ( [ this . message ] ) ;
String toString ( ) {
Object ? message = this . message ;
if ( message = = null ) return " InAppBrowserNotOpenedException " ;
return " InAppBrowserNotOpenedException: $ message " ;
}
}
2019-10-26 04:42:50 +02:00
///This class uses the native WebView of the platform.
2020-05-11 02:48:41 +02:00
///The [webViewController] field can be used to access the [InAppWebViewController] API.
2022-04-25 22:36:21 +02:00
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
2019-10-26 04:42:50 +02:00
class InAppBrowser {
2021-03-19 17:34:32 +01:00
///View ID used internally.
2021-03-05 23:19:50 +01:00
late final String id ;
2020-05-21 03:34:39 +02:00
2020-05-30 20:23:33 +02:00
///Context menu used by the browser. It should be set before opening the browser.
2021-01-28 17:10:15 +01:00
ContextMenu ? contextMenu ;
2020-05-21 03:34:39 +02:00
2021-03-05 23:19:50 +01:00
///Represents the pull-to-refresh feature controller.
PullToRefreshController ? pullToRefreshController ;
2021-02-01 15:55:27 +01:00
///Initial list of user scripts to be loaded at start or end of a page loading.
2021-03-05 23:19:50 +01:00
final UnmodifiableListView < UserScript > ? initialUserScripts ;
2021-02-01 15:55:27 +01:00
2019-10-26 04:42:50 +02:00
bool _isOpened = false ;
2021-01-28 17:10:15 +01:00
late MethodChannel _channel ;
2020-05-29 19:56:03 +02:00
static const MethodChannel _sharedChannel =
const MethodChannel ( ' com.pichillilorenzo/flutter_inappbrowser ' ) ;
2019-12-01 12:55:06 +01:00
2020-05-11 02:48:41 +02:00
/// WebView Controller that can be used to access the [InAppWebViewController] API.
2021-03-26 21:04:44 +01:00
late final InAppWebViewController webViewController ;
2019-10-26 04:42:50 +02:00
2021-02-22 12:16:23 +01:00
///The window id of a [CreateWindowAction.windowId].
2021-01-28 17:10:15 +01:00
final int ? windowId ;
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
2022-04-15 19:20:35 +02:00
///Represents the WebView native implementation to be used.
///The default value is [WebViewImplementation.NATIVE].
final WebViewImplementation implementation ;
2019-10-26 04:42:50 +02:00
///
2022-04-19 00:42:57 +02:00
InAppBrowser (
{ this . windowId ,
this . initialUserScripts ,
this . implementation = WebViewImplementation . NATIVE } ) {
2021-03-11 22:42:18 +01:00
id = IdGenerator . generate ( ) ;
2019-12-18 21:34:40 +01:00
this . _channel =
2021-03-01 03:21:07 +01:00
MethodChannel ( ' com.pichillilorenzo/flutter_inappbrowser_ $ id ' ) ;
2019-12-18 21:34:40 +01:00
this . _channel . setMethodCallHandler ( handleMethod ) ;
2019-10-26 04:42:50 +02:00
_isOpened = false ;
2021-02-22 23:54:09 +01:00
webViewController = new InAppWebViewController . fromInAppBrowser (
2021-03-05 23:19:50 +01:00
this . _channel , this , this . initialUserScripts ) ;
2019-10-26 04:42:50 +02:00
}
Future < dynamic > handleMethod ( MethodCall call ) async {
2019-12-01 12:55:06 +01:00
switch ( call . method ) {
2019-10-26 04:42:50 +02:00
case " onBrowserCreated " :
this . _isOpened = true ;
2021-03-05 23:19:50 +01:00
this . pullToRefreshController ? . initMethodChannel ( id ) ;
2019-10-26 04:42:50 +02:00
onBrowserCreated ( ) ;
break ;
case " onExit " :
this . _isOpened = false ;
onExit ( ) ;
break ;
default :
return webViewController . handleMethod ( call ) ;
}
}
2021-03-23 21:53:42 +01:00
///Opens the [InAppBrowser] instance with an [urlRequest].
2019-10-26 04:42:50 +02:00
///
2021-02-22 12:16:23 +01:00
///[urlRequest]: The [urlRequest] to load.
2019-11-10 14:11:30 +01:00
///
///[options]: Options for the [InAppBrowser].
2022-04-20 02:18:36 +02:00
///
///[settings]: Settings for the [InAppBrowser].
2021-02-22 12:16:23 +01:00
Future < void > openUrlRequest (
{ required URLRequest urlRequest ,
2022-04-20 03:05:46 +02:00
// ignore: deprecated_member_use_from_same_package
@ Deprecated ( ' Use settings instead ' ) InAppBrowserClassOptions ? options ,
InAppBrowserClassSettings ? settings } ) async {
2021-02-22 12:16:23 +01:00
this . throwIfAlreadyOpened ( message: ' Cannot open $ urlRequest ! ' ) ;
assert ( urlRequest . url ! = null & & urlRequest . url . toString ( ) . isNotEmpty ) ;
2019-10-27 04:35:05 +01:00
2022-04-20 03:05:46 +02:00
var initialSettings = settings ? . toMap ( ) ? ?
options ? . toMap ( ) ? ?
2022-04-20 01:31:14 +02:00
InAppBrowserClassSettings ( ) . toMap ( ) ;
2022-04-20 03:05:46 +02:00
Map < String , dynamic > pullToRefreshSettings =
pullToRefreshController ? . settings . toMap ( ) ? ?
// ignore: deprecated_member_use_from_same_package
pullToRefreshController ? . options . toMap ( ) ? ?
PullToRefreshSettings ( enabled: false ) . toMap ( ) ;
2019-10-26 04:42:50 +02:00
Map < String , dynamic > args = < String , dynamic > { } ;
2021-03-01 03:21:07 +01:00
args . putIfAbsent ( ' id ' , ( ) = > id ) ;
2021-02-22 12:16:23 +01:00
args . putIfAbsent ( ' urlRequest ' , ( ) = > urlRequest . toMap ( ) ) ;
2022-04-20 01:31:14 +02:00
args . putIfAbsent ( ' settings ' , ( ) = > initialSettings ) ;
2020-05-21 03:34:39 +02:00
args . putIfAbsent ( ' contextMenu ' , ( ) = > contextMenu ? . toMap ( ) ? ? { } ) ;
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
args . putIfAbsent ( ' windowId ' , ( ) = > windowId ) ;
2022-04-15 19:20:35 +02:00
args . putIfAbsent ( ' implementation ' , ( ) = > implementation . toValue ( ) ) ;
2021-02-22 23:54:09 +01:00
args . putIfAbsent ( ' initialUserScripts ' ,
( ) = > initialUserScripts ? . map ( ( e ) = > e . toMap ( ) ) . toList ( ) ? ? [ ] ) ;
2022-04-20 03:05:46 +02:00
args . putIfAbsent ( ' pullToRefreshSettings ' , ( ) = > pullToRefreshSettings ) ;
2021-03-05 23:19:50 +01:00
await _sharedChannel . invokeMethod ( ' open ' , args ) ;
2019-10-26 04:42:50 +02:00
}
2021-03-23 21:53:42 +01:00
///Opens the [InAppBrowser] instance with the given [assetFilePath] file.
2021-02-22 12:16:23 +01:00
///
///[options]: Options for the [InAppBrowser].
2019-10-26 04:42:50 +02:00
///
///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:
2019-11-16 12:41:30 +01:00
/// - assets/index.html
2019-10-26 04:42:50 +02:00
/// - assets/css/
/// - assets/images/
///
///...
///```
///Example of a `main.dart` file:
///```dart
///...
2021-02-22 12:16:23 +01:00
///inAppBrowser.openFile(assetFilePath: "assets/index.html");
2019-10-26 04:42:50 +02:00
///...
///```
2019-11-10 14:11:30 +01:00
///
///[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 [InAppBrowser].
2022-04-20 02:18:36 +02:00
///
///[settings]: Settings for the [InAppBrowser].
2019-12-01 12:55:06 +01:00
Future < void > openFile (
2021-01-28 17:10:15 +01:00
{ required String assetFilePath ,
2022-04-20 01:31:14 +02:00
// ignore: deprecated_member_use_from_same_package
@ Deprecated ( ' Use settings instead ' ) InAppBrowserClassOptions ? options ,
InAppBrowserClassSettings ? settings } ) async {
2021-02-22 12:16:23 +01:00
this . throwIfAlreadyOpened ( message: ' Cannot open $ assetFilePath ! ' ) ;
2021-01-28 17:10:15 +01:00
assert ( assetFilePath . isNotEmpty ) ;
2019-10-27 04:35:05 +01:00
2022-04-20 03:05:46 +02:00
var initialSettings = settings ? . toMap ( ) ? ?
options ? . toMap ( ) ? ?
2022-04-20 01:31:14 +02:00
InAppBrowserClassSettings ( ) . toMap ( ) ;
2022-04-20 03:05:46 +02:00
Map < String , dynamic > pullToRefreshSettings =
pullToRefreshController ? . settings . toMap ( ) ? ?
// ignore: deprecated_member_use_from_same_package
pullToRefreshController ? . options . toMap ( ) ? ?
PullToRefreshSettings ( enabled: false ) . toMap ( ) ;
2019-10-26 04:42:50 +02:00
Map < String , dynamic > args = < String , dynamic > { } ;
2021-03-01 03:21:07 +01:00
args . putIfAbsent ( ' id ' , ( ) = > id ) ;
2021-02-22 12:16:23 +01:00
args . putIfAbsent ( ' assetFilePath ' , ( ) = > assetFilePath ) ;
2022-04-20 01:31:14 +02:00
args . putIfAbsent ( ' settings ' , ( ) = > initialSettings ) ;
2020-05-21 03:34:39 +02:00
args . putIfAbsent ( ' contextMenu ' , ( ) = > contextMenu ? . toMap ( ) ? ? { } ) ;
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
args . putIfAbsent ( ' windowId ' , ( ) = > windowId ) ;
2022-04-15 19:20:35 +02:00
args . putIfAbsent ( ' implementation ' , ( ) = > implementation . toValue ( ) ) ;
2021-02-22 23:54:09 +01:00
args . putIfAbsent ( ' initialUserScripts ' ,
( ) = > initialUserScripts ? . map ( ( e ) = > e . toMap ( ) ) . toList ( ) ? ? [ ] ) ;
2022-04-20 03:05:46 +02:00
args . putIfAbsent ( ' pullToRefreshSettings ' , ( ) = > pullToRefreshSettings ) ;
2021-03-05 23:19:50 +01:00
await _sharedChannel . invokeMethod ( ' open ' , args ) ;
2019-10-26 04:42:50 +02:00
}
2021-03-23 21:53:42 +01:00
///Opens the [InAppBrowser] instance with [data] as a content, using [baseUrl] as the base URL for it.
2019-11-10 14:11:30 +01:00
///
2019-12-03 00:07:29 +01:00
///The [mimeType] parameter specifies the format of the data. The default value is `"text/html"`.
2019-11-10 14:11:30 +01:00
///
2019-12-03 00:07:29 +01:00
///The [encoding] parameter specifies the encoding of the data. The default value is `"utf8"`.
///
2019-12-16 23:58:10 +01:00
///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.
2019-11-10 14:11:30 +01:00
///
///The [options] parameter specifies the options for the [InAppBrowser].
2022-04-20 02:18:36 +02:00
///
///[settings]: Settings for the [InAppBrowser].
2019-12-01 12:55:06 +01:00
Future < void > openData (
2021-01-28 17:10:15 +01:00
{ required String data ,
2019-12-01 12:55:06 +01:00
String mimeType = " text/html " ,
String encoding = " utf8 " ,
2021-02-22 12:16:23 +01:00
Uri ? baseUrl ,
2022-04-20 02:18:36 +02:00
@ Deprecated ( " Use historyUrl instead " ) Uri ? androidHistoryUrl ,
Uri ? historyUrl ,
2022-04-20 01:31:14 +02:00
// ignore: deprecated_member_use_from_same_package
@ Deprecated ( ' Use settings instead ' ) InAppBrowserClassOptions ? options ,
InAppBrowserClassSettings ? settings } ) async {
2021-02-22 12:16:23 +01:00
this . throwIfAlreadyOpened ( message: ' Cannot open data! ' ) ;
2021-02-22 23:54:09 +01:00
2022-04-20 03:05:46 +02:00
var initialSettings = settings ? . toMap ( ) ? ?
options ? . toMap ( ) ? ?
2022-04-20 01:31:14 +02:00
InAppBrowserClassSettings ( ) . toMap ( ) ;
2022-04-20 03:05:46 +02:00
Map < String , dynamic > pullToRefreshSettings =
pullToRefreshController ? . settings . toMap ( ) ? ?
// ignore: deprecated_member_use_from_same_package
pullToRefreshController ? . options . toMap ( ) ? ?
PullToRefreshSettings ( enabled: false ) . toMap ( ) ;
2019-10-26 04:42:50 +02:00
Map < String , dynamic > args = < String , dynamic > { } ;
2021-03-01 03:21:07 +01:00
args . putIfAbsent ( ' id ' , ( ) = > id ) ;
2022-04-20 01:31:14 +02:00
args . putIfAbsent ( ' settings ' , ( ) = > initialSettings ) ;
2019-10-26 04:42:50 +02:00
args . putIfAbsent ( ' data ' , ( ) = > data ) ;
args . putIfAbsent ( ' mimeType ' , ( ) = > mimeType ) ;
args . putIfAbsent ( ' encoding ' , ( ) = > encoding ) ;
2021-02-22 23:38:30 +01:00
args . putIfAbsent ( ' baseUrl ' , ( ) = > baseUrl ? . toString ( ) ? ? " about:blank " ) ;
2022-04-20 03:05:46 +02:00
args . putIfAbsent ( ' historyUrl ' ,
( ) = > ( historyUrl ? ? androidHistoryUrl ) ? . toString ( ) ? ? " about:blank " ) ;
2020-05-21 03:34:39 +02:00
args . putIfAbsent ( ' contextMenu ' , ( ) = > contextMenu ? . toMap ( ) ? ? { } ) ;
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
args . putIfAbsent ( ' windowId ' , ( ) = > windowId ) ;
2022-04-15 19:20:35 +02:00
args . putIfAbsent ( ' implementation ' , ( ) = > implementation . toValue ( ) ) ;
2021-02-22 23:54:09 +01:00
args . putIfAbsent ( ' initialUserScripts ' ,
( ) = > initialUserScripts ? . map ( ( e ) = > e . toMap ( ) ) . toList ( ) ? ? [ ] ) ;
2022-04-20 03:05:46 +02:00
args . putIfAbsent ( ' pullToRefreshSettings ' , ( ) = > pullToRefreshSettings ) ;
2021-03-05 23:19:50 +01:00
await _sharedChannel . invokeMethod ( ' open ' , args ) ;
2019-10-26 04:42:50 +02:00
}
///This is a static method that opens an [url] in the system browser. You wont be able to use the [InAppBrowser] methods here!
2021-02-22 12:16:23 +01:00
static Future < void > openWithSystemBrowser ( { required Uri url } ) async {
assert ( url . toString ( ) . isNotEmpty ) ;
2019-10-26 04:42:50 +02:00
Map < String , dynamic > args = < String , dynamic > { } ;
2021-02-22 12:16:23 +01:00
args . putIfAbsent ( ' url ' , ( ) = > url . toString ( ) ) ;
2019-12-18 21:34:40 +01:00
return await _sharedChannel . invokeMethod ( ' openWithSystemBrowser ' , args ) ;
2019-10-26 04:42:50 +02:00
}
///Displays an [InAppBrowser] window that was opened hidden. Calling this has no effect if the [InAppBrowser] was already visible.
Future < void > show ( ) async {
2021-02-22 12:16:23 +01:00
this . throwIfNotOpened ( ) ;
2019-10-26 04:42:50 +02:00
Map < String , dynamic > args = < String , dynamic > { } ;
2019-12-18 21:34:40 +01:00
await _channel . invokeMethod ( ' show ' , args ) ;
2019-10-26 04:42:50 +02:00
}
///Hides the [InAppBrowser] window. Calling this has no effect if the [InAppBrowser] was already hidden.
Future < void > hide ( ) async {
2021-02-22 12:16:23 +01:00
this . throwIfNotOpened ( ) ;
2019-10-26 04:42:50 +02:00
Map < String , dynamic > args = < String , dynamic > { } ;
2019-12-18 21:34:40 +01:00
await _channel . invokeMethod ( ' hide ' , args ) ;
2019-10-26 04:42:50 +02:00
}
///Closes the [InAppBrowser] window.
Future < void > close ( ) async {
2021-02-22 12:16:23 +01:00
this . throwIfNotOpened ( ) ;
2019-10-26 04:42:50 +02:00
Map < String , dynamic > args = < String , dynamic > { } ;
2019-12-18 21:34:40 +01:00
await _channel . invokeMethod ( ' close ' , args ) ;
2019-10-26 04:42:50 +02:00
}
///Check if the Web View of the [InAppBrowser] instance is hidden.
Future < bool > isHidden ( ) async {
2021-02-22 12:16:23 +01:00
this . throwIfNotOpened ( ) ;
2019-10-26 04:42:50 +02:00
Map < String , dynamic > args = < String , dynamic > { } ;
2019-12-18 21:34:40 +01:00
return await _channel . invokeMethod ( ' isHidden ' , args ) ;
2019-10-26 04:42:50 +02:00
}
2022-04-20 01:31:14 +02:00
///Use [setSettings] instead.
@ Deprecated ( ' Use setSettings instead ' )
2021-01-28 17:10:15 +01:00
Future < void > setOptions ( { required InAppBrowserClassOptions options } ) async {
2021-02-22 12:16:23 +01:00
this . throwIfNotOpened ( ) ;
2019-10-27 04:35:05 +01:00
2019-10-26 04:42:50 +02:00
Map < String , dynamic > args = < String , dynamic > { } ;
2022-04-20 01:31:14 +02:00
args . putIfAbsent ( ' settings ' , ( ) = > options . toMap ( ) ) ;
await _channel . invokeMethod ( ' setSettings ' , args ) ;
2019-10-26 04:42:50 +02:00
}
2022-04-20 01:31:14 +02:00
///Use [getSettings] instead.
@ Deprecated ( ' Use getSettings instead ' )
2021-01-28 17:10:15 +01:00
Future < InAppBrowserClassOptions ? > getOptions ( ) async {
2021-02-22 12:16:23 +01:00
this . throwIfNotOpened ( ) ;
2019-10-26 04:42:50 +02:00
Map < String , dynamic > args = < String , dynamic > { } ;
2019-11-04 01:39:23 +01:00
2021-01-28 17:10:15 +01:00
Map < dynamic , dynamic > ? options =
2022-04-20 01:31:14 +02:00
await _channel . invokeMethod ( ' getSettings ' , args ) ;
2019-11-04 01:39:23 +01:00
if ( options ! = null ) {
2019-11-02 19:58:01 +01:00
options = options . cast < String , dynamic > ( ) ;
2021-01-28 17:10:15 +01:00
return InAppBrowserClassOptions . fromMap ( options as Map < String , dynamic > ) ;
2019-11-04 01:39:23 +01:00
}
2020-06-13 03:50:19 +02:00
return null ;
2019-10-26 04:42:50 +02:00
}
2022-04-20 01:31:14 +02:00
///Sets the [InAppBrowser] settings with the new [settings] and evaluates them.
2022-04-20 03:05:46 +02:00
Future < void > setSettings (
{ required InAppBrowserClassSettings settings } ) async {
2022-04-20 01:31:14 +02:00
this . throwIfNotOpened ( ) ;
Map < String , dynamic > args = < String , dynamic > { } ;
args . putIfAbsent ( ' settings ' , ( ) = > settings . toMap ( ) ) ;
await _channel . invokeMethod ( ' setSettings ' , args ) ;
}
///Gets the current [InAppBrowser] settings. Returns `null` if it wasn't able to get them.
Future < InAppBrowserClassSettings ? > getSettings ( ) async {
this . throwIfNotOpened ( ) ;
Map < String , dynamic > args = < String , dynamic > { } ;
Map < dynamic , dynamic > ? settings =
2022-04-20 03:05:46 +02:00
await _channel . invokeMethod ( ' getSettings ' , args ) ;
2022-04-20 01:31:14 +02:00
if ( settings ! = null ) {
settings = settings . cast < String , dynamic > ( ) ;
2022-04-20 03:05:46 +02:00
return InAppBrowserClassSettings . fromMap (
settings as Map < String , dynamic > ) ;
2022-04-20 01:31:14 +02:00
}
return null ;
}
2019-10-26 04:42:50 +02:00
///Returns `true` if the [InAppBrowser] instance is opened, otherwise `false`.
bool isOpened ( ) {
return this . _isOpened ;
}
2019-11-25 23:04:17 +01:00
///Event fired when the [InAppBrowser] is created.
2019-12-01 12:55:06 +01:00
void onBrowserCreated ( ) { }
2019-10-26 04:42:50 +02:00
2019-11-25 23:04:17 +01:00
///Event fired when the [InAppBrowser] window is closed.
2019-12-01 12:55:06 +01:00
void onExit ( ) { }
2019-11-25 23:04:17 +01:00
///Event fired when the [InAppBrowser] starts to load an [url].
2020-05-29 01:03:45 +02:00
///
2022-04-15 19:20:35 +02:00
///**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))
2021-02-22 12:16:23 +01:00
void onLoadStart ( Uri ? url ) { }
2019-10-26 04:42:50 +02:00
2019-11-25 23:04:17 +01:00
///Event fired when the [InAppBrowser] finishes loading an [url].
2020-05-29 01:03:45 +02:00
///
2022-04-15 19:20:35 +02:00
///**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))
2021-02-22 12:16:23 +01:00
void onLoadStop ( Uri ? url ) { }
2019-10-26 04:42:50 +02:00
2022-05-01 17:06:16 +02:00
///Use [onReceivedError] instead.
@ Deprecated ( " Use onReceivedError instead " )
void onLoadError ( Uri ? url , int code , String message ) { }
///Event fired when the [InAppBrowser] encounters an [error] loading a [request].
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**Supported Platforms/Implementations**:
2022-05-01 17:06:16 +02:00
///- 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)))
2022-04-20 01:31:14 +02:00
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview))
2022-05-01 17:06:16 +02:00
void onReceivedError ( WebResourceRequest request , WebResourceError error ) { }
2019-10-26 04:42:50 +02:00
2022-05-01 17:06:16 +02:00
///Use [onReceivedHttpError] instead.
@ Deprecated ( " Use onReceivedHttpError instead " )
void onLoadHttpError ( Uri ? url , int statusCode , String description ) { }
///Event fired when the [InAppBrowser] receives an HTTP error.
2019-11-21 02:19:43 +01:00
///
2022-05-01 17:06:16 +02:00
///[request] represents the originating request.
2019-11-21 02:19:43 +01:00
///
2022-05-01 17:06:16 +02:00
///[errorResponse] represents the information about the error occurred.
2019-11-21 02:19:43 +01:00
///
///**NOTE**: available on Android 23+.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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))
2022-05-01 17:06:16 +02:00
void onReceivedHttpError (
WebResourceRequest request , WebResourceResponse errorResponse ) { }
2019-11-21 02:19:43 +01:00
2019-11-25 23:04:17 +01:00
///Event fired when the current [progress] (range 0-100) of loading a page is changed.
2020-05-29 01:03:45 +02:00
///
2022-04-15 19:20:35 +02:00
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onProgressChanged](https://developer.android.com/reference/android/webkit/WebChromeClient#onProgressChanged(android.webkit.WebView,%20int)))
///- iOS
2019-12-01 12:55:06 +01:00
void onProgressChanged ( int progress ) { }
2019-10-26 04:42:50 +02:00
2019-11-25 23:04:17 +01:00
///Event fired when the [InAppBrowser] webview receives a [ConsoleMessage].
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onConsoleMessage](https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage)))
///- iOS
2019-12-01 12:55:06 +01:00
void onConsoleMessage ( ConsoleMessage consoleMessage ) { }
2019-10-26 04:42:50 +02:00
2019-12-10 00:29:09 +01:00
///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.
2022-04-20 01:31:14 +02:00
///However, if you want to cancel requests for subframes, you can use the [InAppWebViewSettings.regexToCancelSubFramesLoading] option
2019-12-10 00:29:09 +01:00
///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.
///
2021-02-22 12:16:23 +01:00
///[navigationAction] represents an object that contains information about an action that causes navigation to occur.
2019-10-26 04:42:50 +02:00
///
2022-04-20 01:31:14 +02:00
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldOverrideUrlLoading] option to `true`.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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))
2021-02-22 12:16:23 +01:00
Future < NavigationActionPolicy ? > ? shouldOverrideUrlLoading (
NavigationAction navigationAction ) { }
2019-10-26 04:42:50 +02:00
2019-11-25 23:04:17 +01:00
///Event fired when the [InAppBrowser] webview loads a resource.
2019-10-26 04:42:50 +02:00
///
2022-04-20 01:31:14 +02:00
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnLoadResource] and [InAppWebViewSettings.javaScriptEnabled] options to `true`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
2019-12-01 12:55:06 +01:00
void onLoadResource ( LoadedResource resource ) { }
2019-10-26 04:42:50 +02:00
2019-11-25 23:04:17 +01:00
///Event fired when the [InAppBrowser] webview scrolls.
2019-10-29 03:03:50 +01:00
///
2019-10-26 04:42:50 +02:00
///[x] represents the current horizontal scroll origin in pixels.
2019-10-29 03:03:50 +01:00
///
2019-10-26 04:42:50 +02:00
///[y] represents the current vertical scroll origin in pixels.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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))
2019-12-01 12:55:06 +01:00
void onScrollChanged ( int x , int y ) { }
2019-10-26 04:42:50 +02:00
2022-04-17 16:19:31 +02:00
///Use [onDownloadStartRequest] instead
2022-04-20 01:31:14 +02:00
@ Deprecated ( ' Use onDownloadStartRequest instead ' )
2022-04-17 16:19:31 +02:00
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.
2019-10-29 03:03:50 +01:00
///
2022-04-17 16:19:31 +02:00
///[downloadStartRequest] represents the request of the file to download.
2019-11-08 19:12:21 +01:00
///
2022-04-20 01:31:14 +02:00
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnDownloadStart] option to `true`.
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
///
2022-04-20 01:31:14 +02:00
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.setDownloadListener](https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener)))
///- iOS
2022-04-17 16:19:31 +02:00
void onDownloadStartRequest ( DownloadStartRequest downloadStartRequest ) { }
2019-10-26 04:42:50 +02:00
2019-11-25 23:04:17 +01:00
///Event fired when the [InAppBrowser] 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`.
2019-10-29 03:03:50 +01:00
///
2019-10-26 04:42:50 +02:00
///[scheme] represents the scheme of the url.
2019-10-29 03:03:50 +01:00
///
2019-10-26 04:42:50 +02:00
///[url] represents the url of the request.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - WKURLSchemeHandler](https://developer.apple.com/documentation/webkit/wkurlschemehandler))
2021-02-22 23:54:09 +01:00
Future < CustomSchemeResponse ? > ? onLoadResourceCustomScheme ( Uri url ) { }
2019-10-26 04:42:50 +02:00
2019-12-10 00:29:09 +01:00
///Event fired when the [InAppBrowser] 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.
2020-06-30 10:58:59 +02:00
///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`.
2019-10-29 03:03:50 +01:00
///
2021-02-22 12:16:23 +01:00
///[createWindowAction] represents the request.
2019-11-08 19:12:21 +01:00
///
2022-04-20 01:31:14 +02:00
///**NOTE**: to allow JavaScript to open windows, you need to set [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically] option to `true`.
2020-07-02 17:30:55 +02:00
///
2022-04-20 01:31:14 +02:00
///**NOTE**: on Android you need to set [InAppWebViewSettings.supportMultipleWindows] option to `true`.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**NOTE**: on iOS, setting these initial options: [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],
2022-04-26 12:16:47 +02:00
///[InAppWebViewSettings.ignoresViewportScaleLimits], [InAppWebViewSettings.limitsNavigationsToAppBoundDomains],
///[InAppWebViewSettings.upgradeKnownHostsToHTTPS],
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
///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.
2022-04-20 01:31:14 +02:00
///Also, note that calling [InAppWebViewController.setSettings] method using the controller of the new created WebView,
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
///it will update also the WebView options of the caller WebView.
///
2022-04-20 01:31:14 +02:00
///**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))
2021-02-22 12:16:23 +01:00
Future < bool ? > ? onCreateWindow ( CreateWindowAction createWindowAction ) { }
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
///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.
///
2022-04-20 01:31:14 +02:00
///**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))
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
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.
2022-04-20 01:31:14 +02:00
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
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.
2022-04-20 01:31:14 +02:00
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
void onWindowBlur ( ) { }
2019-10-29 12:16:31 +01:00
2019-11-25 23:04:17 +01:00
///Event fired when javascript calls the `alert()` method to display an alert dialog.
2019-10-29 03:03:50 +01:00
///If [JsAlertResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
///
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
///[jsAlertRequest] contains the message to be displayed in the alert dialog and the of the page requesting the dialog.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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))
2021-01-28 17:10:15 +01:00
Future < JsAlertResponse ? > ? onJsAlert ( JsAlertRequest jsAlertRequest ) { }
2019-10-29 03:03:50 +01:00
2019-11-25 23:04:17 +01:00
///Event fired when javascript calls the `confirm()` method to display a confirm dialog.
2019-10-29 03:03:50 +01:00
///If [JsConfirmResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
///
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
///[jsConfirmRequest] contains the message to be displayed in the confirm dialog and the of the page requesting the dialog.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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))
2021-01-28 17:10:15 +01:00
Future < JsConfirmResponse ? > ? onJsConfirm ( JsConfirmRequest jsConfirmRequest ) { }
2019-10-29 03:03:50 +01:00
2019-11-25 23:04:17 +01:00
///Event fired when javascript calls the `prompt()` method to display a prompt dialog.
2019-10-29 03:03:50 +01:00
///If [JsPromptResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
///
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
///[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.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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))
2021-01-28 17:10:15 +01:00
Future < JsPromptResponse ? > ? onJsPrompt ( JsPromptRequest jsPromptRequest ) { }
2019-10-29 03:03:50 +01:00
2019-11-25 23:04:17 +01:00
///Event fired when the WebView received an HTTP authentication request. The default behavior is to cancel the request.
2019-10-29 17:51:55 +01:00
///
2021-02-10 02:32:05 +01:00
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [URLAuthenticationChallenge].
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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))
2021-01-28 17:10:15 +01:00
Future < HttpAuthResponse ? > ? onReceivedHttpAuthRequest (
2021-02-10 02:32:05 +01:00
URLAuthenticationChallenge challenge ) { }
2019-10-31 23:09:54 +01:00
2019-11-25 23:04:17 +01:00
///Event fired when the WebView need to perform server trust authentication (certificate validation).
2019-11-09 23:35:18 +01:00
///The host application must return either [ServerTrustAuthResponse] instance with [ServerTrustAuthResponseAction.CANCEL] or [ServerTrustAuthResponseAction.PROCEED].
2019-10-31 23:09:54 +01:00
///
2019-11-08 19:12:21 +01:00
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ServerTrustChallenge].
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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))
2021-01-28 17:10:15 +01:00
Future < ServerTrustAuthResponse ? > ? onReceivedServerTrustAuthRequest (
2021-02-22 12:16:23 +01:00
URLAuthenticationChallenge challenge ) { }
2019-10-31 23:09:54 +01:00
2019-12-01 12:55:06 +01:00
///Notify the host application to handle an SSL client certificate request.
2019-11-08 19:12:21 +01:00
///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.
2019-10-31 23:09:54 +01:00
///
2019-11-08 19:12:21 +01:00
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ClientCertChallenge].
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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))
2021-01-28 17:10:15 +01:00
Future < ClientCertResponse ? > ? onReceivedClientCertRequest (
2021-02-22 12:16:23 +01:00
URLAuthenticationChallenge challenge ) { }
2019-10-29 17:51:55 +01:00
2019-11-02 04:16:47 +01:00
///Event fired as find-on-page operations progress.
2022-04-15 19:20:35 +02:00
///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.
2019-11-02 04:16:47 +01:00
///
///[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.
2020-05-29 01:03:45 +02:00
///
2022-04-15 19:20:35 +02:00
///**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
2019-12-01 12:55:06 +01:00
void onFindResultReceived (
int activeMatchOrdinal , int numberOfMatches , bool isDoneCounting ) { }
2019-11-02 04:16:47 +01:00
2019-11-08 19:12:21 +01:00
///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.
2019-11-06 00:23:24 +01:00
///
2019-11-08 19:12:21 +01:00
///[ajaxRequest] represents the `XMLHttpRequest`.
///
2022-04-20 01:31:14 +02:00
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] option 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
2021-01-28 17:10:15 +01:00
Future < AjaxRequest ? > ? shouldInterceptAjaxRequest ( AjaxRequest ajaxRequest ) { }
2019-11-06 00:23:24 +01:00
2019-11-08 19:12:21 +01:00
///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].
2019-11-06 00:23:24 +01:00
///
2022-04-20 01:31:14 +02:00
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] option 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
2021-01-28 17:10:15 +01:00
Future < AjaxRequestAction ? > ? onAjaxReadyStateChange ( AjaxRequest ajaxRequest ) { }
2019-11-06 00:23:24 +01:00
2019-11-08 19:12:21 +01:00
///Event fired as an `XMLHttpRequest` progress.
///It gives the host application a chance to abort the request.
2019-11-06 00:23:24 +01:00
///
2019-11-08 19:12:21 +01:00
///[ajaxRequest] represents the [XMLHttpRequest].
///
2022-04-20 01:31:14 +02:00
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] option 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
2021-01-28 17:10:15 +01:00
Future < AjaxRequestAction ? > ? onAjaxProgress ( AjaxRequest ajaxRequest ) { }
2019-11-06 00:23:24 +01:00
2019-11-25 23:04:17 +01:00
///Event fired when a request is sent to a server through [Fetch API](https://developer.mozilla.org/it/docs/Web/API/Fetch_API).
2019-11-08 19:12:21 +01:00
///It gives the host application a chance to take control over the request before sending it.
///
///[fetchRequest] represents a resource request.
2019-11-06 00:23:24 +01:00
///
2022-04-20 01:31:14 +02:00
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptFetchRequest] option 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
2021-02-22 23:54:09 +01:00
Future < FetchRequest ? > ? shouldInterceptFetchRequest (
FetchRequest fetchRequest ) { }
2019-11-06 00:23:24 +01:00
2019-12-16 23:58:10 +01:00
///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).
2019-11-06 00:23:24 +01:00
///
2019-12-16 23:58:10 +01:00
///[url] represents the url being visited.
2019-11-06 00:23:24 +01:00
///
2022-04-20 01:31:14 +02:00
///[isReload] indicates if this url is being reloaded. Available only on Android.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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
void onUpdateVisitedHistory ( Uri ? url , bool ? isReload ) { }
2019-12-16 23:58:10 +01:00
///Event fired when `window.print()` is called from JavaScript side.
///
///[url] represents the url on which is called.
///
2022-04-15 19:20:35 +02:00
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
2021-02-22 12:16:23 +01:00
void onPrint ( Uri ? url ) { }
2019-12-16 23:58:10 +01:00
2020-05-09 04:36:07 +02:00
///Event fired when an HTML element of the webview has been clicked and held.
///
///[hitTestResult] represents the hit result for hitting an HTML elements.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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))
2020-05-21 03:34:39 +02:00
void onLongPressHitTestResult ( InAppWebViewHitTestResult hitTestResult ) { }
2020-05-09 04:36:07 +02:00
2020-05-23 19:33:54 +02:00
///Event fired when the current page has entered full screen mode.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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))
2020-05-23 19:33:54 +02:00
void onEnterFullscreen ( ) { }
///Event fired when the current page has exited full screen mode.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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))
2020-05-23 19:33:54 +02:00
void onExitFullscreen ( ) { }
2020-05-29 01:03:45 +02:00
///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.
///
2022-04-20 01:31:14 +02:00
///**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))
2021-02-22 12:16:23 +01:00
void onPageCommitVisible ( Uri ? url ) { }
2020-05-29 01:03:45 +02:00
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
///Event fired when a change in the document title occurred.
///
///[title] represents the string containing the new title of the document.
///
2022-04-20 01:31:14 +02:00
///**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
2021-01-28 17:10:15 +01:00
void onTitleChanged ( String ? title ) { }
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
2021-03-22 16:21:56 +01:00
///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.
///
2022-04-20 01:31:14 +02:00
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.onOverScrolled](https://developer.android.com/reference/android/webkit/WebView#onOverScrolled(int,%20int,%20boolean,%20boolean)))
///- iOS
2021-03-22 16:21:56 +01:00
void onOverScrolled ( int x , int y , bool clampedX , bool clampedY ) { }
2021-03-26 21:04:44 +01:00
///Event fired when the zoom scale of the WebView has changed.
///
///[oldScale] The old zoom scale factor.
///
2022-04-20 01:31:14 +02:00
///[newScale] The new zoom scale factor.ì
2021-03-26 21:04:44 +01:00
///
2022-04-20 01:31:14 +02:00
///**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))
2021-03-26 21:04:44 +01:00
void onZoomScaleChanged ( double oldScale , double newScale ) { }
2022-04-20 01:31:14 +02:00
///Use [onSafeBrowsingHit] instead.
@ Deprecated ( " Use onSafeBrowsingHit instead " )
Future < SafeBrowsingResponse ? > ? androidOnSafeBrowsingHit (
Uri url , SafeBrowsingThreat ? threatType ) { }
2019-12-16 23:58:10 +01:00
///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+.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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 < SafeBrowsingResponse ? > ? onSafeBrowsingHit (
2021-02-22 12:16:23 +01:00
Uri url , SafeBrowsingThreat ? threatType ) { }
2019-11-06 00:23:24 +01:00
2022-04-20 01:31:14 +02:00
///Use [onPermissionRequest] instead.
@ Deprecated ( " Use onPermissionRequest instead " )
Future < PermissionRequestResponse ? > ? androidOnPermissionRequest (
String origin , List < String > resources ) { }
2019-11-28 02:39:06 +01:00
///Event fired when the WebView is requesting permission to access the specified resources and the permission currently isn't granted or denied.
///
///[origin] represents the origin of the web page which is trying to access the restricted resources.
///
///[resources] represents the array of resources the web content wants to access.
///
///**NOTE**: available only on Android 23+.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onPermissionRequest](https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest)))
2022-04-21 12:20:48 +02:00
Future < PermissionResponse ? > ? onPermissionRequest (
PermissionRequest permissionRequest ) { }
2019-11-28 02:39:06 +01:00
2022-04-20 01:31:14 +02:00
///Use [onGeolocationPermissionsShowPrompt] instead.
@ Deprecated ( " Use onGeolocationPermissionsShowPrompt instead " )
Future < GeolocationPermissionShowPromptResponse ? > ?
androidOnGeolocationPermissionsShowPrompt ( String origin ) { }
2019-12-16 23:58:10 +01:00
///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.
2019-12-10 00:29:09 +01:00
///
2019-12-16 23:58:10 +01:00
///[origin] represents the origin of the web content attempting to use the Geolocation API.
2019-12-10 00:29:09 +01:00
///
2022-04-20 01:31:14 +02:00
///**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)))
2021-01-28 17:10:15 +01:00
Future < GeolocationPermissionShowPromptResponse ? > ?
2022-04-20 03:05:46 +02:00
onGeolocationPermissionsShowPrompt ( String origin ) { }
2019-12-16 23:58:10 +01:00
2022-04-20 01:31:14 +02:00
///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.
2019-12-16 23:58:10 +01:00
///Any related UI should therefore be hidden.
///
2022-04-20 01:31:14 +02:00
///**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 < WebResourceResponse ? > ? androidShouldInterceptRequest (
WebResourceRequest request ) { }
2019-12-10 00:29:09 +01:00
2020-05-29 01:03:45 +02:00
///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.
2020-05-09 04:36:07 +02:00
///
2020-05-29 01:03:45 +02:00
///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.
///
2022-04-20 01:31:14 +02:00
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptRequest] option to `true`.
2020-05-29 01:03:45 +02:00
///
2022-04-20 01:31:14 +02:00
///**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 < WebResourceResponse ? > ? shouldInterceptRequest (
2021-02-22 23:54:09 +01:00
WebResourceRequest request ) { }
2020-05-09 04:36:07 +02:00
2022-04-20 01:31:14 +02:00
///Use [onRenderProcessUnresponsive] instead.
@ Deprecated ( " Use onRenderProcessUnresponsive instead " )
Future < WebViewRenderProcessAction ? > ? androidOnRenderProcessUnresponsive (
Uri ? url ) { }
2020-05-29 01:03:45 +02:00
///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.
2022-04-20 01:31:14 +02:00
///If the renderer becomes responsive again, [onRenderProcessResponsive] will be called once,
2020-05-29 01:03:45 +02:00
///and this method will not subsequently be called unless another period of unresponsiveness is detected.
///
2022-04-20 01:31:14 +02:00
///The minimum interval between successive calls to [onRenderProcessUnresponsive] is 5 seconds.
2020-05-29 01:03:45 +02:00
///
///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,
2022-04-20 01:31:14 +02:00
///if in multiprocess mode, however this must be accompanied by correctly handling [onRenderProcessGone] for this WebView,
2020-05-29 01:03:45 +02:00
///and all other WebViews associated with the same renderer. Failure to do so will result in application termination.
///
///**NOTE**: available only on Android 29+.
///
2022-04-20 01:31:14 +02:00
///**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)))
2022-04-20 03:05:46 +02:00
Future < WebViewRenderProcessAction ? > ? onRenderProcessUnresponsive ( Uri ? url ) { }
2022-04-20 01:31:14 +02:00
///Use [onRenderProcessResponsive] instead.
@ Deprecated ( " Use onRenderProcessResponsive instead " )
Future < WebViewRenderProcessAction ? > ? androidOnRenderProcessResponsive (
2021-02-22 23:54:09 +01:00
Uri ? url ) { }
2020-05-29 01:03:45 +02:00
///Event called once when an unresponsive renderer currently associated with the WebView becomes responsive.
///
2022-04-20 01:31:14 +02:00
///After a WebView renderer becomes unresponsive, which is notified to the application by [onRenderProcessUnresponsive],
2020-05-29 01:03:45 +02:00
///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+.
///
2022-04-20 01:31:14 +02:00
///**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)))
2022-04-20 03:05:46 +02:00
Future < WebViewRenderProcessAction ? > ? onRenderProcessResponsive ( Uri ? url ) { }
2020-05-29 01:03:45 +02:00
2022-04-20 01:31:14 +02:00
///Use [onRenderProcessGone] instead.
@ Deprecated ( " Use onRenderProcessGone instead " )
void androidOnRenderProcessGone ( RenderProcessGoneDetail detail ) { }
2020-05-29 01:03:45 +02:00
///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+.
///
2022-04-20 01:31:14 +02:00
///**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 < FormResubmissionAction ? > ? androidOnFormResubmission ( Uri ? url ) { }
2020-05-29 01:03:45 +02:00
///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.
///
2022-04-20 01:31:14 +02:00
///**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 < FormResubmissionAction ? > ? onFormResubmission ( Uri ? url ) { }
2020-05-29 01:03:45 +02:00
2021-03-26 21:04:44 +01:00
///Use [onZoomScaleChanged] instead.
2022-04-20 01:31:14 +02:00
@ Deprecated ( ' Use onZoomScaleChanged instead ' )
2020-05-29 01:03:45 +02:00
void androidOnScaleChanged ( double oldScale , double newScale ) { }
2022-04-20 01:31:14 +02:00
///Use [onReceivedIcon] instead.
@ Deprecated ( ' Use onReceivedIcon instead ' )
void androidOnReceivedIcon ( Uint8List icon ) { }
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
///Event fired when there is new favicon for the current page.
///
///[icon] represents the favicon for the current page.
///
2022-04-20 01:31:14 +02:00
///**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 ) { }
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
///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.
///
2022-04-20 01:31:14 +02:00
///**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 ( Uri url , bool precomposed ) { }
///Use [onJsBeforeUnload] instead.
@ Deprecated ( ' Use onJsBeforeUnload instead ' )
Future < JsBeforeUnloadResponse ? > ? androidOnJsBeforeUnload (
JsBeforeUnloadRequest jsBeforeUnloadRequest ) { }
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
///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.
///
2022-04-20 01:31:14 +02:00
///**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 < JsBeforeUnloadResponse ? > ? onJsBeforeUnload (
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
JsBeforeUnloadRequest jsBeforeUnloadRequest ) { }
2022-04-20 01:31:14 +02:00
///Use [onReceivedLoginRequest] instead.
@ Deprecated ( ' Use onReceivedLoginRequest instead ' )
void androidOnReceivedLoginRequest ( LoginRequest loginRequest ) { }
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
///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.
///
2022-04-20 01:31:14 +02:00
///**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 ) { }
///Use [onWebContentProcessDidTerminate] instead.
@ Deprecated ( ' Use onWebContentProcessDidTerminate instead ' )
void iosOnWebContentProcessDidTerminate ( ) { }
Updated onCreateWindow, onJsAlert, onJsConfirm, and onJsPrompt webview events, added onCloseWindow, onTitleChanged, onWindowFocus, and onWindowBlur webview events, added androidOnRequestFocus, androidOnReceivedIcon, androidOnReceivedTouchIconUrl, androidOnJsBeforeUnload, and androidOnReceivedLoginRequest Android-specific webview events, fix #403
2020-06-29 16:34:08 +02:00
2020-05-29 01:03:45 +02:00
///Invoked when the web view's web content process is terminated.
2020-05-09 04:36:07 +02:00
///
2022-04-20 01:31:14 +02:00
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi))
void onWebContentProcessDidTerminate ( ) { }
///Use [onDidReceiveServerRedirectForProvisionalNavigation] instead.
@ Deprecated ( ' Use onDidReceiveServerRedirectForProvisionalNavigation instead ' )
void iosOnDidReceiveServerRedirectForProvisionalNavigation ( ) { }
2020-05-09 04:36:07 +02:00
///Called when a web view receives a server redirect.
///
2022-04-20 01:31:14 +02:00
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview))
void onDidReceiveServerRedirectForProvisionalNavigation ( ) { }
///Use [onNavigationResponse] instead.
@ Deprecated ( ' Use onNavigationResponse instead ' )
Future < IOSNavigationResponseAction ? > ? iosOnNavigationResponse (
IOSWKNavigationResponse navigationResponse ) { }
2020-05-09 04:36:07 +02:00
2021-02-10 00:15:10 +01:00
///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.
///
2022-04-20 01:31:14 +02:00
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnNavigationResponse] option to `true`.
2021-02-10 00:15:10 +01:00
///
2022-04-20 01:31:14 +02:00
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
Future < NavigationResponseAction ? > ? onNavigationResponse (
NavigationResponse navigationResponse ) { }
///Use [shouldAllowDeprecatedTLS] instead.
@ Deprecated ( ' Use shouldAllowDeprecatedTLS instead ' )
Future < IOSShouldAllowDeprecatedTLSAction ? > ? iosShouldAllowDeprecatedTLS (
URLAuthenticationChallenge challenge ) { }
2021-02-10 00:15:10 +01:00
2021-02-10 02:32:05 +01:00
///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**: available only on iOS 14.0+.
///
2022-04-20 01:31:14 +02:00
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview))
Future < ShouldAllowDeprecatedTLSAction ? > ? shouldAllowDeprecatedTLS (
2021-02-22 23:54:09 +01:00
URLAuthenticationChallenge challenge ) { }
2021-02-10 02:32:05 +01:00
2021-02-22 12:16:23 +01:00
void throwIfAlreadyOpened ( { String message = ' ' } ) {
2019-10-26 04:42:50 +02:00
if ( this . isOpened ( ) ) {
2021-02-22 23:38:30 +01:00
throw InAppBrowserAlreadyOpenedException ( [
2019-12-01 12:55:06 +01:00
' Error: ${ ( message . isEmpty ) ? ' ' : message + ' ' } The browser is already opened. '
] ) ;
2019-10-26 04:42:50 +02:00
}
}
2021-02-22 12:16:23 +01:00
void throwIfNotOpened ( { String message = ' ' } ) {
2019-10-26 04:42:50 +02:00
if ( ! this . isOpened ( ) ) {
2021-02-22 23:38:30 +01:00
throw InAppBrowserNotOpenedException ( [
2019-12-01 12:55:06 +01:00
' Error: ${ ( message . isEmpty ) ? ' ' : message + ' ' } The browser is not opened. '
] ) ;
2019-10-26 04:42:50 +02:00
}
}
}