fixed tests, added android webview EventChannelDelegate, fixed some enum native values based on target platform

This commit is contained in:
Lorenzo Pichilli 2022-05-04 02:17:33 +02:00
parent 3edbbbc396
commit 55f3b64a24
41 changed files with 2673 additions and 973 deletions

View File

@ -15,6 +15,7 @@
### BREAKING CHANGES ### BREAKING CHANGES
- On Android, the `InAppWebView` widget uses hybrid composition by default (`useHybridComposition: true`). - On Android, the `InAppWebView` widget uses hybrid composition by default (`useHybridComposition: true`).
- All properties of `GeolocationPermissionShowPromptResponse` cannot be `null`;
## 5.4.3+4 ## 5.4.3+4

View File

@ -13,11 +13,12 @@ import androidx.webkit.ServiceWorkerControllerCompat;
import androidx.webkit.ServiceWorkerWebSettingsCompat; import androidx.webkit.ServiceWorkerWebSettingsCompat;
import androidx.webkit.WebViewFeature; import androidx.webkit.WebViewFeature;
import com.pichillilorenzo.flutter_inappwebview.types.WebResourceRequestExt;
import com.pichillilorenzo.flutter_inappwebview.types.WebResourceResponseExt;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
@ -44,7 +45,7 @@ public class ServiceWorkerManager implements MethodChannel.MethodCallHandler {
} }
@Override @Override
public void onMethodCall(MethodCall call, MethodChannel.Result result) { public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
ServiceWorkerWebSettingsCompat serviceWorkerWebSettings = (serviceWorkerController != null) ? serviceWorkerController.getServiceWorkerWebSettings() : null; ServiceWorkerWebSettingsCompat serviceWorkerWebSettings = (serviceWorkerController != null) ? serviceWorkerController.getServiceWorkerWebSettings() : null;
switch (call.method) { switch (call.method) {
@ -124,17 +125,11 @@ public class ServiceWorkerManager implements MethodChannel.MethodCallHandler {
@Nullable @Nullable
@Override @Override
public WebResourceResponse shouldInterceptRequest(@NonNull WebResourceRequest request) { public WebResourceResponse shouldInterceptRequest(@NonNull WebResourceRequest request) {
final Map<String, Object> obj = new HashMap<>(); WebResourceRequestExt requestExt = WebResourceRequestExt.fromWebResourceRequest(request);
obj.put("url", request.getUrl().toString());
obj.put("method", request.getMethod());
obj.put("headers", request.getRequestHeaders());
obj.put("isForMainFrame", request.isForMainFrame());
obj.put("hasGesture", request.hasGesture());
obj.put("isRedirect", request.isRedirect());
Util.WaitFlutterResult flutterResult; Util.WaitFlutterResult flutterResult;
try { try {
flutterResult = Util.invokeMethodAndWait(channel, "shouldInterceptRequest", obj); flutterResult = Util.invokeMethodAndWait(channel, "shouldInterceptRequest", requestExt.toMap());
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
@ -144,20 +139,22 @@ public class ServiceWorkerManager implements MethodChannel.MethodCallHandler {
Log.e(LOG_TAG, flutterResult.error); Log.e(LOG_TAG, flutterResult.error);
} }
else if (flutterResult.result != null) { else if (flutterResult.result != null) {
Map<String, Object> res = (Map<String, Object>) flutterResult.result; WebResourceResponseExt response = WebResourceResponseExt.fromMap((Map<String, Object>) flutterResult.result);
String contentType = (String) res.get("contentType"); if (response != null) {
String contentEncoding = (String) res.get("contentEncoding"); String contentType = response.getContentType();
byte[] data = (byte[]) res.get("data"); String contentEncoding = response.getContentEncoding();
Map<String, String> responseHeaders = (Map<String, String>) res.get("headers"); byte[] data = response.getData();
Integer statusCode = (Integer) res.get("statusCode"); Map<String, String> responseHeaders = response.getHeaders();
String reasonPhrase = (String) res.get("reasonPhrase"); Integer statusCode = response.getStatusCode();
String reasonPhrase = response.getReasonPhrase();
ByteArrayInputStream inputStream = (data != null) ? new ByteArrayInputStream(data) : null; ByteArrayInputStream inputStream = (data != null) ? new ByteArrayInputStream(data) : null;
if ((responseHeaders == null && statusCode == null && reasonPhrase == null) || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { if (statusCode != null && reasonPhrase != null) {
return new WebResourceResponse(contentType, contentEncoding, inputStream); return new WebResourceResponse(contentType, contentEncoding, statusCode, reasonPhrase, responseHeaders, inputStream);
} else { } else {
return new WebResourceResponse(contentType, contentEncoding, statusCode, reasonPhrase, responseHeaders, inputStream); return new WebResourceResponse(contentType, contentEncoding, inputStream);
}
} }
} }

View File

@ -10,9 +10,12 @@ import android.os.Looper;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import com.pichillilorenzo.flutter_inappwebview.types.SyncBaseCallbackResultImpl;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@ -127,6 +130,20 @@ public class Util {
return new WaitFlutterResult(flutterResultMap.get("result"), (String) flutterResultMap.get("error")); return new WaitFlutterResult(flutterResultMap.get("result"), (String) flutterResultMap.get("error"));
} }
public static <T> T invokeMethodAndWaitResult(final @NonNull MethodChannel channel,
final @NonNull String method, final @Nullable Object arguments,
final @NonNull SyncBaseCallbackResultImpl<T> callback) throws InterruptedException {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
channel.invokeMethod(method, arguments, callback);
}
});
callback.latch.await();
return callback.result;
}
public static class WaitFlutterResult { public static class WaitFlutterResult {
public Object result; public Object result;
public String error; public String error;
@ -137,8 +154,11 @@ public class Util {
} }
} }
public static PrivateKeyAndCertificates loadPrivateKeyAndCertificate(InAppWebViewFlutterPlugin plugin, String certificatePath, String certificatePassword, String keyStoreType) { @Nullable
public static PrivateKeyAndCertificates loadPrivateKeyAndCertificate(@NonNull InAppWebViewFlutterPlugin plugin,
@NonNull String certificatePath,
@Nullable String certificatePassword,
@NonNull String keyStoreType) {
PrivateKeyAndCertificates privateKeyAndCertificates = null; PrivateKeyAndCertificates privateKeyAndCertificates = null;
try { try {
@ -150,7 +170,7 @@ public class Util {
Enumeration<String> aliases = keyStore.aliases(); Enumeration<String> aliases = keyStore.aliases();
String alias = aliases.nextElement(); String alias = aliases.nextElement();
Key key = keyStore.getKey(alias, certificatePassword.toCharArray()); Key key = keyStore.getKey(alias, certificatePassword != null ? certificatePassword.toCharArray() : null);
if (key instanceof PrivateKey) { if (key instanceof PrivateKey) {
PrivateKey privateKey = (PrivateKey)key; PrivateKey privateKey = (PrivateKey)key;
Certificate cert = keyStore.getCertificate(alias); Certificate cert = keyStore.getCertificate(alias);
@ -319,8 +339,8 @@ public class Util {
return InetAddress.getByName(address).getCanonicalHostName(); return InetAddress.getByName(address).getCanonicalHostName();
} }
public static Object getOrDefault(Map map, String key, Object defaultValue) { public static <T> T getOrDefault(Map<String, Object> map, String key, T defaultValue) {
return map.containsKey(key) ? map.get(key) : defaultValue; return map.containsKey(key) ? (T) map.get(key) : defaultValue;
} }
@Nullable @Nullable

View File

@ -77,14 +77,14 @@ public class ChromeSafariBrowserManager implements MethodChannel.MethodCallHandl
extras.putSerializable("actionButton", (Serializable) actionButton); extras.putSerializable("actionButton", (Serializable) actionButton);
extras.putSerializable("menuItemList", (Serializable) menuItemList); extras.putSerializable("menuItemList", (Serializable) menuItemList);
Boolean isSingleInstance = (Boolean) Util.getOrDefault(settings, "isSingleInstance", false); Boolean isSingleInstance = Util.<Boolean>getOrDefault(settings, "isSingleInstance", false);
Boolean isTrustedWebActivity = (Boolean) Util.getOrDefault(settings, "isTrustedWebActivity", false); Boolean isTrustedWebActivity = Util.<Boolean>getOrDefault(settings, "isTrustedWebActivity", false);
if (CustomTabActivityHelper.isAvailable(activity)) { if (CustomTabActivityHelper.isAvailable(activity)) {
intent = new Intent(activity, !isSingleInstance ? intent = new Intent(activity, !isSingleInstance ?
(!isTrustedWebActivity ? ChromeCustomTabsActivity.class : TrustedWebActivity.class) : (!isTrustedWebActivity ? ChromeCustomTabsActivity.class : TrustedWebActivity.class) :
(!isTrustedWebActivity ? ChromeCustomTabsActivitySingleInstance.class : TrustedWebActivitySingleInstance.class)); (!isTrustedWebActivity ? ChromeCustomTabsActivitySingleInstance.class : TrustedWebActivitySingleInstance.class));
intent.putExtras(extras); intent.putExtras(extras);
Boolean noHistory = (Boolean) Util.getOrDefault(settings, "noHistory", false); Boolean noHistory = Util.<Boolean>getOrDefault(settings, "noHistory", false);
if (noHistory) { if (noHistory) {
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
} }

View File

@ -5,6 +5,8 @@ import android.os.Handler;
import android.util.Log; import android.util.Log;
import android.webkit.WebResourceResponse; import android.webkit.WebResourceResponse;
import androidx.annotation.Nullable;
import com.pichillilorenzo.flutter_inappwebview.in_app_webview.InAppWebView; import com.pichillilorenzo.flutter_inappwebview.in_app_webview.InAppWebView;
import com.pichillilorenzo.flutter_inappwebview.Util; import com.pichillilorenzo.flutter_inappwebview.Util;
@ -42,6 +44,7 @@ public class ContentBlockerHandler {
this.ruleList = newRuleList; this.ruleList = newRuleList;
} }
@Nullable
public WebResourceResponse checkUrl(final InAppWebView webView, String url, ContentBlockerTriggerResourceType responseResourceType) throws URISyntaxException, InterruptedException, MalformedURLException { public WebResourceResponse checkUrl(final InAppWebView webView, String url, ContentBlockerTriggerResourceType responseResourceType) throws URISyntaxException, InterruptedException, MalformedURLException {
if (webView.customSettings.contentBlockers == null) if (webView.customSettings.contentBlockers == null)
return null; return null;
@ -211,12 +214,14 @@ public class ContentBlockerHandler {
} }
return null; return null;
} }
@Nullable
public WebResourceResponse checkUrl(final InAppWebView webView, String url) throws URISyntaxException, InterruptedException, MalformedURLException { public WebResourceResponse checkUrl(final InAppWebView webView, String url) throws URISyntaxException, InterruptedException, MalformedURLException {
ContentBlockerTriggerResourceType responseResourceType = getResourceTypeFromUrl(url); ContentBlockerTriggerResourceType responseResourceType = getResourceTypeFromUrl(url);
return checkUrl(webView, url, responseResourceType); return checkUrl(webView, url, responseResourceType);
} }
@Nullable
public WebResourceResponse checkUrl(final InAppWebView webView, String url, String contentType) throws URISyntaxException, InterruptedException, MalformedURLException { public WebResourceResponse checkUrl(final InAppWebView webView, String url, String contentType) throws URISyntaxException, InterruptedException, MalformedURLException {
ContentBlockerTriggerResourceType responseResourceType = getResourceTypeFromContentType(contentType); ContentBlockerTriggerResourceType responseResourceType = getResourceTypeFromContentType(contentType);
return checkUrl(webView, url, responseResourceType); return checkUrl(webView, url, responseResourceType);

View File

@ -0,0 +1,571 @@
package com.pichillilorenzo.flutter_inappwebview.in_app_webview;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.pichillilorenzo.flutter_inappwebview.Util;
import com.pichillilorenzo.flutter_inappwebview.types.BaseCallbackResultImpl;
import com.pichillilorenzo.flutter_inappwebview.types.ClientCertChallenge;
import com.pichillilorenzo.flutter_inappwebview.types.ClientCertResponse;
import com.pichillilorenzo.flutter_inappwebview.types.CreateWindowAction;
import com.pichillilorenzo.flutter_inappwebview.types.CustomSchemeResponse;
import com.pichillilorenzo.flutter_inappwebview.types.DownloadStartRequest;
import com.pichillilorenzo.flutter_inappwebview.types.GeolocationPermissionShowPromptResponse;
import com.pichillilorenzo.flutter_inappwebview.types.HitTestResult;
import com.pichillilorenzo.flutter_inappwebview.types.HttpAuthResponse;
import com.pichillilorenzo.flutter_inappwebview.types.HttpAuthenticationChallenge;
import com.pichillilorenzo.flutter_inappwebview.types.JsAlertResponse;
import com.pichillilorenzo.flutter_inappwebview.types.JsBeforeUnloadResponse;
import com.pichillilorenzo.flutter_inappwebview.types.JsConfirmResponse;
import com.pichillilorenzo.flutter_inappwebview.types.JsPromptResponse;
import com.pichillilorenzo.flutter_inappwebview.types.NavigationAction;
import com.pichillilorenzo.flutter_inappwebview.types.NavigationActionPolicy;
import com.pichillilorenzo.flutter_inappwebview.types.PermissionResponse;
import com.pichillilorenzo.flutter_inappwebview.types.SafeBrowsingResponse;
import com.pichillilorenzo.flutter_inappwebview.types.ServerTrustAuthResponse;
import com.pichillilorenzo.flutter_inappwebview.types.ServerTrustChallenge;
import com.pichillilorenzo.flutter_inappwebview.types.SyncBaseCallbackResultImpl;
import com.pichillilorenzo.flutter_inappwebview.types.WebResourceErrorExt;
import com.pichillilorenzo.flutter_inappwebview.types.WebResourceRequestExt;
import com.pichillilorenzo.flutter_inappwebview.types.WebResourceResponseExt;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.flutter.plugin.common.MethodChannel;
public class EventChannelDelegate {
@Nullable
private MethodChannel channel;
public EventChannelDelegate(@Nullable MethodChannel channel) {
this.channel = channel;
}
public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches, boolean isDoneCounting) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("activeMatchOrdinal", activeMatchOrdinal);
obj.put("numberOfMatches", numberOfMatches);
obj.put("isDoneCounting", isDoneCounting);
channel.invokeMethod("onFindResultReceived", obj);
}
public void onLongPressHitTestResult(HitTestResult hitTestResult) {
if (channel == null) return;
channel.invokeMethod("onLongPressHitTestResult", hitTestResult.toMap());
}
public void onScrollChanged(int x, int y) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("x", x);
obj.put("y", y);
channel.invokeMethod("onScrollChanged", obj);
}
public void onDownloadStartRequest(DownloadStartRequest downloadStartRequest) {
if (channel == null) return;
channel.invokeMethod("onDownloadStartRequest", downloadStartRequest.toMap());
}
public void onCreateContextMenu(HitTestResult hitTestResult) {
if (channel == null) return;
channel.invokeMethod("onCreateContextMenu", hitTestResult.toMap());
}
public void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("x", scrollX);
obj.put("y", scrollY);
obj.put("clampedX", clampedX);
obj.put("clampedY", clampedY);
channel.invokeMethod("onOverScrolled", obj);
}
public void onContextMenuActionItemClicked(int itemId, String itemTitle) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("id", itemId);
obj.put("androidId", itemId);
obj.put("iosId", null);
obj.put("title", itemTitle);
channel.invokeMethod("onContextMenuActionItemClicked", obj);
}
public void onHideContextMenu() {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
channel.invokeMethod("onHideContextMenu", obj);
}
public void onEnterFullscreen() {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
channel.invokeMethod("onEnterFullscreen", obj);
}
public void onExitFullscreen() {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
channel.invokeMethod("onExitFullscreen", obj);
}
public static class JsAlertCallback extends BaseCallbackResultImpl<JsAlertResponse> {
@Nullable
@Override
public JsAlertResponse decodeResult(@Nullable Object obj) {
return JsAlertResponse.fromMap((Map<String, Object>) obj);
}
}
public void onJsAlert(String url, String message, Boolean isMainFrame, @NonNull JsAlertCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
obj.put("message", message);
obj.put("isMainFrame", isMainFrame);
channel.invokeMethod("onJsAlert", obj, callback);
}
public static class JsConfirmCallback extends BaseCallbackResultImpl<JsConfirmResponse> {
@Nullable
@Override
public JsConfirmResponse decodeResult(@Nullable Object obj) {
return JsConfirmResponse.fromMap((Map<String, Object>) obj);
}
}
public void onJsConfirm(String url, String message, Boolean isMainFrame, @NonNull JsConfirmCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
obj.put("message", message);
obj.put("isMainFrame", isMainFrame);
channel.invokeMethod("onJsConfirm", obj, callback);
}
public static class JsPromptCallback extends BaseCallbackResultImpl<JsPromptResponse> {
@Nullable
@Override
public JsPromptResponse decodeResult(@Nullable Object obj) {
return JsPromptResponse.fromMap((Map<String, Object>) obj);
}
}
public void onJsPrompt(String url, String message, String defaultValue, Boolean isMainFrame, @NonNull JsPromptCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
obj.put("message", message);
obj.put("defaultValue", defaultValue);
obj.put("isMainFrame", isMainFrame);
channel.invokeMethod("onJsPrompt", obj, callback);
}
public static class JsBeforeUnloadCallback extends BaseCallbackResultImpl<JsBeforeUnloadResponse> {
@Nullable
@Override
public JsBeforeUnloadResponse decodeResult(@Nullable Object obj) {
return JsBeforeUnloadResponse.fromMap((Map<String, Object>) obj);
}
}
public void onJsBeforeUnload(String url, String message, @NonNull JsBeforeUnloadCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
obj.put("message", message);
channel.invokeMethod("onJsBeforeUnload", obj, callback);
}
public static class CreateWindowCallback extends BaseCallbackResultImpl<Boolean> {
@Nullable
@Override
public Boolean decodeResult(@Nullable Object obj) {
return (obj instanceof Boolean) && (boolean) obj;
}
}
public void onCreateWindow(CreateWindowAction createWindowAction, @NonNull CreateWindowCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
channel.invokeMethod("onCreateWindow", createWindowAction.toMap(), callback);
}
public void onCloseWindow() {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
channel.invokeMethod("onCloseWindow", obj);
}
public static class GeolocationPermissionsShowPromptCallback extends BaseCallbackResultImpl<GeolocationPermissionShowPromptResponse> {
@Nullable
@Override
public GeolocationPermissionShowPromptResponse decodeResult(@Nullable Object obj) {
return GeolocationPermissionShowPromptResponse.fromMap((Map<String, Object>) obj);
}
}
public void onGeolocationPermissionsShowPrompt(String origin, @NonNull GeolocationPermissionsShowPromptCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
Map<String, Object> obj = new HashMap<>();
obj.put("origin", origin);
channel.invokeMethod("onGeolocationPermissionsShowPrompt", obj, callback);
}
public void onGeolocationPermissionsHidePrompt() {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
channel.invokeMethod("onGeolocationPermissionsHidePrompt", obj);
}
public void onConsoleMessage(String message, int messageLevel) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("message", message);
obj.put("messageLevel", messageLevel);
channel.invokeMethod("onConsoleMessage", obj);
}
public void onProgressChanged(int progress) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("progress", progress);
channel.invokeMethod("onProgressChanged", obj);
}
public void onTitleChanged(String title) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("title", title);
channel.invokeMethod("onTitleChanged", obj);
}
public void onReceivedIcon(byte[] icon) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("icon", icon);
channel.invokeMethod("onReceivedIcon", obj);
}
public void onReceivedTouchIconUrl(String url, boolean precomposed) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
obj.put("precomposed", precomposed);
channel.invokeMethod("onReceivedTouchIconUrl", obj);
}
public static class PermissionRequestCallback extends BaseCallbackResultImpl<PermissionResponse> {
@Nullable
@Override
public PermissionResponse decodeResult(@Nullable Object obj) {
return PermissionResponse.fromMap((Map<String, Object>) obj);
}
}
public void onPermissionRequest(String origin, List<String> resources, Object frame, @NonNull PermissionRequestCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
Map<String, Object> obj = new HashMap<>();
obj.put("origin", origin);
obj.put("resources", resources);
obj.put("frame", frame);
channel.invokeMethod("onPermissionRequest", obj, callback);
}
public static class ShouldOverrideUrlLoadingCallback extends BaseCallbackResultImpl<NavigationActionPolicy> {
@Nullable
@Override
public NavigationActionPolicy decodeResult(@Nullable Object obj) {
Integer action = Util.<Integer>getOrDefault((Map<String, Object>) obj,
"action", NavigationActionPolicy.CANCEL.rawValue());
return NavigationActionPolicy.fromValue(action);
}
}
public void shouldOverrideUrlLoading(NavigationAction navigationAction, @NonNull ShouldOverrideUrlLoadingCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
channel.invokeMethod("shouldOverrideUrlLoading", navigationAction.toMap(), callback);
}
public void onLoadStart(String url) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
channel.invokeMethod("onLoadStart", obj);
}
public void onLoadStop(String url) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
channel.invokeMethod("onLoadStop", obj);
}
public void onUpdateVisitedHistory(String url, boolean isReload) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
obj.put("isReload", isReload);
channel.invokeMethod("onUpdateVisitedHistory", obj);
}
public void onReceivedError(WebResourceRequestExt request, WebResourceErrorExt error) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("request", request.toMap());
obj.put("error", error.toMap());
channel.invokeMethod("onReceivedError", obj);
}
public void onReceivedHttpError(WebResourceRequestExt request, WebResourceResponseExt errorResponse) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("request", request.toMap());
obj.put("errorResponse", errorResponse.toMap());
channel.invokeMethod("onReceivedHttpError", obj);
}
public static class ReceivedHttpAuthRequestCallback extends BaseCallbackResultImpl<HttpAuthResponse> {
@Nullable
@Override
public HttpAuthResponse decodeResult(@Nullable Object obj) {
return HttpAuthResponse.fromMap((Map<String, Object>) obj);
}
}
public void onReceivedHttpAuthRequest(HttpAuthenticationChallenge challenge, @NonNull ReceivedHttpAuthRequestCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
channel.invokeMethod("onReceivedHttpAuthRequest", challenge.toMap(), callback);
}
public static class ReceivedServerTrustAuthRequestCallback extends BaseCallbackResultImpl<ServerTrustAuthResponse> {
@Nullable
@Override
public ServerTrustAuthResponse decodeResult(@Nullable Object obj) {
return ServerTrustAuthResponse.fromMap((Map<String, Object>) obj);
}
}
public void onReceivedServerTrustAuthRequest(ServerTrustChallenge challenge, @NonNull ReceivedServerTrustAuthRequestCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
channel.invokeMethod("onReceivedServerTrustAuthRequest", challenge.toMap(), callback);
}
public static class ReceivedClientCertRequestCallback extends BaseCallbackResultImpl<ClientCertResponse> {
@Nullable
@Override
public ClientCertResponse decodeResult(@Nullable Object obj) {
return ClientCertResponse.fromMap((Map<String, Object>) obj);
}
}
public void onReceivedClientCertRequest(ClientCertChallenge challenge, @NonNull ReceivedClientCertRequestCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
channel.invokeMethod("onReceivedClientCertRequest", challenge.toMap(), callback);
}
public void onZoomScaleChanged(float oldScale, float newScale) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("oldScale", oldScale);
obj.put("newScale", newScale);
channel.invokeMethod("onZoomScaleChanged", obj);
}
public static class SafeBrowsingHitCallback extends BaseCallbackResultImpl<SafeBrowsingResponse> {
@Nullable
@Override
public SafeBrowsingResponse decodeResult(@Nullable Object obj) {
return SafeBrowsingResponse.fromMap((Map<String, Object>) obj);
}
}
public void onSafeBrowsingHit(String url, int threatType, @NonNull SafeBrowsingHitCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
obj.put("threatType", threatType);
channel.invokeMethod("onSafeBrowsingHit", obj, callback);
}
public static class FormResubmissionCallback extends BaseCallbackResultImpl<Integer> {
@Nullable
@Override
public Integer decodeResult(@Nullable Object obj) {
return obj != null ? (Integer) ((Map<String, Object>) obj).get("action") : null;
}
}
public void onFormResubmission(String url, @NonNull FormResubmissionCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
channel.invokeMethod("onFormResubmission", obj, callback);
}
public void onPageCommitVisible(String url) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
channel.invokeMethod("onPageCommitVisible", obj);
}
public void onRenderProcessGone(boolean didCrash, int rendererPriorityAtExit) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("didCrash", didCrash);
obj.put("rendererPriorityAtExit", rendererPriorityAtExit);
channel.invokeMethod("onRenderProcessGone", obj);
}
public void onReceivedLoginRequest(String realm, String account, String args) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("realm", realm);
obj.put("account", account);
obj.put("args", args);
channel.invokeMethod("onReceivedLoginRequest", obj);
}
public static class LoadResourceCustomSchemeCallback extends BaseCallbackResultImpl<CustomSchemeResponse> {
@Nullable
@Override
public CustomSchemeResponse decodeResult(@Nullable Object obj) {
return CustomSchemeResponse.fromMap((Map<String, Object>) obj);
}
}
public void onLoadResourceCustomScheme(String url, @NonNull LoadResourceCustomSchemeCallback callback) {
if (channel == null) return;
Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
channel.invokeMethod("onLoadResourceCustomScheme", obj, callback);
}
public static class SyncLoadResourceCustomSchemeCallback extends SyncBaseCallbackResultImpl<CustomSchemeResponse> {
@Nullable
@Override
public CustomSchemeResponse decodeResult(@Nullable Object obj) {
return (new LoadResourceCustomSchemeCallback()).decodeResult(obj);
}
}
@Nullable
public CustomSchemeResponse onLoadResourceCustomScheme(String url) throws InterruptedException {
if (channel == null) return null;
final Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
final SyncLoadResourceCustomSchemeCallback callback = new SyncLoadResourceCustomSchemeCallback();
return Util.invokeMethodAndWaitResult(channel, "onLoadResourceCustomScheme", obj, callback);
}
public static class ShouldInterceptRequestCallback extends BaseCallbackResultImpl<WebResourceResponseExt> {
@Nullable
@Override
public WebResourceResponseExt decodeResult(@Nullable Object obj) {
return WebResourceResponseExt.fromMap((Map<String, Object>) obj);
}
}
public void shouldInterceptRequest(WebResourceRequestExt request, @NonNull ShouldInterceptRequestCallback callback) {
if (channel == null) return;
channel.invokeMethod("shouldInterceptRequest", request.toMap(), callback);
}
public static class SyncShouldInterceptRequestCallback extends SyncBaseCallbackResultImpl<WebResourceResponseExt> {
@Nullable
@Override
public WebResourceResponseExt decodeResult(@Nullable Object obj) {
return (new ShouldInterceptRequestCallback()).decodeResult(obj);
}
}
@Nullable
public WebResourceResponseExt shouldInterceptRequest(WebResourceRequestExt request) throws InterruptedException {
if (channel == null) return null;
final SyncShouldInterceptRequestCallback callback = new SyncShouldInterceptRequestCallback();
return Util.invokeMethodAndWaitResult(channel, "shouldInterceptRequest", request.toMap(), callback);
}
public static class RenderProcessUnresponsiveCallback extends BaseCallbackResultImpl<Integer> {
@Nullable
@Override
public Integer decodeResult(@Nullable Object obj) {
return obj != null ? (Integer) ((Map<String, Object>) obj).get("action") : null;
}
}
public void onRenderProcessUnresponsive(String url, @NonNull RenderProcessUnresponsiveCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
channel.invokeMethod("onRenderProcessUnresponsive", obj, callback);
}
public static class RenderProcessResponsiveCallback extends BaseCallbackResultImpl<Integer> {
@Nullable
@Override
public Integer decodeResult(@Nullable Object obj) {
return obj != null ? (Integer) ((Map<String, Object>) obj).get("action") : null;
}
}
public void onRenderProcessResponsive(String url, @NonNull RenderProcessResponsiveCallback callback) {
if (channel == null) {
callback.defaultBehaviour(null);
return;
}
Map<String, Object> obj = new HashMap<>();
obj.put("url", url);
channel.invokeMethod("onRenderProcessResponsive", obj, callback);
}
public void dispose() {
channel = null;
}
}

