| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/ui/ntp/google_landing_controller.h" | 5 #import "ios/chrome/browser/ui/ntp/google_landing_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
| 10 #import "base/ios/weak_nsobject.h" | 10 #import "base/ios/weak_nsobject.h" |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 referrer:web::Referrer() | 1216 referrer:web::Referrer() |
| 1217 transition:ui::PAGE_TRANSITION_AUTO_BOOKMARK | 1217 transition:ui::PAGE_TRANSITION_AUTO_BOOKMARK |
| 1218 rendererInitiated:NO]; | 1218 rendererInitiated:NO]; |
| 1219 } | 1219 } |
| 1220 | 1220 |
| 1221 #pragma mark - UICollectionViewDataSource | 1221 #pragma mark - UICollectionViewDataSource |
| 1222 | 1222 |
| 1223 - (UICollectionReusableView*)collectionView:(UICollectionView*)collectionView | 1223 - (UICollectionReusableView*)collectionView:(UICollectionView*)collectionView |
| 1224 viewForSupplementaryElementOfKind:(NSString*)kind | 1224 viewForSupplementaryElementOfKind:(NSString*)kind |
| 1225 atIndexPath:(NSIndexPath*)indexPath { | 1225 atIndexPath:(NSIndexPath*)indexPath { |
| 1226 DCHECK(kind == UICollectionElementKindSectionHeader); |
| 1227 |
| 1226 if (!_supplementaryViews) | 1228 if (!_supplementaryViews) |
| 1227 _supplementaryViews.reset([[NSMutableArray alloc] init]); | 1229 _supplementaryViews.reset([[NSMutableArray alloc] init]); |
| 1228 if (kind == UICollectionElementKindSectionHeader) { | |
| 1229 NSUInteger section = indexPath.section; | |
| 1230 if (section == SectionWithOmnibox) { | |
| 1231 if (!_headerView) { | |
| 1232 _headerView.reset([[collectionView | |
| 1233 dequeueReusableSupplementaryViewOfKind: | |
| 1234 UICollectionElementKindSectionHeader | |
| 1235 withReuseIdentifier:@"header" | |
| 1236 forIndexPath:indexPath] retain]); | |
| 1237 [_headerView addSubview:[_doodleController view]]; | |
| 1238 [_headerView addSubview:_searchTapTarget]; | |
| 1239 [_headerView addViewsToSearchField:_searchTapTarget]; | |
| 1240 | 1230 |
| 1241 if (!IsIPadIdiom()) { | 1231 if (indexPath.section == SectionWithOmnibox) { |
| 1242 ReadingListModel* readingListModel = nullptr; | 1232 if (!_headerView) { |
| 1243 if (reading_list::switches::IsReadingListEnabled()) { | 1233 _headerView.reset([[collectionView |
| 1244 readingListModel = | 1234 dequeueReusableSupplementaryViewOfKind: |
| 1245 ReadingListModelFactory::GetForBrowserState(_browserState); | 1235 UICollectionElementKindSectionHeader |
| 1246 } | 1236 withReuseIdentifier:@"header" |
| 1247 // iPhone header also contains a toolbar since the normal toolbar is | 1237 forIndexPath:indexPath] retain]); |
| 1248 // hidden. | 1238 [_headerView addSubview:[_doodleController view]]; |
| 1249 [_headerView addToolbarWithDelegate:_webToolbarDelegate | 1239 [_headerView addSubview:_searchTapTarget]; |
| 1250 focuser:_focuser | 1240 [_headerView addViewsToSearchField:_searchTapTarget]; |
| 1251 tabModel:_tabModel | 1241 |
| 1252 readingListModel:readingListModel]; | 1242 if (!IsIPadIdiom()) { |
| 1243 ReadingListModel* readingListModel = nullptr; |
| 1244 if (reading_list::switches::IsReadingListEnabled()) { |
| 1245 readingListModel = |
| 1246 ReadingListModelFactory::GetForBrowserState(_browserState); |
| 1253 } | 1247 } |
| 1254 [_supplementaryViews addObject:_headerView]; | 1248 // iPhone header also contains a toolbar since the normal toolbar is |
| 1249 // hidden. |
| 1250 [_headerView addToolbarWithDelegate:_webToolbarDelegate |
| 1251 focuser:_focuser |
| 1252 tabModel:_tabModel |
| 1253 readingListModel:readingListModel]; |
| 1255 } | 1254 } |
| 1256 return _headerView; | 1255 [_supplementaryViews addObject:_headerView]; |
| 1257 } else if (section == SectionWithMostVisited) { | 1256 } |
| 1258 if (!_promoHeaderView) { | 1257 return _headerView; |
| 1259 _promoHeaderView.reset([[collectionView | 1258 } |
| 1260 dequeueReusableSupplementaryViewOfKind: | 1259 |
| 1261 UICollectionElementKindSectionHeader | 1260 if (indexPath.section == SectionWithMostVisited) { |
| 1262 withReuseIdentifier:@"whatsNew" | 1261 if (!_promoHeaderView) { |
| 1263 forIndexPath:indexPath] retain]); | 1262 _promoHeaderView.reset([[collectionView |
| 1264 [_promoHeaderView setSideMargin:[self leftMargin]]; | 1263 dequeueReusableSupplementaryViewOfKind: |
| 1265 [_promoHeaderView setDelegate:self]; | 1264 UICollectionElementKindSectionHeader |
| 1266 if (_notification_promo && _notification_promo->CanShow()) { | 1265 withReuseIdentifier:@"whatsNew" |
| 1267 [_promoHeaderView setText:base::SysUTF8ToNSString( | 1266 forIndexPath:indexPath] retain]); |
| 1268 _notification_promo->promo_text())]; | 1267 [_promoHeaderView setSideMargin:[self leftMargin]]; |
| 1269 [_promoHeaderView setIcon:_notification_promo->icon()]; | 1268 [_promoHeaderView setDelegate:self]; |
| 1270 _notification_promo->HandleViewed(); | 1269 if (_notification_promo && _notification_promo->CanShow()) { |
| 1271 } | 1270 [_promoHeaderView |
| 1272 [_supplementaryViews addObject:_promoHeaderView]; | 1271 setText:base::SysUTF8ToNSString(_notification_promo->promo_text())]; |
| 1272 [_promoHeaderView setIcon:_notification_promo->icon()]; |
| 1273 _notification_promo->HandleViewed(); |
| 1273 } | 1274 } |
| 1274 return _promoHeaderView; | 1275 [_supplementaryViews addObject:_promoHeaderView]; |
| 1275 } | 1276 } |
| 1277 return _promoHeaderView; |
| 1276 } | 1278 } |
| 1279 |
| 1280 NOTREACHED(); |
| 1277 return nil; | 1281 return nil; |
| 1278 } | 1282 } |
| 1279 | 1283 |
| 1280 - (NSInteger)numberOfSectionsInCollectionView: | 1284 - (NSInteger)numberOfSectionsInCollectionView: |
| 1281 (UICollectionView*)collectionView { | 1285 (UICollectionView*)collectionView { |
| 1282 return NumberOfCollectionViewSections; | 1286 return NumberOfCollectionViewSections; |
| 1283 } | 1287 } |
| 1284 | 1288 |
| 1285 - (NSInteger)collectionView:(UICollectionView*)collectionView | 1289 - (NSInteger)collectionView:(UICollectionView*)collectionView |
| 1286 numberOfItemsInSection:(NSInteger)section { | 1290 numberOfItemsInSection:(NSInteger)section { |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1740 if (!view) { | 1744 if (!view) { |
| 1741 return nil; | 1745 return nil; |
| 1742 } | 1746 } |
| 1743 if ([view isKindOfClass:aClass]) { | 1747 if ([view isKindOfClass:aClass]) { |
| 1744 return view; | 1748 return view; |
| 1745 } | 1749 } |
| 1746 return [self nearestAncestorOfView:[view superview] withClass:aClass]; | 1750 return [self nearestAncestorOfView:[view superview] withClass:aClass]; |
| 1747 } | 1751 } |
| 1748 | 1752 |
| 1749 @end | 1753 @end |
| OLD | NEW |