restore all tabs on demand

	Bug: 3214151
	introduced new flag to determine if all tabs should be restored
   	controlled by the Ui implementation

Change-Id: I3e296f87a93fae54693bca186bb06ecd6db11d02
diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java
index aeffbc0..2d90d23 100644
--- a/src/com/android/browser/TabControl.java
+++ b/src/com/android/browser/TabControl.java
@@ -26,6 +26,7 @@
 import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Vector;
 
 class TabControl {
@@ -99,6 +100,13 @@
     }
 
     /**
+     * return the list of tabs
+     */
+    List<Tab> getTabs() {
+        return mTabs;
+    }
+
+    /**
      * Return the tab at the specified index.
      * @return The Tab for the specified index or null if the tab does not
      *         exist.
@@ -281,10 +289,14 @@
     /**
      * Restore the state of all the tabs.
      * @param inState The saved state of all the tabs.
+     * @param restoreIncognitoTabs Restoring private browsing tabs
+     * @param restoreAll All webviews get restored, not just the current tab
+     *        (this does not override handling of incognito tabs)
      * @return True if there were previous tabs that were restored. False if
      *         there was no saved state or restoring the state failed.
      */
-    boolean restoreState(Bundle inState, boolean dontRestoreIncognitoTabs) {
+    boolean restoreState(Bundle inState, boolean restoreIncognitoTabs,
+            boolean restoreAll) {
         final int numTabs = (inState == null)
                 ? -1 : inState.getInt(Tab.NUMTABS, -1);
         if (numTabs == -1) {
@@ -295,7 +307,7 @@
             // Determine whether the saved current tab can be restored, and
             // if not, which tab will take its place.
             int currentTab = -1;
-            if (!dontRestoreIncognitoTabs
+            if (restoreIncognitoTabs
                     || !inState.getBundle(Tab.WEBVIEW + oldCurrentTab).getBoolean(Tab.INCOGNITO)) {
                 currentTab = oldCurrentTab;
             } else {
@@ -317,13 +329,15 @@
             for (int i = 0; i < numTabs; i++) {
                 Bundle state = inState.getBundle(Tab.WEBVIEW + i);
 
-                if (dontRestoreIncognitoTabs && state != null && state.getBoolean(Tab.INCOGNITO)) {
+                if (!restoreIncognitoTabs && state != null && state.getBoolean(Tab.INCOGNITO)) {
                     originalTabIndices.put(i, -1);
-                } else if (i == currentTab) {
+                } else if (i == currentTab || restoreAll) {
                     Tab t = createNewTab();
                     // Me must set the current tab before restoring the state
                     // so that all the client classes are set.
-                    setCurrentTab(t);
+                    if (i == currentTab) {
+                        setCurrentTab(t);
+                    }
                     if (!t.restoreState(state)) {
                         Log.w(LOGTAG, "Fail in restoreState, load home page.");
                         t.getWebView().loadUrl(BrowserSettings.getInstance()