handle preload tab when max count is reached
Bug: 5066968
when opening the pre-load tab, check against max count
if max count is already reached, replace the least
used tab with the pre-loaded tab; it's back/forward
history will be lost
Change-Id: I091b6b066a3e990f330be458d4aff72f62c8de38
diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java
index 7055ef3..cd8da2e 100644
--- a/src/com/android/browser/TabControl.java
+++ b/src/com/android/browser/TabControl.java
@@ -514,6 +514,25 @@
return tabsToGo;
}
+ Tab getLeastUsedTab(Tab current) {
+ if (getTabCount() == 1 || current == null) {
+ return null;
+ }
+ if (mTabQueue.size() == 0) {
+ return null;
+ }
+ // find a tab which is not the current tab or the parent of the
+ // current tab
+ for (Tab t : mTabQueue) {
+ if (t != null && t.getWebView() != null) {
+ if (t != current && t != current.getParent()) {
+ return t;
+ }
+ }
+ }
+ return null;
+ }
+
/**
* Show the tab that contains the given WebView.
* @param view The WebView used to find the tab.