Bug 1304914 - Don't show "offline version" notifications on error pages r=sebastian
MozReview-Commit-ID: BE6GPLCAU3h
--- a/mobile/android/base/java/org/mozilla/gecko/delegates/OfflineTabStatusDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/delegates/OfflineTabStatusDelegate.java
@@ -58,19 +58,29 @@ public class OfflineTabStatusDelegate ex
return;
}
// Ignore tabs displaying about pages
if (AboutPages.isAboutPage(tab.getURL())) {
return;
}
+ // We only want to show these notifications for tabs that were loaded successfully.
+ if (tab.getState() != Tab.STATE_SUCCESS) {
+ return;
+ }
+
switch (event) {
- // Show offline notification if tab is visible, or queue it for display later.
- case PAGE_SHOW:
+ // We listen specifically for the STOP event (as opposed to PAGE_SHOW), because we need
+ // to know if page load actually succeeded. When STOP is triggered, tab.getState()
+ // will return definitive STATE_SUCCESS or STATE_ERROR. When PAGE_SHOW is triggered,
+ // tab.getState() will return STATE_LOADING, which is ambiguous for our purposes.
+ // We don't want to show these notifications for 404 pages, for example. See Bug 1304914.
+ case STOP:
+ // Show offline notification if tab is visible, or queue it for display later.
if (!isTabsTrayVisible() && Tabs.getInstance().isSelectedTab(tab)) {
showLoadedOfflineSnackbar(activityReference.get());
} else {
tabsQueuedForOfflineSnackbar.put(tab, null);
}
break;
// Fallthrough; see Bug 1278980 for details on why this event is here.
case OPENED_FROM_TABS_TRAY: