Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: ios/chrome/browser/tabs/tab.mm

Issue 2782713002: Correct UIApplicationState check for sad tab test. (Closed)
Patch Set: nit Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/tabs/tab.mm
diff --git a/ios/chrome/browser/tabs/tab.mm b/ios/chrome/browser/tabs/tab.mm
index 30b394fe6b6ed0095dd9fd0d6a102d1c03bac64b..4c03620e18e05d2f23f1067c4f1c04353dabb706 100644
--- a/ios/chrome/browser/tabs/tab.mm
+++ b/ios/chrome/browser/tabs/tab.mm
@@ -199,6 +199,13 @@ enum class RendererTerminationTabState {
BACKGROUND_TAB_BACKGROUND_APP,
TERMINATION_TAB_STATE_COUNT
};
+
+// Returns true if the application is in the background or inactive state.
+bool IsApplicationStateNotActive(UIApplicationState state) {
+ return (state == UIApplicationStateBackground ||
+ state == UIApplicationStateInactive);
+}
+
} // namespace
@interface Tab ()<CRWWebStateObserver,
@@ -1911,6 +1918,8 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
}
- (void)renderProcessGoneForWebState:(web::WebState*)webState {
+ UIApplicationState state = [UIApplication sharedApplication].applicationState;
+ BOOL applicationIsNotActive = IsApplicationStateNotActive(state);
if (browserState_ && !browserState_->IsOffTheRecord()) {
// Report the crash.
GetApplicationContext()
@@ -1921,8 +1930,7 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
RendererTerminationTabState tab_state =
visible_ ? RendererTerminationTabState::FOREGROUND_TAB_FOREGROUND_APP
: RendererTerminationTabState::BACKGROUND_TAB_FOREGROUND_APP;
- if ([UIApplication sharedApplication].applicationState ==
- UIApplicationStateBackground) {
+ if (applicationIsNotActive) {
tab_state =
visible_ ? RendererTerminationTabState::FOREGROUND_TAB_BACKGROUND_APP
: RendererTerminationTabState::BACKGROUND_TAB_BACKGROUND_APP;
@@ -1935,11 +1943,8 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
[parentTabModel_ tabUsageRecorder]->RendererTerminated(self, visible_);
}
- BOOL applicationIsBackgrounded =
- [UIApplication sharedApplication].applicationState ==
- UIApplicationStateBackground;
if (visible_) {
- if (!applicationIsBackgrounded) {
+ if (!applicationIsNotActive) {
base::WeakNSObject<Tab> weakSelf(self);
base::scoped_nsobject<SadTabView> sadTabView(
[[SadTabView alloc] initWithReloadHandler:^{
@@ -1963,7 +1968,7 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
// Note: Given that the tab is visible, calling |requirePageReload| will not
// work when the app becomes active because there is nothing to trigger
// a view redisplay in that scenario.
- requireReloadAfterBecomingActive_ = visible_ && applicationIsBackgrounded;
+ requireReloadAfterBecomingActive_ = visible_ && applicationIsNotActive;
[self.dialogDelegate cancelDialogForTab:self];
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698