summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tabs
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-09 23:28:28 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-09 23:28:28 +0000
commit3b98246a35f25df934bcc1263c266f8b3c04e3be (patch)
tree9a0110d793fd152895d71994346b7117bd4e27b2 /chrome/browser/tabs
parent456152b2db14e57195d78dfda5b0549846dfa936 (diff)
downloadchromium_src-3b98246a35f25df934bcc1263c266f8b3c04e3be.zip
chromium_src-3b98246a35f25df934bcc1263c266f8b3c04e3be.tar.gz
chromium_src-3b98246a35f25df934bcc1263c266f8b3c04e3be.tar.bz2
Bounds check the tab index before attempting to index into the TabStripModel using it. Under some circumstances, it seems like it's possible for the user to close or otherwise manipulate a Tab whose corresponding entry has already been removed from the model. This might be related to animations and performance constraints.
B=1366019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1949 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tabs')
-rw-r--r--chrome/browser/tabs/tab_strip.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/chrome/browser/tabs/tab_strip.cc b/chrome/browser/tabs/tab_strip.cc
index 03f6c2e..57a8e32 100644
--- a/chrome/browser/tabs/tab_strip.cc
+++ b/chrome/browser/tabs/tab_strip.cc
@@ -881,13 +881,13 @@ bool TabStrip::IsTabSelected(const Tab* tab) const {
void TabStrip::SelectTab(Tab* tab) {
int index = GetIndexOfTab(tab);
- if (index != -1)
+ if (model_->ContainsIndex(index))
model_->SelectTabContentsAt(index, true);
}
void TabStrip::CloseTab(Tab* tab) {
int tab_index = GetIndexOfTab(tab);
- if (tab_index != -1) {
+ if (model_->ContainsIndex(tab_index)) {
TabContents* contents = model_->GetTabContentsAt(tab_index);
if (contents)
UserMetrics::RecordAction(L"CloseTab_Mouse", contents->profile());
@@ -905,7 +905,7 @@ void TabStrip::CloseTab(Tab* tab) {
bool TabStrip::IsCommandEnabledForTab(
TabStripModel::ContextMenuCommand command_id, const Tab* tab) const {
int index = GetIndexOfTab(tab);
- if (index != -1)
+ if (model_->ContainsIndex(index))
return model_->IsContextMenuCommandEnabled(index, command_id);
return false;
}
@@ -913,7 +913,7 @@ bool TabStrip::IsCommandEnabledForTab(
void TabStrip::ExecuteCommandForTab(
TabStripModel::ContextMenuCommand command_id, Tab* tab) {
int index = GetIndexOfTab(tab);
- if (index != -1)
+ if (model_->ContainsIndex(index))
model_->ExecuteContextMenuCommand(index, command_id);
}
@@ -921,7 +921,7 @@ void TabStrip::StartHighlightTabsForCommand(
TabStripModel::ContextMenuCommand command_id, Tab* tab) {
if (command_id == TabStripModel::CommandCloseTabsOpenedBy) {
int index = GetIndexOfTab(tab);
- if (index != -1) {
+ if (model_->ContainsIndex(index)) {
std::vector<int> indices = model_->GetIndexesOpenedBy(index);
std::vector<int>::const_iterator iter = indices.begin();
for (; iter != indices.end(); ++iter) {
@@ -933,7 +933,7 @@ void TabStrip::StartHighlightTabsForCommand(
}
} else if (command_id == TabStripModel::CommandCloseTabsToRight) {
int index = GetIndexOfTab(tab);
- if (index != -1) {
+ if (model_->ContainsIndex(index)) {
for (int i = index + 1; i < GetTabCount(); ++i) {
Tab* current_tab = GetTabAt(i);
current_tab->StartPulse();