Commit 909c936a authored by Mark Cogan's avatar Mark Cogan Committed by Commit Bot

[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/1143262Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Mark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576458}
parent 0f5cb500
......@@ -202,6 +202,14 @@ void PositionView(UIView* view, CGPoint point) {
- (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;
}
......
......@@ -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 @@ namespace {
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 @@ web::WebState* GetWebStateWithId(WebStateList* web_state_list,
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"];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment