Commit 31dc73cf authored by Lorenzo Pichilli's avatar Lorenzo Pichilli

added new webview options

parent b4544c7d
This diff is collapsed.
......@@ -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)
......
......@@ -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<String, Map<String, Object>> 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,11 +904,10 @@ 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);
if (newOptionsMap.get("blockNetworkImage") != null && options.blockNetworkImage != 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<String, Map<String, Object>> contentBlocker : newOptions.contentBlockers) {
......
......@@ -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<String> resourceCustomSchemes = new ArrayList<>();
public List<Map<String, Map<String, Object>>> contentBlockers = new ArrayList<>();
public Integer preferredContentMode = PreferredContentModeOptionType.RECOMMENDED.toValue();
public Boolean useShouldInterceptAjaxRequest = false;
public Boolean useShouldInterceptFetchRequest = false;
public Boolean incognito = false;
public Boolean cacheEnabled = true;
public Boolean transparentBackground = false;
public boolean clearSessionCache = false;
public boolean builtInZoomControls = false;
public boolean displayZoomControls = false;
public boolean supportZoom = true;
public boolean databaseEnabled = false;
public boolean domStorageEnabled = false;
public boolean useWideViewPort = true;
public boolean safeBrowsingEnabled = true;
public boolean transparentBackground = false;
public Boolean clearSessionCache = false;
public Boolean builtInZoomControls = false;
public Boolean displayZoomControls = false;
public Boolean supportZoom = true;
public Boolean databaseEnabled = false;
public Boolean domStorageEnabled = false;
public Boolean useWideViewPort = true;
public Boolean safeBrowsingEnabled = true;
public Integer mixedContentMode;
public boolean allowContentAccess = true;
public boolean allowFileAccess = true;
public boolean allowFileAccessFromFileURLs = true;
public boolean allowUniversalAccessFromFileURLs = true;
public boolean appCacheEnabled = true;
public Boolean allowContentAccess = true;
public Boolean allowFileAccess = true;
public Boolean allowFileAccessFromFileURLs = true;
public Boolean allowUniversalAccessFromFileURLs = true;
public String appCachePath;
public boolean blockNetworkImage = false;
public boolean blockNetworkLoads = false;
public Boolean blockNetworkImage = false;
public Boolean blockNetworkLoads = false;
public Integer cacheMode = WebSettings.LOAD_DEFAULT;
public String cursiveFontFamily = "cursive";
public Integer defaultFixedFontSize = 16;
......@@ -59,14 +61,17 @@ public class InAppWebViewOptions extends Options {
public String fantasyFontFamily = "fantasy";
public String fixedFontFamily = "monospace";
public Integer forceDark = 0; // WebSettings.FORCE_DARK_OFF
public boolean geolocationEnabled = true;
public Boolean geolocationEnabled = true;
public WebSettings.LayoutAlgorithm layoutAlgorithm;
public boolean loadWithOverviewMode = true;
public boolean loadsImagesAutomatically = true;
public Boolean loadWithOverviewMode = true;
public Boolean loadsImagesAutomatically = true;
public Integer minimumLogicalFontSize = 8;
public boolean needInitialFocus = true;
public boolean offscreenPreRaster = false;
public Boolean needInitialFocus = true;
public Boolean offscreenPreRaster = false;
public String sansSerifFontFamily = "sans-serif";
public String serifFontFamily = "sans-serif";
public String standardFontFamily = "sans-serif";
public Boolean saveFormData = true;
public Boolean thirdPartyCookiesEnabled = true;
public Boolean hardwareAcceleration = true;
}
......@@ -93,7 +93,7 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
initialOptions: InAppWebViewWidgetOptions(
inAppWebViewOptions: InAppWebViewOptions(
debuggingEnabled: true,
clearCache: true,
//clearCache: true,
useShouldOverrideUrlLoading: true,
useOnTargetBlank: true,
useOnLoadResource: true,
......@@ -113,7 +113,6 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
),
androidInAppWebViewOptions: AndroidInAppWebViewOptions(
databaseEnabled: true,
appCacheEnabled: true,
domStorageEnabled: true,
geolocationEnabled: true,
//safeBrowsingEnabled: true,
......
......@@ -302,6 +302,10 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView {
}
result(true)
break
case "removeFromSuperview":
webView!.removeFromSuperview()
result(true)
break
default:
result(FlutterMethodNotImplemented)
break
......
......@@ -26,6 +26,19 @@ func convertToDictionary(text: String) -> [String: Any]? {
return nil
}
func JSONStringify(value: Any, prettyPrinted: Bool = false) -> String {
let options: JSONSerialization.WritingOptions = prettyPrinted ? .prettyPrinted : .init(rawValue: 0)
if JSONSerialization.isValidJSONObject(value) {
let data = try? JSONSerialization.data(withJSONObject: value, options: options)
if data != nil {
if let string = String(data: data!, encoding: .utf8) {
return string
}
}
}
return ""
}
let JAVASCRIPT_BRIDGE_NAME = "flutter_inappbrowser"
// the message needs to be concatenated with '' in order to have the same behavior like on Android
......@@ -662,7 +675,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
let jscriptWebkitTouchCallout = WKUserScript(source: "document.body.style.webkitTouchCallout='none';", injectionTime: .atDocumentEnd, forMainFrameOnly: true)
configuration.userContentController.addUserScript(jscriptWebkitTouchCallout)
let consoleLogJSScript = WKUserScript(source: consoleLogJS, injectionTime: .atDocumentStart, forMainFrameOnly: false)
configuration.userContentController.addUserScript(consoleLogJSScript)
configuration.userContentController.add(self, name: "consoleLog")
......@@ -699,18 +711,39 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
configuration.userContentController.addUserScript(interceptFetchRequestsJSScript)
}
if #available(iOS 9.0, *) {
if ((options?.incognito)!) {
configuration.websiteDataStore = WKWebsiteDataStore.nonPersistent()
} else if ((options?.cacheEnabled)!) {
configuration.websiteDataStore = WKWebsiteDataStore.default()
}
}
//keyboardDisplayRequiresUserAction = browserOptions?.keyboardDisplayRequiresUserAction
if #available(iOS 11.0, *) {
if((options?.sharedCookiesEnabled)!) {
// More info to sending cookies with WKWebView
// https://stackoverflow.com/questions/26573137/can-i-set-the-cookies-to-be-used-by-a-wkwebview/26577303#26577303
// Set Cookies in iOS 11 and above, initialize websiteDataStore before setting cookies
// See also https://forums.developer.apple.com/thread/97194
// check if websiteDataStore has not been initialized before
if(!(options?.incognito)! && !(options?.cacheEnabled)!) {
configuration.websiteDataStore = WKWebsiteDataStore.nonPersistent()
}
for cookie in HTTPCookieStorage.shared.cookies ?? [] {
configuration.websiteDataStore.httpCookieStore.setCookie(cookie, completionHandler: nil)
}
}
}
configuration.suppressesIncrementalRendering = (options?.suppressesIncrementalRendering)!
allowsBackForwardNavigationGestures = (options?.allowsBackForwardNavigationGestures)!
if #available(iOS 9.0, *) {
allowsLinkPreview = (options?.allowsLinkPreview)!
configuration.allowsPictureInPictureMediaPlayback = (options?.allowsPictureInPictureMediaPlayback)!
if ((options?.applicationNameForUserAgent)! != "") {
if (options?.applicationNameForUserAgent != nil && (options?.applicationNameForUserAgent)! != "") {
configuration.applicationNameForUserAgent = (options?.applicationNameForUserAgent)!
}
if ((options?.userAgent)! != "") {
if (options?.userAgent != nil && (options?.userAgent)! != "") {
customUserAgent = (options?.userAgent)!
}
}
......@@ -927,6 +960,25 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
}
}
if #available(iOS 9.0, *) {
if (newOptionsMap["incognito"] != nil && options?.incognito != newOptions.incognito && newOptions.incognito) {
configuration.websiteDataStore = WKWebsiteDataStore.nonPersistent()
} else if (newOptionsMap["cacheEnabled"] != nil && options?.cacheEnabled != newOptions.cacheEnabled && newOptions.cacheEnabled) {
configuration.websiteDataStore = WKWebsiteDataStore.default()
}
}
if #available(iOS 11.0, *) {
if (newOptionsMap["sharedCookiesEnabled"] != nil && options?.sharedCookiesEnabled != newOptions.sharedCookiesEnabled && newOptions.sharedCookiesEnabled) {
if(!newOptions.incognito && !newOptions.cacheEnabled) {
configuration.websiteDataStore = WKWebsiteDataStore.nonPersistent()
}
for cookie in HTTPCookieStorage.shared.cookies ?? [] {
configuration.websiteDataStore.httpCookieStore.setCookie(cookie, completionHandler: nil)
}
}
}
if newOptionsMap["enableViewportScale"] != nil && options?.enableViewportScale != newOptions.enableViewportScale && newOptions.enableViewportScale {
let jscript = "var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);"
evaluateJavaScript(jscript, completionHandler: nil)
......@@ -960,10 +1012,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
configuration.allowsInlineMediaPlayback = newOptions.allowsInlineMediaPlayback
}
// if newOptionsMap["keyboardDisplayRequiresUserAction"] != nil && browserOptions?.keyboardDisplayRequiresUserAction != newOptions.keyboardDisplayRequiresUserAction {
// self.webView.keyboardDisplayRequiresUserAction = newOptions.keyboardDisplayRequiresUserAction
// }
if newOptionsMap["suppressesIncrementalRendering"] != nil && options?.suppressesIncrementalRendering != newOptions.suppressesIncrementalRendering {
configuration.suppressesIncrementalRendering = newOptions.suppressesIncrementalRendering
}
......@@ -1997,4 +2045,24 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
func clearMatches(completionHandler: ((Any?, Error?) -> Void)?) {
evaluateJavaScript("wkwebview_ClearMatches();", completionHandler: completionHandler)
}
public override func removeFromSuperview() {
configuration.userContentController.removeScriptMessageHandler(forName: "consoleLog")
configuration.userContentController.removeScriptMessageHandler(forName: "consoleDebug")
configuration.userContentController.removeScriptMessageHandler(forName: "consoleError")
configuration.userContentController.removeScriptMessageHandler(forName: "consoleInfo")
configuration.userContentController.removeScriptMessageHandler(forName: "consoleWarn")
configuration.userContentController.removeScriptMessageHandler(forName: "callHandler")
configuration.userContentController.removeScriptMessageHandler(forName: "onFindResultReceived")
configuration.userContentController.removeScriptMessageHandler(forName: "onNavigationStateChange")
configuration.userContentController.removeAllUserScripts()
removeObserver(self, forKeyPath: "estimatedProgress")
super.removeFromSuperview()
uiDelegate = nil
navigationDelegate = nil
scrollView.delegate = nil
IAWController?.channel?.setMethodCallHandler(nil)
IABController?.webView = nil
IAWController?.webView = nil
}
}
......@@ -17,6 +17,7 @@ public class InAppWebViewOptions: Options {
var useOnTargetBlank = false
var clearCache = false
var userAgent = ""
var applicationNameForUserAgent = ""
var javaScriptEnabled = true
var debuggingEnabled = true
var javaScriptCanOpenWindowsAutomatically = false
......@@ -25,13 +26,15 @@ public class InAppWebViewOptions: Options {
var horizontalScrollBarEnabled = true
var resourceCustomSchemes: [String] = []
var contentBlockers: [[String: [String : Any]]] = []
var minimumFontSize = 0;
var minimumFontSize = 0
var useShouldInterceptAjaxRequest = false
var useShouldInterceptFetchRequest = false
var incognito = false
var cacheEnabled = true
var transparentBackground = false
var disallowOverScroll = false
var enableViewportScale = false
//var keyboardDisplayRequiresUserAction = true
var suppressesIncrementalRendering = false
var allowsAirPlayForMediaPlayback = true
var allowsBackForwardNavigationGestures = true
......@@ -39,12 +42,11 @@ public class InAppWebViewOptions: Options {
var ignoresViewportScaleLimits = false
var allowsInlineMediaPlayback = false
var allowsPictureInPictureMediaPlayback = true
var transparentBackground = false
var applicationNameForUserAgent = "";
var isFraudulentWebsiteWarningEnabled = true;
var selectionGranularity = 0;
var dataDetectorTypes: [String] = ["NONE"]; // WKDataDetectorTypeNone
var preferredContentMode = 0;
var dataDetectorTypes: [String] = ["NONE"] // WKDataDetectorTypeNone
var preferredContentMode = 0
var sharedCookiesEnabled = false
override init(){
super.init()
......
......@@ -325,6 +325,13 @@ class _InAppWebViewState extends State<InAppWebView> {
super.didUpdateWidget(oldWidget);
}
@override
void dispose(){
super.dispose();
if (Platform.isIOS)
_controller._channel.invokeMethod('removeFromSuperview');
}
void _onPlatformViewCreated(int id) {
_controller = InAppWebViewController(id, widget);
if (widget.onWebViewCreated != null) {
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment