0

[iOS] Hide Tab Grid recently closed section during search when empty

Additionally, remove the Show Full History item when searching because
actions will be added to a new section at the bottom of the table.

Change-Id: I64788695f5c08a1bdf543ff9382f88ebb8fd3edd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3443820
Reviewed-by: Sergio Collazos <sczs@chromium.org>
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#969740}
This commit is contained in:
Mike Dougherty
2022-02-11 00:30:55 +00:00
committed by Chromium LUCI CQ
parent 7a484747a7
commit 79462bfe04

@ -223,10 +223,6 @@ typedef std::pair<SessionID, TableViewURLItem*> RecentlyClosedTableViewItemPair;
}
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
#pragma mark - Setters & Getters
- (void)setBrowser:(Browser*)browser {
@ -318,6 +314,11 @@ typedef std::pair<SessionID, TableViewURLItem*> RecentlyClosedTableViewItemPair;
#pragma mark Recently Closed Section
- (void)addRecentlyClosedSection {
// Hide section during search if empty.
if (![self recentlyClosedTabsSectionExists]) {
return;
}
TableViewModel* model = self.tableViewModel;
// Recently Closed Section.
@ -341,6 +342,12 @@ typedef std::pair<SessionID, TableViewURLItem*> RecentlyClosedTableViewItemPair;
// Add Recently Closed Tabs Cells.
[self addRecentlyClosedTabItems];
if (self.searchTerms.length) {
// Hide the show full history item in the recently closed section while
// searching.
return;
}
// Add show full history item last.
TableViewImageItem* historyItem =
[[TableViewImageItem alloc] initWithType:ItemTypeShowFullHistory];
@ -1158,6 +1165,21 @@ typedef std::pair<SessionID, TableViewURLItem*> RecentlyClosedTableViewItemPair;
#pragma mark - Recently closed tab helpers
- (BOOL)recentlyClosedTabsSectionExists {
// Recently closed section always exists when tab search is disabled.
if (!IsTabsSearchEnabled()) {
return YES;
}
// The recently closed section does not exist if the user is searching and
// there are no matching recently closed items.
if (self.searchTerms.length && [self numberOfRecentlyClosedTabs] == 0) {
return NO;
}
return YES;
}
- (NSInteger)numberOfRecentlyClosedTabs {
if (!self.tabRestoreService)
return 0;