Commit df0da86d authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Immediately hide the NTP when navigating away from it.

Remove the NTP and show the web view more quickly.  WKWebView appears
to run more slowly in certain circumstances when it is obscured by
another view.

Change-Id: I769d9e5602a0b19a0032d5bca2fc6c6d85f3d365
Reviewed-on: https://chromium-review.googlesource.com/c/1333873
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607705}
parent ce65f398
......@@ -81,6 +81,8 @@ void NewTabPageTabHelper::DidStartNavigation(
web::NavigationContext* navigation_context) {
if (IsNTPURL(navigation_context->GetUrl())) {
UpdatePendingItem();
} else {
SetActive(false);
}
}
......
......@@ -143,6 +143,8 @@ TEST_F(NewTabPageTabHelperTest, TestToggleToAndFromNTP) {
GURL not_ntp_url(kTestURL);
context.SetUrl(not_ntp_url);
test_web_state_.OnNavigationStarted(&context);
EXPECT_FALSE(tab_helper()->IsActive());
test_web_state_.OnNavigationFinished(&context);
EXPECT_FALSE(tab_helper()->IsActive());
......@@ -151,6 +153,8 @@ TEST_F(NewTabPageTabHelperTest, TestToggleToAndFromNTP) {
EXPECT_TRUE(tab_helper()->IsActive());
context.SetUrl(not_ntp_url);
test_web_state_.OnNavigationStarted(&context);
EXPECT_FALSE(tab_helper()->IsActive());
test_web_state_.OnNavigationFinished(&context);
EXPECT_FALSE(tab_helper()->IsActive());
}
......@@ -3645,13 +3645,6 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
proposedCredential:(NSURLCredential*)proposedCredential
completionHandler:(void (^)(NSString* username,
NSString* password))handler {
// Hide the NTP immediately when load an HTTP auth page from the NTP.
// |dialogPresenter| should only run when the webState->GetView() is visible.
NewTabPageTabHelper* NTPHelper = NewTabPageTabHelper::FromWebState(webState);
if (NTPHelper && NTPHelper->IsActive()) {
NTPHelper->Deactivate();
}
[self.dialogPresenter runAuthDialogForProtectionSpace:protectionSpace
proposedCredential:proposedCredential
webState:webState
......@@ -4362,7 +4355,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
DCHECK(currentTab);
currentTab.navigationManager->LoadURLWithParams(params);
// Deactive the NTP immediately on a load to hide the NTP quickly, but after
// Deactivate the NTP immediately on a load to hide the NTP quickly, but after
// calling -LoadURLWithParams. Otherwise, if the webState has never been
// visible (such as during startup with an NTP), it's possible the webView can
// trigger a unnecessary load for chrome://newtab.
......
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