Don't assume WebContents has a LastCommittedEntry when setting zoom.

In HostZoomMapImpl::SetZoomLevelForWebContents() we currently make the
assumption that the WebContents passed in will always have a non-null
last-committed navigation entry, but this leads to failures on the
fuzzing tests. This CL removes that assumption, and ignores attempts to
set zoom if no such entry exists.

BUG=382320

Review URL: https://codereview.chromium.org/320863002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276040 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/host_zoom_map_impl.cc b/content/browser/host_zoom_map_impl.cc
index a0a68da..c52d54f8 100644
--- a/content/browser/host_zoom_map_impl.cc
+++ b/content/browser/host_zoom_map_impl.cc
@@ -247,11 +247,14 @@
     // WebContentsImpl::GetLastCommittedURL() may give us a virtual url that
     // is different than what the render view is using. If the two don't match,
     // the attempt to set the zoom will fail.
-    GURL url;
     NavigationEntry* entry =
         web_contents_impl.GetController().GetLastCommittedEntry();
-    DCHECK(entry);
-    url = entry->GetURL();
+    // Tests may invoke this function with a null entry, but we don't
+    // want to save zoom levels in this case.
+    if (!entry)
+      return;
+
+    GURL url = entry->GetURL();
     SetZoomLevelForHost(net::GetHostOrSpecFromURL(url), level);
   }
 }