Commit 49ba2b54 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Correct ntp_util URL naming and add new helper.

Changes Url to URL and adds an -IsURLNewTabPage helper.

Change-Id: If80a6e41d9b2d74ed5449550b49de1cb670bed07
Reviewed-on: https://chromium-review.googlesource.com/c/1350191Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610937}
parent 1894813c
......@@ -2570,7 +2570,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
// Hide the toolbar when displaying content suggestions without the tab
// strip, without the focused omnibox, and for UI Refresh, only when in
// split toolbar mode.
hideToolbar = IsVisibleUrlNewTabPage(tab.webState) && !_isOffTheRecord &&
hideToolbar = IsVisibleURLNewTabPage(tab.webState) && !_isOffTheRecord &&
![self.primaryToolbarCoordinator isOmniboxFirstResponder] &&
![self.primaryToolbarCoordinator showingOmniboxPopup] &&
![self canShowTabStrip] && IsSplitToolbarMode(self);
......@@ -3744,7 +3744,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
}
- (CGFloat)nativeContentHeaderHeightForWebState:(web::WebState*)webState {
if (IsVisibleUrlNewTabPage(webState) && ![self canShowTabStrip]) {
if (IsVisibleURLNewTabPage(webState) && ![self canShowTabStrip]) {
if (self.usesFullscreenContainer)
return 0;
// Also subtract the top safe area so the view will appear as full screen.
......@@ -3770,7 +3770,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
- (CGFloat)collapsedTopToolbarHeight {
if (base::FeatureList::IsEnabled(web::features::kOutOfWebFullscreen) &&
IsVisibleUrlNewTabPage(self.currentWebState)) {
IsVisibleURLNewTabPage(self.currentWebState)) {
return 0;
}
CGFloat collapsedToolbarHeight =
......@@ -3786,7 +3786,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
- (CGFloat)expandedTopToolbarHeight {
if (base::FeatureList::IsEnabled(web::features::kOutOfWebFullscreen) &&
IsVisibleUrlNewTabPage(self.currentWebState)) {
IsVisibleURLNewTabPage(self.currentWebState)) {
return 0;
}
return [self primaryToolbarHeightWithInset] +
......@@ -3796,7 +3796,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
- (CGFloat)bottomToolbarHeight {
if (base::FeatureList::IsEnabled(web::features::kOutOfWebFullscreen) &&
IsVisibleUrlNewTabPage(self.currentWebState)) {
IsVisibleURLNewTabPage(self.currentWebState)) {
return 0;
}
return [self secondaryToolbarHeightWithInset];
......@@ -4301,7 +4301,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
[self.sideSwipeController setEnabled:NO];
web::WebState* webState = self.tabModel.currentTab.webState;
if (!IsVisibleUrlNewTabPage(webState)) {
if (!IsVisibleURLNewTabPage(webState)) {
// Tapping on web content area should dismiss the keyboard. Tapping on NTP
// gesture should propagate to NTP view.
[self.view insertSubview:self.typingShield aboveSubview:self.contentArea];
......
......@@ -262,7 +262,7 @@ const int kLocationAuthorizationStatusCount = 4;
- (void)focusOmnibox {
// When the NTP and fakebox are visible, make the fakebox animates into place
// before focusing the omnibox.webState
if (IsVisibleUrlNewTabPage([self webState]) &&
if (IsVisibleURLNewTabPage([self webState]) &&
!self.browserState->IsOffTheRecord()) {
[self.viewController.dispatcher focusFakebox];
} else {
......
......@@ -11,6 +11,7 @@
#include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/chrome/browser/ssl/ios_security_state_tab_helper.h"
#import "ios/chrome/browser/ui/location_bar/location_bar_consumer.h"
#import "ios/chrome/browser/ui/ntp/ntp_util.h"
#import "ios/chrome/browser/ui/omnibox/omnibox_util.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h"
......@@ -184,7 +185,7 @@
- (void)notifyConsumerOfChangedLocation {
[self.consumer updateLocationText:[self currentLocationString]];
GURL URL = self.webState->GetVisibleURL();
BOOL isNTP = URL.GetOrigin() == kChromeUINewTabURL;
BOOL isNTP = IsURLNewTabPage(URL);
if (isNTP) {
[self.consumer updateAfterNavigatingToNTP];
}
......
......@@ -7,8 +7,10 @@
#import "ios/web/public/web_state/web_state.h"
// Returns whether the |web_state| is currently having the NewTabPage url as
// visible URL.
bool IsVisibleUrlNewTabPage(web::WebState* web_state);
// Returns whether the |url| is currently a NewTabPage url.
bool IsURLNewTabPage(const GURL& url);
// Returns whether the |web_state| visible URL is currently a NewTabPage url.
bool IsVisibleURLNewTabPage(web::WebState* web_state);
#endif // IOS_CHROME_BROWSER_UI_NTP_NTP_UTIL_H_
......@@ -12,8 +12,12 @@
#error "This file requires ARC support."
#endif
bool IsVisibleUrlNewTabPage(web::WebState* web_state) {
bool IsURLNewTabPage(const GURL& url) {
return url.GetOrigin() == kChromeUINewTabURL;
}
bool IsVisibleURLNewTabPage(web::WebState* web_state) {
if (!web_state)
return false;
return web_state->GetVisibleURL().GetOrigin() == kChromeUINewTabURL;
return IsURLNewTabPage(web_state->GetVisibleURL());
}
......@@ -110,7 +110,7 @@
- (void)openPopup {
// Show shortcuts when the feature is enabled. Don't show them on NTP as they
// are already part of the NTP.
if (!IsVisibleUrlNewTabPage(self.webStateList->GetActiveWebState()) &&
if (!IsVisibleURLNewTabPage(self.webStateList->GetActiveWebState()) &&
base::FeatureList::IsEnabled(
omnibox::kOmniboxPopupShortcutIconsInZeroState) &&
!self.browserState->IsOffTheRecord()) {
......
......@@ -61,7 +61,7 @@
BOOL shortcutsEnabled = base::FeatureList::IsEnabled(
omnibox::kOmniboxPopupShortcutIconsInZeroState);
BOOL isNTP = IsVisibleUrlNewTabPage(self.webStateList->GetActiveWebState());
BOOL isNTP = IsVisibleURLNewTabPage(self.webStateList->GetActiveWebState());
if (!self.hasResults && (!shortcutsEnabled || isNTP)) {
[self.presenter animateCollapse];
......
......@@ -124,7 +124,7 @@
}
- (void)updateToolbarForSideSwipeSnapshot:(web::WebState*)webState {
BOOL isNTP = IsVisibleUrlNewTabPage(webState);
BOOL isNTP = IsVisibleURLNewTabPage(webState);
[self.mediator updateConsumerForWebState:webState];
[self.viewController updateForSideSwipeSnapshotOnNTP:isNTP];
......
......@@ -174,7 +174,7 @@
- (void)onFakeboxBlur {
// Hide the toolbar if the NTP is currently displayed.
web::WebState* webState = self.webStateList->GetActiveWebState();
if (webState && IsVisibleUrlNewTabPage(webState)) {
if (webState && IsVisibleURLNewTabPage(webState)) {
self.viewController.view.hidden = IsSplitToolbarMode();
}
}
......@@ -201,7 +201,7 @@
- (void)updateToolbarForSideSwipeSnapshot:(web::WebState*)webState {
[super updateToolbarForSideSwipeSnapshot:webState];
BOOL isNTP = IsVisibleUrlNewTabPage(webState);
BOOL isNTP = IsVisibleURLNewTabPage(webState);
// Don't do anything for a live non-ntp tab.
if (webState == self.webStateList->GetActiveWebState() && !isNTP) {
......
......@@ -267,7 +267,7 @@
DCHECK(self.consumer);
[self updateConsumerForWebState:self.webState];
[self.consumer setIsNTP:IsVisibleUrlNewTabPage(self.webState)];
[self.consumer setIsNTP:IsVisibleURLNewTabPage(self.webState)];
[self.consumer setLoadingState:self.webState->IsLoading()];
[self updateBookmarksForWebState:self.webState];
[self updateShareMenuForWebState:self.webState];
......
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