Enable favicon downloading.

If an app is targetting >= K, always download favicons (as the legacy
method for enabling the behavior is deprecated). Also enable favicon
downloading for legacy apps that use the deprecated method.

Bug: 10825362
Change-Id: Ia0037365fc7211cdf01714d8385907f017225386
(cherry picked from commit 54bae732019ac13327c0a68a6f8a82548d73ea9e)
diff --git a/chromium/java/com/android/webview/chromium/WebIconDatabaseAdapter.java b/chromium/java/com/android/webview/chromium/WebIconDatabaseAdapter.java
index 50bb771..c8af220 100644
--- a/chromium/java/com/android/webview/chromium/WebIconDatabaseAdapter.java
+++ b/chromium/java/com/android/webview/chromium/WebIconDatabaseAdapter.java
@@ -20,14 +20,15 @@
 import android.webkit.WebIconDatabase;
 import android.webkit.WebIconDatabase.IconListener;
 
+import org.chromium.android_webview.AwContents;
+
 /**
  * Chromium implementation of WebIconDatabase -- big old no-op (base class is deprecated).
  */
 final class WebIconDatabaseAdapter extends WebIconDatabase {
     @Override
     public void open(String path) {
-        // Intentional no-op: historically main effect of calling this method was to enable
-        // favicon download, but chromium webview always downloads favicons.
+        AwContents.setShouldDownloadFavicons();
     }
 
     @Override
diff --git a/chromium/java/com/android/webview/chromium/WebViewChromium.java b/chromium/java/com/android/webview/chromium/WebViewChromium.java
index 0354c98..3219de4 100644
--- a/chromium/java/com/android/webview/chromium/WebViewChromium.java
+++ b/chromium/java/com/android/webview/chromium/WebViewChromium.java
@@ -221,6 +221,7 @@
                 mAppTargetSdkVersion < Build.VERSION_CODES.JELLY_BEAN;
         final boolean areLegacyQuirksEnabled =
                 mAppTargetSdkVersion < Build.VERSION_CODES.KITKAT;
+
         mContentsClientAdapter = new WebViewContentsClientAdapter(mWebView);
         mWebSettings = new ContentSettingsAdapter(new AwSettings(
                 mWebView.getContext(), isAccessFromFileURLsGrantedByDefault,
@@ -245,6 +246,12 @@
         mAwContents = new AwContents(mFactory.getBrowserContext(), mWebView,
                 new InternalAccessAdapter(), mContentsClientAdapter, new AwLayoutSizer(),
                 mWebSettings.getAwSettings());
+
+        if (mAppTargetSdkVersion >= Build.VERSION_CODES.KITKAT) {
+            // On KK and above, favicons are automatically downloaded as the method
+            // old apps use to enable that behavior is deprecated.
+            AwContents.setShouldDownloadFavicons();
+        }
     }
 
     void startYourEngine() {