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 @@ ...@@ -324,6 +324,8 @@
headerController:self.headerController]; headerController:self.headerController];
self.ntpMediator.headerCollectionInteractionHandler = self.ntpMediator.headerCollectionInteractionHandler =
self.headerCollectionInteractionHandler; self.headerCollectionInteractionHandler;
DCHECK(!self.ntpMediator.primaryViewController);
self.ntpMediator.primaryViewController = self.suggestionsViewController;
} }
self.dragDropHandler = [[URLDragDropHandler alloc] init]; self.dragDropHandler = [[URLDragDropHandler alloc] init];
......
...@@ -248,7 +248,7 @@ initWithCollectionController: ...@@ -248,7 +248,7 @@ initWithCollectionController:
} }
- (CGFloat)pinnedOffsetY { - (CGFloat)pinnedOffsetY {
return [self.headerController pinnedOffsetY]; return [self.headerController pinnedOffsetY] - self.additionalOffset;
} }
- (CGFloat)headerHeight { - (CGFloat)headerHeight {
......
...@@ -27,6 +27,7 @@ class WebState; ...@@ -27,6 +27,7 @@ class WebState;
class AuthenticationService; class AuthenticationService;
class Browser; class Browser;
@protocol BrowserCommands; @protocol BrowserCommands;
@protocol ContentSuggestionsCollectionControlling;
@class ContentSuggestionsHeaderSynchronizer; @class ContentSuggestionsHeaderSynchronizer;
@class ContentSuggestionsMediator; @class ContentSuggestionsMediator;
@class ContentSuggestionsMetricsRecorder; @class ContentSuggestionsMetricsRecorder;
...@@ -48,46 +49,50 @@ class VoiceSearchAvailability; ...@@ -48,46 +49,50 @@ class VoiceSearchAvailability;
ContentSuggestionsGestureCommands, ContentSuggestionsGestureCommands,
ContentSuggestionsHeaderViewControllerDelegate> ContentSuggestionsHeaderViewControllerDelegate>
- (nullable instancetype) - (instancetype)initWithWebState:(web::WebState*)webState
initWithWebState:(nonnull web::WebState*)webState templateURLService:(TemplateURLService*)templateURLService
templateURLService:(nonnull TemplateURLService*)templateURLService URLLoader:(UrlLoadingBrowserAgent*)URLLoader
URLLoader:(nonnull UrlLoadingBrowserAgent*)URLLoader authService:(AuthenticationService*)authService
authService:(nonnull AuthenticationService*)authService identityManager:(signin::IdentityManager*)identityManager
identityManager:(nonnull signin::IdentityManager*)identityManager logoVendor:(id<LogoVendor>)logoVendor
logoVendor:(nonnull id<LogoVendor>)logoVendor
voiceSearchAvailability: voiceSearchAvailability:
(nonnull VoiceSearchAvailability*)voiceSearchAvailability (VoiceSearchAvailability*)voiceSearchAvailability
NS_DESIGNATED_INITIALIZER; NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
// Dispatcher. // Dispatcher.
@property(nonatomic, weak, nullable) @property(nonatomic, weak)
id<ApplicationCommands, BrowserCommands, OmniboxCommands, SnackbarCommands> id<ApplicationCommands, BrowserCommands, OmniboxCommands, SnackbarCommands>
dispatcher; dispatcher;
// Suggestions service used to get the suggestions. // Suggestions service used to get the suggestions.
@property(nonatomic, assign, nonnull) @property(nonatomic, assign)
ntp_snippets::ContentSuggestionsService* suggestionsService; ntp_snippets::ContentSuggestionsService* suggestionsService;
// Recorder for the metrics related to ContentSuggestions. // Recorder for the metrics related to ContentSuggestions.
@property(nonatomic, strong, nullable) @property(nonatomic, strong) ContentSuggestionsMetricsRecorder* metricsRecorder;
ContentSuggestionsMetricsRecorder* metricsRecorder;
// Recorder for the metrics related to the NTP. // 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. // Recorder for the metrics related to the Discover feed.
@property(nonatomic, strong, nullable) @property(nonatomic, strong) DiscoverFeedMetricsRecorder* discoverFeedMetrics;
DiscoverFeedMetricsRecorder* discoverFeedMetrics;
// View Controller displaying the suggestions. // View Controller displaying the suggestions.
@property(nonatomic, weak, nullable) @property(nonatomic, weak)
ContentSuggestionsViewController* suggestionsViewController; 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; ContentSuggestionsHeaderSynchronizer* headerCollectionInteractionHandler;
// Mediator for the ContentSuggestions. // Mediator for the ContentSuggestions.
@property(nonatomic, strong, nonnull) @property(nonatomic, strong) ContentSuggestionsMediator* suggestionsMediator;
ContentSuggestionsMediator* suggestionsMediator;
// Consumer for this mediator. // Consumer for this mediator.
@property(nonatomic, weak, nullable) id<NTPHomeConsumer> consumer; @property(nonatomic, weak) id<NTPHomeConsumer> consumer;
// The browser. // The browser.
@property(nonatomic, assign, nullable) Browser* browser; @property(nonatomic, assign) Browser* browser;
// Inits the mediator. // Inits the mediator.
- (void)setUp; - (void)setUp;
......
...@@ -517,7 +517,7 @@ const char kNTPHelpURL[] = ...@@ -517,7 +517,7 @@ const char kNTPHelpURL[] =
} }
- (BOOL)isScrolledToTop { - (BOOL)isScrolledToTop {
return self.suggestionsViewController.scrolledToTop; return self.primaryViewController.scrolledToTop;
} }
- (void)registerImageUpdater:(id<UserAccountImageUpdateDelegate>)imageUpdater { - (void)registerImageUpdater:(id<UserAccountImageUpdateDelegate>)imageUpdater {
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
@property(nonatomic, strong) NewTabPageViewController* ntpViewController; @property(nonatomic, strong) NewTabPageViewController* ntpViewController;
// Mediator owned by this Coordinator. // Mediator owned by this Coordinator.
@property(nonatomic, strong) NTPHomeMediator* NTPMediator; @property(nonatomic, strong) NTPHomeMediator* ntpMediator;
// Authentication Service for the user's signed-in state. // Authentication Service for the user's signed-in state.
@property(nonatomic, assign) AuthenticationService* authService; @property(nonatomic, assign) AuthenticationService* authService;
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
ios::TemplateURLServiceFactory::GetForBrowserState( ios::TemplateURLServiceFactory::GetForBrowserState(
self.browser->GetBrowserState()); self.browser->GetBrowserState());
self.NTPMediator = [[NTPHomeMediator alloc] self.ntpMediator = [[NTPHomeMediator alloc]
initWithWebState:self.webState initWithWebState:self.webState
templateURLService:templateURLService templateURLService:templateURLService
URLLoader:UrlLoadingBrowserAgent::FromBrowser(self.browser) URLLoader:UrlLoadingBrowserAgent::FromBrowser(self.browser)
...@@ -155,7 +155,7 @@ ...@@ -155,7 +155,7 @@
logoVendor:ios::GetChromeBrowserProvider()->CreateLogoVendor( logoVendor:ios::GetChromeBrowserProvider()->CreateLogoVendor(
self.browser, self.webState) self.browser, self.webState)
voiceSearchAvailability:&_voiceSearchAvailability]; voiceSearchAvailability:&_voiceSearchAvailability];
self.NTPMediator.browser = self.browser; self.ntpMediator.browser = self.browser;
self.contentSuggestionsCoordinator = [[ContentSuggestionsCoordinator alloc] self.contentSuggestionsCoordinator = [[ContentSuggestionsCoordinator alloc]
initWithBaseViewController:nil initWithBaseViewController:nil
...@@ -163,7 +163,7 @@ ...@@ -163,7 +163,7 @@
self.contentSuggestionsCoordinator.webState = self.webState; self.contentSuggestionsCoordinator.webState = self.webState;
self.contentSuggestionsCoordinator.toolbarDelegate = self.toolbarDelegate; self.contentSuggestionsCoordinator.toolbarDelegate = self.toolbarDelegate;
self.contentSuggestionsCoordinator.panGestureHandler = self.panGestureHandler; self.contentSuggestionsCoordinator.panGestureHandler = self.panGestureHandler;
self.contentSuggestionsCoordinator.ntpMediator = self.NTPMediator; self.contentSuggestionsCoordinator.ntpMediator = self.ntpMediator;
self.contentSuggestionsCoordinator.ntpCommandHandler = self; self.contentSuggestionsCoordinator.ntpCommandHandler = self;
[self.contentSuggestionsCoordinator start]; [self.contentSuggestionsCoordinator start];
...@@ -195,6 +195,7 @@ ...@@ -195,6 +195,7 @@
self.ntpViewController.headerController = self.ntpViewController.headerController =
self.contentSuggestionsCoordinator.headerController; self.contentSuggestionsCoordinator.headerController;
self.ntpMediator.primaryViewController = self.ntpViewController;
} }
base::RecordAction(base::UserMetricsAction("MobileNTPShowMostVisited")); 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