View File

@ -154,6 +154,7 @@ public class FlutterWebView implements PlatformWebView {
if (webView.inAppWebViewRenderProcessClient != null) { if (webView.inAppWebViewRenderProcessClient != null) {
webView.inAppWebViewRenderProcessClient.dispose(); webView.inAppWebViewRenderProcessClient.dispose();
} }
webView.eventChannelDelegate.dispose();
webView.inAppWebViewChromeClient.dispose(); webView.inAppWebViewChromeClient.dispose();
webView.inAppWebViewClient.dispose(); webView.inAppWebViewClient.dispose();
webView.javaScriptBridgeInterface.dispose(); webView.javaScriptBridgeInterface.dispose();

View File

@ -43,7 +43,6 @@ import android.webkit.WebBackForwardList;
import android.webkit.WebHistoryItem; import android.webkit.WebHistoryItem;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebStorage; import android.webkit.WebStorage;
import android.webkit.WebView;
import android.widget.HorizontalScrollView; import android.widget.HorizontalScrollView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
@ -116,10 +115,15 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
public Object id; public Object id;
@Nullable @Nullable
public Integer windowId; public Integer windowId;
@Nullable
public InAppWebViewClient inAppWebViewClient; public InAppWebViewClient inAppWebViewClient;
@Nullable
public InAppWebViewChromeClient inAppWebViewChromeClient; public InAppWebViewChromeClient inAppWebViewChromeClient;
@Nullable @Nullable
public InAppWebViewRenderProcessClient inAppWebViewRenderProcessClient; public InAppWebViewRenderProcessClient inAppWebViewRenderProcessClient;
@Nullable
public EventChannelDelegate eventChannelDelegate;
@Nullable
public JavaScriptBridgeInterface javaScriptBridgeInterface; public JavaScriptBridgeInterface javaScriptBridgeInterface;
public InAppWebViewSettings customSettings; public InAppWebViewSettings customSettings;
public boolean isLoading = false; public boolean isLoading = false;
@ -184,20 +188,21 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
} }
public void prepare() { public void prepare() {
httpClient = new OkHttpClient().newBuilder().build(); httpClient = new OkHttpClient().newBuilder().build();
eventChannelDelegate = new EventChannelDelegate(channel);
javaScriptBridgeInterface = new JavaScriptBridgeInterface(this); javaScriptBridgeInterface = new JavaScriptBridgeInterface(this);
addJavascriptInterface(javaScriptBridgeInterface, JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME); addJavascriptInterface(javaScriptBridgeInterface, JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME);
inAppWebViewChromeClient = new InAppWebViewChromeClient(plugin, channel, this, inAppBrowserDelegate); inAppWebViewChromeClient = new InAppWebViewChromeClient(plugin, this, inAppBrowserDelegate);
setWebChromeClient(inAppWebViewChromeClient); setWebChromeClient(inAppWebViewChromeClient);
inAppWebViewClient = new InAppWebViewClient(channel, inAppBrowserDelegate); inAppWebViewClient = new InAppWebViewClient(inAppBrowserDelegate);
setWebViewClient(inAppWebViewClient); setWebViewClient(inAppWebViewClient);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && WebViewFeature.isFeatureSupported(WebViewFeature.WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && WebViewFeature.isFeatureSupported(WebViewFeature.WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE)) {
inAppWebViewRenderProcessClient = new InAppWebViewRenderProcessClient(channel); inAppWebViewRenderProcessClient = new InAppWebViewRenderProcessClient();
WebViewCompat.setWebViewRenderProcessClient(this, inAppWebViewRenderProcessClient); WebViewCompat.setWebViewRenderProcessClient(this, inAppWebViewRenderProcessClient);
} }
@ -392,11 +397,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
setFindListener(new FindListener() { setFindListener(new FindListener() {
@Override @Override
public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches, boolean isDoneCounting) { public void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches, boolean isDoneCounting) {
Map<String, Object> obj = new HashMap<>(); if (eventChannelDelegate != null) eventChannelDelegate.onFindResultReceived(activeMatchOrdinal, numberOfMatches, isDoneCounting);
obj.put("activeMatchOrdinal", activeMatchOrdinal);
obj.put("numberOfMatches", numberOfMatches);
obj.put("isDoneCounting", isDoneCounting);
channel.invokeMethod("onFindResultReceived", obj);
} }
}); });
@ -492,7 +493,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
com.pichillilorenzo.flutter_inappwebview.types.HitTestResult hitTestResult = com.pichillilorenzo.flutter_inappwebview.types.HitTestResult hitTestResult =
com.pichillilorenzo.flutter_inappwebview.types.HitTestResult.fromWebViewHitTestResult(getHitTestResult()); com.pichillilorenzo.flutter_inappwebview.types.HitTestResult.fromWebViewHitTestResult(getHitTestResult());
channel.invokeMethod("onLongPressHitTestResult", hitTestResult.toMap()); if (eventChannelDelegate != null) eventChannelDelegate.onLongPressHitTestResult(hitTestResult);
return false; return false;
} }
}); });
@ -1193,10 +1194,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
floatingContextMenu.setVisibility(View.GONE); floatingContextMenu.setVisibility(View.GONE);
} }
Map<String, Object> obj = new HashMap<>(); if (eventChannelDelegate != null) eventChannelDelegate.onScrollChanged(x, y);
obj.put("x", x);
obj.put("y", y);
channel.invokeMethod("onScrollChanged", obj);
} }
public void scrollTo(Integer x, Integer y, Boolean animated) { public void scrollTo(Integer x, Integer y, Boolean animated) {
@ -1233,7 +1231,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
URLUtil.guessFileName(url, contentDisposition, mimeType), URLUtil.guessFileName(url, contentDisposition, mimeType),
null null
); );
channel.invokeMethod("onDownloadStartRequest", downloadStartRequest.toMap()); if (eventChannelDelegate != null) eventChannelDelegate.onDownloadStartRequest(downloadStartRequest);
} }
} }
@ -1284,7 +1282,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
private void sendOnCreateContextMenuEvent() { private void sendOnCreateContextMenuEvent() {
com.pichillilorenzo.flutter_inappwebview.types.HitTestResult hitTestResult = com.pichillilorenzo.flutter_inappwebview.types.HitTestResult hitTestResult =
com.pichillilorenzo.flutter_inappwebview.types.HitTestResult.fromWebViewHitTestResult(getHitTestResult()); com.pichillilorenzo.flutter_inappwebview.types.HitTestResult.fromWebViewHitTestResult(getHitTestResult());
channel.invokeMethod("onCreateContextMenu", hitTestResult.toMap()); if (eventChannelDelegate != null) eventChannelDelegate.onCreateContextMenu(hitTestResult);
} }
private Point contextMenuPoint = new Point(0, 0); private Point contextMenuPoint = new Point(0, 0);
@ -1323,12 +1321,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
} }
if (overScrolledHorizontally || overScrolledVertically) { if (overScrolledHorizontally || overScrolledVertically) {
Map<String, Object> obj = new HashMap<>(); if (eventChannelDelegate != null) eventChannelDelegate.onOverScrolled(scrollX, scrollY, overScrolledHorizontally, overScrolledVertically);
obj.put("x", scrollX);
obj.put("y", scrollY);
obj.put("clampedX", overScrolledHorizontally);
obj.put("clampedY", overScrolledVertically);
channel.invokeMethod("onOverScrolled", obj);
} }
} }
@ -1441,12 +1434,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
hideContextMenu(); hideContextMenu();
callback.onActionItemClicked(actionMode, menuItem); callback.onActionItemClicked(actionMode, menuItem);
Map<String, Object> obj = new HashMap<>(); if (eventChannelDelegate != null) eventChannelDelegate.onContextMenuActionItemClicked(itemId, itemTitle);
obj.put("id", itemId);
obj.put("androidId", itemId);
obj.put("iosId", null);
obj.put("title", itemTitle);
channel.invokeMethod("onContextMenuActionItemClicked", obj);
} }
}); });
if (floatingContextMenu != null) { if (floatingContextMenu != null) {
@ -1466,12 +1454,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
public void onClick(View v) { public void onClick(View v) {
hideContextMenu(); hideContextMenu();
Map<String, Object> obj = new HashMap<>(); if (eventChannelDelegate != null) eventChannelDelegate.onContextMenuActionItemClicked(itemId, itemTitle);
obj.put("id", itemId);
obj.put("androidId", itemId);
obj.put("iosId", null);
obj.put("title", itemTitle);
channel.invokeMethod("onContextMenuActionItemClicked", obj);
} }
}); });
if (floatingContextMenu != null) { if (floatingContextMenu != null) {
@ -1547,12 +1530,8 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
public void hideContextMenu() { public void hideContextMenu() {
removeView(floatingContextMenu); removeView(floatingContextMenu);
floatingContextMenu = null; floatingContextMenu = null;
onHideContextMenu();
} if (eventChannelDelegate != null) eventChannelDelegate.onHideContextMenu();
public void onHideContextMenu() {
Map<String, Object> obj = new HashMap<>();
channel.invokeMethod("onHideContextMenu", obj);
} }
public void onScrollStopped() { public void onScrollStopped() {
@ -1813,6 +1792,17 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
callback.onReceiveValue(com.pichillilorenzo.flutter_inappwebview.types.HitTestResult.fromWebViewHitTestResult(getHitTestResult())); callback.onReceiveValue(com.pichillilorenzo.flutter_inappwebview.types.HitTestResult.fromWebViewHitTestResult(getHitTestResult()));
} }
@Nullable
@Override
public EventChannelDelegate getEventChannelDelegate() {
return eventChannelDelegate;
}
@Override
public void setEventChannelDelegate(@Nullable EventChannelDelegate eventChannelDelegate) {
this.eventChannelDelegate = eventChannelDelegate;
}
@Override @Override
public void dispose() { public void dispose() {
if (windowId != null) { if (windowId != null) {
@ -1834,6 +1824,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
inAppWebViewClient = null; inAppWebViewClient = null;
javaScriptBridgeInterface = null; javaScriptBridgeInterface = null;
inAppWebViewRenderProcessClient = null; inAppWebViewRenderProcessClient = null;
eventChannelDelegate = null;
plugin = null; plugin = null;
super.dispose(); super.dispose();
} }

View File

@ -46,6 +46,12 @@ import com.pichillilorenzo.flutter_inappwebview.in_app_browser.ActivityResultLis
import com.pichillilorenzo.flutter_inappwebview.in_app_browser.InAppBrowserDelegate; import com.pichillilorenzo.flutter_inappwebview.in_app_browser.InAppBrowserDelegate;
import com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin; import com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin;
import com.pichillilorenzo.flutter_inappwebview.R; import com.pichillilorenzo.flutter_inappwebview.R;
import com.pichillilorenzo.flutter_inappwebview.types.GeolocationPermissionShowPromptResponse;
import com.pichillilorenzo.flutter_inappwebview.types.JsAlertResponse;
import com.pichillilorenzo.flutter_inappwebview.types.JsBeforeUnloadResponse;
import com.pichillilorenzo.flutter_inappwebview.types.JsConfirmResponse;
import com.pichillilorenzo.flutter_inappwebview.types.JsPromptResponse;
import com.pichillilorenzo.flutter_inappwebview.types.PermissionResponse;
import com.pichillilorenzo.flutter_inappwebview.types.URLRequest; import com.pichillilorenzo.flutter_inappwebview.types.URLRequest;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -54,7 +60,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
@ -66,7 +71,6 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
protected static final String LOG_TAG = "IABWebChromeClient"; protected static final String LOG_TAG = "IABWebChromeClient";
private InAppBrowserDelegate inAppBrowserDelegate; private InAppBrowserDelegate inAppBrowserDelegate;
private final MethodChannel channel;
public static Map<Integer, Message> windowWebViewMessages = new HashMap<>(); public static Map<Integer, Message> windowWebViewMessages = new HashMap<>();
private static int windowAutoincrementId = 0; private static int windowAutoincrementId = 0;
@ -105,11 +109,10 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
@Nullable @Nullable
public InAppWebView inAppWebView; public InAppWebView inAppWebView;
public InAppWebViewChromeClient(@NonNull final InAppWebViewFlutterPlugin plugin, MethodChannel channel, public InAppWebViewChromeClient(@NonNull final InAppWebViewFlutterPlugin plugin,
@NonNull InAppWebView inAppWebView, InAppBrowserDelegate inAppBrowserDelegate) { @NonNull InAppWebView inAppWebView, InAppBrowserDelegate inAppBrowserDelegate) {
super(); super();
this.plugin = plugin; this.plugin = plugin;
this.channel = channel;
this.inAppWebView = inAppWebView; this.inAppWebView = inAppWebView;
this.inAppBrowserDelegate = inAppBrowserDelegate; this.inAppBrowserDelegate = inAppBrowserDelegate;
if (this.inAppBrowserDelegate != null) { if (this.inAppBrowserDelegate != null) {
@ -145,10 +148,11 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
this.mCustomViewCallback.onCustomViewHidden(); this.mCustomViewCallback.onCustomViewHidden();
this.mCustomViewCallback = null; this.mCustomViewCallback = null;
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
Map<String, Object> obj = new HashMap<>();
channel.invokeMethod("onExitFullscreen", obj);
if (inAppWebView != null) { if (inAppWebView != null) {
EventChannelDelegate eventChannelDelegate = inAppWebView.eventChannelDelegate;
if (eventChannelDelegate != null)
eventChannelDelegate.onExitFullscreen();
inAppWebView.setInFullscreen(false); inAppWebView.setInFullscreen(false);
} }
} }
@ -183,10 +187,10 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
((FrameLayout) decorView).addView(this.mCustomView, FULLSCREEN_LAYOUT_PARAMS); ((FrameLayout) decorView).addView(this.mCustomView, FULLSCREEN_LAYOUT_PARAMS);
Map<String, Object> obj = new HashMap<>();
channel.invokeMethod("onEnterFullscreen", obj);
if (inAppWebView != null) { if (inAppWebView != null) {
EventChannelDelegate eventChannelDelegate = inAppWebView.eventChannelDelegate;
if (eventChannelDelegate != null)
eventChannelDelegate.onEnterFullscreen();
inAppWebView.setInFullscreen(true); inAppWebView.setInFullscreen(true);
} }
} }
@ -194,24 +198,12 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
@Override @Override
public boolean onJsAlert(final WebView view, String url, final String message, public boolean onJsAlert(final WebView view, String url, final String message,
final JsResult result) { final JsResult result) {
Map<String, Object> obj = new HashMap<>(); if (inAppWebView != null && inAppWebView.eventChannelDelegate != null) {
obj.put("url", url); inAppWebView.eventChannelDelegate.onJsAlert(url, message, null, new EventChannelDelegate.JsAlertCallback() {
obj.put("message", message); @Override
obj.put("isMainFrame", null); public boolean nonNullSuccess(@NonNull JsAlertResponse response) {
if (response.isHandledByClient()) {
channel.invokeMethod("onJsAlert", obj, new MethodChannel.Result() { Integer action = response.getAction();
@Override
public void success(@Nullable Object response) {
String responseMessage = null;
String confirmButtonTitle = null;
if (response != null) {
Map<String, Object> responseMap = (Map<String, Object>) response;
responseMessage = (String) responseMap.get("message");
confirmButtonTitle = (String) responseMap.get("confirmButtonTitle");
Boolean handledByClient = (Boolean) responseMap.get("handledByClient");
if (handledByClient != null && handledByClient) {
Integer action = (Integer) responseMap.get("action");
action = action != null ? action : 1; action = action != null ? action : 1;
switch (action) { switch (action) {
case 0: case 0:
@ -221,26 +213,33 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
default: default:
result.cancel(); result.cancel();
} }
return; return false;
} }
return true;
} }
createAlertDialog(view, message, result, responseMessage, confirmButtonTitle); @Override
} public void defaultBehaviour(@Nullable JsAlertResponse response) {
String responseMessage = null;
String confirmButtonTitle = null;
if (response != null) {
responseMessage = response.getMessage();
confirmButtonTitle = response.getConfirmButtonTitle();
}
createAlertDialog(view, message, result, responseMessage, confirmButtonTitle);
}
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : "")); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
result.cancel(); result.cancel();
} }
});
@Override return true;
public void notImplemented() { }
createAlertDialog(view, message, result, null, null);
}
});
return true; return false;
} }
public void createAlertDialog(WebView view, String message, final JsResult result, String responseMessage, String confirmButtonTitle) { public void createAlertDialog(WebView view, String message, final JsResult result, String responseMessage, String confirmButtonTitle) {
@ -282,26 +281,12 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
@Override @Override
public boolean onJsConfirm(final WebView view, String url, final String message, public boolean onJsConfirm(final WebView view, String url, final String message,
final JsResult result) { final JsResult result) {
Map<String, Object> obj = new HashMap<>(); if (inAppWebView != null && inAppWebView.eventChannelDelegate != null) {
obj.put("url", url); inAppWebView.eventChannelDelegate.onJsConfirm(url, message, null, new EventChannelDelegate.JsConfirmCallback() {
obj.put("message", message); @Override
obj.put("isMainFrame", null); public boolean nonNullSuccess(@NonNull JsConfirmResponse response) {
if (response.isHandledByClient()) {
channel.invokeMethod("onJsConfirm", obj, new MethodChannel.Result() { Integer action = response.getAction();
@Override
public void success(Object response) {
String responseMessage = null;
String confirmButtonTitle = null;
String cancelButtonTitle = null;
if (response != null) {
Map<String, Object> responseMap = (Map<String, Object>) response;
responseMessage = (String) responseMap.get("message");
confirmButtonTitle = (String) responseMap.get("confirmButtonTitle");
cancelButtonTitle = (String) responseMap.get("cancelButtonTitle");
Boolean handledByClient = (Boolean) responseMap.get("handledByClient");
if (handledByClient != null && handledByClient) {
Integer action = (Integer) responseMap.get("action");
action = action != null ? action : 1; action = action != null ? action : 1;
switch (action) { switch (action) {
case 0: case 0:
@ -311,26 +296,35 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
default: default:
result.cancel(); result.cancel();
} }
return; return false;
} }
return true;
} }
createConfirmDialog(view, message, result, responseMessage, confirmButtonTitle, cancelButtonTitle); @Override
} public void defaultBehaviour(@Nullable JsConfirmResponse response) {
String responseMessage = null;
String confirmButtonTitle = null;
String cancelButtonTitle = null;
if (response != null) {
responseMessage = response.getMessage();
confirmButtonTitle = response.getConfirmButtonTitle();
cancelButtonTitle = response.getCancelButtonTitle();
}
createConfirmDialog(view, message, result, responseMessage, confirmButtonTitle, cancelButtonTitle);
}
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : "")); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
result.cancel(); result.cancel();
} }
});
@Override return true;
public void notImplemented() { }
createConfirmDialog(view, message, result, null, null, null);
}
});
return true; return false;
} }
public void createConfirmDialog(WebView view, String message, final JsResult result, String responseMessage, String confirmButtonTitle, String cancelButtonTitle) { public void createConfirmDialog(WebView view, String message, final JsResult result, String responseMessage, String confirmButtonTitle, String cancelButtonTitle) {
@ -383,60 +377,54 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
@Override @Override
public boolean onJsPrompt(final WebView view, String url, final String message, public boolean onJsPrompt(final WebView view, String url, final String message,
final String defaultValue, final JsPromptResult result) { final String defaultValue, final JsPromptResult result) {
Map<String, Object> obj = new HashMap<>(); if (inAppWebView != null && inAppWebView.eventChannelDelegate != null) {
obj.put("url", url); inAppWebView.eventChannelDelegate.onJsPrompt(url, message, defaultValue, null, new EventChannelDelegate.JsPromptCallback() {
obj.put("message", message); @Override
obj.put("defaultValue", defaultValue); public boolean nonNullSuccess(@NonNull JsPromptResponse response) {
obj.put("isMainFrame", null); if (response.isHandledByClient()) {
Integer action = response.getAction();
channel.invokeMethod("onJsPrompt", obj, new MethodChannel.Result() {
@Override
public void success(Object response) {
String responseMessage = null;
String responseDefaultValue = null;
String confirmButtonTitle = null;
String cancelButtonTitle = null;
String value = null;
if (response != null) {
Map<String, Object> responseMap = (Map<String, Object>) response;
responseMessage = (String) responseMap.get("message");
responseDefaultValue = (String) responseMap.get("defaultValue");
confirmButtonTitle = (String) responseMap.get("confirmButtonTitle");
cancelButtonTitle = (String) responseMap.get("cancelButtonTitle");
value = (String) responseMap.get("value");
Boolean handledByClient = (Boolean) responseMap.get("handledByClient");
if (handledByClient != null && handledByClient) {
Integer action = (Integer) responseMap.get("action");
action = action != null ? action : 1; action = action != null ? action : 1;
switch (action) { switch (action) {
case 0: case 0:
result.confirm(value); result.confirm(response.getValue());
break; break;
case 1: case 1:
default: default:
result.cancel(); result.cancel();
} }
return; return false;
} }
return true;
} }
createPromptDialog(view, message, defaultValue, result, responseMessage, responseDefaultValue, value, cancelButtonTitle, confirmButtonTitle); @Override
} public void defaultBehaviour(@Nullable JsPromptResponse response) {
String responseMessage = null;
String responseDefaultValue = null;
String value = null;
String confirmButtonTitle = null;
String cancelButtonTitle = null;
if (response != null) {
responseMessage = response.getMessage();
responseDefaultValue = response.getDefaultValue();
value = response.getValue();
confirmButtonTitle = response.getConfirmButtonTitle();
cancelButtonTitle = response.getCancelButtonTitle();
}
createPromptDialog(view, message, defaultValue, result, responseMessage, responseDefaultValue, value, cancelButtonTitle, confirmButtonTitle);
}
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : "")); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
result.cancel(); result.cancel();
} }
});
@Override return true;
public void notImplemented() { }
createPromptDialog(view, message, defaultValue, result, null, null, null, null, null);
}
});
return true; return false;
} }
public void createPromptDialog(WebView view, String message, String defaultValue, final JsPromptResult result, String responseMessage, String responseDefaultValue, String value, String cancelButtonTitle, String confirmButtonTitle) { public void createPromptDialog(WebView view, String message, String defaultValue, final JsPromptResult result, String responseMessage, String responseDefaultValue, String value, String cancelButtonTitle, String confirmButtonTitle) {
@ -506,25 +494,12 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
@Override @Override
public boolean onJsBeforeUnload(final WebView view, String url, final String message, public boolean onJsBeforeUnload(final WebView view, String url, final String message,
final JsResult result) { final JsResult result) {
Map<String, Object> obj = new HashMap<>(); if (inAppWebView != null && inAppWebView.eventChannelDelegate != null) {
obj.put("url", url); inAppWebView.eventChannelDelegate.onJsBeforeUnload(url, message, new EventChannelDelegate.JsBeforeUnloadCallback() {
obj.put("message", message); @Override
public boolean nonNullSuccess(@NonNull JsBeforeUnloadResponse response) {
channel.invokeMethod("onJsBeforeUnload", obj, new MethodChannel.Result() { if (response.isHandledByClient()) {
@Override Integer action = response.getAction();
public void success(Object response) {
String responseMessage = null;
String confirmButtonTitle = null;
String cancelButtonTitle = null;
if (response != null) {
Map<String, Object> responseMap = (Map<String, Object>) response;
responseMessage = (String) responseMap.get("message");
confirmButtonTitle = (String) responseMap.get("confirmButtonTitle");
cancelButtonTitle = (String) responseMap.get("cancelButtonTitle");
Boolean handledByClient = (Boolean) responseMap.get("handledByClient");
if (handledByClient != null && handledByClient) {
Integer action = (Integer) responseMap.get("action");
action = action != null ? action : 1; action = action != null ? action : 1;
switch (action) { switch (action) {
case 0: case 0:
@ -534,26 +509,35 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
default: default:
result.cancel(); result.cancel();
} }
return; return false;
} }
return true;
} }
createBeforeUnloadDialog(view, message, result, responseMessage, confirmButtonTitle, cancelButtonTitle); @Override
} public void defaultBehaviour(@Nullable JsBeforeUnloadResponse response) {
String responseMessage = null;
String confirmButtonTitle = null;
String cancelButtonTitle = null;
if (response != null) {
responseMessage = response.getMessage();
confirmButtonTitle = response.getConfirmButtonTitle();
cancelButtonTitle = response.getCancelButtonTitle();
}
createBeforeUnloadDialog(view, message, result, responseMessage, confirmButtonTitle, cancelButtonTitle);
}
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : "")); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
result.cancel(); result.cancel();
} }
});
@Override return true;
public void notImplemented() { }
createConfirmDialog(view, message, result, null, null, null);
}
});
return true; return false;
} }
public void createBeforeUnloadDialog(WebView view, String message, final JsResult result, String responseMessage, String confirmButtonTitle, String cancelButtonTitle) { public void createBeforeUnloadDialog(WebView view, String message, final JsResult result, String responseMessage, String confirmButtonTitle, String cancelButtonTitle) {
@ -636,84 +620,82 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
windowWebViewMessages.put(windowId, resultMsg); windowWebViewMessages.put(windowId, resultMsg);
channel.invokeMethod("onCreateWindow", createWindowAction.toMap(), new MethodChannel.Result() { if (inAppWebView != null && inAppWebView.eventChannelDelegate != null) {
@Override inAppWebView.eventChannelDelegate.onCreateWindow(createWindowAction, new EventChannelDelegate.CreateWindowCallback() {
public void success(@Nullable Object result) { @Override
boolean handledByClient = false; public boolean nonNullSuccess(@NonNull Boolean handledByClient) {
if (result instanceof Boolean) { return !handledByClient;
handledByClient = (boolean) result;
} }
if (!handledByClient && InAppWebViewChromeClient.windowWebViewMessages.containsKey(windowId)) {
@Override
public void defaultBehaviour(@Nullable Boolean handledByClient) {
InAppWebViewChromeClient.windowWebViewMessages.remove(windowId); InAppWebViewChromeClient.windowWebViewMessages.remove(windowId);
} }
}
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : "")); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
if (InAppWebViewChromeClient.windowWebViewMessages.containsKey(windowId)) { defaultBehaviour(null);
InAppWebViewChromeClient.windowWebViewMessages.remove(windowId);
} }
} });
@Override return true;
public void notImplemented() { }
if (InAppWebViewChromeClient.windowWebViewMessages.containsKey(windowId)) {
InAppWebViewChromeClient.windowWebViewMessages.remove(windowId);
}
}
});
return true; return false;
} }
@Override @Override
public void onCloseWindow(WebView window) { public void onCloseWindow(WebView window) {
final Map<String, Object> obj = new HashMap<>(); if (inAppWebView != null && inAppWebView.eventChannelDelegate != null) {
channel.invokeMethod("onCloseWindow", obj); inAppWebView.eventChannelDelegate.onCloseWindow();
}
super.onCloseWindow(window); super.onCloseWindow(window);
} }
@Override @Override
public void onGeolocationPermissionsShowPrompt(final String origin, final GeolocationPermissions.Callback callback) { public void onGeolocationPermissionsShowPrompt(final String origin, final GeolocationPermissions.Callback callback) {
Map<String, Object> obj = new HashMap<>(); final EventChannelDelegate.GeolocationPermissionsShowPromptCallback resultCallback = new EventChannelDelegate.GeolocationPermissionsShowPromptCallback() {
obj.put("origin", origin);
channel.invokeMethod("onGeolocationPermissionsShowPrompt", obj, new MethodChannel.Result() {
@Override @Override
public void success(Object o) { public boolean nonNullSuccess(@NonNull GeolocationPermissionShowPromptResponse response) {
Map<String, Object> response = (Map<String, Object>) o; callback.invoke(response.getOrigin(), response.isAllow(), response.isRetain());
if (response != null) return false;
callback.invoke((String) response.get("origin"), (Boolean) response.get("allow"), (Boolean) response.get("retain")); }
else
callback.invoke(origin, false, false); @Override
public void defaultBehaviour(@Nullable GeolocationPermissionShowPromptResponse response) {
callback.invoke(origin, false, false);
} }
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : "")); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
callback.invoke(origin, false, false); defaultBehaviour(null);
} }
};
@Override
public void notImplemented() { if (inAppWebView != null && inAppWebView.eventChannelDelegate != null) {
callback.invoke(origin, false, false); inAppWebView.eventChannelDelegate.onGeolocationPermissionsShowPrompt(origin, resultCallback);
} } else {
}); resultCallback.defaultBehaviour(null);
}
} }
@Override @Override
public void onGeolocationPermissionsHidePrompt() { public void onGeolocationPermissionsHidePrompt() {
Map<String, Object> obj = new HashMap<>(); if (inAppWebView != null && inAppWebView.eventChannelDelegate != null) {
channel.invokeMethod("onGeolocationPermissionsHidePrompt", obj); inAppWebView.eventChannelDelegate.onGeolocationPermissionsHidePrompt();
}
} }
@Override @Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) { public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
Map<String, Object> obj = new HashMap<>(); if (inAppWebView != null && inAppWebView.eventChannelDelegate != null) {
obj.put("message", consoleMessage.message()); inAppWebView.eventChannelDelegate.onConsoleMessage(
obj.put("messageLevel", consoleMessage.messageLevel().ordinal()); consoleMessage.message(),
channel.invokeMethod("onConsoleMessage", obj); consoleMessage.messageLevel().ordinal());
}
return true; return true;
} }
@ -721,19 +703,20 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
public void onProgressChanged(WebView view, int progress) { public void onProgressChanged(WebView view, int progress) {
super.onProgressChanged(view, progress); super.onProgressChanged(view, progress);
InAppWebView webView = (InAppWebView) view;
if (inAppBrowserDelegate != null) { if (inAppBrowserDelegate != null) {
inAppBrowserDelegate.didChangeProgress(progress); inAppBrowserDelegate.didChangeProgress(progress);
} }
InAppWebView webView = (InAppWebView) view;
if (webView.inAppWebViewClient != null) { if (webView.inAppWebViewClient != null) {
webView.inAppWebViewClient.loadCustomJavaScriptOnPageStarted(view); webView.inAppWebViewClient.loadCustomJavaScriptOnPageStarted(view);
} }
Map<String, Object> obj = new HashMap<>(); if (webView.eventChannelDelegate != null) {
obj.put("progress", progress); webView.eventChannelDelegate.onProgressChanged(progress);
channel.invokeMethod("onProgressChanged", obj); }
} }
@Override @Override
@ -743,10 +726,12 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
if (inAppBrowserDelegate != null) { if (inAppBrowserDelegate != null) {
inAppBrowserDelegate.didChangeTitle(title); inAppBrowserDelegate.didChangeTitle(title);
} }
InAppWebView webView = (InAppWebView) view;
Map<String, Object> obj = new HashMap<>(); if (webView.eventChannelDelegate != null) {
obj.put("title", title); webView.eventChannelDelegate.onTitleChanged(title);
channel.invokeMethod("onTitleChanged", obj); }
} }
@Override @Override
@ -766,9 +751,10 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
} }
icon.recycle(); icon.recycle();
Map<String, Object> obj = new HashMap<>(); InAppWebView webView = (InAppWebView) view;
obj.put("icon", byteArrayOutputStream.toByteArray()); if (webView.eventChannelDelegate != null) {
channel.invokeMethod("onReceivedIcon", obj); webView.eventChannelDelegate.onReceivedIcon(byteArrayOutputStream.toByteArray());
}
} }
@Override @Override
@ -777,10 +763,10 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
boolean precomposed) { boolean precomposed) {
super.onReceivedTouchIconUrl(view, url, precomposed); super.onReceivedTouchIconUrl(view, url, precomposed);
Map<String, Object> obj = new HashMap<>(); InAppWebView webView = (InAppWebView) view;
obj.put("url", url); if (webView.eventChannelDelegate != null) {
obj.put("precomposed", precomposed); webView.eventChannelDelegate.onReceivedTouchIconUrl(url, precomposed);
channel.invokeMethod("onReceivedTouchIconUrl", obj); }
} }
@Nullable @Nullable
@ -1171,47 +1157,44 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
@Override @Override
public void onPermissionRequest(final PermissionRequest request) { public void onPermissionRequest(final PermissionRequest request) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Map<String, Object> obj = new HashMap<>(); final EventChannelDelegate.PermissionRequestCallback callback = new EventChannelDelegate.PermissionRequestCallback() {
obj.put("origin", request.getOrigin().toString());
obj.put("resources", Arrays.asList(request.getResources()));
obj.put("frame", null);
channel.invokeMethod("onPermissionRequest", obj, new MethodChannel.Result() {
@Override @Override
public void success(Object response) { public boolean nonNullSuccess(@NonNull PermissionResponse response) {
if (response != null) { Integer action = response.getAction();
Map<String, Object> responseMap = (Map<String, Object>) response; if (action != null) {
Integer action = (Integer) responseMap.get("action"); switch (action) {
List<String> resourceList = (List<String>) responseMap.get("resources"); case 1:
if (resourceList == null) String[] resources = new String[response.getResources().size()];
resourceList = new ArrayList<String>(); resources = response.getResources().toArray(resources);
String[] resources = new String[resourceList.size()]; request.grant(resources);
resources = resourceList.toArray(resources); break;
if (action != null) { case 0:
switch (action) { default:
case 1: request.deny();
request.grant(resources);
return;
case 0:
default:
request.deny();
return;
}
} }
return false;
} }
return true;
}
@Override
public void defaultBehaviour(@Nullable PermissionResponse response) {
request.deny(); request.deny();
} }
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : "")); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
request.deny(); defaultBehaviour(null);
} }
};
@Override
public void notImplemented() { if(inAppWebView != null && inAppWebView.eventChannelDelegate != null) {
request.deny(); inAppWebView.eventChannelDelegate.onPermissionRequest(request.getOrigin().toString(),
} Arrays.asList(request.getResources()), null, callback);
}); } else {
callback.defaultBehaviour(null);
}
} }
} }

