Skip to content

Commit

Permalink
[iOS] Don't hide the omnibox on incognito NTP
Browse files Browse the repository at this point in the history
The omnibox should only be hidden on non-incognito NTP.

Fixed: 1090521
Change-Id: I521a466b92eb29ccbef78e90b4c6e02aedff091c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2236410
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Commit-Queue: David Jean <djean@chromium.org>
Reviewed-by: David Jean <djean@chromium.org>
Auto-Submit: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#777303}
  • Loading branch information
Gauthier Ambard authored and Commit Bot committed Jun 11, 2020
1 parent f7c6722 commit e2287c3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ios/chrome/browser/ui/toolbar/primary_toolbar_coordinator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/mac/foundation_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/sys_string_conversions.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/ui/commands/command_dispatcher.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_controller.h"
Expand Down Expand Up @@ -71,6 +72,8 @@ - (void)start {
forProtocol:@protocol(FakeboxFocuser)];

self.viewController = [[PrimaryToolbarViewController alloc] init];
self.viewController.shouldHideOmniboxOnNTP =
!self.browser->GetBrowserState()->IsOffTheRecord();
self.viewController.buttonFactory = [self buttonFactoryWithType:PRIMARY];
// TODO(crbug.com/1045047): Use HandlerForProtocol after commands protocol
// clean up.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

@property(nonatomic, weak) id<PrimaryToolbarViewControllerDelegate> delegate;

// Whether the omnibox should be hidden on NTP.
@property(nonatomic, assign) BOOL shouldHideOmniboxOnNTP;

// Sets the location bar view controller, containing the omnibox.
- (void)setLocationBarViewController:(UIViewController*)locationBarView;

Expand Down
10 changes: 8 additions & 2 deletions ios/chrome/browser/ui/toolbar/primary_toolbar_view_controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,16 @@ - (void)setIsNTP:(BOOL)isNTP {
return;
[super setIsNTP:isNTP];
_isNTP = isNTP;
if (!isNTP && !IsSplitToolbarMode(self)) {
if (IsSplitToolbarMode(self) || !self.shouldHideOmniboxOnNTP)
return;

// This is hiding/showing and positionning the omnibox. This is only needed
// if the omnibox should be hidden when there is only one toolbar.
if (!isNTP) {
// Reset any location bar view updates when not an NTP.
[self setScrollProgressForTabletOmnibox:1];
} else if (isNTP && !IsSplitToolbarMode(self)) {
} else {
// Hides the omnibox.
[self setScrollProgressForTabletOmnibox:0];
}
}
Expand Down

0 comments on commit e2287c3

Please sign in to comment.