| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/browser/metrics/user_metrics.h" | 10 #include "chrome/browser/metrics/user_metrics.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 ChangeSelectedContentsFrom(GetSelectedTabContents(), index, user_gesture); | 152 ChangeSelectedContentsFrom(GetSelectedTabContents(), index, user_gesture); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void TabStripModel::ReplaceTabContentsAt(int index, | 155 void TabStripModel::ReplaceTabContentsAt(int index, |
| 156 TabContents* replacement_contents) { | 156 TabContents* replacement_contents) { |
| 157 DCHECK(ContainsIndex(index)); | 157 DCHECK(ContainsIndex(index)); |
| 158 TabContents* old_contents = GetContentsAt(index); | 158 TabContents* old_contents = GetContentsAt(index); |
| 159 contents_data_[index]->contents = replacement_contents; | 159 contents_data_[index]->contents = replacement_contents; |
| 160 | 160 |
| 161 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | 161 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, |
| 162 TabChangedAt(replacement_contents, index)); | 162 TabChangedAt(replacement_contents, index, false)); |
| 163 | 163 |
| 164 // Re-use the logic for selecting tabs to ensure the replacement contents is | 164 // Re-use the logic for selecting tabs to ensure the replacement contents is |
| 165 // shown and sized appropriately. | 165 // shown and sized appropriately. |
| 166 if (index == selected_index_) { | 166 if (index == selected_index_) { |
| 167 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | 167 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, |
| 168 TabSelectedAt(old_contents, replacement_contents, index, false)); | 168 TabSelectedAt(old_contents, replacement_contents, index, false)); |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 void TabStripModel::MoveTabContentsAt(int index, int to_position) { | 172 void TabStripModel::MoveTabContentsAt(int index, int to_position) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 const NavigationController* controller) const { | 208 const NavigationController* controller) const { |
| 209 int index = 0; | 209 int index = 0; |
| 210 TabContentsDataVector::const_iterator iter = contents_data_.begin(); | 210 TabContentsDataVector::const_iterator iter = contents_data_.begin(); |
| 211 for (; iter != contents_data_.end(); ++iter, ++index) { | 211 for (; iter != contents_data_.end(); ++iter, ++index) { |
| 212 if ((*iter)->contents->controller() == controller) | 212 if ((*iter)->contents->controller() == controller) |
| 213 return index; | 213 return index; |
| 214 } | 214 } |
| 215 return kNoTab; | 215 return kNoTab; |
| 216 } | 216 } |
| 217 | 217 |
| 218 void TabStripModel::UpdateTabContentsStateAt(int index) { | 218 void TabStripModel::UpdateTabContentsStateAt(int index, bool loading_only) { |
| 219 DCHECK(ContainsIndex(index)); | 219 DCHECK(ContainsIndex(index)); |
| 220 | 220 |
| 221 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | 221 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, |
| 222 TabChangedAt(GetContentsAt(index), index)); | 222 TabChangedAt(GetContentsAt(index), index, loading_only)); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void TabStripModel::CloseAllTabs() { | 225 void TabStripModel::CloseAllTabs() { |
| 226 // Set state so that observers can adjust their behavior to suit this | 226 // Set state so that observers can adjust their behavior to suit this |
| 227 // specific condition when CloseTabContentsAt causes a flurry of | 227 // specific condition when CloseTabContentsAt causes a flurry of |
| 228 // Close/Detach/Select notifications to be sent. | 228 // Close/Detach/Select notifications to be sent. |
| 229 closing_all_ = true; | 229 closing_all_ = true; |
| 230 for (int i = count() - 1; i >= 0; --i) | 230 for (int i = count() - 1; i >= 0; --i) |
| 231 CloseTabContentsAt(i); | 231 CloseTabContentsAt(i); |
| 232 } | 232 } |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 int index = GetIndexOfTabContents(contents); | 586 int index = GetIndexOfTabContents(contents); |
| 587 contents_data_.at(index)->opener = opener->controller(); | 587 contents_data_.at(index)->opener = opener->controller(); |
| 588 } | 588 } |
| 589 | 589 |
| 590 // static | 590 // static |
| 591 bool TabStripModel::OpenerMatches(const TabContentsData* data, | 591 bool TabStripModel::OpenerMatches(const TabContentsData* data, |
| 592 const NavigationController* opener, | 592 const NavigationController* opener, |
| 593 bool use_group) { | 593 bool use_group) { |
| 594 return data->opener == opener || (use_group && data->group == opener); | 594 return data->opener == opener || (use_group && data->group == opener); |
| 595 } | 595 } |
| OLD | NEW |