View File

@ -26,7 +26,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.webkit.WebResourceRequestCompat; import androidx.webkit.WebResourceRequestCompat;
import androidx.webkit.WebViewCompat;
import androidx.webkit.WebViewFeature; import androidx.webkit.WebViewFeature;
import com.pichillilorenzo.flutter_inappwebview.Util; import com.pichillilorenzo.flutter_inappwebview.Util;
@ -34,9 +33,13 @@ import com.pichillilorenzo.flutter_inappwebview.credential_database.CredentialDa
import com.pichillilorenzo.flutter_inappwebview.in_app_browser.InAppBrowserDelegate; import com.pichillilorenzo.flutter_inappwebview.in_app_browser.InAppBrowserDelegate;
import com.pichillilorenzo.flutter_inappwebview.plugin_scripts_js.JavaScriptBridgeJS; import com.pichillilorenzo.flutter_inappwebview.plugin_scripts_js.JavaScriptBridgeJS;
import com.pichillilorenzo.flutter_inappwebview.types.ClientCertChallenge; import com.pichillilorenzo.flutter_inappwebview.types.ClientCertChallenge;
import com.pichillilorenzo.flutter_inappwebview.types.ClientCertResponse;
import com.pichillilorenzo.flutter_inappwebview.types.CustomSchemeResponse;
import com.pichillilorenzo.flutter_inappwebview.types.HttpAuthResponse;
import com.pichillilorenzo.flutter_inappwebview.types.HttpAuthenticationChallenge; import com.pichillilorenzo.flutter_inappwebview.types.HttpAuthenticationChallenge;
import com.pichillilorenzo.flutter_inappwebview.types.NavigationAction; import com.pichillilorenzo.flutter_inappwebview.types.NavigationAction;
import com.pichillilorenzo.flutter_inappwebview.types.NavigationActionPolicy; import com.pichillilorenzo.flutter_inappwebview.types.NavigationActionPolicy;
import com.pichillilorenzo.flutter_inappwebview.types.ServerTrustAuthResponse;
import com.pichillilorenzo.flutter_inappwebview.types.ServerTrustChallenge; import com.pichillilorenzo.flutter_inappwebview.types.ServerTrustChallenge;
import com.pichillilorenzo.flutter_inappwebview.types.URLCredential; import com.pichillilorenzo.flutter_inappwebview.types.URLCredential;
import com.pichillilorenzo.flutter_inappwebview.types.URLProtectionSpace; import com.pichillilorenzo.flutter_inappwebview.types.URLProtectionSpace;
@ -49,25 +52,19 @@ import java.io.ByteArrayInputStream;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import io.flutter.plugin.common.MethodChannel;
public class InAppWebViewClient extends WebViewClient { public class InAppWebViewClient extends WebViewClient {
protected static final String LOG_TAG = "IAWebViewClient"; protected static final String LOG_TAG = "IAWebViewClient";
private InAppBrowserDelegate inAppBrowserDelegate; private InAppBrowserDelegate inAppBrowserDelegate;
private final MethodChannel channel;
private static int previousAuthRequestFailureCount = 0; private static int previousAuthRequestFailureCount = 0;
private static List<URLCredential> credentialsProposed = null; private static List<URLCredential> credentialsProposed = null;
public InAppWebViewClient(MethodChannel channel, InAppBrowserDelegate inAppBrowserDelegate) { public InAppWebViewClient(InAppBrowserDelegate inAppBrowserDelegate) {
super(); super();
this.channel = channel;
this.inAppBrowserDelegate = inAppBrowserDelegate; this.inAppBrowserDelegate = inAppBrowserDelegate;
} }
@ -136,41 +133,37 @@ public class InAppWebViewClient extends WebViewClient {
isRedirect isRedirect
); );
channel.invokeMethod("shouldOverrideUrlLoading", navigationAction.toMap(), new MethodChannel.Result() { final EventChannelDelegate.ShouldOverrideUrlLoadingCallback callback = new EventChannelDelegate.ShouldOverrideUrlLoadingCallback() {
@Override @Override
public void success(Object response) { public boolean nonNullSuccess(@NonNull NavigationActionPolicy result) {
if (response != null) { switch (result) {
Map<String, Object> responseMap = (Map<String, Object>) response; case ALLOW:
Integer action = (Integer) responseMap.get("action"); allowShouldOverrideUrlLoading(webView, url, headers, isForMainFrame);
action = action != null ? action : NavigationActionPolicy.CANCEL.rawValue(); break;
case CANCEL:
NavigationActionPolicy navigationActionPolicy = NavigationActionPolicy.fromValue(action); default:
if (navigationActionPolicy != null) { break;
switch (navigationActionPolicy) {
case ALLOW:
allowShouldOverrideUrlLoading(webView, url, headers, isForMainFrame);
return;
case CANCEL:
default:
return;
}
}
return;
} }
return false;
}
@Override
public void defaultBehaviour(@Nullable NavigationActionPolicy result) {
allowShouldOverrideUrlLoading(webView, url, headers, isForMainFrame); allowShouldOverrideUrlLoading(webView, url, headers, isForMainFrame);
} }
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : "")); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
allowShouldOverrideUrlLoading(webView, url, headers, isForMainFrame); defaultBehaviour(null);
} }
};
@Override
public void notImplemented() { if (webView.eventChannelDelegate != null) {
allowShouldOverrideUrlLoading(webView, url, headers, isForMainFrame); webView.eventChannelDelegate.shouldOverrideUrlLoading(navigationAction, callback);
} } else {
}); callback.defaultBehaviour(null);
}
} }
public void loadCustomJavaScriptOnPageStarted(WebView view) { public void loadCustomJavaScriptOnPageStarted(WebView view) {
@ -211,9 +204,9 @@ public class InAppWebViewClient extends WebViewClient {
inAppBrowserDelegate.didStartNavigation(url); inAppBrowserDelegate.didStartNavigation(url);
} }
Map<String, Object> obj = new HashMap<>(); if (webView.eventChannelDelegate != null) {
obj.put("url", url); webView.eventChannelDelegate.onLoadStart(url);
channel.invokeMethod("onLoadStart", obj); }
} }
@ -245,26 +238,26 @@ public class InAppWebViewClient extends WebViewClient {
webView.loadUrl("javascript:" + js.replaceAll("[\r\n]+", "")); webView.loadUrl("javascript:" + js.replaceAll("[\r\n]+", ""));
} }
Map<String, Object> obj = new HashMap<>(); if (webView.eventChannelDelegate != null) {
obj.put("url", url); webView.eventChannelDelegate.onLoadStop(url);
channel.invokeMethod("onLoadStop", obj); }
} }
@Override @Override
public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) { public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
super.doUpdateVisitedHistory(view, url, isReload); super.doUpdateVisitedHistory(view, url, isReload);
// url argument sometimes doesn't contain the new changed URL, so we get it again from the webview.
url = view.getUrl(); url = view.getUrl();
if (inAppBrowserDelegate != null) { if (inAppBrowserDelegate != null) {
inAppBrowserDelegate.didUpdateVisitedHistory(url); inAppBrowserDelegate.didUpdateVisitedHistory(url);
} }
Map<String, Object> obj = new HashMap<>(); final InAppWebView webView = (InAppWebView) view;
// url argument sometimes doesn't contain the new changed URL, so we get it again from the webview. if (webView.eventChannelDelegate != null) {
obj.put("url", url); webView.eventChannelDelegate.onUpdateVisitedHistory(url, isReload);
obj.put("isReload", isReload); }
channel.invokeMethod("onUpdateVisitedHistory", obj);
} }
@RequiresApi(api = Build.VERSION_CODES.M) @RequiresApi(api = Build.VERSION_CODES.M)
@ -287,10 +280,11 @@ public class InAppWebViewClient extends WebViewClient {
} }
} }
Map<String, Object> obj = new HashMap<>(); if (webView.eventChannelDelegate != null) {
obj.put("request", WebResourceRequestExt.fromWebResourceRequest(request).toMap()); webView.eventChannelDelegate.onReceivedError(
obj.put("error", WebResourceErrorExt.fromWebResourceError(error).toMap()); WebResourceRequestExt.fromWebResourceRequest(request),
channel.invokeMethod("onReceivedError", obj); WebResourceErrorExt.fromWebResourceError(error));
}
} }
@Override @Override
@ -323,10 +317,11 @@ public class InAppWebViewClient extends WebViewClient {
description description
); );
Map<String, Object> obj = new HashMap<>(); if (webView.eventChannelDelegate != null) {
obj.put("request", request.toMap()); webView.eventChannelDelegate.onReceivedError(
obj.put("error",error.toMap()); request,
channel.invokeMethod("onReceivedError", obj); error);
}
super.onReceivedError(view, errorCode, description, failingUrl); super.onReceivedError(view, errorCode, description, failingUrl);
} }
@ -336,15 +331,16 @@ public class InAppWebViewClient extends WebViewClient {
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
super.onReceivedHttpError(view, request, errorResponse); super.onReceivedHttpError(view, request, errorResponse);
Map<String, Object> obj = new HashMap<>(); final InAppWebView webView = (InAppWebView) view;
obj.put("request", WebResourceRequestExt.fromWebResourceRequest(request).toMap()); if (webView.eventChannelDelegate != null) {
obj.put("errorResponse", WebResourceResponseExt.fromWebResourceResponse(errorResponse).toMap()); webView.eventChannelDelegate.onReceivedHttpError(
channel.invokeMethod("onReceivedHttpError", obj); WebResourceRequestExt.fromWebResourceRequest(request),
WebResourceResponseExt.fromWebResourceResponse(errorResponse));
}
} }
@Override @Override
public void onReceivedHttpAuthRequest(final WebView view, final HttpAuthHandler handler, final String host, final String realm) { public void onReceivedHttpAuthRequest(final WebView view, final HttpAuthHandler handler, final String host, final String realm) {
URI uri; URI uri;
try { try {
uri = new URI(view.getUrl()); uri = new URI(view.getUrl());
@ -363,13 +359,6 @@ public class InAppWebViewClient extends WebViewClient {
previousAuthRequestFailureCount++; previousAuthRequestFailureCount++;
Map<String, Object> obj = new HashMap<>();
obj.put("host", host);
obj.put("protocol", protocol);
obj.put("realm", realm);
obj.put("port", port);
obj.put("previousFailureCount", previousAuthRequestFailureCount);
if (credentialsProposed == null) if (credentialsProposed == null)
credentialsProposed = CredentialDatabase.getInstance(view.getContext()).getHttpAuthCredentials(host, protocol, realm, port); credentialsProposed = CredentialDatabase.getInstance(view.getContext()).getHttpAuthCredentials(host, protocol, realm, port);
@ -381,56 +370,63 @@ public class InAppWebViewClient extends WebViewClient {
URLProtectionSpace protectionSpace = new URLProtectionSpace(host, protocol, realm, port, view.getCertificate(), null); URLProtectionSpace protectionSpace = new URLProtectionSpace(host, protocol, realm, port, view.getCertificate(), null);
HttpAuthenticationChallenge challenge = new HttpAuthenticationChallenge(protectionSpace, previousAuthRequestFailureCount, credentialProposed); HttpAuthenticationChallenge challenge = new HttpAuthenticationChallenge(protectionSpace, previousAuthRequestFailureCount, credentialProposed);
channel.invokeMethod("onReceivedHttpAuthRequest", challenge.toMap(), new MethodChannel.Result() { final InAppWebView webView = (InAppWebView) view;
final EventChannelDelegate.ReceivedHttpAuthRequestCallback callback = new EventChannelDelegate.ReceivedHttpAuthRequestCallback() {
@Override @Override
public void success(Object response) { public boolean nonNullSuccess(@NonNull HttpAuthResponse response) {
if (response != null) { Integer action = response.getAction();
Map<String, Object> responseMap = (Map<String, Object>) response; if (action != null) {
Integer action = (Integer) responseMap.get("action"); switch (action) {
if (action != null) { case 1:
switch (action) { String username = response.getUsername();
case 1: String password = response.getPassword();
String username = (String) responseMap.get("username"); boolean permanentPersistence = response.isPermanentPersistence();
String password = (String) responseMap.get("password"); if (permanentPersistence) {
Boolean permanentPersistence = (Boolean) responseMap.get("permanentPersistence"); CredentialDatabase.getInstance(view.getContext())
if (permanentPersistence != null && permanentPersistence) { .setHttpAuthCredential(host, protocol, realm, port, username, password);
CredentialDatabase.getInstance(view.getContext()).setHttpAuthCredential(host, protocol, realm, port, username, password); }
} handler.proceed(username, password);
handler.proceed(username, password); break;
return; case 2:
case 2: if (credentialsProposed.size() > 0) {
if (credentialsProposed.size() > 0) { URLCredential credential = credentialsProposed.remove(0);
URLCredential credential = credentialsProposed.remove(0); handler.proceed(credential.getUsername(), credential.getPassword());
handler.proceed(credential.getUsername(), credential.getPassword()); } else {
} else {
handler.cancel();
}
// used custom CredentialDatabase!
// handler.useHttpAuthUsernamePassword();
return;
case 0:
default:
credentialsProposed = null;
previousAuthRequestFailureCount = 0;
handler.cancel(); handler.cancel();
return; }
} // used custom CredentialDatabase!
// handler.useHttpAuthUsernamePassword();
break;
case 0:
default:
credentialsProposed = null;
previousAuthRequestFailureCount = 0;
handler.cancel();
} }
return false;
} }
return true;
}
@Override
public void defaultBehaviour(@Nullable HttpAuthResponse result) {
InAppWebViewClient.super.onReceivedHttpAuthRequest(view, handler, host, realm); InAppWebViewClient.super.onReceivedHttpAuthRequest(view, handler, host, realm);
} }
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : "")); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
defaultBehaviour(null);
} }
};
@Override
public void notImplemented() { if (webView.eventChannelDelegate != null) {
InAppWebViewClient.super.onReceivedHttpAuthRequest(view, handler, host, realm); webView.eventChannelDelegate.onReceivedHttpAuthRequest(challenge, callback);
} } else {
}); callback.defaultBehaviour(null);
}
} }
@Override @Override
@ -452,46 +448,49 @@ public class InAppWebViewClient extends WebViewClient {
URLProtectionSpace protectionSpace = new URLProtectionSpace(host, protocol, realm, port, sslError.getCertificate(), sslError); URLProtectionSpace protectionSpace = new URLProtectionSpace(host, protocol, realm, port, sslError.getCertificate(), sslError);
ServerTrustChallenge challenge = new ServerTrustChallenge(protectionSpace); ServerTrustChallenge challenge = new ServerTrustChallenge(protectionSpace);
channel.invokeMethod("onReceivedServerTrustAuthRequest", challenge.toMap(), new MethodChannel.Result() { final InAppWebView webView = (InAppWebView) view;
final EventChannelDelegate.ReceivedServerTrustAuthRequestCallback callback = new EventChannelDelegate.ReceivedServerTrustAuthRequestCallback() {
@Override @Override
public void success(Object response) { public boolean nonNullSuccess(@NonNull ServerTrustAuthResponse response) {
if (response != null) { Integer action = response.getAction();
Map<String, Object> responseMap = (Map<String, Object>) response; if (action != null) {
Integer action = (Integer) responseMap.get("action"); switch (action) {
if (action != null) { case 1:
switch (action) { handler.proceed();
case 1: break;
handler.proceed(); case 0:
return; default:
case 0: handler.cancel();
default:
handler.cancel();
return;
}
} }
return false;
} }
return true;
}
@Override
public void defaultBehaviour(@Nullable ServerTrustAuthResponse result) {
InAppWebViewClient.super.onReceivedSslError(view, handler, sslError); InAppWebViewClient.super.onReceivedSslError(view, handler, sslError);
} }
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : "")); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
defaultBehaviour(null);
} }
};
@Override
public void notImplemented() { if (webView.eventChannelDelegate != null) {
InAppWebViewClient.super.onReceivedSslError(view, handler, sslError); webView.eventChannelDelegate.onReceivedServerTrustAuthRequest(challenge, callback);
} } else {
}); callback.defaultBehaviour(null);
}
} }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override @Override
public void onReceivedClientCertRequest(final WebView view, final ClientCertRequest request) { public void onReceivedClientCertRequest(final WebView view, final ClientCertRequest request) {
InAppWebView webView = (InAppWebView) view;
URI uri; URI uri;
try { try {
uri = new URI(view.getUrl()); uri = new URI(view.getUrl());
@ -509,48 +508,58 @@ public class InAppWebViewClient extends WebViewClient {
URLProtectionSpace protectionSpace = new URLProtectionSpace(host, protocol, realm, port, view.getCertificate(), null); URLProtectionSpace protectionSpace = new URLProtectionSpace(host, protocol, realm, port, view.getCertificate(), null);
ClientCertChallenge challenge = new ClientCertChallenge(protectionSpace, request.getPrincipals(), request.getKeyTypes()); ClientCertChallenge challenge = new ClientCertChallenge(protectionSpace, request.getPrincipals(), request.getKeyTypes());
channel.invokeMethod("onReceivedClientCertRequest", challenge.toMap(), new MethodChannel.Result() { final InAppWebView webView = (InAppWebView) view;
final EventChannelDelegate.ReceivedClientCertRequestCallback callback = new EventChannelDelegate.ReceivedClientCertRequestCallback() {
@Override @Override
public void success(Object response) { public boolean nonNullSuccess(@NonNull ClientCertResponse response) {
if (response != null) { Integer action = response.getAction();
Map<String, Object> responseMap = (Map<String, Object>) response; if (action != null && webView.plugin != null) {
Integer action = (Integer) responseMap.get("action"); switch (action) {
if (action != null) { case 1:
switch (action) { {
case 1: String certificatePath = (String) response.getCertificatePath();
{ String certificatePassword = (String) response.getCertificatePassword();
InAppWebView webView = (InAppWebView) view; String keyStoreType = (String) response.getKeyStoreType();
String certificatePath = (String) responseMap.get("certificatePath"); Util.PrivateKeyAndCertificates privateKeyAndCertificates =
String certificatePassword = (String) responseMap.get("certificatePassword"); Util.loadPrivateKeyAndCertificate(webView.plugin, certificatePath, certificatePassword, keyStoreType);
String androidKeyStoreType = (String) responseMap.get("androidKeyStoreType"); if (privateKeyAndCertificates != null) {
Util.PrivateKeyAndCertificates privateKeyAndCertificates = Util.loadPrivateKeyAndCertificate(webView.plugin, certificatePath, certificatePassword, androidKeyStoreType);
request.proceed(privateKeyAndCertificates.privateKey, privateKeyAndCertificates.certificates); request.proceed(privateKeyAndCertificates.privateKey, privateKeyAndCertificates.certificates);
} else {
request.cancel();
} }
return; }
case 2: break;
request.ignore(); case 2:
return; request.ignore();
case 0: break;
default: case 0:
request.cancel(); default:
return; request.cancel();
}
} }
return false;
} }
return true;
}
@Override
public void defaultBehaviour(@Nullable ClientCertResponse result) {
InAppWebViewClient.super.onReceivedClientCertRequest(view, request); InAppWebViewClient.super.onReceivedClientCertRequest(view, request);
} }
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : "")); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
defaultBehaviour(null);
} }
};
@Override if (webView.eventChannelDelegate != null) {
public void notImplemented() { webView.eventChannelDelegate.onReceivedClientCertRequest(challenge, callback);
InAppWebViewClient.super.onReceivedClientCertRequest(view, request); } else {
} callback.defaultBehaviour(null);
}); }
} }
@Override @Override
@ -559,68 +568,64 @@ public class InAppWebViewClient extends WebViewClient {
final InAppWebView webView = (InAppWebView) view; final InAppWebView webView = (InAppWebView) view;
webView.zoomScale = newScale / Util.getPixelDensity(webView.getContext()); webView.zoomScale = newScale / Util.getPixelDensity(webView.getContext());
Map<String, Object> obj = new HashMap<>(); if (webView.eventChannelDelegate != null) {
obj.put("oldScale", oldScale); webView.eventChannelDelegate.onZoomScaleChanged(oldScale, newScale);
obj.put("newScale", newScale); }
channel.invokeMethod("onZoomScaleChanged", obj);
} }
@RequiresApi(api = Build.VERSION_CODES.O_MR1) @RequiresApi(api = Build.VERSION_CODES.O_MR1)
@Override @Override
public void onSafeBrowsingHit(final WebView view, final WebResourceRequest request, final int threatType, final SafeBrowsingResponse callback) { public void onSafeBrowsingHit(final WebView view, final WebResourceRequest request, final int threatType, final SafeBrowsingResponse callback) {
Map<String, Object> obj = new HashMap<>(); final InAppWebView webView = (InAppWebView) view;
obj.put("url", request.getUrl().toString()); final EventChannelDelegate.SafeBrowsingHitCallback resultCallback = new EventChannelDelegate.SafeBrowsingHitCallback() {
obj.put("threatType", threatType);
channel.invokeMethod("onSafeBrowsingHit", obj, new MethodChannel.Result() {
@Override @Override
public void success(Object response) { public boolean nonNullSuccess(@NonNull com.pichillilorenzo.flutter_inappwebview.types.SafeBrowsingResponse response) {
if (response != null) { Integer action = response.getAction();
Map<String, Object> responseMap = (Map<String, Object>) response; if (action != null) {
Boolean report = (Boolean) responseMap.get("report"); boolean report = response.isReport();
Integer action = (Integer) responseMap.get("action"); switch (action) {
case 0:
report = report != null ? report : true; callback.backToSafety(report);
break;
if (action != null) { case 1:
switch (action) { callback.proceed(report);
case 0: break;
callback.backToSafety(report); case 2:
return; default:
case 1: callback.showInterstitial(report);
callback.proceed(report);
return;
case 2:
default:
callback.showInterstitial(report);
return;
}
} }
return false;
} }
return true;
}
@Override
public void defaultBehaviour(@Nullable com.pichillilorenzo.flutter_inappwebview.types.SafeBrowsingResponse result) {
InAppWebViewClient.super.onSafeBrowsingHit(view, request, threatType, callback); InAppWebViewClient.super.onSafeBrowsingHit(view, request, threatType, callback);
} }
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : "")); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
defaultBehaviour(null);
} }
};
@Override if (webView.eventChannelDelegate != null) {
public void notImplemented() { webView.eventChannelDelegate.onSafeBrowsingHit(request.getUrl().toString(), threatType, resultCallback);
InAppWebViewClient.super.onSafeBrowsingHit(view, request, threatType, callback); } else {
} resultCallback.defaultBehaviour(null);
}); }
} }
@Override @Override
public WebResourceResponse shouldInterceptRequest(WebView view, final String url) { public WebResourceResponse shouldInterceptRequest(WebView view, final String url) {
final InAppWebView webView = (InAppWebView) view; final InAppWebView webView = (InAppWebView) view;
if (webView.customSettings.useShouldInterceptRequest) { if (webView.customSettings.useShouldInterceptRequest) {
WebResourceResponse onShouldInterceptResponse = onShouldInterceptRequest(url); return onShouldInterceptRequest(view, url);
return onShouldInterceptResponse;
} }
URI uri; URI uri;
@ -641,32 +646,28 @@ public class InAppWebViewClient extends WebViewClient {
String scheme = uri.getScheme(); String scheme = uri.getScheme();
if (webView.customSettings.resourceCustomSchemes != null && webView.customSettings.resourceCustomSchemes.contains(scheme)) { if (webView.customSettings.resourceCustomSchemes != null && webView.customSettings.resourceCustomSchemes.contains(scheme)) {
final Map<String, Object> obj = new HashMap<>(); CustomSchemeResponse customSchemeResponse = null;
obj.put("url", url); if (webView.eventChannelDelegate != null) {
try {
Util.WaitFlutterResult flutterResult; customSchemeResponse = webView.eventChannelDelegate.onLoadResourceCustomScheme(url);
try { } catch (InterruptedException e) {
flutterResult = Util.invokeMethodAndWait(channel, "onLoadResourceCustomScheme", obj); e.printStackTrace();
} catch (InterruptedException e) { return null;
e.printStackTrace(); }
return null;
} }
if (flutterResult.error != null) { if (customSchemeResponse != null) {
Log.e(LOG_TAG, flutterResult.error);
}
else if (flutterResult.result != null) {
Map<String, Object> res = (Map<String, Object>) flutterResult.result;
WebResourceResponse response = null; WebResourceResponse response = null;
try { try {
response = webView.contentBlockerHandler.checkUrl(webView, url, res.get("contentType").toString()); response = webView.contentBlockerHandler.checkUrl(webView, url, customSchemeResponse.getContentType());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
if (response != null) if (response != null)
return response; return response;
byte[] data = (byte[]) res.get("data"); return new WebResourceResponse(customSchemeResponse.getContentType(),
return new WebResourceResponse(res.get("contentType").toString(), res.get("contentEncoding").toString(), new ByteArrayInputStream(data)); customSchemeResponse.getContentType(),
new ByteArrayInputStream(customSchemeResponse.getData()));
} }
} }
@ -689,68 +690,50 @@ public class InAppWebViewClient extends WebViewClient {
String url = request.getUrl().toString(); String url = request.getUrl().toString();
if (webView.customSettings.useShouldInterceptRequest) { if (webView.customSettings.useShouldInterceptRequest) {
WebResourceResponse onShouldInterceptResponse = onShouldInterceptRequest(request); return onShouldInterceptRequest(view, request);
return onShouldInterceptResponse;
} }
return shouldInterceptRequest(view, url); return shouldInterceptRequest(view, url);
} }
public WebResourceResponse onShouldInterceptRequest(Object request) { public WebResourceResponse onShouldInterceptRequest(WebView view, Object request) {
String url = request instanceof String ? (String) request : null; final InAppWebView webView = (InAppWebView) view;
String method = "GET";
Map<String, String> headers = null; WebResourceRequestExt requestExt;
boolean hasGesture = false;
boolean isForMainFrame = true;
boolean isRedirect = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && request instanceof WebResourceRequest) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && request instanceof WebResourceRequest) {
WebResourceRequest webResourceRequest = (WebResourceRequest) request; WebResourceRequest webResourceRequest = (WebResourceRequest) request;
url = webResourceRequest.getUrl().toString(); requestExt = WebResourceRequestExt.fromWebResourceRequest(webResourceRequest);
headers = webResourceRequest.getRequestHeaders(); } else {
hasGesture = webResourceRequest.hasGesture(); requestExt = new WebResourceRequestExt(
isForMainFrame = webResourceRequest.isForMainFrame(); Uri.parse((String) request), null, false,
if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_RESOURCE_REQUEST_IS_REDIRECT)) { false, true, "GET"
isRedirect = WebResourceRequestCompat.isRedirect(webResourceRequest); );
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { }
isRedirect = webResourceRequest.isRedirect();
WebResourceResponseExt response = null;
if (webView.eventChannelDelegate != null) {
try {
response = webView.eventChannelDelegate.shouldInterceptRequest(requestExt);
} catch (InterruptedException e) {
e.printStackTrace();
return null;
} }
} }
final Map<String, Object> obj = new HashMap<>(); if (response != null) {
obj.put("url", url); String contentType = response.getContentType();
obj.put("method", method); String contentEncoding = response.getContentEncoding();
obj.put("headers", headers); byte[] data = response.getData();
obj.put("isForMainFrame", isForMainFrame); Map<String, String> responseHeaders = response.getHeaders();
obj.put("hasGesture", hasGesture); Integer statusCode = response.getStatusCode();
obj.put("isRedirect", isRedirect); String reasonPhrase = response.getReasonPhrase();
Util.WaitFlutterResult flutterResult;
try {
flutterResult = Util.invokeMethodAndWait(channel, "shouldInterceptRequest", obj);
} catch (InterruptedException e) {
e.printStackTrace();
return null;
}
if (flutterResult.error != null) {
Log.e(LOG_TAG, flutterResult.error);
}
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");
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; ByteArrayInputStream inputStream = (data != null) ? new ByteArrayInputStream(data) : null;
if ((responseHeaders == null && statusCode == null && reasonPhrase == null) || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && statusCode != null && reasonPhrase != null) {
return new WebResourceResponse(contentType, contentEncoding, inputStream);
} else {
return new WebResourceResponse(contentType, contentEncoding, statusCode, reasonPhrase, responseHeaders, inputStream); return new WebResourceResponse(contentType, contentEncoding, statusCode, reasonPhrase, responseHeaders, inputStream);
} else {
return new WebResourceResponse(contentType, contentEncoding, inputStream);
} }
} }
@ -758,51 +741,49 @@ public class InAppWebViewClient extends WebViewClient {
} }
@Override @Override
public void onFormResubmission (final WebView view, final Message dontResend, final Message resend) { public void onFormResubmission(final WebView view, final Message dontResend, final Message resend) {
Map<String, Object> obj = new HashMap<>(); final InAppWebView webView = (InAppWebView) view;
obj.put("url", view.getUrl()); final EventChannelDelegate.FormResubmissionCallback callback = new EventChannelDelegate.FormResubmissionCallback() {
@Override
channel.invokeMethod("onFormResubmission", obj, new MethodChannel.Result() { public boolean nonNullSuccess(@NonNull Integer action) {
switch (action) {
case 0:
resend.sendToTarget();
break;
case 1:
default:
dontResend.sendToTarget();
}
return false;
}
@Override @Override
public void success(@Nullable Object response) { public void defaultBehaviour(@Nullable Integer result) {
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;
}
}
}
InAppWebViewClient.super.onFormResubmission(view, dontResend, resend); InAppWebViewClient.super.onFormResubmission(view, dontResend, resend);
} }
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, "ERROR: " + errorCode + " " + errorMessage); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
defaultBehaviour(null);
} }
};
@Override if (webView.eventChannelDelegate != null) {
public void notImplemented() { webView.eventChannelDelegate.onFormResubmission(webView.getUrl(), callback);
InAppWebViewClient.super.onFormResubmission(view, dontResend, resend); } else {
} callback.defaultBehaviour(null);
}); }
} }
@Override @Override
public void onPageCommitVisible(WebView view, String url) { public void onPageCommitVisible(WebView view, String url) {
super.onPageCommitVisible(view, url); super.onPageCommitVisible(view, url);
Map<String, Object> obj = new HashMap<>();
obj.put("url", url); final InAppWebView webView = (InAppWebView) view;
channel.invokeMethod("onPageCommitVisible", obj); if (webView.eventChannelDelegate != null) {
webView.eventChannelDelegate.onPageCommitVisible(url);
}
} }
@RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O)
@ -810,16 +791,10 @@ public class InAppWebViewClient extends WebViewClient {
public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail) { public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail) {
final InAppWebView webView = (InAppWebView) view; final InAppWebView webView = (InAppWebView) view;
if (webView.customSettings.useOnRenderProcessGone) { if (webView.customSettings.useOnRenderProcessGone && webView.eventChannelDelegate != null) {
Boolean didCrash = detail.didCrash(); boolean didCrash = detail.didCrash();
Integer rendererPriorityAtExit = detail.rendererPriorityAtExit(); int rendererPriorityAtExit = detail.rendererPriorityAtExit();
webView.eventChannelDelegate.onRenderProcessGone(didCrash, rendererPriorityAtExit);
Map<String, Object> obj = new HashMap<>();
obj.put("didCrash", didCrash);
obj.put("rendererPriorityAtExit", rendererPriorityAtExit);
channel.invokeMethod("onRenderProcessGone", obj);
return true; return true;
} }
@ -828,18 +803,14 @@ public class InAppWebViewClient extends WebViewClient {
@Override @Override
public void onReceivedLoginRequest(WebView view, String realm, String account, String args) { public void onReceivedLoginRequest(WebView view, String realm, String account, String args) {
Map<String, Object> obj = new HashMap<>(); final InAppWebView webView = (InAppWebView) view;
obj.put("realm", realm); if (webView.eventChannelDelegate != null) {
obj.put("account", account); webView.eventChannelDelegate.onReceivedLoginRequest(realm, account, args);
obj.put("args", args); }
channel.invokeMethod("onReceivedLoginRequest", obj);
} }
@Override @Override
public void onUnhandledKeyEvent(WebView view, KeyEvent event) { public void onUnhandledKeyEvent(WebView view, KeyEvent event) {}
}
public void dispose() { public void dispose() {
if (inAppBrowserDelegate != null) { if (inAppBrowserDelegate != null) {

View File

@ -9,88 +9,86 @@ import androidx.webkit.WebViewFeature;
import androidx.webkit.WebViewRenderProcess; import androidx.webkit.WebViewRenderProcess;
import androidx.webkit.WebViewRenderProcessClient; import androidx.webkit.WebViewRenderProcessClient;
import java.util.HashMap;
import java.util.Map;
import io.flutter.plugin.common.MethodChannel;
public class InAppWebViewRenderProcessClient extends WebViewRenderProcessClient { public class InAppWebViewRenderProcessClient extends WebViewRenderProcessClient {
protected static final String LOG_TAG = "IAWRenderProcessClient"; protected static final String LOG_TAG = "IAWRenderProcessClient";
private final MethodChannel channel;
public InAppWebViewRenderProcessClient(MethodChannel channel) { public InAppWebViewRenderProcessClient() {
super(); super();
this.channel = channel;
} }
@Override @Override
public void onRenderProcessUnresponsive(@NonNull WebView view, @Nullable final WebViewRenderProcess renderer) { public void onRenderProcessUnresponsive(@NonNull WebView view, @Nullable final WebViewRenderProcess renderer) {
Map<String, Object> obj = new HashMap<>(); final InAppWebView webView = (InAppWebView) view;
obj.put("url", view.getUrl()); final EventChannelDelegate.RenderProcessUnresponsiveCallback callback = new EventChannelDelegate.RenderProcessUnresponsiveCallback() {
channel.invokeMethod("onRenderProcessUnresponsive", obj, new MethodChannel.Result() { @Override
public boolean nonNullSuccess(@NonNull Integer action) {
if (renderer != null) {
switch (action) {
case 0:
if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_VIEW_RENDERER_TERMINATE))
renderer.terminate();
break;
}
return false;
}
return true;
}
@Override @Override
public void success(@Nullable Object response) { public void defaultBehaviour(@Nullable Integer result) {
if (response != null) {
Map<String, Object> responseMap = (Map<String, Object>) response;
Integer action = (Integer) responseMap.get("action");
if (action != null && renderer != null) {
switch (action) {
case 0:
if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_VIEW_RENDERER_TERMINATE))
renderer.terminate();
break;
}
}
}
} }
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : "")); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
defaultBehaviour(null);
} }
};
@Override if (webView.eventChannelDelegate != null) {
public void notImplemented() { webView.eventChannelDelegate.onRenderProcessUnresponsive(webView.getUrl(), callback);
} else {
} callback.defaultBehaviour(null);
}); }
} }
@Override @Override
public void onRenderProcessResponsive(@NonNull WebView view, @Nullable final WebViewRenderProcess renderer) { public void onRenderProcessResponsive(@NonNull WebView view, @Nullable final WebViewRenderProcess renderer) {
Map<String, Object> obj = new HashMap<>(); final InAppWebView webView = (InAppWebView) view;
obj.put("url", view.getUrl()); final EventChannelDelegate.RenderProcessResponsiveCallback callback = new EventChannelDelegate.RenderProcessResponsiveCallback() {
channel.invokeMethod("onRenderProcessResponsive", obj, new MethodChannel.Result() { @Override
public boolean nonNullSuccess(@NonNull Integer action) {
if (renderer != null) {
switch (action) {
case 0:
if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_VIEW_RENDERER_TERMINATE))
renderer.terminate();
break;
}
return false;
}
return true;
}
@Override @Override
public void success(@Nullable Object response) { public void defaultBehaviour(@Nullable Integer result) {
if (response != null) {
Map<String, Object> responseMap = (Map<String, Object>) response;
Integer action = (Integer) responseMap.get("action");
if (action != null && renderer != null) {
switch (action) {
case 0:
if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_VIEW_RENDERER_TERMINATE))
renderer.terminate();
break;
}
}
}
} }
@Override @Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : "")); Log.e(LOG_TAG, errorCode + ", " + ((errorMessage != null) ? errorMessage : ""));
defaultBehaviour(null);
} }
};
@Override if (webView.eventChannelDelegate != null) {
public void notImplemented() { webView.eventChannelDelegate.onRenderProcessResponsive(webView.getUrl(), callback);
} else {
} callback.defaultBehaviour(null);
}); }
} }
void dispose() { void dispose() {

View File

@ -0,0 +1,47 @@
package com.pichillilorenzo.flutter_inappwebview.types;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public class BaseCallbackResultImpl<T> implements ICallbackResult<T> {
@Override
public boolean nonNullSuccess(@NonNull T result) {
return true;
}
@Override
public boolean nullSuccess() {
return true;
}
@Override
public void defaultBehaviour(@Nullable T result) {}
@Override
public void success(@Nullable Object obj) {
T result = decodeResult(obj);
boolean shouldRunDefaultBehaviour;
if (result == null) {
shouldRunDefaultBehaviour = nullSuccess();
} else {
shouldRunDefaultBehaviour = nonNullSuccess(result);
}
if (shouldRunDefaultBehaviour) {
defaultBehaviour(result);
}
}
@Nullable
@Override
public T decodeResult(@Nullable Object obj) {
return null;
}
@Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {}
@Override
public void notImplemented() {
defaultBehaviour(null);
}
}

View File

@ -0,0 +1,105 @@
package com.pichillilorenzo.flutter_inappwebview.types;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.Map;
public class ClientCertResponse {
@NonNull
private String certificatePath;
@Nullable
private String certificatePassword;
@NonNull
private String keyStoreType;
@Nullable
private Integer action;
public ClientCertResponse(@NonNull String certificatePath, @Nullable String certificatePassword, @NonNull String keyStoreType, @Nullable Integer action) {
this.certificatePath = certificatePath;
this.certificatePassword = certificatePassword;
this.keyStoreType = keyStoreType;
this.action = action;
}
@Nullable
public static ClientCertResponse fromMap(@Nullable Map<String, Object> map) {
if (map == null) {
return null;
}
String certificatePath = (String) map.get("certificatePath");
String certificatePassword = (String) map.get("certificatePassword");
String keyStoreType = (String) map.get("keyStoreType");
Integer action = (Integer) map.get("action");
return new ClientCertResponse(certificatePath, certificatePassword, keyStoreType, action);
}
@NonNull
public String getCertificatePath() {
return certificatePath;
}
public void setCertificatePath(@NonNull String certificatePath) {
this.certificatePath = certificatePath;
}
@Nullable
public String getCertificatePassword() {
return certificatePassword;
}
public void setCertificatePassword(@Nullable String certificatePassword) {
this.certificatePassword = certificatePassword;
}
@NonNull
public String getKeyStoreType() {
return keyStoreType;
}
public void setKeyStoreType(@NonNull String keyStoreType) {
this.keyStoreType = keyStoreType;
}
@Nullable
public Integer getAction() {
return action;
}
public void setAction(@Nullable Integer action) {
this.action = action;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ClientCertResponse that = (ClientCertResponse) o;
if (!certificatePath.equals(that.certificatePath)) return false;
if (certificatePassword != null ? !certificatePassword.equals(that.certificatePassword) : that.certificatePassword != null)
return false;
if (!keyStoreType.equals(that.keyStoreType)) return false;
return action != null ? action.equals(that.action) : that.action == null;
}
@Override
public int hashCode() {
int result = certificatePath.hashCode();
result = 31 * result + (certificatePassword != null ? certificatePassword.hashCode() : 0);
result = 31 * result + keyStoreType.hashCode();
result = 31 * result + (action != null ? action.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "ClientCertResponse{" +
"certificatePath='" + certificatePath + '\'' +
", certificatePassword='" + certificatePassword + '\'' +
", keyStoreType='" + keyStoreType + '\'' +
", action=" + action +
'}';
}
}

View File

@ -0,0 +1,89 @@
package com.pichillilorenzo.flutter_inappwebview.types;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.Arrays;
import java.util.Map;
public class CustomSchemeResponse {
@NonNull
private byte[] data;
@NonNull
private String contentType;
@NonNull
private String contentEncoding;
public CustomSchemeResponse(@NonNull byte[] data, @NonNull String contentType, @NonNull String contentEncoding) {
this.data = data;
this.contentType = contentType;
this.contentEncoding = contentEncoding;
}
@Nullable
public static CustomSchemeResponse fromMap(@Nullable Map<String, Object> map) {
if (map == null) {
return null;
}
byte[] data = (byte[]) map.get("data");
String contentType = (String) map.get("contentType");
String contentEncoding = (String) map.get("contentEncoding");
return new CustomSchemeResponse(data, contentType, contentEncoding);
}
@NonNull
public byte[] getData() {
return data;
}
public void setData(@NonNull byte[] data) {
this.data = data;
}
@NonNull
public String getContentType() {
return contentType;
}
public void setContentType(@NonNull String contentType) {
this.contentType = contentType;
}
@NonNull
public String getContentEncoding() {
return contentEncoding;
}
public void setContentEncoding(@NonNull String contentEncoding) {
this.contentEncoding = contentEncoding;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CustomSchemeResponse that = (CustomSchemeResponse) o;
if (!Arrays.equals(data, that.data)) return false;
if (!contentType.equals(that.contentType)) return false;
return contentEncoding.equals(that.contentEncoding);
}
@Override
public int hashCode() {
int result = Arrays.hashCode(data);
result = 31 * result + contentType.hashCode();
result = 31 * result + contentEncoding.hashCode();
return result;
}
@Override
public String toString() {
return "CustomSchemeResponse{" +
"data=" + Arrays.toString(data) +
", contentType='" + contentType + '\'' +
", contentEncoding='" + contentEncoding + '\'' +
'}';
}
}

View File

@ -0,0 +1,84 @@
package com.pichillilorenzo.flutter_inappwebview.types;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.Map;
public class GeolocationPermissionShowPromptResponse {
@NonNull
private String origin;
boolean allow;
boolean retain;
public GeolocationPermissionShowPromptResponse(@NonNull String origin, boolean allow, boolean retain) {
this.origin = origin;
this.allow = allow;
this.retain = retain;
}
@Nullable
public static GeolocationPermissionShowPromptResponse fromMap(@Nullable Map<String, Object> map) {
if (map == null) {
return null;
}
String origin = (String) map.get("origin");
boolean allow = (boolean) map.get("allow");
boolean retain = (boolean) map.get("retain");
return new GeolocationPermissionShowPromptResponse(origin, allow, retain);
}
@NonNull
public String getOrigin() {
return origin;
}
public void setOrigin(@NonNull String origin) {
this.origin = origin;
}
public boolean isAllow() {
return allow;
}
public void setAllow(boolean allow) {
this.allow = allow;
}
public boolean isRetain() {
return retain;
}
public void setRetain(boolean retain) {
this.retain = retain;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GeolocationPermissionShowPromptResponse that = (GeolocationPermissionShowPromptResponse) o;
if (allow != that.allow) return false;
if (retain != that.retain) return false;
return origin.equals(that.origin);
}
@Override
public int hashCode() {
int result = origin.hashCode();
result = 31 * result + (allow ? 1 : 0);
result = 31 * result + (retain ? 1 : 0);
return result;
}
@Override
public String toString() {
return "GeolocationPermissionShowPromptResponse{" +
"origin='" + origin + '\'' +
", allow=" + allow +
", retain=" + retain +
'}';
}
}

View File

@ -0,0 +1,102 @@
package com.pichillilorenzo.flutter_inappwebview.types;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.Map;
public class HttpAuthResponse {
@NonNull
private String username;
@NonNull
private String password;
boolean permanentPersistence;
@Nullable
private Integer action;
public HttpAuthResponse(@NonNull String username, @NonNull String password, boolean permanentPersistence, @Nullable Integer action) {
this.username = username;
this.password = password;
this.permanentPersistence = permanentPersistence;
this.action = action;
}
@Nullable
public static HttpAuthResponse fromMap(@Nullable Map<String, Object> map) {
if (map == null) {
return null;
}
String username = (String) map.get("username");
String password = (String) map.get("password");
boolean permanentPersistence = (boolean) map.get("permanentPersistence");
Integer action = (Integer) map.get("action");
return new HttpAuthResponse(username, password, permanentPersistence, action);
}
@NonNull
public String getUsername() {
return username;
}
public void setUsername(@NonNull String username) {
this.username = username;
}
@NonNull
public String getPassword() {
return password;
}
public void setPassword(@NonNull String password) {
this.password = password;
}
public boolean isPermanentPersistence() {
return permanentPersistence;
}
public void setPermanentPersistence(boolean permanentPersistence) {
this.permanentPersistence = permanentPersistence;
}
@Nullable
public Integer getAction() {
return action;
}
public void setAction(@Nullable Integer action) {
this.action = action;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
HttpAuthResponse that = (HttpAuthResponse) o;
if (permanentPersistence != that.permanentPersistence) return false;
if (!username.equals(that.username)) return false;
if (!password.equals(that.password)) return false;
return action != null ? action.equals(that.action) : that.action == null;
}
@Override
public int hashCode() {
int result = username.hashCode();
result = 31 * result + password.hashCode();
result = 31 * result + (permanentPersistence ? 1 : 0);
result = 31 * result + (action != null ? action.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "HttpAuthResponse{" +
"username='" + username + '\'' +
", password='" + password + '\'' +
", permanentPersistence=" + permanentPersistence +
", action=" + action +
'}';
}
}

View File

@ -0,0 +1,13 @@
package com.pichillilorenzo.flutter_inappwebview.types;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import io.flutter.plugin.common.MethodChannel;
public interface ICallbackResult<T> extends MethodChannel.Result {
boolean nonNullSuccess(@NonNull T result);
boolean nullSuccess();
void defaultBehaviour(@Nullable T result);
@Nullable T decodeResult(@Nullable Object obj);
}

View File

@ -8,9 +8,12 @@ import android.webkit.ValueCallback;
import android.webkit.WebMessage; import android.webkit.WebMessage;
import android.webkit.WebView; import android.webkit.WebView;
import androidx.annotation.Nullable;
import com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin; import com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin;
import com.pichillilorenzo.flutter_inappwebview.in_app_browser.InAppBrowserDelegate; import com.pichillilorenzo.flutter_inappwebview.in_app_browser.InAppBrowserDelegate;
import com.pichillilorenzo.flutter_inappwebview.in_app_webview.InAppWebViewSettings; import com.pichillilorenzo.flutter_inappwebview.in_app_webview.InAppWebViewSettings;
import com.pichillilorenzo.flutter_inappwebview.in_app_webview.EventChannelDelegate;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
@ -102,4 +105,7 @@ public interface InAppWebViewInterface {
Looper getWebViewLooper(); Looper getWebViewLooper();
boolean isInFullscreen(); boolean isInFullscreen();
void setInFullscreen(boolean inFullscreen); void setInFullscreen(boolean inFullscreen);
@Nullable
EventChannelDelegate getEventChannelDelegate();
void setEventChannelDelegate(@Nullable EventChannelDelegate eventChannelDelegate);
} }

View File

@ -0,0 +1,98 @@
package com.pichillilorenzo.flutter_inappwebview.types;
import androidx.annotation.Nullable;
import java.util.Map;
public class JsAlertResponse {
private String message;
private String confirmButtonTitle;
private boolean handledByClient;
@Nullable
private Integer action;
public JsAlertResponse(String message, String confirmButtonTitle, boolean handledByClient, @Nullable Integer action) {
this.message = message;
this.confirmButtonTitle = confirmButtonTitle;
this.handledByClient = handledByClient;
this.action = action;
}
@Nullable
public static JsAlertResponse fromMap(@Nullable Map<String, Object> map) {
if (map == null) {
return null;
}
String message = (String) map.get("message");
String confirmButtonTitle = (String) map.get("confirmButtonTitle");
boolean handledByClient = (boolean) map.get("handledByClient");
Integer action = (Integer) map.get("action");
return new JsAlertResponse(message, confirmButtonTitle, handledByClient, action);
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getConfirmButtonTitle() {
return confirmButtonTitle;
}
public void setConfirmButtonTitle(String confirmButtonTitle) {
this.confirmButtonTitle = confirmButtonTitle;
}
public boolean isHandledByClient() {
return handledByClient;
}
public void setHandledByClient(boolean handledByClient) {
this.handledByClient = handledByClient;
}
@Nullable
public Integer getAction() {
return action;
}
public void setAction(@Nullable Integer action) {
this.action = action;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JsAlertResponse that = (JsAlertResponse) o;
if (handledByClient != that.handledByClient) return false;
if (message != null ? !message.equals(that.message) : that.message != null) return false;
if (confirmButtonTitle != null ? !confirmButtonTitle.equals(that.confirmButtonTitle) : that.confirmButtonTitle != null)
return false;
return action != null ? action.equals(that.action) : that.action == null;
}
@Override
public int hashCode() {
int result = message != null ? message.hashCode() : 0;
result = 31 * result + (confirmButtonTitle != null ? confirmButtonTitle.hashCode() : 0);
result = 31 * result + (handledByClient ? 1 : 0);
result = 31 * result + (action != null ? action.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "JsAlertResponse{" +
"message='" + message + '\'' +
", confirmButtonTitle='" + confirmButtonTitle + '\'' +
", handledByClient=" + handledByClient +
", action=" + action +
'}';
}
}

View File

@ -0,0 +1,113 @@
package com.pichillilorenzo.flutter_inappwebview.types;
import androidx.annotation.Nullable;
import java.util.Map;
public class JsBeforeUnloadResponse {
private String message;
private String confirmButtonTitle;
private String cancelButtonTitle;
private boolean handledByClient;
@Nullable
private Integer action;
public JsBeforeUnloadResponse(String message, String confirmButtonTitle, String cancelButtonTitle, boolean handledByClient, @Nullable Integer action) {
this.message = message;
this.confirmButtonTitle = confirmButtonTitle;
this.cancelButtonTitle = cancelButtonTitle;
this.handledByClient = handledByClient;
this.action = action;
}
@Nullable
public static JsBeforeUnloadResponse fromMap(@Nullable Map<String, Object> map) {
if (map == null) {
return null;
}
String message = (String) map.get("message");
String confirmButtonTitle = (String) map.get("confirmButtonTitle");
String cancelButtonTitle = (String) map.get("cancelButtonTitle");
boolean handledByClient = (boolean) map.get("handledByClient");
Integer action = (Integer) map.get("action");
return new JsBeforeUnloadResponse(message, confirmButtonTitle, cancelButtonTitle, handledByClient, action);
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getConfirmButtonTitle() {
return confirmButtonTitle;
}
public void setConfirmButtonTitle(String confirmButtonTitle) {
this.confirmButtonTitle = confirmButtonTitle;
}
public String getCancelButtonTitle() {
return cancelButtonTitle;
}
public void setCancelButtonTitle(String cancelButtonTitle) {
this.cancelButtonTitle = cancelButtonTitle;
}
public boolean isHandledByClient() {
return handledByClient;
}
public void setHandledByClient(boolean handledByClient) {
this.handledByClient = handledByClient;
}
@Nullable
public Integer getAction() {
return action;
}
public void setAction(@Nullable Integer action) {
this.action = action;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JsBeforeUnloadResponse that = (JsBeforeUnloadResponse) o;
if (handledByClient != that.handledByClient) return false;
if (message != null ? !message.equals(that.message) : that.message != null) return false;
if (confirmButtonTitle != null ? !confirmButtonTitle.equals(that.confirmButtonTitle) : that.confirmButtonTitle != null)
return false;
if (cancelButtonTitle != null ? !cancelButtonTitle.equals(that.cancelButtonTitle) : that.cancelButtonTitle != null)
return false;
return action != null ? action.equals(that.action) : that.action == null;
}
@Override
public int hashCode() {
int result = message != null ? message.hashCode() : 0;
result = 31 * result + (confirmButtonTitle != null ? confirmButtonTitle.hashCode() : 0);
result = 31 * result + (cancelButtonTitle != null ? cancelButtonTitle.hashCode() : 0);
result = 31 * result + (handledByClient ? 1 : 0);
result = 31 * result + (action != null ? action.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "JsConfirmResponse{" +
"message='" + message + '\'' +
", confirmButtonTitle='" + confirmButtonTitle + '\'' +
", cancelButtonTitle='" + cancelButtonTitle + '\'' +
", handledByClient=" + handledByClient +
", action=" + action +
'}';
}
}

View File

@ -0,0 +1,113 @@
package com.pichillilorenzo.flutter_inappwebview.types;
import androidx.annotation.Nullable;
import java.util.Map;
public class JsConfirmResponse {
private String message;
private String confirmButtonTitle;
private String cancelButtonTitle;
private boolean handledByClient;
@Nullable
private Integer action;
public JsConfirmResponse(String message, String confirmButtonTitle, String cancelButtonTitle, boolean handledByClient, @Nullable Integer action) {
this.message = message;
this.confirmButtonTitle = confirmButtonTitle;
this.cancelButtonTitle = cancelButtonTitle;
this.handledByClient = handledByClient;
this.action = action;
}
@Nullable
public static JsConfirmResponse fromMap(@Nullable Map<String, Object> map) {
if (map == null) {
return null;
}
String message = (String) map.get("message");
String confirmButtonTitle = (String) map.get("confirmButtonTitle");
String cancelButtonTitle = (String) map.get("cancelButtonTitle");
boolean handledByClient = (boolean) map.get("handledByClient");
Integer action = (Integer) map.get("action");
return new JsConfirmResponse(message, confirmButtonTitle, cancelButtonTitle, handledByClient, action);
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getConfirmButtonTitle() {
return confirmButtonTitle;
}
public void setConfirmButtonTitle(String confirmButtonTitle) {
this.confirmButtonTitle = confirmButtonTitle;
}
public String getCancelButtonTitle() {
return cancelButtonTitle;
}
public void setCancelButtonTitle(String cancelButtonTitle) {
this.cancelButtonTitle = cancelButtonTitle;
}
public boolean isHandledByClient() {
return handledByClient;
}
public void setHandledByClient(boolean handledByClient) {
this.handledByClient = handledByClient;
}
@Nullable
public Integer getAction() {
return action;
}
public void setAction(@Nullable Integer action) {
this.action = action;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JsConfirmResponse that = (JsConfirmResponse) o;
if (handledByClient != that.handledByClient) return false;
if (message != null ? !message.equals(that.message) : that.message != null) return false;
if (confirmButtonTitle != null ? !confirmButtonTitle.equals(that.confirmButtonTitle) : that.confirmButtonTitle != null)
return false;
if (cancelButtonTitle != null ? !cancelButtonTitle.equals(that.cancelButtonTitle) : that.cancelButtonTitle != null)
return false;
return action != null ? action.equals(that.action) : that.action == null;
}
@Override
public int hashCode() {
int result = message != null ? message.hashCode() : 0;
result = 31 * result + (confirmButtonTitle != null ? confirmButtonTitle.hashCode() : 0);
result = 31 * result + (cancelButtonTitle != null ? cancelButtonTitle.hashCode() : 0);
result = 31 * result + (handledByClient ? 1 : 0);
result = 31 * result + (action != null ? action.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "JsConfirmResponse{" +
"message='" + message + '\'' +
", confirmButtonTitle='" + confirmButtonTitle + '\'' +
", cancelButtonTitle='" + cancelButtonTitle + '\'' +
", handledByClient=" + handledByClient +
", action=" + action +
'}';
}
}

View File

@ -0,0 +1,145 @@
package com.pichillilorenzo.flutter_inappwebview.types;
import androidx.annotation.Nullable;
import java.util.Map;
public class JsPromptResponse {
private String message;
private String defaultValue;
private String confirmButtonTitle;
private String cancelButtonTitle;
private boolean handledByClient;
@Nullable
private String value;
@Nullable
private Integer action;
public JsPromptResponse(String message, String defaultValue, String confirmButtonTitle,
String cancelButtonTitle, boolean handledByClient, @Nullable String value, @Nullable Integer action) {
this.message = message;
this.defaultValue = defaultValue;
this.confirmButtonTitle = confirmButtonTitle;
this.cancelButtonTitle = cancelButtonTitle;
this.handledByClient = handledByClient;
this.value = value;
this.action = action;
}
@Nullable
public static JsPromptResponse fromMap(@Nullable Map<String, Object> map) {
if (map == null) {
return null;
}
String message = (String) map.get("message");
String defaultValue = (String) map.get("defaultValue");
String confirmButtonTitle = (String) map.get("confirmButtonTitle");
String cancelButtonTitle = (String) map.get("cancelButtonTitle");
boolean handledByClient = (boolean) map.get("handledByClient");
String value = (String) map.get("value");
Integer action = (Integer) map.get("action");
return new JsPromptResponse(message, defaultValue, confirmButtonTitle, cancelButtonTitle, handledByClient, value, action);
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public String getConfirmButtonTitle() {
return confirmButtonTitle;
}
public void setConfirmButtonTitle(String confirmButtonTitle) {
this.confirmButtonTitle = confirmButtonTitle;
}
public String getCancelButtonTitle() {
return cancelButtonTitle;
}
public void setCancelButtonTitle(String cancelButtonTitle) {
this.cancelButtonTitle = cancelButtonTitle;
}
public boolean isHandledByClient() {
return handledByClient;
}
public void setHandledByClient(boolean handledByClient) {
this.handledByClient = handledByClient;
}
@Nullable
public String getValue() {
return value;
}
public void setValue(@Nullable String value) {
this.value = value;
}
@Nullable
public Integer getAction() {
return action;
}
public void setAction(@Nullable Integer action) {
this.action = action;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JsPromptResponse that = (JsPromptResponse) o;
if (handledByClient != that.handledByClient) return false;
if (message != null ? !message.equals(that.message) : that.message != null) return false;
if (defaultValue != null ? !defaultValue.equals(that.defaultValue) : that.defaultValue != null)
return false;
if (confirmButtonTitle != null ? !confirmButtonTitle.equals(that.confirmButtonTitle) : that.confirmButtonTitle != null)
return false;
if (cancelButtonTitle != null ? !cancelButtonTitle.equals(that.cancelButtonTitle) : that.cancelButtonTitle != null)
return false;
if (value != null ? !value.equals(that.value) : that.value != null) return false;
return action != null ? action.equals(that.action) : that.action == null;
}
@Override
public int hashCode() {
int result = message != null ? message.hashCode() : 0;
result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0);
result = 31 * result + (confirmButtonTitle != null ? confirmButtonTitle.hashCode() : 0);
result = 31 * result + (cancelButtonTitle != null ? cancelButtonTitle.hashCode() : 0);
result = 31 * result + (handledByClient ? 1 : 0);
result = 31 * result + (value != null ? value.hashCode() : 0);
result = 31 * result + (action != null ? action.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "JsPromptResponse{" +
"message='" + message + '\'' +
", defaultValue='" + defaultValue + '\'' +
", confirmButtonTitle='" + confirmButtonTitle + '\'' +
", cancelButtonTitle='" + cancelButtonTitle + '\'' +
", handledByClient=" + handledByClient +
", value='" + value + '\'' +
", action=" + action +
'}';
}
}

View File

@ -15,7 +15,7 @@ public enum NavigationActionPolicy {
} }
public static NavigationActionPolicy fromValue(int value) { public static NavigationActionPolicy fromValue(int value) {
for( NavigationActionPolicy type : NavigationActionPolicy.values()) { for(NavigationActionPolicy type : NavigationActionPolicy.values()) {
if(value == type.value) if(value == type.value)
return type; return type;
} }

View File

@ -0,0 +1,73 @@
package com.pichillilorenzo.flutter_inappwebview.types;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.List;
import java.util.Map;
public class PermissionResponse {
@NonNull
private List<String> resources;
@Nullable
private Integer action;
public PermissionResponse(@NonNull List<String> resources, @Nullable Integer action) {
this.resources = resources;
this.action = action;
}
@Nullable
public static PermissionResponse fromMap(@Nullable Map<String, Object> map) {
if (map == null) {
return null;
}
List<String> resources = (List<String>) map.get("resources");
Integer action = (Integer) map.get("action");
return new PermissionResponse(resources, action);
}
@NonNull
public List<String> getResources() {
return resources;
}
public void setResources(@NonNull List<String> resources) {
this.resources = resources;
}
@Nullable
public Integer getAction() {
return action;
}
public void setAction(@Nullable Integer action) {
this.action = action;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PermissionResponse that = (PermissionResponse) o;
if (!resources.equals(that.resources)) return false;
return action != null ? action.equals(that.action) : that.action == null;
}
@Override
public int hashCode() {
int result = resources.hashCode();
result = 31 * result + (action != null ? action.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "PermissionResponse{" +
"resources=" + resources +
", action=" + action +
'}';
}
}

View File

@ -0,0 +1,69 @@
package com.pichillilorenzo.flutter_inappwebview.types;
import androidx.annotation.Nullable;
import java.util.Map;
public class SafeBrowsingResponse {
private boolean report;
@Nullable
private Integer action;
public SafeBrowsingResponse(boolean report, @Nullable Integer action) {
this.report = report;
this.action = action;
}
@Nullable
public static SafeBrowsingResponse fromMap(@Nullable Map<String, Object> map) {
if (map == null) {
return null;
}
boolean report = (boolean) map.get("report");
Integer action = (Integer) map.get("action");
return new SafeBrowsingResponse(report, action);
}
public boolean isReport() {
return report;
}
public void setReport(boolean report) {
this.report = report;
}
@Nullable
public Integer getAction() {
return action;
}
public void setAction(@Nullable Integer action) {
this.action = action;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SafeBrowsingResponse that = (SafeBrowsingResponse) o;
if (report != that.report) return false;
return action != null ? action.equals(that.action) : that.action == null;
}
@Override
public int hashCode() {
int result = (report ? 1 : 0);
result = 31 * result + (action != null ? action.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "SafeBrowsingResponse{" +
"report=" + report +
", action=" + action +
'}';
}
}

View File

@ -0,0 +1,54 @@
package com.pichillilorenzo.flutter_inappwebview.types;
import androidx.annotation.Nullable;
import java.util.Map;
public class ServerTrustAuthResponse {
@Nullable
private Integer action;
public ServerTrustAuthResponse(@Nullable Integer action) {
this.action = action;
}
@Nullable
public static ServerTrustAuthResponse fromMap(@Nullable Map<String, Object> map) {
if (map == null) {
return null;
}
Integer action = (Integer) map.get("action");
return new ServerTrustAuthResponse(action);
}
@Nullable
public Integer getAction() {
return action;
}
public void setAction(@Nullable Integer action) {
this.action = action;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ServerTrustAuthResponse that = (ServerTrustAuthResponse) o;
return action != null ? action.equals(that.action) : that.action == null;
}
@Override
public int hashCode() {
return action != null ? action.hashCode() : 0;
}
@Override
public String toString() {
return "ServerTrustAuthResponse{" +
"action=" + action +
'}';
}
}

View File

@ -0,0 +1,48 @@
package com.pichillilorenzo.flutter_inappwebview.types;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.concurrent.CountDownLatch;
public class SyncBaseCallbackResultImpl<T> extends BaseCallbackResultImpl<T> {
final public CountDownLatch latch = new CountDownLatch(1);
@Nullable
public T result = null;
@CallSuper
@Override
public void defaultBehaviour(@Nullable T result) {
latch.countDown();
}
@Override
public void success(@Nullable Object obj) {
T result = decodeResult(obj);
this.result = result;
boolean shouldRunDefaultBehaviour;
if (result == null) {
shouldRunDefaultBehaviour = nullSuccess();
} else {
shouldRunDefaultBehaviour = nonNullSuccess(result);
}
if (shouldRunDefaultBehaviour) {
defaultBehaviour(result);
} else {
latch.countDown();
}
}
@CallSuper
@Override
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
latch.countDown();
}
@CallSuper
@Override
public void notImplemented() {
defaultBehaviour(null);
}
}

View File

@ -24,7 +24,8 @@ public class WebResourceResponseExt {
@Nullable @Nullable
private byte[] data; private byte[] data;
public WebResourceResponseExt(String contentType, String contentEncoding, @Nullable Integer statusCode, @Nullable String reasonPhrase, @Nullable Map<String, String> headers, @Nullable byte[] data) { public WebResourceResponseExt(String contentType, String contentEncoding, @Nullable Integer statusCode,
@Nullable String reasonPhrase, @Nullable Map<String, String> headers, @Nullable byte[] data) {
this.contentType = contentType; this.contentType = contentType;
this.contentEncoding = contentEncoding; this.contentEncoding = contentEncoding;
this.statusCode = statusCode; this.statusCode = statusCode;
@ -51,6 +52,20 @@ public class WebResourceResponseExt {
); );
} }
@Nullable
public static WebResourceResponseExt fromMap(@Nullable Map<String, Object> map) {
if (map == null) {
return null;
}
String contentType = (String) map.get("contentType");
String contentEncoding = (String) map.get("contentEncoding");
Integer statusCode = (Integer) map.get("statusCode");
String reasonPhrase = (String) map.get("reasonPhrase");
Map<String, String> headers = (Map<String, String>) map.get("headers");
byte[] data = (byte[]) map.get("data");
return new WebResourceResponseExt(contentType, contentEncoding, statusCode, reasonPhrase, headers, data);
}
public Map<String, Object> toMap() { public Map<String, Object> toMap() {
Map<String, Object> webResourceResponseMap = new HashMap<>(); Map<String, Object> webResourceResponseMap = new HashMap<>();
webResourceResponseMap.put("contentType", contentType); webResourceResponseMap.put("contentType", contentType);

View File

@ -47,6 +47,7 @@ void onFindResultReceived() {
await pageLoaded.future; await pageLoaded.future;
await tester.pump(); await tester.pump();
await Future.delayed(Duration(seconds: 1));
await controller.findAllAsync(find: "InAppWebViewInitialFileTest"); await controller.findAllAsync(find: "InAppWebViewInitialFileTest");
final int numberOfMatches = await numberOfMatchesCompleter.future; final int numberOfMatches = await numberOfMatchesCompleter.future;

View File

@ -42,27 +42,6 @@ void onReceivedError() {
expect(url, TEST_NOT_A_WEBSITE_URL.toString()); expect(url, TEST_NOT_A_WEBSITE_URL.toString());
}); });
testWidgets('file not found', (WidgetTester tester) async {
final Completer<WebResourceErrorType> errorCodeCompleter = Completer<WebResourceErrorType>();
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: InAppWebView(
key: GlobalKey(),
initialUrlRequest: URLRequest(url: Uri.parse('file:flutter.dev')),
onReceivedError: (controller, request, error) {
errorCodeCompleter.complete(error.type);
},
),
),
);
final WebResourceErrorType errorType = await errorCodeCompleter.future;
expect(errorType, WebResourceErrorType.FILE_NOT_FOUND);
});
testWidgets('event is not called with valid url', testWidgets('event is not called with valid url',
(WidgetTester tester) async { (WidgetTester tester) async {
final Completer<void> onReceivedErrorCompleter = Completer<void>(); final Completer<void> onReceivedErrorCompleter = Completer<void>();

View File

@ -53,8 +53,8 @@ void clearAndSetProxyOverride() {
final String url = await pageLoaded.future; final String url = await pageLoaded.future;
expect(url, TEST_URL_HTTP_EXAMPLE.toString()); expect(url, TEST_URL_HTTP_EXAMPLE.toString());
expect(await controller.evaluateJavascript(source: "document.getElementById('url')"), TEST_URL_HTTP_EXAMPLE.toString()); expect(await controller.evaluateJavascript(source: "document.getElementById('url').innerHTML;"), TEST_URL_HTTP_EXAMPLE.toString());
expect(await controller.evaluateJavascript(source: "document.getElementById('method')"), "GET"); expect(await controller.evaluateJavascript(source: "document.getElementById('method').innerHTML;"), "GET");
expect(await controller.evaluateJavascript(source: "document.getElementById('headers')"), isNotNull); expect(await controller.evaluateJavascript(source: "document.getElementById('headers').innerHTML;"), isNotNull);
}, skip: shouldSkip); }, skip: shouldSkip);
} }

View File

@ -48,6 +48,6 @@ void shouldInterceptRequest() {
), ),
); );
expect(completer.future, completes); await expectLater(completer.future, completes);
}, skip: shouldSkip); }, skip: shouldSkip);
} }

