Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2370)

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwSafeBrowsingConfigHelper.java

Issue 2714303002: DO NOT SUBMIT: Allow SafeBrowsing in WebView for N and below (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/java/src/org/chromium/android_webview/AwSafeBrowsingConfigHelper.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwSafeBrowsingConfigHelper.java b/android_webview/java/src/org/chromium/android_webview/AwSafeBrowsingConfigHelper.java
index 8aa544f5e7aa8f37c2fe02f5f7a74adcfd2f0927..95dc6b305a476972e43c52a6af8fa1967f436465 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwSafeBrowsingConfigHelper.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwSafeBrowsingConfigHelper.java
@@ -41,10 +41,24 @@ public class AwSafeBrowsingConfigHelper {
}
}
+ /**
+ * If the app has set its opt-in/opt-out preference for SafeBrowsing, this fetches it.
+ * Otherwise, this returns the default value, depending on the version of Android we're running
+ * on (On by default for O+, off by default otherwise).
+ */
+ private static boolean getEffectiveSafeBrowsingOptInChoice(Context appContext) {
+ if (BuildInfo.isAtLeastO()) {
+ boolean hasOptedOut = appHasMetadataKeyValue(appContext, OPT_IN_META_DATA_STR, false);
+ return !hasOptedOut;
+ } else {
+ boolean hasOptedIn = appHasMetadataKeyValue(appContext, OPT_IN_META_DATA_STR, true);
+ return hasOptedIn;
+ }
+ }
+
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));
+ || getEffectiveSafeBrowsingOptInChoice(appContext);
}
private static boolean appHasMetadataKeyValue(Context appContext, String key, boolean value) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698