Implement enableSlowWholeDocumentDraw

Keep a static boolean in WebViewChromium to distinguish setting by API
call vs setting by targetSdkVersion. Call into chromium side in
initForReal.

BUG: 16300353

Change-Id: Ifd7cb4c27d4129575edaeeedf1464ca43c9f4c03
diff --git a/chromium/java/com/android/webview/chromium/WebViewChromium.java b/chromium/java/com/android/webview/chromium/WebViewChromium.java
index 9833569..6e6e188 100644
--- a/chromium/java/com/android/webview/chromium/WebViewChromium.java
+++ b/chromium/java/com/android/webview/chromium/WebViewChromium.java
@@ -58,6 +58,7 @@
 
 import org.chromium.android_webview.AwBrowserContext;
 import org.chromium.android_webview.AwContents;
+import org.chromium.android_webview.AwContentsStatics;
 import org.chromium.android_webview.AwLayoutSizer;
 import org.chromium.android_webview.AwSettings;
 import org.chromium.android_webview.AwPrintDocumentAdapter;
@@ -143,6 +144,11 @@
 
     private WebViewChromiumFactoryProvider mFactory;
 
+    private static boolean sRecordWholeDocumentEnabledByApi = false;
+    static void enableSlowWholeDocumentDraw() {
+        sRecordWholeDocumentEnabledByApi = true;
+    }
+
     // This does not touch any global / non-threadsafe state, but note that
     // init is ofter called right after and is NOT threadsafe.
     public WebViewChromium(WebViewChromiumFactoryProvider factory, WebView webView,
@@ -266,6 +272,9 @@
             AwContents.setShouldDownloadFavicons();
         }
 
+        AwContentsStatics.setRecordFullDocument(sRecordWholeDocumentEnabledByApi ||
+                mAppTargetSdkVersion < Build.VERSION_CODES.L);
+
         if (mAppTargetSdkVersion <= Build.VERSION_CODES.KITKAT) {
             // On KK and older versions, JavaScript objects injected via addJavascriptInterface
             // were not inspectable.
diff --git a/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java b/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
index a1bc335..69f4856 100644
--- a/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
+++ b/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
@@ -376,6 +376,11 @@
                         // route it from WebViewChromiumFactoryProvider for now.
                         WebViewChromiumFactoryProvider.this.optOutDataReductionProxy();
                     }
+
+                    // TODO: Add @Override.
+                    public void enableSlowWholeDocumentDraw() {
+                        WebViewChromium.enableSlowWholeDocumentDraw();
+                    }
                 };
             }
         }