| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 TabContentsData* data = new TabContentsData(contents); | 134 TabContentsData* data = new TabContentsData(contents); |
| 135 data->pinned = pin; | 135 data->pinned = pin; |
| 136 if ((add_types & ADD_INHERIT_GROUP) && selected_contents) { | 136 if ((add_types & ADD_INHERIT_GROUP) && selected_contents) { |
| 137 if (foreground) { | 137 if (foreground) { |
| 138 // Forget any existing relationships, we don't want to make things too | 138 // Forget any existing relationships, we don't want to make things too |
| 139 // confusing by having multiple groups active at the same time. | 139 // confusing by having multiple groups active at the same time. |
| 140 ForgetAllOpeners(); | 140 ForgetAllOpeners(); |
| 141 } | 141 } |
| 142 // Anything opened by a link we deem to have an opener. | 142 // Anything opened by a link we deem to have an opener. |
| 143 data->SetGroup(&selected_contents->controller()); | 143 data->SetGroup(&selected_contents->controller()); |
| 144 // TODO(sky): nuke when we figure out what is causing 34135. | |
| 145 CHECK(data->opener != &(contents->controller())); | |
| 146 } else if ((add_types & ADD_INHERIT_OPENER) && selected_contents) { | 144 } else if ((add_types & ADD_INHERIT_OPENER) && selected_contents) { |
| 147 if (foreground) { | 145 if (foreground) { |
| 148 // Forget any existing relationships, we don't want to make things too | 146 // Forget any existing relationships, we don't want to make things too |
| 149 // confusing by having multiple groups active at the same time. | 147 // confusing by having multiple groups active at the same time. |
| 150 ForgetAllOpeners(); | 148 ForgetAllOpeners(); |
| 151 } | 149 } |
| 152 data->opener = &selected_contents->controller(); | 150 data->opener = &selected_contents->controller(); |
| 153 // TODO(sky): nuke when we figure out what is causing 34135. | |
| 154 CHECK(data->opener != &(contents->controller())); | |
| 155 } | 151 } |
| 156 | 152 |
| 157 contents_data_.insert(contents_data_.begin() + index, data); | 153 contents_data_.insert(contents_data_.begin() + index, data); |
| 158 | 154 |
| 159 if (index <= selected_index_) { | 155 if (index <= selected_index_) { |
| 160 // If a tab is inserted before the current selected index, | 156 // If a tab is inserted before the current selected index, |
| 161 // then |selected_index| needs to be incremented. | 157 // then |selected_index| needs to be incremented. |
| 162 ++selected_index_; | 158 ++selected_index_; |
| 163 } | 159 } |
| 164 | 160 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 InternalCloseTabs(closing_tabs, CLOSE_NONE); | 202 InternalCloseTabs(closing_tabs, CLOSE_NONE); |
| 207 } | 203 } |
| 208 | 204 |
| 209 TabContentsWrapper* TabStripModel::DetachTabContentsAt(int index) { | 205 TabContentsWrapper* TabStripModel::DetachTabContentsAt(int index) { |
| 210 if (contents_data_.empty()) | 206 if (contents_data_.empty()) |
| 211 return NULL; | 207 return NULL; |
| 212 | 208 |
| 213 DCHECK(ContainsIndex(index)); | 209 DCHECK(ContainsIndex(index)); |
| 214 | 210 |
| 215 TabContentsWrapper* removed_contents = GetContentsAt(index); | 211 TabContentsWrapper* removed_contents = GetContentsAt(index); |
| 216 // TODO(sky): nuke reason and old_data when we figure out what is causing | 212 int next_selected_index = order_controller_->DetermineNewSelectedIndex(index); |
| 217 // 34135. | |
| 218 volatile int reason = 0; | |
| 219 int next_selected_index = | |
| 220 order_controller_->DetermineNewSelectedIndex(index, &reason); | |
| 221 volatile TabContentsData old_data = *contents_data_.at(index); | |
| 222 delete contents_data_.at(index); | 213 delete contents_data_.at(index); |
| 223 contents_data_.erase(contents_data_.begin() + index); | 214 contents_data_.erase(contents_data_.begin() + index); |
| 224 ForgetOpenersAndGroupsReferencing(&(removed_contents->controller())); | 215 ForgetOpenersAndGroupsReferencing(&(removed_contents->controller())); |
| 225 if (empty()) | 216 if (empty()) |
| 226 closing_all_ = true; | 217 closing_all_ = true; |
| 227 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | 218 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, |
| 228 TabDetachedAt(removed_contents, index)); | 219 TabDetachedAt(removed_contents, index)); |
| 229 if (empty()) { | 220 if (empty()) { |
| 230 // TabDetachedAt() might unregister observers, so send |TabStripEmtpy()| in | 221 // TabDetachedAt() might unregister observers, so send |TabStripEmtpy()| in |
| 231 // a second pass. | 222 // a second pass. |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 void TabStripModel::ForgetOpenersAndGroupsReferencing( | 1016 void TabStripModel::ForgetOpenersAndGroupsReferencing( |
| 1026 const NavigationController* tab) { | 1017 const NavigationController* tab) { |
| 1027 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); | 1018 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); |
| 1028 i != contents_data_.end(); ++i) { | 1019 i != contents_data_.end(); ++i) { |
| 1029 if ((*i)->group == tab) | 1020 if ((*i)->group == tab) |
| 1030 (*i)->group = NULL; | 1021 (*i)->group = NULL; |
| 1031 if ((*i)->opener == tab) | 1022 if ((*i)->opener == tab) |
| 1032 (*i)->opener = NULL; | 1023 (*i)->opener = NULL; |
| 1033 } | 1024 } |
| 1034 } | 1025 } |
| OLD | NEW |