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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm

Issue 8892011: Clean up TCW, make it solely a hub for 1:1 observer/helper objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <limits> 10 #include <limits>
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 // Called when a notification is received from the model to select a particular 1101 // Called when a notification is received from the model to select a particular
1102 // tab. Swaps in the toolbar and content area associated with |newContents|. 1102 // tab. Swaps in the toolbar and content area associated with |newContents|.
1103 - (void)activateTabWithContents:(TabContentsWrapper*)newContents 1103 - (void)activateTabWithContents:(TabContentsWrapper*)newContents
1104 previousContents:(TabContentsWrapper*)oldContents 1104 previousContents:(TabContentsWrapper*)oldContents
1105 atIndex:(NSInteger)modelIndex 1105 atIndex:(NSInteger)modelIndex
1106 userGesture:(bool)wasUserGesture { 1106 userGesture:(bool)wasUserGesture {
1107 // Take closing tabs into account. 1107 // Take closing tabs into account.
1108 NSInteger activeIndex = [self indexFromModelIndex:modelIndex]; 1108 NSInteger activeIndex = [self indexFromModelIndex:modelIndex];
1109 1109
1110 if (oldContents) { 1110 if (oldContents) {
1111 int oldModelIndex = 1111 int oldModelIndex = browser_->GetIndexOfController(
1112 browser_->GetIndexOfController(&(oldContents->controller())); 1112 &(oldContents->tab_contents()->controller()));
1113 if (oldModelIndex != -1) { // When closing a tab, the old tab may be gone. 1113 if (oldModelIndex != -1) { // When closing a tab, the old tab may be gone.
1114 NSInteger oldIndex = [self indexFromModelIndex:oldModelIndex]; 1114 NSInteger oldIndex = [self indexFromModelIndex:oldModelIndex];
1115 TabContentsController* oldController = 1115 TabContentsController* oldController =
1116 [tabContentsArray_ objectAtIndex:oldIndex]; 1116 [tabContentsArray_ objectAtIndex:oldIndex];
1117 [oldController willBecomeUnselectedTab]; 1117 [oldController willBecomeUnselectedTab];
1118 oldContents->view()->StoreFocus(); 1118 oldContents->tab_contents()->view()->StoreFocus();
1119 oldContents->tab_contents()->WasHidden(); 1119 oldContents->tab_contents()->WasHidden();
1120 } 1120 }
1121 } 1121 }
1122 1122
1123 // First get the vector of indices, which is allays sorted in ascending order. 1123 // First get the vector of indices, which is allays sorted in ascending order.
1124 TabStripSelectionModel::SelectedIndices selection( 1124 TabStripSelectionModel::SelectedIndices selection(
1125 tabStripModel_->selection_model().selected_indices()); 1125 tabStripModel_->selection_model().selected_indices());
1126 // Iterate through all of the tabs, selecting each as necessary. 1126 // Iterate through all of the tabs, selecting each as necessary.
1127 TabStripSelectionModel::SelectedIndices::iterator iter = selection.begin(); 1127 TabStripSelectionModel::SelectedIndices::iterator iter = selection.begin();
1128 int i = 0; 1128 int i = 0;
(...skipping 16 matching lines...) Expand all
1145 // Relayout for new tabs and to let the selected tab grow to be larger in 1145 // Relayout for new tabs and to let the selected tab grow to be larger in
1146 // size than surrounding tabs if the user has many. This also raises the 1146 // size than surrounding tabs if the user has many. This also raises the
1147 // selected tab to the top. 1147 // selected tab to the top.
1148 [self layoutTabs]; 1148 [self layoutTabs];
1149 1149
1150 // Swap in the contents for the new tab. 1150 // Swap in the contents for the new tab.
1151 [self swapInTabAtIndex:modelIndex]; 1151 [self swapInTabAtIndex:modelIndex];
1152 1152
1153 if (newContents) { 1153 if (newContents) {
1154 newContents->tab_contents()->DidBecomeSelected(); 1154 newContents->tab_contents()->DidBecomeSelected();
1155 newContents->view()->RestoreFocus(); 1155 newContents->tab_contents()->view()->RestoreFocus();
1156 1156
1157 if (newContents->find_tab_helper()->find_ui_active()) 1157 if (newContents->find_tab_helper()->find_ui_active())
1158 browser_->GetFindBarController()->find_bar()->SetFocusAndSelection(); 1158 browser_->GetFindBarController()->find_bar()->SetFocusAndSelection();
1159 } 1159 }
1160 } 1160 }
1161 1161
1162 - (void)tabReplacedWithContents:(TabContentsWrapper*)newContents 1162 - (void)tabReplacedWithContents:(TabContentsWrapper*)newContents
1163 previousContents:(TabContentsWrapper*)oldContents 1163 previousContents:(TabContentsWrapper*)oldContents
1164 atIndex:(NSInteger)modelIndex { 1164 atIndex:(NSInteger)modelIndex {
1165 NSInteger index = [self indexFromModelIndex:modelIndex]; 1165 NSInteger index = [self indexFromModelIndex:modelIndex];
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 NSInteger index = [self indexFromModelIndex:modelIndex]; 2019 NSInteger index = [self indexFromModelIndex:modelIndex];
2020 BrowserWindowController* controller = 2020 BrowserWindowController* controller =
2021 (BrowserWindowController*)[[switchView_ window] windowController]; 2021 (BrowserWindowController*)[[switchView_ window] windowController];
2022 DCHECK(index >= 0); 2022 DCHECK(index >= 0);
2023 if (index >= 0) { 2023 if (index >= 0) {
2024 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; 2024 [controller setTab:[self viewAtIndex:index] isDraggable:YES];
2025 } 2025 }
2026 } 2026 }
2027 2027
2028 @end 2028 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabpose_window.mm ('k') | chrome/browser/ui/constrained_window_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698