View File

@ -3,12 +3,11 @@
export "FLUTTER_ROOT=/Users/lorenzopichilli/fvm/versions/2.10.4" export "FLUTTER_ROOT=/Users/lorenzopichilli/fvm/versions/2.10.4"
export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example" export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true" export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/lib/main.dart" export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build" export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1" export "FLUTTER_BUILD_NUMBER=1"
export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ=="
export "DART_OBFUSCATION=false" export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true" export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=false" export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/.dart_tool/package_config.json" export "PACKAGE_CONFIG=.packages"

View File

@ -45,7 +45,7 @@ class ServiceWorkerController {
static Future<dynamic> _handleMethod(MethodCall call) async { static Future<dynamic> _handleMethod(MethodCall call) async {
ServiceWorkerController controller = ServiceWorkerController.instance(); ServiceWorkerController controller = ServiceWorkerController.instance();
ServiceWorkerClient? serviceWorkerClient = controller.serviceWorkerClient; ServiceWorkerClient? serviceWorkerClient = controller._serviceWorkerClient;
switch (call.method) { switch (call.method) {
case "shouldInterceptRequest": case "shouldInterceptRequest":

View File

@ -1407,131 +1407,132 @@ class InAppWebViewSettings
ReferrerPolicy.fromValue(map["iframeReferrerPolicy"]); ReferrerPolicy.fromValue(map["iframeReferrerPolicy"]);
settings.iframeName = map["iframeName"]; settings.iframeName = map["iframeName"];
settings.iframeCsp = map["iframeCsp"]; settings.iframeCsp = map["iframeCsp"];
} } else {
if (defaultTargetPlatform == TargetPlatform.android) { if (defaultTargetPlatform == TargetPlatform.android) {
settings.textZoom = map["textZoom"]; settings.textZoom = map["textZoom"];
settings.clearSessionCache = map["clearSessionCache"]; settings.clearSessionCache = map["clearSessionCache"];
settings.builtInZoomControls = map["builtInZoomControls"]; settings.builtInZoomControls = map["builtInZoomControls"];
settings.displayZoomControls = map["displayZoomControls"]; settings.displayZoomControls = map["displayZoomControls"];
settings.databaseEnabled = map["databaseEnabled"]; settings.databaseEnabled = map["databaseEnabled"];
settings.domStorageEnabled = map["domStorageEnabled"]; settings.domStorageEnabled = map["domStorageEnabled"];
settings.useWideViewPort = map["useWideViewPort"]; settings.useWideViewPort = map["useWideViewPort"];
settings.safeBrowsingEnabled = map["safeBrowsingEnabled"]; settings.safeBrowsingEnabled = map["safeBrowsingEnabled"];
settings.mixedContentMode = settings.mixedContentMode =
MixedContentMode.fromValue(map["mixedContentMode"]); MixedContentMode.fromValue(map["mixedContentMode"]);
settings.allowContentAccess = map["allowContentAccess"]; settings.allowContentAccess = map["allowContentAccess"];
settings.allowFileAccess = map["allowFileAccess"]; settings.allowFileAccess = map["allowFileAccess"];
settings.appCachePath = map["appCachePath"]; settings.appCachePath = map["appCachePath"];
settings.blockNetworkImage = map["blockNetworkImage"]; settings.blockNetworkImage = map["blockNetworkImage"];
settings.blockNetworkLoads = map["blockNetworkLoads"]; settings.blockNetworkLoads = map["blockNetworkLoads"];
settings.cacheMode = CacheMode.fromValue(map["cacheMode"]); settings.cacheMode = CacheMode.fromValue(map["cacheMode"]);
settings.cursiveFontFamily = map["cursiveFontFamily"]; settings.cursiveFontFamily = map["cursiveFontFamily"];
settings.defaultFixedFontSize = map["defaultFixedFontSize"]; settings.defaultFixedFontSize = map["defaultFixedFontSize"];
settings.defaultFontSize = map["defaultFontSize"]; settings.defaultFontSize = map["defaultFontSize"];
settings.defaultTextEncodingName = map["defaultTextEncodingName"]; settings.defaultTextEncodingName = map["defaultTextEncodingName"];
settings.disabledActionModeMenuItems = settings.disabledActionModeMenuItems =
ActionModeMenuItem.fromValue(map["disabledActionModeMenuItems"]); ActionModeMenuItem.fromValue(map["disabledActionModeMenuItems"]);
settings.fantasyFontFamily = map["fantasyFontFamily"]; settings.fantasyFontFamily = map["fantasyFontFamily"];
settings.fixedFontFamily = map["fixedFontFamily"]; settings.fixedFontFamily = map["fixedFontFamily"];
settings.forceDark = ForceDark.fromValue(map["forceDark"]); settings.forceDark = ForceDark.fromValue(map["forceDark"]);
settings.forceDarkStrategy = ForceDarkStrategy.fromValue(map["forceDarkStrategy"]); settings.forceDarkStrategy = ForceDarkStrategy.fromValue(map["forceDarkStrategy"]);
settings.geolocationEnabled = map["geolocationEnabled"]; settings.geolocationEnabled = map["geolocationEnabled"];
settings.layoutAlgorithm = settings.layoutAlgorithm =
LayoutAlgorithm.fromValue(map["layoutAlgorithm"]); LayoutAlgorithm.fromValue(map["layoutAlgorithm"]);
settings.loadWithOverviewMode = map["loadWithOverviewMode"]; settings.loadWithOverviewMode = map["loadWithOverviewMode"];
settings.loadsImagesAutomatically = map["loadsImagesAutomatically"]; settings.loadsImagesAutomatically = map["loadsImagesAutomatically"];
settings.minimumLogicalFontSize = map["minimumLogicalFontSize"]; settings.minimumLogicalFontSize = map["minimumLogicalFontSize"];
settings.initialScale = map["initialScale"]; settings.initialScale = map["initialScale"];
settings.needInitialFocus = map["needInitialFocus"]; settings.needInitialFocus = map["needInitialFocus"];
settings.offscreenPreRaster = map["offscreenPreRaster"]; settings.offscreenPreRaster = map["offscreenPreRaster"];
settings.sansSerifFontFamily = map["sansSerifFontFamily"]; settings.sansSerifFontFamily = map["sansSerifFontFamily"];
settings.serifFontFamily = map["serifFontFamily"]; settings.serifFontFamily = map["serifFontFamily"];
settings.standardFontFamily = map["standardFontFamily"]; settings.standardFontFamily = map["standardFontFamily"];
settings.saveFormData = map["saveFormData"]; settings.saveFormData = map["saveFormData"];
settings.thirdPartyCookiesEnabled = map["thirdPartyCookiesEnabled"]; settings.thirdPartyCookiesEnabled = map["thirdPartyCookiesEnabled"];
settings.hardwareAcceleration = map["hardwareAcceleration"]; settings.hardwareAcceleration = map["hardwareAcceleration"];
settings.supportMultipleWindows = map["supportMultipleWindows"]; settings.supportMultipleWindows = map["supportMultipleWindows"];
settings.regexToCancelSubFramesLoading = settings.regexToCancelSubFramesLoading =
map["regexToCancelSubFramesLoading"]; map["regexToCancelSubFramesLoading"];
settings.useHybridComposition = map["useHybridComposition"]; settings.useHybridComposition = map["useHybridComposition"];
settings.useShouldInterceptRequest = map["useShouldInterceptRequest"]; settings.useShouldInterceptRequest = map["useShouldInterceptRequest"];
settings.useOnRenderProcessGone = map["useOnRenderProcessGone"]; settings.useOnRenderProcessGone = map["useOnRenderProcessGone"];
settings.overScrollMode = OverScrollMode.fromValue(map["overScrollMode"]); settings.overScrollMode = OverScrollMode.fromValue(map["overScrollMode"]);
settings.networkAvailable = map["networkAvailable"]; settings.networkAvailable = map["networkAvailable"];
settings.scrollBarStyle = ScrollBarStyle.fromValue(map["scrollBarStyle"]); settings.scrollBarStyle = ScrollBarStyle.fromValue(map["scrollBarStyle"]);
settings.verticalScrollbarPosition = settings.verticalScrollbarPosition =
VerticalScrollbarPosition.fromValue(map["verticalScrollbarPosition"]); VerticalScrollbarPosition.fromValue(map["verticalScrollbarPosition"]);
settings.scrollBarDefaultDelayBeforeFade = settings.scrollBarDefaultDelayBeforeFade =
map["scrollBarDefaultDelayBeforeFade"]; map["scrollBarDefaultDelayBeforeFade"];
settings.scrollbarFadingEnabled = map["scrollbarFadingEnabled"]; settings.scrollbarFadingEnabled = map["scrollbarFadingEnabled"];
settings.scrollBarFadeDuration = map["scrollBarFadeDuration"]; settings.scrollBarFadeDuration = map["scrollBarFadeDuration"];
settings.rendererPriorityPolicy = RendererPriorityPolicy.fromMap( settings.rendererPriorityPolicy = RendererPriorityPolicy.fromMap(
map["rendererPriorityPolicy"]?.cast<String, dynamic>()); map["rendererPriorityPolicy"]?.cast<String, dynamic>());
settings.disableDefaultErrorPage = map["disableDefaultErrorPage"]; settings.disableDefaultErrorPage = map["disableDefaultErrorPage"];
settings.verticalScrollbarThumbColor = settings.verticalScrollbarThumbColor =
UtilColor.fromHex(map["verticalScrollbarThumbColor"]); UtilColor.fromHex(map["verticalScrollbarThumbColor"]);
settings.verticalScrollbarTrackColor = settings.verticalScrollbarTrackColor =
UtilColor.fromHex(map["verticalScrollbarTrackColor"]); UtilColor.fromHex(map["verticalScrollbarTrackColor"]);
settings.horizontalScrollbarThumbColor = settings.horizontalScrollbarThumbColor =
UtilColor.fromHex(map["horizontalScrollbarThumbColor"]); UtilColor.fromHex(map["horizontalScrollbarThumbColor"]);
settings.horizontalScrollbarTrackColor = settings.horizontalScrollbarTrackColor =
UtilColor.fromHex(map["horizontalScrollbarTrackColor"]); UtilColor.fromHex(map["horizontalScrollbarTrackColor"]);
} }
if (defaultTargetPlatform == TargetPlatform.iOS || else if (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform == TargetPlatform.macOS) { defaultTargetPlatform == TargetPlatform.macOS) {
settings.disallowOverScroll = map["disallowOverScroll"]; settings.disallowOverScroll = map["disallowOverScroll"];
settings.enableViewportScale = map["enableViewportScale"]; settings.enableViewportScale = map["enableViewportScale"];
settings.suppressesIncrementalRendering = settings.suppressesIncrementalRendering =
map["suppressesIncrementalRendering"]; map["suppressesIncrementalRendering"];
settings.allowsAirPlayForMediaPlayback = settings.allowsAirPlayForMediaPlayback =
map["allowsAirPlayForMediaPlayback"]; map["allowsAirPlayForMediaPlayback"];
settings.allowsBackForwardNavigationGestures = settings.allowsBackForwardNavigationGestures =
map["allowsBackForwardNavigationGestures"]; map["allowsBackForwardNavigationGestures"];
settings.allowsLinkPreview = map["allowsLinkPreview"]; settings.allowsLinkPreview = map["allowsLinkPreview"];
settings.ignoresViewportScaleLimits = map["ignoresViewportScaleLimits"]; settings.ignoresViewportScaleLimits = map["ignoresViewportScaleLimits"];
settings.allowsInlineMediaPlayback = map["allowsInlineMediaPlayback"]; settings.allowsInlineMediaPlayback = map["allowsInlineMediaPlayback"];
settings.allowsPictureInPictureMediaPlayback = settings.allowsPictureInPictureMediaPlayback =
map["allowsPictureInPictureMediaPlayback"]; map["allowsPictureInPictureMediaPlayback"];
settings.isFraudulentWebsiteWarningEnabled = settings.isFraudulentWebsiteWarningEnabled =
map["isFraudulentWebsiteWarningEnabled"]; map["isFraudulentWebsiteWarningEnabled"];
settings.selectionGranularity = settings.selectionGranularity =
SelectionGranularity.fromValue(map["selectionGranularity"])!; SelectionGranularity.fromValue(map["selectionGranularity"])!;
settings.dataDetectorTypes = dataDetectorTypes; settings.dataDetectorTypes = dataDetectorTypes;
settings.sharedCookiesEnabled = map["sharedCookiesEnabled"]; settings.sharedCookiesEnabled = map["sharedCookiesEnabled"];
settings.automaticallyAdjustsScrollIndicatorInsets = settings.automaticallyAdjustsScrollIndicatorInsets =
map["automaticallyAdjustsScrollIndicatorInsets"]; map["automaticallyAdjustsScrollIndicatorInsets"];
settings.accessibilityIgnoresInvertColors = settings.accessibilityIgnoresInvertColors =
map["accessibilityIgnoresInvertColors"]; map["accessibilityIgnoresInvertColors"];
settings.decelerationRate = settings.decelerationRate =
ScrollViewDecelerationRate.fromValue(map["decelerationRate"])!; ScrollViewDecelerationRate.fromValue(map["decelerationRate"])!;
settings.alwaysBounceVertical = map["alwaysBounceVertical"]; settings.alwaysBounceVertical = map["alwaysBounceVertical"];
settings.alwaysBounceHorizontal = map["alwaysBounceHorizontal"]; settings.alwaysBounceHorizontal = map["alwaysBounceHorizontal"];
settings.scrollsToTop = map["scrollsToTop"]; settings.scrollsToTop = map["scrollsToTop"];
settings.isPagingEnabled = map["isPagingEnabled"]; settings.isPagingEnabled = map["isPagingEnabled"];
settings.maximumZoomScale = map["maximumZoomScale"]; settings.maximumZoomScale = map["maximumZoomScale"];
settings.minimumZoomScale = map["minimumZoomScale"]; settings.minimumZoomScale = map["minimumZoomScale"];
settings.contentInsetAdjustmentBehavior = settings.contentInsetAdjustmentBehavior =
ScrollViewContentInsetAdjustmentBehavior.fromValue( ScrollViewContentInsetAdjustmentBehavior.fromValue(
map["contentInsetAdjustmentBehavior"])!; map["contentInsetAdjustmentBehavior"])!;
settings.isDirectionalLockEnabled = map["isDirectionalLockEnabled"]; settings.isDirectionalLockEnabled = map["isDirectionalLockEnabled"];
settings.mediaType = map["mediaType"]; settings.mediaType = map["mediaType"];
settings.pageZoom = map["pageZoom"]; settings.pageZoom = map["pageZoom"];
settings.limitsNavigationsToAppBoundDomains = settings.limitsNavigationsToAppBoundDomains =
map["limitsNavigationsToAppBoundDomains"]; map["limitsNavigationsToAppBoundDomains"];
settings.useOnNavigationResponse = map["useOnNavigationResponse"]; settings.useOnNavigationResponse = map["useOnNavigationResponse"];
settings.applePayAPIEnabled = map["applePayAPIEnabled"]; settings.applePayAPIEnabled = map["applePayAPIEnabled"];
settings.allowingReadAccessTo = map["allowingReadAccessTo"] != null settings.allowingReadAccessTo = map["allowingReadAccessTo"] != null
? Uri.parse(map["allowingReadAccessTo"]) ? Uri.parse(map["allowingReadAccessTo"])
: null; : null;
settings.disableLongPressContextMenuOnLinks = settings.disableLongPressContextMenuOnLinks =
map["disableLongPressContextMenuOnLinks"]; map["disableLongPressContextMenuOnLinks"];
settings.disableInputAccessoryView = map["disableInputAccessoryView"]; settings.disableInputAccessoryView = map["disableInputAccessoryView"];
settings.underPageBackgroundColor = settings.underPageBackgroundColor =
UtilColor.fromHex(map["underPageBackgroundColor"]); UtilColor.fromHex(map["underPageBackgroundColor"]);
settings.isTextInteractionEnabled = map["isTextInteractionEnabled"]; settings.isTextInteractionEnabled = map["isTextInteractionEnabled"];
settings.isSiteSpecificQuirksModeEnabled = settings.isSiteSpecificQuirksModeEnabled =
map["isSiteSpecificQuirksModeEnabled"]; map["isSiteSpecificQuirksModeEnabled"];
settings.upgradeKnownHostsToHTTPS = map["upgradeKnownHostsToHTTPS"]; settings.upgradeKnownHostsToHTTPS = map["upgradeKnownHostsToHTTPS"];
}
} }
return settings; return settings;
} }

View File

@ -1,3 +1,5 @@
import 'package:flutter/foundation.dart';
import '../in_app_webview/webview.dart'; import '../in_app_webview/webview.dart';
import 'client_cert_response_action.dart'; import 'client_cert_response_action.dart';
@ -29,8 +31,12 @@ class ClientCertResponse {
this.action = ClientCertResponseAction.CANCEL}) { this.action = ClientCertResponseAction.CANCEL}) {
if (this.action == ClientCertResponseAction.PROCEED) if (this.action == ClientCertResponseAction.PROCEED)
assert(certificatePath.isNotEmpty); assert(certificatePath.isNotEmpty);
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
this.keyStoreType = this.keyStoreType ?? this.androidKeyStoreType; this.keyStoreType = this.keyStoreType ?? this.androidKeyStoreType;
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android)
assert(this.keyStoreType != null);
} }
///Converts instance to a map. ///Converts instance to a map.

