Bug 1268887 - DON'T USE: Always restore about:home panel draft
authorAndrzej Hunt <ahunt@mozilla.com>
Fri, 29 Apr 2016 16:40:55 +0200
changeset 357838 ab877878c7f2c32a9b2738f90bbdcc82c01caf02
parent 357837 a63b4895de0d13760a070e4220497594576b0675
child 519715 cb6d7f1913f58f24a2322e28a4d8edea2e4a873c
push id16857
push userahunt@mozilla.com
push dateFri, 29 Apr 2016 14:41:27 +0000
bugs1268887
milestone49.0a1
Bug 1268887 - DON'T USE: Always restore about:home panel This is flawed, we shouldn't use this. MozReview-Commit-ID: 9JPHsvSiwix
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -2624,29 +2624,24 @@ public class BrowserApp extends GeckoApp
             return;
         }
 
         // History will only store that we were visiting about:home, however the specific panel
         // isn't stored. (We are able to navigate directly to homepanels using an about:home?panel=...
         // URL, but the reverse doesn't apply: manually switching panels doesn't update the URL.)
         // Hence we need to restore the panel, in addition to panel state, here.
         if (isAboutHome(tab)) {
-            String panelId = AboutPages.getPanelIdFromAboutHomeUrl(tab.getURL());
-            Bundle panelRestoreData = null;
-            if (panelId == null) {
-                // No panel was specified in the URL. Try loading the most recent
-                // home panel for this tab.
-                // Note: this isn't necessarily correct. We don't update the URL when we switch tabs.
-                // If a user explicitly navigated to about:reader?panel=FOO, and then switches
-                // to panel BAR, the history URL still contains FOO, and we restore to FOO. In most
-                // cases however we aren't supplying a panel ID in the URL so this code still works
-                // for most cases.
-                panelId = tab.getMostRecentHomePanel();
-                panelRestoreData = tab.getMostRecentHomePanelData();
-            }
+            // It's possible that the about:home url contains a panelId, which can be retrieved using
+            // AboutPages.getPanelIdFromAboutHomeUrl(tab.getURL());
+            // This may be garbage if we're going back in history, but may be valid (if we're explicitly
+            // switching directly to e.g. the bookmarks panel. We therefore can't restore if a panelId
+            // has been supplied, therefore this code is WRONG.
+            final String panelId = tab.getMostRecentHomePanel();
+            final Bundle panelRestoreData = tab.getMostRecentHomePanelData();
+
             showHomePager(panelId, panelRestoreData);
 
             if (mDynamicToolbar.isEnabled()) {
                 mDynamicToolbar.setVisible(true, VisibilityTransition.ANIMATE);
             }
         } else {
             hideHomePager();
         }