This source file includes following definitions.
- JNINamespace
- bindUiThread
- runOnUiThreadBlockingAndLocked
- maybePostOnUiThread
- updateWebkitPreferencesLocked
- onGestureZoomSupportChanged
- nativeAwSettingsGone
- getDIPScaleLocked
- setDIPScale
- setZoomListener
- setWebContents
- setBlockNetworkLoads
- getBlockNetworkLoads
- setAllowFileAccess
- getAllowFileAccess
- setAllowContentAccess
- getAllowContentAccess
- setCacheMode
- getCacheMode
- setShouldFocusFirstNode
- setInitialPageScale
- getInitialPageScalePercentLocked
- setSpatialNavigationEnabled
- getSpatialNavigationLocked
- setEnableSupportedHardwareAcceleratedFeatures
- getEnableSupportedHardwareAcceleratedFeaturesLocked
- shouldFocusFirstNode
- setGeolocationEnabled
- getGeolocationEnabled
- setSaveFormData
- getSaveFormData
- getSaveFormDataLocked
- getDefaultUserAgent
- setUserAgentString
- getUserAgentString
- getUserAgentLocked
- setLoadWithOverviewMode
- getLoadWithOverviewMode
- getLoadWithOverviewModeLocked
- setTextZoom
- getTextZoom
- getTextSizePercentLocked
- setStandardFontFamily
- getStandardFontFamily
- getStandardFontFamilyLocked
- setFixedFontFamily
- getFixedFontFamily
- getFixedFontFamilyLocked
- setSansSerifFontFamily
- getSansSerifFontFamily
- getSansSerifFontFamilyLocked
- setSerifFontFamily
- getSerifFontFamily
- getSerifFontFamilyLocked
- setCursiveFontFamily
- getCursiveFontFamily
- getCursiveFontFamilyLocked
- setFantasyFontFamily
- getFantasyFontFamily
- getFantasyFontFamilyLocked
- setMinimumFontSize
- getMinimumFontSize
- getMinimumFontSizeLocked
- setMinimumLogicalFontSize
- getMinimumLogicalFontSize
- getMinimumLogicalFontSizeLocked
- setDefaultFontSize
- getDefaultFontSize
- getDefaultFontSizeLocked
- setDefaultFixedFontSize
- getDefaultFixedFontSize
- getDefaultFixedFontSizeLocked
- setJavaScriptEnabled
- setAllowUniversalAccessFromFileURLs
- setAllowFileAccessFromFileURLs
- setLoadsImagesAutomatically
- getLoadsImagesAutomatically
- getLoadsImagesAutomaticallyLocked
- setImagesEnabled
- getImagesEnabled
- getImagesEnabledLocked
- getJavaScriptEnabled
- getJavaScriptEnabledLocked
- getAllowUniversalAccessFromFileURLs
- getAllowUniversalAccessFromFileURLsLocked
- getAllowFileAccessFromFileURLs
- getAllowFileAccessFromFileURLsLocked
- setPluginsEnabled
- setPluginState
- getPluginsEnabled
- getPluginsDisabledLocked
- getPluginState
- setJavaScriptCanOpenWindowsAutomatically
- getJavaScriptCanOpenWindowsAutomatically
- getJavaScriptCanOpenWindowsAutomaticallyLocked
- setLayoutAlgorithm
- getLayoutAlgorithm
- getTextAutosizingEnabledLocked
- setSupportMultipleWindows
- supportMultipleWindows
- getSupportMultipleWindowsLocked
- getSupportLegacyQuirksLocked
- setUseWideViewPort
- getUseWideViewPort
- getUseWideViewportLocked
- getPasswordEchoEnabledLocked
- setAppCacheEnabled
- setAppCachePath
- getAppCacheEnabledLocked
- setDomStorageEnabled
- getDomStorageEnabled
- getDomStorageEnabledLocked
- setDatabaseEnabled
- getDatabaseEnabled
- getDatabaseEnabledLocked
- setDefaultTextEncodingName
- getDefaultTextEncodingName
- getDefaultTextEncodingLocked
- setMediaPlaybackRequiresUserGesture
- getMediaPlaybackRequiresUserGesture
- getMediaPlaybackRequiresUserGestureLocked
- setDefaultVideoPosterURL
- getDefaultVideoPosterURL
- getDefaultVideoPosterURLLocked
- onGestureZoomSupportChanged
- setSupportZoom
- supportZoom
- setBuiltInZoomControls
- getBuiltInZoomControls
- setDisplayZoomControls
- getDisplayZoomControls
- supportsDoubleTapZoomLocked
- supportsMultiTouchZoomLocked
- supportsMultiTouchZoom
- shouldDisplayZoomControls
- clipFontSize
- updateEverything
- populateWebPreferences
- updateWebkitPreferencesOnUiThreadLocked
- nativeInit
- nativeDestroy
- nativePopulateWebPreferencesLocked
- nativeResetScrollAndScaleState
- nativeUpdateEverythingLocked
- nativeUpdateInitialPageScaleLocked
- nativeUpdateUserAgentLocked
- nativeUpdateWebkitPreferencesLocked
- nativeGetDefaultUserAgent
- nativeUpdateFormDataPreferencesLocked
package org.chromium.android_webview;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.Message;
import android.os.Process;
import android.provider.Settings;
import android.util.Log;
import android.webkit.WebSettings;
import android.webkit.WebSettings.PluginState;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.base.ThreadUtils;
@JNINamespace("android_webview")
public class AwSettings {
public enum LayoutAlgorithm {
NORMAL,
SINGLE_COLUMN,
NARROW_COLUMNS,
TEXT_AUTOSIZING,
}
private static final String TAG = "AwSettings";
private final boolean mHasInternetPermission;
private ZoomSupportChangeListener mZoomChangeListener;
private double mDIPScale = 1.0;
private final Object mAwSettingsLock = new Object();
private LayoutAlgorithm mLayoutAlgorithm = LayoutAlgorithm.NARROW_COLUMNS;
private int mTextSizePercent = 100;
private String mStandardFontFamily = "sans-serif";
private String mFixedFontFamily = "monospace";
private String mSansSerifFontFamily = "sans-serif";
private String mSerifFontFamily = "serif";
private String mCursiveFontFamily = "cursive";
private String mFantasyFontFamily = "fantasy";
private String mDefaultTextEncoding;
private String mUserAgent;
private int mMinimumFontSize = 8;
private int mMinimumLogicalFontSize = 8;
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;
private boolean mJavaScriptCanOpenWindowsAutomatically = false;
private boolean mSupportMultipleWindows = false;
private PluginState mPluginState = PluginState.OFF;
private boolean mAppCacheEnabled = false;
private boolean mDomStorageEnabled = false;
private boolean mDatabaseEnabled = false;
private boolean mUseWideViewport = false;
private boolean mLoadWithOverviewMode = false;
private boolean mMediaPlaybackRequiresUserGesture = true;
private String mDefaultVideoPosterURL;
private float mInitialPageScalePercent = 0;
private boolean mSpatialNavigationEnabled;
private boolean mEnableSupportedHardwareAcceleratedFeatures = false;
private final boolean mSupportLegacyQuirks;
private final boolean mPasswordEchoEnabled;
private boolean mBlockNetworkLoads;
private boolean mAllowContentUrlAccess = true;
private boolean mAllowFileUrlAccess = true;
private int mCacheMode = WebSettings.LOAD_DEFAULT;
private boolean mShouldFocusFirstNode = true;
private boolean mGeolocationEnabled = true;
private boolean mAutoCompleteEnabled = true;
private boolean mSupportZoom = true;
private boolean mBuiltInZoomControls = false;
private boolean mDisplayZoomControls = true;
static class LazyDefaultUserAgent{
private static final String sInstance = nativeGetDefaultUserAgent();
}
private static final Object sGlobalContentSettingsLock = new Object();
private static boolean sAppCachePathIsSet = false;
private long mNativeAwSettings = 0;
private final EventHandler mEventHandler;
private static final int MINIMUM_FONT_SIZE = 1;
private static final int MAXIMUM_FONT_SIZE = 72;
private class EventHandler {
private static final int RUN_RUNNABLE_BLOCKING = 0;
private Handler mHandler;
private boolean mSynchronizationPending = false;
EventHandler() {
}
void bindUiThread() {
if (mHandler != null) return;
mHandler = new Handler(ThreadUtils.getUiThreadLooper()) {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case RUN_RUNNABLE_BLOCKING:
synchronized (mAwSettingsLock) {
if (mNativeAwSettings != 0) {
((Runnable)msg.obj).run();
}
mSynchronizationPending = false;
mAwSettingsLock.notifyAll();
}
break;
}
}
};
}
void runOnUiThreadBlockingAndLocked(Runnable r) {
assert Thread.holdsLock(mAwSettingsLock);
if (mHandler == null) return;
if (ThreadUtils.runningOnUiThread()) {
r.run();
} else {
assert !mSynchronizationPending;
mSynchronizationPending = true;
mHandler.sendMessage(Message.obtain(null, RUN_RUNNABLE_BLOCKING, r));
try {
while (mSynchronizationPending) {
mAwSettingsLock.wait();
}
} catch (InterruptedException e) {
Log.e(TAG, "Interrupted waiting a Runnable to complete", e);
mSynchronizationPending = false;
}
}
}
void maybePostOnUiThread(Runnable r) {
if (mHandler != null) {
mHandler.post(r);
}
}
void updateWebkitPreferencesLocked() {
runOnUiThreadBlockingAndLocked(new Runnable() {
@Override
public void run() {
updateWebkitPreferencesOnUiThreadLocked();
}
});
}
}
interface ZoomSupportChangeListener {
public void onGestureZoomSupportChanged(
boolean supportsDoubleTapZoom, boolean supportsMultiTouchZoom);
}
public AwSettings(Context context,
boolean isAccessFromFileURLsGrantedByDefault,
boolean supportsLegacyQuirks) {
boolean hasInternetPermission = context.checkPermission(
android.Manifest.permission.INTERNET,
Process.myPid(),
Process.myUid()) == PackageManager.PERMISSION_GRANTED;
synchronized (mAwSettingsLock) {
mHasInternetPermission = hasInternetPermission;
mBlockNetworkLoads = !hasInternetPermission;
mEventHandler = new EventHandler();
if (isAccessFromFileURLsGrantedByDefault) {
mAllowUniversalAccessFromFileURLs = true;
mAllowFileAccessFromFileURLs = true;
}
mDefaultTextEncoding = AwResource.getDefaultTextEncoding();
mUserAgent = LazyDefaultUserAgent.sInstance;
mSpatialNavigationEnabled = !context.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_TOUCHSCREEN);
mPasswordEchoEnabled = Settings.System.getInt(context.getContentResolver(),
Settings.System.TEXT_SHOW_PASSWORD, 1) == 1;
mTextSizePercent *= context.getResources().getConfiguration().fontScale;
mSupportLegacyQuirks = supportsLegacyQuirks;
}
}
@CalledByNative
private void nativeAwSettingsGone(long nativeAwSettings) {
assert mNativeAwSettings != 0 && mNativeAwSettings == nativeAwSettings;
mNativeAwSettings = 0;
}
@CalledByNative
private double getDIPScaleLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mDIPScale;
}
void setDIPScale(double dipScale) {
synchronized (mAwSettingsLock) {
mDIPScale = dipScale;
}
}
void setZoomListener(ZoomSupportChangeListener zoomChangeListener) {
synchronized (mAwSettingsLock) {
mZoomChangeListener = zoomChangeListener;
}
}
void setWebContents(long nativeWebContents) {
synchronized (mAwSettingsLock) {
if (mNativeAwSettings != 0) {
nativeDestroy(mNativeAwSettings);
assert mNativeAwSettings == 0;
}
if (nativeWebContents != 0) {
mEventHandler.bindUiThread();
mNativeAwSettings = nativeInit(nativeWebContents);
nativeUpdateEverythingLocked(mNativeAwSettings);
onGestureZoomSupportChanged(
supportsDoubleTapZoomLocked(), supportsMultiTouchZoomLocked());
}
}
}
public void setBlockNetworkLoads(boolean flag) {
synchronized (mAwSettingsLock) {
if (!flag && !mHasInternetPermission) {
throw new SecurityException("Permission denied - " +
"application missing INTERNET permission");
}
mBlockNetworkLoads = flag;
}
}
public boolean getBlockNetworkLoads() {
synchronized (mAwSettingsLock) {
return mBlockNetworkLoads;
}
}
public void setAllowFileAccess(boolean allow) {
synchronized (mAwSettingsLock) {
if (mAllowFileUrlAccess != allow) {
mAllowFileUrlAccess = allow;
}
}
}
public boolean getAllowFileAccess() {
synchronized (mAwSettingsLock) {
return mAllowFileUrlAccess;
}
}
public void setAllowContentAccess(boolean allow) {
synchronized (mAwSettingsLock) {
if (mAllowContentUrlAccess != allow) {
mAllowContentUrlAccess = allow;
}
}
}
public boolean getAllowContentAccess() {
synchronized (mAwSettingsLock) {
return mAllowContentUrlAccess;
}
}
public void setCacheMode(int mode) {
synchronized (mAwSettingsLock) {
if (mCacheMode != mode) {
mCacheMode = mode;
}
}
}
public int getCacheMode() {
synchronized (mAwSettingsLock) {
return mCacheMode;
}
}
public void setShouldFocusFirstNode(boolean flag) {
synchronized (mAwSettingsLock) {
mShouldFocusFirstNode = flag;
}
}
public void setInitialPageScale(final float scaleInPercent) {
synchronized (mAwSettingsLock) {
if (mInitialPageScalePercent != scaleInPercent) {
mInitialPageScalePercent = scaleInPercent;
mEventHandler.runOnUiThreadBlockingAndLocked(new Runnable() {
@Override
public void run() {
nativeUpdateInitialPageScaleLocked(mNativeAwSettings);
}
});
}
}
}
@CalledByNative
private float getInitialPageScalePercentLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mInitialPageScalePercent;
}
void setSpatialNavigationEnabled(boolean enable) {
synchronized (mAwSettingsLock) {
if (mSpatialNavigationEnabled != enable) {
mSpatialNavigationEnabled = enable;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
@CalledByNative
private boolean getSpatialNavigationLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mSpatialNavigationEnabled;
}
void setEnableSupportedHardwareAcceleratedFeatures(boolean enable) {
synchronized (mAwSettingsLock) {
if (mEnableSupportedHardwareAcceleratedFeatures != enable) {
mEnableSupportedHardwareAcceleratedFeatures = enable;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
@CalledByNative
private boolean getEnableSupportedHardwareAcceleratedFeaturesLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mEnableSupportedHardwareAcceleratedFeatures;
}
public boolean shouldFocusFirstNode() {
synchronized (mAwSettingsLock) {
return mShouldFocusFirstNode;
}
}
public void setGeolocationEnabled(boolean flag) {
synchronized (mAwSettingsLock) {
if (mGeolocationEnabled != flag) {
mGeolocationEnabled = flag;
}
}
}
boolean getGeolocationEnabled() {
synchronized (mAwSettingsLock) {
return mGeolocationEnabled;
}
}
public void setSaveFormData(final boolean enable) {
synchronized (mAwSettingsLock) {
if (mAutoCompleteEnabled != enable) {
mAutoCompleteEnabled = enable;
mEventHandler.runOnUiThreadBlockingAndLocked(new Runnable() {
@Override
public void run() {
nativeUpdateFormDataPreferencesLocked(mNativeAwSettings);
}
});
}
}
}
public boolean getSaveFormData() {
synchronized (mAwSettingsLock) {
return getSaveFormDataLocked();
}
}
@CalledByNative
private boolean getSaveFormDataLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mAutoCompleteEnabled;
}
public static String getDefaultUserAgent() {
return LazyDefaultUserAgent.sInstance;
}
public void setUserAgentString(String ua) {
synchronized (mAwSettingsLock) {
final String oldUserAgent = mUserAgent;
if (ua == null || ua.length() == 0) {
mUserAgent = LazyDefaultUserAgent.sInstance;
} else {
mUserAgent = ua;
}
if (!oldUserAgent.equals(mUserAgent)) {
mEventHandler.runOnUiThreadBlockingAndLocked(new Runnable() {
@Override
public void run() {
nativeUpdateUserAgentLocked(mNativeAwSettings);
}
});
}
}
}
public String getUserAgentString() {
synchronized (mAwSettingsLock) {
return mUserAgent;
}
}
@CalledByNative
private String getUserAgentLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mUserAgent;
}
public void setLoadWithOverviewMode(boolean overview) {
synchronized (mAwSettingsLock) {
if (mLoadWithOverviewMode != overview) {
mLoadWithOverviewMode = overview;
mEventHandler.runOnUiThreadBlockingAndLocked(new Runnable() {
@Override
public void run() {
updateWebkitPreferencesOnUiThreadLocked();
nativeResetScrollAndScaleState(mNativeAwSettings);
}
});
}
}
}
public boolean getLoadWithOverviewMode() {
synchronized (mAwSettingsLock) {
return mLoadWithOverviewMode;
}
}
@CalledByNative
private boolean getLoadWithOverviewModeLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mLoadWithOverviewMode;
}
public void setTextZoom(final int textZoom) {
synchronized (mAwSettingsLock) {
if (mTextSizePercent != textZoom) {
mTextSizePercent = textZoom;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public int getTextZoom() {
synchronized (mAwSettingsLock) {
return mTextSizePercent;
}
}
@CalledByNative
private int getTextSizePercentLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mTextSizePercent;
}
public void setStandardFontFamily(String font) {
synchronized (mAwSettingsLock) {
if (font != null && !mStandardFontFamily.equals(font)) {
mStandardFontFamily = font;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public String getStandardFontFamily() {
synchronized (mAwSettingsLock) {
return mStandardFontFamily;
}
}
@CalledByNative
private String getStandardFontFamilyLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mStandardFontFamily;
}
public void setFixedFontFamily(String font) {
synchronized (mAwSettingsLock) {
if (font != null && !mFixedFontFamily.equals(font)) {
mFixedFontFamily = font;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public String getFixedFontFamily() {
synchronized (mAwSettingsLock) {
return mFixedFontFamily;
}
}
@CalledByNative
private String getFixedFontFamilyLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mFixedFontFamily;
}
public void setSansSerifFontFamily(String font) {
synchronized (mAwSettingsLock) {
if (font != null && !mSansSerifFontFamily.equals(font)) {
mSansSerifFontFamily = font;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public String getSansSerifFontFamily() {
synchronized (mAwSettingsLock) {
return mSansSerifFontFamily;
}
}
@CalledByNative
private String getSansSerifFontFamilyLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mSansSerifFontFamily;
}
public void setSerifFontFamily(String font) {
synchronized (mAwSettingsLock) {
if (font != null && !mSerifFontFamily.equals(font)) {
mSerifFontFamily = font;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public String getSerifFontFamily() {
synchronized (mAwSettingsLock) {
return mSerifFontFamily;
}
}
@CalledByNative
private String getSerifFontFamilyLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mSerifFontFamily;
}
public void setCursiveFontFamily(String font) {
synchronized (mAwSettingsLock) {
if (font != null && !mCursiveFontFamily.equals(font)) {
mCursiveFontFamily = font;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public String getCursiveFontFamily() {
synchronized (mAwSettingsLock) {
return mCursiveFontFamily;
}
}
@CalledByNative
private String getCursiveFontFamilyLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mCursiveFontFamily;
}
public void setFantasyFontFamily(String font) {
synchronized (mAwSettingsLock) {
if (font != null && !mFantasyFontFamily.equals(font)) {
mFantasyFontFamily = font;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public String getFantasyFontFamily() {
synchronized (mAwSettingsLock) {
return mFantasyFontFamily;
}
}
@CalledByNative
private String getFantasyFontFamilyLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mFantasyFontFamily;
}
public void setMinimumFontSize(int size) {
synchronized (mAwSettingsLock) {
size = clipFontSize(size);
if (mMinimumFontSize != size) {
mMinimumFontSize = size;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public int getMinimumFontSize() {
synchronized (mAwSettingsLock) {
return mMinimumFontSize;
}
}
@CalledByNative
private int getMinimumFontSizeLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mMinimumFontSize;
}
public void setMinimumLogicalFontSize(int size) {
synchronized (mAwSettingsLock) {
size = clipFontSize(size);
if (mMinimumLogicalFontSize != size) {
mMinimumLogicalFontSize = size;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public int getMinimumLogicalFontSize() {
synchronized (mAwSettingsLock) {
return mMinimumLogicalFontSize;
}
}
@CalledByNative
private int getMinimumLogicalFontSizeLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mMinimumLogicalFontSize;
}
public void setDefaultFontSize(int size) {
synchronized (mAwSettingsLock) {
size = clipFontSize(size);
if (mDefaultFontSize != size) {
mDefaultFontSize = size;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public int getDefaultFontSize() {
synchronized (mAwSettingsLock) {
return mDefaultFontSize;
}
}
@CalledByNative
private int getDefaultFontSizeLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mDefaultFontSize;
}
public void setDefaultFixedFontSize(int size) {
synchronized (mAwSettingsLock) {
size = clipFontSize(size);
if (mDefaultFixedFontSize != size) {
mDefaultFixedFontSize = size;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public int getDefaultFixedFontSize() {
synchronized (mAwSettingsLock) {
return mDefaultFixedFontSize;
}
}
@CalledByNative
private int getDefaultFixedFontSizeLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mDefaultFixedFontSize;
}
public void setJavaScriptEnabled(boolean flag) {
synchronized (mAwSettingsLock) {
if (mJavaScriptEnabled != flag) {
mJavaScriptEnabled = flag;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public void setAllowUniversalAccessFromFileURLs(boolean flag) {
synchronized (mAwSettingsLock) {
if (mAllowUniversalAccessFromFileURLs != flag) {
mAllowUniversalAccessFromFileURLs = flag;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public void setAllowFileAccessFromFileURLs(boolean flag) {
synchronized (mAwSettingsLock) {
if (mAllowFileAccessFromFileURLs != flag) {
mAllowFileAccessFromFileURLs = flag;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public void setLoadsImagesAutomatically(boolean flag) {
synchronized (mAwSettingsLock) {
if (mLoadsImagesAutomatically != flag) {
mLoadsImagesAutomatically = flag;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public boolean getLoadsImagesAutomatically() {
synchronized (mAwSettingsLock) {
return mLoadsImagesAutomatically;
}
}
@CalledByNative
private boolean getLoadsImagesAutomaticallyLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mLoadsImagesAutomatically;
}
public void setImagesEnabled(boolean flag) {
synchronized (mAwSettingsLock) {
if (mImagesEnabled != flag) {
mImagesEnabled = flag;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public boolean getImagesEnabled() {
synchronized (mAwSettingsLock) {
return mImagesEnabled;
}
}
@CalledByNative
private boolean getImagesEnabledLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mImagesEnabled;
}
public boolean getJavaScriptEnabled() {
synchronized (mAwSettingsLock) {
return mJavaScriptEnabled;
}
}
@CalledByNative
private boolean getJavaScriptEnabledLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mJavaScriptEnabled;
}
public boolean getAllowUniversalAccessFromFileURLs() {
synchronized (mAwSettingsLock) {
return mAllowUniversalAccessFromFileURLs;
}
}
@CalledByNative
private boolean getAllowUniversalAccessFromFileURLsLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mAllowUniversalAccessFromFileURLs;
}
public boolean getAllowFileAccessFromFileURLs() {
synchronized (mAwSettingsLock) {
return mAllowFileAccessFromFileURLs;
}
}
@CalledByNative
private boolean getAllowFileAccessFromFileURLsLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mAllowFileAccessFromFileURLs;
}
public void setPluginsEnabled(boolean flag) {
setPluginState(flag ? PluginState.ON : PluginState.OFF);
}
public void setPluginState(PluginState state) {
synchronized (mAwSettingsLock) {
if (mPluginState != state) {
mPluginState = state;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public boolean getPluginsEnabled() {
synchronized (mAwSettingsLock) {
return mPluginState == PluginState.ON;
}
}
@CalledByNative
private boolean getPluginsDisabledLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mPluginState == PluginState.OFF;
}
public PluginState getPluginState() {
synchronized (mAwSettingsLock) {
return mPluginState;
}
}
public void setJavaScriptCanOpenWindowsAutomatically(boolean flag) {
synchronized (mAwSettingsLock) {
if (mJavaScriptCanOpenWindowsAutomatically != flag) {
mJavaScriptCanOpenWindowsAutomatically = flag;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public boolean getJavaScriptCanOpenWindowsAutomatically() {
synchronized (mAwSettingsLock) {
return mJavaScriptCanOpenWindowsAutomatically;
}
}
@CalledByNative
private boolean getJavaScriptCanOpenWindowsAutomaticallyLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mJavaScriptCanOpenWindowsAutomatically;
}
public void setLayoutAlgorithm(LayoutAlgorithm l) {
synchronized (mAwSettingsLock) {
if (mLayoutAlgorithm != l) {
mLayoutAlgorithm = l;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public LayoutAlgorithm getLayoutAlgorithm() {
synchronized (mAwSettingsLock) {
return mLayoutAlgorithm;
}
}
@CalledByNative
private boolean getTextAutosizingEnabledLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mLayoutAlgorithm == LayoutAlgorithm.TEXT_AUTOSIZING;
}
public void setSupportMultipleWindows(boolean support) {
synchronized (mAwSettingsLock) {
if (mSupportMultipleWindows != support) {
mSupportMultipleWindows = support;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public boolean supportMultipleWindows() {
synchronized (mAwSettingsLock) {
return mSupportMultipleWindows;
}
}
@CalledByNative
private boolean getSupportMultipleWindowsLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mSupportMultipleWindows;
}
@CalledByNative
private boolean getSupportLegacyQuirksLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mSupportLegacyQuirks;
}
public void setUseWideViewPort(boolean use) {
synchronized (mAwSettingsLock) {
if (mUseWideViewport != use) {
mUseWideViewport = use;
onGestureZoomSupportChanged(
supportsDoubleTapZoomLocked(), supportsMultiTouchZoomLocked());
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public boolean getUseWideViewPort() {
synchronized (mAwSettingsLock) {
return mUseWideViewport;
}
}
@CalledByNative
private boolean getUseWideViewportLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mUseWideViewport;
}
@CalledByNative
private boolean getPasswordEchoEnabledLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mPasswordEchoEnabled;
}
public void setAppCacheEnabled(boolean flag) {
synchronized (mAwSettingsLock) {
if (mAppCacheEnabled != flag) {
mAppCacheEnabled = flag;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public void setAppCachePath(String path) {
boolean needToSync = false;
synchronized (sGlobalContentSettingsLock) {
if (!sAppCachePathIsSet && path != null && !path.isEmpty()) {
sAppCachePathIsSet = true;
needToSync = true;
}
}
if (needToSync) {
synchronized (mAwSettingsLock) {
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
@CalledByNative
private boolean getAppCacheEnabledLocked() {
assert Thread.holdsLock(mAwSettingsLock);
if (!mAppCacheEnabled) {
return false;
}
synchronized (sGlobalContentSettingsLock) {
return sAppCachePathIsSet;
}
}
public void setDomStorageEnabled(boolean flag) {
synchronized (mAwSettingsLock) {
if (mDomStorageEnabled != flag) {
mDomStorageEnabled = flag;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public boolean getDomStorageEnabled() {
synchronized (mAwSettingsLock) {
return mDomStorageEnabled;
}
}
@CalledByNative
private boolean getDomStorageEnabledLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mDomStorageEnabled;
}
public void setDatabaseEnabled(boolean flag) {
synchronized (mAwSettingsLock) {
if (mDatabaseEnabled != flag) {
mDatabaseEnabled = flag;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public boolean getDatabaseEnabled() {
synchronized (mAwSettingsLock) {
return mDatabaseEnabled;
}
}
@CalledByNative
private boolean getDatabaseEnabledLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mDatabaseEnabled;
}
public void setDefaultTextEncodingName(String encoding) {
synchronized (mAwSettingsLock) {
if (encoding != null && !mDefaultTextEncoding.equals(encoding)) {
mDefaultTextEncoding = encoding;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public String getDefaultTextEncodingName() {
synchronized (mAwSettingsLock) {
return mDefaultTextEncoding;
}
}
@CalledByNative
private String getDefaultTextEncodingLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mDefaultTextEncoding;
}
public void setMediaPlaybackRequiresUserGesture(boolean require) {
synchronized (mAwSettingsLock) {
if (mMediaPlaybackRequiresUserGesture != require) {
mMediaPlaybackRequiresUserGesture = require;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public boolean getMediaPlaybackRequiresUserGesture() {
synchronized (mAwSettingsLock) {
return mMediaPlaybackRequiresUserGesture;
}
}
@CalledByNative
private boolean getMediaPlaybackRequiresUserGestureLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mMediaPlaybackRequiresUserGesture;
}
public void setDefaultVideoPosterURL(String url) {
synchronized (mAwSettingsLock) {
if (mDefaultVideoPosterURL != null && !mDefaultVideoPosterURL.equals(url) ||
mDefaultVideoPosterURL == null && url != null) {
mDefaultVideoPosterURL = url;
mEventHandler.updateWebkitPreferencesLocked();
}
}
}
public String getDefaultVideoPosterURL() {
synchronized (mAwSettingsLock) {
return mDefaultVideoPosterURL;
}
}
@CalledByNative
private String getDefaultVideoPosterURLLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mDefaultVideoPosterURL;
}
private void onGestureZoomSupportChanged(
final boolean supportsDoubleTapZoom, final boolean supportsMultiTouchZoom) {
mEventHandler.maybePostOnUiThread(new Runnable() {
@Override
public void run() {
synchronized (mAwSettingsLock) {
if (mZoomChangeListener != null) {
mZoomChangeListener.onGestureZoomSupportChanged(
supportsDoubleTapZoom, supportsMultiTouchZoom);
}
}
}
});
}
public void setSupportZoom(boolean support) {
synchronized (mAwSettingsLock) {
if (mSupportZoom != support) {
mSupportZoom = support;
onGestureZoomSupportChanged(
supportsDoubleTapZoomLocked(), supportsMultiTouchZoomLocked());
}
}
}
public boolean supportZoom() {
synchronized (mAwSettingsLock) {
return mSupportZoom;
}
}
public void setBuiltInZoomControls(boolean enabled) {
synchronized (mAwSettingsLock) {
if (mBuiltInZoomControls != enabled) {
mBuiltInZoomControls = enabled;
onGestureZoomSupportChanged(
supportsDoubleTapZoomLocked(), supportsMultiTouchZoomLocked());
}
}
}
public boolean getBuiltInZoomControls() {
synchronized (mAwSettingsLock) {
return mBuiltInZoomControls;
}
}
public void setDisplayZoomControls(boolean enabled) {
synchronized (mAwSettingsLock) {
mDisplayZoomControls = enabled;
}
}
public boolean getDisplayZoomControls() {
synchronized (mAwSettingsLock) {
return mDisplayZoomControls;
}
}
@CalledByNative
private boolean supportsDoubleTapZoomLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mSupportZoom && mBuiltInZoomControls && mUseWideViewport;
}
private boolean supportsMultiTouchZoomLocked() {
assert Thread.holdsLock(mAwSettingsLock);
return mSupportZoom && mBuiltInZoomControls;
}
boolean supportsMultiTouchZoom() {
synchronized (mAwSettingsLock) {
return supportsMultiTouchZoomLocked();
}
}
boolean shouldDisplayZoomControls() {
synchronized (mAwSettingsLock) {
return supportsMultiTouchZoomLocked() && mDisplayZoomControls;
}
}
private int clipFontSize(int size) {
if (size < MINIMUM_FONT_SIZE) {
return MINIMUM_FONT_SIZE;
} else if (size > MAXIMUM_FONT_SIZE) {
return MAXIMUM_FONT_SIZE;
}
return size;
}
@CalledByNative
private void updateEverything() {
synchronized (mAwSettingsLock) {
nativeUpdateEverythingLocked(mNativeAwSettings);
}
}
@CalledByNative
private void populateWebPreferences(long webPrefsPtr) {
synchronized (mAwSettingsLock) {
nativePopulateWebPreferencesLocked(mNativeAwSettings, webPrefsPtr);
}
}
private void updateWebkitPreferencesOnUiThreadLocked() {
assert mEventHandler.mHandler != null;
ThreadUtils.assertOnUiThread();
nativeUpdateWebkitPreferencesLocked(mNativeAwSettings);
}
private native long nativeInit(long webContentsPtr);
private native void nativeDestroy(long nativeAwSettings);
private native void nativePopulateWebPreferencesLocked(long nativeAwSettings, long webPrefsPtr);
private native void nativeResetScrollAndScaleState(long nativeAwSettings);
private native void nativeUpdateEverythingLocked(long nativeAwSettings);
private native void nativeUpdateInitialPageScaleLocked(long nativeAwSettings);
private native void nativeUpdateUserAgentLocked(long nativeAwSettings);
private native void nativeUpdateWebkitPreferencesLocked(long nativeAwSettings);
private static native String nativeGetDefaultUserAgent();
private native void nativeUpdateFormDataPreferencesLocked(long nativeAwSettings);
}