diff options
author | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-26 16:23:56 +0000 |
---|---|---|
committer | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-26 16:23:56 +0000 |
commit | 29f51bbf25b7f262cc29e46a38676fd5b27220a8 (patch) | |
tree | 3426dbdbd67d62c4dd4ae1ec4fee9d651c8d5f04 /content/public/android | |
parent | 0b083cdfe51ed571d697f96ca5ba7756e9af5ed2 (diff) | |
download | chromium_src-29f51bbf25b7f262cc29e46a38676fd5b27220a8.zip chromium_src-29f51bbf25b7f262cc29e46a38676fd5b27220a8.tar.gz chromium_src-29f51bbf25b7f262cc29e46a38676fd5b27220a8.tar.bz2 |
Implement Android WebView BlockNetworkImages
This uses the WebCore ImagesEnabled setting, which is added to
ContentSettings. The setting also includes overriding
WebPermissionClient::allowImage, which here allows images with local
soucres to load as well.
Use a whitelist of local file schemes instead of blacklisting only
http(s).
BUG=
Review URL: https://chromiumcodereview.appspot.com/10920033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158809 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/public/android')
-rw-r--r-- | content/public/android/java/src/org/chromium/content/browser/ContentSettings.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentSettings.java b/content/public/android/java/src/org/chromium/content/browser/ContentSettings.java index 7ae55c7..f3b858b 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ContentSettings.java +++ b/content/public/android/java/src/org/chromium/content/browser/ContentSettings.java @@ -80,6 +80,7 @@ public class ContentSettings { private int mDefaultFontSize = 16; private int mDefaultFixedFontSize = 13; private boolean mLoadsImagesAutomatically = true; + private boolean mImagesEnabled = true; private boolean mJavaScriptEnabled = false; private boolean mAllowUniversalAccessFromFileURLs = false; private boolean mAllowFileAccessFromFileURLs = false; @@ -723,6 +724,8 @@ public class ContentSettings { /** * Tell the WebView to load image resources automatically. + * Note that setting this flag to false this does not block image loads + * from WebCore cache. * @param flag True if the WebView should load images automatically. */ public void setLoadsImagesAutomatically(boolean flag) { @@ -747,6 +750,34 @@ public class ContentSettings { } /** + * Sets whether images are enabled for this WebView. Setting this from + * false to true will reload the blocked images in place. + * Note that unlike {@link #setLoadsImagesAutomatically}, setting this + * flag to false this will block image loads from WebCore cache as well. + * The default is true. + * @param flag whether the WebView should enable images. + */ + public void setImagesEnabled(boolean flag) { + assert mCanModifySettings; + synchronized (mContentSettingsLock) { + if (mImagesEnabled != flag) { + mImagesEnabled = flag; + mEventHandler.syncSettingsLocked(); + } + } + } + + /** + * Gets whether images are enabled for this WebView. + * @return true if the WebView has images eanbled + */ + public boolean getImagesEnabled() { + synchronized (mContentSettingsLock) { + return mImagesEnabled; + } + } + + /** * Return true if JavaScript is enabled. <b>Note: The default is false.</b> * * @return True if JavaScript is enabled. |