Skip to content

Commit

Permalink
Added onPermissionRequest event (available only on Android), new plug…
Browse files Browse the repository at this point in the history
…in version 2.0.1
  • Loading branch information
pichillilorenzo committed Nov 28, 2019
1 parent b0224c7 commit 6677917
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 50 deletions.
95 changes: 50 additions & 45 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions lib/src/in_app_browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
///[url] represents the url of the request.
Expand Down Expand Up @@ -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.
///
///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).
Expand All @@ -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 = ''}) {
if (this.isOpened()) {
throw Exception(['Error: ${ (message.isEmpty) ? '' : message + ' '}The browser is already opened.']);
Expand Down
6 changes: 3 additions & 3 deletions lib/src/in_app_webview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class InAppWebView extends StatefulWidget {
///[url] represents the new url.
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.
///
Expand Down Expand Up @@ -596,8 +596,8 @@ class InAppWebViewController {
List<String> resources = call.arguments["resources"].cast<String>();
if (_widget != null && _widget.onPermissionRequest != null)
return (await _widget.onPermissionRequest(this, origin, resources))?.toMap();
/*else if (_inAppBrowser != null)
return (await _inAppBrowser.onPermissionRequest(origin, resources))?.toMap();*/
else if (_inAppBrowser != null)
return (await _inAppBrowser.onPermissionRequest(origin, resources))?.toMap();
break;
case "onCallJsHandler":
String handlerName = call.arguments["handlerName"];
Expand Down

0 comments on commit 6677917

Please sign in to comment.