summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-30 00:41:01 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-30 00:41:01 +0000
commitad7bc681c78532ec0aa06177857575a96a59df4d (patch)
tree93f23a5a05a0b3937077ce96898e0a890bdd2099 /chrome/browser
parent1d6b2b85fdb0202fc6f17ad4b0f2c4ce83051d4e (diff)
downloadchromium_src-ad7bc681c78532ec0aa06177857575a96a59df4d.zip
chromium_src-ad7bc681c78532ec0aa06177857575a96a59df4d.tar.gz
chromium_src-ad7bc681c78532ec0aa06177857575a96a59df4d.tar.bz2
I screwed this one up, and had my index munging wrong.
This is actually a much simpler approach. Get the TabContents that the context menu was brought up for and reverse walk the list closing all Tabs that don't match. Duh. B=1298878 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc21
1 files changed, 8 insertions, 13 deletions
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index 7ada01d..930a0f9 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -267,8 +267,11 @@ bool TabStripModel::TabsAreLoading() const {
}
bool TabStripModel::TabHasUnloadListener(int index) {
+ // TODO(beng): this should call through to the delegate, so we can mock it
+ // in testing and then provide better test coverage for features
+ // like "close other tabs".
WebContents* web_contents = GetContentsAt(index)->AsWebContents();
- if (web_contents) {
+ if (web_contents)
// If the WebContents is not connected yet, then there's no unload
// handler we can fire even if the WebContents has an unload listener.
// One case where we hit this is in a tab that has an infinite loop
@@ -276,7 +279,6 @@ bool TabStripModel::TabHasUnloadListener(int index) {
return web_contents->notify_disconnection() &&
!web_contents->IsShowingInterstitialPage() &&
web_contents->render_view_host()->HasUnloadListener();
- }
return false;
}
@@ -466,17 +468,10 @@ void TabStripModel::ExecuteContextMenuCommand(
break;
case CommandCloseOtherTabs: {
UserMetrics::RecordAction(L"TabContextMenu_CloseOtherTabs", profile_);
- // Remove tabs before the tab to keep.
- int index = 0;
- for (int i = 0; i < context_index; i++) {
- if (!CloseTabContentsAt(index))
- ++index;
- }
- // Remove all tabs after the tab to keep.
- index = 1;
- for (int i = 1, c = count(); i < c; i++) {
- if (!CloseTabContentsAt(index))
- ++index;
+ TabContents* contents = GetTabContentsAt(context_index);
+ for (int i = count() - 1; i >= 0; --i) {
+ if (GetTabContentsAt(i) != contents)
+ CloseTabContentsAt(i);
}
break;
}