Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ContentSettings.java

Issue 10920033: Implement Android WebView BlockNetworkImages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update ContentSetting to new locking semantics. Add a test that does not require http server. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.os.Handler; 7 import android.os.Handler;
8 import android.os.Looper; 8 import android.os.Looper;
9 import android.os.Message; 9 import android.os.Message;
10 import android.webkit.WebSettings.PluginState; 10 import android.webkit.WebSettings.PluginState;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 private String mCursiveFontFamily = "cursive"; 73 private String mCursiveFontFamily = "cursive";
74 private String mFantasyFontFamily = "fantasy"; 74 private String mFantasyFontFamily = "fantasy";
75 // FIXME: Should be obtained from Android. Problem: it is hidden. 75 // FIXME: Should be obtained from Android. Problem: it is hidden.
76 private String mDefaultTextEncoding = "Latin-1"; 76 private String mDefaultTextEncoding = "Latin-1";
77 private String mUserAgent; 77 private String mUserAgent;
78 private int mMinimumFontSize = 8; 78 private int mMinimumFontSize = 8;
79 private int mMinimumLogicalFontSize = 8; 79 private int mMinimumLogicalFontSize = 8;
80 private int mDefaultFontSize = 16; 80 private int mDefaultFontSize = 16;
81 private int mDefaultFixedFontSize = 13; 81 private int mDefaultFixedFontSize = 13;
82 private boolean mLoadsImagesAutomatically = true; 82 private boolean mLoadsImagesAutomatically = true;
83 private boolean mImagesEnabled = true;
83 private boolean mJavaScriptEnabled = false; 84 private boolean mJavaScriptEnabled = false;
84 private boolean mAllowUniversalAccessFromFileURLs = false; 85 private boolean mAllowUniversalAccessFromFileURLs = false;
85 private boolean mAllowFileAccessFromFileURLs = false; 86 private boolean mAllowFileAccessFromFileURLs = false;
86 private boolean mJavaScriptCanOpenWindowsAutomatically = false; 87 private boolean mJavaScriptCanOpenWindowsAutomatically = false;
87 private PluginState mPluginState = PluginState.OFF; 88 private PluginState mPluginState = PluginState.OFF;
88 private boolean mDomStorageEnabled = false; 89 private boolean mDomStorageEnabled = false;
89 private boolean mAllowFileUrlAccess = true; 90 private boolean mAllowFileUrlAccess = true;
90 private boolean mAllowContentUrlAccess = true; 91 private boolean mAllowContentUrlAccess = true;
91 92
92 // Not accessed by the native side. 93 // Not accessed by the native side.
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 synchronized (mContentSettingsLock) { 717 synchronized (mContentSettingsLock) {
717 if (mAllowFileAccessFromFileURLs != flag) { 718 if (mAllowFileAccessFromFileURLs != flag) {
718 mAllowFileAccessFromFileURLs = flag; 719 mAllowFileAccessFromFileURLs = flag;
719 mEventHandler.syncSettingsLocked(); 720 mEventHandler.syncSettingsLocked();
720 } 721 }
721 } 722 }
722 } 723 }
723 724
724 /** 725 /**
725 * Tell the WebView to load image resources automatically. 726 * Tell the WebView to load image resources automatically.
727 * Note that this does not block image loads from WebCore cache.
mnaganov (inactive) 2012/09/25 09:55:53 ...that setting this flag to false does not block.
726 * @param flag True if the WebView should load images automatically. 728 * @param flag True if the WebView should load images automatically.
727 */ 729 */
728 public void setLoadsImagesAutomatically(boolean flag) { 730 public void setLoadsImagesAutomatically(boolean flag) {
729 assert mCanModifySettings; 731 assert mCanModifySettings;
730 synchronized (mContentSettingsLock) { 732 synchronized (mContentSettingsLock) {
731 if (mLoadsImagesAutomatically != flag) { 733 if (mLoadsImagesAutomatically != flag) {
732 mLoadsImagesAutomatically = flag; 734 mLoadsImagesAutomatically = flag;
733 mEventHandler.syncSettingsLocked(); 735 mEventHandler.syncSettingsLocked();
734 } 736 }
735 } 737 }
736 } 738 }
737 739
738 /** 740 /**
739 * Return true if the WebView will load image resources automatically. 741 * Return true if the WebView will load image resources automatically.
740 * The default is true. 742 * The default is true.
741 * @return True if the WebView loads images automatically. 743 * @return True if the WebView loads images automatically.
742 */ 744 */
743 public boolean getLoadsImagesAutomatically() { 745 public boolean getLoadsImagesAutomatically() {
744 synchronized (mContentSettingsLock) { 746 synchronized (mContentSettingsLock) {
745 return mLoadsImagesAutomatically; 747 return mLoadsImagesAutomatically;
746 } 748 }
747 } 749 }
748 750
749 /** 751 /**
752 * Sets whether images are enabled for this WebView. Setting this from
753 * false to true will reload the blocked images in place.
754 * Note that unlike LoadsImagesAutomatically, this will block image loads
mnaganov (inactive) 2012/09/25 09:55:53 LoadImagesAutomatically -> {@link #setLoadsImagesA
mnaganov (inactive) 2012/09/25 09:55:53 ...setting this flag to false will block...
755 * from WebCore cache as well.
mnaganov (inactive) 2012/09/25 09:55:53 Please add "The default is true."
756 * @param flag True if the WebView should enable images.
mnaganov (inactive) 2012/09/25 09:55:53 whether the WebView should enable images
757 */
758 public void setImagesEnabled(boolean flag) {
759 assert mCanModifySettings;
760 synchronized (mContentSettingsLock) {
761 if (mImagesEnabled != flag) {
762 mImagesEnabled = flag;
763 mEventHandler.syncSettingsLocked();
764 }
765 }
766 }
767
768 /**
769 * Gets whether images are enabled for this WebView.
770 * @return true if the WebView has images eanbled
771 */
772 public boolean getImagesEnabled() {
773 synchronized (mContentSettingsLock) {
774 return mImagesEnabled;
775 }
776 }
777
778 /**
750 * Return true if JavaScript is enabled. <b>Note: The default is false.</b> 779 * Return true if JavaScript is enabled. <b>Note: The default is false.</b>
751 * 780 *
752 * @return True if JavaScript is enabled. 781 * @return True if JavaScript is enabled.
753 */ 782 */
754 public boolean getJavaScriptEnabled() { 783 public boolean getJavaScriptEnabled() {
755 synchronized (mContentSettingsLock) { 784 synchronized (mContentSettingsLock) {
756 return mJavaScriptEnabled; 785 return mJavaScriptEnabled;
757 } 786 }
758 } 787 }
759 788
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 private static native void nativeDestroy(int nativeContentSettings); 997 private static native void nativeDestroy(int nativeContentSettings);
969 998
970 private static native String nativeGetDefaultUserAgent(); 999 private static native String nativeGetDefaultUserAgent();
971 1000
972 // Synchronize Java settings from native settings. 1001 // Synchronize Java settings from native settings.
973 private native void nativeSyncFromNative(int nativeContentSettings); 1002 private native void nativeSyncFromNative(int nativeContentSettings);
974 1003
975 // Synchronize native settings from Java settings. 1004 // Synchronize native settings from Java settings.
976 private native void nativeSyncToNative(int nativeContentSettings); 1005 private native void nativeSyncToNative(int nativeContentSettings);
977 } 1006 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698