Commit 6677917b authored by Lorenzo Pichilli's avatar Lorenzo Pichilli

Added onPermissionRequest event (available only on Android), new plugin version 2.0.1

parent b0224c74
This diff is collapsed.
...@@ -420,7 +420,7 @@ class InAppBrowser { ...@@ -420,7 +420,7 @@ class InAppBrowser {
} }
///Event fired when the webview notifies that a loading URL has been flagged by Safe Browsing. ///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. ///The default behavior is to show an interstitial to the user, with the reporting checkbox visible.
/// ///
///[url] represents the url of the request. ///[url] represents the url of the request.
...@@ -517,7 +517,7 @@ class InAppBrowser { ...@@ -517,7 +517,7 @@ class InAppBrowser {
} }
///Event fired when the navigation state of the [InAppWebView] changes throught the usage of ///Event fired when the navigation state of the WebView changes throught the usage of
///javascript **[History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API)** functions (`pushState()`, `replaceState()`) and `onpopstate` event. ///javascript **[History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API)** functions (`pushState()`, `replaceState()`) and `onpopstate` event.
/// ///
///Also, the event is fired when the javascript `window.location` changes without reloading the webview (for example appending or modifying an hash to the url). ///Also, the event is fired when the javascript `window.location` changes without reloading the webview (for example appending or modifying an hash to the url).
...@@ -527,6 +527,17 @@ class InAppBrowser { ...@@ -527,6 +527,17 @@ class InAppBrowser {
} }
///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+.
Future<PermissionRequestResponse> onPermissionRequest(String origin, List<String> resources) {
}
void throwIsAlreadyOpened({String message = ''}) { void throwIsAlreadyOpened({String message = ''}) {
if (this.isOpened()) { if (this.isOpened()) {
throw Exception(['Error: ${ (message.isEmpty) ? '' : message + ' '}The browser is already opened.']); throw Exception(['Error: ${ (message.isEmpty) ? '' : message + ' '}The browser is already opened.']);
......
...@@ -214,7 +214,7 @@ class InAppWebView extends StatefulWidget { ...@@ -214,7 +214,7 @@ class InAppWebView extends StatefulWidget {
///[url] represents the new url. ///[url] represents the new url.
final void Function(InAppWebViewController controller, String url) onNavigationStateChange; final void Function(InAppWebViewController controller, String url) onNavigationStateChange;
///Event fired when the webview is requesting permission to access the specified resources and the permission currently isn't granted or denied. ///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. ///[origin] represents the origin of the web page which is trying to access the restricted resources.
/// ///
...@@ -596,8 +596,8 @@ class InAppWebViewController { ...@@ -596,8 +596,8 @@ class InAppWebViewController {
List<String> resources = call.arguments["resources"].cast<String>(); List<String> resources = call.arguments["resources"].cast<String>();
if (_widget != null && _widget.onPermissionRequest != null) if (_widget != null && _widget.onPermissionRequest != null)
return (await _widget.onPermissionRequest(this, origin, resources))?.toMap(); return (await _widget.onPermissionRequest(this, origin, resources))?.toMap();
/*else if (_inAppBrowser != null) else if (_inAppBrowser != null)
return (await _inAppBrowser.onPermissionRequest(origin, resources))?.toMap();*/ return (await _inAppBrowser.onPermissionRequest(origin, resources))?.toMap();
break; break;
case "onCallJsHandler": case "onCallJsHandler":
String handlerName = call.arguments["handlerName"]; String handlerName = call.arguments["handlerName"];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment