Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 570 | 570 |
| 571 bool TabStripModel::IsTabBlocked(int index) const { | 571 bool TabStripModel::IsTabBlocked(int index) const { |
| 572 return contents_data_[index]->blocked; | 572 return contents_data_[index]->blocked; |
| 573 } | 573 } |
| 574 | 574 |
| 575 bool TabStripModel::IsTabDiscarded(int index) const { | 575 bool TabStripModel::IsTabDiscarded(int index) const { |
| 576 return contents_data_[index]->discarded; | 576 return contents_data_[index]->discarded; |
| 577 } | 577 } |
| 578 | 578 |
| 579 int TabStripModel::IndexOfFirstNonMiniTab() const { | 579 int TabStripModel::IndexOfFirstNonMiniTab() const { |
| 580 for (size_t i = 0; i < contents_data_.size(); ++i) { | 580 for (int i = 0; i < count(); ++i) { |
| 581 if (!IsMiniTab(static_cast<int>(i))) | 581 if (!IsMiniTab(i)) |
| 582 return static_cast<int>(i); | 582 return i; |
| 583 } | 583 } |
| 584 // No mini-tabs. | 584 // No non-mini-tabs. |
| 585 return count(); | 585 return count(); |
| 586 } | 586 } |
| 587 | 587 |
| 588 int TabStripModel::IndexOfFirstBlockedTab() const { | |
|
sky
2012/11/07 00:25:39
See tab_strip_model_utils. It has this function.
sail
2012/11/07 00:58:48
Done.
Good catch. Fixed.
| |
| 589 for (int i = 0; i < count(); ++i) { | |
| 590 if (IsTabBlocked(i)) | |
| 591 return i; | |
| 592 } | |
| 593 // No blocked tabs. | |
| 594 return count(); | |
| 595 } | |
| 596 | |
| 588 int TabStripModel::ConstrainInsertionIndex(int index, bool mini_tab) { | 597 int TabStripModel::ConstrainInsertionIndex(int index, bool mini_tab) { |
| 589 return mini_tab ? std::min(std::max(0, index), IndexOfFirstNonMiniTab()) : | 598 return mini_tab ? std::min(std::max(0, index), IndexOfFirstNonMiniTab()) : |
| 590 std::min(count(), std::max(index, IndexOfFirstNonMiniTab())); | 599 std::min(count(), std::max(index, IndexOfFirstNonMiniTab())); |
| 591 } | 600 } |
| 592 | 601 |
| 593 void TabStripModel::ExtendSelectionTo(int index) { | 602 void TabStripModel::ExtendSelectionTo(int index) { |
| 594 DCHECK(ContainsIndex(index)); | 603 DCHECK(ContainsIndex(index)); |
| 595 TabStripSelectionModel new_model; | 604 TabStripSelectionModel new_model; |
| 596 new_model.Copy(selection_model_); | 605 new_model.Copy(selection_model_); |
| 597 new_model.SetSelectionFromAnchorTo(index); | 606 new_model.SetSelectionFromAnchorTo(index); |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1312 void TabStripModel::ForgetOpenersAndGroupsReferencing( | 1321 void TabStripModel::ForgetOpenersAndGroupsReferencing( |
| 1313 const WebContents* tab) { | 1322 const WebContents* tab) { |
| 1314 for (WebContentsDataVector::const_iterator i = contents_data_.begin(); | 1323 for (WebContentsDataVector::const_iterator i = contents_data_.begin(); |
| 1315 i != contents_data_.end(); ++i) { | 1324 i != contents_data_.end(); ++i) { |
| 1316 if ((*i)->group == tab) | 1325 if ((*i)->group == tab) |
| 1317 (*i)->group = NULL; | 1326 (*i)->group = NULL; |
| 1318 if ((*i)->opener == tab) | 1327 if ((*i)->opener == tab) |
| 1319 (*i)->opener = NULL; | 1328 (*i)->opener = NULL; |
| 1320 } | 1329 } |
| 1321 } | 1330 } |
| OLD | NEW |