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 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 contents_data_[index]->contents = new_contents; | 176 contents_data_[index]->contents = new_contents; |
177 | 177 |
178 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | 178 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, |
179 TabReplacedAt(this, old_contents, new_contents, index)); | 179 TabReplacedAt(this, old_contents, new_contents, index)); |
180 | 180 |
181 // When the selected tab contents is replaced send out selected notification | 181 // When the selected tab contents is replaced send out selected notification |
182 // 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 |
183 // selected contents as selection changing. | 183 // selected contents as selection changing. |
184 if (selected_index_ == index) { | 184 if (selected_index_ == index) { |
185 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | 185 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, |
186 TabSelectedAt(old_contents, new_contents, | 186 TabSelectionChanged(this, old_contents, false)); |
187 selected_index_, false)); | |
188 } | 187 } |
189 return old_contents; | 188 return old_contents; |
190 } | 189 } |
191 | 190 |
192 void TabStripModel::ReplaceNavigationControllerAt( | 191 void TabStripModel::ReplaceNavigationControllerAt( |
193 int index, TabContentsWrapper* contents) { | 192 int index, TabContentsWrapper* contents) { |
194 // This appears to be OK with no flicker since no redraw event | 193 // This appears to be OK with no flicker since no redraw event |
195 // occurs between the call to add an aditional tab and one to close | 194 // occurs between the call to add an aditional tab and one to close |
196 // the previous tab. | 195 // the previous tab. |
197 InsertTabContentsAt( | 196 InsertTabContentsAt( |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 if (old_contents == new_contents) | 955 if (old_contents == new_contents) |
957 return; | 956 return; |
958 | 957 |
959 TabContentsWrapper* last_selected_contents = old_contents; | 958 TabContentsWrapper* last_selected_contents = old_contents; |
960 if (last_selected_contents) { | 959 if (last_selected_contents) { |
961 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | 960 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, |
962 TabDeselected(last_selected_contents)); | 961 TabDeselected(last_selected_contents)); |
963 } | 962 } |
964 | 963 |
965 selected_index_ = to_index; | 964 selected_index_ = to_index; |
966 ObserverListBase<TabStripModelObserver>::Iterator it(observers_); | 965 |
967 TabStripModelObserver* obs; | 966 FOR_EACH_OBSERVER( |
968 while ((obs = it.GetNext()) != NULL) | 967 TabStripModelObserver, observers_, |
969 obs->TabSelectedAt(last_selected_contents, new_contents, | 968 TabSelectionChanged(this, last_selected_contents, user_gesture)); |
970 selected_index_, user_gesture); | |
971 /* | |
972 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | |
973 TabSelectedAt(last_selected_contents, new_contents, selected_index_, | |
974 user_gesture)); | |
975 */ | |
976 } | 969 } |
977 | 970 |
978 void TabStripModel::SelectRelativeTab(bool next) { | 971 void TabStripModel::SelectRelativeTab(bool next) { |
979 // This may happen during automated testing or if a user somehow buffers | 972 // This may happen during automated testing or if a user somehow buffers |
980 // many key accelerators. | 973 // many key accelerators. |
981 if (contents_data_.empty()) | 974 if (contents_data_.empty()) |
982 return; | 975 return; |
983 | 976 |
984 int index = selected_index_; | 977 int index = selected_index_; |
985 int delta = next ? 1 : -1; | 978 int delta = next ? 1 : -1; |
(...skipping 30 matching lines...) Expand all Loading... |
1016 void TabStripModel::ForgetOpenersAndGroupsReferencing( | 1009 void TabStripModel::ForgetOpenersAndGroupsReferencing( |
1017 const NavigationController* tab) { | 1010 const NavigationController* tab) { |
1018 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); | 1011 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); |
1019 i != contents_data_.end(); ++i) { | 1012 i != contents_data_.end(); ++i) { |
1020 if ((*i)->group == tab) | 1013 if ((*i)->group == tab) |
1021 (*i)->group = NULL; | 1014 (*i)->group = NULL; |
1022 if ((*i)->opener == tab) | 1015 if ((*i)->opener == tab) |
1023 (*i)->opener = NULL; | 1016 (*i)->opener = NULL; |
1024 } | 1017 } |
1025 } | 1018 } |
OLD | NEW |