summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tabs/tab_strip_model.cc
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-11-25 19:40:10 +0000
committerBen Murdoch <benm@google.com>2010-12-03 13:52:53 +0000
commit4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7 (patch)
tree938665d93a11fe7a6d0124e3c1e020d1f9d3f947 /chrome/browser/tabs/tab_strip_model.cc
parent7c627d87728a355737862918d144f98f69406954 (diff)
downloadexternal_chromium-4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7.zip
external_chromium-4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7.tar.gz
external_chromium-4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7.tar.bz2
Merge Chromium at r66597: Initial merge by git.
Change-Id: I9639f8a997f90ec219573aa22a49f5dbde78cc7b
Diffstat (limited to 'chrome/browser/tabs/tab_strip_model.cc')
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index 5862727..711fe49 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -789,8 +789,18 @@ bool TabStripModel::IsNewTabAtEndOfTabStrip(TabContents* contents) const {
bool TabStripModel::InternalCloseTabs(const std::vector<int>& indices,
uint32 close_types) {
+ if (indices.empty())
+ return true;
+
bool retval = true;
+ // Map the indices to TabContents, that way if deleting a tab deletes other
+ // tabs we're ok. Crashes seem to indicate during tab deletion other tabs are
+ // getting removed.
+ std::vector<TabContents*> tabs;
+ for (size_t i = 0; i < indices.size(); ++i)
+ tabs.push_back(GetContentsAt(indices[i]));
+
// We only try the fast shutdown path if the whole browser process is *not*
// shutting down. Fast shutdown during browser termination is handled in
// BrowserShutdown.
@@ -824,11 +834,16 @@ bool TabStripModel::InternalCloseTabs(const std::vector<int>& indices,
}
// We now return to our regularly scheduled shutdown procedure.
- for (size_t i = 0; i < indices.size(); ++i) {
- TabContents* detached_contents = GetContentsAt(indices[i]);
+ for (size_t i = 0; i < tabs.size(); ++i) {
+ TabContents* detached_contents = tabs[i];
+ int index = GetIndexOfTabContents(detached_contents);
+ // Make sure we still contain the tab.
+ if (index == kNoTab)
+ continue;
+
detached_contents->OnCloseStarted();
- if (!delegate_->CanCloseContentsAt(indices[i])) {
+ if (!delegate_->CanCloseContentsAt(index)) {
retval = false;
continue;
}
@@ -847,7 +862,7 @@ bool TabStripModel::InternalCloseTabs(const std::vector<int>& indices,
continue;
}
- InternalCloseTab(detached_contents, indices[i],
+ InternalCloseTab(detached_contents, index,
(close_types & CLOSE_CREATE_HISTORICAL_TAB) != 0);
}