OLD | NEW |
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 Loading... |
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 Loading... |
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 setting this flag to false this does not block image loads |
| 728 * from WebCore cache. |
726 * @param flag True if the WebView should load images automatically. | 729 * @param flag True if the WebView should load images automatically. |
727 */ | 730 */ |
728 public void setLoadsImagesAutomatically(boolean flag) { | 731 public void setLoadsImagesAutomatically(boolean flag) { |
729 assert mCanModifySettings; | 732 assert mCanModifySettings; |
730 synchronized (mContentSettingsLock) { | 733 synchronized (mContentSettingsLock) { |
731 if (mLoadsImagesAutomatically != flag) { | 734 if (mLoadsImagesAutomatically != flag) { |
732 mLoadsImagesAutomatically = flag; | 735 mLoadsImagesAutomatically = flag; |
733 mEventHandler.syncSettingsLocked(); | 736 mEventHandler.syncSettingsLocked(); |
734 } | 737 } |
735 } | 738 } |
736 } | 739 } |
737 | 740 |
738 /** | 741 /** |
739 * Return true if the WebView will load image resources automatically. | 742 * Return true if the WebView will load image resources automatically. |
740 * The default is true. | 743 * The default is true. |
741 * @return True if the WebView loads images automatically. | 744 * @return True if the WebView loads images automatically. |
742 */ | 745 */ |
743 public boolean getLoadsImagesAutomatically() { | 746 public boolean getLoadsImagesAutomatically() { |
744 synchronized (mContentSettingsLock) { | 747 synchronized (mContentSettingsLock) { |
745 return mLoadsImagesAutomatically; | 748 return mLoadsImagesAutomatically; |
746 } | 749 } |
747 } | 750 } |
748 | 751 |
749 /** | 752 /** |
| 753 * Sets whether images are enabled for this WebView. Setting this from |
| 754 * false to true will reload the blocked images in place. |
| 755 * Note that unlike {@link #setLoadsImagesAutomatically}, setting this |
| 756 * flag to false this will block image loads from WebCore cache as well. |
| 757 * The default is true. |
| 758 * @param flag whether the WebView should enable images. |
| 759 */ |
| 760 public void setImagesEnabled(boolean flag) { |
| 761 assert mCanModifySettings; |
| 762 synchronized (mContentSettingsLock) { |
| 763 if (mImagesEnabled != flag) { |
| 764 mImagesEnabled = flag; |
| 765 mEventHandler.syncSettingsLocked(); |
| 766 } |
| 767 } |
| 768 } |
| 769 |
| 770 /** |
| 771 * Gets whether images are enabled for this WebView. |
| 772 * @return true if the WebView has images eanbled |
| 773 */ |
| 774 public boolean getImagesEnabled() { |
| 775 synchronized (mContentSettingsLock) { |
| 776 return mImagesEnabled; |
| 777 } |
| 778 } |
| 779 |
| 780 /** |
750 * Return true if JavaScript is enabled. <b>Note: The default is false.</b> | 781 * Return true if JavaScript is enabled. <b>Note: The default is false.</b> |
751 * | 782 * |
752 * @return True if JavaScript is enabled. | 783 * @return True if JavaScript is enabled. |
753 */ | 784 */ |
754 public boolean getJavaScriptEnabled() { | 785 public boolean getJavaScriptEnabled() { |
755 synchronized (mContentSettingsLock) { | 786 synchronized (mContentSettingsLock) { |
756 return mJavaScriptEnabled; | 787 return mJavaScriptEnabled; |
757 } | 788 } |
758 } | 789 } |
759 | 790 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 private static native void nativeDestroy(int nativeContentSettings); | 999 private static native void nativeDestroy(int nativeContentSettings); |
969 | 1000 |
970 private static native String nativeGetDefaultUserAgent(); | 1001 private static native String nativeGetDefaultUserAgent(); |
971 | 1002 |
972 // Synchronize Java settings from native settings. | 1003 // Synchronize Java settings from native settings. |
973 private native void nativeSyncFromNative(int nativeContentSettings); | 1004 private native void nativeSyncFromNative(int nativeContentSettings); |
974 | 1005 |
975 // Synchronize native settings from Java settings. | 1006 // Synchronize native settings from Java settings. |
976 private native void nativeSyncToNative(int nativeContentSettings); | 1007 private native void nativeSyncToNative(int nativeContentSettings); |
977 } | 1008 } |
OLD | NEW |