| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 // occurs between the call to add an additional tab and one to close | 198 // occurs between the call to add an additional tab and one to close |
| 199 // the previous tab. | 199 // the previous tab. |
| 200 InsertTabContentsAt(index + 1, contents, ADD_ACTIVE | ADD_INHERIT_GROUP); | 200 InsertTabContentsAt(index + 1, contents, ADD_ACTIVE | ADD_INHERIT_GROUP); |
| 201 std::vector<int> closing_tabs; | 201 std::vector<int> closing_tabs; |
| 202 closing_tabs.push_back(index); | 202 closing_tabs.push_back(index); |
| 203 InternalCloseTabs(closing_tabs, CLOSE_NONE); | 203 InternalCloseTabs(closing_tabs, CLOSE_NONE); |
| 204 } | 204 } |
| 205 | 205 |
| 206 TabContents* TabStripModel::DiscardTabContentsAt(int index) { | 206 TabContents* TabStripModel::DiscardTabContentsAt(int index) { |
| 207 DCHECK(ContainsIndex(index)); | 207 DCHECK(ContainsIndex(index)); |
| 208 // Do not discard active tab. |
| 209 if (active_index() == index) |
| 210 return NULL; |
| 211 |
| 208 TabContents* null_contents = TabContents::Factory::CreateTabContents( | 212 TabContents* null_contents = TabContents::Factory::CreateTabContents( |
| 209 WebContents::Create(profile(), | 213 WebContents::Create(profile(), |
| 210 NULL /* site_instance */, | 214 NULL /* site_instance */, |
| 211 MSG_ROUTING_NONE, | 215 MSG_ROUTING_NONE, |
| 212 NULL /* base_tab_contents */)); | 216 NULL /* base_tab_contents */)); |
| 213 TabContents* old_contents = GetContentsAt(index); | 217 TabContents* old_contents = GetContentsAt(index); |
| 214 // Copy over the state from the navigation controller so we preserve the | 218 // Copy over the state from the navigation controller so we preserve the |
| 215 // back/forward history and continue to display the correct title/favicon. | 219 // back/forward history and continue to display the correct title/favicon. |
| 216 null_contents->web_contents()->GetController().CopyStateFrom( | 220 null_contents->web_contents()->GetController().CopyStateFrom( |
| 217 old_contents->web_contents()->GetController()); | 221 old_contents->web_contents()->GetController()); |
| (...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 void TabStripModel::ForgetOpenersAndGroupsReferencing( | 1319 void TabStripModel::ForgetOpenersAndGroupsReferencing( |
| 1316 const NavigationController* tab) { | 1320 const NavigationController* tab) { |
| 1317 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); | 1321 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); |
| 1318 i != contents_data_.end(); ++i) { | 1322 i != contents_data_.end(); ++i) { |
| 1319 if ((*i)->group == tab) | 1323 if ((*i)->group == tab) |
| 1320 (*i)->group = NULL; | 1324 (*i)->group = NULL; |
| 1321 if ((*i)->opener == tab) | 1325 if ((*i)->opener == tab) |
| 1322 (*i)->opener = NULL; | 1326 (*i)->opener = NULL; |
| 1323 } | 1327 } |
| 1324 } | 1328 } |
| OLD | NEW |