diff options
| author | Ben Murdoch <benm@google.com> | 2014-04-10 15:31:06 +0100 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2014-05-02 14:17:25 +0100 |
| commit | fe9fc3d1a34d879ded2b1cf2443600701e5c5fc5 (patch) | |
| tree | 86d06d881ffd031f5b7bad9c6f9f346e27e527e9 /core/java/android/webkit/WebSettings.java | |
| parent | 97f1b8572f9fba9c5bf771951fa24459e3bdb9c7 (diff) | |
Add API definition for WebSettings.allowMixedContent
Introduces an API for configuring how the WebView behaves with
regard to referencing insecure content from a secure origin.
By default, apps targeting <= KK will allow mixed content. New apps
will block all insecure content.
Bug: 13948531
Change-Id: Ie773ee144e223f78b6449da0a8564192dd9c1c5d
Diffstat (limited to 'core/java/android/webkit/WebSettings.java')
| -rw-r--r-- | core/java/android/webkit/WebSettings.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java index 98ef66e32350..7c32c5bcb6f9 100644 --- a/core/java/android/webkit/WebSettings.java +++ b/core/java/android/webkit/WebSettings.java @@ -171,6 +171,38 @@ public abstract class WebSettings { } /** + * Used with {@link #setMixedContentMode} + * + * In this mode, the WebView will allow a secure origin to load content from any other origin, + * even if that origin is insecure. This is the least secure mode of operation for the WebView, + * and where possible apps should not set this mode. + */ + public static final int MIXED_CONTENT_ALWAYS_ALLOW = 0; + + /** + * Used with {@link #setMixedContentMode} + * + * In this mode, the WebView will not allow a secure origin to load content from an insecure + * origin. This is the preferred and most secure mode of operation for the WebView and apps are + * strongly advised to use this mode. + */ + public static final int MIXED_CONTENT_NEVER_ALLOW = 1; + + /** + * Used with {@link #setMixedContentMode} + * + * In this mode, the WebView will attempt to be compatible with the approach of a modern web + * browser with regard to mixed content. Some insecure content may be allowed to be loaded by + * a secure origin and other types of content will be blocked. The types of content are allowed + * or blocked may change release to release and are not explicitly defined. + * + * This mode is intended to be used by apps that are not in control of the content that they + * render but desire to operate in a reasonably secure environment. For highest security, apps + * are recommended to use {@link #MIXED_CONTENT_NEVER_ALLOW}. + */ + public static final int MIXED_CONTENT_COMPATIBILITY_MODE = 2; + + /** * Hidden constructor to prevent clients from creating a new settings * instance or deriving the class. * @@ -1403,4 +1435,29 @@ public abstract class WebSettings { public int getCacheMode() { throw new MustOverrideException(); } + + /** + * 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#L} 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_NEVER_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}. + */ + public abstract void setMixedContentMode(int mode); + + /** + * Gets the current behavior of the WebView with regard to loading insecure content from a + * secure origin. + * @return The current setting, one of {@link #MIXED_CONTENT_NEVER_ALLOW}, + * {@link #MIXED_CONTENT_NEVER_ALLOW} or {@link #MIXED_CONTENT_COMPATIBILITY_MODE}. + */ + public abstract int getMixedContentMode(); } |
