summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/TabControl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/browser/TabControl.java')
-rw-r--r--src/com/android/browser/TabControl.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java
index 5f3995ff3..1be2016ac 100644
--- a/src/com/android/browser/TabControl.java
+++ b/src/com/android/browser/TabControl.java
@@ -297,10 +297,12 @@ class TabControl {
long[] ids = new long[numTabs];
int i = 0;
for (Tab tab : mTabs) {
- ids[i++] = tab.getId();
if (tab.saveState()) {
+ ids[i++] = tab.getId();
outState.putBundle(Long.toString(tab.getId()),
tab.getSavedState(saveImages));
+ } else {
+ ids[i++] = -1;
}
}
if (!outState.isEmpty()) {
@@ -327,13 +329,12 @@ class TabControl {
}
final long oldcurrent = inState.getLong(CURRENT);
long current = -1;
- if (restoreIncognitoTabs ||
- !inState.getBundle(Long.toString(oldcurrent)).getBoolean(Tab.INCOGNITO)) {
+ if (restoreIncognitoTabs || (hasState(oldcurrent, inState) && !isIncognito(oldcurrent, inState))) {
current = oldcurrent;
} else {
// pick first non incognito tab
for (long id : ids) {
- if (!inState.getBundle(Long.toString(id)).getBoolean(Tab.INCOGNITO)) {
+ if (hasState(id, inState) && !isIncognito(id, inState)) {
current = id;
break;
}
@@ -342,6 +343,20 @@ class TabControl {
return current;
}
+ private boolean hasState(long id, Bundle state) {
+ if (id == -1) return false;
+ Bundle tab = state.getBundle(Long.toString(id));
+ return ((tab != null) && !tab.isEmpty());
+ }
+
+ private boolean isIncognito(long id, Bundle state) {
+ Bundle tabstate = state.getBundle(Long.toString(id));
+ if ((tabstate != null) && !tabstate.isEmpty()) {
+ return tabstate.getBoolean(Tab.INCOGNITO);
+ }
+ return false;
+ }
+
/**
* Restore the state of all the tabs.
* @param currentId The tab id to restore.