WebView

2019-12-18  本文已影响0人  钦_79f7

WebView 内核 Chrome

Android 4.4 KitKat 版本开始讲WebView的实现从WebKit转为Chromium实现。

OS Version Chrome Version
4.4 30.0.0.0
4.4.3 33.0.0.0
L 36.0.0.0

备注:关于Vue 2.0 仅 Chrome 32 版本以上的才会正常支持。

Method

pauseTimers、onPause、resumeTimers、onResume

webView.getSettings().setDomStorageEnabled(true);

设置WebView开放LocalStorage的功能给H5做持久化存储

HTML5 Web Storage主要有:

作为 HTML5 标准的一部分,绝大多数的浏览器都是支持 localStorage 的,但是鉴于它的安全特性(任何人都能读取到它,尽管有相应的限制,将敏感数据存储在这里依然不是明智之举),Android 默认是关闭该功能的。

web storage和cookie的区别:

webView.getSettings().setMixedContentMode()

设置WebView支持加载混合资源的模式,API Call Required 21

    /**
     * Configures the WebView's behavior when a secure origin attempts to load a resource from an
     * insecure origin.
     *
     * By default, apps that target {@link android.os.Build.VERSION_CODES#KITKAT} or below default
     * to {@link #MIXED_CONTENT_ALWAYS_ALLOW}. Apps targeting
     * {@link android.os.Build.VERSION_CODES#LOLLIPOP} default to {@link #MIXED_CONTENT_NEVER_ALLOW}.
     *
     * The preferred and most secure mode of operation for the WebView is
     * {@link #MIXED_CONTENT_NEVER_ALLOW} and use of {@link #MIXED_CONTENT_ALWAYS_ALLOW} is
     * strongly discouraged.
     *
     * @param mode The mixed content mode to use. One of {@link #MIXED_CONTENT_NEVER_ALLOW},
     *     {@link #MIXED_CONTENT_ALWAYS_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}.
     */

根据文档注释可知,在4.4- 默认下是开启混合模式的。但是由于其存在安全隐患,在5.0+默认关闭了混合模式的加载,并且Google强烈不建议开启混合模式。即HTTPS路径下访问Http的资源。

参考

上一篇 下一篇

猜你喜欢

热点阅读