Commit 208d6c73 authored by Lorenzo Pichilli's avatar Lorenzo Pichilli

added onPageCommitVisible event, updated dart code for new events and methods,...

added onPageCommitVisible event, updated dart code for new events and methods, updated docs, fix #367
parent 6c97be36
......@@ -5,18 +5,21 @@
- Added Android keyboard workaround to hide the keyboard when clicking other HTML elements, losing the focus on the previous input
- Added `onEnterFullscreen`, `onExitFullscreen` webview events [#275](https://github.com/pichillilorenzo/flutter_inappwebview/issues/275)
- Added Android support to use camera on HTML inputs that requires it, such as `<input type="file" accept="image/*" capture>` [#353](https://github.com/pichillilorenzo/flutter_inappwebview/issues/353)
- Added `overScrollMode`, `networkAvailable`, `scrollBarStyle`, `verticalScrollbarPosition`, `scrollBarDefaultDelayBeforeFade`, `scrollbarFadingEnabled`, `scrollBarFadeDuration`, `rendererPriorityPolicy` webview options on Android
- Added `overScrollMode`, `networkAvailable`, `scrollBarStyle`, `verticalScrollbarPosition`, `scrollBarDefaultDelayBeforeFade`, `scrollbarFadingEnabled`, `scrollBarFadeDuration`, `rendererPriorityPolicy`, `useShouldInterceptRequest`, `useOnRenderProcessGone` webview options on Android
- Added `pageDown`, `pageUp`, `saveWebArchive`, `zoomIn`, `zoomOut` webview methods on Android
- Added `getCurrentWebViewPackage` static webview method on Android
- Added `shouldInterceptRequest`, `onRenderProcessUnresponsive`, `onRenderProcessResponsive`, `onRenderProcessGone`, `onFormResubmission`, `onPageCommitVisible`, `onScaleChanged` Android events
- Added `onPageCommitVisible` webview event
- Added `androidShouldInterceptRequest`, `androidOnRenderProcessUnresponsive`, `androidOnRenderProcessResponsive`, `androidOnRenderProcessGone`, `androidOnFormResubmission`, `androidOnScaleChanged` Android events
- Fixed `Print preview is not working? java.lang.IllegalStateException: Can print only from an activity` [#128](https://github.com/pichillilorenzo/flutter_inappwebview/issues/128)
- Fixed `onJsAlert`, `onJsConfirm`, `onJsPrompt` for `InAppBrowser` on Android
- Fixed `onActivityResult` for `InAppBrowser` on Android
- Fixed `InAppBrowser.openWithSystemBrowser crash on iOS` [#358](https://github.com/pichillilorenzo/flutter_inappwebview/issues/358)
- Fixed `Attempt to invoke virtual method 'java.util.Set java.util.HashMap.entrySet()' on a null object reference` [#367](https://github.com/pichillilorenzo/flutter_inappwebview/issues/367)
### BREAKING CHANGES
- Android `clearClientCertPreferences`, `getSafeBrowsingPrivacyPolicyUrl`, `setSafeBrowsingWhitelist` webview methods are static now
- Removed iOS event `onDidCommit`; it has been renamed to `onPageCommitVisible` and made cross-platform
## 3.2.0
......
......@@ -407,13 +407,19 @@ Screenshots:
Android-specific methods can be called using the `InAppWebViewController.android` attribute.
* `startSafeBrowsing`: Starts Safe Browsing initialization.
* `setSafeBrowsingWhitelist({@required List<String> hosts})`: Sets the list of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks. The list is global for all the WebViews.
* `getSafeBrowsingPrivacyPolicyUrl`: Returns a URL pointing to the privacy policy for Safe Browsing reporting. This value will never be `null`.
* `clearSslPreferences`: Clears the SSL preferences table stored in response to proceeding with SSL certificate errors.
* `clearClientCertPreferences`: Clears the client certificate preferences stored in response to proceeding/cancelling client cert requests.
* `pause`: 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.
* `resume`: Resumes a WebView after a previous call to `pause()`.
* `getOriginalUrl`: Gets the URL that was originally requested for the current page.
* `pageDown({@required bool bottom})`: Scrolls the contents of this WebView down by half the page size.
* `pageUp({@required bool top})`: Scrolls the contents of this WebView up by half the view size.
* `saveWebArchive({@required String basename, @required bool autoname})`: Saves the current view as a web archive.
* `zoomIn`: Performs zoom in in this WebView.
* `zoomOut`: Performs zoom out in this WebView.
* `static clearClientCertPreferences`: Clears the client certificate preferences stored in response to proceeding/cancelling client cert requests.
* `static getSafeBrowsingPrivacyPolicyUrl`: Returns a URL pointing to the privacy policy for Safe Browsing reporting. This value will never be `null`.
* `static setSafeBrowsingWhitelist({@required List<String> hosts})`: Sets the list of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks. The list is global for all the WebViews.
* `static getCurrentWebViewPackage()`: Gets the current Android WebView package info.
##### `InAppWebViewController` iOS-specific methods
......@@ -474,6 +480,8 @@ Instead, on the `onLoadStop` WebView event, you can use `callHandler` directly:
* `useShouldOverrideUrlLoading`: Set to `true` to be able to listen at the `shouldOverrideUrlLoading` event. The default value is `false`.
* `useOnLoadResource`: Set to `true` to be able to listen at the `onLoadResource` event. The default value is `false`.
* `useOnDownloadStart`: Set to `true` to be able to listen at the `onDownloadStart` event. The default value is `false`.
* `useShouldInterceptAjaxRequest`: Set to `true` to be able to listen at the `shouldInterceptAjaxRequest` event. The default value is `false`.
* `useShouldInterceptFetchRequest`: Set to `true` to be able to listen at the `shouldInterceptFetchRequest` event. The default value is `false`.
* `clearCache`: Set to `true` to have all the browser's cache cleared before the new window is opened. The default value is `false`.
* `userAgent`: Sets the user-agent for the WebView.
* `applicationNameForUserAgent`: Append to the existing user-agent. Setting userAgent will override this.
......@@ -487,8 +495,6 @@ Instead, on the `onLoadStop` WebView event, you can use `callHandler` directly:
* `resourceCustomSchemes`: List of custom schemes that the WebView must handle. Use the `onLoadResourceCustomScheme` event to intercept resource requests with custom scheme.
* `contentBlockers`: List of `ContentBlocker` that are a set of rules used to block content in the browser window.
* `preferredContentMode`: Sets the content mode that the WebView needs to use when loading and rendering a webpage. The default value is `InAppWebViewUserPreferredContentMode.RECOMMENDED`.
* `useShouldInterceptAjaxRequest`: Set to `true` to be able to listen at the `shouldInterceptAjaxRequest` event. The default value is `false`.
* `useShouldInterceptFetchRequest`: Set to `true` to be able to listen at the `shouldInterceptFetchRequest` event. The default value is `false`.
* `incognito`: Set to `true` to open a browser window with incognito mode. The default value is `false`.
* `cacheEnabled`: Sets whether WebView should use browser caching. The default value is `true`.
* `transparentBackground`: Set to `true` to make the background of the WebView transparent. If your app has a dark theme, this can prevent a white flash on initialization. The default value is `false`.
......@@ -498,6 +504,8 @@ Instead, on the `onLoadStop` WebView event, you can use `callHandler` directly:
##### `InAppWebView` Android-specific options
* `useShouldInterceptRequest`: Set to `true` to be able to listen at the `androidShouldInterceptRequest` event. The default value is `false`.
* `useOnRenderProcessGone`: Set to `true` to be able to listen at the `androidOnRenderProcessGone` event. The default value is `false`.
* `textZoom`: Sets the text zoom of the page in percent. The default value is `100`.
* `clearSessionCache`: Set to `true` to have the session cookie cache cleared before the new window is opened.
* `builtInZoomControls`: Set to `true` if the WebView should use its built-in zoom mechanisms. The default value is `false`.
......@@ -540,6 +548,13 @@ Instead, on the `onLoadStop` WebView event, you can use `callHandler` directly:
* `hardwareAcceleration`: Boolean value to enable Hardware Acceleration in the WebView.
* `supportMultipleWindows`: Sets whether the WebView whether supports multiple windows.
* `regexToCancelSubFramesLoading`: Regular expression used by `shouldOverrideUrlLoading` event to cancel navigation 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.
* `overScrollMode`: Sets the WebView's over-scroll mode. The default value is `AndroidOverScrollMode.OVER_SCROLL_IF_CONTENT_SCROLLS`.
* `scrollBarStyle`: Specify the style of the scrollbars. The scrollbars can be overlaid or inset. The default value is `AndroidScrollBarStyle.SCROLLBARS_INSIDE_OVERLAY`.
* `verticalScrollbarPosition`: Set the position of the vertical scroll bar. The default value is `AndroidVerticalScrollbarPosition.SCROLLBAR_POSITION_DEFAULT`.
* `scrollBarDefaultDelayBeforeFade`: Defines the delay in milliseconds that a scrollbar waits before fade out.
* `scrollbarFadingEnabled`: Define whether scrollbars will fade when the view is not scrolling. The default value is `true`.
* `scrollBarFadeDuration`: Define the scrollbar fade duration in milliseconds.
* `rendererPriorityPolicy`: Set the renderer priority policy for this WebView.
##### `InAppWebView` iOS-specific options
......@@ -599,12 +614,18 @@ Event names that starts with `android` or `ios` are events platform-specific.
* `onLongPressHitTestResult`: Event fired when an HTML element of the webview has been clicked and held.
* `onEnterFullscreen`: Event fired when the current page has entered full screen mode.
* `onExitFullscreen`: Event fired when the current page has exited full screen mode.
* `onPageCommitVisible`: Called when the web view begins to receive web content.
* `androidOnSafeBrowsingHit`: Event fired when the webview notifies that a loading URL has been flagged by Safe Browsing (available only on Android).
* `androidOnPermissionRequest`: Event fired when the webview is requesting permission to access the specified resources and the permission currently isn't granted or denied (available only on Android).
* `androidOnGeolocationPermissionsShowPrompt`: 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 (available only on Android).
* `androidOnGeolocationPermissionsHidePrompt`: Notify the host application that a request for Geolocation permissions, made with a previous call to `androidOnGeolocationPermissionsShowPrompt` has been canceled. (available only on Android).
* `androidOnGeolocationPermissionsHidePrompt`: Notify the host application that a request for Geolocation permissions, made with a previous call to `androidOnGeolocationPermissionsShowPrompt` has been canceled (available only on Android).
* `androidShouldInterceptRequest`: Notify the host application of a resource request and allow the application to return the data (available only on Android).
* `androidOnRenderProcessGone`: Event fired when the given WebView's render process has exited (available only on Android).
* `androidOnRenderProcessResponsive`: Event called once when an unresponsive renderer currently associated with the WebView becomes responsive (available only on Android).
* `androidOnRenderProcessUnresponsive`: 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 (available only on Android).
* `androidOnFormResubmission`: 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 (available only on Android).
* `androidOnScaleChanged`: Event fired when the scale applied to the WebView has changed (available only on Android).
* `iosOnWebContentProcessDidTerminate`: Invoked when the web view's web content process is terminated (available only on iOS).
* `iosOnDidCommit`: Called when the web view begins to receive web content (available only on iOS).
* `iosOnDidReceiveServerRedirectForProvisionalNavigation`: Called when a web view receives a server redirect (available only on iOS).
### `ContextMenu` class
......
package com.pichillilorenzo.flutter_inappwebview.InAppBrowser;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Picture;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
......@@ -32,8 +29,6 @@ import com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebViewOptions
import com.pichillilorenzo.flutter_inappwebview.R;
import com.pichillilorenzo.flutter_inappwebview.Shared;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -345,6 +340,31 @@ public class InAppBrowserActivity extends AppCompatActivity implements MethodCha
case "getHitTestResult":
result.success(getHitTestResult());
break;
case "pageDown":
{
boolean bottom = (boolean) call.argument("bottom");
result.success(pageDown(bottom));
}
break;
case "pageUp":
{
boolean top = (boolean) call.argument("top");
result.success(pageUp(top));
}
break;
case "saveWebArchive":
{
String basename = (String) call.argument("basename");
boolean autoname = (boolean) call.argument("autoname");
saveWebArchive(basename, autoname, result);
}
break;
case "zoomIn":
result.success(zoomIn());
break;
case "zoomOut":
result.success(zoomOut());
break;
default:
result.notImplemented();
}
......@@ -852,6 +872,43 @@ public class InAppBrowserActivity extends AppCompatActivity implements MethodCha
return null;
}
public boolean pageDown(boolean bottom) {
if (webView != null)
return webView.pageDown(bottom);
return false;
}
public boolean pageUp(boolean top) {
if (webView != null)
return webView.pageUp(top);
return false;
}
public void saveWebArchive(String basename, boolean autoname, final MethodChannel.Result result) {
if (webView != null) {
webView.saveWebArchive(basename, autoname, new ValueCallback<String>() {
@Override
public void onReceiveValue(String value) {
result.success(value);
}
});
} else {
result.success(null);
}
}
public boolean zoomIn() {
if (webView != null)
return webView.zoomIn();
return false;
}
public boolean zoomOut() {
if (webView != null)
return webView.zoomOut();
return false;
}
public void dispose() {
channel.setMethodCallHandler(null);
activityResultListeners.clear();
......
......@@ -396,9 +396,6 @@ public class FlutterWebView implements PlatformView, MethodCallHandler {
result.success(null);
}
break;
case "pageDown":
if (webView != null) {
boolean bottom = (boolean) call.argument("bottom");
......
......@@ -777,7 +777,8 @@ final public class InAppWebView extends InputAwareWebView {
setRendererPriorityPolicy(
(int) options.rendererPriorityPolicy.get("rendererRequestedPriority"),
(boolean) options.rendererPriorityPolicy.get("waivedWhenNotVisible"));
} else if (options.rendererPriorityPolicy == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
} else if ((options.rendererPriorityPolicy == null || (options.rendererPriorityPolicy != null && options.rendererPriorityPolicy.isEmpty())) &&
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
options.rendererPriorityPolicy.put("rendererRequestedPriority", getRendererRequestedPriority());
options.rendererPriorityPolicy.put("waivedWhenNotVisible", getRendererPriorityWaivedWhenNotVisible());
}
......
......@@ -24,18 +24,14 @@ import android.webkit.WebViewClient;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.webkit.WebViewFeature;
import com.pichillilorenzo.flutter_inappwebview.CredentialDatabase.Credential;
import com.pichillilorenzo.flutter_inappwebview.CredentialDatabase.CredentialDatabase;
import com.pichillilorenzo.flutter_inappwebview.InAppBrowser.InAppBrowserActivity;
import com.pichillilorenzo.flutter_inappwebview.JavaScriptBridgeInterface;
import com.pichillilorenzo.flutter_inappwebview.Shared;
import com.pichillilorenzo.flutter_inappwebview.Util;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
......@@ -746,7 +742,7 @@ public class InAppWebViewClient extends WebViewClient {
headers = webResourceRequest.getRequestHeaders();
hasGesture = webResourceRequest.hasGesture();
isForMainFrame = webResourceRequest.isForMainFrame();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
isRedirect = webResourceRequest.isRedirect();
}
}
......@@ -775,8 +771,20 @@ public class InAppWebViewClient extends WebViewClient {
}
else if (flutterResult.result != null) {
Map<String, Object> res = (Map<String, Object>) flutterResult.result;
String contentType = (String) res.get("contentType");
String contentEncoding = (String) res.get("contentEncoding");
byte[] data = (byte[]) res.get("data");
return new WebResourceResponse(res.get("content-type").toString(), res.get("content-encoding").toString(), new ByteArrayInputStream(data));
Map<String, String> responseHeaders = (Map<String, String>) res.get("headers");
Integer statusCode = (Integer) res.get("statusCode");
String reasonPhrase = (String) res.get("reasonPhrase");
ByteArrayInputStream inputStream = (data != null) ? new ByteArrayInputStream(data) : null;
if ((responseHeaders == null && statusCode == null && reasonPhrase == null) || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return new WebResourceResponse(contentType, contentEncoding, inputStream);
} else {
return new WebResourceResponse(contentType, contentEncoding, statusCode, reasonPhrase, responseHeaders, inputStream);
}
}
return null;
......@@ -793,17 +801,19 @@ public class InAppWebViewClient extends WebViewClient {
@Override
public void success(@Nullable Object response) {
Map<String, Object> responseMap = (Map<String, Object>) response;
Integer action = (Integer) responseMap.get("action");
if (action != null) {
switch (action) {
case 1:
resend.sendToTarget();
return;
case 0:
default:
dontResend.sendToTarget();
return;
if (response != null) {
Map<String, Object> responseMap = (Map<String, Object>) response;
Integer action = (Integer) responseMap.get("action");
if (action != null) {
switch (action) {
case 0:
resend.sendToTarget();
return;
case 1:
default:
dontResend.sendToTarget();
return;
}
}
}
......@@ -835,16 +845,22 @@ public class InAppWebViewClient extends WebViewClient {
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail) {
Boolean didCrash = detail.didCrash();
Integer rendererPriorityAtExit = detail.rendererPriorityAtExit();
final InAppWebView webView = (InAppWebView) view;
Map<String, Object> obj = new HashMap<>();
if (inAppBrowserActivity != null)
obj.put("uuid", inAppBrowserActivity.uuid);
obj.put("didCrash", didCrash);
obj.put("rendererPriorityAtExit", rendererPriorityAtExit);
if (webView.options.useOnRenderProcessGone) {
Boolean didCrash = detail.didCrash();
Integer rendererPriorityAtExit = detail.rendererPriorityAtExit();
channel.invokeMethod("onRenderProcessGone", obj);
Map<String, Object> obj = new HashMap<>();
if (inAppBrowserActivity != null)
obj.put("uuid", inAppBrowserActivity.uuid);
obj.put("didCrash", didCrash);
obj.put("rendererPriorityAtExit", rendererPriorityAtExit);
channel.invokeMethod("onRenderProcessGone", obj);
return true;
}
return super.onRenderProcessGone(view, detail);
}
......
......@@ -87,7 +87,6 @@ public class InAppWebViewOptions implements Options {
public Boolean hardwareAcceleration = true;
public Boolean supportMultipleWindows = false;
public String regexToCancelSubFramesLoading;
public Integer overScrollMode = View.OVER_SCROLL_IF_CONTENT_SCROLLS;
public Boolean networkAvailable = null;
public Integer scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY;
......@@ -97,6 +96,7 @@ public class InAppWebViewOptions implements Options {
public Integer scrollBarFadeDuration = null;
public Map<String, Object> rendererPriorityPolicy = new HashMap<>();
public Boolean useShouldInterceptRequest = false;
public Boolean useOnRenderProcessGone = false;
@Override
public InAppWebViewOptions parse(HashMap<String, Object> options) {
......@@ -333,6 +333,9 @@ public class InAppWebViewOptions implements Options {
case "useShouldInterceptRequest":
useShouldInterceptRequest = (Boolean) value;
break;
case "useOnRenderProcessGone":
useOnRenderProcessGone = (Boolean) value;
break;
}
}
......@@ -417,6 +420,7 @@ public class InAppWebViewOptions implements Options {
options.put("scrollBarFadeDuration", scrollBarFadeDuration);
options.put("rendererPriorityPolicy", rendererPriorityPolicy);
options.put("useShouldInterceptRequest", useShouldInterceptRequest);
options.put("useOnRenderProcessGone", useOnRenderProcessGone);
return options;
}
......
......@@ -37,6 +37,7 @@ public class InAppWebViewRenderProcessClient extends WebViewRenderProcessClient
Map<String, Object> obj = new HashMap<>();
if (inAppBrowserActivity != null)
obj.put("uuid", inAppBrowserActivity.uuid);
obj.put("url", view.getUrl());
channel.invokeMethod("onRenderProcessUnresponsive", obj, new MethodChannel.Result() {
@Override
......@@ -45,7 +46,7 @@ public class InAppWebViewRenderProcessClient extends WebViewRenderProcessClient
Integer action = (Integer) responseMap.get("action");
if (action != null && renderer != null) {
switch (action) {
case 1:
case 0:
if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_VIEW_RENDERER_TERMINATE))
renderer.terminate();
break;
......@@ -70,6 +71,7 @@ public class InAppWebViewRenderProcessClient extends WebViewRenderProcessClient
Map<String, Object> obj = new HashMap<>();
if (inAppBrowserActivity != null)
obj.put("uuid", inAppBrowserActivity.uuid);
obj.put("url", view.getUrl());
channel.invokeMethod("onRenderProcessResponsive", obj, new MethodChannel.Result() {
@Override
......@@ -78,7 +80,7 @@ public class InAppWebViewRenderProcessClient extends WebViewRenderProcessClient
Integer action = (Integer) responseMap.get("action");
if (action != null && renderer != null) {
switch (action) {
case 1:
case 0:
if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_VIEW_RENDERER_TERMINATE))
renderer.terminate();
break;
......
......@@ -33,8 +33,6 @@ public class InAppWebViewStatic implements MethodChannel.MethodCallHandler {
case "getDefaultUserAgent":
result.success(WebSettings.getDefaultUserAgent(Shared.applicationContext));
break;
case "clearClientCertPreferences":
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
WebView.clearClientCertPreferences(new Runnable() {
......@@ -66,15 +64,12 @@ public class InAppWebViewStatic implements MethodChannel.MethodCallHandler {
else
result.success(false);
break;
case "getCurrentWebViewPackage":
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
result.success(
convertWebViewPackageToMap(WebViewCompat.getCurrentWebViewPackage(Shared.activity)));
} else {
result.success(false);
result.success(null);
}
break;
default:
......
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.0+hotfix.6/","dependencies":[]}],"android":[{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.0+hotfix.6/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"e2e","dependencies":[]},{"name":"flutter_inappwebview","dependencies":[]},{"name":"permission_handler","dependencies":[]}],"date_created":"2020-05-26 00:10:53.444505","version":"1.17.1"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.0+hotfix.6/","dependencies":[]}],"android":[{"name":"e2e","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/e2e-0.2.4+4/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.0+hotfix.6/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"e2e","dependencies":[]},{"name":"flutter_inappwebview","dependencies":[]},{"name":"permission_handler","dependencies":[]}],"date_created":"2020-05-29 00:17:33.621880","version":"1.17.1"}
\ No newline at end of file
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
......
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'main.dart';
......
......@@ -6,7 +6,7 @@ import 'package:flutter_inappwebview_example/chrome_safari_browser_example.scree
import 'package:flutter_inappwebview_example/headless_in_app_webview.screen.dart';
import 'package:flutter_inappwebview_example/in_app_webiew_example.screen.dart';
import 'package:flutter_inappwebview_example/in_app_browser_example.screen.dart';
import 'package:permission_handler/permission_handler.dart';
// import 'package:permission_handler/permission_handler.dart';
// InAppLocalhostServer localhostServer = new InAppLocalhostServer();
......
......@@ -26,7 +26,6 @@
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_inappwebview/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_inappwebview/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_inappwebview/example/build" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_inappwebview/example/ios/Flutter/App.framework/flutter_assets/packages" />
<excludeFolder url="file://$MODULE_DIR$/example/ios/Flutter/App.framework/flutter_assets/packages" />
<excludeFolder url="file://$MODULE_DIR$/flutter_inappbrowser_tests/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/flutter_inappbrowser_tests/.pub" />
......
......@@ -2204,7 +2204,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
public func webView(_ webView: WKWebView,
didCommit navigation: WKNavigation!) {
onDidCommit()
onPageCommitVisible(url: url?.absoluteString)
}
public func webView(_ webView: WKWebView,
......@@ -2486,8 +2486,11 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
channel?.invokeMethod("onWebContentProcessDidTerminate", arguments: [])
}
public func onDidCommit() {
channel?.invokeMethod("onDidCommit", arguments: [])
public func onPageCommitVisible(url: String?) {
let arguments: [String: Any?] = [
"url": url
]
channel?.invokeMethod("onPageCommitVisible", arguments: arguments)
}
public func onDidReceiveServerRedirectForProvisionalNavigation() {
......
......@@ -47,12 +47,18 @@ class HeadlessInAppWebView implements WebView {
this.onLongPressHitTestResult,
this.onEnterFullscreen,
this.onExitFullscreen,
this.onPageCommitVisible,
this.androidOnSafeBrowsingHit,
this.androidOnPermissionRequest,
this.androidOnGeolocationPermissionsShowPrompt,
this.androidOnGeolocationPermissionsHidePrompt,
this.androidShouldInterceptRequest,
this.androidOnRenderProcessGone,
this.androidOnRenderProcessResponsive,
this.androidOnRenderProcessUnresponsive,
this.androidOnFormResubmission,
this.androidOnScaleChanged,
this.iosOnWebContentProcessDidTerminate,
this.iosOnDidCommit,
this.iosOnDidReceiveServerRedirectForProvisionalNavigation,
this.initialUrl,
this.initialFile,
......@@ -88,7 +94,7 @@ class HeadlessInAppWebView implements WebView {
'initialFile': this.initialFile,
'initialData': this.initialData?.toMap(),
'initialHeaders': this.initialHeaders,
'initialOptions': this.initialOptions?.toMap(),
'initialOptions': this.initialOptions?.toMap() ?? {},
'contextMenu': this.contextMenu?.toMap() ?? {}
});
await _sharedChannel.invokeMethod('createHeadlessWebView', args);
......@@ -143,7 +149,7 @@ class HeadlessInAppWebView implements WebView {
final String initialUrl;
@override
final Future<void> Function(InAppWebViewController controller) iosOnDidCommit;
final Future<void> Function(InAppWebViewController controller, String url) onPageCommitVisible;
@override
final Future<void> Function(InAppWebViewController controller)
......@@ -276,4 +282,28 @@ class HeadlessInAppWebView implements WebView {
@override
final void Function(InAppWebViewController controller) onExitFullscreen;
@override
final Future<WebResourceResponse> Function(InAppWebViewController controller, WebResourceRequest request)
androidShouldInterceptRequest;
@override
final Future<WebViewRenderProcessAction> Function(InAppWebViewController controller, String url)
androidOnRenderProcessUnresponsive;
@override
final Future<WebViewRenderProcessAction> Function(InAppWebViewController controller, String url)
androidOnRenderProcessResponsive;
@override
final Future<void> Function(InAppWebViewController controller, RenderProcessGoneDetail detail)
androidOnRenderProcessGone;
@override
final Future<FormResubmissionAction> Function(InAppWebViewController controller, String url)
androidOnFormResubmission;
@override
final Future<void> Function(InAppWebViewController controller, double oldScale, double newScale)
androidOnScaleChanged;
}
\ No newline at end of file
This diff is collapsed.
......@@ -39,7 +39,7 @@ class InAppWebView extends StatefulWidget implements WebView {
this.initialFile,
this.initialData,
this.initialHeaders = const {},
@required this.initialOptions,
this.initialOptions,
this.contextMenu,
this.onWebViewCreated,
this.onLoadStart,
......@@ -70,12 +70,18 @@ class InAppWebView extends StatefulWidget implements WebView {
this.onLongPressHitTestResult,
this.onEnterFullscreen,
this.onExitFullscreen,
this.onPageCommitVisible,
this.androidOnSafeBrowsingHit,
this.androidOnPermissionRequest,
this.androidOnGeolocationPermissionsShowPrompt,
this.androidOnGeolocationPermissionsHidePrompt,
this.androidShouldInterceptRequest,
this.androidOnRenderProcessGone,
this.androidOnRenderProcessResponsive,
this.androidOnRenderProcessUnresponsive,
this.androidOnFormResubmission,
this.androidOnScaleChanged,
this.iosOnWebContentProcessDidTerminate,
this.iosOnDidCommit,
this.iosOnDidReceiveServerRedirectForProvisionalNavigation,
this.gestureRecognizers,
}) : super(key: key);
......@@ -121,7 +127,7 @@ class InAppWebView extends StatefulWidget implements WebView {
final ContextMenu contextMenu;
@override
final Future<void> Function(InAppWebViewController controller) iosOnDidCommit;
final Future<void> Function(InAppWebViewController controller, String url) onPageCommitVisible;
@override
final Future<void> Function(InAppWebViewController controller)
......@@ -254,6 +260,30 @@ class InAppWebView extends StatefulWidget implements WebView {
@override
final void Function(InAppWebViewController controller) onExitFullscreen;
@override
final Future<WebResourceResponse> Function(InAppWebViewController controller, WebResourceRequest request)
androidShouldInterceptRequest;
@override
final Future<WebViewRenderProcessAction> Function(InAppWebViewController controller, String url)
androidOnRenderProcessUnresponsive;
@override
final Future<WebViewRenderProcessAction> Function(InAppWebViewController controller, String url)
androidOnRenderProcessResponsive;
@override
final Future<void> Function(InAppWebViewController controller, RenderProcessGoneDetail detail)
androidOnRenderProcessGone;
@override
final Future<FormResubmissionAction> Function(InAppWebViewController controller, String url)
androidOnFormResubmission;
@override
final Future<void> Function(InAppWebViewController controller, double oldScale, double newScale)
androidOnScaleChanged;
}
class _InAppWebViewState extends State<InAppWebView> {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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