| 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/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // Gets the icon of a what's new promo. | 186 // Gets the icon of a what's new promo. |
| 187 // TODO(crbug.com/694750): This should not be WhatsNewIcon. | 187 // TODO(crbug.com/694750): This should not be WhatsNewIcon. |
| 188 @property(nonatomic, assign) WhatsNewIcon promoIcon; | 188 @property(nonatomic, assign) WhatsNewIcon promoIcon; |
| 189 | 189 |
| 190 // |YES| if a what's new promo can be displayed. | 190 // |YES| if a what's new promo can be displayed. |
| 191 @property(nonatomic, assign) BOOL promoCanShow; | 191 @property(nonatomic, assign) BOOL promoCanShow; |
| 192 | 192 |
| 193 // The number of tabs to show in the google landing fake toolbar. | 193 // The number of tabs to show in the google landing fake toolbar. |
| 194 @property(nonatomic, assign) int tabCount; | 194 @property(nonatomic, assign) int tabCount; |
| 195 | 195 |
| 196 // |YES| if the google landing toolbar can show the forward arrow, cached and |
| 197 // pushed into the header view. |
| 198 @property(nonatomic, assign) BOOL canGoForward; |
| 199 |
| 200 // |YES| if the google landing toolbar can show the back arrow, cached and |
| 201 // pushed into the header view. |
| 202 @property(nonatomic, assign) BOOL canGoBack; |
| 203 |
| 196 // iPhone landscape uses a slightly different layout for the doodle and search | 204 // iPhone landscape uses a slightly different layout for the doodle and search |
| 197 // field frame. Returns the proper frame from |frames| based on orientation, | 205 // field frame. Returns the proper frame from |frames| based on orientation, |
| 198 // centered in the view. | 206 // centered in the view. |
| 199 - (CGRect)getOrientationFrame:(const CGRect[])frames; | 207 - (CGRect)getOrientationFrame:(const CGRect[])frames; |
| 200 // Returns the proper frame for the doodle. | 208 // Returns the proper frame for the doodle. |
| 201 - (CGRect)doodleFrame; | 209 - (CGRect)doodleFrame; |
| 202 // Returns the proper frame for the search field. | 210 // Returns the proper frame for the search field. |
| 203 - (CGRect)searchFieldFrame; | 211 - (CGRect)searchFieldFrame; |
| 204 // Returns the height to use for the What's New promo view. | 212 // Returns the height to use for the What's New promo view. |
| 205 - (CGFloat)promoHeaderHeight; | 213 - (CGFloat)promoHeaderHeight; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 @synthesize dataSource = _dataSource; | 264 @synthesize dataSource = _dataSource; |
| 257 // Property declared in NewTabPagePanelProtocol. | 265 // Property declared in NewTabPagePanelProtocol. |
| 258 @synthesize delegate = _delegate; | 266 @synthesize delegate = _delegate; |
| 259 @synthesize isOffTheRecord = _isOffTheRecord; | 267 @synthesize isOffTheRecord = _isOffTheRecord; |
| 260 @synthesize logoIsShowing = _logoIsShowing; | 268 @synthesize logoIsShowing = _logoIsShowing; |
| 261 @synthesize promoText = _promoText; | 269 @synthesize promoText = _promoText; |
| 262 @synthesize promoIcon = _promoIcon; | 270 @synthesize promoIcon = _promoIcon; |
| 263 @synthesize promoCanShow = _promoCanShow; | 271 @synthesize promoCanShow = _promoCanShow; |
| 264 @synthesize maximumMostVisitedSitesShown = _maximumMostVisitedSitesShown; | 272 @synthesize maximumMostVisitedSitesShown = _maximumMostVisitedSitesShown; |
| 265 @synthesize tabCount = _tabCount; | 273 @synthesize tabCount = _tabCount; |
| 274 @synthesize canGoForward = _canGoForward; |
| 275 @synthesize canGoBack = _canGoBack; |
| 266 @synthesize voiceSearchIsEnabled = _voiceSearchIsEnabled; | 276 @synthesize voiceSearchIsEnabled = _voiceSearchIsEnabled; |
| 267 | 277 |
| 268 - (void)loadView { | 278 - (void)loadView { |
| 269 self.view = [[[GoogleLandingView alloc] | 279 self.view = [[[GoogleLandingView alloc] |
| 270 initWithFrame:[UIScreen mainScreen].bounds] autorelease]; | 280 initWithFrame:[UIScreen mainScreen].bounds] autorelease]; |
| 271 } | 281 } |
| 272 | 282 |
| 273 - (void)viewDidLoad { | 283 - (void)viewDidLoad { |
| 274 [super viewDidLoad]; | 284 [super viewDidLoad]; |
| 275 [self.view setAutoresizingMask:UIViewAutoresizingFlexibleHeight | | 285 [self.view setAutoresizingMask:UIViewAutoresizingFlexibleHeight | |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 forIndexPath:indexPath] retain]); | 1003 forIndexPath:indexPath] retain]); |
| 994 [_headerView addSubview:[self.logoVendor view]]; | 1004 [_headerView addSubview:[self.logoVendor view]]; |
| 995 [_headerView addSubview:_searchTapTarget]; | 1005 [_headerView addSubview:_searchTapTarget]; |
| 996 [_headerView addViewsToSearchField:_searchTapTarget]; | 1006 [_headerView addViewsToSearchField:_searchTapTarget]; |
| 997 | 1007 |
| 998 if (!IsIPadIdiom()) { | 1008 if (!IsIPadIdiom()) { |
| 999 // iPhone header also contains a toolbar since the normal toolbar is | 1009 // iPhone header also contains a toolbar since the normal toolbar is |
| 1000 // hidden. | 1010 // hidden. |
| 1001 [_headerView addToolbarWithDataSource:self.dataSource]; | 1011 [_headerView addToolbarWithDataSource:self.dataSource]; |
| 1002 [_headerView setToolbarTabCount:self.tabCount]; | 1012 [_headerView setToolbarTabCount:self.tabCount]; |
| 1013 [_headerView setCanGoForward:self.canGoForward]; |
| 1014 [_headerView setCanGoBack:self.canGoBack]; |
| 1003 } | 1015 } |
| 1004 [_supplementaryViews addObject:_headerView]; | 1016 [_supplementaryViews addObject:_headerView]; |
| 1005 } | 1017 } |
| 1006 return _headerView; | 1018 return _headerView; |
| 1007 } | 1019 } |
| 1008 | 1020 |
| 1009 if (indexPath.section == SectionWithMostVisited) { | 1021 if (indexPath.section == SectionWithMostVisited) { |
| 1010 if (!_promoHeaderView) { | 1022 if (!_promoHeaderView) { |
| 1011 _promoHeaderView.reset([[collectionView | 1023 _promoHeaderView.reset([[collectionView |
| 1012 dequeueReusableSupplementaryViewOfKind: | 1024 dequeueReusableSupplementaryViewOfKind: |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 NSIndexPath* indexPath = | 1499 NSIndexPath* indexPath = |
| 1488 [NSIndexPath indexPathForRow:index inSection:SectionWithMostVisited]; | 1500 [NSIndexPath indexPathForRow:index inSection:SectionWithMostVisited]; |
| 1489 [_mostVisitedView reloadItemsAtIndexPaths:@[ indexPath ]]; | 1501 [_mostVisitedView reloadItemsAtIndexPaths:@[ indexPath ]]; |
| 1490 } | 1502 } |
| 1491 | 1503 |
| 1492 - (void)setTabCount:(int)tabCount { | 1504 - (void)setTabCount:(int)tabCount { |
| 1493 _tabCount = tabCount; | 1505 _tabCount = tabCount; |
| 1494 [_headerView setToolbarTabCount:self.tabCount]; | 1506 [_headerView setToolbarTabCount:self.tabCount]; |
| 1495 } | 1507 } |
| 1496 | 1508 |
| 1509 - (void)setCanGoForward:(BOOL)canGoForward { |
| 1510 _canGoForward = canGoForward; |
| 1511 [_headerView setCanGoForward:self.canGoForward]; |
| 1512 } |
| 1513 |
| 1514 - (void)setCanGoBack:(BOOL)canGoBack { |
| 1515 _canGoBack = canGoBack; |
| 1516 [_headerView setCanGoBack:self.canGoBack]; |
| 1517 } |
| 1497 @end | 1518 @end |
| OLD | NEW |