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

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

Issue 7134026: Multi-tab: Renaming TabStripModel::GetSelectedTabContents to GetActiveTabContents (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renaming in tab_strip_controller.mm too. Created 9 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 bool pin = 121 bool pin =
122 contents->extension_tab_helper()->is_app() || add_types & ADD_PINNED; 122 contents->extension_tab_helper()->is_app() || add_types & ADD_PINNED;
123 index = ConstrainInsertionIndex(index, pin); 123 index = ConstrainInsertionIndex(index, pin);
124 124
125 // In tab dragging situations, if the last tab in the window was detached 125 // In tab dragging situations, if the last tab in the window was detached
126 // then the user aborted the drag, we will have the |closing_all_| member 126 // then the user aborted the drag, we will have the |closing_all_| member
127 // set (see DetachTabContentsAt) which will mess with our mojo here. We need 127 // set (see DetachTabContentsAt) which will mess with our mojo here. We need
128 // to clear this bit. 128 // to clear this bit.
129 closing_all_ = false; 129 closing_all_ = false;
130 130
131 // Have to get the selected contents before we monkey with |contents_| 131 // Have to get the active contents before we monkey with |contents_|
132 // otherwise we run into problems when we try to change the selected contents 132 // otherwise we run into problems when we try to change the active contents
133 // since the old contents and the new contents will be the same... 133 // since the old contents and the new contents will be the same...
134 TabContentsWrapper* selected_contents = GetSelectedTabContents(); 134 TabContentsWrapper* selected_contents = GetActiveTabContents();
135 TabContentsData* data = new TabContentsData(contents); 135 TabContentsData* data = new TabContentsData(contents);
136 data->pinned = pin; 136 data->pinned = pin;
137 if ((add_types & ADD_INHERIT_GROUP) && selected_contents) { 137 if ((add_types & ADD_INHERIT_GROUP) && selected_contents) {
138 if (active) { 138 if (active) {
139 // Forget any existing relationships, we don't want to make things too 139 // Forget any existing relationships, we don't want to make things too
140 // confusing by having multiple groups active at the same time. 140 // confusing by having multiple groups active at the same time.
141 ForgetAllOpeners(); 141 ForgetAllOpeners();
142 } 142 }
143 // Anything opened by a link we deem to have an opener. 143 // Anything opened by a link we deem to have an opener.
144 data->SetGroup(&selected_contents->controller()); 144 data->SetGroup(&selected_contents->controller());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 238 }
239 } 239 }
240 return removed_contents; 240 return removed_contents;
241 } 241 }
242 242
243 void TabStripModel::ActivateTabAt(int index, bool user_gesture) { 243 void TabStripModel::ActivateTabAt(int index, bool user_gesture) {
244 DCHECK(ContainsIndex(index)); 244 DCHECK(ContainsIndex(index));
245 bool had_multi = selection_model_.selected_indices().size() > 1; 245 bool had_multi = selection_model_.selected_indices().size() > 1;
246 TabContentsWrapper* old_contents = 246 TabContentsWrapper* old_contents =
247 (active_index() == TabStripSelectionModel::kUnselectedIndex) ? 247 (active_index() == TabStripSelectionModel::kUnselectedIndex) ?
248 NULL : GetSelectedTabContents(); 248 NULL : GetActiveTabContents();
249 selection_model_.SetSelectedIndex(index); 249 selection_model_.SetSelectedIndex(index);
250 TabContentsWrapper* new_contents = GetContentsAt(index); 250 TabContentsWrapper* new_contents = GetContentsAt(index);
251 if (old_contents != new_contents && old_contents) { 251 if (old_contents != new_contents && old_contents) {
252 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 252 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
253 TabDeactivated(old_contents)); 253 TabDeactivated(old_contents));
254 } 254 }
255 if (old_contents != new_contents || had_multi) { 255 if (old_contents != new_contents || had_multi) {
256 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 256 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
257 ActiveTabChanged(old_contents, new_contents, 257 ActiveTabChanged(old_contents, new_contents,
258 active_index(), user_gesture)); 258 active_index(), user_gesture));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 303 }
304 if (selected_mini_count == selected_count) 304 if (selected_mini_count == selected_count)
305 return; 305 return;
306 306
307 // Then move the non-pinned tabs. 307 // Then move the non-pinned tabs.
308 MoveSelectedTabsToImpl(std::max(index, total_mini_count), 308 MoveSelectedTabsToImpl(std::max(index, total_mini_count),
309 selected_mini_count, 309 selected_mini_count,
310 selected_count - selected_mini_count); 310 selected_count - selected_mini_count);
311 } 311 }
312 312
313 TabContentsWrapper* TabStripModel::GetSelectedTabContents() const { 313 TabContentsWrapper* TabStripModel::GetActiveTabContents() const {
314 return GetTabContentsAt(active_index()); 314 return GetTabContentsAt(active_index());
315 } 315 }
316 316
317 TabContentsWrapper* TabStripModel::GetTabContentsAt(int index) const { 317 TabContentsWrapper* TabStripModel::GetTabContentsAt(int index) const {
318 if (ContainsIndex(index)) 318 if (ContainsIndex(index))
319 return GetContentsAt(index); 319 return GetContentsAt(index);
320 return NULL; 320 return NULL;
321 } 321 }
322 322
323 int TabStripModel::GetIndexOfTabContents( 323 int TabStripModel::GetIndexOfTabContents(
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 // TODO(sky): figure out why this is here and not in InsertTabContentsAt. When 662 // TODO(sky): figure out why this is here and not in InsertTabContentsAt. When
663 // here we seem to get failures in startup perf tests. 663 // here we seem to get failures in startup perf tests.
664 // Ensure that the new TabContentsView begins at the same size as the 664 // Ensure that the new TabContentsView begins at the same size as the
665 // previous TabContentsView if it existed. Otherwise, the initial WebKit 665 // previous TabContentsView if it existed. Otherwise, the initial WebKit
666 // layout will be performed based on a width of 0 pixels, causing a 666 // layout will be performed based on a width of 0 pixels, causing a
667 // very long, narrow, inaccurate layout. Because some scripts on pages (as 667 // very long, narrow, inaccurate layout. Because some scripts on pages (as
668 // well as WebKit's anchor link location calculation) are run on the 668 // well as WebKit's anchor link location calculation) are run on the
669 // initial layout and not recalculated later, we need to ensure the first 669 // initial layout and not recalculated later, we need to ensure the first
670 // layout is performed with sane view dimensions even when we're opening a 670 // layout is performed with sane view dimensions even when we're opening a
671 // new background tab. 671 // new background tab.
672 if (TabContentsWrapper* old_contents = GetSelectedTabContents()) { 672 if (TabContentsWrapper* old_contents = GetActiveTabContents()) {
673 if ((add_types & ADD_ACTIVE) == 0) { 673 if ((add_types & ADD_ACTIVE) == 0) {
674 contents->tab_contents()->view()-> 674 contents->tab_contents()->view()->
675 SizeContents(old_contents->tab_contents()-> 675 SizeContents(old_contents->tab_contents()->
676 view()->GetContainerSize()); 676 view()->GetContainerSize());
677 // We need to hide the contents or else we get and execute paints for 677 // We need to hide the contents or else we get and execute paints for
678 // background tabs. With enough background tabs they will steal the 678 // background tabs. With enough background tabs they will steal the
679 // backing store of the visible tab causing flashing. See bug 20831. 679 // backing store of the visible tab causing flashing. See bug 20831.
680 contents->tab_contents()->HideContents(); 680 contents->tab_contents()->HideContents();
681 } 681 }
682 } 682 }
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 void TabStripModel::ForgetOpenersAndGroupsReferencing( 1311 void TabStripModel::ForgetOpenersAndGroupsReferencing(
1312 const NavigationController* tab) { 1312 const NavigationController* tab) {
1313 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); 1313 for (TabContentsDataVector::const_iterator i = contents_data_.begin();
1314 i != contents_data_.end(); ++i) { 1314 i != contents_data_.end(); ++i) {
1315 if ((*i)->group == tab) 1315 if ((*i)->group == tab)
1316 (*i)->group = NULL; 1316 (*i)->group = NULL;
1317 if ((*i)->opener == tab) 1317 if ((*i)->opener == tab)
1318 (*i)->opener = NULL; 1318 (*i)->opener = NULL;
1319 } 1319 }
1320 } 1320 }
OLDNEW
« no previous file with comments | « chrome/browser/tabs/tab_strip_model.h ('k') | chrome/browser/tabs/tab_strip_model_order_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698