diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index b71b49ee..a5a9789e 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -16,13 +16,15 @@
+
-
-
+
+
+
-
+
@@ -45,8 +47,8 @@
-
-
+
+
@@ -57,7 +59,7 @@
-
+
@@ -69,8 +71,8 @@
-
-
+
+
@@ -78,11 +80,11 @@
-
+
-
-
+
+
@@ -93,7 +95,7 @@
-
+
@@ -102,17 +104,17 @@
-
+
-
+
-
-
+
+
@@ -123,8 +125,8 @@
-
-
+
+
@@ -141,16 +143,6 @@
- .toValue
- fromValue(
- ?.toMap());
- fromMap
- setOptions
- fromValue
- List<
- debuggingEnabled
- initialOp
- injectScriptFile
injectScriptUrlFile
[InAppWebView] window
javaScriptEnabled
@@ -171,6 +163,16 @@
NAVIGATION
onNavigationStateChange
shouldInterceptFetchRequest
+ scheme
+ applicationNameForUserAgent
+ cacheMOde
+ inco
+ cacheEna
+ appCacheEnabled
+ appC
+ cache
+ customScheme
+ transparentBackground
activity.getPreferences(0)
@@ -240,17 +242,17 @@
-
-
-
+
+
+
-
+
@@ -261,35 +263,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -339,6 +312,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -489,7 +491,7 @@
-
+
@@ -503,7 +505,7 @@
-
+
@@ -511,7 +513,7 @@
-
+
@@ -742,19 +744,30 @@
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -762,17 +775,10 @@
-
+
-
-
-
-
-
-
-
-
-
+
+
@@ -781,38 +787,34 @@
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9169ec81..a2231f6d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,9 +13,9 @@
- Added `onLoadResourceCustomScheme` event and `resourceCustomSchemes` option to set custom schemes that WebView must handle to load resources
- Added `onTargetBlank` event and `useOnTargetBlank` option to manage links with `target="_blank"`
- Added `ContentBlocker`, `ContentBlockerTrigger` and `ContentBlockerAction` classes and the `contentBlockers` option that allows to define a set of rules to use to block content in the WebView
-- Added new WebView options: `minimumFontSize`, `debuggingEnabled`, `preferredContentMode`
-- Added new Android WebView options: `allowContentAccess`, `allowFileAccess`, `allowFileAccessFromFileURLs`, `allowUniversalAccessFromFileURLs`, `appCacheEnabled`, `appCachePath`, `blockNetworkImage`, `blockNetworkLoads`, `cacheMode`, `cursiveFontFamily`, `defaultFixedFontSize`, `defaultFontSize`, `defaultTextEncodingName`, `disabledActionModeMenuItems`, `fantasyFontFamily`, `fixedFontFamily`, `forceDark`, `geolocationEnabled`, `layoutAlgorithm`, `loadWithOverviewMode`, `loadsImagesAutomatically`, `minimumLogicalFontSize`, `needInitialFocus`, `offscreenPreRaster`, `sansSerifFontFamily`, `serifFontFamily`, `standardFontFamily`
-- Added new iOS WebView options: `applicationNameForUserAgent`, `isFraudulentWebsiteWarningEnabled`, `selectionGranularity`, `dataDetectorTypes`
+- Added new WebView options: `minimumFontSize`, `debuggingEnabled`, `preferredContentMode`, `applicationNameForUserAgent`, `incognito`, `cacheEnabled`
+- Added new Android WebView options: `allowContentAccess`, `allowFileAccess`, `allowFileAccessFromFileURLs`, `allowUniversalAccessFromFileURLs`, `appCachePath`, `blockNetworkImage`, `blockNetworkLoads`, `cacheMode`, `cursiveFontFamily`, `defaultFixedFontSize`, `defaultFontSize`, `defaultTextEncodingName`, `disabledActionModeMenuItems`, `fantasyFontFamily`, `fixedFontFamily`, `forceDark`, `geolocationEnabled`, `layoutAlgorithm`, `loadWithOverviewMode`, `loadsImagesAutomatically`, `minimumLogicalFontSize`, `needInitialFocus`, `offscreenPreRaster`, `sansSerifFontFamily`, `serifFontFamily`, `standardFontFamily`, `saveFormData`, `thirdPartyCookiesEnabled`, `hardwareAcceleration`
+- Added new iOS WebView options: `isFraudulentWebsiteWarningEnabled`, `selectionGranularity`, `dataDetectorTypes`, `sharedCookiesEnabled`
- Added `onGeolocationPermissionsShowPrompt` event and `GeolocationPermissionShowPromptResponse` class (available only for Android)
- Added `startSafeBrowsing`, `setSafeBrowsingWhitelist` and `getSafeBrowsingPrivacyPolicyUrl` methods (available only for Android)
- Added `clearSslPreferences` and `clearClientCertPreferences` methods (available only for Android)
diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java
index e5349026..ff3dfbe8 100644
--- a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java
+++ b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebView.java
@@ -499,19 +499,28 @@ final public class InAppWebView extends InputAwareWebView {
settings.setDatabaseEnabled(options.databaseEnabled);
settings.setDomStorageEnabled(options.domStorageEnabled);
- if (!options.userAgent.isEmpty())
+ if (options.userAgent != null && !options.userAgent.isEmpty())
settings.setUserAgentString(options.userAgent);
+ else if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
+ settings.setUserAgentString(WebSettings.getDefaultUserAgent(getContext()));
+
+ if (options.applicationNameForUserAgent != null && !options.applicationNameForUserAgent.isEmpty()) {
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ String userAgent = (options.userAgent != null && !options.userAgent.isEmpty()) ? options.userAgent :WebSettings.getDefaultUserAgent(getContext());
+ String userAgentWithApplicationName = userAgent + " " + options.applicationNameForUserAgent;
+ settings.setUserAgentString(userAgentWithApplicationName);
+ }
+ }
if (options.clearCache)
clearAllCache();
else if (options.clearSessionCache)
CookieManager.getInstance().removeSessionCookie();
- // Enable Thirdparty Cookies on >=Android 5.0 device
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
- CookieManager.getInstance().setAcceptThirdPartyCookies(this, true);
+ CookieManager.getInstance().setAcceptThirdPartyCookies(this, options.thirdPartyCookiesEnabled);
- settings.setLoadWithOverviewMode(true);
+ settings.setLoadWithOverviewMode(options.loadWithOverviewMode);
settings.setUseWideViewPort(options.useWideViewPort);
settings.setSupportZoom(options.supportZoom);
settings.setTextZoom(options.textZoom);
@@ -528,8 +537,8 @@ final public class InAppWebView extends InputAwareWebView {
settings.setAllowFileAccess(options.allowFileAccess);
settings.setAllowFileAccessFromFileURLs(options.allowFileAccessFromFileURLs);
settings.setAllowUniversalAccessFromFileURLs(options.allowUniversalAccessFromFileURLs);
- settings.setAppCacheEnabled(options.appCacheEnabled);
- if (options.appCachePath != null && !options.appCachePath.isEmpty() && options.appCacheEnabled)
+ setCacheEnabled(options.cacheEnabled);
+ if (options.appCachePath != null && !options.appCachePath.isEmpty() && options.cacheEnabled)
settings.setAppCachePath(options.appCachePath);
settings.setBlockNetworkImage(options.blockNetworkImage);
settings.setBlockNetworkLoads(options.blockNetworkLoads);
@@ -548,7 +557,6 @@ final public class InAppWebView extends InputAwareWebView {
settings.setGeolocationEnabled(options.geolocationEnabled);
if (options.layoutAlgorithm != null)
settings.setLayoutAlgorithm(options.layoutAlgorithm);
- settings.setLoadWithOverviewMode(options.loadWithOverviewMode);
settings.setLoadsImagesAutomatically(options.loadsImagesAutomatically);
settings.setMinimumFontSize(options.minimumFontSize);
settings.setMinimumLogicalFontSize(options.minimumLogicalFontSize);
@@ -570,6 +578,13 @@ final public class InAppWebView extends InputAwareWebView {
break;
}
}
+ settings.setSaveFormData(options.saveFormData);
+ if (options.incognito)
+ setIncognito(true);
+ if (options.hardwareAcceleration)
+ setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ else
+ setLayerType(View.LAYER_TYPE_SOFTWARE, null);
contentBlockerHandler.getRuleList().clear();
for (Map> contentBlocker : options.contentBlockers) {
@@ -593,6 +608,49 @@ final public class InAppWebView extends InputAwareWebView {
});
}
+ public void setIncognito(boolean enabled) {
+ WebSettings settings = getSettings();
+ if (enabled) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ CookieManager.getInstance().removeAllCookies(null);
+ } else {
+ CookieManager.getInstance().removeAllCookie();
+ }
+
+ // Disable caching
+ settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
+ settings.setAppCacheEnabled(false);
+ clearHistory();
+ clearCache(true);
+
+ // No form data or autofill enabled
+ clearFormData();
+ settings.setSavePassword(false);
+ settings.setSaveFormData(false);
+ }
+ else {
+ settings.setCacheMode(WebSettings.LOAD_DEFAULT);
+ settings.setAppCacheEnabled(true);
+ settings.setSavePassword(true);
+ settings.setSaveFormData(true);
+ }
+ }
+
+ public void setCacheEnabled(boolean enabled) {
+ WebSettings settings = getSettings();
+ if (enabled) {
+ Context ctx = getContext();
+ if (ctx != null) {
+ settings.setAppCachePath(ctx.getCacheDir().getAbsolutePath());
+ settings.setCacheMode(WebSettings.LOAD_DEFAULT);
+ settings.setAppCacheEnabled(true);
+ }
+ } else {
+ settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
+ settings.setAppCacheEnabled(false);
+ }
+ }
+
public void loadUrl(String url, MethodChannel.Result result) {
if (!url.isEmpty()) {
loadUrl(url);
@@ -780,11 +838,22 @@ final public class InAppWebView extends InputAwareWebView {
if (newOptionsMap.get("userAgent") != null && !options.userAgent.equals(newOptions.userAgent) && !newOptions.userAgent.isEmpty())
settings.setUserAgentString(newOptions.userAgent);
+ if (newOptionsMap.get("applicationNameForUserAgent") != null && !options.applicationNameForUserAgent.equals(newOptions.applicationNameForUserAgent) && !newOptions.applicationNameForUserAgent.isEmpty()) {
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ String userAgent = (newOptions.userAgent != null && !newOptions.userAgent.isEmpty()) ? newOptions.userAgent : WebSettings.getDefaultUserAgent(getContext());
+ String userAgentWithApplicationName = userAgent + " " + options.applicationNameForUserAgent;
+ settings.setUserAgentString(userAgentWithApplicationName);
+ }
+ }
+
if (newOptionsMap.get("clearCache") != null && newOptions.clearCache)
clearAllCache();
else if (newOptionsMap.get("clearSessionCache") != null && newOptions.clearSessionCache)
CookieManager.getInstance().removeSessionCookie();
+ if (newOptionsMap.get("thirdPartyCookiesEnabled") != null && options.thirdPartyCookiesEnabled != newOptions.thirdPartyCookiesEnabled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
+ CookieManager.getInstance().setAcceptThirdPartyCookies(this, newOptions.thirdPartyCookiesEnabled);
+
if (newOptionsMap.get("useWideViewPort") != null && options.useWideViewPort != newOptions.useWideViewPort)
settings.setUseWideViewPort(newOptions.useWideViewPort);
@@ -835,12 +904,11 @@ final public class InAppWebView extends InputAwareWebView {
if (newOptionsMap.get("allowUniversalAccessFromFileURLs") != null && options.allowUniversalAccessFromFileURLs != newOptions.allowUniversalAccessFromFileURLs)
settings.setAllowUniversalAccessFromFileURLs(newOptions.allowUniversalAccessFromFileURLs);
- if (newOptionsMap.get("appCacheEnabled") != null && options.appCacheEnabled != newOptions.appCacheEnabled)
- settings.setAppCacheEnabled(newOptions.appCacheEnabled);
+ if (newOptionsMap.get("cacheEnabled") != null && options.cacheEnabled != newOptions.cacheEnabled)
+ setCacheEnabled(newOptions.cacheEnabled);
if (newOptionsMap.get("appCachePath") != null && !options.appCachePath.equals(newOptions.appCachePath))
- if (newOptions.appCacheEnabled)
- settings.setAppCachePath(newOptions.appCachePath);
+ settings.setAppCachePath(newOptions.appCachePath);
if (newOptionsMap.get("blockNetworkImage") != null && options.blockNetworkImage != newOptions.blockNetworkImage)
settings.setBlockNetworkImage(newOptions.blockNetworkImage);
@@ -911,6 +979,19 @@ final public class InAppWebView extends InputAwareWebView {
if (newOptionsMap.get("standardFontFamily") != null && !options.standardFontFamily.equals(newOptions.standardFontFamily))
settings.setStandardFontFamily(newOptions.standardFontFamily);
+ if (newOptionsMap.get("saveFormData") != null && options.saveFormData != newOptions.saveFormData)
+ settings.setSaveFormData(newOptions.saveFormData);
+
+ if (newOptionsMap.get("incognito") != null && options.incognito != newOptions.incognito)
+ setIncognito(newOptions.incognito);
+
+ if (newOptionsMap.get("hardwareAcceleration") != null && options.hardwareAcceleration != newOptions.hardwareAcceleration) {
+ if (newOptions.hardwareAcceleration)
+ setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ else
+ setLayerType(View.LAYER_TYPE_SOFTWARE, null);
+ }
+
if (newOptions.contentBlockers != null) {
contentBlockerHandler.getRuleList().clear();
for (Map> contentBlocker : newOptions.contentBlockers) {
diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java
index 4168c34f..b06208a0 100644
--- a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java
+++ b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebViewOptions.java
@@ -12,44 +12,46 @@ public class InAppWebViewOptions extends Options {
public static final String LOG_TAG = "InAppWebViewOptions";
- public boolean useShouldOverrideUrlLoading = false;
- public boolean useOnLoadResource = false;
- public boolean useOnDownloadStart = false;
- public boolean useOnTargetBlank = false;
- public boolean clearCache = false;
+ public Boolean useShouldOverrideUrlLoading = false;
+ public Boolean useOnLoadResource = false;
+ public Boolean useOnDownloadStart = false;
+ public Boolean useOnTargetBlank = false;
+ public Boolean clearCache = false;
public String userAgent = "";
- public boolean javaScriptEnabled = true;
- public boolean debuggingEnabled = false;
- public boolean javaScriptCanOpenWindowsAutomatically = false;
- public boolean mediaPlaybackRequiresUserGesture = true;
+ public String applicationNameForUserAgent = "";
+ public Boolean javaScriptEnabled = true;
+ public Boolean debuggingEnabled = false;
+ public Boolean javaScriptCanOpenWindowsAutomatically = false;
+ public Boolean mediaPlaybackRequiresUserGesture = true;
public Integer textZoom = 100;
public Integer minimumFontSize = 8;
- public boolean verticalScrollBarEnabled = true;
- public boolean horizontalScrollBarEnabled = true;
+ public Boolean verticalScrollBarEnabled = true;
+ public Boolean horizontalScrollBarEnabled = true;
public List resourceCustomSchemes = new ArrayList<>();
public List