Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/tabs/tab_strip_model.cc

Issue 7043020: Multi-tab selection: Renaming TabStripModelObserver::TabSelectedAt to ActiveTabChanged (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updating TODO comments Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 contents_data_[index]->contents = new_contents; 175 contents_data_[index]->contents = new_contents;
176 176
177 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 177 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
178 TabReplacedAt(this, old_contents, new_contents, index)); 178 TabReplacedAt(this, old_contents, new_contents, index));
179 179
180 // When the active tab contents is replaced send out selected notification 180 // When the active tab contents is replaced send out selected notification
181 // too. We do this as nearly all observers need to treat a replace of the 181 // too. We do this as nearly all observers need to treat a replace of the
182 // selected contents as selection changing. 182 // selected contents as selection changing.
183 if (active_index() == index) { 183 if (active_index() == index) {
184 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 184 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
185 TabSelectedAt(old_contents, new_contents, active_index(), 185 ActiveTabChanged(old_contents, new_contents,
186 false)); 186 active_index(), false));
187 } 187 }
188 return old_contents; 188 return old_contents;
189 } 189 }
190 190
191 void TabStripModel::ReplaceNavigationControllerAt( 191 void TabStripModel::ReplaceNavigationControllerAt(
192 int index, TabContentsWrapper* contents) { 192 int index, TabContentsWrapper* contents) {
193 // 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
194 // 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
195 // the previous tab. 195 // the previous tab.
196 InsertTabContentsAt(index + 1, contents, ADD_ACTIVE | ADD_INHERIT_GROUP); 196 InsertTabContentsAt(index + 1, contents, ADD_ACTIVE | ADD_INHERIT_GROUP);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 (active_index() == TabStripSelectionModel::kUnselectedIndex) ? 247 (active_index() == TabStripSelectionModel::kUnselectedIndex) ?
248 NULL : GetSelectedTabContents(); 248 NULL : GetSelectedTabContents();
249 selection_model_.SetSelectedIndex(index); 249 selection_model_.SetSelectedIndex(index);
250 TabContentsWrapper* new_contents = GetContentsAt(index); 250 TabContentsWrapper* new_contents = GetContentsAt(index);
251 if (old_contents != new_contents && old_contents) { 251 if (old_contents != new_contents && old_contents) {
252 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 252 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
253 TabDeselected(old_contents)); 253 TabDeselected(old_contents));
254 } 254 }
255 if (old_contents != new_contents || had_multi) { 255 if (old_contents != new_contents || had_multi) {
256 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 256 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
257 TabSelectedAt(old_contents, new_contents, 257 ActiveTabChanged(old_contents, new_contents,
258 active_index(), user_gesture)); 258 active_index(), user_gesture));
259 } 259 }
260 } 260 }
261 261
262 void TabStripModel::MoveTabContentsAt(int index, 262 void TabStripModel::MoveTabContentsAt(int index,
263 int to_position, 263 int to_position,
264 bool select_after_move) { 264 bool select_after_move) {
265 DCHECK(ContainsIndex(index)); 265 DCHECK(ContainsIndex(index));
266 if (index == to_position) 266 if (index == to_position)
267 return; 267 return;
268 268
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 if (old_contents == new_contents) 1213 if (old_contents == new_contents)
1214 return; 1214 return;
1215 1215
1216 TabContentsWrapper* last_selected_contents = old_contents; 1216 TabContentsWrapper* last_selected_contents = old_contents;
1217 if (last_selected_contents) { 1217 if (last_selected_contents) {
1218 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 1218 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
1219 TabDeselected(last_selected_contents)); 1219 TabDeselected(last_selected_contents));
1220 } 1220 }
1221 1221
1222 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 1222 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
1223 TabSelectedAt(last_selected_contents, new_contents, 1223 ActiveTabChanged(last_selected_contents, new_contents,
1224 active_index(), user_gesture)); 1224 active_index(), user_gesture));
1225 } 1225 }
1226 1226
1227 void TabStripModel::NotifySelectionChanged(int old_selected_index) { 1227 void TabStripModel::NotifySelectionChanged(int old_selected_index) {
1228 TabContentsWrapper* old_tab = 1228 TabContentsWrapper* old_tab =
1229 old_selected_index == TabStripSelectionModel::kUnselectedIndex ? 1229 old_selected_index == TabStripSelectionModel::kUnselectedIndex ?
1230 NULL : GetTabContentsAt(old_selected_index); 1230 NULL : GetTabContentsAt(old_selected_index);
1231 TabContentsWrapper* new_tab = 1231 TabContentsWrapper* new_tab =
1232 active_index() == TabStripSelectionModel::kUnselectedIndex ? 1232 active_index() == TabStripSelectionModel::kUnselectedIndex ?
1233 NULL : GetTabContentsAt(active_index()); 1233 NULL : GetTabContentsAt(active_index());
1234 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 1234 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
1235 TabSelectedAt(old_tab, new_tab, active_index(), true)); 1235 ActiveTabChanged(old_tab, new_tab, active_index(), true));
1236 } 1236 }
1237 1237
1238 void TabStripModel::SelectRelativeTab(bool next) { 1238 void TabStripModel::SelectRelativeTab(bool next) {
1239 // This may happen during automated testing or if a user somehow buffers 1239 // This may happen during automated testing or if a user somehow buffers
1240 // many key accelerators. 1240 // many key accelerators.
1241 if (contents_data_.empty()) 1241 if (contents_data_.empty())
1242 return; 1242 return;
1243 1243
1244 int index = active_index(); 1244 int index = active_index();
1245 int delta = next ? 1 : -1; 1245 int delta = next ? 1 : -1;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 void TabStripModel::ForgetOpenersAndGroupsReferencing( 1310 void TabStripModel::ForgetOpenersAndGroupsReferencing(
1311 const NavigationController* tab) { 1311 const NavigationController* tab) {
1312 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); 1312 for (TabContentsDataVector::const_iterator i = contents_data_.begin();
1313 i != contents_data_.end(); ++i) { 1313 i != contents_data_.end(); ++i) {
1314 if ((*i)->group == tab) 1314 if ((*i)->group == tab)
1315 (*i)->group = NULL; 1315 (*i)->group = NULL;
1316 if ((*i)->opener == tab) 1316 if ((*i)->opener == tab)
1317 (*i)->opener = NULL; 1317 (*i)->opener = NULL;
1318 } 1318 }
1319 } 1319 }
OLDNEW
« no previous file with comments | « chrome/browser/tabs/default_tab_handler.cc ('k') | chrome/browser/tabs/tab_strip_model_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698