summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-29 05:52:57 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-29 05:52:57 +0000
commit06d31f0faf9bfb5dd23b5b54621781564fed710c (patch)
treeb1b7a993c2f1e60a059879a70559f05e7706ab96
parente4d0ff8452e962af5397fd58b96f4b8124c1e4c2 (diff)
downloadchromium_src-06d31f0faf9bfb5dd23b5b54621781564fed710c.zip
chromium_src-06d31f0faf9bfb5dd23b5b54621781564fed710c.tar.gz
chromium_src-06d31f0faf9bfb5dd23b5b54621781564fed710c.tar.bz2
Add a return value to InternalCloseTabContentsAt, indicating whether or not the TabContents was closed immediately or if we're waiting for an unload handler to fire.
Adjust indices in Close other tabs handler to take into account the fact that some tabs may not close immediately B=1295790 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63 0039d316-1c4b-4281-b951-d872f2087c98
-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;