Commit e2521352 authored by ntfschr's avatar ntfschr Committed by Commit bot

Change WebView's Safe Browsing opt-in requirements

Safe Browsing will now be enabled for any app which opts in by setting
the flag `android.webkit.WebView.EnableSafeBrowsing` to "true",
regardless of Android version or Target SDK.

BUG=699193

Review-Url: https://codereview.chromium.org/2739003002
Cr-Commit-Position: refs/heads/master@{#455958}
parent 8d97710b
......@@ -12,7 +12,6 @@ import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.provider.Settings;
import org.chromium.base.BuildInfo;
import org.chromium.base.CommandLine;
import org.chromium.base.Log;
import org.chromium.base.annotations.JNINamespace;
......@@ -43,11 +42,10 @@ public class AwSafeBrowsingConfigHelper {
private static boolean shouldEnableSafeBrowsingSupport(Context appContext) {
return CommandLine.getInstance().hasSwitch(AwSwitches.WEBVIEW_ENABLE_SAFEBROWSING_SUPPORT)
|| (BuildInfo.isAtLeastO()
&& !appHasMetadataKeyValue(appContext, OPT_IN_META_DATA_STR, false));
|| appHasOptedIn(appContext);
}
private static boolean appHasMetadataKeyValue(Context appContext, String key, boolean value) {
private static boolean appHasOptedIn(Context appContext) {
try {
ApplicationInfo info = appContext.getPackageManager().getApplicationInfo(
appContext.getPackageName(), PackageManager.GET_META_DATA);
......@@ -55,7 +53,9 @@ public class AwSafeBrowsingConfigHelper {
// null means no such tag was found.
return false;
}
return info.metaData.containsKey(key) ? info.metaData.getBoolean(key) == value : false;
return info.metaData.containsKey(OPT_IN_META_DATA_STR)
? info.metaData.getBoolean(OPT_IN_META_DATA_STR)
: false;
} catch (PackageManager.NameNotFoundException e) {
// This should never happen.
Log.e(TAG, "App could not find itself by package name!");
......
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