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

[ios] Don't show a sad tab over the NTP.

Don't layer the sad tab overlay over the NTP, since it doesn't matter of the web
process bails for about://newtab.  Interestingly enough, this is a possible
outcome.

Bug: 932618
Change-Id: I9cc2afdb0e5ca6ac9de9a9e8ad91146574392e99
Reviewed-on: https://chromium-review.googlesource.com/c/1475793
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Auto-Submit: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632729}
parent e234f2cf
...@@ -40,6 +40,7 @@ source_set("web") { ...@@ -40,6 +40,7 @@ source_set("web") {
"//ios/chrome/app/strings:ios_strings_grit", "//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser", "//ios/chrome/browser",
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/ntp",
"//ios/chrome/browser/snapshots", "//ios/chrome/browser/snapshots",
"//ios/chrome/browser/ui", "//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/commands:commands", "//ios/chrome/browser/ui/commands:commands",
...@@ -105,7 +106,9 @@ source_set("unit_tests") { ...@@ -105,7 +106,9 @@ source_set("unit_tests") {
"//components/search_engines", "//components/search_engines",
"//components/services/unzip/public/interfaces", "//components/services/unzip/public/interfaces",
"//components/strings:components_strings_grit", "//components/strings:components_strings_grit",
"//ios/chrome/browser",
"//ios/chrome/browser/browser_state:test_support", "//ios/chrome/browser/browser_state:test_support",
"//ios/chrome/browser/ntp",
"//ios/chrome/browser/snapshots", "//ios/chrome/browser/snapshots",
"//ios/chrome/test:test_support", "//ios/chrome/test:test_support",
"//ios/net:test_support", "//ios/net:test_support",
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
#import "ios/chrome/browser/ntp/new_tab_page_tab_helper.h"
#include "ios/chrome/browser/ui/fullscreen/fullscreen_controller_factory.h" #include "ios/chrome/browser/ui/fullscreen/fullscreen_controller_factory.h"
#include "ios/chrome/browser/ui/fullscreen/scoped_fullscreen_disabler.h" #include "ios/chrome/browser/ui/fullscreen/scoped_fullscreen_disabler.h"
#import "ios/chrome/browser/web/page_placeholder_tab_helper.h" #import "ios/chrome/browser/web/page_placeholder_tab_helper.h"
...@@ -102,6 +103,13 @@ void SadTabTabHelper::WasHidden(web::WebState* web_state) { ...@@ -102,6 +103,13 @@ void SadTabTabHelper::WasHidden(web::WebState* web_state) {
void SadTabTabHelper::RenderProcessGone(web::WebState* web_state) { void SadTabTabHelper::RenderProcessGone(web::WebState* web_state) {
DCHECK_EQ(web_state_, web_state); DCHECK_EQ(web_state_, web_state);
// Don't present a sad tab on top of an NTP.
NewTabPageTabHelper* NTPHelper = NewTabPageTabHelper::FromWebState(web_state);
if (NTPHelper && NTPHelper->IsActive()) {
return;
}
if (!web_state->IsVisible()) { if (!web_state->IsVisible()) {
requires_reload_on_becoming_visible_ = true; requires_reload_on_becoming_visible_ = true;
return; return;
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
#include "base/test/scoped_task_environment.h" #include "base/test/scoped_task_environment.h"
#include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
#include "ios/chrome/browser/chrome_url_constants.h"
#import "ios/chrome/browser/ntp/new_tab_page_tab_helper.h"
#import "ios/chrome/browser/ntp/new_tab_page_tab_helper_delegate.h"
#import "ios/chrome/browser/web/page_placeholder_tab_helper.h" #import "ios/chrome/browser/web/page_placeholder_tab_helper.h"
#import "ios/chrome/browser/web/sad_tab_tab_helper_delegate.h" #import "ios/chrome/browser/web/sad_tab_tab_helper_delegate.h"
#import "ios/web/public/test/fakes/fake_navigation_context.h" #import "ios/web/public/test/fakes/fake_navigation_context.h"
...@@ -142,6 +145,25 @@ TEST_F(SadTabTabHelperTest, AppInBackground) { ...@@ -142,6 +145,25 @@ TEST_F(SadTabTabHelperTest, AppInBackground) {
EXPECT_TRUE(navigation_manager_->LoadIfNecessaryWasCalled()); EXPECT_TRUE(navigation_manager_->LoadIfNecessaryWasCalled());
} }
// Tests that SadTab is not presented if app is displaying the NTP.
TEST_F(SadTabTabHelperTest, AppOnNTP) {
web_state_.WasShown();
web_state_.SetVisibleURL(GURL(kChromeUINewTabURL));
id delegate = OCMProtocolMock(@protocol(NewTabPageTabHelperDelegate));
NewTabPageTabHelper::CreateForWebState(&web_state_, delegate);
// Delegate and TabHelper should not present a SadTab.
EXPECT_FALSE(tab_helper()->is_showing_sad_tab());
EXPECT_FALSE(sad_tab_delegate_.showingSadTab);
// Helper should get notified of render process failure,
// but Sad Tab should not be presented, because application is on the NTP.
web_state_.OnRenderProcessGone();
EXPECT_FALSE(tab_helper()->is_showing_sad_tab());
EXPECT_FALSE(sad_tab_delegate_.showingSadTab);
}
// Tests that SadTab is not presented if app is in inactive and navigation // Tests that SadTab is not presented if app is in inactive and navigation
// item is reloaded once the app became active. // item is reloaded once the app became active.
TEST_F(SadTabTabHelperTest, AppIsInactive) { TEST_F(SadTabTabHelperTest, AppIsInactive) {
......
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