Keep URL in omnibox when navigating to chrome://bookmarks on iPhone
This is to fix the bug that when navigating to chrome://bookmarks, the
URL in omnibox was mistakenly cleared if chrome://bookmarks is disabled
(non-iPad or new bookmarks flag is ON).
Bug: 777510
Change-Id: I4d9dfd790c155e8351db9d9049b053c740d9f318
Reviewed-on: https://chromium-review.googlesource.com/737290
Commit-Queue: Marti Wong <[email protected]>
Reviewed-by: Sylvain Defresne <[email protected]>
Reviewed-by: Gauthier Ambard <[email protected]>
Cr-Commit-Position: refs/heads/master@{#512734}
diff --git a/ios/chrome/browser/ui/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view_controller.mm
index 257b863..ed4a6aab 100644
--- a/ios/chrome/browser/ui/browser_view_controller.mm
+++ b/ios/chrome/browser/ui/browser_view_controller.mm
@@ -3395,7 +3395,7 @@
}
- (BOOL)hasControllerForURL:(const GURL&)url {
- std::string host(url.host());
+ base::StringPiece host = url.host_piece();
if (host == kChromeUIOfflineHost) {
// Only allow offline URL that are fully specified.
return reading_list::IsOfflineURLValid(
@@ -3403,8 +3403,7 @@
}
if (host == kChromeUIBookmarksHost) {
- // Only allow bookmark URL on iPad when Bookmarks is not shown modally.
- return IsIPadIdiom() && !PresentNTPPanelModally();
+ return IsBookmarksHostEnabled();
}
return host == kChromeUINewTabHost;
@@ -3415,10 +3414,9 @@
DCHECK(url.SchemeIs(kChromeUIScheme));
id<CRWNativeContent> nativeController = nil;
- std::string url_host = url.host();
+ base::StringPiece url_host = url.host_piece();
if (url_host == kChromeUINewTabHost ||
- (IsIPadIdiom() && url_host == kChromeUIBookmarksHost &&
- !PresentNTPPanelModally())) {
+ (url_host == kChromeUIBookmarksHost && IsBookmarksHostEnabled())) {
CGFloat fakeStatusBarHeight = _fakeStatusBarView.frame.size.height;
UIEdgeInsets safeAreaInset = UIEdgeInsetsZero;
if (@available(iOS 11.0, *)) {
@@ -3443,7 +3441,7 @@
// Panel is always NTP for iPhone.
ntp_home::PanelIdentifier panelType = ntp_home::HOME_PANEL;
- if (IsIPadIdiom() && !PresentNTPPanelModally()) {
+ if (IsBookmarksHostEnabled()) {
// New Tab Page can have multiple panels. Each panel is addressable
// by a #fragment, e.g. chrome://newtab/#most_visited takes user to
// the Most Visited page, chrome://newtab/#bookmarks takes user to