summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContents.java17
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwSettings.java937
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientOnScaleChangedTest.java2
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java2
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwQuotaManagerBridgeTest.java4
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java189
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwTargetDensityDpiTest.java4
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java2
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/ClientAddMessageToConsoleTest.java2
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/ContentViewZoomTest.java35
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java2
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java14
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/NavigationHistoryTest.java2
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/UserAgentTest.java2
-rw-r--r--android_webview/native/aw_settings.cc356
-rw-r--r--android_webview/native/aw_settings.h23
-rw-r--r--android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java2
-rw-r--r--build/android/findbugs_filter/findbugs_known_bugs.txt1
-rw-r--r--content/browser/android/content_settings.cc393
-rw-r--r--content/browser/android/content_settings.h12
-rw-r--r--content/browser/android/content_view_core_impl.cc16
-rw-r--r--content/browser/android/content_view_core_impl.h4
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentSettings.java1070
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentView.java6
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java18
25 files changed, 1360 insertions, 1755 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index 5db2093..00b7b6f 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -288,7 +288,7 @@ public class AwContents {
* @param containerView the view-hierarchy item this object will be bound to.
* @param internalAccessAdapter to access private methods on containerView.
* @param contentsClient will receive API callbacks from this WebView Contents
- * @param isAccessFromFileURLsGrantedByDefault passed to ContentViewCore.initialize.
+ * @param isAccessFromFileURLsGrantedByDefault passed to AwSettings.
*
* This constructor uses the default view sizing policy.
*/
@@ -328,12 +328,12 @@ public class AwContents {
mCleanupReference = new CleanupReference(this, new DestroyRunnable(mNativeAwContents));
int nativeWebContents = nativeGetWebContents(mNativeAwContents);
- mContentViewCore.initialize(containerView, internalAccessAdapter, nativeWebContents,
- null, isAccessFromFileURLsGrantedByDefault);
+ mContentViewCore.initialize(containerView, internalAccessAdapter, nativeWebContents, null);
mContentViewCore.setContentViewClient(mContentsClient);
mContentsClient.installWebContentsObserver(mContentViewCore);
- mSettings = new AwSettings(mContentViewCore.getContext(), nativeWebContents);
+ mSettings = new AwSettings(mContentViewCore.getContext(), nativeWebContents,
+ isAccessFromFileURLsGrantedByDefault);
setIoThreadClient(new IoThreadClientImpl());
setInterceptNavigationDelegate(new InterceptNavigationDelegateImpl());
@@ -344,7 +344,7 @@ public class AwContents {
mContentsClient.setDIPScale(mDIPScale);
mSettings.setDIPScale(mDIPScale);
mDefaultVideoPosterRequestHandler = new DefaultVideoPosterRequestHandler(mContentsClient);
- mContentViewCore.getContentSettings().setDefaultVideoPosterURL(
+ mSettings.setDefaultVideoPosterURL(
mDefaultVideoPosterRequestHandler.getDefaultVideoPosterURL());
ContentVideoView.registerContentVideoViewContextDelegate(
@@ -571,11 +571,7 @@ public class AwContents {
// wrap it and then swap it.
ContentViewCore newCore = new ContentViewCore(mContainerView.getContext(),
ContentViewCore.PERSONALITY_VIEW);
- // Note we pass false for isAccessFromFileURLsGrantedByDefault as we'll
- // set it correctly when when we copy the settings from the old ContentViewCore
- // into the new one.
- newCore.initialize(mContainerView, mInternalAccessAdapter,
- newWebContentsPtr, null, false);
+ newCore.initialize(mContainerView, mInternalAccessAdapter, newWebContentsPtr, null);
newCore.setContentViewClient(mContentsClient);
mContentsClient.installWebContentsObserver(newCore);
@@ -591,6 +587,7 @@ public class AwContents {
nativeSetIoThreadClient(mNativeAwContents, mIoThreadClient);
nativeSetInterceptNavigationDelegate(mNativeAwContents, mInterceptNavigationDelegate);
+ // This will also apply settings to the new WebContents.
mSettings.setWebContents(newWebContentsPtr);
// Finally poke the new ContentViewCore with the size of the container view and show it.
diff --git a/android_webview/java/src/org/chromium/android_webview/AwSettings.java b/android_webview/java/src/org/chromium/android_webview/AwSettings.java
index 76b36f6..8d1c57c7 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwSettings.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwSettings.java
@@ -6,9 +6,15 @@ package org.chromium.android_webview;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
import android.os.Process;
+import android.webkit.WebSettings.PluginState;
import android.webkit.WebSettings;
+import android.webkit.WebView;
+import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.base.ThreadUtils;
@@ -21,22 +27,141 @@ import org.chromium.base.ThreadUtils;
*/
@JNINamespace("android_webview")
public class AwSettings {
+ // This enum corresponds to WebSettings.LayoutAlgorithm. We use our own to be
+ // able to extend it.
+ public enum LayoutAlgorithm {
+ NORMAL,
+ SINGLE_COLUMN,
+ NARROW_COLUMNS,
+ TEXT_AUTOSIZING,
+ }
+
+ private static final String TAG = "AwSettings";
+
+ // This class must be created on the UI thread. Afterwards, it can be
+ // used from any thread. Internally, the class uses a message queue
+ // to call native code on the UI thread only.
+
// Lock to protect all settings.
private final Object mAwSettingsLock = new Object();
private final Context mContext;
private double mDIPScale;
+
+ 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";
+ // TODO(mnaganov): Should be obtained from Android. Problem: it is hidden.
+ private String mDefaultTextEncoding = "Latin-1";
+ 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 final boolean mSupportDeprecatedTargetDensityDPI = true;
+
+ // Not accessed by the native side.
private boolean mBlockNetworkLoads; // Default depends on permission of embedding APK.
private boolean mAllowContentUrlAccess = true;
private boolean mAllowFileUrlAccess = true;
private int mCacheMode = WebSettings.LOAD_DEFAULT;
private boolean mShouldFocusFirstNode = true;
private boolean mGeolocationEnabled = true;
+ static class LazyDefaultUserAgent{
+ // Lazy Holder pattern
+ private static final String sInstance = nativeGetDefaultUserAgent();
+ }
+
+ // Protects access to settings global fields.
+ private static final Object sGlobalContentSettingsLock = new Object();
+ // For compatibility with the legacy WebView, we can only enable AppCache when the path is
+ // provided. However, we don't use the path, so we just check if we have received it from the
+ // client.
+ private static boolean sAppCachePathIsSet = false;
// The native side of this object.
private int mNativeAwSettings = 0;
- public AwSettings(Context context, int nativeWebContents) {
+ // A flag to avoid sending superfluous synchronization messages.
+ private boolean mIsUpdateWebkitPrefsMessagePending = false;
+ // Custom handler that queues messages to call native code on the UI thread.
+ private final EventHandler mEventHandler;
+
+ private static final int MINIMUM_FONT_SIZE = 1;
+ private static final int MAXIMUM_FONT_SIZE = 72;
+
+ // Class to handle messages to be processed on the UI thread.
+ private class EventHandler {
+ // Message id for updating Webkit preferences
+ private static final int UPDATE_WEBKIT_PREFERENCES = 0;
+ // Actual UI thread handler
+ private Handler mHandler;
+
+ EventHandler() {
+ mHandler = new Handler(Looper.getMainLooper()) {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case UPDATE_WEBKIT_PREFERENCES:
+ synchronized (mAwSettingsLock) {
+ updateWebkitPreferencesOnUiThread();
+ mIsUpdateWebkitPrefsMessagePending = false;
+ mAwSettingsLock.notifyAll();
+ }
+ break;
+ }
+ }
+ };
+ }
+
+ private void updateWebkitPreferencesLocked() {
+ assert Thread.holdsLock(mAwSettingsLock);
+ if (mNativeAwSettings == 0) return;
+ if (Looper.myLooper() == mHandler.getLooper()) {
+ updateWebkitPreferencesOnUiThread();
+ } else {
+ // We're being called on a background thread, so post a message.
+ if (mIsUpdateWebkitPrefsMessagePending) {
+ return;
+ }
+ mIsUpdateWebkitPrefsMessagePending = true;
+ mHandler.sendMessage(Message.obtain(null, UPDATE_WEBKIT_PREFERENCES));
+ // We must block until the settings have been sync'd to native to
+ // ensure that they have taken effect.
+ try {
+ while (mIsUpdateWebkitPrefsMessagePending) {
+ mAwSettingsLock.wait();
+ }
+ } catch (InterruptedException e) {}
+ }
+ }
+ }
+
+ public AwSettings(Context context, int nativeWebContents,
+ boolean isAccessFromFileURLsGrantedByDefault) {
+ ThreadUtils.assertOnUiThread();
mContext = context;
mBlockNetworkLoads = mContext.checkPermission(
android.Manifest.permission.INTERNET,
@@ -44,6 +169,15 @@ public class AwSettings {
Process.myUid()) != PackageManager.PERMISSION_GRANTED;
mNativeAwSettings = nativeInit(nativeWebContents);
assert mNativeAwSettings != 0;
+
+ if (isAccessFromFileURLsGrantedByDefault) {
+ mAllowUniversalAccessFromFileURLs = true;
+ mAllowFileAccessFromFileURLs = true;
+ }
+
+ mEventHandler = new EventHandler();
+ mUserAgent = LazyDefaultUserAgent.sInstance;
+ nativeUpdateEverything(mNativeAwSettings);
}
public void destroy() {
@@ -51,8 +185,16 @@ public class AwSettings {
mNativeAwSettings = 0;
}
- void setDIPScale(double dipScale) {
- mDIPScale = dipScale;
+ public void setDIPScale(double dipScale) {
+ synchronized (mAwSettingsLock) {
+ mDIPScale = dipScale;
+ }
+ }
+
+ public void setWebContents(int nativeWebContents) {
+ synchronized (mAwSettingsLock) {
+ nativeSetWebContents(mNativeAwSettings, nativeWebContents);
+ }
}
/**
@@ -155,44 +297,22 @@ public class AwSettings {
}
/**
- * Sets the initial scale for this WebView. The default value
- * is 0. A non-default value overrides initial scale set by
- * the meta viewport tag.
+ * See {@link android.webkit.WebView#setInitialScale}.
*/
public void setInitialPageScale(final float scaleInPercent) {
- // There is no need to lock, because the native code doesn't
- // read anything from the Java side.
- ThreadUtils.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- nativeSetInitialPageScale(mNativeAwSettings, (float)(scaleInPercent / mDIPScale));
- }
- });
- }
-
- /**
- * Sets the text zoom of the page in percent. This kind of zooming is
- * only applicable when Text Autosizing is turned off. Passing -1 will
- * reset the zoom to the default value.
- */
- public void setTextZoom(final int textZoom) {
- // There is no need to lock, because the native code doesn't
- // read anything from the Java side.
- ThreadUtils.runOnUiThreadBlocking(new Runnable() {
- @Override
- public void run() {
- nativeSetTextZoom(mNativeAwSettings, textZoom);
- }
- });
- }
-
- public void resetScrollAndScaleState() {
- ThreadUtils.runOnUiThreadBlocking(new Runnable() {
- @Override
- public void run() {
- nativeResetScrollAndScaleState(mNativeAwSettings);
+ synchronized (mAwSettingsLock) {
+ if (mInitialPageScalePercent != scaleInPercent) {
+ mInitialPageScalePercent = scaleInPercent;
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ if (mNativeAwSettings != 0) {
+ nativeUpdateInitialPageScale(mNativeAwSettings);
+ }
+ }
+ });
}
- });
+ }
}
/**
@@ -224,8 +344,735 @@ public class AwSettings {
}
}
- public void setWebContents(int nativeWebContents) {
- nativeSetWebContents(mNativeAwSettings, nativeWebContents);
+ /**
+ * @returns the default User-Agent used by each ContentViewCore instance, i.e. unless
+ * overridden by {@link #setUserAgentString()}
+ */
+ public static String getDefaultUserAgent() {
+ return LazyDefaultUserAgent.sInstance;
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setUserAgentString}.
+ */
+ 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)) {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ if (mNativeAwSettings != 0) {
+ nativeUpdateUserAgent(mNativeAwSettings);
+ }
+ }
+ });
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getUserAgentString}.
+ */
+ public String getUserAgentString() {
+ synchronized (mAwSettingsLock) {
+ return mUserAgent;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setLoadWithOverviewMode}.
+ */
+ public void setLoadWithOverviewMode(boolean overview) {
+ synchronized (mAwSettingsLock) {
+ if (mLoadWithOverviewMode != overview) {
+ mLoadWithOverviewMode = overview;
+ mEventHandler.updateWebkitPreferencesLocked();
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ if (mNativeAwSettings != 0) {
+ nativeResetScrollAndScaleState(mNativeAwSettings);
+ }
+ }
+ });
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getLoadWithOverviewMode}.
+ */
+ public boolean getLoadWithOverviewMode() {
+ synchronized (mAwSettingsLock) {
+ return mLoadWithOverviewMode;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setTextZoom}.
+ */
+ public void setTextZoom(final int textZoom) {
+ synchronized (mAwSettingsLock) {
+ if (mTextSizePercent != textZoom) {
+ mTextSizePercent = textZoom;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getTextZoom}.
+ */
+ public int getTextZoom() {
+ synchronized (mAwSettingsLock) {
+ return mTextSizePercent;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setStandardFontFamily}.
+ */
+ public void setStandardFontFamily(String font) {
+ synchronized (mAwSettingsLock) {
+ if (font != null && !mStandardFontFamily.equals(font)) {
+ mStandardFontFamily = font;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getStandardFontFamily}.
+ */
+ public String getStandardFontFamily() {
+ synchronized (mAwSettingsLock) {
+ return mStandardFontFamily;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setFixedFontFamily}.
+ */
+ public void setFixedFontFamily(String font) {
+ synchronized (mAwSettingsLock) {
+ if (font != null && !mFixedFontFamily.equals(font)) {
+ mFixedFontFamily = font;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getFixedFontFamily}.
+ */
+ public String getFixedFontFamily() {
+ synchronized (mAwSettingsLock) {
+ return mFixedFontFamily;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setSansSerifFontFamily}.
+ */
+ public void setSansSerifFontFamily(String font) {
+ synchronized (mAwSettingsLock) {
+ if (font != null && !mSansSerifFontFamily.equals(font)) {
+ mSansSerifFontFamily = font;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getSansSerifFontFamily}.
+ */
+ public String getSansSerifFontFamily() {
+ synchronized (mAwSettingsLock) {
+ return mSansSerifFontFamily;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setSerifFontFamily}.
+ */
+ public void setSerifFontFamily(String font) {
+ synchronized (mAwSettingsLock) {
+ if (font != null && !mSerifFontFamily.equals(font)) {
+ mSerifFontFamily = font;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getSerifFontFamily}.
+ */
+ public String getSerifFontFamily() {
+ synchronized (mAwSettingsLock) {
+ return mSerifFontFamily;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setCursiveFontFamily}.
+ */
+ public void setCursiveFontFamily(String font) {
+ synchronized (mAwSettingsLock) {
+ if (font != null && !mCursiveFontFamily.equals(font)) {
+ mCursiveFontFamily = font;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getCursiveFontFamily}.
+ */
+ public String getCursiveFontFamily() {
+ synchronized (mAwSettingsLock) {
+ return mCursiveFontFamily;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setFantasyFontFamily}.
+ */
+ public void setFantasyFontFamily(String font) {
+ synchronized (mAwSettingsLock) {
+ if (font != null && !mFantasyFontFamily.equals(font)) {
+ mFantasyFontFamily = font;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getFantasyFontFamily}.
+ */
+ public String getFantasyFontFamily() {
+ synchronized (mAwSettingsLock) {
+ return mFantasyFontFamily;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setMinimumFontSize}.
+ */
+ public void setMinimumFontSize(int size) {
+ synchronized (mAwSettingsLock) {
+ size = clipFontSize(size);
+ if (mMinimumFontSize != size) {
+ mMinimumFontSize = size;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getMinimumFontSize}.
+ */
+ public int getMinimumFontSize() {
+ synchronized (mAwSettingsLock) {
+ return mMinimumFontSize;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setMinimumLogicalFontSize}.
+ */
+ public void setMinimumLogicalFontSize(int size) {
+ synchronized (mAwSettingsLock) {
+ size = clipFontSize(size);
+ if (mMinimumLogicalFontSize != size) {
+ mMinimumLogicalFontSize = size;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getMinimumLogicalFontSize}.
+ */
+ public int getMinimumLogicalFontSize() {
+ synchronized (mAwSettingsLock) {
+ return mMinimumLogicalFontSize;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setDefaultFontSize}.
+ */
+ public void setDefaultFontSize(int size) {
+ synchronized (mAwSettingsLock) {
+ size = clipFontSize(size);
+ if (mDefaultFontSize != size) {
+ mDefaultFontSize = size;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getDefaultFontSize}.
+ */
+ public int getDefaultFontSize() {
+ synchronized (mAwSettingsLock) {
+ return mDefaultFontSize;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setDefaultFixedFontSize}.
+ */
+ public void setDefaultFixedFontSize(int size) {
+ synchronized (mAwSettingsLock) {
+ size = clipFontSize(size);
+ if (mDefaultFixedFontSize != size) {
+ mDefaultFixedFontSize = size;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getDefaultFixedFontSize}.
+ */
+ public int getDefaultFixedFontSize() {
+ synchronized (mAwSettingsLock) {
+ return mDefaultFixedFontSize;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setJavaScriptEnabled}.
+ */
+ public void setJavaScriptEnabled(boolean flag) {
+ synchronized (mAwSettingsLock) {
+ if (mJavaScriptEnabled != flag) {
+ mJavaScriptEnabled = flag;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setAllowUniversalAccessFromFileURLs}.
+ */
+ public void setAllowUniversalAccessFromFileURLs(boolean flag) {
+ synchronized (mAwSettingsLock) {
+ if (mAllowUniversalAccessFromFileURLs != flag) {
+ mAllowUniversalAccessFromFileURLs = flag;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setAllowFileAccessFromFileURLs}.
+ */
+ public void setAllowFileAccessFromFileURLs(boolean flag) {
+ synchronized (mAwSettingsLock) {
+ if (mAllowFileAccessFromFileURLs != flag) {
+ mAllowFileAccessFromFileURLs = flag;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setLoadsImagesAutomatically}.
+ */
+ public void setLoadsImagesAutomatically(boolean flag) {
+ synchronized (mAwSettingsLock) {
+ if (mLoadsImagesAutomatically != flag) {
+ mLoadsImagesAutomatically = flag;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getLoadsImagesAutomatically}.
+ */
+ public boolean getLoadsImagesAutomatically() {
+ synchronized (mAwSettingsLock) {
+ return mLoadsImagesAutomatically;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setImagesEnabled}.
+ */
+ public void setImagesEnabled(boolean flag) {
+ synchronized (mAwSettingsLock) {
+ if (mImagesEnabled != flag) {
+ mImagesEnabled = flag;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getImagesEnabled}.
+ */
+ public boolean getImagesEnabled() {
+ synchronized (mAwSettingsLock) {
+ return mImagesEnabled;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getJavaScriptEnabled}.
+ */
+ public boolean getJavaScriptEnabled() {
+ synchronized (mAwSettingsLock) {
+ return mJavaScriptEnabled;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getAllowUniversalAccessFromFileURLs}.
+ */
+ public boolean getAllowUniversalAccessFromFileURLs() {
+ synchronized (mAwSettingsLock) {
+ return mAllowUniversalAccessFromFileURLs;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getAllowFileAccessFromFileURLs}.
+ */
+ public boolean getAllowFileAccessFromFileURLs() {
+ synchronized (mAwSettingsLock) {
+ return mAllowFileAccessFromFileURLs;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setPluginsEnabled}.
+ */
+ @Deprecated
+ public void setPluginsEnabled(boolean flag) {
+ setPluginState(flag ? PluginState.ON : PluginState.OFF);
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setPluginState}.
+ */
+ public void setPluginState(PluginState state) {
+ synchronized (mAwSettingsLock) {
+ if (mPluginState != state) {
+ mPluginState = state;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getPluginsEnabled}.
+ */
+ @Deprecated
+ public boolean getPluginsEnabled() {
+ synchronized (mAwSettingsLock) {
+ return mPluginState == PluginState.ON;
+ }
+ }
+
+ /**
+ * Return true if plugins are disabled.
+ * @return True if plugins are disabled.
+ * @hide
+ */
+ @CalledByNative
+ private boolean getPluginsDisabled() {
+ // This should only be called from UpdateWebkitPreferences, which is called
+ // either from the constructor, or with mAwSettingsLock being held.
+ return mPluginState == PluginState.OFF;
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getPluginState}.
+ */
+ public PluginState getPluginState() {
+ synchronized (mAwSettingsLock) {
+ return mPluginState;
+ }
+ }
+
+
+ /**
+ * See {@link android.webkit.WebSettings#setJavaScriptCanOpenWindowsAutomatically}.
+ */
+ public void setJavaScriptCanOpenWindowsAutomatically(boolean flag) {
+ synchronized (mAwSettingsLock) {
+ if (mJavaScriptCanOpenWindowsAutomatically != flag) {
+ mJavaScriptCanOpenWindowsAutomatically = flag;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getJavaScriptCanOpenWindowsAutomatically}.
+ */
+ public boolean getJavaScriptCanOpenWindowsAutomatically() {
+ synchronized (mAwSettingsLock) {
+ return mJavaScriptCanOpenWindowsAutomatically;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setLayoutAlgorithm}.
+ */
+ public void setLayoutAlgorithm(LayoutAlgorithm l) {
+ synchronized (mAwSettingsLock) {
+ if (mLayoutAlgorithm != l) {
+ mLayoutAlgorithm = l;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getLayoutAlgorithm}.
+ */
+ public LayoutAlgorithm getLayoutAlgorithm() {
+ synchronized (mAwSettingsLock) {
+ return mLayoutAlgorithm;
+ }
+ }
+
+ /**
+ * Gets whether Text Auto-sizing layout algorithm is enabled.
+ *
+ * @return true if Text Auto-sizing layout algorithm is enabled
+ * @hide
+ */
+ @CalledByNative
+ private boolean getTextAutosizingEnabled() {
+ return mLayoutAlgorithm == LayoutAlgorithm.TEXT_AUTOSIZING;
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setSupportMultipleWindows}.
+ */
+ public void setSupportMultipleWindows(boolean support) {
+ synchronized (mAwSettingsLock) {
+ if (mSupportMultipleWindows != support) {
+ mSupportMultipleWindows = support;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#supportMultipleWindows}.
+ */
+ public boolean supportMultipleWindows() {
+ synchronized (mAwSettingsLock) {
+ return mSupportMultipleWindows;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setUseWideViewPort}.
+ */
+ public void setUseWideViewPort(boolean use) {
+ synchronized (mAwSettingsLock) {
+ if (mUseWideViewport != use) {
+ mUseWideViewport = use;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getUseWideViewPort}.
+ */
+ public boolean getUseWideViewPort() {
+ synchronized (mAwSettingsLock) {
+ return mUseWideViewport;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setAppCacheEnabled}.
+ */
+ public void setAppCacheEnabled(boolean flag) {
+ synchronized (mAwSettingsLock) {
+ if (mAppCacheEnabled != flag) {
+ mAppCacheEnabled = flag;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setAppCachePath}.
+ */
+ public void setAppCachePath(String path) {
+ boolean needToSync = false;
+ synchronized (sGlobalContentSettingsLock) {
+ // AppCachePath can only be set once.
+ if (!sAppCachePathIsSet && path != null && !path.isEmpty()) {
+ sAppCachePathIsSet = true;
+ needToSync = true;
+ }
+ }
+ // The obvious problem here is that other WebViews will not be updated,
+ // until they execute synchronization from Java to the native side.
+ // But this is the same behaviour as it was in the legacy WebView.
+ if (needToSync) {
+ synchronized (mAwSettingsLock) {
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * Gets whether Application Cache is enabled.
+ *
+ * @return true if Application Cache is enabled
+ * @hide
+ */
+ @CalledByNative
+ private boolean getAppCacheEnabled() {
+ // This should only be called from UpdateWebkitPreferences, which is called
+ // either from the constructor, or with mAwSettingsLock being held.
+ if (!mAppCacheEnabled) {
+ return false;
+ }
+ synchronized (sGlobalContentSettingsLock) {
+ return sAppCachePathIsSet;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setDomStorageEnabled}.
+ */
+ public void setDomStorageEnabled(boolean flag) {
+ synchronized (mAwSettingsLock) {
+ if (mDomStorageEnabled != flag) {
+ mDomStorageEnabled = flag;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getDomStorageEnabled}.
+ */
+ public boolean getDomStorageEnabled() {
+ synchronized (mAwSettingsLock) {
+ return mDomStorageEnabled;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setDatabaseEnabled}.
+ */
+ public void setDatabaseEnabled(boolean flag) {
+ synchronized (mAwSettingsLock) {
+ if (mDatabaseEnabled != flag) {
+ mDatabaseEnabled = flag;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getDatabaseEnabled}.
+ */
+ public boolean getDatabaseEnabled() {
+ synchronized (mAwSettingsLock) {
+ return mDatabaseEnabled;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setDefaultTextEncodingName}.
+ */
+ public void setDefaultTextEncodingName(String encoding) {
+ synchronized (mAwSettingsLock) {
+ if (encoding != null && !mDefaultTextEncoding.equals(encoding)) {
+ mDefaultTextEncoding = encoding;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getDefaultTextEncodingName}.
+ */
+ public String getDefaultTextEncodingName() {
+ synchronized (mAwSettingsLock) {
+ return mDefaultTextEncoding;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setMediaPlaybackRequiresUserGesture}.
+ */
+ public void setMediaPlaybackRequiresUserGesture(boolean require) {
+ synchronized (mAwSettingsLock) {
+ if (mMediaPlaybackRequiresUserGesture != require) {
+ mMediaPlaybackRequiresUserGesture = require;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getMediaPlaybackRequiresUserGesture}.
+ */
+ public boolean getMediaPlaybackRequiresUserGesture() {
+ synchronized (mAwSettingsLock) {
+ return mMediaPlaybackRequiresUserGesture;
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#setDefaultVideoPosterURL}.
+ */
+ public void setDefaultVideoPosterURL(String url) {
+ synchronized (mAwSettingsLock) {
+ if (mDefaultVideoPosterURL != null && !mDefaultVideoPosterURL.equals(url) ||
+ mDefaultVideoPosterURL == null && url != null) {
+ mDefaultVideoPosterURL = url;
+ mEventHandler.updateWebkitPreferencesLocked();
+ }
+ }
+ }
+
+ /**
+ * See {@link android.webkit.WebSettings#getDefaultVideoPosterURL}.
+ */
+ public String getDefaultVideoPosterURL() {
+ synchronized (mAwSettingsLock) {
+ return mDefaultVideoPosterURL;
+ }
+ }
+
+ 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;
+ }
+
+ private void updateWebkitPreferencesOnUiThread() {
+ if (mNativeAwSettings != 0) {
+ ThreadUtils.assertOnUiThread();
+ nativeUpdateWebkitPreferences(mNativeAwSettings);
+ }
}
private native int nativeInit(int webContentsPtr);
@@ -236,7 +1083,13 @@ public class AwSettings {
private native void nativeSetWebContents(int nativeAwSettings, int nativeWebContents);
- private native void nativeSetInitialPageScale(int nativeAwSettings, float scaleInPercent);
+ private native void nativeUpdateEverything(int nativeAwSettings);
+
+ private native void nativeUpdateInitialPageScale(int nativeAwSettings);
+
+ private native void nativeUpdateUserAgent(int nativeAwSettings);
+
+ private native void nativeUpdateWebkitPreferences(int nativeAwSettings);
- private native void nativeSetTextZoom(int nativeAwSettings, int textZoom);
+ private static native String nativeGetDefaultUserAgent();
}
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientOnScaleChangedTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientOnScaleChangedTest.java
index eb3a22b..d47b32d 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientOnScaleChangedTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientOnScaleChangedTest.java
@@ -41,7 +41,7 @@ public class AwContentsClientOnScaleChangedTest extends AwTestBase {
*/
@DisabledTest
public void testScaleUp() throws Throwable {
- getContentSettingsOnUiThread(mAwContents).setUseWideViewPort(true);
+ getAwSettingsOnUiThread(mAwContents).setUseWideViewPort(true);
loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
CommonResources.ABOUT_HTML, "text/html", false);
ContentViewCore core = mAwContents.getContentViewCore();
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
index da647b4..2045d55 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
@@ -291,7 +291,7 @@ public class AwContentsTest extends AwTestBase {
// the page load completes which makes it slightly hard to test.
final Bitmap defaultFavicon = awContents.getFavicon();
- getContentSettingsOnUiThread(awContents).setImagesEnabled(true);
+ getAwSettingsOnUiThread(awContents).setImagesEnabled(true);
loadUrlSync(awContents, mContentsClient.getOnPageFinishedHelper(), pageUrl);
assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwQuotaManagerBridgeTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwQuotaManagerBridgeTest.java
index 221504e8..8b356f9 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwQuotaManagerBridgeTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwQuotaManagerBridgeTest.java
@@ -10,8 +10,8 @@ import android.webkit.ValueCallback;
import org.chromium.android_webview.AwContents;
import org.chromium.android_webview.AwQuotaManagerBridge;
+import org.chromium.android_webview.AwSettings;
import org.chromium.base.test.util.Feature;
-import org.chromium.content.browser.ContentSettings;
import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
@@ -37,7 +37,7 @@ public class AwQuotaManagerBridgeTest extends AwTestBase {
mWebServer = new TestWebServer(false);
mOrigin = mWebServer.getBaseUrl();
- ContentSettings settings = getContentSettingsOnUiThread(mAwContents);
+ AwSettings settings = getAwSettingsOnUiThread(mAwContents);
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
settings.setAppCacheEnabled(true);
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java
index c85061d..e3fc616 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java
@@ -18,6 +18,7 @@ import org.apache.http.Header;
import org.apache.http.HttpRequest;
import org.chromium.android_webview.AndroidProtocolHandler;
import org.chromium.android_webview.AwContents;
+import org.chromium.android_webview.AwSettings.LayoutAlgorithm;
import org.chromium.android_webview.AwSettings;
import org.chromium.android_webview.InterceptedRequestData;
import org.chromium.android_webview.test.util.CommonResources;
@@ -28,8 +29,6 @@ import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.TestFileUtil;
import org.chromium.base.test.util.UrlUtils;
-import org.chromium.content.browser.ContentSettings;
-import org.chromium.content.browser.ContentSettings.LayoutAlgorithm;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.content.browser.test.util.Criteria;
@@ -46,7 +45,7 @@ import java.util.ArrayList;
import java.util.List;
/**
- * A test suite for ContentSettings class. The key objective is to verify that each
+ * A test suite for AwSettings class. The key objective is to verify that each
* settings applies either to each individual view or to all views of the
* application
*/
@@ -58,7 +57,7 @@ public class AwSettingsTest extends AwTestBase {
private static final boolean DISABLED = false;
/**
- * A helper class for testing a particular preference from ContentSettings.
+ * A helper class for testing a particular preference from AwSettings.
* The generic type T is the type of the setting. Usually, to test an
* effect of the preference, JS code is executed that sets document's title.
* In this case, requiresJsEnabled constructor argument must be set to true.
@@ -66,16 +65,16 @@ public class AwSettingsTest extends AwTestBase {
abstract class AwSettingsTestHelper<T> {
protected final AwContents mAwContents;
protected final TestAwContentsClient mContentViewClient;
- protected final ContentSettings mContentSettings;
+ protected final AwSettings mAwSettings;
AwSettingsTestHelper(AwContents awContents,
TestAwContentsClient contentViewClient,
boolean requiresJsEnabled) throws Throwable {
mAwContents = awContents;
mContentViewClient = contentViewClient;
- mContentSettings = getContentSettingsOnUiThread(mAwContents);
+ mAwSettings = AwSettingsTest.this.getAwSettingsOnUiThread(awContents);
if (requiresJsEnabled) {
- mContentSettings.setJavaScriptEnabled(true);
+ mAwSettings.setJavaScriptEnabled(true);
}
}
@@ -165,12 +164,12 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected Boolean getCurrentValue() {
- return mContentSettings.getJavaScriptEnabled();
+ return mAwSettings.getJavaScriptEnabled();
}
@Override
protected void setCurrentValue(Boolean value) {
- mContentSettings.setJavaScriptEnabled(value);
+ mAwSettings.setJavaScriptEnabled(value);
}
@Override
@@ -233,12 +232,12 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected Boolean getCurrentValue() {
- return mContentSettings.getPluginsEnabled();
+ return mAwSettings.getPluginsEnabled();
}
@Override
protected void setCurrentValue(Boolean value) {
- mContentSettings.setPluginsEnabled(value);
+ mAwSettings.setPluginsEnabled(value);
}
@Override
@@ -274,12 +273,12 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected String getCurrentValue() {
- return mContentSettings.getStandardFontFamily();
+ return mAwSettings.getStandardFontFamily();
}
@Override
protected void setCurrentValue(String value) {
- mContentSettings.setStandardFontFamily(value);
+ mAwSettings.setStandardFontFamily(value);
}
@Override
@@ -314,12 +313,12 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected Integer getCurrentValue() {
- return mContentSettings.getDefaultFontSize();
+ return mAwSettings.getDefaultFontSize();
}
@Override
protected void setCurrentValue(Integer value) {
- mContentSettings.setDefaultFontSize(value);
+ mAwSettings.setDefaultFontSize(value);
}
@Override
@@ -358,12 +357,12 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected Boolean getCurrentValue() {
- return mContentSettings.getLoadsImagesAutomatically();
+ return mAwSettings.getLoadsImagesAutomatically();
}
@Override
protected void setCurrentValue(Boolean value) {
- mContentSettings.setLoadsImagesAutomatically(value);
+ mAwSettings.setLoadsImagesAutomatically(value);
}
@Override
@@ -395,12 +394,12 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected String getCurrentValue() {
- return mContentSettings.getDefaultTextEncodingName();
+ return mAwSettings.getDefaultTextEncodingName();
}
@Override
protected void setCurrentValue(String value) {
- mContentSettings.setDefaultTextEncodingName(value);
+ mAwSettings.setDefaultTextEncodingName(value);
}
@Override
@@ -423,7 +422,7 @@ public class AwSettingsTest extends AwTestBase {
AwContents awContents,
TestAwContentsClient contentViewClient) throws Throwable {
super(awContents, contentViewClient, true);
- mDefaultUa = mContentSettings.getUserAgentString();
+ mDefaultUa = mAwSettings.getUserAgentString();
}
@Override
@@ -443,13 +442,13 @@ public class AwSettingsTest extends AwTestBase {
// and getUserAgentString returns the default UA string afterwards.
// To align with the framework, we return an empty string instead of
// the default UA.
- String currentUa = mContentSettings.getUserAgentString();
+ String currentUa = mAwSettings.getUserAgentString();
return mDefaultUa.equals(currentUa) ? DEFAULT_UA : currentUa;
}
@Override
protected void setCurrentValue(String value) {
- mContentSettings.setUserAgentString(value);
+ mAwSettings.setUserAgentString(value);
}
@Override
@@ -487,12 +486,12 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected Boolean getCurrentValue() {
- return mContentSettings.getDomStorageEnabled();
+ return mAwSettings.getDomStorageEnabled();
}
@Override
protected void setCurrentValue(Boolean value) {
- mContentSettings.setDomStorageEnabled(value);
+ mAwSettings.setDomStorageEnabled(value);
}
@Override
@@ -528,12 +527,12 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected Boolean getCurrentValue() {
- return mContentSettings.getDatabaseEnabled();
+ return mAwSettings.getDatabaseEnabled();
}
@Override
protected void setCurrentValue(Boolean value) {
- mContentSettings.setDatabaseEnabled(value);
+ mAwSettings.setDatabaseEnabled(value);
}
@Override
@@ -560,11 +559,11 @@ public class AwSettingsTest extends AwTestBase {
mIframeContainerUrl = UrlUtils.getTestFileUrl("webview/iframe_access.html");
mIframeUrl = UrlUtils.getTestFileUrl("webview/hello_world.html");
// The value of the setting depends on the SDK version.
- mContentSettings.setAllowUniversalAccessFromFileURLs(false);
+ mAwSettings.setAllowUniversalAccessFromFileURLs(false);
// If universal access is true, the value of file access doesn't
// matter. While if universal access is false, having file access
// enabled will allow file loading.
- mContentSettings.setAllowFileAccessFromFileURLs(false);
+ mAwSettings.setAllowFileAccessFromFileURLs(false);
}
@Override
@@ -579,12 +578,12 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected Boolean getCurrentValue() {
- return mContentSettings.getAllowUniversalAccessFromFileURLs();
+ return mAwSettings.getAllowUniversalAccessFromFileURLs();
}
@Override
protected void setCurrentValue(Boolean value) {
- mContentSettings.setAllowUniversalAccessFromFileURLs(value);
+ mAwSettings.setAllowUniversalAccessFromFileURLs(value);
}
@Override
@@ -610,9 +609,9 @@ public class AwSettingsTest extends AwTestBase {
super(awContents, contentViewClient, true);
mIframeContainerUrl = UrlUtils.getTestFileUrl("webview/iframe_access.html");
mIframeUrl = UrlUtils.getTestFileUrl("webview/hello_world.html");
- mContentSettings.setAllowUniversalAccessFromFileURLs(false);
+ mAwSettings.setAllowUniversalAccessFromFileURLs(false);
// The value of the setting depends on the SDK version.
- mContentSettings.setAllowFileAccessFromFileURLs(false);
+ mAwSettings.setAllowFileAccessFromFileURLs(false);
}
@Override
@@ -627,12 +626,12 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected Boolean getCurrentValue() {
- return mContentSettings.getAllowFileAccessFromFileURLs();
+ return mAwSettings.getAllowFileAccessFromFileURLs();
}
@Override
protected void setCurrentValue(Boolean value) {
- mContentSettings.setAllowFileAccessFromFileURLs(value);
+ mAwSettings.setAllowFileAccessFromFileURLs(value);
}
@Override
@@ -656,9 +655,9 @@ public class AwSettingsTest extends AwTestBase {
TestAwContentsClient contentViewClient) throws Throwable {
super(awContents, contentViewClient, true);
mXhrContainerUrl = UrlUtils.getTestFileUrl("webview/xhr_access.html");
- mContentSettings.setAllowUniversalAccessFromFileURLs(false);
+ mAwSettings.setAllowUniversalAccessFromFileURLs(false);
// The value of the setting depends on the SDK version.
- mContentSettings.setAllowFileAccessFromFileURLs(false);
+ mAwSettings.setAllowFileAccessFromFileURLs(false);
}
@Override
@@ -673,12 +672,12 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected Boolean getCurrentValue() {
- return mContentSettings.getAllowFileAccessFromFileURLs();
+ return mAwSettings.getAllowFileAccessFromFileURLs();
}
@Override
protected void setCurrentValue(Boolean value) {
- mContentSettings.setAllowFileAccessFromFileURLs(value);
+ mAwSettings.setAllowFileAccessFromFileURLs(value);
}
@Override
@@ -692,20 +691,7 @@ public class AwSettingsTest extends AwTestBase {
private final String mXhrContainerUrl;
}
- // A helper super class for test cases that need to access AwSettings.
- abstract class AwSettingsWithSettingsTestHelper<T> extends AwSettingsTestHelper<T> {
- protected AwSettings mAwSettings;
-
- AwSettingsWithSettingsTestHelper(
- AwContents awContents,
- TestAwContentsClient contentViewClient,
- boolean requiresJsEnabled) throws Throwable {
- super(awContents, contentViewClient, requiresJsEnabled);
- mAwSettings = AwSettingsTest.this.getAwSettingsOnUiThread(awContents);
- }
- }
-
- class AwSettingsFileUrlAccessTestHelper extends AwSettingsWithSettingsTestHelper<Boolean> {
+ class AwSettingsFileUrlAccessTestHelper extends AwSettingsTestHelper<Boolean> {
private static final String ACCESS_GRANTED_TITLE = "Hello, World!";
AwSettingsFileUrlAccessTestHelper(
@@ -752,7 +738,7 @@ public class AwSettingsTest extends AwTestBase {
private int mIndex;
}
- class AwSettingsContentUrlAccessTestHelper extends AwSettingsWithSettingsTestHelper<Boolean> {
+ class AwSettingsContentUrlAccessTestHelper extends AwSettingsTestHelper<Boolean> {
AwSettingsContentUrlAccessTestHelper(
AwContents awContents,
@@ -796,8 +782,7 @@ public class AwSettingsTest extends AwTestBase {
private final String mTarget;
}
- class AwSettingsContentUrlAccessFromFileTestHelper
- extends AwSettingsWithSettingsTestHelper<Boolean> {
+ class AwSettingsContentUrlAccessFromFileTestHelper extends AwSettingsTestHelper<Boolean> {
private static final String TARGET = "content_from_file";
AwSettingsContentUrlAccessFromFileTestHelper(
@@ -859,8 +844,7 @@ public class AwSettingsTest extends AwTestBase {
// This class provides helper methods for testing of settings related to
// the text autosizing feature.
- abstract class AwSettingsTextAutosizingTestHelper<T>
- extends AwSettingsWithSettingsTestHelper<T> {
+ abstract class AwSettingsTextAutosizingTestHelper<T> extends AwSettingsTestHelper<T> {
protected static final float PARAGRAPH_FONT_SIZE = 14.0f;
AwSettingsTextAutosizingTestHelper(
@@ -937,7 +921,7 @@ public class AwSettingsTest extends AwTestBase {
TestAwContentsClient contentViewClient) throws Throwable {
super(awContents, contentViewClient);
// Font autosizing doesn't step in for narrow layout widths.
- mContentSettings.setUseWideViewPort(true);
+ mAwSettings.setUseWideViewPort(true);
}
@Override
@@ -952,13 +936,13 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected LayoutAlgorithm getCurrentValue() {
- return mContentSettings.getLayoutAlgorithm();
+ return mAwSettings.getLayoutAlgorithm();
}
@Override
protected void setCurrentValue(LayoutAlgorithm value) throws Throwable {
super.setCurrentValue(value);
- mContentSettings.setLayoutAlgorithm(value);
+ mAwSettings.setLayoutAlgorithm(value);
}
@Override
@@ -997,13 +981,12 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected Integer getCurrentValue() {
- return mContentSettings.getTextZoom();
+ return mAwSettings.getTextZoom();
}
@Override
protected void setCurrentValue(Integer value) throws Throwable {
super.setCurrentValue(value);
- mContentSettings.setTextZoom(value);
mAwSettings.setTextZoom(value);
}
@@ -1031,7 +1014,7 @@ public class AwSettingsTest extends AwTestBase {
AwContents awContents,
TestAwContentsClient contentViewClient) throws Throwable {
super(awContents, contentViewClient);
- mContentSettings.setLayoutAlgorithm(LayoutAlgorithm.TEXT_AUTOSIZING);
+ mAwSettings.setLayoutAlgorithm(LayoutAlgorithm.TEXT_AUTOSIZING);
// The initial font size can be adjusted by font autosizer depending on the page's
// viewport width.
mInitialActualFontSize = getActualFontSize();
@@ -1049,15 +1032,13 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected Integer getCurrentValue() {
- return mContentSettings.getTextZoom();
+ return mAwSettings.getTextZoom();
}
@Override
protected void setCurrentValue(Integer value) throws Throwable {
super.setCurrentValue(value);
- mContentSettings.setTextZoom(value);
- // This is to verify that AwSettings will not affect font boosting by Autosizer.
- mAwSettings.setTextZoom(-1);
+ mAwSettings.setTextZoom(value);
}
@Override
@@ -1097,12 +1078,12 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected Boolean getCurrentValue() {
- return mContentSettings.getJavaScriptCanOpenWindowsAutomatically();
+ return mAwSettings.getJavaScriptCanOpenWindowsAutomatically();
}
@Override
protected void setCurrentValue(Boolean value) {
- mContentSettings.setJavaScriptCanOpenWindowsAutomatically(value);
+ mAwSettings.setJavaScriptCanOpenWindowsAutomatically(value);
}
@Override
@@ -1140,7 +1121,7 @@ public class AwSettingsTest extends AwTestBase {
}
}
- class AwSettingsCacheModeTestHelper extends AwSettingsWithSettingsTestHelper<Integer> {
+ class AwSettingsCacheModeTestHelper extends AwSettingsTestHelper<Integer> {
AwSettingsCacheModeTestHelper(
AwContents awContents,
@@ -1197,7 +1178,7 @@ public class AwSettingsTest extends AwTestBase {
// "viewport" tag is ignored, and the layout width is set to device width in DIP pixels.
// We specify a very high width value to make sure that it doesn't intersect with
// device screen widths (in DIP pixels).
- class AwSettingsUseWideViewportTestHelper extends AwSettingsWithSettingsTestHelper<Boolean> {
+ class AwSettingsUseWideViewportTestHelper extends AwSettingsTestHelper<Boolean> {
static private final String VIEWPORT_TAG_LAYOUT_WIDTH = "3000";
AwSettingsUseWideViewportTestHelper(
@@ -1218,12 +1199,12 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected Boolean getCurrentValue() {
- return mContentSettings.getUseWideViewPort();
+ return mAwSettings.getUseWideViewPort();
}
@Override
protected void setCurrentValue(Boolean value) {
- mContentSettings.setUseWideViewPort(value);
+ mAwSettings.setUseWideViewPort(value);
}
@Override
@@ -1254,7 +1235,7 @@ public class AwSettingsTest extends AwTestBase {
boolean withViewPortTag) throws Throwable {
super(awContents, contentViewClient, true);
mWithViewPortTag = withViewPortTag;
- mContentSettings.setUseWideViewPort(true);
+ mAwSettings.setUseWideViewPort(true);
}
@Override
@@ -1269,18 +1250,17 @@ public class AwSettingsTest extends AwTestBase {
@Override
protected Boolean getCurrentValue() {
- return mContentSettings.getLoadWithOverviewMode();
+ return mAwSettings.getLoadWithOverviewMode();
}
@Override
protected void setCurrentValue(Boolean value) {
- mExpectScaleChange = mContentSettings.getLoadWithOverviewMode() != value;
+ mExpectScaleChange = mAwSettings.getLoadWithOverviewMode() != value;
if (mExpectScaleChange) {
mOnScaleChangedCallCount =
mContentViewClient.getOnScaleChangedHelper().getCallCount();
}
- mContentSettings.setLoadWithOverviewMode(value);
- mAwContents.getSettings().resetScrollAndScaleState();
+ mAwSettings.setLoadWithOverviewMode(value);
}
@Override
@@ -1313,7 +1293,7 @@ public class AwSettingsTest extends AwTestBase {
}
// The test verifies that JavaScript is disabled upon WebView
- // creation without accessing ContentSettings. If the test passes,
+ // creation without accessing AwSettings. If the test passes,
// it means that WebView-specific web preferences configuration
// is applied on WebView creation. JS state is used, because it is
// enabled by default in Chrome, but must be disabled by default
@@ -1393,9 +1373,9 @@ public class AwSettingsTest extends AwTestBase {
@SmallTest
public void testLoadsImagesAutomaticallyWithCachedImage() throws Throwable {
ViewPair views = createViews();
- ContentSettings settings0 = getContentSettingsOnUiThread(views.getContents0());
+ AwSettings settings0 = getAwSettingsOnUiThread(views.getContents0());
settings0.setJavaScriptEnabled(true);
- ContentSettings settings1 = getContentSettingsOnUiThread(views.getContents1());
+ AwSettings settings1 = getAwSettingsOnUiThread(views.getContents1());
settings1.setJavaScriptEnabled(true);
ImagePageGenerator generator = new ImagePageGenerator(0, false);
@@ -1466,7 +1446,7 @@ public class AwSettingsTest extends AwTestBase {
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentClient);
final AwContents awContents = testContainerView.getAwContents();
- ContentSettings settings = getContentSettingsOnUiThread(awContents);
+ AwSettings settings = getAwSettingsOnUiThread(awContents);
settings.setJavaScriptEnabled(true);
ImagePageGenerator generator = new ImagePageGenerator(0, false);
settings.setLoadsImagesAutomatically(false);
@@ -1526,7 +1506,7 @@ public class AwSettingsTest extends AwTestBase {
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentClient);
final AwContents awContents = testContainerView.getAwContents();
- ContentSettings settings = getContentSettingsOnUiThread(awContents);
+ AwSettings settings = getAwSettingsOnUiThread(awContents);
final String actualUserAgentString = settings.getUserAgentString();
final String patternString =
"Mozilla/5\\.0 \\(Linux;( U;)? Android ([^;]+);( (\\w+)-(\\w+);)?" +
@@ -1555,7 +1535,7 @@ public class AwSettingsTest extends AwTestBase {
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentClient);
final AwContents awContents = testContainerView.getAwContents();
- ContentSettings settings = getContentSettingsOnUiThread(awContents);
+ AwSettings settings = getAwSettingsOnUiThread(awContents);
final String defaultUserAgentString = settings.getUserAgentString();
// Check that an attempt to reset the default UA string has no effect.
@@ -1569,7 +1549,7 @@ public class AwSettingsTest extends AwTestBase {
assertEquals(defaultUserAgentString, settings.getUserAgentString());
// Set a custom UA string, verify that it can be reset back to default.
- final String customUserAgentString = "ContentSettingsTest";
+ final String customUserAgentString = "AwSettingsTest";
settings.setUserAgentString(customUserAgentString);
assertEquals(customUserAgentString, settings.getUserAgentString());
settings.setUserAgentString(null);
@@ -1587,10 +1567,10 @@ public class AwSettingsTest extends AwTestBase {
final AwContents awContents = testContainerView.getAwContents();
final ContentViewCore contentView = testContainerView.getContentViewCore();
CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHelper();
- ContentSettings settings = getContentSettingsOnUiThread(awContents);
+ AwSettings settings = getAwSettingsOnUiThread(awContents);
settings.setJavaScriptEnabled(true);
final String defaultUserAgentString = settings.getUserAgentString();
- final String customUserAgentString = "ContentSettingsTest";
+ final String customUserAgentString = "AwSettingsTest";
// We are using different page titles to make sure that we are really
// going back and forward between them.
final String pageTemplate =
@@ -1634,7 +1614,7 @@ public class AwSettingsTest extends AwTestBase {
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentClient);
AwContents awContents = testContainerView.getAwContents();
- ContentSettings settings = getContentSettingsOnUiThread(awContents);
+ AwSettings settings = getAwSettingsOnUiThread(awContents);
final String customUserAgentString =
"testUserAgentWithTestServerUserAgent";
@@ -1731,7 +1711,7 @@ public class AwSettingsTest extends AwTestBase {
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentClient);
final AwContents awContents = testContainerView.getAwContents();
- ContentSettings settings = getContentSettingsOnUiThread(awContents);
+ AwSettings settings = getAwSettingsOnUiThread(awContents);
settings.setJavaScriptEnabled(true);
settings.setAllowUniversalAccessFromFileURLs(false);
settings.setAllowFileAccessFromFileURLs(false);
@@ -1819,7 +1799,7 @@ public class AwSettingsTest extends AwTestBase {
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentClient);
final AwContents awContents = testContainerView.getAwContents();
- final ContentSettings settings = getContentSettingsOnUiThread(awContents);
+ final AwSettings settings = getAwSettingsOnUiThread(awContents);
ImagePageGenerator generator = new ImagePageGenerator(0, false);
settings.setJavaScriptEnabled(true);
@@ -1839,7 +1819,7 @@ public class AwSettingsTest extends AwTestBase {
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentClient);
final AwContents awContents = testContainerView.getAwContents();
- final ContentSettings settings = getContentSettingsOnUiThread(awContents);
+ final AwSettings settings = getAwSettingsOnUiThread(awContents);
settings.setJavaScriptEnabled(true);
ImagePageGenerator generator = new ImagePageGenerator(0, false);
@@ -1885,9 +1865,8 @@ public class AwSettingsTest extends AwTestBase {
final AwTestContainerView testContainer =
createAwTestContainerViewOnMainSync(contentClient);
final AwContents awContents = testContainer.getAwContents();
- final ContentSettings contentSettings = getContentSettingsOnUiThread(awContents);
- final AwSettings awSettings = getAwSettingsOnUiThread(testContainer.getAwContents());
- contentSettings.setJavaScriptEnabled(true);
+ final AwSettings awSettings = getAwSettingsOnUiThread(awContents);
+ awSettings.setJavaScriptEnabled(true);
ImagePageGenerator generator = new ImagePageGenerator(0, false);
TestWebServer webServer = null;
@@ -2213,7 +2192,7 @@ public class AwSettingsTest extends AwTestBase {
final AwTestContainerView testContainer =
createAwTestContainerViewOnMainSync(contentClient);
final AwContents awContents = testContainer.getAwContents();
- final ContentSettings settings = getContentSettingsOnUiThread(awContents);
+ final AwSettings settings = getAwSettingsOnUiThread(awContents);
settings.setJavaScriptEnabled(true);
// Note that the cache isn't actually enabled until the call to setAppCachePath.
settings.setAppCacheEnabled(true);
@@ -2255,11 +2234,11 @@ public class AwSettingsTest extends AwTestBase {
// will take about 20 seconds.
ViewPair views = createViews();
- ContentSettings settings0 = getContentSettingsOnUiThread(views.getContents0());
+ AwSettings settings0 = getAwSettingsOnUiThread(views.getContents0());
settings0.setJavaScriptEnabled(true);
settings0.setAppCachePath("whatever");
settings0.setAppCacheEnabled(true);
- ContentSettings settings1 = getContentSettingsOnUiThread(views.getContents1());
+ AwSettings settings1 = getAwSettingsOnUiThread(views.getContents1());
settings1.setJavaScriptEnabled(true);
// AppCachePath setting is global, no need to set it for the second view.
settings1.setAppCacheEnabled(true);
@@ -2321,7 +2300,7 @@ public class AwSettingsTest extends AwTestBase {
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentClient);
final AwContents awContents = testContainerView.getAwContents();
- ContentSettings settings = getContentSettingsOnUiThread(awContents);
+ AwSettings settings = getAwSettingsOnUiThread(awContents);
CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHelper();
final String pageTemplate = "<html><head>%s</head>" +
@@ -2382,7 +2361,7 @@ public class AwSettingsTest extends AwTestBase {
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentClient);
final AwContents awContents = testContainerView.getAwContents();
- ContentSettings settings = getContentSettingsOnUiThread(awContents);
+ AwSettings settings = getAwSettingsOnUiThread(awContents);
CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHelper();
final String page = "<html><body>Page Text</body></html>";
@@ -2483,10 +2462,9 @@ public class AwSettingsTest extends AwTestBase {
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
- ContentSettings contentSettings =
- awContents.getContentViewCore().getContentSettings();
- contentSettings.setJavaScriptEnabled(true);
- contentSettings.setMediaPlaybackRequiresUserGesture(requiredUserGesture);
+ AwSettings awSettings = awContents.getSettings();
+ awSettings.setJavaScriptEnabled(true);
+ awSettings.setMediaPlaybackRequiresUserGesture(requiredUserGesture);
observer.register(awContents.getContentViewCore(), "javaObserver");
}
});
@@ -2546,9 +2524,8 @@ public class AwSettingsTest extends AwTestBase {
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
- ContentSettings contentSettings =
- awContents.getContentViewCore().getContentSettings();
- contentSettings.setDefaultVideoPosterURL(DEFAULT_VIDEO_POSTER_URL);
+ AwSettings awSettings = awContents.getSettings();
+ awSettings.setDefaultVideoPosterURL(DEFAULT_VIDEO_POSTER_URL);
}
});
VideoTestWebServer webServer = new VideoTestWebServer(
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwTargetDensityDpiTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwTargetDensityDpiTest.java
index 5b9a56d..92dfb61 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwTargetDensityDpiTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwTargetDensityDpiTest.java
@@ -6,8 +6,8 @@ package org.chromium.android_webview.test;
import android.test.suitebuilder.annotation.MediumTest;
import org.chromium.android_webview.AwContents;
+import org.chromium.android_webview.AwSettings;
import org.chromium.base.test.util.Feature;
-import org.chromium.content.browser.ContentSettings;
import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.ui.gfx.DeviceDisplayInfo;
@@ -20,7 +20,7 @@ public class AwTargetDensityDpiTest extends AwTestBase {
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentClient);
final AwContents awContents = testContainerView.getAwContents();
- ContentSettings settings = getContentSettingsOnUiThread(awContents);
+ AwSettings settings = getAwSettingsOnUiThread(awContents);
CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHelper();
final String pageTemplate = "<html><head>" +
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java
index 0c1d1e0..69a2c50a 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java
@@ -71,7 +71,7 @@ public class AwTestBase
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
- awContents.getContentViewCore().getContentSettings().setJavaScriptEnabled(true);
+ awContents.getSettings().setJavaScriptEnabled(true);
}
});
}
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/ClientAddMessageToConsoleTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/ClientAddMessageToConsoleTest.java
index e657915..0bd5467 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/ClientAddMessageToConsoleTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/ClientAddMessageToConsoleTest.java
@@ -37,7 +37,7 @@ public class ClientAddMessageToConsoleTest extends AwTestBase {
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
- mAwContents.getContentViewCore().getContentSettings().setJavaScriptEnabled(true);
+ mAwContents.getSettings().setJavaScriptEnabled(true);
}
});
}
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/ContentViewZoomTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/ContentViewZoomTest.java
index 7b0e769..e0da4d3 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/ContentViewZoomTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/ContentViewZoomTest.java
@@ -12,6 +12,7 @@ import android.view.View;
import android.view.ViewConfiguration;
import org.chromium.android_webview.AwContents;
+import org.chromium.android_webview.AwSettings;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
@@ -193,7 +194,7 @@ public class ContentViewZoomTest extends AwTestBase {
}
private void runMagnificationTest(boolean supportZoom) throws Throwable {
- getContentSettingsOnUiThread(mAwContents).setUseWideViewPort(true);
+ getAwSettingsOnUiThread(mAwContents).setUseWideViewPort(true);
loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
getZoomableHtml(), "text/html", false);
// It takes some time for scaling to settle down.
@@ -238,13 +239,13 @@ public class ContentViewZoomTest extends AwTestBase {
@SmallTest
@Feature({"AndroidWebView"})
public void testZoomUsingMultiTouch() throws Throwable {
- ContentSettings webSettings = getContentSettingsOnUiThread(mAwContents);
+ AwSettings webSettings = getAwSettingsOnUiThread(mAwContents);
webSettings.setUseWideViewPort(true);
loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
getZoomableHtml(), "text/html", false);
- assertTrue(webSettings.supportZoom());
- assertFalse(webSettings.getBuiltInZoomControls());
+ assertTrue(getContentSettingsOnUiThread(mAwContents).supportZoom());
+ assertFalse(getContentSettingsOnUiThread(mAwContents).getBuiltInZoomControls());
assertFalse(isMultiTouchZoomSupportedOnUiThread());
getContentSettingsOnUiThread(mAwContents).setBuiltInZoomControls(true);
@@ -261,14 +262,14 @@ public class ContentViewZoomTest extends AwTestBase {
*/
@FlakyTest
public void testZoomControls() throws Throwable {
- ContentSettings webSettings = getContentSettingsOnUiThread(mAwContents);
+ AwSettings webSettings = getAwSettingsOnUiThread(mAwContents);
webSettings.setUseWideViewPort(true);
loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
getZoomableHtml(), "text/html", false);
- assertTrue(webSettings.supportZoom());
- webSettings.setBuiltInZoomControls(true);
- webSettings.setDisplayZoomControls(false);
+ assertTrue(getContentSettingsOnUiThread(mAwContents).supportZoom());
+ getContentSettingsOnUiThread(mAwContents).setBuiltInZoomControls(true);
+ getContentSettingsOnUiThread(mAwContents).setDisplayZoomControls(false);
// With DisplayZoomControls set to false, attempts to display zoom
// controls must be ignored.
@@ -276,7 +277,7 @@ public class ContentViewZoomTest extends AwTestBase {
invokeZoomPickerOnUiThread();
assertNull(getZoomControlsOnUiThread());
- webSettings.setDisplayZoomControls(true);
+ getContentSettingsOnUiThread(mAwContents).setDisplayZoomControls(true);
assertNull(getZoomControlsOnUiThread());
invokeZoomPickerOnUiThread();
View zoomControls = getZoomControlsOnUiThread();
@@ -286,7 +287,7 @@ public class ContentViewZoomTest extends AwTestBase {
@SmallTest
@Feature({"AndroidWebView"})
public void testZoomControlsOnNonZoomableContent() throws Throwable {
- ContentSettings webSettings = getContentSettingsOnUiThread(mAwContents);
+ AwSettings webSettings = getAwSettingsOnUiThread(mAwContents);
webSettings.setUseWideViewPort(true);
loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
getNonZoomableHtml(), "text/html", false);
@@ -294,9 +295,9 @@ public class ContentViewZoomTest extends AwTestBase {
// ContentView must update itself according to the viewport setup.
waitUntilCanNotZoom();
- assertTrue(webSettings.supportZoom());
- webSettings.setBuiltInZoomControls(true);
- webSettings.setDisplayZoomControls(true);
+ assertTrue(getContentSettingsOnUiThread(mAwContents).supportZoom());
+ getContentSettingsOnUiThread(mAwContents).setBuiltInZoomControls(true);
+ getContentSettingsOnUiThread(mAwContents).setDisplayZoomControls(true);
assertNull(getZoomControlsOnUiThread());
invokeZoomPickerOnUiThread();
View zoomControls = getZoomControlsOnUiThread();
@@ -310,14 +311,14 @@ public class ContentViewZoomTest extends AwTestBase {
*/
@DisabledTest
public void testZoomControlsOnOrientationChange() throws Throwable {
- ContentSettings webSettings = getContentSettingsOnUiThread(mAwContents);
+ AwSettings webSettings = getAwSettingsOnUiThread(mAwContents);
webSettings.setUseWideViewPort(true);
loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
getZoomableHtml(), "text/html", false);
- assertTrue(webSettings.supportZoom());
- webSettings.setBuiltInZoomControls(true);
- webSettings.setDisplayZoomControls(true);
+ assertTrue(getContentSettingsOnUiThread(mAwContents).supportZoom());
+ getContentSettingsOnUiThread(mAwContents).setBuiltInZoomControls(true);
+ getContentSettingsOnUiThread(mAwContents).setDisplayZoomControls(true);
invokeZoomPickerOnUiThread();
// Now force an orientation change, and try to display the zoom picker
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java
index 744550a..cb5fe8e 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/CookieManagerTest.java
@@ -44,7 +44,7 @@ public class CookieManagerTest extends AwTestBase {
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(mContentsClient);
mAwContents = testContainerView.getAwContents();
- mAwContents.getContentViewCore().getContentSettings().setJavaScriptEnabled(true);
+ mAwContents.getSettings().setJavaScriptEnabled(true);
assertNotNull(mCookieManager);
}
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java
index c54051b..8871ebe 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java
@@ -9,10 +9,10 @@ import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.android_webview.AndroidProtocolHandler;
import org.chromium.android_webview.AwContents;
+import org.chromium.android_webview.AwSettings;
import org.chromium.android_webview.test.util.CommonResources;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
-import org.chromium.content.browser.ContentSettings;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.LoadUrlParams;
import org.chromium.content.browser.test.util.Criteria;
@@ -100,7 +100,7 @@ public class LoadDataWithBaseUrlTest extends AwTestBase {
webServer.setResponseBase64("/" + CommonResources.FAVICON_FILENAME,
CommonResources.FAVICON_DATA_BASE64, CommonResources.getImagePngHeaders(true));
- ContentSettings contentSettings = getContentSettingsOnUiThread(mAwContents);
+ AwSettings contentSettings = getAwSettingsOnUiThread(mAwContents);
contentSettings.setImagesEnabled(true);
contentSettings.setJavaScriptEnabled(true);
@@ -125,7 +125,7 @@ public class LoadDataWithBaseUrlTest extends AwTestBase {
CommonResources.getTextJavascriptHeaders(true));
final String pageHtml = getScriptFileTestPageHtml(scriptUrl);
- getContentSettingsOnUiThread(mAwContents).setJavaScriptEnabled(true);
+ getAwSettingsOnUiThread(mAwContents).setJavaScriptEnabled(true);
loadDataWithBaseUrlSync(pageHtml, "text/html", false, webServer.getBaseUrl(), null);
assertEquals(SCRIPT_LOADED, getTitleOnUiThread(mAwContents));
@@ -144,7 +144,7 @@ public class LoadDataWithBaseUrlTest extends AwTestBase {
CommonResources.ABOUT_HTML, CommonResources.getTextHtmlHeaders(true));
final String html = getCrossOriginAccessTestPageHtml(frameUrl);
- getContentSettingsOnUiThread(mAwContents).setJavaScriptEnabled(true);
+ getAwSettingsOnUiThread(mAwContents).setJavaScriptEnabled(true);
loadDataWithBaseUrlSync(html, "text/html", false, webServer.getBaseUrl(), null);
assertEquals(frameUrl, getTitleOnUiThread(mAwContents));
@@ -164,7 +164,7 @@ public class LoadDataWithBaseUrlTest extends AwTestBase {
final String html = getCrossOriginAccessTestPageHtml(frameUrl);
final String baseUrl = webServer.getBaseUrl().replaceFirst("localhost", "127.0.0.1");
- getContentSettingsOnUiThread(mAwContents).setJavaScriptEnabled(true);
+ getAwSettingsOnUiThread(mAwContents).setJavaScriptEnabled(true);
loadDataWithBaseUrlSync(html, "text/html", false, baseUrl, null);
// TODO(mnaganov): Catch a security exception and set the title accordingly,
@@ -179,7 +179,7 @@ public class LoadDataWithBaseUrlTest extends AwTestBase {
@SmallTest
@Feature({"AndroidWebView"})
public void testNullBaseUrl() throws Throwable {
- getContentSettingsOnUiThread(mAwContents).setJavaScriptEnabled(true);
+ getAwSettingsOnUiThread(mAwContents).setJavaScriptEnabled(true);
final String pageHtml = "<html><body onload='document.title=document.location.href'>" +
"</body></html>";
loadDataWithBaseUrlSync(pageHtml, "text/html", false, null, null);
@@ -294,7 +294,7 @@ public class LoadDataWithBaseUrlTest extends AwTestBase {
fos.close();
String imagePath = tempImage.getAbsolutePath();
- ContentSettings contentSettings = getContentSettingsOnUiThread(mAwContents);
+ AwSettings contentSettings = getAwSettingsOnUiThread(mAwContents);
contentSettings.setImagesEnabled(true);
contentSettings.setJavaScriptEnabled(true);
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/NavigationHistoryTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/NavigationHistoryTest.java
index 21118f9..ceac328 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/NavigationHistoryTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/NavigationHistoryTest.java
@@ -201,7 +201,7 @@ public class NavigationHistoryTest extends AwTestBase {
CommonResources.FAVICON_STATIC_HTML, null);
assertEquals(0, list.getEntryCount());
- getContentSettingsOnUiThread(mAwContents).setImagesEnabled(true);
+ getAwSettingsOnUiThread(mAwContents).setImagesEnabled(true);
loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), url);
list = getNavigationHistory(mAwContents);
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/UserAgentTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/UserAgentTest.java
index a69a96f..b2e0ba8 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/UserAgentTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/UserAgentTest.java
@@ -31,7 +31,7 @@ public class UserAgentTest extends AwTestBase {
@SmallTest
@Feature({"AndroidWebView"})
public void testNoExtraSpaceBeforeBuildName() throws Throwable {
- getContentSettingsOnUiThread(mAwContents).setJavaScriptEnabled(true);
+ getAwSettingsOnUiThread(mAwContents).setJavaScriptEnabled(true);
loadDataSync(
mAwContents,
mContentsClient.getOnPageFinishedHelper(),
diff --git a/android_webview/native/aw_settings.cc b/android_webview/native/aw_settings.cc
index 81ff074..9ef64f7 100644
--- a/android_webview/native/aw_settings.cc
+++ b/android_webview/native/aw_settings.cc
@@ -6,17 +6,134 @@
#include "android_webview/browser/renderer_host/aw_render_view_host_ext.h"
#include "android_webview/native/aw_contents.h"
+#include "base/android/jni_android.h"
+#include "base/android/jni_string.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/content_client.h"
#include "jni/AwSettings_jni.h"
#include "webkit/glue/webkit_glue.h"
+#include "webkit/glue/webpreferences.h"
+#include "webkit/user_agent/user_agent.h"
+
+using base::android::CheckException;
+using base::android::ConvertJavaStringToUTF16;
+using base::android::ConvertUTF16ToJavaString;
+using base::android::ConvertUTF8ToJavaString;
+using base::android::GetClass;
+using base::android::GetFieldID;
+using base::android::GetMethodIDFromClassName;
+using base::android::ScopedJavaLocalRef;
+using webkit_glue::WebPreferences;
namespace android_webview {
+struct AwSettings::FieldIds {
+ // Note on speed. One may think that an approach that reads field values via
+ // JNI is ineffective and should not be used. Please keep in mind that in the
+ // legacy WebView the whole Sync method took <1ms on Xoom, and no one is
+ // expected to modify settings in performance-critical code.
+ FieldIds() { }
+
+ FieldIds(JNIEnv* env) {
+ const char* kStringClassName = "Ljava/lang/String;";
+
+ // FIXME: we should be using a new GetFieldIDFromClassName() with caching.
+ ScopedJavaLocalRef<jclass> clazz(
+ GetClass(env, "org/chromium/android_webview/AwSettings"));
+ text_size_percent = GetFieldID(env, clazz, "mTextSizePercent", "I");
+ standard_fond_family =
+ GetFieldID(env, clazz, "mStandardFontFamily", kStringClassName);
+ fixed_font_family =
+ GetFieldID(env, clazz, "mFixedFontFamily", kStringClassName);
+ sans_serif_font_family =
+ GetFieldID(env, clazz, "mSansSerifFontFamily", kStringClassName);
+ serif_font_family =
+ GetFieldID(env, clazz, "mSerifFontFamily", kStringClassName);
+ cursive_font_family =
+ GetFieldID(env, clazz, "mCursiveFontFamily", kStringClassName);
+ fantasy_font_family =
+ GetFieldID(env, clazz, "mFantasyFontFamily", kStringClassName);
+ default_text_encoding =
+ GetFieldID(env, clazz, "mDefaultTextEncoding", kStringClassName);
+ user_agent =
+ GetFieldID(env, clazz, "mUserAgent", kStringClassName);
+ minimum_font_size = GetFieldID(env, clazz, "mMinimumFontSize", "I");
+ minimum_logical_font_size =
+ GetFieldID(env, clazz, "mMinimumLogicalFontSize", "I");
+ default_font_size = GetFieldID(env, clazz, "mDefaultFontSize", "I");
+ default_fixed_font_size =
+ GetFieldID(env, clazz, "mDefaultFixedFontSize", "I");
+ load_images_automatically =
+ GetFieldID(env, clazz, "mLoadsImagesAutomatically", "Z");
+ images_enabled =
+ GetFieldID(env, clazz, "mImagesEnabled", "Z");
+ java_script_enabled =
+ GetFieldID(env, clazz, "mJavaScriptEnabled", "Z");
+ allow_universal_access_from_file_urls =
+ GetFieldID(env, clazz, "mAllowUniversalAccessFromFileURLs", "Z");
+ allow_file_access_from_file_urls =
+ GetFieldID(env, clazz, "mAllowFileAccessFromFileURLs", "Z");
+ java_script_can_open_windows_automatically =
+ GetFieldID(env, clazz, "mJavaScriptCanOpenWindowsAutomatically", "Z");
+ support_multiple_windows =
+ GetFieldID(env, clazz, "mSupportMultipleWindows", "Z");
+ dom_storage_enabled =
+ GetFieldID(env, clazz, "mDomStorageEnabled", "Z");
+ database_enabled =
+ GetFieldID(env, clazz, "mDatabaseEnabled", "Z");
+ use_wide_viewport =
+ GetFieldID(env, clazz, "mUseWideViewport", "Z");
+ load_with_overview_mode =
+ GetFieldID(env, clazz, "mLoadWithOverviewMode", "Z");
+ media_playback_requires_user_gesture =
+ GetFieldID(env, clazz, "mMediaPlaybackRequiresUserGesture", "Z");
+ default_video_poster_url =
+ GetFieldID(env, clazz, "mDefaultVideoPosterURL", kStringClassName);
+ support_deprecated_target_density_dpi =
+ GetFieldID(env, clazz, "mSupportDeprecatedTargetDensityDPI", "Z");
+ dip_scale =
+ GetFieldID(env, clazz, "mDIPScale", "D");
+ initial_page_scale_percent =
+ GetFieldID(env, clazz, "mInitialPageScalePercent", "F");
+ }
+
+ // Field ids
+ jfieldID text_size_percent;
+ jfieldID standard_fond_family;
+ jfieldID fixed_font_family;
+ jfieldID sans_serif_font_family;
+ jfieldID serif_font_family;
+ jfieldID cursive_font_family;
+ jfieldID fantasy_font_family;
+ jfieldID default_text_encoding;
+ jfieldID user_agent;
+ jfieldID minimum_font_size;
+ jfieldID minimum_logical_font_size;
+ jfieldID default_font_size;
+ jfieldID default_fixed_font_size;
+ jfieldID load_images_automatically;
+ jfieldID images_enabled;
+ jfieldID java_script_enabled;
+ jfieldID allow_universal_access_from_file_urls;
+ jfieldID allow_file_access_from_file_urls;
+ jfieldID java_script_can_open_windows_automatically;
+ jfieldID support_multiple_windows;
+ jfieldID dom_storage_enabled;
+ jfieldID database_enabled;
+ jfieldID use_wide_viewport;
+ jfieldID load_with_overview_mode;
+ jfieldID media_playback_requires_user_gesture;
+ jfieldID default_video_poster_url;
+ jfieldID support_deprecated_target_density_dpi;
+ jfieldID dip_scale;
+ jfieldID initial_page_scale_percent;
+};
+
AwSettings::AwSettings(JNIEnv* env, jobject obj)
- : java_ref_(env, obj),
- initial_page_scale_percent_(0),
- text_zoom_percent_(100) {
+ : aw_settings_(env, obj) {
}
AwSettings::~AwSettings() {
@@ -39,69 +156,208 @@ void AwSettings::ResetScrollAndScaleState(JNIEnv* env, jobject obj) {
rvhe->ResetScrollAndScaleState();
}
-void AwSettings::SetInitialPageScale(
- JNIEnv* env, jobject obj, jfloat page_scale_percent) {
- if (initial_page_scale_percent_ == page_scale_percent) return;
- initial_page_scale_percent_ = page_scale_percent;
- UpdateInitialPageScale();
-}
-
-void AwSettings::SetTextZoom(JNIEnv* env, jobject obj, jint text_zoom_percent) {
- if (text_zoom_percent_ == text_zoom_percent) return;
- text_zoom_percent_ = text_zoom_percent;
- UpdateTextZoom();
-}
-
void AwSettings::SetWebContents(JNIEnv* env, jobject obj, jint jweb_contents) {
content::WebContents* web_contents =
reinterpret_cast<content::WebContents*>(jweb_contents);
Observe(web_contents);
- UpdateRenderViewHostExtSettings();
- if (web_contents->GetRenderViewHost()) {
- UpdateRenderViewHostSettings(web_contents->GetRenderViewHost());
- }
+ UpdateEverything(env, obj);
}
-void AwSettings::UpdateInitialPageScale() {
- AwRenderViewHostExt* rvhe = GetAwRenderViewHostExt();
- if (!rvhe) return;
- if (initial_page_scale_percent_ == 0) {
- rvhe->SetInitialPageScale(-1);
+void AwSettings::UpdateEverything() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ CHECK(env);
+ ScopedJavaLocalRef<jobject> scoped_obj = aw_settings_.get(env);
+ jobject obj = scoped_obj.obj();
+ if (!obj) return;
+ UpdateEverything(env, obj);
+}
+
+void AwSettings::UpdateEverything(JNIEnv* env, jobject obj) {
+ UpdateInitialPageScale(env, obj);
+ UpdateWebkitPreferences(env, obj);
+ UpdateUserAgent(env, obj);
+ ResetScrollAndScaleState(env, obj);
+ UpdatePreferredSizeMode();
+}
+
+void AwSettings::UpdateUserAgent(JNIEnv* env, jobject obj) {
+ if (!web_contents()) return;
+
+ if (!field_ids_)
+ field_ids_.reset(new FieldIds(env));
+
+ ScopedJavaLocalRef<jstring> str(env, static_cast<jstring>(
+ env->GetObjectField(obj, field_ids_->user_agent)));
+ std::string override = base::android::ConvertJavaStringToUTF8(str);
+ web_contents()->SetUserAgentOverride(override);
+
+ const content::NavigationController& controller =
+ web_contents()->GetController();
+ for (int i = 0; i < controller.GetEntryCount(); ++i)
+ controller.GetEntryAtIndex(i)->SetIsOverridingUserAgent(true);
+}
+
+void AwSettings::UpdateWebkitPreferences(JNIEnv* env, jobject obj) {
+ if (!web_contents()) return;
+ AwRenderViewHostExt* render_view_host_ext = GetAwRenderViewHostExt();
+ if (!render_view_host_ext) return;
+
+ if (!field_ids_)
+ field_ids_.reset(new FieldIds(env));
+
+ content::RenderViewHost* render_view_host =
+ web_contents()->GetRenderViewHost();
+ if (!render_view_host) return;
+ WebPreferences prefs = render_view_host->GetWebkitPreferences();
+
+ prefs.text_autosizing_enabled =
+ Java_AwSettings_getTextAutosizingEnabled(env, obj);
+
+ int text_size_percent = env->GetIntField(obj, field_ids_->text_size_percent);
+ if (prefs.text_autosizing_enabled) {
+ prefs.font_scale_factor = text_size_percent / 100.0f;
+ prefs.force_enable_zoom = text_size_percent >= 130;
+ // Use the default zoom level value when Text Autosizer is turned on.
+ render_view_host_ext->SetTextZoomLevel(0);
} else {
- rvhe->SetInitialPageScale(initial_page_scale_percent_ / 100.0f);
+ prefs.force_enable_zoom = false;
+ render_view_host_ext->SetTextZoomLevel(webkit_glue::ZoomFactorToZoomLevel(
+ text_size_percent / 100.0f));
}
+
+ ScopedJavaLocalRef<jstring> str(
+ env, static_cast<jstring>(
+ env->GetObjectField(obj, field_ids_->standard_fond_family)));
+ prefs.standard_font_family_map[WebPreferences::kCommonScript] =
+ ConvertJavaStringToUTF16(str);
+
+ str.Reset(
+ env, static_cast<jstring>(
+ env->GetObjectField(obj, field_ids_->fixed_font_family)));
+ prefs.fixed_font_family_map[WebPreferences::kCommonScript] =
+ ConvertJavaStringToUTF16(str);
+
+ str.Reset(
+ env, static_cast<jstring>(
+ env->GetObjectField(obj, field_ids_->sans_serif_font_family)));
+ prefs.sans_serif_font_family_map[WebPreferences::kCommonScript] =
+ ConvertJavaStringToUTF16(str);
+
+ str.Reset(
+ env, static_cast<jstring>(
+ env->GetObjectField(obj, field_ids_->serif_font_family)));
+ prefs.serif_font_family_map[WebPreferences::kCommonScript] =
+ ConvertJavaStringToUTF16(str);
+
+ str.Reset(
+ env, static_cast<jstring>(
+ env->GetObjectField(obj, field_ids_->cursive_font_family)));
+ prefs.cursive_font_family_map[WebPreferences::kCommonScript] =
+ ConvertJavaStringToUTF16(str);
+
+ str.Reset(
+ env, static_cast<jstring>(
+ env->GetObjectField(obj, field_ids_->fantasy_font_family)));
+ prefs.fantasy_font_family_map[WebPreferences::kCommonScript] =
+ ConvertJavaStringToUTF16(str);
+
+ str.Reset(
+ env, static_cast<jstring>(
+ env->GetObjectField(obj, field_ids_->default_text_encoding)));
+ prefs.default_encoding = ConvertJavaStringToUTF8(str);
+
+ prefs.minimum_font_size =
+ env->GetIntField(obj, field_ids_->minimum_font_size);
+
+ prefs.minimum_logical_font_size =
+ env->GetIntField(obj, field_ids_->minimum_logical_font_size);
+
+ prefs.default_font_size =
+ env->GetIntField(obj, field_ids_->default_font_size);
+
+ prefs.default_fixed_font_size =
+ env->GetIntField(obj, field_ids_->default_fixed_font_size);
+
+ prefs.loads_images_automatically =
+ env->GetBooleanField(obj, field_ids_->load_images_automatically);
+
+ prefs.images_enabled =
+ env->GetBooleanField(obj, field_ids_->images_enabled);
+
+ prefs.javascript_enabled =
+ env->GetBooleanField(obj, field_ids_->java_script_enabled);
+
+ prefs.allow_universal_access_from_file_urls = env->GetBooleanField(
+ obj, field_ids_->allow_universal_access_from_file_urls);
+
+ prefs.allow_file_access_from_file_urls = env->GetBooleanField(
+ obj, field_ids_->allow_file_access_from_file_urls);
+
+ prefs.javascript_can_open_windows_automatically = env->GetBooleanField(
+ obj, field_ids_->java_script_can_open_windows_automatically);
+
+ prefs.supports_multiple_windows = env->GetBooleanField(
+ obj, field_ids_->support_multiple_windows);
+
+ prefs.plugins_enabled = !Java_AwSettings_getPluginsDisabled(env, obj);
+
+ prefs.application_cache_enabled =
+ Java_AwSettings_getAppCacheEnabled(env, obj);
+
+ prefs.local_storage_enabled = env->GetBooleanField(
+ obj, field_ids_->dom_storage_enabled);
+
+ prefs.databases_enabled = env->GetBooleanField(
+ obj, field_ids_->database_enabled);
+
+ prefs.double_tap_to_zoom_enabled = prefs.use_wide_viewport =
+ env->GetBooleanField(obj, field_ids_->use_wide_viewport);
+
+ prefs.initialize_at_minimum_page_scale = env->GetBooleanField(
+ obj, field_ids_->load_with_overview_mode);
+
+ prefs.user_gesture_required_for_media_playback = env->GetBooleanField(
+ obj, field_ids_->media_playback_requires_user_gesture);
+
+ str.Reset(
+ env, static_cast<jstring>(
+ env->GetObjectField(obj, field_ids_->default_video_poster_url)));
+ prefs.default_video_poster_url = str.obj() ?
+ GURL(ConvertJavaStringToUTF8(str)) : GURL();
+
+ prefs.support_deprecated_target_density_dpi = env->GetBooleanField(
+ obj, field_ids_->support_deprecated_target_density_dpi);
+
+ render_view_host->UpdateWebkitPreferences(prefs);
}
-void AwSettings::UpdateTextZoom() {
+void AwSettings::UpdateInitialPageScale(JNIEnv* env, jobject obj) {
AwRenderViewHostExt* rvhe = GetAwRenderViewHostExt();
if (!rvhe) return;
- if (text_zoom_percent_ > 0) {
- rvhe->SetTextZoomLevel(webkit_glue::ZoomFactorToZoomLevel(
- text_zoom_percent_ / 100.0f));
- } else {
- // Use the default zoom level value when Text Autosizer is turned on.
- rvhe->SetTextZoomLevel(0);
- }
-}
-void AwSettings::UpdatePreferredSizeMode(
- content::RenderViewHost* render_view_host) {
- render_view_host->EnablePreferredSizeMode();
-}
+ if (!field_ids_)
+ field_ids_.reset(new FieldIds(env));
-void AwSettings::UpdateRenderViewHostExtSettings() {
- UpdateInitialPageScale();
- UpdateTextZoom();
+ float initial_page_scale_percent =
+ env->GetFloatField(obj, field_ids_->initial_page_scale_percent);
+ if (initial_page_scale_percent == 0) {
+ rvhe->SetInitialPageScale(-1);
+ } else {
+ float dip_scale = static_cast<float>(
+ env->GetDoubleField(obj, field_ids_->dip_scale));
+ rvhe->SetInitialPageScale(initial_page_scale_percent / dip_scale / 100.0f);
+ }
}
-void AwSettings::UpdateRenderViewHostSettings(
- content::RenderViewHost* render_view_host) {
- UpdatePreferredSizeMode(render_view_host);
+void AwSettings::UpdatePreferredSizeMode() {
+ if (web_contents()->GetRenderViewHost()) {
+ web_contents()->GetRenderViewHost()->EnablePreferredSizeMode();
+ }
}
void AwSettings::RenderViewCreated(content::RenderViewHost* render_view_host) {
- // A single WebContents can normally have 0, 1 or 2 RenderViewHost instances
+ // A single WebContents can normally have 0 to many RenderViewHost instances
// associated with it.
// This is important since there is only one RenderViewHostExt instance per
// WebContents (and not one RVHExt per RVH, as you might expect) and updating
@@ -112,8 +368,7 @@ void AwSettings::RenderViewCreated(content::RenderViewHost* render_view_host) {
// (since we only ever go from 0 to 1 RVH instances) and hence the DCHECK.
DCHECK(web_contents()->GetRenderViewHost() == render_view_host);
- UpdateRenderViewHostExtSettings();
- UpdateRenderViewHostSettings(render_view_host);
+ UpdateEverything();
}
static jint Init(JNIEnv* env,
@@ -124,6 +379,11 @@ static jint Init(JNIEnv* env,
return reinterpret_cast<jint>(settings);
}
+static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) {
+ return base::android::ConvertUTF8ToJavaString(
+ env, content::GetUserAgent(GURL())).Release();
+}
+
bool RegisterAwSettings(JNIEnv* env) {
return RegisterNativesImpl(env) >= 0;
}
diff --git a/android_webview/native/aw_settings.h b/android_webview/native/aw_settings.h
index a8658c8..d24df56 100644
--- a/android_webview/native/aw_settings.h
+++ b/android_webview/native/aw_settings.h
@@ -9,6 +9,7 @@
#include "base/android/jni_helper.h"
#include "base/android/scoped_java_ref.h"
+#include "base/memory/scoped_ptr.h"
#include "content/public/browser/web_contents_observer.h"
namespace android_webview {
@@ -23,25 +24,27 @@ class AwSettings : public content::WebContentsObserver {
// Called from Java.
void Destroy(JNIEnv* env, jobject obj);
void ResetScrollAndScaleState(JNIEnv* env, jobject obj);
- void SetInitialPageScale(JNIEnv* env, jobject obj, jfloat page_scale_percent);
- void SetTextZoom(JNIEnv* env, jobject obj, jint text_zoom_percent);
void SetWebContents(JNIEnv* env, jobject obj, jint web_contents);
+ void UpdateEverything(JNIEnv* env, jobject obj);
+ void UpdateInitialPageScale(JNIEnv* env, jobject obj);
+ void UpdateUserAgent(JNIEnv* env, jobject obj);
+ void UpdateWebkitPreferences(JNIEnv* env, jobject obj);
private:
+ struct FieldIds;
+
AwRenderViewHostExt* GetAwRenderViewHostExt();
- void UpdateInitialPageScale();
- void UpdateTextZoom();
- void UpdatePreferredSizeMode(content::RenderViewHost* render_view_host);
- void UpdateRenderViewHostExtSettings();
- void UpdateRenderViewHostSettings(content::RenderViewHost* render_view_host);
+ void UpdateEverything();
+ void UpdatePreferredSizeMode();
// WebContentsObserver overrides:
virtual void RenderViewCreated(
content::RenderViewHost* render_view_host) OVERRIDE;
- JavaObjectWeakGlobalRef java_ref_;
- float initial_page_scale_percent_;
- int text_zoom_percent_;
+ // Java field references for accessing the values in the Java object.
+ scoped_ptr<FieldIds> field_ids_;
+
+ JavaObjectWeakGlobalRef aw_settings_;
};
bool RegisterAwSettings(JNIEnv* env);
diff --git a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java
index 783ade5..e2d6dcf 100644
--- a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java
+++ b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java
@@ -88,7 +88,7 @@ public class AwShellActivity extends Activity {
testContainerView.initialize(new AwContents(browserContext, testContainerView,
testContainerView.getInternalAccessDelegate(),
awContentsClient, false));
- testContainerView.getContentViewCore().getContentSettings().setJavaScriptEnabled(true);
+ testContainerView.getAwContents().getSettings().setJavaScriptEnabled(true);
return testContainerView;
}
diff --git a/build/android/findbugs_filter/findbugs_known_bugs.txt b/build/android/findbugs_filter/findbugs_known_bugs.txt
index cb37ca2..c0fe27f 100644
--- a/build/android/findbugs_filter/findbugs_known_bugs.txt
+++ b/build/android/findbugs_filter/findbugs_known_bugs.txt
@@ -29,7 +29,6 @@ M D SF: Switch statement found in org.chromium.chrome.browser.ChromeBrowserProvi
M D SF: Switch statement found in org.chromium.chrome.browser.database.SQLiteCursor.fillWindow(int, CursorWindow) where default case is missing At SQLiteCursor.java
M D SF: Switch statement found in org.chromium.content.browser.ContentSettings$EventHandler$1.handleMessage(Message) where default case is missing At ContentSettings.java
M D SF: Switch statement found in org.chromium.content.browser.third_party.GestureDetector.onTouchEvent(MotionEvent) where default case is missing At GestureDetector.java
-M D ST: Write to static field org.chromium.content.browser.ContentSettings.sAppCachePathIsSet from instance method org.chromium.content.browser.ContentSettings.setAppCachePath(String) At ContentSettings.java
M M LI: Incorrect lazy initialization and update of static field org.chromium.content.browser.ContentVideoView.sContentVideoView in org.chromium.content.browser.ContentVideoView.createContentVideoView(int) At ContentVideoView.java
M M UG: org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.getBooleanValue() is unsynchronized, org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.setBooleanValue(boolean) is synchronized At JavaBridgeReturnValuesTest.java
M M UG: org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.getStringValue() is unsynchronized, org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.setStringValue(String) is synchronized At JavaBridgeReturnValuesTest.java
diff --git a/content/browser/android/content_settings.cc b/content/browser/android/content_settings.cc
index 8ac82cb..e82b014 100644
--- a/content/browser/android/content_settings.cc
+++ b/content/browser/android/content_settings.cc
@@ -5,7 +5,6 @@
#include "content/browser/android/content_settings.h"
#include "base/android/jni_android.h"
-#include "base/android/jni_string.h"
#include "content/browser/android/content_view_core_impl.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
@@ -14,122 +13,31 @@
#include "jni/ContentSettings_jni.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webpreferences.h"
-#include "webkit/user_agent/user_agent.h"
-using base::android::CheckException;
-using base::android::ConvertJavaStringToUTF16;
-using base::android::ConvertUTF16ToJavaString;
-using base::android::ConvertUTF8ToJavaString;
-using base::android::GetClass;
using base::android::GetFieldID;
-using base::android::GetMethodIDFromClassName;
using base::android::ScopedJavaLocalRef;
-using webkit_glue::WebPreferences;
namespace content {
struct ContentSettings::FieldIds {
- // Note on speed. One may think that an approach that reads field values via
- // JNI is ineffective and should not be used. Please keep in mind that in the
- // legacy WebView the whole Sync method took <1ms on Xoom, and no one is
- // expected to modify settings in performance-critical code.
FieldIds() { }
FieldIds(JNIEnv* env) {
- const char* kStringClassName = "Ljava/lang/String;";
-
// FIXME: we should be using a new GetFieldIDFromClassName() with caching.
- ScopedJavaLocalRef<jclass> clazz(
- GetClass(env, "org/chromium/content/browser/ContentSettings"));
- text_size_percent = GetFieldID(env, clazz, "mTextSizePercent", "I");
- standard_fond_family =
- GetFieldID(env, clazz, "mStandardFontFamily", kStringClassName);
- fixed_font_family =
- GetFieldID(env, clazz, "mFixedFontFamily", kStringClassName);
- sans_serif_font_family =
- GetFieldID(env, clazz, "mSansSerifFontFamily", kStringClassName);
- serif_font_family =
- GetFieldID(env, clazz, "mSerifFontFamily", kStringClassName);
- cursive_font_family =
- GetFieldID(env, clazz, "mCursiveFontFamily", kStringClassName);
- fantasy_font_family =
- GetFieldID(env, clazz, "mFantasyFontFamily", kStringClassName);
- default_text_encoding =
- GetFieldID(env, clazz, "mDefaultTextEncoding", kStringClassName);
- user_agent =
- GetFieldID(env, clazz, "mUserAgent", kStringClassName);
- minimum_font_size = GetFieldID(env, clazz, "mMinimumFontSize", "I");
- minimum_logical_font_size =
- GetFieldID(env, clazz, "mMinimumLogicalFontSize", "I");
- default_font_size = GetFieldID(env, clazz, "mDefaultFontSize", "I");
- default_fixed_font_size =
- GetFieldID(env, clazz, "mDefaultFixedFontSize", "I");
- load_images_automatically =
- GetFieldID(env, clazz, "mLoadsImagesAutomatically", "Z");
- images_enabled =
- GetFieldID(env, clazz, "mImagesEnabled", "Z");
+ ScopedJavaLocalRef<jclass> clazz(base::android::GetClass(
+ env, "org/chromium/content/browser/ContentSettings"));
java_script_enabled =
GetFieldID(env, clazz, "mJavaScriptEnabled", "Z");
- allow_universal_access_from_file_urls =
- GetFieldID(env, clazz, "mAllowUniversalAccessFromFileURLs", "Z");
- allow_file_access_from_file_urls =
- GetFieldID(env, clazz, "mAllowFileAccessFromFileURLs", "Z");
- java_script_can_open_windows_automatically =
- GetFieldID(env, clazz, "mJavaScriptCanOpenWindowsAutomatically", "Z");
- support_multiple_windows =
- GetFieldID(env, clazz, "mSupportMultipleWindows", "Z");
- dom_storage_enabled =
- GetFieldID(env, clazz, "mDomStorageEnabled", "Z");
- database_enabled =
- GetFieldID(env, clazz, "mDatabaseEnabled", "Z");
- use_wide_viewport =
- GetFieldID(env, clazz, "mUseWideViewport", "Z");
- load_with_overview_mode =
- GetFieldID(env, clazz, "mLoadWithOverviewMode", "Z");
- media_playback_requires_user_gesture =
- GetFieldID(env, clazz, "mMediaPlaybackRequiresUserGesture", "Z");
- default_video_poster_url =
- GetFieldID(env, clazz, "mDefaultVideoPosterURL", kStringClassName);
- support_deprecated_target_density_dpi =
- GetFieldID(env, clazz, "mSupportDeprecatedTargetDensityDPI", "Z");
}
// Field ids
- jfieldID text_size_percent;
- jfieldID standard_fond_family;
- jfieldID fixed_font_family;
- jfieldID sans_serif_font_family;
- jfieldID serif_font_family;
- jfieldID cursive_font_family;
- jfieldID fantasy_font_family;
- jfieldID default_text_encoding;
- jfieldID user_agent;
- jfieldID minimum_font_size;
- jfieldID minimum_logical_font_size;
- jfieldID default_font_size;
- jfieldID default_fixed_font_size;
- jfieldID load_images_automatically;
- jfieldID images_enabled;
jfieldID java_script_enabled;
- jfieldID allow_universal_access_from_file_urls;
- jfieldID allow_file_access_from_file_urls;
- jfieldID java_script_can_open_windows_automatically;
- jfieldID support_multiple_windows;
- jfieldID dom_storage_enabled;
- jfieldID database_enabled;
- jfieldID use_wide_viewport;
- jfieldID load_with_overview_mode;
- jfieldID media_playback_requires_user_gesture;
- jfieldID default_video_poster_url;
- jfieldID support_deprecated_target_density_dpi;
};
ContentSettings::ContentSettings(JNIEnv* env,
jobject obj,
- WebContents* contents,
- bool is_master_mode)
+ WebContents* contents)
: WebContentsObserver(contents),
- is_master_mode_(is_master_mode),
content_settings_(env, obj) {
}
@@ -158,314 +66,29 @@ void ContentSettings::SyncFromNativeImpl() {
if (!obj)
return;
RenderViewHost* render_view_host = web_contents()->GetRenderViewHost();
- WebPreferences prefs = render_view_host->GetDelegate()->GetWebkitPrefs();
-
- Java_ContentSettings_setTextAutosizingEnabled(
- env, obj, prefs.text_autosizing_enabled);
- CheckException(env);
-
- env->SetIntField(
- obj,
- field_ids_->text_size_percent,
- prefs.font_scale_factor * 100.0f);
- CheckException(env);
-
- ScopedJavaLocalRef<jstring> str =
- ConvertUTF16ToJavaString(env,
- prefs.standard_font_family_map[WebPreferences::kCommonScript]);
- env->SetObjectField(obj, field_ids_->standard_fond_family, str.obj());
- CheckException(env);
-
- str.Reset(ConvertUTF16ToJavaString(env,
- prefs.fixed_font_family_map[WebPreferences::kCommonScript]));
- env->SetObjectField(obj, field_ids_->fixed_font_family, str.obj());
- CheckException(env);
-
- str.Reset(ConvertUTF16ToJavaString(env,
- prefs.sans_serif_font_family_map[WebPreferences::kCommonScript]));
- env->SetObjectField(obj, field_ids_->sans_serif_font_family, str.obj());
- CheckException(env);
-
- str.Reset(ConvertUTF16ToJavaString(env,
- prefs.serif_font_family_map[WebPreferences::kCommonScript]));
- env->SetObjectField(obj, field_ids_->serif_font_family, str.obj());
- CheckException(env);
-
- str.Reset(ConvertUTF16ToJavaString(env,
- prefs.cursive_font_family_map[WebPreferences::kCommonScript]));
- env->SetObjectField(obj, field_ids_->cursive_font_family, str.obj());
- CheckException(env);
-
- str.Reset(ConvertUTF16ToJavaString(env,
- prefs.fantasy_font_family_map[WebPreferences::kCommonScript]));
- env->SetObjectField(obj, field_ids_->fantasy_font_family, str.obj());
- CheckException(env);
-
- str.Reset(ConvertUTF8ToJavaString(env, prefs.default_encoding));
- env->SetObjectField(obj, field_ids_->default_text_encoding, str.obj());
- CheckException(env);
-
- str.Reset(ConvertUTF8ToJavaString(env, webkit_glue::GetUserAgent(GURL(""))));
- env->SetObjectField(obj, field_ids_->user_agent, str.obj());
- CheckException(env);
-
- env->SetIntField(obj, field_ids_->minimum_font_size,
- prefs.minimum_font_size);
- CheckException(env);
-
- env->SetIntField(
- obj,
- field_ids_->minimum_logical_font_size, prefs.minimum_logical_font_size);
- CheckException(env);
-
- env->SetIntField(obj, field_ids_->default_font_size,
- prefs.default_font_size);
- CheckException(env);
-
- env->SetIntField(
- obj, field_ids_->default_fixed_font_size, prefs.default_fixed_font_size);
- CheckException(env);
-
- env->SetBooleanField(
- obj,
- field_ids_->load_images_automatically, prefs.loads_images_automatically);
- CheckException(env);
-
- env->SetBooleanField(
- obj,
- field_ids_->images_enabled, prefs.images_enabled);
- CheckException(env);
+ webkit_glue::WebPreferences prefs =
+ render_view_host->GetDelegate()->GetWebkitPrefs();
env->SetBooleanField(
obj, field_ids_->java_script_enabled, prefs.javascript_enabled);
- CheckException(env);
-
- env->SetBooleanField(
- obj,
- field_ids_->allow_universal_access_from_file_urls,
- prefs.allow_universal_access_from_file_urls);
- CheckException(env);
-
- env->SetBooleanField(
- obj,
- field_ids_->allow_file_access_from_file_urls,
- prefs.allow_file_access_from_file_urls);
- CheckException(env);
-
- env->SetBooleanField(
- obj,
- field_ids_->java_script_can_open_windows_automatically,
- prefs.javascript_can_open_windows_automatically);
- CheckException(env);
-
- env->SetBooleanField(
- obj,
- field_ids_->support_multiple_windows,
- prefs.supports_multiple_windows);
- CheckException(env);
-
- Java_ContentSettings_setPluginsDisabled(env, obj, !prefs.plugins_enabled);
- CheckException(env);
-
- // We don't need to sync AppCache settings to Java, because there are
- // no getters for them in the API.
-
- env->SetBooleanField(
- obj,
- field_ids_->dom_storage_enabled,
- prefs.local_storage_enabled);
- CheckException(env);
-
- env->SetBooleanField(
- obj,
- field_ids_->database_enabled,
- prefs.databases_enabled);
- CheckException(env);
-
- env->SetBooleanField(
- obj,
- field_ids_->use_wide_viewport,
- prefs.use_wide_viewport);
- CheckException(env);
-
- env->SetBooleanField(
- obj,
- field_ids_->load_with_overview_mode,
- prefs.initialize_at_minimum_page_scale);
- CheckException(env);
-
- env->SetBooleanField(
- obj,
- field_ids_->media_playback_requires_user_gesture,
- prefs.user_gesture_required_for_media_playback);
- CheckException(env);
-
- str.Reset(
- ConvertUTF8ToJavaString(env, prefs.default_video_poster_url.spec()));
- env->SetObjectField(obj, field_ids_->default_video_poster_url, str.obj());
- CheckException(env);
-}
-
-void ContentSettings::SyncToNativeImpl() {
- JNIEnv* env = base::android::AttachCurrentThread();
- CHECK(env);
- if (!field_ids_)
- field_ids_.reset(new FieldIds(env));
-
- ScopedJavaLocalRef<jobject> scoped_obj = content_settings_.get(env);
- jobject obj = scoped_obj.obj();
- if (!obj)
- return;
- RenderViewHost* render_view_host = web_contents()->GetRenderViewHost();
- WebPreferences prefs = render_view_host->GetDelegate()->GetWebkitPrefs();
-
- prefs.text_autosizing_enabled =
- Java_ContentSettings_getTextAutosizingEnabled(env, obj);
-
- int text_size_percent = env->GetIntField(obj, field_ids_->text_size_percent);
- if (prefs.text_autosizing_enabled) {
- prefs.font_scale_factor = text_size_percent / 100.0f;
- prefs.force_enable_zoom = text_size_percent >= 130;
- } else {
- prefs.force_enable_zoom = false;
- }
-
- ScopedJavaLocalRef<jstring> str(
- env, static_cast<jstring>(
- env->GetObjectField(obj, field_ids_->standard_fond_family)));
- prefs.standard_font_family_map[WebPreferences::kCommonScript] =
- ConvertJavaStringToUTF16(str);
-
- str.Reset(
- env, static_cast<jstring>(
- env->GetObjectField(obj, field_ids_->fixed_font_family)));
- prefs.fixed_font_family_map[WebPreferences::kCommonScript] =
- ConvertJavaStringToUTF16(str);
-
- str.Reset(
- env, static_cast<jstring>(
- env->GetObjectField(obj, field_ids_->sans_serif_font_family)));
- prefs.sans_serif_font_family_map[WebPreferences::kCommonScript] =
- ConvertJavaStringToUTF16(str);
-
- str.Reset(
- env, static_cast<jstring>(
- env->GetObjectField(obj, field_ids_->serif_font_family)));
- prefs.serif_font_family_map[WebPreferences::kCommonScript] =
- ConvertJavaStringToUTF16(str);
-
- str.Reset(
- env, static_cast<jstring>(
- env->GetObjectField(obj, field_ids_->cursive_font_family)));
- prefs.cursive_font_family_map[WebPreferences::kCommonScript] =
- ConvertJavaStringToUTF16(str);
-
- str.Reset(
- env, static_cast<jstring>(
- env->GetObjectField(obj, field_ids_->fantasy_font_family)));
- prefs.fantasy_font_family_map[WebPreferences::kCommonScript] =
- ConvertJavaStringToUTF16(str);
-
- str.Reset(
- env, static_cast<jstring>(
- env->GetObjectField(obj, field_ids_->default_text_encoding)));
- prefs.default_encoding = ConvertJavaStringToUTF8(str);
-
- prefs.minimum_font_size =
- env->GetIntField(obj, field_ids_->minimum_font_size);
-
- prefs.minimum_logical_font_size =
- env->GetIntField(obj, field_ids_->minimum_logical_font_size);
-
- prefs.default_font_size =
- env->GetIntField(obj, field_ids_->default_font_size);
-
- prefs.default_fixed_font_size =
- env->GetIntField(obj, field_ids_->default_fixed_font_size);
-
- prefs.loads_images_automatically =
- env->GetBooleanField(obj, field_ids_->load_images_automatically);
-
- prefs.images_enabled =
- env->GetBooleanField(obj, field_ids_->images_enabled);
-
- prefs.javascript_enabled =
- env->GetBooleanField(obj, field_ids_->java_script_enabled);
-
- prefs.allow_universal_access_from_file_urls = env->GetBooleanField(
- obj, field_ids_->allow_universal_access_from_file_urls);
-
- prefs.allow_file_access_from_file_urls = env->GetBooleanField(
- obj, field_ids_->allow_file_access_from_file_urls);
-
- prefs.javascript_can_open_windows_automatically = env->GetBooleanField(
- obj, field_ids_->java_script_can_open_windows_automatically);
-
- prefs.supports_multiple_windows = env->GetBooleanField(
- obj, field_ids_->support_multiple_windows);
-
- prefs.plugins_enabled = !Java_ContentSettings_getPluginsDisabled(env, obj);
-
- prefs.application_cache_enabled =
- Java_ContentSettings_getAppCacheEnabled(env, obj);
-
- prefs.local_storage_enabled = env->GetBooleanField(
- obj, field_ids_->dom_storage_enabled);
-
- prefs.databases_enabled = env->GetBooleanField(
- obj, field_ids_->database_enabled);
-
- prefs.double_tap_to_zoom_enabled = prefs.use_wide_viewport =
- env->GetBooleanField(obj, field_ids_->use_wide_viewport);
-
- prefs.initialize_at_minimum_page_scale = env->GetBooleanField(
- obj, field_ids_->load_with_overview_mode);
-
- prefs.user_gesture_required_for_media_playback = env->GetBooleanField(
- obj, field_ids_->media_playback_requires_user_gesture);
-
- str.Reset(
- env, static_cast<jstring>(
- env->GetObjectField(obj, field_ids_->default_video_poster_url)));
- prefs.default_video_poster_url = str.obj() ?
- GURL(ConvertJavaStringToUTF8(str)) : GURL();
-
- prefs.support_deprecated_target_density_dpi = env->GetBooleanField(
- obj, field_ids_->support_deprecated_target_density_dpi);
-
- render_view_host->UpdateWebkitPreferences(prefs);
+ base::android::CheckException(env);
}
void ContentSettings::SyncFromNative(JNIEnv* env, jobject obj) {
SyncFromNativeImpl();
}
-void ContentSettings::SyncToNative(JNIEnv* env, jobject obj) {
- SyncToNativeImpl();
-}
-
-void ContentSettings::RenderViewCreated(RenderViewHost* render_view_host) {
- if (is_master_mode_)
- SyncToNativeImpl();
-}
-
void ContentSettings::WebContentsDestroyed(WebContents* web_contents) {
delete this;
}
-static jint Init(JNIEnv* env, jobject obj, jint nativeContentViewCore,
- jboolean is_master_mode) {
+static jint Init(JNIEnv* env, jobject obj, jint nativeContentViewCore) {
WebContents* web_contents =
reinterpret_cast<ContentViewCoreImpl*>(nativeContentViewCore)
->GetWebContents();
ContentSettings* content_settings =
- new ContentSettings(env, obj, web_contents, is_master_mode);
+ new ContentSettings(env, obj, web_contents);
return reinterpret_cast<jint>(content_settings);
}
-static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) {
- return base::android::ConvertUTF8ToJavaString(
- env, GetContentClient()->GetUserAgent()).Release();
-}
-
} // namespace content
diff --git a/content/browser/android/content_settings.h b/content/browser/android/content_settings.h
index 3a9128e..ce8ea70 100644
--- a/content/browser/android/content_settings.h
+++ b/content/browser/android/content_settings.h
@@ -16,15 +16,11 @@ namespace content {
class ContentSettings : public WebContentsObserver {
public:
ContentSettings(JNIEnv* env, jobject obj,
- WebContents* contents,
- bool is_master_mode);
+ WebContents* contents);
static bool RegisterContentSettings(JNIEnv* env);
- // Synchronizes the Java settings from native settings.
void SyncFromNative(JNIEnv* env, jobject obj);
- // Synchronizes the native settings from Java settings.
- void SyncToNative(JNIEnv* env, jobject obj);
private:
struct FieldIds;
@@ -32,16 +28,10 @@ class ContentSettings : public WebContentsObserver {
virtual ~ContentSettings();
void SyncFromNativeImpl();
- void SyncToNativeImpl();
// WebContentsObserver overrides:
- virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;
- // Determines whether a sync to native should be triggered when a new render
- // view is created.
- bool is_master_mode_;
-
// Java field references for accessing the values in the Java object.
scoped_ptr<FieldIds> field_ids_;
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index befac7a..8745bf7 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -794,22 +794,6 @@ jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) {
web_contents_->GetRenderViewHost());
}
-void ContentViewCoreImpl::SetAllUserAgentOverridesInHistory(
- JNIEnv* env,
- jobject,
- jstring user_agent_override) {
- bool override_used = user_agent_override != NULL;
- if (override_used) {
- std::string override =
- base::android::ConvertJavaStringToUTF8(env, user_agent_override);
- web_contents_->SetUserAgentOverride(override);
- }
-
- const NavigationController& controller = web_contents_->GetController();
- for (int i = 0; i < controller.GetEntryCount(); ++i)
- controller.GetEntryAtIndex(i)->SetIsOverridingUserAgent(override_used);
-}
-
ScopedJavaLocalRef<jstring> ContentViewCoreImpl::GetURL(
JNIEnv* env, jobject) const {
return ConvertUTF8ToJavaString(env, GetWebContents()->GetURL().spec());
diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h
index f10e7e18..c625483 100644
--- a/content/browser/android/content_view_core_impl.h
+++ b/content/browser/android/content_view_core_impl.h
@@ -88,10 +88,6 @@ class ContentViewCoreImpl : public ContentViewCore,
jstring base_url_for_data_url,
jstring virtual_url_for_data_url,
jboolean can_load_local_resources);
- void SetAllUserAgentOverridesInHistory(
- JNIEnv* env,
- jobject obj,
- jstring user_agent_override);
base::android::ScopedJavaLocalRef<jstring> GetURL(JNIEnv* env, jobject) const;
base::android::ScopedJavaLocalRef<jstring> GetTitle(
JNIEnv* env, jobject obj) const;
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 bd5f04a..5f55786 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
@@ -22,14 +22,6 @@ import org.chromium.base.ThreadUtils;
*/
@JNINamespace("content")
public class ContentSettings {
- // This enum corresponds to WebSettings.LayoutAlgorithm. We use our own to be
- // able to extend it.
- public enum LayoutAlgorithm {
- NORMAL,
- SINGLE_COLUMN,
- NARROW_COLUMNS,
- TEXT_AUTOSIZING,
- }
private static final String TAG = "ContentSettings";
@@ -43,10 +35,6 @@ public class ContentSettings {
private ContentViewCore mContentViewCore;
- // When ContentView is used in PERSONALITY_CHROME mode, settings can't
- // be modified through the ContentSettings instance.
- private boolean mCanModifySettings;
-
// A flag to avoid sending superfluous synchronization messages.
private boolean mIsSyncMessagePending = false;
// Custom handler that queues messages to call native code on the UI thread.
@@ -55,71 +43,17 @@ public class ContentSettings {
// Protects access to settings fields.
private final Object mContentSettingsLock = new Object();
- private static final int MINIMUM_FONT_SIZE = 1;
- private static final int MAXIMUM_FONT_SIZE = 72;
-
- // Private settings so we don't have to go into native code to
- // retrieve the values. After setXXX, mEventHandler.syncSettingsLocked() needs to be called.
- //
- // TODO(mnaganov): populate with the complete set of legacy WebView settings.
- // Note: If adding a new setting to this class, make sure to add it to the initFrom()
- // method defined below.
-
- 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";
- // FIXME: Should be obtained from Android. Problem: it is hidden.
- private String mDefaultTextEncoding = "Latin-1";
- 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 boolean mSupportDeprecatedTargetDensityDPI = false;
// Not accessed by the native side.
private boolean mSupportZoom = true;
private boolean mBuiltInZoomControls = false;
private boolean mDisplayZoomControls = true;
- static class LazyDefaultUserAgent {
- // Lazy Holder pattern
- private static final String sInstance = nativeGetDefaultUserAgent();
- }
-
- // Protects access to settings global fields.
- private static final Object sGlobalContentSettingsLock = new Object();
- // For compatibility with the legacy WebView, we can only enable AppCache when the path is
- // provided. However, we don't use the path, so we just check if we have received it from the
- // client.
- private static boolean sAppCachePathIsSet = false;
// Class to handle messages to be processed on the UI thread.
private class EventHandler {
// Message id for syncing
private static final int SYNC = 0;
- // Message id for updating user agent in the view
- private static final int UPDATE_UA = 1;
// Message id for updating multi-touch zoom state in the view
private static final int UPDATE_MULTI_TOUCH = 2;
// Actual UI thread handler
@@ -131,18 +65,6 @@ public class ContentSettings {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
- case SYNC:
- synchronized (mContentSettingsLock) {
- syncToNativeOnUiThread();
- mIsSyncMessagePending = false;
- mContentSettingsLock.notifyAll();
- }
- break;
- case UPDATE_UA:
- if (mContentViewCore.isAlive()) {
- mContentViewCore.setAllUserAgentOverridesInHistory();
- }
- break;
case UPDATE_MULTI_TOUCH:
if (mContentViewCore.isAlive()) {
mContentViewCore.updateMultiTouchZoomSupport();
@@ -169,26 +91,7 @@ public class ContentSettings {
private void syncSettingsLocked() {
assert Thread.holdsLock(mContentSettingsLock);
if (mNativeContentSettings == 0) return;
- if (mContentViewCore.isPersonalityView()) {
- if (Looper.myLooper() == mHandler.getLooper()) {
- syncToNativeOnUiThread();
- } else {
- // We're being called on a background thread, so post a message.
- if (mIsSyncMessagePending) {
- return;
- }
- mIsSyncMessagePending = true;
- mHandler.sendMessage(Message.obtain(null, SYNC));
- // When used in PERSONALITY_VIEW mode, we must block
- // until the settings have been sync'd to native to
- // ensure that they have taken effect.
- try {
- while (mIsSyncMessagePending) {
- mContentSettingsLock.wait();
- }
- } catch (InterruptedException e) {}
- }
- } else {
+ if (!mContentViewCore.isPersonalityView()) {
if (mIsSyncMessagePending) {
return;
}
@@ -197,12 +100,6 @@ public class ContentSettings {
}
}
- private void sendUpdateUaMessageLocked() {
- assert Thread.holdsLock(mContentSettingsLock);
- if (mNativeContentSettings == 0) return;
- mHandler.sendMessage(Message.obtain(null, UPDATE_UA));
- }
-
private void sendUpdateMultiTouchMessageLocked() {
assert Thread.holdsLock(mContentSettingsLock);
if (mNativeContentSettings == 0) return;
@@ -214,29 +111,14 @@ public class ContentSettings {
* Package constructor to prevent clients from creating a new settings
* instance. Must be called on the UI thread.
*/
- ContentSettings(ContentViewCore contentViewCore, int nativeContentView,
- boolean isAccessFromFileURLsGrantedByDefault) {
+ ContentSettings(ContentViewCore contentViewCore, int nativeContentView) {
ThreadUtils.assertOnUiThread();
mContentViewCore = contentViewCore;
- mCanModifySettings = mContentViewCore.isPersonalityView();
- mNativeContentSettings = nativeInit(nativeContentView, mCanModifySettings);
+ mNativeContentSettings = nativeInit(nativeContentView);
assert mNativeContentSettings != 0;
- if (isAccessFromFileURLsGrantedByDefault) {
- mAllowUniversalAccessFromFileURLs = true;
- mAllowFileAccessFromFileURLs = true;
- }
-
mEventHandler = new EventHandler();
- if (mCanModifySettings) {
- // PERSONALITY_VIEW
- mUserAgent = LazyDefaultUserAgent.sInstance;
- mSupportDeprecatedTargetDensityDPI = true;
- syncToNativeOnUiThread();
- } else {
- // PERSONALITY_CHROME
- // Chrome has zooming enabled by default. These settings are not
- // set by the native code.
+ if (!mContentViewCore.isPersonalityView()) {
mBuiltInZoomControls = true;
mDisplayZoomControls = false;
syncFromNativeOnUiThread();
@@ -254,43 +136,6 @@ public class ContentSettings {
}
/**
- * @returns the default User-Agent used by each ContentViewCore instance, i.e. unless
- * overridden by {@link #setUserAgentString()}
- */
- public static String getDefaultUserAgent() {
- return LazyDefaultUserAgent.sInstance;
- }
-
- /**
- * Set the WebView's user-agent string. If the string "ua" is null or empty,
- * it will use the system default user-agent string.
- */
- public void setUserAgentString(String ua) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- final String oldUserAgent = mUserAgent;
- if (ua == null || ua.length() == 0) {
- mUserAgent = LazyDefaultUserAgent.sInstance;
- } else {
- mUserAgent = ua;
- }
- if (!oldUserAgent.equals(mUserAgent)) {
- mEventHandler.sendUpdateUaMessageLocked();
- }
- }
- }
-
- /**
- * Gets the WebView's user-agent string.
- */
- public String getUserAgentString() {
- // TODO(mnaganov): Doesn't reflect changes made by ChromeNativePreferences.
- synchronized (mContentSettingsLock) {
- return mUserAgent;
- }
- }
-
- /**
* Sets whether the WebView should support zooming using its on-screen zoom
* controls and gestures. The particular zoom mechanisms that should be used
* can be set with {@link #setBuiltInZoomControls}. This setting does not
@@ -382,418 +227,6 @@ public class ContentSettings {
return supportsMultiTouchZoom() && mDisplayZoomControls;
}
- public void setLoadWithOverviewMode(boolean overview) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mLoadWithOverviewMode != overview) {
- mLoadWithOverviewMode = overview;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- public boolean getLoadWithOverviewMode() {
- synchronized (mContentSettingsLock) {
- return mLoadWithOverviewMode;
- }
- }
-
- /**
- * Sets the text zoom of the page in percent. Default is 100.
- *
- * @param textZoom the percent value for increasing or decreasing the text
- */
- public void setTextZoom(int textZoom) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mTextSizePercent != textZoom) {
- mTextSizePercent = textZoom;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Gets the text zoom of the page in percent.
- *
- * @return a percent value describing the text zoom
- * @see #setTextSizeZoom
- */
- public int getTextZoom() {
- synchronized (mContentSettingsLock) {
- return mTextSizePercent;
- }
- }
-
- /**
- * Set the standard font family name.
- * @param font A font family name.
- */
- public void setStandardFontFamily(String font) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (font != null && !mStandardFontFamily.equals(font)) {
- mStandardFontFamily = font;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Get the standard font family name. The default is "sans-serif".
- * @return The standard font family name as a string.
- */
- public String getStandardFontFamily() {
- synchronized (mContentSettingsLock) {
- return mStandardFontFamily;
- }
- }
-
- /**
- * Set the fixed font family name.
- * @param font A font family name.
- */
- public void setFixedFontFamily(String font) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (font != null && !mFixedFontFamily.equals(font)) {
- mFixedFontFamily = font;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Get the fixed font family name. The default is "monospace".
- * @return The fixed font family name as a string.
- */
- public String getFixedFontFamily() {
- synchronized (mContentSettingsLock) {
- return mFixedFontFamily;
- }
- }
-
- /**
- * Set the sans-serif font family name.
- * @param font A font family name.
- */
- public void setSansSerifFontFamily(String font) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (font != null && !mSansSerifFontFamily.equals(font)) {
- mSansSerifFontFamily = font;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Get the sans-serif font family name.
- * @return The sans-serif font family name as a string.
- */
- public String getSansSerifFontFamily() {
- synchronized (mContentSettingsLock) {
- return mSansSerifFontFamily;
- }
- }
-
- /**
- * Set the serif font family name. The default is "sans-serif".
- * @param font A font family name.
- */
- public void setSerifFontFamily(String font) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (font != null && !mSerifFontFamily.equals(font)) {
- mSerifFontFamily = font;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Get the serif font family name. The default is "serif".
- * @return The serif font family name as a string.
- */
- public String getSerifFontFamily() {
- synchronized (mContentSettingsLock) {
- return mSerifFontFamily;
- }
- }
-
- /**
- * Set the cursive font family name.
- * @param font A font family name.
- */
- public void setCursiveFontFamily(String font) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (font != null && !mCursiveFontFamily.equals(font)) {
- mCursiveFontFamily = font;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Get the cursive font family name. The default is "cursive".
- * @return The cursive font family name as a string.
- */
- public String getCursiveFontFamily() {
- synchronized (mContentSettingsLock) {
- return mCursiveFontFamily;
- }
- }
-
- /**
- * Set the fantasy font family name.
- * @param font A font family name.
- */
- public void setFantasyFontFamily(String font) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (font != null && !mFantasyFontFamily.equals(font)) {
- mFantasyFontFamily = font;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Get the fantasy font family name. The default is "fantasy".
- * @return The fantasy font family name as a string.
- */
- public String getFantasyFontFamily() {
- synchronized (mContentSettingsLock) {
- return mFantasyFontFamily;
- }
- }
-
- /**
- * Set the minimum font size.
- * @param size A non-negative integer between 1 and 72.
- * Any number outside the specified range will be pinned.
- */
- public void setMinimumFontSize(int size) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- size = clipFontSize(size);
- if (mMinimumFontSize != size) {
- mMinimumFontSize = size;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Get the minimum font size. The default is 8.
- * @return A non-negative integer between 1 and 72.
- */
- public int getMinimumFontSize() {
- synchronized (mContentSettingsLock) {
- return mMinimumFontSize;
- }
- }
-
- /**
- * Set the minimum logical font size.
- * @param size A non-negative integer between 1 and 72.
- * Any number outside the specified range will be pinned.
- */
- public void setMinimumLogicalFontSize(int size) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- size = clipFontSize(size);
- if (mMinimumLogicalFontSize != size) {
- mMinimumLogicalFontSize = size;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Get the minimum logical font size. The default is 8.
- * @return A non-negative integer between 1 and 72.
- */
- public int getMinimumLogicalFontSize() {
- synchronized (mContentSettingsLock) {
- return mMinimumLogicalFontSize;
- }
- }
-
- /**
- * Set the default font size.
- * @param size A non-negative integer between 1 and 72.
- * Any number outside the specified range will be pinned.
- */
- public void setDefaultFontSize(int size) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- size = clipFontSize(size);
- if (mDefaultFontSize != size) {
- mDefaultFontSize = size;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Get the default font size. The default is 16.
- * @return A non-negative integer between 1 and 72.
- */
- public int getDefaultFontSize() {
- synchronized (mContentSettingsLock) {
- return mDefaultFontSize;
- }
- }
-
- /**
- * Set the default fixed font size.
- * @param size A non-negative integer between 1 and 72.
- * Any number outside the specified range will be pinned.
- */
- public void setDefaultFixedFontSize(int size) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- size = clipFontSize(size);
- if (mDefaultFixedFontSize != size) {
- mDefaultFixedFontSize = size;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Get the default fixed font size. The default is 16.
- * @return A non-negative integer between 1 and 72.
- */
- public int getDefaultFixedFontSize() {
- synchronized (mContentSettingsLock) {
- return mDefaultFixedFontSize;
- }
- }
-
- /**
- * Tell the WebView to enable JavaScript execution.
- *
- * @param flag True if the WebView should execute JavaScript.
- */
- public void setJavaScriptEnabled(boolean flag) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mJavaScriptEnabled != flag) {
- mJavaScriptEnabled = flag;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Sets whether JavaScript running in the context of a file scheme URL
- * should be allowed to access content from any origin. This includes
- * access to content from other file scheme URLs. See
- * {@link #setAllowFileAccessFromFileURLs}. To enable the most restrictive,
- * and therefore secure policy, this setting should be disabled.
- * <p>
- * The default value is true for API level
- * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and below,
- * and false for API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN}
- * and above.
- *
- * @param flag whether JavaScript running in the context of a file scheme
- * URL should be allowed to access content from any origin
- */
- public void setAllowUniversalAccessFromFileURLs(boolean flag) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mAllowUniversalAccessFromFileURLs != flag) {
- mAllowUniversalAccessFromFileURLs = flag;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Sets whether JavaScript running in the context of a file scheme URL
- * should be allowed to access content from other file scheme URLs. To
- * enable the most restrictive, and therefore secure policy, this setting
- * should be disabled. Note that the value of this setting is ignored if
- * the value of {@link #getAllowUniversalAccessFromFileURLs} is true.
- * <p>
- * The default value is true for API level
- * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and below,
- * and false for API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN}
- * and above.
- *
- * @param flag whether JavaScript running in the context of a file scheme
- * URL should be allowed to access content from other file
- * scheme URLs
- */
- public void setAllowFileAccessFromFileURLs(boolean flag) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mAllowFileAccessFromFileURLs != flag) {
- mAllowFileAccessFromFileURLs = flag;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * 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) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mLoadsImagesAutomatically != flag) {
- mLoadsImagesAutomatically = flag;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Return true if the WebView will load image resources automatically.
- * The default is true.
- * @return True if the WebView loads images automatically.
- */
- public boolean getLoadsImagesAutomatically() {
- synchronized (mContentSettingsLock) {
- return mLoadsImagesAutomatically;
- }
- }
-
- /**
- * 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>
*
@@ -806,453 +239,6 @@ public class ContentSettings {
}
/**
- * Gets whether JavaScript running in the context of a file scheme URL can
- * access content from any origin. This includes access to content from
- * other file scheme URLs.
- *
- * @return whether JavaScript running in the context of a file scheme URL
- * can access content from any origin
- * @see #setAllowUniversalAccessFromFileURLs
- */
- public boolean getAllowUniversalAccessFromFileURLs() {
- synchronized (mContentSettingsLock) {
- return mAllowUniversalAccessFromFileURLs;
- }
- }
-
- /**
- * Gets whether JavaScript running in the context of a file scheme URL can
- * access content from other file scheme URLs.
- *
- * @return whether JavaScript running in the context of a file scheme URL
- * can access content from other file scheme URLs
- * @see #setAllowFileAccessFromFileURLs
- */
- public boolean getAllowFileAccessFromFileURLs() {
- synchronized (mContentSettingsLock) {
- return mAllowFileAccessFromFileURLs;
- }
- }
-
- /**
- * Tell the WebView to enable plugins.
- * @param flag True if the WebView should load plugins.
- * @deprecated This method has been deprecated in favor of
- * {@link #setPluginState}
- */
- @Deprecated
- public void setPluginsEnabled(boolean flag) {
- assert mCanModifySettings;
- setPluginState(flag ? PluginState.ON : PluginState.OFF);
- }
-
- /**
- * Tell the WebView to enable, disable, or have plugins on demand. On
- * demand mode means that if a plugin exists that can handle the embedded
- * content, a placeholder icon will be shown instead of the plugin. When
- * the placeholder is clicked, the plugin will be enabled.
- * @param state One of the PluginState values.
- */
- public void setPluginState(PluginState state) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mPluginState != state) {
- mPluginState = state;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Return true if plugins are enabled.
- * @return True if plugins are enabled.
- * @deprecated This method has been replaced by {@link #getPluginState}
- */
- @Deprecated
- public boolean getPluginsEnabled() {
- synchronized (mContentSettingsLock) {
- return mPluginState == PluginState.ON;
- }
- }
-
- /**
- * Return true if plugins are disabled.
- * @return True if plugins are disabled.
- * @hide
- */
- @CalledByNative
- private boolean getPluginsDisabled() {
- // This should only be called from SyncToNative, which is called
- // either from the constructor, or with mContentSettingsLock being held.
- return mPluginState == PluginState.OFF;
- }
-
- /**
- * Sets if plugins are disabled.
- * @return True if plugins are disabled.
- * @hide
- */
- @CalledByNative
- private void setPluginsDisabled(boolean disabled) {
- // This should only be called from SyncFromToNative, which is called
- // either from the constructor, or with mContentSettingsLock being held.
- mPluginState = disabled ? PluginState.OFF : PluginState.ON;
- }
-
- /**
- * Return the current plugin state.
- * @return A value corresponding to the enum PluginState.
- */
- public PluginState getPluginState() {
- synchronized (mContentSettingsLock) {
- return mPluginState;
- }
- }
-
-
- /**
- * Tell javascript to open windows automatically. This applies to the
- * javascript function window.open().
- * @param flag True if javascript can open windows automatically.
- */
- public void setJavaScriptCanOpenWindowsAutomatically(boolean flag) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mJavaScriptCanOpenWindowsAutomatically != flag) {
- mJavaScriptCanOpenWindowsAutomatically = flag;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Return true if javascript can open windows automatically. The default
- * is false.
- * @return True if javascript can open windows automatically during
- * window.open().
- */
- public boolean getJavaScriptCanOpenWindowsAutomatically() {
- synchronized (mContentSettingsLock) {
- return mJavaScriptCanOpenWindowsAutomatically;
- }
- }
-
- /**
- * Sets the underlying layout algorithm. The default is
- * {@link LayoutAlgorithm#NARROW_COLUMNS}.
- *
- * @param l the layout algorithm to use, as a {@link LayoutAlgorithm} value
- */
- public void setLayoutAlgorithm(LayoutAlgorithm l) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mLayoutAlgorithm != l) {
- mLayoutAlgorithm = l;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Gets the current layout algorithm.
- *
- * @return the layout algorithm in use, as a {@link LayoutAlgorithm} value
- * @see #setLayoutAlgorithm
- */
- public LayoutAlgorithm getLayoutAlgorithm() {
- synchronized (mContentSettingsLock) {
- return mLayoutAlgorithm;
- }
- }
-
- /**
- * Sets whether Text Auto-sizing layout algorithm is enabled.
- *
- * @param enabled whether Text Auto-sizing layout algorithm is enabled
- * @hide
- */
- @CalledByNative
- private void setTextAutosizingEnabled(boolean enabled) {
- // This should only be called from SyncFromNative, which is called
- // either from the constructor, or with mContentSettingsLock being held.
- mLayoutAlgorithm = enabled ?
- LayoutAlgorithm.TEXT_AUTOSIZING : LayoutAlgorithm.NARROW_COLUMNS;
- }
-
- /**
- * Gets whether Text Auto-sizing layout algorithm is enabled.
- *
- * @return true if Text Auto-sizing layout algorithm is enabled
- * @hide
- */
- @CalledByNative
- private boolean getTextAutosizingEnabled() {
- return mLayoutAlgorithm == LayoutAlgorithm.TEXT_AUTOSIZING;
- }
-
- /**
- * Tells the WebView whether it supports multiple windows. True means
- * that {@link WebChromeClient#onCreateWindow(WebView, boolean,
- * boolean, Message)} is implemented by the host application.
- */
- public void setSupportMultipleWindows(boolean support) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mSupportMultipleWindows != support) {
- mSupportMultipleWindows = support;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Gets whether the WebView is supporting multiple windows.
- *
- * @return true if the WebView is supporting multiple windows. This means
- * that {@link WebChromeClient#onCreateWindow(WebView, boolean,
- * boolean, Message)} is implemented by the host application.
- */
- public boolean supportMultipleWindows() {
- synchronized (mContentSettingsLock) {
- return mSupportMultipleWindows;
- }
- }
-
- /**
- * Sets whether the WebView should enable support for the &quot;viewport&quot;
- * HTML meta tag or should use a wide viewport.
- * When the value of the setting is false, the layout width is always set to the
- * width of the WebView control in device-independent (CSS) pixels.
- * When the value is true and the page contains the viewport meta tag, the value
- * of the width specified in the tag is used. If the page does not contain the tag or
- * does not provide a width, then a wide viewport will be used.
- *
- * @param use whether to enable support for the viewport meta tag
- */
- public void setUseWideViewPort(boolean use) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mUseWideViewport != use) {
- mUseWideViewport = use;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Gets whether the WebView supports the &quot;viewport&quot;
- * HTML meta tag or will use a wide viewport.
- *
- * @return true if the WebView supports the viewport meta tag
- * @see #setUseWideViewPort
- */
- public boolean getUseWideViewPort() {
- synchronized (mContentSettingsLock) {
- return mUseWideViewport;
- }
- }
-
- /**
- * Sets whether the Application Caches API should be enabled. The default
- * is false. Note that in order for the Application Caches API to be
- * enabled, a non-empty database path must also be supplied to
- * {@link #setAppCachePath} (this is done for compatibility with the
- * legacy implementation).
- *
- * @param flag true if the WebView should enable Application Caches
- */
- public void setAppCacheEnabled(boolean flag) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mAppCacheEnabled != flag) {
- mAppCacheEnabled = flag;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Sets the path to the Application Caches files. In order for the
- * Application Caches API to be enabled, this method must be called with a
- * non-empty path. This method should only be called once: repeated calls
- * are ignored.
- *
- * @param path a non empty-string
- */
- public void setAppCachePath(String path) {
- assert mCanModifySettings;
- boolean needToSync = false;
- synchronized (sGlobalContentSettingsLock) {
- // AppCachePath can only be set once.
- if (!sAppCachePathIsSet && path != null && !path.isEmpty()) {
- sAppCachePathIsSet = true;
- needToSync = true;
- }
- }
- // The obvious problem here is that other WebViews will not be updated,
- // until they execute synchronization from Java to the native side.
- // But this is the same behaviour as it was in the legacy WebView.
- if (needToSync) {
- synchronized (mContentSettingsLock) {
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Gets whether Application Cache is enabled.
- *
- * @return true if Application Cache is enabled
- * @hide
- */
- @CalledByNative
- private boolean getAppCacheEnabled() {
- // This should only be called from SyncToNative, which is called
- // either from the constructor, or with mContentSettingsLock being held.
- if (!mAppCacheEnabled) {
- return false;
- }
- synchronized (sGlobalContentSettingsLock) {
- return sAppCachePathIsSet;
- }
- }
-
- /**
- * Sets whether the DOM storage API is enabled. The default value is false.
- *
- * @param flag true if the ContentView should use the DOM storage API
- */
- public void setDomStorageEnabled(boolean flag) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mDomStorageEnabled != flag) {
- mDomStorageEnabled = flag;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Gets whether the DOM Storage APIs are enabled.
- *
- * @return true if the DOM Storage APIs are enabled
- * @see #setDomStorageEnabled
- */
- public boolean getDomStorageEnabled() {
- synchronized (mContentSettingsLock) {
- return mDomStorageEnabled;
- }
- }
-
- /**
- * Sets whether the WebSQL storage API is enabled. The default value is false.
- *
- * @param flag true if the ContentView should use the WebSQL storage API
- */
- public void setDatabaseEnabled(boolean flag) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mDatabaseEnabled != flag) {
- mDatabaseEnabled = flag;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Gets whether the WebSQL Storage APIs are enabled.
- *
- * @return true if the WebSQL Storage APIs are enabled
- * @see #setDatabaseEnabled
- */
- public boolean getDatabaseEnabled() {
- synchronized (mContentSettingsLock) {
- return mDatabaseEnabled;
- }
- }
-
- /**
- * Set the default text encoding name to use when decoding html pages.
- * @param encoding The text encoding name.
- */
- public void setDefaultTextEncodingName(String encoding) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (encoding != null && !mDefaultTextEncoding.equals(encoding)) {
- mDefaultTextEncoding = encoding;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Get the default text encoding name. The default is "Latin-1".
- * @return The default text encoding name as a string.
- */
- public String getDefaultTextEncodingName() {
- synchronized (mContentSettingsLock) {
- return mDefaultTextEncoding;
- }
- }
-
- /**
- * Set whether the user gesture is required for media playback.
- * @param require true if the user gesture is required.
- */
- public void setMediaPlaybackRequiresUserGesture(boolean require) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mMediaPlaybackRequiresUserGesture != require) {
- mMediaPlaybackRequiresUserGesture = require;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Get whether the user gesture is required for Media Playback.
- * @return true if the user gesture is required.
- */
- public boolean getMediaPlaybackRequiresUserGesture() {
- synchronized (mContentSettingsLock) {
- return mMediaPlaybackRequiresUserGesture;
- }
- }
-
- /**
- * Set the default video poster URL.
- * @param url The url of default video poster.
- */
- public void setDefaultVideoPosterURL(String url) {
- assert mCanModifySettings;
- synchronized (mContentSettingsLock) {
- if (mDefaultVideoPosterURL != null && !mDefaultVideoPosterURL.equals(url) ||
- mDefaultVideoPosterURL == null && url != null) {
- mDefaultVideoPosterURL = url;
- mEventHandler.syncSettingsLocked();
- }
- }
- }
-
- /**
- * Get the default video poster URL.
- */
- public String getDefaultVideoPosterURL() {
- synchronized (mContentSettingsLock) {
- return mDefaultVideoPosterURL;
- }
- }
-
- 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;
- }
-
- /**
* Sets the settings in this object to those from another
* ContentSettings.
* Required by WebView when we swap a in a new ContentViewCore
@@ -1260,69 +246,23 @@ public class ContentSettings {
* windows in an already created WebView)
*/
public void initFrom(ContentSettings settings) {
- setLayoutAlgorithm(settings.getLayoutAlgorithm());
- setLoadWithOverviewMode(settings.getLoadWithOverviewMode());
- setTextZoom(settings.getTextZoom());
- setStandardFontFamily(settings.getStandardFontFamily());
- setFixedFontFamily(settings.getFixedFontFamily());
- setSansSerifFontFamily(settings.getSansSerifFontFamily());
- setSerifFontFamily(settings.getSerifFontFamily());
- setCursiveFontFamily(settings.getCursiveFontFamily());
- setFantasyFontFamily(settings.getFantasyFontFamily());
- setDefaultTextEncodingName(settings.getDefaultTextEncodingName());
- setUserAgentString(settings.getUserAgentString());
- setMinimumFontSize(settings.getMinimumFontSize());
- setMinimumLogicalFontSize(settings.getMinimumLogicalFontSize());
- setDefaultFontSize(settings.getDefaultFontSize());
- setDefaultFixedFontSize(settings.getDefaultFixedFontSize());
- setLoadsImagesAutomatically(settings.getLoadsImagesAutomatically());
- setImagesEnabled(settings.getImagesEnabled());
- setJavaScriptEnabled(settings.getJavaScriptEnabled());
- setAllowUniversalAccessFromFileURLs(settings.getAllowUniversalAccessFromFileURLs());
- setAllowFileAccessFromFileURLs(settings.getAllowFileAccessFromFileURLs());
- setJavaScriptCanOpenWindowsAutomatically(
- settings.getJavaScriptCanOpenWindowsAutomatically());
- setSupportMultipleWindows(settings.supportMultipleWindows());
- setPluginState(settings.getPluginState());
- setAppCacheEnabled(settings.mAppCacheEnabled);
- setDomStorageEnabled(settings.getDomStorageEnabled());
- setDatabaseEnabled(settings.getDatabaseEnabled());
setSupportZoom(settings.supportZoom());
setBuiltInZoomControls(settings.getBuiltInZoomControls());
setDisplayZoomControls(settings.getDisplayZoomControls());
- setMediaPlaybackRequiresUserGesture(settings.getMediaPlaybackRequiresUserGesture());
- setDefaultVideoPosterURL(settings.getDefaultVideoPosterURL());
}
- /**
- * Synchronize java side and native side settings. When ContentView
- * is running in PERSONALITY_VIEW mode, this needs to be done after
- * any java side setting is changed to sync them to native. In
- * PERSONALITY_CHROME mode, this needs to be called whenever native
- * settings are changed to sync them to java.
- */
void syncSettings() {
synchronized (mContentSettingsLock) {
mEventHandler.syncSettingsLocked();
}
}
- void syncToNativeOnUiThread() {
- if (mNativeContentSettings != 0) nativeSyncToNative(mNativeContentSettings);
- }
-
void syncFromNativeOnUiThread() {
if (mNativeContentSettings != 0) nativeSyncFromNative(mNativeContentSettings);
}
// Initialize the ContentSettings native side.
- private native int nativeInit(int contentViewPtr, boolean isMasterMode);
-
- private static native String nativeGetDefaultUserAgent();
+ private native int nativeInit(int contentViewPtr);
- // Synchronize Java settings from native settings.
private native void nativeSyncFromNative(int nativeContentSettings);
-
- // Synchronize native settings from Java settings.
- private native void nativeSyncToNative(int nativeContentSettings);
}
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentView.java b/content/public/android/java/src/org/chromium/content/browser/ContentView.java
index f067389..fe6655b 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentView.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentView.java
@@ -109,7 +109,7 @@ public class ContentView extends FrameLayout
super(context, attrs, defStyle);
mContentViewCore = new ContentViewCore(context, personality);
- mContentViewCore.initialize(this, this, nativeWebContents, windowAndroid, false);
+ mContentViewCore.initialize(this, this, nativeWebContents, windowAndroid);
}
// PageInfo implementation.
@@ -229,10 +229,6 @@ public class ContentView extends FrameLayout
mContentViewCore.loadUrl(params);
}
- void setAllUserAgentOverridesInHistory() {
- mContentViewCore.setAllUserAgentOverridesInHistory();
- }
-
/**
* Stops loading the current web contents.
*/
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index fc76afa..94190be 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -519,7 +519,6 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
* containerView.
* @param nativeWebContents A pointer to the native web contents.
* @param windowAndroid An instance of the WindowAndroid.
- * @param isAccessFromFileURLsGrantedByDefault Default WebSettings configuration.
*/
// Perform important post-construction set up of the ContentViewCore.
// We do not require the containing view in the constructor to allow embedders to create a
@@ -531,8 +530,7 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
// Note that the caller remains the owner of the nativeWebContents and is responsible for
// deleting it after destroying the ContentViewCore.
public void initialize(ViewGroup containerView, InternalAccessDelegate internalDispatcher,
- int nativeWebContents, WindowAndroid windowAndroid,
- boolean isAccessFromFileURLsGrantedByDefault) {
+ int nativeWebContents, WindowAndroid windowAndroid) {
// Check whether to use hardware acceleration. This is a bit hacky, and
// only works if the Context is actually an Activity (as it is in the
// Chrome application).
@@ -560,12 +558,8 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
mNativeContentViewCore = nativeInit(mHardwareAccelerated,
nativeWebContents, viewAndroidNativePointer, windowNativePointer);
- mContentSettings = new ContentSettings(
- this, mNativeContentViewCore, isAccessFromFileURLsGrantedByDefault);
+ mContentSettings = new ContentSettings(this, mNativeContentViewCore);
initializeContainerView(internalDispatcher);
- if (mPersonality == PERSONALITY_VIEW) {
- setAllUserAgentOverridesInHistory();
- }
mAccessibilityInjector = AccessibilityInjector.newInstance(this);
mAccessibilityInjector.addOrRemoveAccessibilityApisIfNecessary();
@@ -812,11 +806,6 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
params.mCanLoadLocalResources);
}
- void setAllUserAgentOverridesInHistory() {
- nativeSetAllUserAgentOverridesInHistory(mNativeContentViewCore,
- mContentSettings.getUserAgentString());
- }
-
/**
* Stops loading the current web contents.
*/
@@ -2756,9 +2745,6 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
String virtualUrlForDataUrl,
boolean canLoadLocalResources);
- private native void nativeSetAllUserAgentOverridesInHistory(int nativeContentViewCoreImpl,
- String userAgentOverride);
-
private native String nativeGetURL(int nativeContentViewCoreImpl);
private native String nativeGetTitle(int nativeContentViewCoreImpl);