Commit 5f199640 authored by Nate Fischer's avatar Nate Fischer Committed by Chromium LUCI CQ

Android: inline deprecated BuildInfo methods (/android_webview)

No change to logic. This inlines BuildInfo.isAtLeast{Q,R} and
BuildInfo.targetsAtLeast{Q,R} (and their C++ equivalents) in
/android_webview.

The methods themselves will be removed in a follow-up CL once all call
sites have been removed.

This CL was uploaded by git cl split.

R=boliu@chromium.org

Bug: 1106920
Test: autoninja -C out/Default monochrome_public_apk
Change-Id: I7c772186e1d54f5e4e6e2b36aaa08ca350124bf7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575326
Commit-Queue: Nate Fischer <ntfschr@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Auto-Submit: Nate Fischer <ntfschr@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833879}
parent fcbaead2
...@@ -65,7 +65,6 @@ import org.chromium.android_webview.AwSettings; ...@@ -65,7 +65,6 @@ import org.chromium.android_webview.AwSettings;
import org.chromium.android_webview.AwThreadUtils; import org.chromium.android_webview.AwThreadUtils;
import org.chromium.android_webview.gfx.AwDrawFnImpl; import org.chromium.android_webview.gfx.AwDrawFnImpl;
import org.chromium.android_webview.renderer_priority.RendererPriority; import org.chromium.android_webview.renderer_priority.RendererPriority;
import org.chromium.base.BuildInfo;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.ScopedSysTraceEvent; import org.chromium.base.metrics.ScopedSysTraceEvent;
...@@ -2537,7 +2536,7 @@ class WebViewChromium implements WebViewProvider, WebViewProvider.ScrollDelegate ...@@ -2537,7 +2536,7 @@ class WebViewChromium implements WebViewProvider, WebViewProvider.ScrollDelegate
@Override @Override
public AwDrawFnImpl.DrawFnAccess getDrawFnAccess() { public AwDrawFnImpl.DrawFnAccess getDrawFnAccess() {
if (BuildInfo.isAtLeastQ()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
return mFactory.getWebViewDelegate(); return mFactory.getWebViewDelegate();
} }
return null; return null;
......
...@@ -342,7 +342,7 @@ public class WebViewChromiumAwInit { ...@@ -342,7 +342,7 @@ public class WebViewChromiumAwInit {
private void initPlatSupportLibrary() { private void initPlatSupportLibrary() {
try (ScopedSysTraceEvent e = ScopedSysTraceEvent.scoped( try (ScopedSysTraceEvent e = ScopedSysTraceEvent.scoped(
"WebViewChromiumAwInit.initPlatSupportLibrary")) { "WebViewChromiumAwInit.initPlatSupportLibrary")) {
if (BuildInfo.isAtLeastQ()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
AwDrawFnImpl.setDrawFnFunctionTable(DrawFunctor.getDrawFnFunctionTable()); AwDrawFnImpl.setDrawFnFunctionTable(DrawFunctor.getDrawFnFunctionTable());
} }
DrawGLFunctor.setChromiumAwDrawGLFunction(AwContents.getAwDrawGLFunction()); DrawGLFunctor.setChromiumAwDrawGLFunction(AwContents.getAwDrawGLFunction());
......
...@@ -58,7 +58,6 @@ import org.chromium.android_webview.gfx.RectUtils; ...@@ -58,7 +58,6 @@ import org.chromium.android_webview.gfx.RectUtils;
import org.chromium.android_webview.permission.AwGeolocationCallback; import org.chromium.android_webview.permission.AwGeolocationCallback;
import org.chromium.android_webview.permission.AwPermissionRequest; import org.chromium.android_webview.permission.AwPermissionRequest;
import org.chromium.android_webview.renderer_priority.RendererPriority; import org.chromium.android_webview.renderer_priority.RendererPriority;
import org.chromium.base.BuildInfo;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.CommandLine; import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
...@@ -1932,7 +1931,9 @@ public class AwContents implements SmartClipProvider { ...@@ -1932,7 +1931,9 @@ public class AwContents implements SmartClipProvider {
if (TRACE) Log.i(TAG, "%s loadData", this); if (TRACE) Log.i(TAG, "%s loadData", this);
if (isDestroyed(WARN)) return; if (isDestroyed(WARN)) return;
if (data != null && data.contains("#")) { if (data != null && data.contains("#")) {
if (!BuildInfo.targetsAtLeastQ() && !isBase64Encoded(encoding)) { if (ContextUtils.getApplicationContext().getApplicationInfo().targetSdkVersion
< Build.VERSION_CODES.Q
&& !isBase64Encoded(encoding)) {
// As of Chromium M72, data URI parsing strictly enforces encoding of '#'. To // As of Chromium M72, data URI parsing strictly enforces encoding of '#'. To
// support WebView applications which were not expecting this change, we do it for // support WebView applications which were not expecting this change, we do it for
// them. // them.
......
...@@ -21,7 +21,6 @@ import org.chromium.android_webview.common.AwFeatures; ...@@ -21,7 +21,6 @@ import org.chromium.android_webview.common.AwFeatures;
import org.chromium.android_webview.safe_browsing.AwSafeBrowsingConfigHelper; import org.chromium.android_webview.safe_browsing.AwSafeBrowsingConfigHelper;
import org.chromium.android_webview.settings.ForceDarkBehavior; import org.chromium.android_webview.settings.ForceDarkBehavior;
import org.chromium.android_webview.settings.ForceDarkMode; import org.chromium.android_webview.settings.ForceDarkMode;
import org.chromium.base.BuildInfo;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
...@@ -294,7 +293,9 @@ public class AwSettings { ...@@ -294,7 +293,9 @@ public class AwSettings {
mDoNotUpdateSelectionOnMutatingSelectionRange = mDoNotUpdateSelectionOnMutatingSelectionRange =
doNotUpdateSelectionOnMutatingSelectionRange; doNotUpdateSelectionOnMutatingSelectionRange;
mAllowFileUrlAccess = !BuildInfo.targetsAtLeastR(); mAllowFileUrlAccess =
ContextUtils.getApplicationContext().getApplicationInfo().targetSdkVersion
< Build.VERSION_CODES.R;
} }
// Defer initializing the native side until a native WebContents instance is set. // Defer initializing the native side until a native WebContents instance is set.
} }
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
package org.chromium.android_webview.safe_browsing; package org.chromium.android_webview.safe_browsing;
import android.os.Build;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import org.chromium.base.BuildInfo; import org.chromium.base.ContextUtils;
import org.chromium.components.safe_browsing.SBThreatType; import org.chromium.components.safe_browsing.SBThreatType;
/** /**
...@@ -53,8 +54,10 @@ public final class AwSafeBrowsingConversionHelper { ...@@ -53,8 +54,10 @@ public final class AwSafeBrowsingConversionHelper {
case SBThreatType.URL_UNWANTED: case SBThreatType.URL_UNWANTED:
return SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE; return SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE;
case SBThreatType.BILLING: case SBThreatType.BILLING:
return BuildInfo.targetsAtLeastQ() ? SAFE_BROWSING_THREAT_BILLING return ContextUtils.getApplicationContext().getApplicationInfo().targetSdkVersion
: SAFE_BROWSING_THREAT_UNKNOWN; >= Build.VERSION_CODES.Q
? SAFE_BROWSING_THREAT_BILLING
: SAFE_BROWSING_THREAT_UNKNOWN;
default: default:
return SAFE_BROWSING_THREAT_UNKNOWN; return SAFE_BROWSING_THREAT_UNKNOWN;
} }
......
...@@ -12,6 +12,7 @@ import android.graphics.Bitmap; ...@@ -12,6 +12,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.Message; import android.os.Message;
...@@ -38,7 +39,7 @@ import org.chromium.android_webview.AwSettings; ...@@ -38,7 +39,7 @@ import org.chromium.android_webview.AwSettings;
import org.chromium.android_webview.renderer_priority.RendererPriority; import org.chromium.android_webview.renderer_priority.RendererPriority;
import org.chromium.android_webview.test.TestAwContentsClient.OnDownloadStartHelper; import org.chromium.android_webview.test.TestAwContentsClient.OnDownloadStartHelper;
import org.chromium.android_webview.test.util.CommonResources; import org.chromium.android_webview.test.util.CommonResources;
import org.chromium.base.BuildInfo; import org.chromium.base.ContextUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.test.util.CallbackHelper; import org.chromium.base.test.util.CallbackHelper;
...@@ -957,7 +958,9 @@ public class AwContentsTest { ...@@ -957,7 +958,9 @@ public class AwContentsTest {
final AwContents awContents = testView.getAwContents(); final AwContents awContents = testView.getAwContents();
// Before Android Q, the loadData API is expected to handle the encoding for users. // Before Android Q, the loadData API is expected to handle the encoding for users.
boolean encodeOctothorpes = !BuildInfo.targetsAtLeastQ(); boolean encodeOctothorpes =
ContextUtils.getApplicationContext().getApplicationInfo().targetSdkVersion
< Build.VERSION_CODES.Q;
// A URL with no '#' character. // A URL with no '#' character.
mActivityTestRule.loadDataSync(awContents, mContentsClient.getOnPageFinishedHelper(), mActivityTestRule.loadDataSync(awContents, mContentsClient.getOnPageFinishedHelper(),
......
...@@ -6,6 +6,7 @@ package org.chromium.android_webview.test; ...@@ -6,6 +6,7 @@ package org.chromium.android_webview.test;
import static org.chromium.android_webview.test.AwActivityTestRule.WAIT_TIMEOUT_MS; import static org.chromium.android_webview.test.AwActivityTestRule.WAIT_TIMEOUT_MS;
import android.os.Build;
import android.support.test.InstrumentationRegistry; import android.support.test.InstrumentationRegistry;
import android.webkit.JavascriptInterface; import android.webkit.JavascriptInterface;
...@@ -22,7 +23,6 @@ import org.junit.runner.RunWith; ...@@ -22,7 +23,6 @@ import org.junit.runner.RunWith;
import org.chromium.android_webview.AwContents; import org.chromium.android_webview.AwContents;
import org.chromium.android_webview.AwContentsClient.AwWebResourceRequest; import org.chromium.android_webview.AwContentsClient.AwWebResourceRequest;
import org.chromium.android_webview.test.TestAwContentsClient.OnReceivedSslErrorHelper; import org.chromium.android_webview.test.TestAwContentsClient.OnReceivedSslErrorHelper;
import org.chromium.base.BuildInfo;
import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.net.test.EmbeddedTestServer; import org.chromium.net.test.EmbeddedTestServer;
...@@ -72,7 +72,7 @@ public class AwNetworkConfigurationTest { ...@@ -72,7 +72,7 @@ public class AwNetworkConfigurationTest {
String url = mTestServer.getURL("/android_webview/test/data/hello_world.html"); String url = mTestServer.getURL("/android_webview/test/data/hello_world.html");
mActivityTestRule.loadUrlSync( mActivityTestRule.loadUrlSync(
mAwContents, mContentsClient.getOnPageFinishedHelper(), url); mAwContents, mContentsClient.getOnPageFinishedHelper(), url);
if (BuildInfo.isAtLeastQ()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
Assert.assertEquals("We should generate an SSL error on >= Q", count + 1, Assert.assertEquals("We should generate an SSL error on >= Q", count + 1,
onReceivedSslErrorHelper.getCallCount()); onReceivedSslErrorHelper.getCallCount());
} else { } else {
......
...@@ -12,6 +12,7 @@ import android.content.SharedPreferences; ...@@ -12,6 +12,7 @@ import android.content.SharedPreferences;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.support.test.InstrumentationRegistry; import android.support.test.InstrumentationRegistry;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -41,8 +42,8 @@ import org.chromium.android_webview.safe_browsing.AwSafeBrowsingConversionHelper ...@@ -41,8 +42,8 @@ import org.chromium.android_webview.safe_browsing.AwSafeBrowsingConversionHelper
import org.chromium.android_webview.safe_browsing.AwSafeBrowsingResponse; import org.chromium.android_webview.safe_browsing.AwSafeBrowsingResponse;
import org.chromium.android_webview.test.TestAwContentsClient.OnReceivedError2Helper; import org.chromium.android_webview.test.TestAwContentsClient.OnReceivedError2Helper;
import org.chromium.android_webview.test.util.GraphicsTestUtils; import org.chromium.android_webview.test.util.GraphicsTestUtils;
import org.chromium.base.BuildInfo;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.ContextUtils;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.task.PostTask; import org.chromium.base.task.PostTask;
import org.chromium.base.test.util.CallbackHelper; import org.chromium.base.test.util.CallbackHelper;
...@@ -508,7 +509,9 @@ public class SafeBrowsingTest { ...@@ -508,7 +509,9 @@ public class SafeBrowsingTest {
Assert.assertEquals(responseUrl, mContentsClient.getLastRequest().url); Assert.assertEquals(responseUrl, mContentsClient.getLastRequest().url);
// The expectedCode intentionally depends on targetSdk (and is disconnected from SDK_INT). // The expectedCode intentionally depends on targetSdk (and is disconnected from SDK_INT).
// This is for backwards compatibility with apps with a lower targetSdk. // This is for backwards compatibility with apps with a lower targetSdk.
int expectedCode = BuildInfo.targetsAtLeastQ() int expectedCode =
ContextUtils.getApplicationContext().getApplicationInfo().targetSdkVersion
>= Build.VERSION_CODES.Q
? AwSafeBrowsingConversionHelper.SAFE_BROWSING_THREAT_BILLING ? AwSafeBrowsingConversionHelper.SAFE_BROWSING_THREAT_BILLING
: AwSafeBrowsingConversionHelper.SAFE_BROWSING_THREAT_UNKNOWN; : AwSafeBrowsingConversionHelper.SAFE_BROWSING_THREAT_UNKNOWN;
Assert.assertEquals(expectedCode, mContentsClient.getLastThreatType()); Assert.assertEquals(expectedCode, mContentsClient.getLastThreatType());
......
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