View File

@ -3,16 +3,17 @@ import '../in_app_webview/webview.dart';
///Class used by the host application to set the Geolocation permission state for an origin during the [WebView.onGeolocationPermissionsShowPrompt] event. ///Class used by the host application to set the Geolocation permission state for an origin during the [WebView.onGeolocationPermissionsShowPrompt] event.
class GeolocationPermissionShowPromptResponse { class GeolocationPermissionShowPromptResponse {
///The origin for which permissions are set. ///The origin for which permissions are set.
String? origin; String origin;
///Whether or not the origin should be allowed to use the Geolocation API. ///Whether or not the origin should be allowed to use the Geolocation API.
bool? allow; bool allow;
///Whether the permission should be retained beyond the lifetime of a page currently being displayed by a WebView ///Whether the permission should be retained beyond the lifetime of a page currently being displayed by a WebView
bool? retain; ///The default value is `false`.
bool retain;
GeolocationPermissionShowPromptResponse( GeolocationPermissionShowPromptResponse(
{this.origin, this.allow, this.retain}); {required this.origin, required this.allow, this.retain = false});
///Converts instance to a map. ///Converts instance to a map.
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {

View File

@ -59,10 +59,10 @@ class PermissionResourceType {
///- iOS ([Official API - WKMediaCaptureType.microphone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/microphone)) ///- iOS ([Official API - WKMediaCaptureType.microphone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/microphone))
static final MICROPHONE = PermissionResourceType._internal( static final MICROPHONE = PermissionResourceType._internal(
'MICROPHONE', 'MICROPHONE',
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? 'android.webkit.resource.AUDIO_CAPTURE' ? 'android.webkit.resource.AUDIO_CAPTURE'
: ((defaultTargetPlatform != TargetPlatform.iOS || : ((defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? 1 ? 1
: null)); : null));
@ -74,7 +74,7 @@ class PermissionResourceType {
///- Android native WebView ([Official API - PermissionRequest.RESOURCE_MIDI_SYSEX](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_MIDI_SYSEX)) ///- Android native WebView ([Official API - PermissionRequest.RESOURCE_MIDI_SYSEX](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_MIDI_SYSEX))
static final MIDI_SYSEX = PermissionResourceType._internal( static final MIDI_SYSEX = PermissionResourceType._internal(
'MIDI_SYSEX', 'MIDI_SYSEX',
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? 'android.webkit.resource.MIDI_SYSEX' ? 'android.webkit.resource.MIDI_SYSEX'
: null); : null);
@ -84,7 +84,7 @@ class PermissionResourceType {
///- Android native WebView ([Official API - PermissionRequest.RESOURCE_PROTECTED_MEDIA_ID](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_PROTECTED_MEDIA_ID)) ///- Android native WebView ([Official API - PermissionRequest.RESOURCE_PROTECTED_MEDIA_ID](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_PROTECTED_MEDIA_ID))
static final PROTECTED_MEDIA_ID = PermissionResourceType._internal( static final PROTECTED_MEDIA_ID = PermissionResourceType._internal(
'PROTECTED_MEDIA_ID', 'PROTECTED_MEDIA_ID',
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? 'android.webkit.resource.PROTECTED_MEDIA_ID' ? 'android.webkit.resource.PROTECTED_MEDIA_ID'
: null); : null);
@ -95,10 +95,10 @@ class PermissionResourceType {
///- iOS ([Official API - WKMediaCaptureType.camera](https://developer.apple.com/documentation/webkit/wkmediacapturetype/camera)) ///- iOS ([Official API - WKMediaCaptureType.camera](https://developer.apple.com/documentation/webkit/wkmediacapturetype/camera))
static final CAMERA = PermissionResourceType._internal( static final CAMERA = PermissionResourceType._internal(
'CAMERA', 'CAMERA',
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? 'android.webkit.resource.VIDEO_CAPTURE' ? 'android.webkit.resource.VIDEO_CAPTURE'
: ((defaultTargetPlatform != TargetPlatform.iOS || : ((defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? 0 ? 0
: null)); : null));
@ -108,8 +108,8 @@ class PermissionResourceType {
///- iOS ([Official API - WKMediaCaptureType.cameraAndMicrophone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/cameraandmicrophone)) ///- iOS ([Official API - WKMediaCaptureType.cameraAndMicrophone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/cameraandmicrophone))
static final CAMERA_AND_MICROPHONE = PermissionResourceType._internal( static final CAMERA_AND_MICROPHONE = PermissionResourceType._internal(
'CAMERA_AND_MICROPHONE', 'CAMERA_AND_MICROPHONE',
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? 2 ? 2
: null); : null);
@ -119,8 +119,8 @@ class PermissionResourceType {
///- iOS ///- iOS
static final DEVICE_ORIENTATION_AND_MOTION = PermissionResourceType._internal( static final DEVICE_ORIENTATION_AND_MOTION = PermissionResourceType._internal(
'DEVICE_ORIENTATION_AND_MOTION', 'DEVICE_ORIENTATION_AND_MOTION',
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? 'deviceOrientationAndMotion' ? 'deviceOrientationAndMotion'
: null); : null);

View File

@ -65,35 +65,35 @@ class SslErrorType {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - SslError.SSL_NOTYETVALID](https://developer.android.com/reference/android/net/http/SslError#SSL_NOTYETVALID)) ///- Android native WebView ([Official API - SslError.SSL_NOTYETVALID](https://developer.android.com/reference/android/net/http/SslError#SSL_NOTYETVALID))
static final NOT_YET_VALID = SslErrorType._internal('NOT_YET_VALID', static final NOT_YET_VALID = SslErrorType._internal('NOT_YET_VALID',
(defaultTargetPlatform != TargetPlatform.android) ? 0 : -1); (defaultTargetPlatform == TargetPlatform.android) ? 0 : -1);
///The certificate has expired. ///The certificate has expired.
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - SslError.SSL_EXPIRED](https://developer.android.com/reference/android/net/http/SslError#SSL_EXPIRED)) ///- Android native WebView ([Official API - SslError.SSL_EXPIRED](https://developer.android.com/reference/android/net/http/SslError#SSL_EXPIRED))
static final EXPIRED = SslErrorType._internal( static final EXPIRED = SslErrorType._internal(
'EXPIRED', (defaultTargetPlatform != TargetPlatform.android) ? 1 : -1); 'EXPIRED', (defaultTargetPlatform == TargetPlatform.android) ? 1 : -1);
///Hostname mismatch. ///Hostname mismatch.
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - SslError.SSL_IDMISMATCH](https://developer.android.com/reference/android/net/http/SslError#SSL_IDMISMATCH)) ///- Android native WebView ([Official API - SslError.SSL_IDMISMATCH](https://developer.android.com/reference/android/net/http/SslError#SSL_IDMISMATCH))
static final IDMISMATCH = SslErrorType._internal( static final IDMISMATCH = SslErrorType._internal(
'IDMISMATCH', (defaultTargetPlatform != TargetPlatform.android) ? 2 : -1); 'IDMISMATCH', (defaultTargetPlatform == TargetPlatform.android) ? 2 : -1);
///The certificate authority is not trusted. ///The certificate authority is not trusted.
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - SslError.SSL_UNTRUSTED](https://developer.android.com/reference/android/net/http/SslError#SSL_UNTRUSTED)) ///- Android native WebView ([Official API - SslError.SSL_UNTRUSTED](https://developer.android.com/reference/android/net/http/SslError#SSL_UNTRUSTED))
static final UNTRUSTED = SslErrorType._internal( static final UNTRUSTED = SslErrorType._internal(
'UNTRUSTED', (defaultTargetPlatform != TargetPlatform.android) ? 3 : -1); 'UNTRUSTED', (defaultTargetPlatform == TargetPlatform.android) ? 3 : -1);
///The date of the certificate is invalid. ///The date of the certificate is invalid.
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - SslError.SSL_DATE_INVALID](https://developer.android.com/reference/android/net/http/SslError#SSL_DATE_INVALID)) ///- Android native WebView ([Official API - SslError.SSL_DATE_INVALID](https://developer.android.com/reference/android/net/http/SslError#SSL_DATE_INVALID))
static final DATE_INVALID = SslErrorType._internal('DATE_INVALID', static final DATE_INVALID = SslErrorType._internal('DATE_INVALID',
(defaultTargetPlatform != TargetPlatform.android) ? 4 : -1); (defaultTargetPlatform == TargetPlatform.android) ? 4 : -1);
///Indicates an invalid setting or result. A generic error occurred. ///Indicates an invalid setting or result. A generic error occurred.
/// ///
@ -102,10 +102,10 @@ class SslErrorType {
///- iOS ([Official API - SecTrustResultType.invalid](https://developer.apple.com/documentation/security/sectrustresulttype/invalid)) ///- iOS ([Official API - SecTrustResultType.invalid](https://developer.apple.com/documentation/security/sectrustresulttype/invalid))
static final INVALID = SslErrorType._internal( static final INVALID = SslErrorType._internal(
'INVALID', 'INVALID',
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? 5 ? 5
: ((defaultTargetPlatform != TargetPlatform.iOS || : ((defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? 0 ? 0
: -1)); : -1));
@ -120,8 +120,8 @@ class SslErrorType {
///- iOS ([Official API - SecTrustResultType.deny](https://developer.apple.com/documentation/security/sectrustresulttype/deny)) ///- iOS ([Official API - SecTrustResultType.deny](https://developer.apple.com/documentation/security/sectrustresulttype/deny))
static final DENY = SslErrorType._internal( static final DENY = SslErrorType._internal(
'DENY', 'DENY',
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? 3 ? 3
: -1); : -1);
@ -138,8 +138,8 @@ class SslErrorType {
///- iOS ([Official API - SecTrustResultType.unspecified](https://developer.apple.com/documentation/security/sectrustresulttype/unspecified)) ///- iOS ([Official API - SecTrustResultType.unspecified](https://developer.apple.com/documentation/security/sectrustresulttype/unspecified))
static final UNSPECIFIED = SslErrorType._internal( static final UNSPECIFIED = SslErrorType._internal(
'UNSPECIFIED', 'UNSPECIFIED',
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? 4 ? 4
: -1); : -1);
@ -157,8 +157,8 @@ class SslErrorType {
///- iOS ([Official API - SecTrustResultType.recoverableTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/recoverabletrustfailure)) ///- iOS ([Official API - SecTrustResultType.recoverableTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/recoverabletrustfailure))
static final RECOVERABLE_TRUST_FAILURE = SslErrorType._internal( static final RECOVERABLE_TRUST_FAILURE = SslErrorType._internal(
'RECOVERABLE_TRUST_FAILURE', 'RECOVERABLE_TRUST_FAILURE',
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? 5 ? 5
: -1); : -1);
@ -173,8 +173,8 @@ class SslErrorType {
///- iOS ([Official API - SecTrustResultType.fatalTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/fataltrustfailure)) ///- iOS ([Official API - SecTrustResultType.fatalTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/fataltrustfailure))
static final FATAL_TRUST_FAILURE = SslErrorType._internal( static final FATAL_TRUST_FAILURE = SslErrorType._internal(
'FATAL_TRUST_FAILURE', 'FATAL_TRUST_FAILURE',
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? 6 ? 6
: -1); : -1);
@ -187,8 +187,8 @@ class SslErrorType {
///- iOS ([Official API - SecTrustResultType.otherError](https://developer.apple.com/documentation/security/sectrustresulttype/othererror)) ///- iOS ([Official API - SecTrustResultType.otherError](https://developer.apple.com/documentation/security/sectrustresulttype/othererror))
static final OTHER_ERROR = SslErrorType._internal( static final OTHER_ERROR = SslErrorType._internal(
'OTHER_ERROR', 'OTHER_ERROR',
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? 7 ? 7
: -1); : -1);

View File

@ -107,7 +107,7 @@ class WebResourceErrorType {
///- Android native WebView ([Official API - WebViewClient.ERROR_AUTHENTICATION](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_AUTHENTICATION)) ///- Android native WebView ([Official API - WebViewClient.ERROR_AUTHENTICATION](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_AUTHENTICATION))
static final USER_AUTHENTICATION_FAILED = WebResourceErrorType._internal( static final USER_AUTHENTICATION_FAILED = WebResourceErrorType._internal(
"USER_AUTHENTICATION_FAILED", "USER_AUTHENTICATION_FAILED",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -4 ? -4
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -118,10 +118,10 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.badURL](https://developer.apple.com/documentation/foundation/urlerror/2293516-badurl)) ///- iOS ([Official API - URLError.badURL](https://developer.apple.com/documentation/foundation/urlerror/2293516-badurl))
static final BAD_URL = WebResourceErrorType._internal( static final BAD_URL = WebResourceErrorType._internal(
"BAD_URL", "BAD_URL",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -12 ? -12
: ((defaultTargetPlatform != TargetPlatform.iOS || : ((defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1000 ? -1000
: UNKNOWN._nativeValue)); : UNKNOWN._nativeValue));
@ -132,10 +132,10 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.cannotConnectToHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883001-cannotconnecttohost)) ///- iOS ([Official API - URLError.cannotConnectToHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883001-cannotconnecttohost))
static final CANNOT_CONNECT_TO_HOST = WebResourceErrorType._internal( static final CANNOT_CONNECT_TO_HOST = WebResourceErrorType._internal(
"CANNOT_CONNECT_TO_HOST", "CANNOT_CONNECT_TO_HOST",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -6 ? -6
: ((defaultTargetPlatform != TargetPlatform.iOS || : ((defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1004 ? -1004
: UNKNOWN._nativeValue)); : UNKNOWN._nativeValue));
@ -145,7 +145,7 @@ class WebResourceErrorType {
///- Android native WebView ([Official API - WebViewClient.ERROR_FAILED_SSL_HANDSHAKE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FAILED_SSL_HANDSHAKE)) ///- Android native WebView ([Official API - WebViewClient.ERROR_FAILED_SSL_HANDSHAKE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FAILED_SSL_HANDSHAKE))
static final FAILED_SSL_HANDSHAKE = WebResourceErrorType._internal( static final FAILED_SSL_HANDSHAKE = WebResourceErrorType._internal(
"FAILED_SSL_HANDSHAKE", "FAILED_SSL_HANDSHAKE",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -11 ? -11
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -155,7 +155,7 @@ class WebResourceErrorType {
///- Android native WebView ([Official API - WebViewClient.ERROR_FILE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FILE)) ///- Android native WebView ([Official API - WebViewClient.ERROR_FILE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FILE))
static final GENERIC_FILE_ERROR = WebResourceErrorType._internal( static final GENERIC_FILE_ERROR = WebResourceErrorType._internal(
"GENERIC_FILE_ERROR", "GENERIC_FILE_ERROR",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -13 ? -13
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -166,10 +166,10 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.fileDoesNotExist](https://developer.apple.com/documentation/foundation/urlerror/code/2883074-filedoesnotexist)) ///- iOS ([Official API - URLError.fileDoesNotExist](https://developer.apple.com/documentation/foundation/urlerror/code/2883074-filedoesnotexist))
static final FILE_NOT_FOUND = WebResourceErrorType._internal( static final FILE_NOT_FOUND = WebResourceErrorType._internal(
"FILE_NOT_FOUND", "FILE_NOT_FOUND",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -14 ? -14
: ((defaultTargetPlatform != TargetPlatform.iOS || : ((defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1100 ? -1100
: UNKNOWN._nativeValue)); : UNKNOWN._nativeValue));
@ -180,10 +180,10 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.cannotFindHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost)) ///- iOS ([Official API - URLError.cannotFindHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost))
static final HOST_LOOKUP = WebResourceErrorType._internal( static final HOST_LOOKUP = WebResourceErrorType._internal(
"HOST_LOOKUP", "HOST_LOOKUP",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -2 ? -2
: ((defaultTargetPlatform != TargetPlatform.iOS || : ((defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1003 ? -1003
: UNKNOWN._nativeValue)); : UNKNOWN._nativeValue));
@ -193,7 +193,7 @@ class WebResourceErrorType {
///- Android native WebView ([Official API - WebViewClient.ERROR_IO](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_IO)) ///- Android native WebView ([Official API - WebViewClient.ERROR_IO](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_IO))
static final IO = WebResourceErrorType._internal( static final IO = WebResourceErrorType._internal(
"IO", "IO",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -7 ? -7
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -203,7 +203,7 @@ class WebResourceErrorType {
///- Android native WebView ([Official API - WebViewClient.ERROR_PROXY_AUTHENTICATION](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_PROXY_AUTHENTICATION)) ///- Android native WebView ([Official API - WebViewClient.ERROR_PROXY_AUTHENTICATION](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_PROXY_AUTHENTICATION))
static final PROXY_AUTHENTICATION = WebResourceErrorType._internal( static final PROXY_AUTHENTICATION = WebResourceErrorType._internal(
"PROXY_AUTHENTICATION", "PROXY_AUTHENTICATION",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -5 ? -5
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -214,10 +214,10 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.cannotFindHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost)) ///- iOS ([Official API - URLError.cannotFindHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost))
static final TOO_MANY_REDIRECTS = WebResourceErrorType._internal( static final TOO_MANY_REDIRECTS = WebResourceErrorType._internal(
"TOO_MANY_REDIRECTS", "TOO_MANY_REDIRECTS",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -9 ? -9
: ((defaultTargetPlatform != TargetPlatform.iOS || : ((defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1007 ? -1007
: UNKNOWN._nativeValue)); : UNKNOWN._nativeValue));
@ -228,10 +228,10 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.timedOut](https://developer.apple.com/documentation/foundation/urlerror/code/2883027-timedout)) ///- iOS ([Official API - URLError.timedOut](https://developer.apple.com/documentation/foundation/urlerror/code/2883027-timedout))
static final TIMEOUT = WebResourceErrorType._internal( static final TIMEOUT = WebResourceErrorType._internal(
"TIMEOUT", "TIMEOUT",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -8 ? -8
: ((defaultTargetPlatform != TargetPlatform.iOS || : ((defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1001 ? -1001
: UNKNOWN._nativeValue)); : UNKNOWN._nativeValue));
@ -241,7 +241,7 @@ class WebResourceErrorType {
///- Android native WebView ([Official API - WebViewClient.ERROR_TOO_MANY_REQUESTS](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_TOO_MANY_REQUESTS)) ///- Android native WebView ([Official API - WebViewClient.ERROR_TOO_MANY_REQUESTS](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_TOO_MANY_REQUESTS))
static final TOO_MANY_REQUESTS = WebResourceErrorType._internal( static final TOO_MANY_REQUESTS = WebResourceErrorType._internal(
"TOO_MANY_REQUESTS", "TOO_MANY_REQUESTS",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -15 ? -15
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -258,7 +258,7 @@ class WebResourceErrorType {
///- Android native WebView ([Official API - WebViewClient.ERROR_UNSAFE_RESOURCE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSAFE_RESOURCE)) ///- Android native WebView ([Official API - WebViewClient.ERROR_UNSAFE_RESOURCE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSAFE_RESOURCE))
static final UNSAFE_RESOURCE = WebResourceErrorType._internal( static final UNSAFE_RESOURCE = WebResourceErrorType._internal(
"UNSAFE_RESOURCE", "UNSAFE_RESOURCE",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -16 ? -16
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -268,7 +268,7 @@ class WebResourceErrorType {
///- Android native WebView ([Official API - WebViewClient.ERROR_UNSUPPORTED_AUTH_SCHEME](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSUPPORTED_AUTH_SCHEME)) ///- Android native WebView ([Official API - WebViewClient.ERROR_UNSUPPORTED_AUTH_SCHEME](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSUPPORTED_AUTH_SCHEME))
static final UNSUPPORTED_AUTH_SCHEME = WebResourceErrorType._internal( static final UNSUPPORTED_AUTH_SCHEME = WebResourceErrorType._internal(
"UNSUPPORTED_AUTH_SCHEME", "UNSUPPORTED_AUTH_SCHEME",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -3 ? -3
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -280,10 +280,10 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.unsupportedURL](https://developer.apple.com/documentation/foundation/urlerror/code/2883043-unsupportedurl)) ///- iOS ([Official API - URLError.unsupportedURL](https://developer.apple.com/documentation/foundation/urlerror/code/2883043-unsupportedurl))
static final UNSUPPORTED_SCHEME = WebResourceErrorType._internal( static final UNSUPPORTED_SCHEME = WebResourceErrorType._internal(
"UNSUPPORTED_SCHEME", "UNSUPPORTED_SCHEME",
(defaultTargetPlatform != TargetPlatform.android) (defaultTargetPlatform == TargetPlatform.android)
? -10 ? -10
: ((defaultTargetPlatform != TargetPlatform.iOS || : ((defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1002 ? -1002
: UNKNOWN._nativeValue)); : UNKNOWN._nativeValue));
@ -293,8 +293,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.cancelled](https://developer.apple.com/documentation/foundation/urlerror/code/2883178-cancelled)) ///- iOS ([Official API - URLError.cancelled](https://developer.apple.com/documentation/foundation/urlerror/code/2883178-cancelled))
static final CANCELLED = WebResourceErrorType._internal( static final CANCELLED = WebResourceErrorType._internal(
"CANCELLED", "CANCELLED",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -999 ? -999
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -304,8 +304,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.networkConnectionLost](https://developer.apple.com/documentation/foundation/urlerror/2293759-networkconnectionlost)) ///- iOS ([Official API - URLError.networkConnectionLost](https://developer.apple.com/documentation/foundation/urlerror/2293759-networkconnectionlost))
static final NETWORK_CONNECTION_LOST = WebResourceErrorType._internal( static final NETWORK_CONNECTION_LOST = WebResourceErrorType._internal(
"NETWORK_CONNECTION_LOST", "NETWORK_CONNECTION_LOST",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1005 ? -1005
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -316,8 +316,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.resourceUnavailable](https://developer.apple.com/documentation/foundation/urlerror/2293555-resourceunavailable)) ///- iOS ([Official API - URLError.resourceUnavailable](https://developer.apple.com/documentation/foundation/urlerror/2293555-resourceunavailable))
static final RESOURCE_UNAVAILABLE = WebResourceErrorType._internal( static final RESOURCE_UNAVAILABLE = WebResourceErrorType._internal(
"RESOURCE_UNAVAILABLE", "RESOURCE_UNAVAILABLE",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1008 ? -1008
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -327,8 +327,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.notConnectedToInternet](https://developer.apple.com/documentation/foundation/urlerror/2293104-notconnectedtointernet)) ///- iOS ([Official API - URLError.notConnectedToInternet](https://developer.apple.com/documentation/foundation/urlerror/2293104-notconnectedtointernet))
static final NOT_CONNECTED_TO_INTERNET = WebResourceErrorType._internal( static final NOT_CONNECTED_TO_INTERNET = WebResourceErrorType._internal(
"NOT_CONNECTED_TO_INTERNET", "NOT_CONNECTED_TO_INTERNET",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1009 ? -1009
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -339,8 +339,8 @@ class WebResourceErrorType {
static final REDIRECT_TO_NON_EXISTENT_LOCATION = static final REDIRECT_TO_NON_EXISTENT_LOCATION =
WebResourceErrorType._internal( WebResourceErrorType._internal(
"REDIRECT_TO_NON_EXISTENT_LOCATION", "REDIRECT_TO_NON_EXISTENT_LOCATION",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1010 ? -1010
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -350,8 +350,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.badServerResponse](https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse)) ///- iOS ([Official API - URLError.badServerResponse](https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse))
static final BAD_SERVER_RESPONSE = WebResourceErrorType._internal( static final BAD_SERVER_RESPONSE = WebResourceErrorType._internal(
"BAD_SERVER_RESPONSE", "BAD_SERVER_RESPONSE",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1011 ? -1011
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -362,8 +362,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.userCancelledAuthentication](https://developer.apple.com/documentation/foundation/urlerror/2293330-usercancelledauthentication)) ///- iOS ([Official API - URLError.userCancelledAuthentication](https://developer.apple.com/documentation/foundation/urlerror/2293330-usercancelledauthentication))
static final USER_CANCELLED_AUTHENTICATION = WebResourceErrorType._internal( static final USER_CANCELLED_AUTHENTICATION = WebResourceErrorType._internal(
"USER_CANCELLED_AUTHENTICATION", "USER_CANCELLED_AUTHENTICATION",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1012 ? -1012
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -373,8 +373,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.userAuthenticationRequired](https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired)) ///- iOS ([Official API - URLError.userAuthenticationRequired](https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired))
static final USER_AUTHENTICATION_REQUIRED = WebResourceErrorType._internal( static final USER_AUTHENTICATION_REQUIRED = WebResourceErrorType._internal(
"USER_AUTHENTICATION_REQUIRED", "USER_AUTHENTICATION_REQUIRED",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1013 ? -1013
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -384,8 +384,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.zeroByteResource](https://developer.apple.com/documentation/foundation/urlerror/2293773-zerobyteresource)) ///- iOS ([Official API - URLError.zeroByteResource](https://developer.apple.com/documentation/foundation/urlerror/2293773-zerobyteresource))
static final ZERO_BYTE_RESOURCE = WebResourceErrorType._internal( static final ZERO_BYTE_RESOURCE = WebResourceErrorType._internal(
"ZERO_BYTE_RESOURCE", "ZERO_BYTE_RESOURCE",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1014 ? -1014
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -395,8 +395,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.cannotDecodeRawData](https://developer.apple.com/documentation/foundation/urlerror/2293573-cannotdecoderawdata)) ///- iOS ([Official API - URLError.cannotDecodeRawData](https://developer.apple.com/documentation/foundation/urlerror/2293573-cannotdecoderawdata))
static final CANNOT_DECODE_RAW_DATA = WebResourceErrorType._internal( static final CANNOT_DECODE_RAW_DATA = WebResourceErrorType._internal(
"CANNOT_DECODE_RAW_DATA", "CANNOT_DECODE_RAW_DATA",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1015 ? -1015
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -406,8 +406,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.cannotDecodeContentData](https://developer.apple.com/documentation/foundation/urlerror/2292983-cannotdecodecontentdata)) ///- iOS ([Official API - URLError.cannotDecodeContentData](https://developer.apple.com/documentation/foundation/urlerror/2292983-cannotdecodecontentdata))
static final CANNOT_DECODE_CONTENT_DATA = WebResourceErrorType._internal( static final CANNOT_DECODE_CONTENT_DATA = WebResourceErrorType._internal(
"CANNOT_DECODE_CONTENT_DATA", "CANNOT_DECODE_CONTENT_DATA",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1016 ? -1016
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -417,8 +417,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.cannotParseResponse](https://developer.apple.com/documentation/foundation/urlerror/code/2882919-cannotparseresponse)) ///- iOS ([Official API - URLError.cannotParseResponse](https://developer.apple.com/documentation/foundation/urlerror/code/2882919-cannotparseresponse))
static final CANNOT_PARSE_RESPONSE = WebResourceErrorType._internal( static final CANNOT_PARSE_RESPONSE = WebResourceErrorType._internal(
"CANNOT_PARSE_RESPONSE", "CANNOT_PARSE_RESPONSE",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1017 ? -1017
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -429,8 +429,8 @@ class WebResourceErrorType {
static final APP_TRANSPORT_SECURITY_REQUIRES_SECURE_CONNECTION = static final APP_TRANSPORT_SECURITY_REQUIRES_SECURE_CONNECTION =
WebResourceErrorType._internal( WebResourceErrorType._internal(
"APP_TRANSPORT_SECURITY_REQUIRES_SECURE_CONNECTION", "APP_TRANSPORT_SECURITY_REQUIRES_SECURE_CONNECTION",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1022 ? -1022
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -440,8 +440,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.fileIsDirectory](https://developer.apple.com/documentation/foundation/urlerror/code/2883220-fileisdirectory)) ///- iOS ([Official API - URLError.fileIsDirectory](https://developer.apple.com/documentation/foundation/urlerror/code/2883220-fileisdirectory))
static final FILE_IS_DIRECTORY = WebResourceErrorType._internal( static final FILE_IS_DIRECTORY = WebResourceErrorType._internal(
"FILE_IS_DIRECTORY", "FILE_IS_DIRECTORY",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1101 ? -1101
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -451,8 +451,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.noPermissionsToReadFile](https://developer.apple.com/documentation/foundation/urlerror/code/2882941-nopermissionstoreadfile)) ///- iOS ([Official API - URLError.noPermissionsToReadFile](https://developer.apple.com/documentation/foundation/urlerror/code/2882941-nopermissionstoreadfile))
static final NO_PERMISSIONS_TO_READ_FILE = WebResourceErrorType._internal( static final NO_PERMISSIONS_TO_READ_FILE = WebResourceErrorType._internal(
"NO_PERMISSIONS_TO_READ_FILE", "NO_PERMISSIONS_TO_READ_FILE",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1102 ? -1102
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -462,8 +462,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.dataLengthExceedsMaximum](https://developer.apple.com/documentation/foundation/urlerror/code/2882930-datalengthexceedsmaximum)) ///- iOS ([Official API - URLError.dataLengthExceedsMaximum](https://developer.apple.com/documentation/foundation/urlerror/code/2882930-datalengthexceedsmaximum))
static final DATA_LENGTH_EXCEEDS_MAXIMUM = WebResourceErrorType._internal( static final DATA_LENGTH_EXCEEDS_MAXIMUM = WebResourceErrorType._internal(
"DATA_LENGTH_EXCEEDS_MAXIMUM", "DATA_LENGTH_EXCEEDS_MAXIMUM",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1103 ? -1103
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -473,8 +473,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.secureConnectionFailed](https://developer.apple.com/documentation/foundation/urlerror/code/2883122-secureconnectionfailed)) ///- iOS ([Official API - URLError.secureConnectionFailed](https://developer.apple.com/documentation/foundation/urlerror/code/2883122-secureconnectionfailed))
static final SECURE_CONNECTION_FAILED = WebResourceErrorType._internal( static final SECURE_CONNECTION_FAILED = WebResourceErrorType._internal(
"SECURE_CONNECTION_FAILED", "SECURE_CONNECTION_FAILED",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1200 ? -1200
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -484,8 +484,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.serverCertificateHasBadDate](https://developer.apple.com/documentation/foundation/urlerror/code/2883088-servercertificatehasbaddate)) ///- iOS ([Official API - URLError.serverCertificateHasBadDate](https://developer.apple.com/documentation/foundation/urlerror/code/2883088-servercertificatehasbaddate))
static final SERVER_CERTIFICATE_HAS_BAD_DATE = WebResourceErrorType._internal( static final SERVER_CERTIFICATE_HAS_BAD_DATE = WebResourceErrorType._internal(
"SERVER_CERTIFICATE_HAS_BAD_DATE", "SERVER_CERTIFICATE_HAS_BAD_DATE",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1201 ? -1201
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -495,8 +495,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.serverCertificateUntrusted](https://developer.apple.com/documentation/foundation/urlerror/code/2882976-servercertificateuntrusted)) ///- iOS ([Official API - URLError.serverCertificateUntrusted](https://developer.apple.com/documentation/foundation/urlerror/code/2882976-servercertificateuntrusted))
static final SERVER_CERTIFICATE_UNTRUSTED = WebResourceErrorType._internal( static final SERVER_CERTIFICATE_UNTRUSTED = WebResourceErrorType._internal(
"SERVER_CERTIFICATE_UNTRUSTED", "SERVER_CERTIFICATE_UNTRUSTED",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1202 ? -1202
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -507,8 +507,8 @@ class WebResourceErrorType {
static final SERVER_CERTIFICATE_HAS_UNKNOWN_ROOT = static final SERVER_CERTIFICATE_HAS_UNKNOWN_ROOT =
WebResourceErrorType._internal( WebResourceErrorType._internal(
"SERVER_CERTIFICATE_HAS_UNKNOWN_ROOT", "SERVER_CERTIFICATE_HAS_UNKNOWN_ROOT",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1203 ? -1203
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -519,8 +519,8 @@ class WebResourceErrorType {
static final SERVER_CERTIFICATE_NOT_YET_VALID = static final SERVER_CERTIFICATE_NOT_YET_VALID =
WebResourceErrorType._internal( WebResourceErrorType._internal(
"SERVER_CERTIFICATE_NOT_YET_VALID", "SERVER_CERTIFICATE_NOT_YET_VALID",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1204 ? -1204
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -530,8 +530,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.clientCertificateRejected](https://developer.apple.com/documentation/foundation/urlerror/code/2883091-clientcertificaterejected)) ///- iOS ([Official API - URLError.clientCertificateRejected](https://developer.apple.com/documentation/foundation/urlerror/code/2883091-clientcertificaterejected))
static final CLIENT_CERTIFICATE_REJECTED = WebResourceErrorType._internal( static final CLIENT_CERTIFICATE_REJECTED = WebResourceErrorType._internal(
"CLIENT_CERTIFICATE_REJECTED", "CLIENT_CERTIFICATE_REJECTED",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1205 ? -1205
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -541,8 +541,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.clientCertificateRequired](https://developer.apple.com/documentation/foundation/urlerror/code/2883199-clientcertificaterequired)) ///- iOS ([Official API - URLError.clientCertificateRequired](https://developer.apple.com/documentation/foundation/urlerror/code/2883199-clientcertificaterequired))
static final CLIENT_CERTIFICATE_REQUIRED = WebResourceErrorType._internal( static final CLIENT_CERTIFICATE_REQUIRED = WebResourceErrorType._internal(
"CLIENT_CERTIFICATE_REQUIRED", "CLIENT_CERTIFICATE_REQUIRED",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1206 ? -1206
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -552,8 +552,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.cannotLoadFromNetwork](https://developer.apple.com/documentation/foundation/urlerror/code/2882968-cannotloadfromnetwork)) ///- iOS ([Official API - URLError.cannotLoadFromNetwork](https://developer.apple.com/documentation/foundation/urlerror/code/2882968-cannotloadfromnetwork))
static final CANNOT_LOAD_FROM_NETWORK = WebResourceErrorType._internal( static final CANNOT_LOAD_FROM_NETWORK = WebResourceErrorType._internal(
"CANNOT_LOAD_FROM_NETWORK", "CANNOT_LOAD_FROM_NETWORK",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -2000 ? -2000
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -563,8 +563,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.cannotCreateFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883204-cannotcreatefile)) ///- iOS ([Official API - URLError.cannotCreateFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883204-cannotcreatefile))
static final CANNOT_CREATE_FILE = WebResourceErrorType._internal( static final CANNOT_CREATE_FILE = WebResourceErrorType._internal(
"CANNOT_CREATE_FILE", "CANNOT_CREATE_FILE",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -3000 ? -3000
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -574,8 +574,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.cannotOpenFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883034-cannotopenfile)) ///- iOS ([Official API - URLError.cannotOpenFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883034-cannotopenfile))
static final CANNOT_OPEN_FILE = WebResourceErrorType._internal( static final CANNOT_OPEN_FILE = WebResourceErrorType._internal(
"CANNOT_OPEN_FILE", "CANNOT_OPEN_FILE",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -3001 ? -3001
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -585,8 +585,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.cannotCloseFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883215-cannotclosefile)) ///- iOS ([Official API - URLError.cannotCloseFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883215-cannotclosefile))
static final CANNOT_CLOSE_FILE = WebResourceErrorType._internal( static final CANNOT_CLOSE_FILE = WebResourceErrorType._internal(
"CANNOT_CLOSE_FILE", "CANNOT_CLOSE_FILE",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -3002 ? -3002
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -596,8 +596,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.cannotWriteToFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883098-cannotwritetofile)) ///- iOS ([Official API - URLError.cannotWriteToFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883098-cannotwritetofile))
static final CANNOT_WRITE_TO_FILE = WebResourceErrorType._internal( static final CANNOT_WRITE_TO_FILE = WebResourceErrorType._internal(
"CANNOT_WRITE_TO_FILE", "CANNOT_WRITE_TO_FILE",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -3003 ? -3003
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -607,8 +607,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.cannotRemoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883202-cannotremovefile)) ///- iOS ([Official API - URLError.cannotRemoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883202-cannotremovefile))
static final CANNOT_REMOVE_FILE = WebResourceErrorType._internal( static final CANNOT_REMOVE_FILE = WebResourceErrorType._internal(
"CANNOT_REMOVE_FILE", "CANNOT_REMOVE_FILE",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -3004 ? -3004
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -618,8 +618,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.cannotMoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883180-cannotmovefile)) ///- iOS ([Official API - URLError.cannotMoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883180-cannotmovefile))
static final CANNOT_MOVE_FILE = WebResourceErrorType._internal( static final CANNOT_MOVE_FILE = WebResourceErrorType._internal(
"CANNOT_MOVE_FILE", "CANNOT_MOVE_FILE",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -3005 ? -3005
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -630,8 +630,8 @@ class WebResourceErrorType {
static final DOWNLOAD_DECODING_FAILED_MID_STREAM = static final DOWNLOAD_DECODING_FAILED_MID_STREAM =
WebResourceErrorType._internal( WebResourceErrorType._internal(
"DOWNLOAD_DECODING_FAILED_MID_STREAM", "DOWNLOAD_DECODING_FAILED_MID_STREAM",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -3006 ? -3006
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -642,8 +642,8 @@ class WebResourceErrorType {
static final DOWNLOAD_DECODING_FAILED_TO_COMPLETE = static final DOWNLOAD_DECODING_FAILED_TO_COMPLETE =
WebResourceErrorType._internal( WebResourceErrorType._internal(
"DOWNLOAD_DECODING_FAILED_TO_COMPLETE", "DOWNLOAD_DECODING_FAILED_TO_COMPLETE",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -3007 ? -3007
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -653,8 +653,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.internationalRoamingOff](https://developer.apple.com/documentation/foundation/urlerror/code/2883134-internationalroamingoff)) ///- iOS ([Official API - URLError.internationalRoamingOff](https://developer.apple.com/documentation/foundation/urlerror/code/2883134-internationalroamingoff))
static final INTERNATIONAL_ROAMING_OFF = WebResourceErrorType._internal( static final INTERNATIONAL_ROAMING_OFF = WebResourceErrorType._internal(
"INTERNATIONAL_ROAMING_OFF", "INTERNATIONAL_ROAMING_OFF",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1018 ? -1018
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -664,8 +664,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.callIsActive](https://developer.apple.com/documentation/foundation/urlerror/code/2883170-callisactive)) ///- iOS ([Official API - URLError.callIsActive](https://developer.apple.com/documentation/foundation/urlerror/code/2883170-callisactive))
static final CALL_IS_ACTIVE = WebResourceErrorType._internal( static final CALL_IS_ACTIVE = WebResourceErrorType._internal(
"CALL_IS_ACTIVE", "CALL_IS_ACTIVE",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1019 ? -1019
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -675,8 +675,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.dataNotAllowed](https://developer.apple.com/documentation/foundation/urlerror/code/2883217-datanotallowed)) ///- iOS ([Official API - URLError.dataNotAllowed](https://developer.apple.com/documentation/foundation/urlerror/code/2883217-datanotallowed))
static final DATA_NOT_ALLOWED = WebResourceErrorType._internal( static final DATA_NOT_ALLOWED = WebResourceErrorType._internal(
"DATA_NOT_ALLOWED", "DATA_NOT_ALLOWED",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1020 ? -1020
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -686,8 +686,8 @@ class WebResourceErrorType {
///- iOS ([Official API - URLError.requestBodyStreamExhausted](https://developer.apple.com/documentation/foundation/urlerror/code/2883176-requestbodystreamexhausted)) ///- iOS ([Official API - URLError.requestBodyStreamExhausted](https://developer.apple.com/documentation/foundation/urlerror/code/2883176-requestbodystreamexhausted))
static final REQUEST_BODY_STREAM_EXHAUSTED = WebResourceErrorType._internal( static final REQUEST_BODY_STREAM_EXHAUSTED = WebResourceErrorType._internal(
"REQUEST_BODY_STREAM_EXHAUSTED", "REQUEST_BODY_STREAM_EXHAUSTED",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -1021 ? -1021
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -698,8 +698,8 @@ class WebResourceErrorType {
static final BACKGROUND_SESSION_REQUIRES_SHARED_CONTAINER = static final BACKGROUND_SESSION_REQUIRES_SHARED_CONTAINER =
WebResourceErrorType._internal( WebResourceErrorType._internal(
"BACKGROUND_SESSION_REQUIRES_SHARED_CONTAINER", "BACKGROUND_SESSION_REQUIRES_SHARED_CONTAINER",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -995 ? -995
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -710,8 +710,8 @@ class WebResourceErrorType {
static final BACKGROUND_SESSION_IN_USE_BY_ANOTHER_PROCESS = static final BACKGROUND_SESSION_IN_USE_BY_ANOTHER_PROCESS =
WebResourceErrorType._internal( WebResourceErrorType._internal(
"BACKGROUND_SESSION_IN_USE_BY_ANOTHER_PROCESS", "BACKGROUND_SESSION_IN_USE_BY_ANOTHER_PROCESS",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -996 ? -996
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);
@ -722,8 +722,8 @@ class WebResourceErrorType {
static final BACKGROUND_SESSION_WAS_DISCONNECTED = static final BACKGROUND_SESSION_WAS_DISCONNECTED =
WebResourceErrorType._internal( WebResourceErrorType._internal(
"BACKGROUND_SESSION_WAS_DISCONNECTED", "BACKGROUND_SESSION_WAS_DISCONNECTED",
(defaultTargetPlatform != TargetPlatform.iOS || (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform != TargetPlatform.macOS) defaultTargetPlatform == TargetPlatform.macOS)
? -997 ? -997
: UNKNOWN._nativeValue); : UNKNOWN._nativeValue);

View File

@ -36,6 +36,7 @@ node index.js &
flutter --version flutter --version
flutter clean flutter clean
flutter pub get
cd $PROJECT_DIR/example cd $PROJECT_DIR/example
flutter clean flutter clean
if [ ! -z "$2" ] && [ $PLATFORM = "web" ]; then if [ ! -z "$2" ] && [ $PLATFORM = "web" ]; then