| Index: chrome/browser/tabs/tab_strip_model.cc
|
| diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
|
| index 8ac8fc443028242484d4212533a9a4b045b44f7f..269de35f021e68fb9b1ab828787416217ee90260 100644
|
| --- a/chrome/browser/tabs/tab_strip_model.cc
|
| +++ b/chrome/browser/tabs/tab_strip_model.cc
|
| @@ -82,6 +82,13 @@ void TabStripModelObserver::TabReplacedAt(TabContents* old_contents,
|
| int index) {
|
| }
|
|
|
| +void TabStripModelObserver::TabReplacedAt(TabContents* old_contents,
|
| + TabContents* new_contents,
|
| + int index,
|
| + TabReplaceType type) {
|
| + TabReplacedAt(old_contents, new_contents, index);
|
| +}
|
| +
|
| void TabStripModelObserver::TabPinnedStateChanged(TabContents* contents,
|
| int index) {
|
| }
|
| @@ -233,6 +240,13 @@ void TabStripModel::InsertTabContentsAt(int index,
|
| ChangeSelectedContentsFrom(selected_contents, index, false);
|
| }
|
|
|
| +void TabStripModel::ReplaceTabContentsAt(
|
| + int index,
|
| + TabContents* new_contents,
|
| + TabStripModelObserver::TabReplaceType type) {
|
| + delete ReplaceTabContentsAtImpl(index, new_contents, type);
|
| +}
|
| +
|
| void TabStripModel::ReplaceNavigationControllerAt(
|
| int index, NavigationController* controller) {
|
| // This appears to be OK with no flicker since no redraw event
|
| @@ -1043,14 +1057,10 @@ bool TabStripModel::ShouldMakePhantomOnClose(int index) {
|
| }
|
|
|
| void TabStripModel::MakePhantom(int index) {
|
| - TabContents* old_contents = GetContentsAt(index);
|
| - TabContents* new_contents = old_contents->CloneAndMakePhantom();
|
| -
|
| - contents_data_[index]->contents = new_contents;
|
| -
|
| - // And notify observers.
|
| - FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
|
| - TabReplacedAt(old_contents, new_contents, index));
|
| + // MakePhantom is called when the TabContents is being destroyed so we don't
|
| + // need to do anything with the returned value from ReplaceTabContentsAtImpl.
|
| + ReplaceTabContentsAtImpl(index, GetContentsAt(index)->CloneAndMakePhantom(),
|
| + TabStripModelObserver::REPLACE_MADE_PHANTOM);
|
|
|
| if (selected_index_ == index && HasNonPhantomTabs()) {
|
| // Change the selection, otherwise we're going to force the phantom tab
|
| @@ -1095,3 +1105,20 @@ bool TabStripModel::OpenerMatches(const TabContentsData* data,
|
| bool use_group) {
|
| return data->opener == opener || (use_group && data->group == opener);
|
| }
|
| +
|
| +TabContents* TabStripModel::ReplaceTabContentsAtImpl(
|
| + int index,
|
| + TabContents* new_contents,
|
| + TabStripModelObserver::TabReplaceType type) {
|
| + // TODO: this should reset group/opener of any tabs that point at
|
| + // old_contents.
|
| + DCHECK(ContainsIndex(index));
|
| +
|
| + TabContents* old_contents = GetContentsAt(index);
|
| +
|
| + contents_data_[index]->contents = new_contents;
|
| +
|
| + FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
|
| + TabReplacedAt(old_contents, new_contents, index, type));
|
| + return old_contents;
|
| +}
|
|
|