Bug 1251362 - Part 15 - Redirect direct loads of the Recent Tabs panel about:home URL to the Recent Tabs folder of the Combined History panel. r=liuche draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 26 May 2016 23:04:53 +0200
changeset 376083 aa1cf12a44dd5229d5a2aa8d1bb6ee81bea90bcf
parent 376082 6d09fadb8ee5de47ffd183abead83b109e08e385
child 376084 c0c66dd9832d4905fc8f056b88543d96bd2bebf7
push id20500
push usermozilla@buttercookie.de
push dateTue, 07 Jun 2016 11:41:20 +0000
reviewersliuche
bugs1251362, 1060544
milestone50.0a1
Bug 1251362 - Part 15 - Redirect direct loads of the Recent Tabs panel about:home URL to the Recent Tabs folder of the Combined History panel. r=liuche After detecting multiple successive crashes in a row, we temporarily switch off automatic session restoring and display the Recent Tabs panel instead. As that panel is going to be removed, we intercept loads of the Recent Tabs panel about:home?panel=... URL and redirect them to the Combined History panel. We also use the facilities provided by bug 1060544 to jump directly to the Recent Tabs folder in that case. MozReview-Commit-ID: 7dQ7tW2dD1M
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -2523,16 +2523,22 @@ public class BrowserApp extends GeckoApp
                 // 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.
                 // We can't fix this directly since we can't ignore the panelId if we're explicitly
                 // loading a specific panel, and we currently can't distinguish between loading
                 // history, and loading new pages, see Bug 1268887
                 panelId = tab.getMostRecentHomePanel();
                 panelRestoreData = tab.getMostRecentHomePanelData();
+            } else if (panelId.equals(HomeConfig.getIdForBuiltinPanelType(PanelType.RECENT_TABS))) {
+                // Redirect to the Combined History panel.
+                panelId = HomeConfig.getIdForBuiltinPanelType(PanelType.COMBINED_HISTORY);
+                panelRestoreData = new Bundle();
+                // Jump directly to the Recent Tabs subview of the Combined History panel.
+                panelRestoreData.putBoolean("goToRecentTabs", true);
             }
             showHomePager(panelId, panelRestoreData);
 
             if (mDynamicToolbar.isEnabled()) {
                 mDynamicToolbar.setVisible(true, VisibilityTransition.ANIMATE);
             }
         } else {
             hideHomePager();
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -1448,23 +1448,26 @@ public abstract class GeckoApp
         mDoorHangerPopup = new DoorHangerPopup(this);
         mPluginContainer = (AbsoluteLayout) findViewById(R.id.plugin_container);
         mFormAssistPopup = (FormAssistPopup) findViewById(R.id.form_assist_popup);
     }
 
     /**
      * Loads the initial tab at Fennec startup. If we don't restore tabs, this
      * tab will be about:home, or the homepage if the user has set one.
-     * If we've temporarily disabled restoring to break out of a crash loop, we'll
-     * show the recent tabs panel so the user can manually restore tabs as needed.
+     * If we've temporarily disabled restoring to break out of a crash loop, we'll show
+     * the Recent Tabs folder of the Combined History panel, so the user can manually
+     * restore tabs as needed.
      * If we restore tabs, we don't need to create a new tab.
      */
     protected void loadStartupTab(final int flags) {
         if (!mShouldRestore) {
             if (mLastSessionCrashed) {
+                // The Recent Tabs panel no longer exists, but BrowserApp will redirect us
+                // to the Recent Tabs folder of the Combined History panel.
                 Tabs.getInstance().loadUrl(AboutPages.getURLForBuiltinPanelType(PanelType.RECENT_TABS), flags);
             } else {
                 final String homepage = getHomepage();
                 Tabs.getInstance().loadUrl(!TextUtils.isEmpty(homepage) ? homepage : AboutPages.HOME, flags);
             }
         }
     }
 
--- a/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
@@ -72,16 +72,18 @@ public class CombinedHistoryPanel extend
     public static final int NUM_SMART_FOLDERS = 2;
 
     private CombinedHistoryRecyclerView mRecyclerView;
     private CombinedHistoryAdapter mHistoryAdapter;
     private ClientsAdapter mClientsAdapter;
     private RecentTabsAdapter mRecentTabsAdapter;
     private CursorLoaderCallbacks mCursorLoaderCallbacks;
 
+    private Bundle mSavedRestoreBundle;
+
     private PanelLevel mPanelLevel;
     private Button mPanelFooterButton;
 
     private PanelStateUpdateHandler mPanelStateUpdateHandler;
 
     // Child refresh layout view.
     protected SwipeRefreshLayout mRefreshLayout;
 
@@ -142,16 +144,21 @@ public class CombinedHistoryPanel extend
         mRecentTabsEmptyView = view.findViewById(R.id.home_recent_tabs_empty_view);
         setUpEmptyViews();
 
         mPanelFooterButton = (Button) view.findViewById(R.id.history_panel_footer_button);
         mPanelFooterButton.setText(R.string.home_clear_history_button);
         mPanelFooterButton.setOnClickListener(new OnFooterButtonClickListener());
 
         mRecentTabsAdapter.startListeningForClosedTabs();
+
+        if (mSavedRestoreBundle != null) {
+            setPanelStateFromBundle(mSavedRestoreBundle);
+            mSavedRestoreBundle = null;
+        }
     }
 
     private void setUpRecyclerView() {
         if (mPanelLevel == null) {
             mPanelLevel = PanelLevel.PARENT;
         }
 
         mRecyclerView.setAdapter(mPanelLevel == PanelLevel.PARENT ? mHistoryAdapter :
@@ -226,16 +233,34 @@ public class CombinedHistoryPanel extend
         final ImageView recentTabsIcon = (ImageView) mRecentTabsEmptyView.findViewById(R.id.home_empty_image);
         recentTabsIcon.setImageResource(R.drawable.icon_remote_tabs_empty);
 
         final TextView recentTabsText = (TextView) mRecentTabsEmptyView.findViewById(R.id.home_empty_text);
         recentTabsText.setText(R.string.home_last_tabs_empty);
     }
 
     @Override
+    public void restoreData(Bundle data) {
+        if (mRecyclerView != null) {
+            setPanelStateFromBundle(data);
+        } else {
+            mSavedRestoreBundle = data;
+        }
+    }
+
+    private void setPanelStateFromBundle(Bundle data) {
+        if (data != null && data.getBoolean("goToRecentTabs", false) && mPanelLevel != PanelLevel.CHILD_RECENT_TABS) {
+            mPanelLevel = PanelLevel.CHILD_RECENT_TABS;
+            mRecyclerView.swapAdapter(mRecentTabsAdapter, true);
+            updateEmptyView();
+            updateButtonFromLevel();
+        }
+    }
+
+    @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
         mCursorLoaderCallbacks = new CursorLoaderCallbacks();
     }
 
     @Override
     protected void load() {
         getLoaderManager().initLoader(LOADER_ID_HISTORY, null, mCursorLoaderCallbacks);