summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc19
-rw-r--r--chrome/browser/tabs/tab_strip_model.h11
2 files changed, 21 insertions, 9 deletions
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index a5e58f9..614d29a6 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -461,11 +461,17 @@ void TabStripModel::ExecuteContextMenuCommand(
case CommandCloseOtherTabs: {
UserMetrics::RecordAction(L"TabContextMenu_CloseOtherTabs", profile_);
// Remove tabs before the tab to keep.
- for (int i = 0; i < context_index; i++)
- CloseTabContentsAt(0);
+ int index = 0;
+ for (int i = 0; i < context_index; i++) {
+ if (!CloseTabContentsAt(index))
+ ++index;
+ }
// Remove all tabs after the tab to keep.
- for (int i = 1, c = count(); i < c; i++)
- CloseTabContentsAt(1);
+ index = 1;
+ for (int i = 1, c = count(); i < c; i++) {
+ if (!CloseTabContentsAt(index))
+ ++index;
+ }
break;
}
case CommandCloseTabsToRight: {
@@ -513,7 +519,7 @@ void TabStripModel::Observe(NotificationType type,
///////////////////////////////////////////////////////////////////////////////
// TabStripModel, private:
-void TabStripModel::InternalCloseTabContentsAt(int index,
+bool TabStripModel::InternalCloseTabContentsAt(int index,
bool create_historical_tab) {
TabContents* detached_contents = GetContentsAt(index);
@@ -526,7 +532,7 @@ void TabStripModel::InternalCloseTabContentsAt(int index,
// If we hit this code path, the tab had better be a WebContents tab.
DCHECK(web_contents);
web_contents->render_view_host()->AttemptToClosePage(false);
- return;
+ return false;
}
// TODO: Now that we know the tab has no unload/beforeunload listeners,
@@ -548,6 +554,7 @@ void TabStripModel::InternalCloseTabContentsAt(int index,
// Closing the TabContents will later call back to us via
// NotificationObserver and detach it.
}
+ return true;
}
TabContents* TabStripModel::GetContentsAt(int index) const {
diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h
index aaa3edb..8a235c5 100644
--- a/chrome/browser/tabs/tab_strip_model.h
+++ b/chrome/browser/tabs/tab_strip_model.h
@@ -248,8 +248,10 @@ class TabStripModel : public NotificationObserver {
// Closes the TabContents at the specified index. This causes the TabContents
// to be destroyed, but it may not happen immediately (e.g. if it's a
// WebContents).
- void CloseTabContentsAt(int index) {
- InternalCloseTabContentsAt(index, true);
+ // Returns true if the TabContents was closed immediately, false if we are
+ // waiting for a response from an onunload handler.
+ bool CloseTabContentsAt(int index) {
+ return InternalCloseTabContentsAt(index, true);
}
// Replaces the entire state of a the tab at index by switching in a
@@ -426,7 +428,10 @@ class TabStripModel : public NotificationObserver {
// The boolean parameter create_historical_tab controls whether to
// record this tab and its history for reopening recently closed
// tabs.
- void InternalCloseTabContentsAt(int index, bool create_historical_tab);
+ //
+ // Returns true if the TabContents was closed immediately, false if we are
+ // waiting for the result of an onunload handler.
+ bool InternalCloseTabContentsAt(int index, bool create_historical_tab);
TabContents* GetContentsAt(int index) const;