[aw] Allow Bitmap allocations to fail without OOM crashing.

One large favicon might cause an OOM crash when it is converted to a
Java-backed Bitmap in Android. Failing to render the favicon still seems
preferable than *ever* crash here.

[email protected],[email protected]

Bug: 1112794
Change-Id: Idca46d2e1484ce4538b79e8df6910de7b18ef1f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2376929
Commit-Queue: Bo <[email protected]>
Reviewed-by: Richard Coles <[email protected]>
Reviewed-by: Bo <[email protected]>
Cr-Commit-Position: refs/heads/master@{#802876}
diff --git a/content/browser/frame_host/navigation_controller_android.cc b/content/browser/frame_host/navigation_controller_android.cc
index 075eb31..4d8453b3 100644
--- a/content/browser/frame_host/navigation_controller_android.cc
+++ b/content/browser/frame_host/navigation_controller_android.cc
@@ -56,8 +56,10 @@
       ConvertUTF8ToJavaString(env, entry->GetReferrer().url.spec()));
   ScopedJavaLocalRef<jobject> j_bitmap;
   const content::FaviconStatus& status = entry->GetFavicon();
-  if (status.valid && status.image.ToSkBitmap()->computeByteSize() > 0)
-    j_bitmap = gfx::ConvertToJavaBitmap(status.image.ToSkBitmap());
+  if (status.valid && status.image.ToSkBitmap()->computeByteSize() > 0) {
+    j_bitmap = gfx::ConvertToJavaBitmap(status.image.ToSkBitmap(),
+                                        gfx::OomBehavior::kReturnNullOnOom);
+  }
   jlong j_timestamp = entry->GetTimestamp().ToJavaTime();
 
   return content::Java_NavigationControllerImpl_createNavigationEntry(