summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2011-07-26 16:37:15 -0700
committerMichael Kolb <kolby@google.com>2011-07-27 10:26:53 -0700
commitff6a748ae78165cc2298f5120a4374b4ed6f836b (patch)
tree1704cb33dca2300924e76e35e0e064ba506e6474 /src/com/android
parentb01c876b978f0b5acf9950194efb28455034f00d (diff)
downloadpackages_apps_Browser-ff6a748ae78165cc2298f5120a4374b4ed6f836b.zip
packages_apps_Browser-ff6a748ae78165cc2298f5120a4374b4ed6f836b.tar.gz
packages_apps_Browser-ff6a748ae78165cc2298f5120a4374b4ed6f836b.tar.bz2
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
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/browser/Controller.java7
-rw-r--r--src/com/android/browser/TabControl.java19
2 files changed, 26 insertions, 0 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 92682c1..b3be618 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -2159,6 +2159,13 @@ public class Controller
return null;
}
}
+ // check tab count and make room for new tab
+ if (!mTabControl.canCreateNewTab()) {
+ Tab leastUsed = mTabControl.getLeastUsedTab(getCurrentTab());
+ if (leastUsed != null) {
+ closeTab(leastUsed);
+ }
+ }
Tab t = tabControl.getTab();
mTabControl.addPreloadedTab(t);
addTab(t);
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 @@ class TabControl {
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.