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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 NULL /* site_instance */, | 210 NULL /* site_instance */, |
| 211 MSG_ROUTING_NONE, | 211 MSG_ROUTING_NONE, |
| 212 NULL /* base_tab_contents */)); | 212 NULL /* base_tab_contents */)); |
| 213 TabContents* old_contents = GetContentsAt(index); | 213 TabContents* old_contents = GetContentsAt(index); |
| 214 // Copy over the state from the navigation controller so we preserve the | 214 // Copy over the state from the navigation controller so we preserve the |
| 215 // back/forward history and continue to display the correct title/favicon. | 215 // back/forward history and continue to display the correct title/favicon. |
| 216 null_contents->web_contents()->GetController().CopyStateFrom( | 216 null_contents->web_contents()->GetController().CopyStateFrom( |
| 217 old_contents->web_contents()->GetController()); | 217 old_contents->web_contents()->GetController()); |
| 218 // Replace the tab we're discarding with the null version. | 218 // Replace the tab we're discarding with the null version. |
| 219 ReplaceTabContentsAt(index, null_contents); | 219 ReplaceTabContentsAt(index, null_contents); |
| 220 // Mark the tab so it will reload when we click. | 220 |
| 221 contents_data_[index]->discarded = true; | 221 // Only mark tabs that are not selected. When selected tab is discarded, it is |
|
sky
2012/09/19 17:06:59
Write a test for this.
simonhong_
2012/09/20 10:26:29
This can be verified by OomProirotyManager::Discar
sky
2012/09/20 15:24:08
Can't you call what OOMPriorityManager is invoking
simonhong_
2012/09/20 16:07:59
Modified tab_strip_model_unittest.
And Added some
| |
| 222 // the last tab. After discarding last tab, it is reloaded again. So, do not | |
| 223 // mark the tab. It is active tab. | |
| 224 if (!IsTabSelected(index)) { | |
| 225 // Mark the tab so it will reload when we click. | |
| 226 contents_data_[index]->discarded = true; | |
| 227 } | |
| 222 // Discard the old tab's renderer. | 228 // Discard the old tab's renderer. |
| 223 // TODO(jamescook): This breaks script connections with other tabs. | 229 // TODO(jamescook): This breaks script connections with other tabs. |
| 224 // We need to find a different approach that doesn't do that, perhaps based | 230 // We need to find a different approach that doesn't do that, perhaps based |
| 225 // on navigation to swappedout://. | 231 // on navigation to swappedout://. |
| 226 delete old_contents; | 232 delete old_contents; |
| 227 return null_contents; | 233 return null_contents; |
| 228 } | 234 } |
| 229 | 235 |
| 230 TabContents* TabStripModel::DetachTabContentsAt(int index) { | 236 TabContents* TabStripModel::DetachTabContentsAt(int index) { |
| 231 if (contents_data_.empty()) | 237 if (contents_data_.empty()) |
| (...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1313 void TabStripModel::ForgetOpenersAndGroupsReferencing( | 1319 void TabStripModel::ForgetOpenersAndGroupsReferencing( |
| 1314 const NavigationController* tab) { | 1320 const NavigationController* tab) { |
| 1315 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); | 1321 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); |
| 1316 i != contents_data_.end(); ++i) { | 1322 i != contents_data_.end(); ++i) { |
| 1317 if ((*i)->group == tab) | 1323 if ((*i)->group == tab) |
| 1318 (*i)->group = NULL; | 1324 (*i)->group = NULL; |
| 1319 if ((*i)->opener == tab) | 1325 if ((*i)->opener == tab) |
| 1320 (*i)->opener = NULL; | 1326 (*i)->opener = NULL; |
| 1321 } | 1327 } |
| 1322 } | 1328 } |
| OLD | NEW |