Commit 2e2442fb authored by adamta's avatar adamta Committed by Chromium LUCI CQ

[iOS] Fake omnibox becomes real omnibox for refactored NTP

Calls the OmniboxCommand to show the omnibox when tapping the fake
omnibox in the refactored NTP. Fixes condition by correctly setting the
parent view controller's "isScrolledToTop" property.

Bug: 1114792
Change-Id: Iaef7b870c35648ab519380aaa94369e74fc20c89
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2628111
Commit-Queue: Adam Trudeau-Arcaro <adamta@google.com>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843337}
parent 9256f7eb
......@@ -324,6 +324,8 @@
headerController:self.headerController];
self.ntpMediator.headerCollectionInteractionHandler =
self.headerCollectionInteractionHandler;
DCHECK(!self.ntpMediator.primaryViewController);
self.ntpMediator.primaryViewController = self.suggestionsViewController;
}
self.dragDropHandler = [[URLDragDropHandler alloc] init];
......
......@@ -248,7 +248,7 @@ initWithCollectionController:
}
- (CGFloat)pinnedOffsetY {
return [self.headerController pinnedOffsetY];
return [self.headerController pinnedOffsetY] - self.additionalOffset;
}
- (CGFloat)headerHeight {
......
......@@ -27,6 +27,7 @@ class WebState;
class AuthenticationService;
class Browser;
@protocol BrowserCommands;
@protocol ContentSuggestionsCollectionControlling;
@class ContentSuggestionsHeaderSynchronizer;
@class ContentSuggestionsMediator;
@class ContentSuggestionsMetricsRecorder;
......@@ -48,46 +49,50 @@ class VoiceSearchAvailability;
ContentSuggestionsGestureCommands,
ContentSuggestionsHeaderViewControllerDelegate>
- (nullable instancetype)
initWithWebState:(nonnull web::WebState*)webState
templateURLService:(nonnull TemplateURLService*)templateURLService
URLLoader:(nonnull UrlLoadingBrowserAgent*)URLLoader
authService:(nonnull AuthenticationService*)authService
identityManager:(nonnull signin::IdentityManager*)identityManager
logoVendor:(nonnull id<LogoVendor>)logoVendor
- (instancetype)initWithWebState:(web::WebState*)webState
templateURLService:(TemplateURLService*)templateURLService
URLLoader:(UrlLoadingBrowserAgent*)URLLoader
authService:(AuthenticationService*)authService
identityManager:(signin::IdentityManager*)identityManager
logoVendor:(id<LogoVendor>)logoVendor
voiceSearchAvailability:
(nonnull VoiceSearchAvailability*)voiceSearchAvailability
(VoiceSearchAvailability*)voiceSearchAvailability
NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)init NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
// Dispatcher.
@property(nonatomic, weak, nullable)
@property(nonatomic, weak)
id<ApplicationCommands, BrowserCommands, OmniboxCommands, SnackbarCommands>
dispatcher;
// Suggestions service used to get the suggestions.
@property(nonatomic, assign, nonnull)
@property(nonatomic, assign)
ntp_snippets::ContentSuggestionsService* suggestionsService;
// Recorder for the metrics related to ContentSuggestions.
@property(nonatomic, strong, nullable)
ContentSuggestionsMetricsRecorder* metricsRecorder;
@property(nonatomic, strong) ContentSuggestionsMetricsRecorder* metricsRecorder;
// Recorder for the metrics related to the NTP.
@property(nonatomic, strong, nullable) NTPHomeMetrics* NTPMetrics;
@property(nonatomic, strong) NTPHomeMetrics* NTPMetrics;
// Recorder for the metrics related to the Discover feed.
@property(nonatomic, strong, nullable)
DiscoverFeedMetricsRecorder* discoverFeedMetrics;
@property(nonatomic, strong) DiscoverFeedMetricsRecorder* discoverFeedMetrics;
// View Controller displaying the suggestions.
@property(nonatomic, weak, nullable)
@property(nonatomic, weak)
ContentSuggestionsViewController* suggestionsViewController;
@property(nonatomic, weak, nullable)
// Primary collection view controller that receives scroll events.
// In the refactored NTP, the Discover feed collection view behaves as the
// primary NTP scroll view. Otherwise, the content suggestions collection view
// becomes the main NTP scroll view.
// TODO(crbug.com/1114792): Change this comment to remove the mention of the
// refactored NTP.
@property(nonatomic, weak) id<ContentSuggestionsCollectionControlling>
primaryViewController;
@property(nonatomic, weak)
ContentSuggestionsHeaderSynchronizer* headerCollectionInteractionHandler;
// Mediator for the ContentSuggestions.
@property(nonatomic, strong, nonnull)
ContentSuggestionsMediator* suggestionsMediator;
@property(nonatomic, strong) ContentSuggestionsMediator* suggestionsMediator;
// Consumer for this mediator.
@property(nonatomic, weak, nullable) id<NTPHomeConsumer> consumer;
@property(nonatomic, weak) id<NTPHomeConsumer> consumer;
// The browser.
@property(nonatomic, assign, nullable) Browser* browser;
@property(nonatomic, assign) Browser* browser;
// Inits the mediator.
- (void)setUp;
......
......@@ -517,7 +517,7 @@ const char kNTPHelpURL[] =
}
- (BOOL)isScrolledToTop {
return self.suggestionsViewController.scrolledToTop;
return self.primaryViewController.scrolledToTop;
}
- (void)registerImageUpdater:(id<UserAccountImageUpdateDelegate>)imageUpdater {
......
......@@ -61,7 +61,7 @@
@property(nonatomic, strong) NewTabPageViewController* ntpViewController;
// Mediator owned by this Coordinator.
@property(nonatomic, strong) NTPHomeMediator* NTPMediator;
@property(nonatomic, strong) NTPHomeMediator* ntpMediator;
// Authentication Service for the user's signed-in state.
@property(nonatomic, assign) AuthenticationService* authService;
......@@ -145,7 +145,7 @@
ios::TemplateURLServiceFactory::GetForBrowserState(
self.browser->GetBrowserState());
self.NTPMediator = [[NTPHomeMediator alloc]
self.ntpMediator = [[NTPHomeMediator alloc]
initWithWebState:self.webState
templateURLService:templateURLService
URLLoader:UrlLoadingBrowserAgent::FromBrowser(self.browser)
......@@ -155,7 +155,7 @@
logoVendor:ios::GetChromeBrowserProvider()->CreateLogoVendor(
self.browser, self.webState)
voiceSearchAvailability:&_voiceSearchAvailability];
self.NTPMediator.browser = self.browser;
self.ntpMediator.browser = self.browser;
self.contentSuggestionsCoordinator = [[ContentSuggestionsCoordinator alloc]
initWithBaseViewController:nil
......@@ -163,7 +163,7 @@
self.contentSuggestionsCoordinator.webState = self.webState;
self.contentSuggestionsCoordinator.toolbarDelegate = self.toolbarDelegate;
self.contentSuggestionsCoordinator.panGestureHandler = self.panGestureHandler;
self.contentSuggestionsCoordinator.ntpMediator = self.NTPMediator;
self.contentSuggestionsCoordinator.ntpMediator = self.ntpMediator;
self.contentSuggestionsCoordinator.ntpCommandHandler = self;
[self.contentSuggestionsCoordinator start];
......@@ -195,6 +195,7 @@
self.ntpViewController.headerController =
self.contentSuggestionsCoordinator.headerController;
self.ntpMediator.primaryViewController = self.ntpViewController;
}
base::RecordAction(base::UserMetricsAction("MobileNTPShowMostVisited"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment