| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/tabs/tab_strip_model.h" | 5 #include "chrome/browser/tabs/tab_strip_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 ++selected_index_; | 158 ++selected_index_; |
| 159 } | 159 } |
| 160 | 160 |
| 161 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | 161 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, |
| 162 TabInsertedAt(contents, index, foreground)); | 162 TabInsertedAt(contents, index, foreground)); |
| 163 | 163 |
| 164 if (foreground) | 164 if (foreground) |
| 165 ChangeSelectedContentsFrom(selected_contents, index, false); | 165 ChangeSelectedContentsFrom(selected_contents, index, false); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void TabStripModel::ReplaceTabContentsAt(int index, | 168 TabContentsWrapper* TabStripModel::ReplaceTabContentsAt( |
| 169 TabContentsWrapper* new_contents) { | 169 int index, |
| 170 TabContentsWrapper* new_contents) { |
| 170 // TODO: this should reset group/opener of any tabs that point at | 171 // TODO: this should reset group/opener of any tabs that point at |
| 171 // old_contents. | 172 // old_contents. |
| 172 DCHECK(ContainsIndex(index)); | 173 DCHECK(ContainsIndex(index)); |
| 173 scoped_ptr<TabContentsWrapper> old_contents(GetContentsAt(index)); | 174 TabContentsWrapper* old_contents = GetContentsAt(index); |
| 174 | 175 |
| 175 contents_data_[index]->contents = new_contents; | 176 contents_data_[index]->contents = new_contents; |
| 176 | 177 |
| 177 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | 178 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, |
| 178 TabReplacedAt(old_contents.get(), new_contents, index)); | 179 TabReplacedAt(old_contents, new_contents, index)); |
| 179 | 180 |
| 180 // When the selected tab contents is replaced send out selected notification | 181 // When the selected tab contents is replaced send out selected notification |
| 181 // too. We do this as nearly all observers need to treat a replace of the | 182 // too. We do this as nearly all observers need to treat a replace of the |
| 182 // selected contents as selection changing. | 183 // selected contents as selection changing. |
| 183 if (selected_index_ == index) { | 184 if (selected_index_ == index) { |
| 184 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | 185 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, |
| 185 TabSelectedAt(old_contents.get(), new_contents, | 186 TabSelectedAt(old_contents, new_contents, |
| 186 selected_index_, false)); | 187 selected_index_, false)); |
| 187 } | 188 } |
| 189 return old_contents; |
| 188 } | 190 } |
| 189 | 191 |
| 190 void TabStripModel::ReplaceNavigationControllerAt( | 192 void TabStripModel::ReplaceNavigationControllerAt( |
| 191 int index, TabContentsWrapper* contents) { | 193 int index, TabContentsWrapper* contents) { |
| 192 // This appears to be OK with no flicker since no redraw event | 194 // This appears to be OK with no flicker since no redraw event |
| 193 // occurs between the call to add an aditional tab and one to close | 195 // occurs between the call to add an aditional tab and one to close |
| 194 // the previous tab. | 196 // the previous tab. |
| 195 InsertTabContentsAt( | 197 InsertTabContentsAt( |
| 196 index + 1, contents, | 198 index + 1, contents, |
| 197 ADD_SELECTED | ADD_INHERIT_GROUP); | 199 ADD_SELECTED | ADD_INHERIT_GROUP); |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | 1003 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, |
| 1002 TabMoved(moved_data->contents, index, to_position)); | 1004 TabMoved(moved_data->contents, index, to_position)); |
| 1003 } | 1005 } |
| 1004 | 1006 |
| 1005 // static | 1007 // static |
| 1006 bool TabStripModel::OpenerMatches(const TabContentsData* data, | 1008 bool TabStripModel::OpenerMatches(const TabContentsData* data, |
| 1007 const NavigationController* opener, | 1009 const NavigationController* opener, |
| 1008 bool use_group) { | 1010 bool use_group) { |
| 1009 return data->opener == opener || (use_group && data->group == opener); | 1011 return data->opener == opener || (use_group && data->group == opener); |
| 1010 } | 1012 } |
| OLD | NEW |