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

Side by Side Diff: ios/chrome/browser/ui/ntp/google_landing_controller.mm

Issue 2829003002: Add CommandDispatcher to BrowserViewController. (Closed)
Patch Set: Cleaner Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "components/strings/grit/components_strings.h" 12 #include "components/strings/grit/components_strings.h"
13 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" 13 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
14 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" 14 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
15 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" 15 #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
16 #import "ios/chrome/browser/ui/context_menu/context_menu_coordinator.h" 16 #import "ios/chrome/browser/ui/context_menu/context_menu_coordinator.h"
17 #import "ios/chrome/browser/ui/ntp/google_landing_commands.h"
17 #import "ios/chrome/browser/ui/ntp/google_landing_data_source.h" 18 #import "ios/chrome/browser/ui/ntp/google_landing_data_source.h"
18 #import "ios/chrome/browser/ui/ntp/most_visited_cell.h" 19 #import "ios/chrome/browser/ui/ntp/most_visited_cell.h"
19 #import "ios/chrome/browser/ui/ntp/most_visited_layout.h" 20 #import "ios/chrome/browser/ui/ntp/most_visited_layout.h"
20 #import "ios/chrome/browser/ui/ntp/new_tab_page_header_constants.h" 21 #import "ios/chrome/browser/ui/ntp/new_tab_page_header_constants.h"
21 #import "ios/chrome/browser/ui/ntp/new_tab_page_header_view.h" 22 #import "ios/chrome/browser/ui/ntp/new_tab_page_header_view.h"
22 #import "ios/chrome/browser/ui/ntp/whats_new_header_view.h" 23 #import "ios/chrome/browser/ui/ntp/whats_new_header_view.h"
23 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller. h" 24 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller. h"
25 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h"
24 #include "ios/chrome/browser/ui/ui_util.h" 26 #include "ios/chrome/browser/ui/ui_util.h"
25 #import "ios/chrome/browser/ui/uikit_ui_util.h" 27 #import "ios/chrome/browser/ui/uikit_ui_util.h"
26 #include "ios/chrome/common/string_util.h" 28 #include "ios/chrome/common/string_util.h"
27 #include "ios/chrome/grit/ios_strings.h" 29 #include "ios/chrome/grit/ios_strings.h"
28 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h" 30 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h"
29 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" 31 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
30 #import "ios/web/public/web_state/context_menu_params.h" 32 #import "ios/web/public/web_state/context_menu_params.h"
31 #import "net/base/mac/url_conversions.h" 33 #import "net/base/mac/url_conversions.h"
32 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
33 35
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 224
223 @end 225 @end
224 226
225 @implementation GoogleLandingController 227 @implementation GoogleLandingController
226 228
227 @dynamic view; 229 @dynamic view;
228 @synthesize logoVendor = _logoVendor; 230 @synthesize logoVendor = _logoVendor;
229 @synthesize dataSource = _dataSource; 231 @synthesize dataSource = _dataSource;
230 // Property declared in NewTabPagePanelProtocol. 232 // Property declared in NewTabPagePanelProtocol.
231 @synthesize delegate = _delegate; 233 @synthesize delegate = _delegate;
234 @synthesize dispatcher = _dispatcher;
232 @synthesize isOffTheRecord = _isOffTheRecord; 235 @synthesize isOffTheRecord = _isOffTheRecord;
233 @synthesize logoIsShowing = _logoIsShowing; 236 @synthesize logoIsShowing = _logoIsShowing;
234 @synthesize promoText = _promoText; 237 @synthesize promoText = _promoText;
235 @synthesize promoIcon = _promoIcon; 238 @synthesize promoIcon = _promoIcon;
236 @synthesize promoCanShow = _promoCanShow; 239 @synthesize promoCanShow = _promoCanShow;
237 @synthesize maximumMostVisitedSitesShown = _maximumMostVisitedSitesShown; 240 @synthesize maximumMostVisitedSitesShown = _maximumMostVisitedSitesShown;
238 @synthesize tabCount = _tabCount; 241 @synthesize tabCount = _tabCount;
239 @synthesize voiceSearchIsEnabled = _voiceSearchIsEnabled; 242 @synthesize voiceSearchIsEnabled = _voiceSearchIsEnabled;
240 243
241 - (void)loadView { 244 - (void)loadView {
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 [[_mostVisitedView collectionViewLayout] invalidateLayout]; 751 [[_mostVisitedView collectionViewLayout] invalidateLayout];
749 } 752 }
750 } 753 }
751 completion:^(BOOL finished) { 754 completion:^(BOOL finished) {
752 // Check to see if we are still scrolled to the top -- it's possible 755 // Check to see if we are still scrolled to the top -- it's possible
753 // (and difficult) to resign the first responder and initiate a 756 // (and difficult) to resign the first responder and initiate a
754 // -shiftTilesDown before the animation here completes. 757 // -shiftTilesDown before the animation here completes.
755 if (_scrolledToTop) { 758 if (_scrolledToTop) {
756 _animateHeader = NO; 759 _animateHeader = NO;
757 if (!IsIPadIdiom()) { 760 if (!IsIPadIdiom()) {
758 [self.dataSource onFakeboxAnimationComplete]; 761 [self.dispatcher onFakeboxAnimationComplete];
759 [_headerView fadeOutShadow]; 762 [_headerView fadeOutShadow];
760 [_searchTapTarget setHidden:YES]; 763 [_searchTapTarget setHidden:YES];
761 } 764 }
762 } 765 }
763 }]; 766 }];
764 } 767 }
765 768
766 - (void)searchFieldTapped:(id)sender { 769 - (void)searchFieldTapped:(id)sender {
767 [self.dataSource focusFakebox]; 770 [self.dispatcher focusFakebox];
768 } 771 }
769 772
770 - (void)blurOmnibox { 773 - (void)blurOmnibox {
771 if (_omniboxFocused) { 774 if (_omniboxFocused) {
772 [self.dataSource cancelOmniboxEdit]; 775 [self.dispatcher cancelOmniboxEdit];
773 } else { 776 } else {
774 [self locationBarResignsFirstResponder]; 777 [self locationBarResignsFirstResponder];
775 } 778 }
776 } 779 }
777 780
778 - (void)locationBarResignsFirstResponder { 781 - (void)locationBarResignsFirstResponder {
779 if (!_isShowing && !_scrolledToTop) 782 if (!_isShowing && !_scrolledToTop)
780 return; 783 return;
781 784
782 _omniboxFocused = NO; 785 _omniboxFocused = NO;
783 if ([_contextMenuCoordinator isVisible]) { 786 if ([_contextMenuCoordinator isVisible]) {
784 return; 787 return;
785 } 788 }
786 789
787 [self shiftTilesDown]; 790 [self shiftTilesDown];
788 } 791 }
789 792
790 - (void)shiftTilesDown { 793 - (void)shiftTilesDown {
791 _animateHeader = YES; 794 _animateHeader = YES;
792 _scrolledToTop = NO; 795 _scrolledToTop = NO;
793 if (!IsIPadIdiom()) { 796 if (!IsIPadIdiom()) {
794 [_searchTapTarget setHidden:NO]; 797 [_searchTapTarget setHidden:NO];
795 [self.dataSource onFakeboxBlur]; 798 [self.dispatcher onFakeboxBlur];
796 } 799 }
797 800
798 // Reload most visited sites in case the number of placeholder cells needs to 801 // Reload most visited sites in case the number of placeholder cells needs to
799 // be updated after an orientation change. 802 // be updated after an orientation change.
800 [_mostVisitedView reloadData]; 803 [_mostVisitedView reloadData];
801 804
802 // Reshow views that are within range of the most visited collection view 805 // Reshow views that are within range of the most visited collection view
803 // (if necessary). 806 // (if necessary).
804 [self.view removeGestureRecognizer:_tapGestureRecognizer]; 807 [self.view removeGestureRecognizer:_tapGestureRecognizer];
805 [self.view removeGestureRecognizer:_swipeGestureRecognizer]; 808 [self.view removeGestureRecognizer:_swipeGestureRecognizer];
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 936 dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
934 static_cast<int64_t>(1 * NSEC_PER_SEC)), 937 static_cast<int64_t>(1 * NSEC_PER_SEC)),
935 dispatch_get_main_queue(), ^{ 938 dispatch_get_main_queue(), ^{
936 [blockView release]; 939 [blockView release];
937 }); 940 });
938 } 941 }
939 942
940 const NSUInteger visitedIndex = indexPath.row; 943 const NSUInteger visitedIndex = indexPath.row;
941 [self blurOmnibox]; 944 [self blurOmnibox];
942 DCHECK(visitedIndex < [self numberOfItems]); 945 DCHECK(visitedIndex < [self numberOfItems]);
943 [self.dataSource logMostVisitedClick:visitedIndex tileType:cell.tileType]; 946 [self.dispatcher logMostVisitedClick:visitedIndex tileType:cell.tileType];
944 [self.dataSource loadURL:[self urlForIndex:visitedIndex] 947 [self.dispatcher loadURL:[self urlForIndex:visitedIndex]
945 referrer:web::Referrer() 948 referrer:web::Referrer()
946 transition:ui::PAGE_TRANSITION_AUTO_BOOKMARK 949 transition:ui::PAGE_TRANSITION_AUTO_BOOKMARK
947 rendererInitiated:NO]; 950 rendererInitiated:NO];
948 } 951 }
949 952
950 #pragma mark - UICollectionViewDataSource 953 #pragma mark - UICollectionViewDataSource
951 954
952 - (UICollectionReusableView*)collectionView:(UICollectionView*)collectionView 955 - (UICollectionReusableView*)collectionView:(UICollectionView*)collectionView
953 viewForSupplementaryElementOfKind:(NSString*)kind 956 viewForSupplementaryElementOfKind:(NSString*)kind
954 atIndexPath:(NSIndexPath*)indexPath { 957 atIndexPath:(NSIndexPath*)indexPath {
955 DCHECK(kind == UICollectionElementKindSectionHeader); 958 DCHECK(kind == UICollectionElementKindSectionHeader);
956 959
957 if (!_supplementaryViews) 960 if (!_supplementaryViews)
958 _supplementaryViews.reset([[NSMutableArray alloc] init]); 961 _supplementaryViews.reset([[NSMutableArray alloc] init]);
959 962
960 if (indexPath.section == SectionWithOmnibox) { 963 if (indexPath.section == SectionWithOmnibox) {
961 if (!_headerView) { 964 if (!_headerView) {
962 _headerView.reset([[collectionView 965 _headerView.reset([[collectionView
963 dequeueReusableSupplementaryViewOfKind: 966 dequeueReusableSupplementaryViewOfKind:
964 UICollectionElementKindSectionHeader 967 UICollectionElementKindSectionHeader
965 withReuseIdentifier:@"header" 968 withReuseIdentifier:@"header"
966 forIndexPath:indexPath] retain]); 969 forIndexPath:indexPath] retain]);
967 [_headerView addSubview:[self.logoVendor view]]; 970 [_headerView addSubview:[self.logoVendor view]];
968 [_headerView addSubview:_searchTapTarget]; 971 [_headerView addSubview:_searchTapTarget];
969 [_headerView addViewsToSearchField:_searchTapTarget]; 972 [_headerView addViewsToSearchField:_searchTapTarget];
970 973
971 if (!IsIPadIdiom()) { 974 if (!IsIPadIdiom()) {
972 // iPhone header also contains a toolbar since the normal toolbar is 975 // iPhone header also contains a toolbar since the normal toolbar is
973 // hidden. 976 // hidden.
974 [_headerView addToolbarWithDataSource:self.dataSource]; 977 [_headerView addToolbarWithDataSource:self.dataSource
978 dispatcher:self.dispatcher];
975 [_headerView setToolbarTabCount:self.tabCount]; 979 [_headerView setToolbarTabCount:self.tabCount];
976 } 980 }
977 [_supplementaryViews addObject:_headerView]; 981 [_supplementaryViews addObject:_headerView];
978 } 982 }
979 return _headerView; 983 return _headerView;
980 } 984 }
981 985
982 if (indexPath.section == SectionWithMostVisited) { 986 if (indexPath.section == SectionWithMostVisited) {
983 if (!_promoHeaderView) { 987 if (!_promoHeaderView) {
984 _promoHeaderView.reset([[collectionView 988 _promoHeaderView.reset([[collectionView
985 dequeueReusableSupplementaryViewOfKind: 989 dequeueReusableSupplementaryViewOfKind:
986 UICollectionElementKindSectionHeader 990 UICollectionElementKindSectionHeader
987 withReuseIdentifier:@"whatsNew" 991 withReuseIdentifier:@"whatsNew"
988 forIndexPath:indexPath] retain]); 992 forIndexPath:indexPath] retain]);
989 [_promoHeaderView setSideMargin:[self leftMargin]]; 993 [_promoHeaderView setSideMargin:[self leftMargin]];
990 [_promoHeaderView setDelegate:self]; 994 [_promoHeaderView setDelegate:self];
991 if (self.promoCanShow) { 995 if (self.promoCanShow) {
992 [_promoHeaderView setText:self.promoText]; 996 [_promoHeaderView setText:self.promoText];
993 [_promoHeaderView setIcon:self.promoIcon]; 997 [_promoHeaderView setIcon:self.promoIcon];
994 [self.dataSource promoViewed]; 998 [self.dispatcher promoViewed];
995 } 999 }
996 [_supplementaryViews addObject:_promoHeaderView]; 1000 [_supplementaryViews addObject:_promoHeaderView];
997 } 1001 }
998 return _promoHeaderView; 1002 return _promoHeaderView;
999 } 1003 }
1000 1004
1001 NOTREACHED(); 1005 NOTREACHED();
1002 return nil; 1006 return nil;
1003 } 1007 }
1004 1008
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 1097
1094 // Open In New Tab. 1098 // Open In New Tab.
1095 GURL url = [self urlForIndex:index]; 1099 GURL url = [self urlForIndex:index];
1096 base::WeakNSObject<GoogleLandingController> weakSelf(self); 1100 base::WeakNSObject<GoogleLandingController> weakSelf(self);
1097 action = ^{ 1101 action = ^{
1098 base::scoped_nsobject<GoogleLandingController> strongSelf( 1102 base::scoped_nsobject<GoogleLandingController> strongSelf(
1099 [weakSelf retain]); 1103 [weakSelf retain]);
1100 if (!strongSelf) 1104 if (!strongSelf)
1101 return; 1105 return;
1102 MostVisitedCell* cell = (MostVisitedCell*)sender.view; 1106 MostVisitedCell* cell = (MostVisitedCell*)sender.view;
1103 [strongSelf.get().dataSource logMostVisitedClick:index 1107 [strongSelf.get().dispatcher logMostVisitedClick:index
1104 tileType:cell.tileType]; 1108 tileType:cell.tileType];
1105 [strongSelf.get().dataSource webPageOrderedOpen:url 1109 [strongSelf.get().dispatcher webPageOrderedOpen:url
1106 referrer:web::Referrer() 1110 referrer:web::Referrer()
1107 inBackground:YES 1111 inBackground:YES
1108 appendTo:kCurrentTab]; 1112 appendTo:kCurrentTab];
1109 }; 1113 };
1110 [_contextMenuCoordinator 1114 [_contextMenuCoordinator
1111 addItemWithTitle:l10n_util::GetNSStringWithFixup( 1115 addItemWithTitle:l10n_util::GetNSStringWithFixup(
1112 IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB) 1116 IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB)
1113 action:action]; 1117 action:action];
1114 1118
1115 if (!self.isOffTheRecord) { 1119 if (!self.isOffTheRecord) {
1116 // Open in Incognito Tab. 1120 // Open in Incognito Tab.
1117 action = ^{ 1121 action = ^{
1118 base::scoped_nsobject<GoogleLandingController> strongSelf( 1122 base::scoped_nsobject<GoogleLandingController> strongSelf(
1119 [weakSelf retain]); 1123 [weakSelf retain]);
1120 if (!strongSelf) 1124 if (!strongSelf)
1121 return; 1125 return;
1122 MostVisitedCell* cell = (MostVisitedCell*)sender.view; 1126 MostVisitedCell* cell = (MostVisitedCell*)sender.view;
1123 [strongSelf.get().dataSource logMostVisitedClick:index 1127 [strongSelf.get().dispatcher logMostVisitedClick:index
1124 tileType:cell.tileType]; 1128 tileType:cell.tileType];
1125 [strongSelf.get().dataSource webPageOrderedOpen:url 1129 [strongSelf.get().dispatcher webPageOrderedOpen:url
1126 referrer:web::Referrer() 1130 referrer:web::Referrer()
1127 inIncognito:YES 1131 inIncognito:YES
1128 inBackground:NO 1132 inBackground:NO
1129 appendTo:kCurrentTab]; 1133 appendTo:kCurrentTab];
1130 }; 1134 };
1131 [_contextMenuCoordinator 1135 [_contextMenuCoordinator
1132 addItemWithTitle:l10n_util::GetNSStringWithFixup( 1136 addItemWithTitle:l10n_util::GetNSStringWithFixup(
1133 IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB) 1137 IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB)
1134 action:action]; 1138 action:action];
1135 } 1139 }
1136 1140
1137 // Remove the most visited url. 1141 // Remove the most visited url.
1138 NSString* title = 1142 NSString* title =
1139 l10n_util::GetNSStringWithFixup(IDS_BOOKMARK_BUBBLE_REMOVE_BOOKMARK); 1143 l10n_util::GetNSStringWithFixup(IDS_BOOKMARK_BUBBLE_REMOVE_BOOKMARK);
1140 action = ^{ 1144 action = ^{
1141 base::scoped_nsobject<GoogleLandingController> strongSelf( 1145 base::scoped_nsobject<GoogleLandingController> strongSelf(
1142 [weakSelf retain]); 1146 [weakSelf retain]);
1143 // Early return if the controller has been deallocated. 1147 // Early return if the controller has been deallocated.
1144 if (!strongSelf) 1148 if (!strongSelf)
1145 return; 1149 return;
1146 base::RecordAction(UserMetricsAction("MostVisited_UrlBlacklisted")); 1150 base::RecordAction(UserMetricsAction("MostVisited_UrlBlacklisted"));
1147 [strongSelf.get().dataSource addBlacklistedURL:url]; 1151 [strongSelf.get().dispatcher addBlacklistedURL:url];
1148 [strongSelf showMostVisitedUndoForURL:net::NSURLWithGURL(url)]; 1152 [strongSelf showMostVisitedUndoForURL:net::NSURLWithGURL(url)];
1149 }; 1153 };
1150 [_contextMenuCoordinator addItemWithTitle:title action:action]; 1154 [_contextMenuCoordinator addItemWithTitle:title action:action];
1151 1155
1152 [_contextMenuCoordinator start]; 1156 [_contextMenuCoordinator start];
1153 1157
1154 if (IsIPadIdiom()) 1158 if (IsIPadIdiom())
1155 [self blurOmnibox]; 1159 [self blurOmnibox];
1156 } 1160 }
1157 } 1161 }
1158 1162
1159 - (void)showMostVisitedUndoForURL:(NSURL*)url { 1163 - (void)showMostVisitedUndoForURL:(NSURL*)url {
1160 _deletedUrl.reset([url retain]); 1164 _deletedUrl.reset([url retain]);
1161 1165
1162 MDCSnackbarMessageAction* action = 1166 MDCSnackbarMessageAction* action =
1163 [[[MDCSnackbarMessageAction alloc] init] autorelease]; 1167 [[[MDCSnackbarMessageAction alloc] init] autorelease];
1164 base::WeakNSObject<GoogleLandingController> weakSelf(self); 1168 base::WeakNSObject<GoogleLandingController> weakSelf(self);
1165 action.handler = ^{ 1169 action.handler = ^{
1166 base::scoped_nsobject<GoogleLandingController> strongSelf( 1170 base::scoped_nsobject<GoogleLandingController> strongSelf(
1167 [weakSelf retain]); 1171 [weakSelf retain]);
1168 if (!strongSelf) 1172 if (!strongSelf)
1169 return; 1173 return;
1170 [strongSelf.get().dataSource 1174 [strongSelf.get().dispatcher
1171 removeBlacklistedURL:net::GURLWithNSURL(_deletedUrl)]; 1175 removeBlacklistedURL:net::GURLWithNSURL(_deletedUrl)];
1172 }; 1176 };
1173 action.title = l10n_util::GetNSString(IDS_NEW_TAB_UNDO_THUMBNAIL_REMOVE); 1177 action.title = l10n_util::GetNSString(IDS_NEW_TAB_UNDO_THUMBNAIL_REMOVE);
1174 action.accessibilityIdentifier = @"Undo"; 1178 action.accessibilityIdentifier = @"Undo";
1175 1179
1176 TriggerHapticFeedbackForNotification(UINotificationFeedbackTypeSuccess); 1180 TriggerHapticFeedbackForNotification(UINotificationFeedbackTypeSuccess);
1177 MDCSnackbarMessage* message = [MDCSnackbarMessage 1181 MDCSnackbarMessage* message = [MDCSnackbarMessage
1178 messageWithText:l10n_util::GetNSString( 1182 messageWithText:l10n_util::GetNSString(
1179 IDS_IOS_NEW_TAB_MOST_VISITED_ITEM_REMOVED)]; 1183 IDS_IOS_NEW_TAB_MOST_VISITED_ITEM_REMOVED)];
1180 message.action = action; 1184 message.action = action;
1181 message.category = @"MostVisitedUndo"; 1185 message.category = @"MostVisitedUndo";
1182 [MDCSnackbarManager showMessage:message]; 1186 [MDCSnackbarManager showMessage:message];
1183 } 1187 }
1184 1188
1185 - (void)onPromoLabelTapped { 1189 - (void)onPromoLabelTapped {
1186 [self.dataSource cancelOmniboxEdit]; 1190 [self.dispatcher cancelOmniboxEdit];
1187 [_promoHeaderView setHidden:YES]; 1191 [_promoHeaderView setHidden:YES];
1188 [self.view setNeedsLayout]; 1192 [self.view setNeedsLayout];
1189 [self.dataSource promoTapped]; 1193 [self.dispatcher promoTapped];
1190 } 1194 }
1191 1195
1192 // Returns the Y value to use for the scroll view's contentOffset when scrolling 1196 // Returns the Y value to use for the scroll view's contentOffset when scrolling
1193 // the omnibox to the top of the screen. 1197 // the omnibox to the top of the screen.
1194 - (CGFloat)pinnedOffsetY { 1198 - (CGFloat)pinnedOffsetY {
1195 CGFloat headerHeight = [_headerView frame].size.height; 1199 CGFloat headerHeight = [_headerView frame].size.height;
1196 CGFloat offsetY = 1200 CGFloat offsetY =
1197 headerHeight - ntp_header::kScrolledToTopOmniboxBottomMargin; 1201 headerHeight - ntp_header::kScrolledToTopOmniboxBottomMargin;
1198 if (!IsIPadIdiom()) 1202 if (!IsIPadIdiom())
1199 offsetY -= ntp_header::kToolbarHeight; 1203 offsetY -= ntp_header::kToolbarHeight;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 #pragma mark - UIScrollViewDelegate Methods. 1277 #pragma mark - UIScrollViewDelegate Methods.
1274 1278
1275 - (void)scrollViewDidScroll:(UIScrollView*)scrollView { 1279 - (void)scrollViewDidScroll:(UIScrollView*)scrollView {
1276 [self.delegate updateNtpBarShadowForPanelController:self]; 1280 [self.delegate updateNtpBarShadowForPanelController:self];
1277 [_overscrollActionsController scrollViewDidScroll:scrollView]; 1281 [_overscrollActionsController scrollViewDidScroll:scrollView];
1278 1282
1279 // Blur the omnibox when the scroll view is scrolled below the pinned offset. 1283 // Blur the omnibox when the scroll view is scrolled below the pinned offset.
1280 CGFloat pinnedOffsetY = [self pinnedOffsetY]; 1284 CGFloat pinnedOffsetY = [self pinnedOffsetY];
1281 if (_omniboxFocused && scrollView.dragging && 1285 if (_omniboxFocused && scrollView.dragging &&
1282 scrollView.contentOffset.y < pinnedOffsetY) { 1286 scrollView.contentOffset.y < pinnedOffsetY) {
1283 [self.dataSource cancelOmniboxEdit]; 1287 [self.dispatcher cancelOmniboxEdit];
1284 } 1288 }
1285 1289
1286 if (IsIPadIdiom()) { 1290 if (IsIPadIdiom()) {
1287 return; 1291 return;
1288 } 1292 }
1289 1293
1290 if (_animateHeader) { 1294 if (_animateHeader) {
1291 [self updateSearchField]; 1295 [self updateSearchField];
1292 } 1296 }
1293 } 1297 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 [NSIndexPath indexPathForRow:index inSection:SectionWithMostVisited]; 1465 [NSIndexPath indexPathForRow:index inSection:SectionWithMostVisited];
1462 [_mostVisitedView reloadItemsAtIndexPaths:@[ indexPath ]]; 1466 [_mostVisitedView reloadItemsAtIndexPaths:@[ indexPath ]];
1463 } 1467 }
1464 1468
1465 - (void)setTabCount:(int)tabCount { 1469 - (void)setTabCount:(int)tabCount {
1466 _tabCount = tabCount; 1470 _tabCount = tabCount;
1467 [_headerView setToolbarTabCount:self.tabCount]; 1471 [_headerView setToolbarTabCount:self.tabCount];
1468 } 1472 }
1469 1473
1470 @end 1474 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698