Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(674)

Side by Side Diff: chrome/browser/ui/tabs/tab_strip_model.cc

Issue 10937028: Do not discard selected tab (Closed) Base URL: http://git.chromium.org/chromium/src.git@new
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
222 // the last tab. After discarding last tab, it is reloaded again. So, we
223 // should not mark the tab.
224 if (!IsTabSelected(index)) {
sky 2012/09/20 19:31:09 I don't understand this. What is triggering the lo
simonhong_ 2012/09/21 00:16:37 I'll explain problematic scenario according to thi
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/oom_priority_manager_browsertest.cc ('k') | chrome/browser/ui/tabs/tab_strip_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698