summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc10
-rw-r--r--chrome/browser/views/frame/browser_view.cc22
2 files changed, 21 insertions, 11 deletions
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index 2fb46aa..15c22f4 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -117,15 +117,17 @@ void TabStripModel::InsertTabContentsAt(int index,
}
contents_data_.insert(contents_data_.begin() + index, data);
+ if (index <= selected_index_) {
+ // If a tab is inserted before the current selected index,
+ // then |selected_index| needs to be incremented.
+ ++selected_index_;
+ }
+
FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
TabInsertedAt(contents, index, foreground));
if (foreground) {
ChangeSelectedContentsFrom(selected_contents, index, false);
- } else if (index <= selected_index_) {
- // If a tab is inserted before the current selected index that is not
- // foreground, |selected_index| needs to be incremented.
- ++selected_index_;
}
}
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 23d7bd3..f50e6a1 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -1259,8 +1259,8 @@ void BrowserView::TabDetachedAt(TabContents* contents, int index) {
// We need to reset the current tab contents to NULL before it gets
// freed. This is because the focus manager performs some operations
// on the selected TabContents when it is removed.
- infobar_container_->ChangeTabContents(NULL);
contents_container_->ChangeTabContents(NULL);
+ infobar_container_->ChangeTabContents(NULL);
UpdateDevToolsForContents(NULL);
}
}
@@ -1281,8 +1281,22 @@ void BrowserView::TabSelectedAt(TabContents* old_contents,
// Update various elements that are interested in knowing the current
// TabContents.
+
+ // When we toggle the NTP floating bookmarks bar,
+ // we don't want any TabContents to be attached, so that we
+ // avoid an unnecessary resize and re-layout of a TabContents.
+ contents_container_->ChangeTabContents(NULL);
+
infobar_container_->ChangeTabContents(new_contents);
+
+ // Update all the UI bits.
+ UpdateTitleBar();
+ toolbar_->SetProfile(new_contents->profile());
+ UpdateToolbar(new_contents, true);
+ UpdateUIForContents(new_contents);
+
contents_container_->ChangeTabContents(new_contents);
+
UpdateDevToolsForContents(new_contents);
// TODO(beng): This should be called automatically by ChangeTabContents, but I
// am striving for parity now rather than cleanliness. This is
@@ -1295,12 +1309,6 @@ void BrowserView::TabSelectedAt(TabContents* old_contents,
// handlers when we are eventually shown.
new_contents->view()->RestoreFocus();
}
-
- // Update all the UI bits.
- UpdateTitleBar();
- toolbar_->SetProfile(new_contents->profile());
- UpdateToolbar(new_contents, true);
- UpdateUIForContents(new_contents);
}
void BrowserView::TabStripEmpty() {