Enable modern SameSite cookies on Android WebView for apps targeting S+

Bug: 986319
Change-Id: I2e9beaca7ed07d012fc38c248198bfe72057545b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2615482
Reviewed-by: Richard Coles <torne@chromium.org>
Commit-Queue: Lily Chen <chlily@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841501}
GitOrigin-RevId: 0f285c2ebfe63aec1d1c148800c96c1eccb7942f
diff --git a/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java b/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
index 33c3deb..a8c68cc 100644
--- a/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
+++ b/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
@@ -316,6 +316,12 @@
                 cl.appendSwitch(AwSwitches.WEBVIEW_SANDBOXED_RENDERER);
             }
 
+            // Enable modern SameSite cookie behavior if the app targets at least S.
+            if (BuildInfo.targetsAtLeastS()) {
+                CommandLine cl = CommandLine.getInstance();
+                cl.appendSwitch(AwSwitches.WEBVIEW_ENABLE_MODERN_COOKIE_SAME_SITE);
+            }
+
             int applicationFlags = ctx.getApplicationInfo().flags;
             boolean isAppDebuggable = (applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
             boolean isOsDebuggable = BuildInfo.isDebugAndroid();