Provide a video poster even if the client doesn't.

To match the behaviour of the old webview, use the framework resource
ic_media_video_poster as the default video poster if the WebChromeClient
provided by the client doesn't give us one.

Bug: 11158656
Change-Id: Id8c5b4e546081ed765356c38308cf1b6f198109d
diff --git a/chromium/java/com/android/webview/chromium/WebViewContentsClientAdapter.java b/chromium/java/com/android/webview/chromium/WebViewContentsClientAdapter.java
index d55332f..2554ddf 100644
--- a/chromium/java/com/android/webview/chromium/WebViewContentsClientAdapter.java
+++ b/chromium/java/com/android/webview/chromium/WebViewContentsClientAdapter.java
@@ -20,6 +20,9 @@
 import android.content.Context;
 import android.content.Intent;
 import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Color;
 import android.graphics.Picture;
 import android.net.http.ErrorStrings;
 import android.net.http.SslError;
@@ -772,12 +775,21 @@
     @Override
     public Bitmap getDefaultVideoPoster() {
         TraceEvent.begin();
-        Bitmap result;
+        Bitmap result = null;
         if (mWebChromeClient != null) {
             if (TRACE) Log.d(TAG, "getDefaultVideoPoster");
             result = mWebChromeClient.getDefaultVideoPoster();
-        } else {
-            result = null;
+        }
+        if (result == null) {
+            // The ic_media_video_poster icon is transparent so we need to draw it on a gray
+            // background.
+            Bitmap poster = BitmapFactory.decodeResource(
+                    mWebView.getContext().getResources(),
+                    com.android.internal.R.drawable.ic_media_video_poster);
+            result = Bitmap.createBitmap(poster.getWidth(), poster.getHeight(), poster.getConfig());
+            result.eraseColor(Color.GRAY);
+            Canvas canvas = new Canvas(result);
+            canvas.drawBitmap(poster, 0f, 0f, null);
         }
         TraceEvent.end();
         return result;