Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: ios/chrome/browser/ui/ntp/google_landing_controller.mm

Issue 2663323002: Cleanup and add NOTREACHED to supplementaryView method. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/ntp/google_landing_controller.mm
diff --git a/ios/chrome/browser/ui/ntp/google_landing_controller.mm b/ios/chrome/browser/ui/ntp/google_landing_controller.mm
index 72bf5d67beae87d0e8750945d0e82bf1c4619d9d..02de0627710da47fb5299189b57b4c51cf4e76d0 100644
--- a/ios/chrome/browser/ui/ntp/google_landing_controller.mm
+++ b/ios/chrome/browser/ui/ntp/google_landing_controller.mm
@@ -1223,57 +1223,61 @@ void SearchEngineObserver::OnTemplateURLServiceChanged() {
- (UICollectionReusableView*)collectionView:(UICollectionView*)collectionView
viewForSupplementaryElementOfKind:(NSString*)kind
atIndexPath:(NSIndexPath*)indexPath {
+ DCHECK(kind == UICollectionElementKindSectionHeader);
+
if (!_supplementaryViews)
_supplementaryViews.reset([[NSMutableArray alloc] init]);
- if (kind == UICollectionElementKindSectionHeader) {
- NSUInteger section = indexPath.section;
- if (section == SectionWithOmnibox) {
- if (!_headerView) {
- _headerView.reset([[collectionView
- dequeueReusableSupplementaryViewOfKind:
- UICollectionElementKindSectionHeader
- withReuseIdentifier:@"header"
- forIndexPath:indexPath] retain]);
- [_headerView addSubview:[_doodleController view]];
- [_headerView addSubview:_searchTapTarget];
- [_headerView addViewsToSearchField:_searchTapTarget];
-
- if (!IsIPadIdiom()) {
- ReadingListModel* readingListModel = nullptr;
- if (reading_list::switches::IsReadingListEnabled()) {
- readingListModel =
- ReadingListModelFactory::GetForBrowserState(_browserState);
- }
- // iPhone header also contains a toolbar since the normal toolbar is
- // hidden.
- [_headerView addToolbarWithDelegate:_webToolbarDelegate
- focuser:_focuser
- tabModel:_tabModel
- readingListModel:readingListModel];
+
+ if (indexPath.section == SectionWithOmnibox) {
+ if (!_headerView) {
+ _headerView.reset([[collectionView
+ dequeueReusableSupplementaryViewOfKind:
+ UICollectionElementKindSectionHeader
+ withReuseIdentifier:@"header"
+ forIndexPath:indexPath] retain]);
+ [_headerView addSubview:[_doodleController view]];
+ [_headerView addSubview:_searchTapTarget];
+ [_headerView addViewsToSearchField:_searchTapTarget];
+
+ if (!IsIPadIdiom()) {
+ ReadingListModel* readingListModel = nullptr;
+ if (reading_list::switches::IsReadingListEnabled()) {
+ readingListModel =
+ ReadingListModelFactory::GetForBrowserState(_browserState);
}
- [_supplementaryViews addObject:_headerView];
+ // iPhone header also contains a toolbar since the normal toolbar is
+ // hidden.
+ [_headerView addToolbarWithDelegate:_webToolbarDelegate
+ focuser:_focuser
+ tabModel:_tabModel
+ readingListModel:readingListModel];
}
- return _headerView;
- } else if (section == SectionWithMostVisited) {
- if (!_promoHeaderView) {
- _promoHeaderView.reset([[collectionView
- dequeueReusableSupplementaryViewOfKind:
- UICollectionElementKindSectionHeader
- withReuseIdentifier:@"whatsNew"
- forIndexPath:indexPath] retain]);
- [_promoHeaderView setSideMargin:[self leftMargin]];
- [_promoHeaderView setDelegate:self];
- if (_notification_promo && _notification_promo->CanShow()) {
- [_promoHeaderView setText:base::SysUTF8ToNSString(
- _notification_promo->promo_text())];
- [_promoHeaderView setIcon:_notification_promo->icon()];
- _notification_promo->HandleViewed();
- }
- [_supplementaryViews addObject:_promoHeaderView];
+ [_supplementaryViews addObject:_headerView];
+ }
+ return _headerView;
+ }
+
+ if (indexPath.section == SectionWithMostVisited) {
+ if (!_promoHeaderView) {
+ _promoHeaderView.reset([[collectionView
+ dequeueReusableSupplementaryViewOfKind:
+ UICollectionElementKindSectionHeader
+ withReuseIdentifier:@"whatsNew"
+ forIndexPath:indexPath] retain]);
+ [_promoHeaderView setSideMargin:[self leftMargin]];
+ [_promoHeaderView setDelegate:self];
+ if (_notification_promo && _notification_promo->CanShow()) {
+ [_promoHeaderView
+ setText:base::SysUTF8ToNSString(_notification_promo->promo_text())];
+ [_promoHeaderView setIcon:_notification_promo->icon()];
+ _notification_promo->HandleViewed();
}
- return _promoHeaderView;
+ [_supplementaryViews addObject:_promoHeaderView];
}
+ return _promoHeaderView;
}
+
+ NOTREACHED();
return nil;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698