diff options
Diffstat (limited to 'src/com/android')
| -rw-r--r-- | src/com/android/browser/Controller.java | 7 | ||||
| -rw-r--r-- | src/com/android/browser/TabControl.java | 19 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 92682c1e9..b3be61873 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 7055ef3bb..cd8da2ed1 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. |
