[iOS] Remove favicon and title for NTP tabs in the tab grid.

This CL special-cases NTP URLs (chrome://newtab) in the tab grid
mediator to set no title or favicon in the grid items sent to the
consumer; this means that the corresponding cells in the tab grid will
have no titles or favicons.

In order to cleanly support cells having no icons, the icon image view
background is set to be clear when there is no image.

Bug: 865074
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I13eeeb3c494f7c5f300f2b179da4887dfeb9cdca
Reviewed-on: https://chromium-review.googlesource.com/1143262
Reviewed-by: Gauthier Ambard <gambard@chromium.org>
Commit-Queue: Mark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576458}
diff --git a/ios/chrome/browser/ui/tab_grid/grid/grid_cell.mm b/ios/chrome/browser/ui/tab_grid/grid/grid_cell.mm
index eb8d5c4..d32534bf 100644
--- a/ios/chrome/browser/ui/tab_grid/grid/grid_cell.mm
+++ b/ios/chrome/browser/ui/tab_grid/grid/grid_cell.mm
@@ -202,6 +202,14 @@
 
 - (void)setIcon:(UIImage*)icon {
   self.iconView.image = icon;
+  // if |icon| is nil (that is, the cell should have no icon), set the icon
+  // background to be clear; otherwise set it to be the icon background.
+  if (icon) {
+    self.iconView.backgroundColor =
+        UIColorFromRGB(kGridCellIconBackgroundColor);
+  } else {
+    self.iconView.backgroundColor = UIColor.clearColor;
+  }
   _icon = icon;
 }
 
diff --git a/ios/chrome/browser/ui/tab_grid/tab_grid_mediator.mm b/ios/chrome/browser/ui/tab_grid/tab_grid_mediator.mm
index b116cd5..0245cd1f 100644
--- a/ios/chrome/browser/ui/tab_grid/tab_grid_mediator.mm
+++ b/ios/chrome/browser/ui/tab_grid/tab_grid_mediator.mm
@@ -11,6 +11,7 @@
 #include "components/favicon/ios/web_favicon_driver.h"
 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
 #include "ios/chrome/browser/chrome_url_constants.h"
+#import "ios/chrome/browser/chrome_url_util.h"
 #include "ios/chrome/browser/experimental_flags.h"
 #import "ios/chrome/browser/snapshots/snapshot_cache.h"
 #import "ios/chrome/browser/snapshots/snapshot_cache_factory.h"
@@ -36,7 +37,10 @@
 GridItem* CreateItem(web::WebState* web_state) {
   TabIdTabHelper* tab_helper = TabIdTabHelper::FromWebState(web_state);
   GridItem* item = [[GridItem alloc] initWithIdentifier:tab_helper->tab_id()];
-  item.title = base::SysUTF16ToNSString(web_state->GetTitle());
+  // chrome://newtab (NTP) tabs have no title.
+  if (!IsURLNtp(web_state->GetVisibleURL())) {
+    item.title = base::SysUTF16ToNSString(web_state->GetTitle());
+  }
   return item;
 }
 
@@ -319,6 +323,10 @@
   if (!webState) {
     return;
   }
+  // NTP tabs get no favicon.
+  if (IsURLNtp(webState->GetVisibleURL())) {
+    return;
+  }
   UIImage* defaultFavicon;
   if (experimental_flags::IsCollectionsUIRebootEnabled()) {
     defaultFavicon = [UIImage imageNamed:@"default_world_favicon"];