Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new option to control the contentMode in Android platform #101

Merged
merged 1 commit into from
Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ else if (options.clearSessionCache)
if (options.transparentBackground) {
setBackgroundColor(Color.TRANSPARENT);
}

if (!options.mixedContentMode.isEmpty()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (options.mixedContentMode.equals("MIXED_CONTENT_COMPATIBILITY_MODE")) {
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
} else if (options.mixedContentMode.equals("MIXED_CONTENT_ALWAYS_ALLOW")) {
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
}
}
}

public void loadUrl(String url, MethodChannel.Result result) {
Expand Down Expand Up @@ -355,6 +365,16 @@ else if (newOptionsMap.get("clearSessionCache") != null && newOptions.clearSessi
}
}

if (newOptionsMap.get("mixedContentMode") != null && options.mixedContentMode != newOptions.mixedContentMode) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (newOptions.mixedContentMode.equals("MIXED_CONTENT_COMPATIBILITY_MODE")) {
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
} else if (newOptions.mixedContentMode.equals("MIXED_CONTENT_ALWAYS_ALLOW")) {
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
}
}

options = newOptions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +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";
}