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

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

Issue 17382005: Unbreak tabs.onRemove extension API in face of fast tab closure Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't modify content Created 7 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/tabs/tab_strip_model.h" 5 #include "chrome/browser/ui/tabs/tab_strip_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 WebContents* removed_contents = GetWebContentsAtImpl(index); 264 WebContents* removed_contents = GetWebContentsAtImpl(index);
265 bool was_selected = IsTabSelected(index); 265 bool was_selected = IsTabSelected(index);
266 int next_selected_index = order_controller_->DetermineNewSelectedIndex(index); 266 int next_selected_index = order_controller_->DetermineNewSelectedIndex(index);
267 delete contents_data_[index]; 267 delete contents_data_[index];
268 contents_data_.erase(contents_data_.begin() + index); 268 contents_data_.erase(contents_data_.begin() + index);
269 ForgetOpenersAndGroupsReferencing(removed_contents); 269 ForgetOpenersAndGroupsReferencing(removed_contents);
270 if (empty()) 270 if (empty())
271 closing_all_ = true; 271 closing_all_ = true;
272 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 272 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
273 TabDetachedAt(removed_contents, index)); 273 TabDetachedAt(removed_contents, index, closing_all_));
274 if (empty()) { 274 if (empty()) {
275 selection_model_.Clear(); 275 selection_model_.Clear();
276 // TabDetachedAt() might unregister observers, so send |TabStripEmpty()| in 276 // TabDetachedAt() might unregister observers, so send |TabStripEmpty()| in
277 // a second pass. 277 // a second pass.
278 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, TabStripEmpty()); 278 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, TabStripEmpty());
279 } else { 279 } else {
280 int old_active = active_index(); 280 int old_active = active_index();
281 selection_model_.DecrementFrom(index); 281 selection_model_.DecrementFrom(index);
282 ui::ListSelectionModel old_model; 282 ui::ListSelectionModel old_model;
283 old_model.Copy(selection_model_); 283 old_model.Copy(selection_model_);
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 void TabStripModel::ForgetOpenersAndGroupsReferencing( 1285 void TabStripModel::ForgetOpenersAndGroupsReferencing(
1286 const WebContents* tab) { 1286 const WebContents* tab) {
1287 for (WebContentsDataVector::const_iterator i = contents_data_.begin(); 1287 for (WebContentsDataVector::const_iterator i = contents_data_.begin();
1288 i != contents_data_.end(); ++i) { 1288 i != contents_data_.end(); ++i) {
1289 if ((*i)->group == tab) 1289 if ((*i)->group == tab)
1290 (*i)->group = NULL; 1290 (*i)->group = NULL;
1291 if ((*i)->opener == tab) 1291 if ((*i)->opener == tab)
1292 (*i)->opener = NULL; 1292 (*i)->opener = NULL;
1293 } 1293 }
1294 } 1294 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698