[
https://issues.apache.org/jira/browse/CB-12780?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16004967#comment-16004967
]
Kerri Shotts commented on CB-12780:
-----------------------------------
Not saying whether or not this should be addressed in Cordova core, but you
might try creating a plugin that changes the setting. Plugins let you use
native code without the same concern you have when editing code in the
platforms/ directory (which could get overwritten), especially given that you
can save plugins to the config and restore them on prepare.
> Add option to setMixedContentMode on Android
> --------------------------------------------
>
> Key: CB-12780
> URL: https://issues.apache.org/jira/browse/CB-12780
> Project: Apache Cordova
> Issue Type: New Feature
> Components: cordova-android
> Affects Versions: 7.0.0
> Reporter: Mike M.
>
> We're currently developing an application that streams audio from a
> continuous stream over http. We have an existing web application served over
> https. The audio streams, which are built using HTML5 audio, are served in
> http only.
> On Android, the WebView won't load our audio stream because of a mixed
> content error.
> According to my research, this is because on Android, as of API level 20, the
> WebView gets a mixedContentMode of {{MIXED_CONTENT_NEVER_ALLOW}} by default
> (see the documentation
> [here|https://developer.android.com/reference/android/webkit/WebSettings.html#setMixedContentMode(int)].
> This is especially frustrating as it doesn't match [what modern browsers
> do|https://developers.google.com/web/fundamentals/security/prevent-mixed-content/fixing-mixed-content],
> which is to allow "passive" mixed content that doesn't interact with the
> page directly like audio/video streams. So in the end, the WebView doesn't
> behave like the browser, which breaks our application.
> When I change the API target level to 19, the resource gets loaded
> successfully. However, sticking with API level 19 isn't a long-term solution.
> As seen in [the
> documentation|https://developer.android.com/reference/android/webkit/WebSettings.html#setMixedContentMode(int)],
> there is a way to let Android treat mixed content like the browser, which
> involves setting the MixedContentMode WebSetting to
> {{MIXED_CONTENT_COMPATIBILITY_MODE}}. However, as I understand it (I'm new to
> Cordova), this would require me to add custom code to the generated android
> activity code, which is discouraged and which I would prefer not to do.
> It would be nice if cordova-android added a configuration setting for mixed
> content which would get translated into setting the MixedContentMode
> WebSetting. It could look something like:
> {code:xml}
> <platform name="android">
> <preference name="android-mixedContentMode"
> value="COMPATIBILITY_MODE" />
> </platform>
> {code}
> That would make the code more maintainable and expresses what we need
> concisely.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]