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. | |
rohitrao (ping after 24h)
2017/04/28 10:39:59
Perhaps mention somewhere that these two values ar
justincohen
2017/04/28 13:23:04
Done.
| |
197 @property(nonatomic, assign) BOOL canGoForward; | |
198 | |
199 // |YES| if the google landing toolbar can show the back arrow. | |
200 @property(nonatomic, assign) BOOL canGoBack; | |
201 | |
196 // iPhone landscape uses a slightly different layout for the doodle and search | 202 // iPhone landscape uses a slightly different layout for the doodle and search |
197 // field frame. Returns the proper frame from |frames| based on orientation, | 203 // field frame. Returns the proper frame from |frames| based on orientation, |
198 // centered in the view. | 204 // centered in the view. |
199 - (CGRect)getOrientationFrame:(const CGRect[])frames; | 205 - (CGRect)getOrientationFrame:(const CGRect[])frames; |
200 // Returns the proper frame for the doodle. | 206 // Returns the proper frame for the doodle. |
201 - (CGRect)doodleFrame; | 207 - (CGRect)doodleFrame; |
202 // Returns the proper frame for the search field. | 208 // Returns the proper frame for the search field. |
203 - (CGRect)searchFieldFrame; | 209 - (CGRect)searchFieldFrame; |
204 // Returns the height to use for the What's New promo view. | 210 // Returns the height to use for the What's New promo view. |
205 - (CGFloat)promoHeaderHeight; | 211 - (CGFloat)promoHeaderHeight; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 @synthesize dataSource = _dataSource; | 262 @synthesize dataSource = _dataSource; |
257 // Property declared in NewTabPagePanelProtocol. | 263 // Property declared in NewTabPagePanelProtocol. |
258 @synthesize delegate = _delegate; | 264 @synthesize delegate = _delegate; |
259 @synthesize isOffTheRecord = _isOffTheRecord; | 265 @synthesize isOffTheRecord = _isOffTheRecord; |
260 @synthesize logoIsShowing = _logoIsShowing; | 266 @synthesize logoIsShowing = _logoIsShowing; |
261 @synthesize promoText = _promoText; | 267 @synthesize promoText = _promoText; |
262 @synthesize promoIcon = _promoIcon; | 268 @synthesize promoIcon = _promoIcon; |
263 @synthesize promoCanShow = _promoCanShow; | 269 @synthesize promoCanShow = _promoCanShow; |
264 @synthesize maximumMostVisitedSitesShown = _maximumMostVisitedSitesShown; | 270 @synthesize maximumMostVisitedSitesShown = _maximumMostVisitedSitesShown; |
265 @synthesize tabCount = _tabCount; | 271 @synthesize tabCount = _tabCount; |
272 @synthesize canGoForward = _canGoForward; | |
273 @synthesize canGoBack = _canGoBack; | |
266 @synthesize voiceSearchIsEnabled = _voiceSearchIsEnabled; | 274 @synthesize voiceSearchIsEnabled = _voiceSearchIsEnabled; |
267 | 275 |
268 - (void)loadView { | 276 - (void)loadView { |
269 self.view = [[[GoogleLandingView alloc] | 277 self.view = [[[GoogleLandingView alloc] |
270 initWithFrame:[UIScreen mainScreen].bounds] autorelease]; | 278 initWithFrame:[UIScreen mainScreen].bounds] autorelease]; |
271 } | 279 } |
272 | 280 |
273 - (void)viewDidLoad { | 281 - (void)viewDidLoad { |
274 [super viewDidLoad]; | 282 [super viewDidLoad]; |
275 [self.view setAutoresizingMask:UIViewAutoresizingFlexibleHeight | | 283 [self.view setAutoresizingMask:UIViewAutoresizingFlexibleHeight | |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
993 forIndexPath:indexPath] retain]); | 1001 forIndexPath:indexPath] retain]); |
994 [_headerView addSubview:[self.logoVendor view]]; | 1002 [_headerView addSubview:[self.logoVendor view]]; |
995 [_headerView addSubview:_searchTapTarget]; | 1003 [_headerView addSubview:_searchTapTarget]; |
996 [_headerView addViewsToSearchField:_searchTapTarget]; | 1004 [_headerView addViewsToSearchField:_searchTapTarget]; |
997 | 1005 |
998 if (!IsIPadIdiom()) { | 1006 if (!IsIPadIdiom()) { |
999 // iPhone header also contains a toolbar since the normal toolbar is | 1007 // iPhone header also contains a toolbar since the normal toolbar is |
1000 // hidden. | 1008 // hidden. |
1001 [_headerView addToolbarWithDataSource:self.dataSource]; | 1009 [_headerView addToolbarWithDataSource:self.dataSource]; |
1002 [_headerView setToolbarTabCount:self.tabCount]; | 1010 [_headerView setToolbarTabCount:self.tabCount]; |
1011 [_headerView setCanGoForward:self.canGoForward]; | |
1012 [_headerView setCanGoBack:self.canGoBack]; | |
1003 } | 1013 } |
1004 [_supplementaryViews addObject:_headerView]; | 1014 [_supplementaryViews addObject:_headerView]; |
1005 } | 1015 } |
1006 return _headerView; | 1016 return _headerView; |
1007 } | 1017 } |
1008 | 1018 |
1009 if (indexPath.section == SectionWithMostVisited) { | 1019 if (indexPath.section == SectionWithMostVisited) { |
1010 if (!_promoHeaderView) { | 1020 if (!_promoHeaderView) { |
1011 _promoHeaderView.reset([[collectionView | 1021 _promoHeaderView.reset([[collectionView |
1012 dequeueReusableSupplementaryViewOfKind: | 1022 dequeueReusableSupplementaryViewOfKind: |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1487 NSIndexPath* indexPath = | 1497 NSIndexPath* indexPath = |
1488 [NSIndexPath indexPathForRow:index inSection:SectionWithMostVisited]; | 1498 [NSIndexPath indexPathForRow:index inSection:SectionWithMostVisited]; |
1489 [_mostVisitedView reloadItemsAtIndexPaths:@[ indexPath ]]; | 1499 [_mostVisitedView reloadItemsAtIndexPaths:@[ indexPath ]]; |
1490 } | 1500 } |
1491 | 1501 |
1492 - (void)setTabCount:(int)tabCount { | 1502 - (void)setTabCount:(int)tabCount { |
1493 _tabCount = tabCount; | 1503 _tabCount = tabCount; |
1494 [_headerView setToolbarTabCount:self.tabCount]; | 1504 [_headerView setToolbarTabCount:self.tabCount]; |
1495 } | 1505 } |
1496 | 1506 |
1507 - (void)setCanGoForward:(BOOL)canGoForward { | |
1508 _canGoForward = canGoForward; | |
1509 [_headerView setCanGoForward:self.canGoForward]; | |
1510 } | |
1511 | |
1512 - (void)setCanGoBack:(BOOL)canGoBack { | |
1513 _canGoBack = canGoBack; | |
1514 [_headerView setCanGoBack:self.canGoBack]; | |
1515 } | |
1497 @end | 1516 @end |
OLD | NEW |