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/Controller.java b/src/com/android/browser/Controller.java
index 63f104a..79fff3d 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -83,6 +83,7 @@
import java.net.URLEncoder;
import java.util.Calendar;
import java.util.HashMap;
+import java.util.List;
/**
* Controller for browser
@@ -239,11 +240,12 @@
Calendar yesterday = Calendar.getInstance();
yesterday.add(Calendar.DATE, -1);
- boolean dontRestoreIncognitoTabs = lastActiveDate == null
+ boolean restoreIncognitoTabs = !(lastActiveDate == null
|| lastActiveDate.before(yesterday)
- || lastActiveDate.after(today);
+ || lastActiveDate.after(today));
- if (!mTabControl.restoreState(icicle, dontRestoreIncognitoTabs)) {
+ if (!mTabControl.restoreState(icicle, restoreIncognitoTabs,
+ mUi.needsRestoreAllTabs())) {
// there is no quit on Android. But if we can't restore the state,
// we can treat it as a new Browser, remove the old session cookies.
CookieManager.getInstance().removeSessionCookie();
@@ -280,7 +282,8 @@
loadUrlDataIn(t, urlData);
}
} else {
- if (dontRestoreIncognitoTabs) {
+ mUi.updateTabs(mTabControl.getTabs());
+ if (!restoreIncognitoTabs) {
WebView.cleanupPrivateBrowsingFiles(mActivity);
}
// TabControl.restoreState() will create a new tab even if
@@ -338,6 +341,11 @@
return mTabControl;
}
+ @Override
+ public List<Tab> getTabs() {
+ return mTabControl.getTabs();
+ }
+
// Open the icon database and retain all the icons for visited sites.
private void retainIconsOnStartup() {
final WebIconDatabase db = WebIconDatabase.getInstance();