Commit 6a617b58 authored by mnaganov@chromium.org's avatar mnaganov@chromium.org

[Android WebView] Prepare to remove AwSettings.LayoutAlgorithm

Usages of AwSettings.LayoutAlgorithm need to be replaced with
WebSettings.LayoutAlgorithm.

This change also fixes a couple of trivial presubmit warnings in
existing code.

BUG=332089

Review URL: https://codereview.chromium.org/115253004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243576 0039d316-1c4b-4281-b951-d872f2087c98
parent e08b910a
......@@ -10,6 +10,7 @@ import android.os.Handler;
import android.os.Message;
import android.os.Process;
import android.provider.Settings;
import android.util.Log;
import android.webkit.WebSettings;
import android.webkit.WebSettings.PluginState;
......@@ -26,8 +27,8 @@ 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.
// Do not use! Will be removed soon. See crbug.com/332089.
// Use android.webkit.WebSettings.LayoutAlgorithm instead.
public enum LayoutAlgorithm {
NORMAL,
SINGLE_COLUMN,
......@@ -50,7 +51,8 @@ public class AwSettings {
// Lock to protect all settings.
private final Object mAwSettingsLock = new Object();
private LayoutAlgorithm mLayoutAlgorithm = LayoutAlgorithm.NARROW_COLUMNS;
private WebSettings.LayoutAlgorithm mLayoutAlgorithm =
WebSettings.LayoutAlgorithm.NARROW_COLUMNS;
private int mTextSizePercent = 100;
private String mStandardFontFamily = "sans-serif";
private String mFixedFontFamily = "monospace";
......@@ -181,7 +183,9 @@ public class AwSettings {
while (mIsUpdateWebkitPrefsMessagePending) {
mAwSettingsLock.wait();
}
} catch (InterruptedException e) {}
} catch (InterruptedException e) {
Log.w(TAG, "updateWebkitPreferencesLocked interrupted", e);
}
}
}
}
......@@ -1026,10 +1030,21 @@ public class AwSettings {
return mJavaScriptCanOpenWindowsAutomatically;
}
// A temporary adapter to avoid breaking code from Android frameworks/webview. crbug.com/332089
public void setLayoutAlgorithm(AwSettings.LayoutAlgorithm l) {
final WebSettings.LayoutAlgorithm[] webViewValues = {
WebSettings.LayoutAlgorithm.NORMAL,
WebSettings.LayoutAlgorithm.SINGLE_COLUMN,
WebSettings.LayoutAlgorithm.NARROW_COLUMNS,
WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING
};
setLayoutAlgorithm(webViewValues[l.ordinal()]);
}
/**
* See {@link android.webkit.WebSettings#setLayoutAlgorithm}.
*/
public void setLayoutAlgorithm(LayoutAlgorithm l) {
public void setLayoutAlgorithm(WebSettings.LayoutAlgorithm l) {
synchronized (mAwSettingsLock) {
if (mLayoutAlgorithm != l) {
mLayoutAlgorithm = l;
......@@ -1041,7 +1056,7 @@ public class AwSettings {
/**
* See {@link android.webkit.WebSettings#getLayoutAlgorithm}.
*/
public LayoutAlgorithm getLayoutAlgorithm() {
public WebSettings.LayoutAlgorithm getLayoutAlgorithm() {
synchronized (mAwSettingsLock) {
return mLayoutAlgorithm;
}
......@@ -1055,7 +1070,7 @@ public class AwSettings {
*/
@CalledByNative
private boolean getTextAutosizingEnabledLocked() {
return mLayoutAlgorithm == LayoutAlgorithm.TEXT_AUTOSIZING;
return mLayoutAlgorithm == WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING;
}
/**
......
......@@ -14,12 +14,12 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.view.WindowManager;
import android.webkit.JavascriptInterface;
import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm;
import org.apache.http.Header;
import org.apache.http.HttpRequest;
import org.chromium.android_webview.AwContents;
import org.chromium.android_webview.AwSettings;
import org.chromium.android_webview.AwSettings.LayoutAlgorithm;
import org.chromium.android_webview.InterceptedRequestData;
import org.chromium.android_webview.test.util.CommonResources;
import org.chromium.android_webview.test.util.ImagePageGenerator;
......@@ -1919,7 +1919,7 @@ public class AwSettingsTest extends AwTestBase {
}
}
public static class AudioEvent {
static class AudioEvent {
private CallbackHelper mCallback;
public AudioEvent(CallbackHelper callback) {
mCallback = callback;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment