diff --git a/.gradle/5.1.1/fileChanges/last-build.bin b/.gradle/5.1.1/fileChanges/last-build.bin
new file mode 100644
index 000000000..f76dd238a
Binary files /dev/null and b/.gradle/5.1.1/fileChanges/last-build.bin differ
diff --git a/.gradle/5.1.1/fileHashes/fileHashes.lock b/.gradle/5.1.1/fileHashes/fileHashes.lock
new file mode 100644
index 000000000..015c98155
Binary files /dev/null and b/.gradle/5.1.1/fileHashes/fileHashes.lock differ
diff --git a/.gradle/5.1.1/gc.properties b/.gradle/5.1.1/gc.properties
new file mode 100644
index 000000000..e69de29bb
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index 9a4cb628a..0c14d8d13 100644
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties
index 3d1809d4e..6fd10dc64 100644
--- a/.gradle/buildOutputCleanup/cache.properties
+++ b/.gradle/buildOutputCleanup/cache.properties
@@ -1,2 +1,2 @@
-#Sun Sep 16 19:20:12 CEST 2018
-gradle.version=4.4.1
+#Sat Jun 01 15:11:27 CEST 2019
+gradle.version=5.1.1
diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties
new file mode 100644
index 000000000..e69de29bb
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
deleted file mode 100644
index 30aa626c2..000000000
--- a/.idea/codeStyles/Project.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 000000000..15a15b218
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml
index f376a57a8..62be7eab6 100644
--- a/.idea/libraries/Dart_SDK.xml
+++ b/.idea/libraries/Dart_SDK.xml
@@ -1,17 +1,26 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 6c6d3f4bd..bfa5e6bb7 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,25 +5,38 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/example_lib_main_dart.xml b/.idea/runConfigurations/example_lib_main_dart.xml
index 5fd9159d1..bac2c8a79 100644
--- a/.idea/runConfigurations/example_lib_main_dart.xml
+++ b/.idea/runConfigurations/example_lib_main_dart.xml
@@ -1,6 +1,6 @@
-
+
-
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index c7434d0ce..94a25f7f4 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,6 +2,5 @@
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 07493bda3..830bc012e 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -15,32 +15,26 @@
+
+
+
+
+
+
+
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
@@ -56,67 +50,22 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -124,8 +73,8 @@
-
-
+
+
@@ -136,8 +85,8 @@
-
-
+
+
@@ -146,31 +95,31 @@
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
+
+
+
-
-
+
+
-
-
+
+
@@ -186,10 +135,6 @@
- _uuidGenerator
- in the flutter
- RELOAD
- localhostServer
initialFile
loadFile
openFile
@@ -216,6 +161,10 @@
hidden
builtInZoomControls
__builtInZoomControls__
+ android.support.v4
+ __transparentBackground__
+ dispose
+ _dispose
activity.getPreferences(0)
@@ -263,25 +212,24 @@
-
-
-
+
-
-
+
+
+
+
-
-
+
@@ -289,7 +237,6 @@
-
@@ -329,12 +276,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -347,6 +309,7 @@
+
@@ -358,10 +321,10 @@
-
+
-
+
@@ -461,7 +424,8 @@
-
+
+
@@ -493,33 +457,35 @@
-
+
-
-
+
+
+
-
+
-
+
-
-
-
+
+
+
-
+
+
@@ -535,21 +501,12 @@
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
@@ -699,125 +656,138 @@
-
+
+
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 958d806d1..fb1f7afed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+## 1.2.1
+
+- Merge "Add new option to control the contentMode in Android platform" [#101](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/101) (thanks to [DreamBuddy](https://github.com/DreamBuddy))
+- Merge "Fix crash on xcode 10.2" [#107](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/107) (thanks to [robsonfingo](https://github.com/robsonfingo))
+- Merge "Remove headers_build_phase from example's Podfile" [#108](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/108) (thanks to [robsonfingo](https://github.com/robsonfingo))
+- Fixed "Make html5 video fullscreen" for Android [#43](https://github.com/pichillilorenzo/flutter_inappbrowser/issues/43)
+- Fixed "AllowsInlineMediaPlayback not working" for iOS [#73](https://github.com/pichillilorenzo/flutter_inappbrowser/issues/73)
+
## 1.2.0
- Merge "Adds a transparentBackground option for iOS and Android" [#86](https://github.com/pichillilorenzo/flutter_inappbrowser/pull/86) (thanks to [matthewlloyd](https://github.com/matthewlloyd))
diff --git a/README.md b/README.md
index 4763f67c3..74a338bbc 100644
--- a/README.md
+++ b/README.md
@@ -252,7 +252,8 @@ All platforms support:
- __domStorageEnabled__: Set to `true` if you want the DOM storage API is enabled. The default value is `false`.
- __useWideViewPort__: Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is true and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. The default value is `true`.
- __safeBrowsingEnabled__: Set to `true` if you want the Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. The default value is `true`.
- - __textZoom__: Set text scaling of the WebView. The default value is `100`.
+ - __textZoom__: Set text scaling of the WebView. The default value is `100`.
+ - __mixedContentMode__: Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. By default, apps that target `Build.VERSION_CODES.KITKAT` or below default to `MIXED_CONTENT_ALWAYS_ALLOW`. Apps targeting `Build.VERSION_CODES.LOLLIPOP` default to `MIXED_CONTENT_NEVER_ALLOW`. The preferred and most secure mode of operation for the WebView is `MIXED_CONTENT_NEVER_ALLOW` and use of `MIXED_CONTENT_ALWAYS_ALLOW` is strongly discouraged.
**iOS** supports these additional options:
@@ -828,6 +829,7 @@ Opens an `url` in a new `InAppBrowser` instance.
- __safeBrowsingEnabled__: Set to `true` if you want the Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. The default value is `true`.
- __progressBar__: Set to `false` to hide the progress bar at the bottom of the toolbar at the top. The default value is `true`.
- __textZoom__: Set text scaling of the WebView. The default value is `100`.
+ - __mixedContentMode__: Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. By default, apps that target `Build.VERSION_CODES.KITKAT` or below default to `MIXED_CONTENT_ALWAYS_ALLOW`. Apps targeting `Build.VERSION_CODES.LOLLIPOP` default to `MIXED_CONTENT_NEVER_ALLOW`. The preferred and most secure mode of operation for the WebView is `MIXED_CONTENT_NEVER_ALLOW` and use of `MIXED_CONTENT_ALWAYS_ALLOW` is strongly discouraged.
**iOS** supports these additional options:
diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebChromeClient.java b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebChromeClient.java
index 1324b0b9c..f18ec0c0f 100644
--- a/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebChromeClient.java
+++ b/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppWebView/InAppWebChromeClient.java
@@ -2,6 +2,8 @@
import android.content.Intent;
import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.view.View;
@@ -9,6 +11,7 @@
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
+import android.widget.FrameLayout;
import com.pichillilorenzo.flutter_inappbrowser.FlutterWebView;
import com.pichillilorenzo.flutter_inappbrowser.InAppBrowserActivity;
@@ -18,24 +21,69 @@
import java.util.Map;
import io.flutter.plugin.common.MethodChannel;
+import io.flutter.plugin.common.PluginRegistry;
public class InAppWebChromeClient extends WebChromeClient {
protected static final String LOG_TAG = "IABWebChromeClient";
+ private PluginRegistry.Registrar registrar;
private FlutterWebView flutterWebView;
private InAppBrowserActivity inAppBrowserActivity;
private ValueCallback mUploadMessageArray;
private ValueCallback mUploadMessage;
private final static int FILECHOOSER_RESULTCODE = 1;
- public InAppWebChromeClient(Object obj) {
+ private View mCustomView;
+ private WebChromeClient.CustomViewCallback mCustomViewCallback;
+ protected FrameLayout mFullscreenContainer;
+ private int mOriginalOrientation;
+ private int mOriginalSystemUiVisibility;
+
+ public InAppWebChromeClient(Object obj, PluginRegistry.Registrar registrar) {
super();
+ this.registrar = registrar;
if (obj instanceof InAppBrowserActivity)
this.inAppBrowserActivity = (InAppBrowserActivity) obj;
else if (obj instanceof FlutterWebView)
this.flutterWebView = (FlutterWebView) obj;
}
+ public Bitmap getDefaultVideoPoster()
+ {
+ if (mCustomView == null) {
+ return null;
+ }
+ return BitmapFactory.decodeResource(this.registrar.activeContext().getResources(), 2130837573);
+ }
+
+ public void onHideCustomView()
+ {
+ View decorView = this.registrar.activity().getWindow().getDecorView();
+ ((FrameLayout) decorView).removeView(this.mCustomView);
+ this.mCustomView = null;
+ decorView.setSystemUiVisibility(this.mOriginalSystemUiVisibility);
+ this.registrar.activity().setRequestedOrientation(this.mOriginalOrientation);
+ this.mCustomViewCallback.onCustomViewHidden();
+ this.mCustomViewCallback = null;
+ }
+
+ public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback paramCustomViewCallback)
+ {
+ if (this.mCustomView != null)
+ {
+ onHideCustomView();
+ return;
+ }
+ View decorView = this.registrar.activity().getWindow().getDecorView();
+ this.mCustomView = paramView;
+ this.mOriginalSystemUiVisibility = decorView.getSystemUiVisibility();
+ this.mOriginalOrientation = this.registrar.activity().getRequestedOrientation();
+ this.mCustomViewCallback = paramCustomViewCallback;
+ this.mCustomView.setBackgroundColor(Color.parseColor("#000000"));
+ ((FrameLayout) decorView).addView(this.mCustomView, new FrameLayout.LayoutParams(-1, -1));
+ decorView.setSystemUiVisibility(3846 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+ }
+
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
Map obj = new HashMap<>();
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 a7c6d8f67..1d81944ab 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
@@ -116,7 +116,7 @@ public void prepare() {
addJavascriptInterface(new JavaScriptBridgeInterface((isFromInAppBrowserActivity) ? inAppBrowserActivity : flutterWebView), JavaScriptBridgeInterface.name);
- inAppWebChromeClient = new InAppWebChromeClient((isFromInAppBrowserActivity) ? inAppBrowserActivity : flutterWebView);
+ inAppWebChromeClient = new InAppWebChromeClient((isFromInAppBrowserActivity) ? inAppBrowserActivity : flutterWebView, this.registrar);
setWebChromeClient(inAppWebChromeClient);
inAppWebViewClient = new InAppWebViewClient((isFromInAppBrowserActivity) ? inAppBrowserActivity : flutterWebView);
@@ -198,6 +198,8 @@ else if (options.clearSessionCache)
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
} else if (options.mixedContentMode.equals("MIXED_CONTENT_ALWAYS_ALLOW")) {
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
+ } else if (options.mixedContentMode.equals("MIXED_CONTENT_NEVER_ALLOW")) {
+ settings.setMixedContentMode(WebSettings.MIXED_CONTENT_NEVER_ALLOW);
}
}
}
@@ -371,6 +373,8 @@ else if (newOptionsMap.get("clearSessionCache") != null && newOptions.clearSessi
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
} else if (newOptions.mixedContentMode.equals("MIXED_CONTENT_ALWAYS_ALLOW")) {
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
+ } else if (newOptions.mixedContentMode.equals("MIXED_CONTENT_NEVER_ALLOW")) {
+ settings.setMixedContentMode(WebSettings.MIXED_CONTENT_NEVER_ALLOW);
}
}
}
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 056cb88c1..14c9e89c5 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
@@ -24,5 +24,5 @@ public class InAppWebViewOptions extends Options {
public boolean useWideViewPort = true;
public boolean safeBrowsingEnabled = true;
public boolean transparentBackground = false;
- public String mixedContentMode = "MIXED_CONTENT_NEVER_ALLOW";
+ public String mixedContentMode = "";
}
diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj
index 49f29988a..42d70d556 100644
--- a/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/example/ios/Runner.xcodeproj/project.pbxproj
@@ -51,6 +51,8 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
+ 9D199BB70329114343003314 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; };
+ B23847D2EEA83886DC92B60F /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; };
E8D91E403808A7540F18B75D /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@@ -79,6 +81,8 @@
647DC95AB5350DB6D2264FFE /* Pods */ = {
isa = PBXGroup;
children = (
+ B23847D2EEA83886DC92B60F /* Pods-Runner.debug.xcconfig */,
+ 9D199BB70329114343003314 /* Pods-Runner.release.xcconfig */,
);
name = Pods;
sourceTree = "";
@@ -250,7 +254,7 @@
files = (
);
inputPaths = (
- "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
"${BUILT_PRODUCTS_DIR}/flutter_inappbrowser/flutter_inappbrowser.framework",
);
@@ -261,7 +265,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
+ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
diff --git a/example/lib/inline_example.screen.dart b/example/lib/inline_example.screen.dart
index 43eb62f01..04fc3bc01 100644
--- a/example/lib/inline_example.screen.dart
+++ b/example/lib/inline_example.screen.dart
@@ -54,10 +54,13 @@ class _InlineExampleScreenState extends State {
decoration:
BoxDecoration(border: Border.all(color: Colors.blueAccent)),
child: InAppWebView(
+ //initialUrl: "https://www.youtube.com/embed/M7lc1UVf-VE?playsinline=1",
//initialUrl: "https://flutter.dev/",
initialFile: "assets/index.html",
initialHeaders: {},
initialOptions: {
+ //"mediaPlaybackRequiresUserGesture": false,
+ //"allowsInlineMediaPlayback": true,
//"useShouldOverrideUrlLoading": true,
//"useOnLoadResource": true
},
diff --git a/example/lib/webview_example.screen.dart b/example/lib/webview_example.screen.dart
index 9648be8ad..43dfbe011 100644
--- a/example/lib/webview_example.screen.dart
+++ b/example/lib/webview_example.screen.dart
@@ -86,10 +86,13 @@ class _WebviewExampleScreenState extends State {
return new Center(
child: new RaisedButton(
onPressed: () {
- widget.browser.open(url: "https://google.com", options: {
- "useShouldOverrideUrlLoading": true,
- "useOnLoadResource": true
- });
+ widget.browser.open(
+ url: "https://google.com",
+ options: {
+ "useShouldOverrideUrlLoading": true,
+ "useOnLoadResource": true,
+ }
+ );
},
child: Text("Open Webview Browser")),
);
diff --git a/ios/Classes/FlutterWebViewController.swift b/ios/Classes/FlutterWebViewController.swift
index 2fc7eb928..c63154576 100644
--- a/ios/Classes/FlutterWebViewController.swift
+++ b/ios/Classes/FlutterWebViewController.swift
@@ -19,10 +19,6 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView {
super.init()
self.registrar = registrar
self.viewId = viewId
- webView = InAppWebView(frame: frame, configuration: WKWebViewConfiguration(), IABController: nil, IAWController: self)
- let channelName = "com.pichillilorenzo/flutter_inappwebview_" + String(viewId)
- self.channel = FlutterMethodChannel(name: channelName, binaryMessenger: registrar.messenger())
- self.channel?.setMethodCallHandler(self.handle)
let initialUrl = (args["initialUrl"] as? String)!
let initialFile = args["initialFile"] as? String
@@ -32,8 +28,14 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView {
let options = InAppWebViewOptions()
options.parse(options: initialOptions)
- webView!.options = options
+ let preWebviewConfiguration = InAppWebView.preWKWebViewConfiguration(options: options)
+ webView = InAppWebView(frame: frame, configuration: preWebviewConfiguration, IABController: nil, IAWController: self)
+ let channelName = "com.pichillilorenzo/flutter_inappwebview_" + String(viewId)
+ self.channel = FlutterMethodChannel(name: channelName, binaryMessenger: registrar.messenger())
+ self.channel?.setMethodCallHandler(self.handle)
+
+ webView!.options = options
webView!.prepare()
if initialFile != nil {
diff --git a/ios/Classes/InAppBrowserWebViewController.swift b/ios/Classes/InAppBrowserWebViewController.swift
index 5cb4de3e4..a9f187267 100644
--- a/ios/Classes/InAppBrowserWebViewController.swift
+++ b/ios/Classes/InAppBrowserWebViewController.swift
@@ -72,7 +72,7 @@ class InAppWebView_IBWrapper: InAppWebView {
class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKUIDelegate, UITextFieldDelegate {
- @IBOutlet var webView: InAppWebView_IBWrapper!
+ @IBOutlet var containerWebView: UIView!
@IBOutlet var closeButton: UIButton!
@IBOutlet var reloadButton: UIBarButtonItem!
@IBOutlet var backButton: UIBarButtonItem!
@@ -85,9 +85,12 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
@IBOutlet var toolbarTop_BottomToWebViewTopConstraint: NSLayoutConstraint!
@IBOutlet var toolbarBottom_TopToWebViewBottomConstraint: NSLayoutConstraint!
+ @IBOutlet var containerWebView_BottomFullScreenConstraint: NSLayoutConstraint!
+ @IBOutlet var containerWebView_TopFullScreenConstraint: NSLayoutConstraint!
@IBOutlet var webView_BottomFullScreenConstraint: NSLayoutConstraint!
@IBOutlet var webView_TopFullScreenConstraint: NSLayoutConstraint!
+ var webView: InAppWebView!
weak var navigationDelegate: SwiftFlutterPlugin?
var initURL: URL?
var tmpWindow: UIWindow?
@@ -109,10 +112,21 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
}
override func viewWillAppear(_ animated: Bool) {
- self.webView.IABController = self
if !viewPrepared {
+ let preWebviewConfiguration = InAppWebView.preWKWebViewConfiguration(options: webViewOptions)
+ self.webView = InAppWebView(frame: .zero, configuration: preWebviewConfiguration, IABController: self, IAWController: nil)
+ self.containerWebView.addSubview(self.webView)
prepareConstraints()
prepareWebView()
+
+ if self.initData == nil {
+ loadUrl(url: self.initURL!, headers: self.initHeaders)
+ }
+ else {
+ webView.loadData(data: initData!, mimeType: initMimeType!, encoding: initEncoding!, baseUrl: initBaseUrl!)
+ }
+
+ navigationDelegate?.onBrowserCreated(uuid: uuid, webView: webView)
}
viewPrepared = true
super.viewWillAppear(animated)
@@ -122,10 +136,6 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
override func viewDidLoad() {
super.viewDidLoad()
-// webView.uiDelegate = self
-// webView.navigationDelegate = nil
-// webView.scrollView.delegate = self
-
urlField.delegate = self
urlField.text = self.initURL?.absoluteString
@@ -149,15 +159,6 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
spinner.hidesWhenStopped = true
spinner.isHidden = false
spinner.stopAnimating()
-
- if self.initData == nil {
- loadUrl(url: self.initURL!, headers: self.initHeaders)
- }
- else {
- webView.loadData(data: initData!, mimeType: initMimeType!, encoding: initEncoding!, baseUrl: initBaseUrl!)
- }
-
- navigationDelegate?.onBrowserCreated(uuid: uuid, webView: webView)
}
// Prevent crashes on closing windows
@@ -171,8 +172,19 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
}
func prepareConstraints () {
- webView_BottomFullScreenConstraint = NSLayoutConstraint(item: self.webView, attribute: NSLayoutAttribute.bottom, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.bottom, multiplier: 1, constant: 0)
- webView_TopFullScreenConstraint = NSLayoutConstraint(item: self.webView, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.top, multiplier: 1, constant: 0)
+ containerWebView_BottomFullScreenConstraint = NSLayoutConstraint(item: self.containerWebView, attribute: NSLayoutAttribute.bottom, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.bottom, multiplier: 1, constant: 0)
+ containerWebView_TopFullScreenConstraint = NSLayoutConstraint(item: self.containerWebView, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.top, multiplier: 1, constant: 0)
+
+ webView.translatesAutoresizingMaskIntoConstraints = false
+ let height = NSLayoutConstraint(item: webView, attribute: .height, relatedBy: .equal, toItem: containerWebView, attribute: .height, multiplier: 1, constant: 0)
+ let width = NSLayoutConstraint(item: webView, attribute: .width, relatedBy: .equal, toItem: containerWebView, attribute: .width, multiplier: 1, constant: 0)
+ let leftConstraint = NSLayoutConstraint(item: webView, attribute: .leftMargin, relatedBy: .equal, toItem: containerWebView, attribute: .leftMargin, multiplier: 1, constant: 0)
+ let rightConstraint = NSLayoutConstraint(item: webView, attribute: .rightMargin, relatedBy: .equal, toItem: containerWebView, attribute: .rightMargin, multiplier: 1, constant: 0)
+ let bottomContraint = NSLayoutConstraint(item: webView, attribute: .bottomMargin, relatedBy: .equal, toItem: containerWebView, attribute: .bottomMargin, multiplier: 1, constant: 0)
+ containerWebView.addConstraints([height, width, leftConstraint, rightConstraint, bottomContraint])
+
+ webView_BottomFullScreenConstraint = NSLayoutConstraint(item: self.webView, attribute: NSLayoutAttribute.bottom, relatedBy: NSLayoutRelation.equal, toItem: self.containerWebView, attribute: NSLayoutAttribute.bottom, multiplier: 1, constant: 0)
+ webView_TopFullScreenConstraint = NSLayoutConstraint(item: self.webView, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: self.containerWebView, attribute: NSLayoutAttribute.top, multiplier: 1, constant: 0)
}
func prepareWebView() {
@@ -194,6 +206,7 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
else {
self.toolbarTop.isHidden = true
self.toolbarTop_BottomToWebViewTopConstraint.isActive = false
+ self.containerWebView_TopFullScreenConstraint.isActive = true
self.webView_TopFullScreenConstraint.isActive = true
}
@@ -206,6 +219,7 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
else {
self.toolbarBottom.isHidden = true
self.toolbarBottom_TopToWebViewBottomConstraint.isActive = false
+ self.containerWebView_BottomFullScreenConstraint.isActive = true
self.webView_BottomFullScreenConstraint.isActive = true
}
@@ -378,6 +392,7 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
}
if newOptionsMap["toolbarTop"] != nil && browserOptions?.toolbarTop != newOptions.toolbarTop {
+ self.containerWebView_TopFullScreenConstraint.isActive = !newOptions.toolbarTop
self.webView_TopFullScreenConstraint.isActive = !newOptions.toolbarTop
self.toolbarTop.isHidden = !newOptions.toolbarTop
self.toolbarTop_BottomToWebViewTopConstraint.isActive = newOptions.toolbarTop
@@ -388,6 +403,7 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU
}
if newOptionsMap["toolbarBottom"] != nil && browserOptions?.toolbarBottom != newOptions.toolbarBottom {
+ self.containerWebView_BottomFullScreenConstraint.isActive = !newOptions.toolbarBottom
self.webView_BottomFullScreenConstraint.isActive = !newOptions.toolbarBottom
self.toolbarBottom.isHidden = !newOptions.toolbarBottom
self.toolbarBottom_TopToWebViewBottomConstraint.isActive = newOptions.toolbarBottom
diff --git a/ios/Classes/InAppWebView.swift b/ios/Classes/InAppWebView.swift
index d51c34b10..ee27192e8 100644
--- a/ios/Classes/InAppWebView.swift
+++ b/ios/Classes/InAppWebView.swift
@@ -112,13 +112,13 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
configuration.userContentController = WKUserContentController()
configuration.preferences = WKPreferences()
-
+
if (options?.transparentBackground)! {
isOpaque = false
backgroundColor = UIColor.clear
scrollView.backgroundColor = UIColor.clear
}
-
+
// prevent webView from bouncing
if (options?.disallowOverScroll)! {
if responds(to: #selector(getter: scrollView)) {
@@ -160,15 +160,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
configuration.userContentController.addUserScript(resourceObserverJSScript)
configuration.userContentController.add(self, name: "resourceLoaded")
- if #available(iOS 10.0, *) {
- configuration.mediaTypesRequiringUserActionForPlayback = ((options?.mediaPlaybackRequiresUserGesture)!) ? .all : []
- } else {
- // Fallback on earlier versions
- configuration.mediaPlaybackRequiresUserAction = (options?.mediaPlaybackRequiresUserGesture)!
- }
-
- configuration.allowsInlineMediaPlayback = (options?.allowsInlineMediaPlayback)!
-
//keyboardDisplayRequiresUserAction = browserOptions?.keyboardDisplayRequiresUserAction
configuration.suppressesIncrementalRendering = (options?.suppressesIncrementalRendering)!
@@ -181,8 +172,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
configuration.ignoresViewportScaleLimits = (options?.ignoresViewportScaleLimits)!
}
- configuration.allowsInlineMediaPlayback = (options?.allowsInlineMediaPlayback)!
-
if #available(iOS 9.0, *) {
configuration.allowsPictureInPictureMediaPlayback = (options?.allowsPictureInPictureMediaPlayback)!
}
@@ -202,6 +191,21 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
}
}
+ public static func preWKWebViewConfiguration(options: InAppWebViewOptions?) -> WKWebViewConfiguration {
+ let configuration = WKWebViewConfiguration()
+
+ if #available(iOS 10.0, *) {
+ configuration.mediaTypesRequiringUserActionForPlayback = ((options?.mediaPlaybackRequiresUserGesture)!) ? .all : []
+ } else {
+ // Fallback on earlier versions
+ configuration.mediaPlaybackRequiresUserAction = (options?.mediaPlaybackRequiresUserGesture)!
+ }
+
+ configuration.allowsInlineMediaPlayback = (options?.allowsInlineMediaPlayback)!
+
+ return configuration
+ }
+
override public func observeValue(forKeyPath keyPath: String?, of object: Any?,
change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if keyPath == "estimatedProgress" {
diff --git a/ios/Storyboards/WebView.storyboard b/ios/Storyboards/WebView.storyboard
index 97a7ef2bf..65e18bfbd 100644
--- a/ios/Storyboards/WebView.storyboard
+++ b/ios/Storyboards/WebView.storyboard
@@ -1,11 +1,11 @@
-
+
-
+
@@ -21,7 +21,7 @@
-
+
@@ -87,6 +87,7 @@
+
@@ -96,7 +97,6 @@
-
diff --git a/lib/flutter_inappbrowser.dart b/lib/flutter_inappbrowser.dart
index ed7793287..22ae60694 100644
--- a/lib/flutter_inappbrowser.dart
+++ b/lib/flutter_inappbrowser.dart
@@ -187,6 +187,7 @@ class InAppBrowser {
/// - __safeBrowsingEnabled__: Set to `true` if you want the Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. The default value is `true`.
/// - __progressBar__: Set to `false` to hide the progress bar at the bottom of the toolbar at the top. The default value is `true`.
/// - __textZoom__: Set text scaling of the WebView. The default value is `100`.
+ /// - __mixedContentMode__: Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. By default, apps that target `Build.VERSION_CODES.KITKAT` or below default to `MIXED_CONTENT_ALWAYS_ALLOW`. Apps targeting `Build.VERSION_CODES.LOLLIPOP` default to `MIXED_CONTENT_NEVER_ALLOW`. The preferred and most secure mode of operation for the WebView is `MIXED_CONTENT_NEVER_ALLOW` and use of `MIXED_CONTENT_ALWAYS_ALLOW` is strongly discouraged.
///
/// - **iOS** supports these additional options:
///
@@ -596,6 +597,7 @@ class InAppWebViewInitialData {
/// - __useWideViewPort__: Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is true and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. The default value is `true`.
/// - __safeBrowsingEnabled__: Set to `true` if you want the Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. The default value is `true`.
/// - __textZoom__: Set text scaling of the WebView. The default value is `100`.
+/// - __mixedContentMode__: Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. By default, apps that target `Build.VERSION_CODES.KITKAT` or below default to `MIXED_CONTENT_ALWAYS_ALLOW`. Apps targeting `Build.VERSION_CODES.LOLLIPOP` default to `MIXED_CONTENT_NEVER_ALLOW`. The preferred and most secure mode of operation for the WebView is `MIXED_CONTENT_NEVER_ALLOW` and use of `MIXED_CONTENT_ALWAYS_ALLOW` is strongly discouraged.
///
/// **iOS** supports these additional options:
///
@@ -1291,7 +1293,7 @@ class InAppWebViewController {
}
return WebHistory(historyList, currentIndex);
}
-
+ ///Dispose/Destroy the WebView.
Future _dispose() async {
await _channel.invokeMethod('dispose');
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 64f5c6a71..453078372 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: flutter_inappbrowser
description: A Flutter plugin that allows you to add an inline webview or open an in-app browser window (inspired by the popular cordova-plugin-inappbrowser).
-version: 1.2.0
+version: 1.2.1
author: Lorenzo Pichilli
homepage: https://github.com/pichillilorenzo/flutter_inappbrowser