OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/tab_strip_controller.h" | 5 #import "chrome/browser/cocoa/tab_strip_controller.h" |
6 | 6 |
7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <string> | 10 #include <string> |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 if (oldContents) { | 934 if (oldContents) { |
935 int oldModelIndex = | 935 int oldModelIndex = |
936 browser_->GetIndexOfController(&(oldContents->controller())); | 936 browser_->GetIndexOfController(&(oldContents->controller())); |
937 if (oldModelIndex != -1) { // When closing a tab, the old tab may be gone. | 937 if (oldModelIndex != -1) { // When closing a tab, the old tab may be gone. |
938 NSInteger oldIndex = [self indexFromModelIndex:oldModelIndex]; | 938 NSInteger oldIndex = [self indexFromModelIndex:oldModelIndex]; |
939 TabContentsController* oldController = | 939 TabContentsController* oldController = |
940 [tabContentsArray_ objectAtIndex:oldIndex]; | 940 [tabContentsArray_ objectAtIndex:oldIndex]; |
941 [oldController willBecomeUnselectedTab]; | 941 [oldController willBecomeUnselectedTab]; |
942 oldContents->view()->StoreFocus(); | 942 oldContents->view()->StoreFocus(); |
943 oldContents->WasHidden(); | 943 oldContents->WasHidden(); |
944 // If the selection changed because the tab was made phantom, update the | |
945 // Cocoa side of the state. | |
946 TabController* tabController = [tabArray_ objectAtIndex:oldIndex]; | |
947 [tabController setPhantom:tabStripModel_->IsPhantomTab(oldModelIndex)]; | |
948 } | 944 } |
949 } | 945 } |
950 | 946 |
951 // De-select all other tabs and select the new tab. | 947 // De-select all other tabs and select the new tab. |
952 int i = 0; | 948 int i = 0; |
953 for (TabController* current in tabArray_.get()) { | 949 for (TabController* current in tabArray_.get()) { |
954 [current setSelected:(i == index) ? YES : NO]; | 950 [current setSelected:(i == index) ? YES : NO]; |
955 ++i; | 951 ++i; |
956 } | 952 } |
957 | 953 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 retain]; | 1120 retain]; |
1125 static NSImage* sadFaviconImage = | 1121 static NSImage* sadFaviconImage = |
1126 [ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SAD_FAVICON) | 1122 [ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SAD_FAVICON) |
1127 retain]; | 1123 retain]; |
1128 | 1124 |
1129 // Take closing tabs into account. | 1125 // Take closing tabs into account. |
1130 NSInteger index = [self indexFromModelIndex:modelIndex]; | 1126 NSInteger index = [self indexFromModelIndex:modelIndex]; |
1131 | 1127 |
1132 TabController* tabController = [tabArray_ objectAtIndex:index]; | 1128 TabController* tabController = [tabArray_ objectAtIndex:index]; |
1133 | 1129 |
1134 // Since the tab is loading, it cannot be phantom any more. | |
1135 if ([tabController phantom]) { | |
1136 [tabController setPhantom:NO]; | |
1137 [[tabController view] setNeedsDisplay:YES]; | |
1138 } | |
1139 | |
1140 bool oldHasIcon = [tabController iconView] != nil; | 1130 bool oldHasIcon = [tabController iconView] != nil; |
1141 bool newHasIcon = contents->ShouldDisplayFavIcon() || | 1131 bool newHasIcon = contents->ShouldDisplayFavIcon() || |
1142 tabStripModel_->IsMiniTab(modelIndex); // Always show icon if mini. | 1132 tabStripModel_->IsMiniTab(modelIndex); // Always show icon if mini. |
1143 | 1133 |
1144 TabLoadingState oldState = [tabController loadingState]; | 1134 TabLoadingState oldState = [tabController loadingState]; |
1145 TabLoadingState newState = kTabDone; | 1135 TabLoadingState newState = kTabDone; |
1146 NSImage* throbberImage = nil; | 1136 NSImage* throbberImage = nil; |
1147 if (contents->is_crashed()) { | 1137 if (contents->is_crashed()) { |
1148 newState = kTabCrashed; | 1138 newState = kTabCrashed; |
1149 newHasIcon = true; | 1139 newHasIcon = true; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 // TODO(sky): make this work. | 1188 // TODO(sky): make this work. |
1199 // We'll receive another notification of the change asynchronously. | 1189 // We'll receive another notification of the change asynchronously. |
1200 return; | 1190 return; |
1201 } | 1191 } |
1202 | 1192 |
1203 TabController* tabController = [tabArray_ objectAtIndex:index]; | 1193 TabController* tabController = [tabArray_ objectAtIndex:index]; |
1204 | 1194 |
1205 if (change != TabStripModelObserver::LOADING_ONLY) | 1195 if (change != TabStripModelObserver::LOADING_ONLY) |
1206 [self setTabTitle:tabController withContents:contents]; | 1196 [self setTabTitle:tabController withContents:contents]; |
1207 | 1197 |
1208 // See if the change was to/from phantom. | |
1209 bool isPhantom = tabStripModel_->IsPhantomTab(modelIndex); | |
1210 if (isPhantom != [tabController phantom]) | |
1211 [tabController setPhantom:isPhantom]; | |
1212 | |
1213 [self updateFavIconForContents:contents atIndex:modelIndex]; | 1198 [self updateFavIconForContents:contents atIndex:modelIndex]; |
1214 | 1199 |
1215 TabContentsController* updatedController = | 1200 TabContentsController* updatedController = |
1216 [tabContentsArray_ objectAtIndex:index]; | 1201 [tabContentsArray_ objectAtIndex:index]; |
1217 [updatedController tabDidChange:contents]; | 1202 [updatedController tabDidChange:contents]; |
1218 } | 1203 } |
1219 | 1204 |
1220 // Called when a tab is moved (usually by drag&drop). Keep our parallel arrays | 1205 // Called when a tab is moved (usually by drag&drop). Keep our parallel arrays |
1221 // in sync with the tab strip model. It can also be pinned/unpinned | 1206 // in sync with the tab strip model. It can also be pinned/unpinned |
1222 // simultaneously, so we need to take care of that. | 1207 // simultaneously, so we need to take care of that. |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1740 return; | 1725 return; |
1741 | 1726 |
1742 TabContentsController* tabController = | 1727 TabContentsController* tabController = |
1743 [tabContentsArray_ objectAtIndex:index]; | 1728 [tabContentsArray_ objectAtIndex:index]; |
1744 TabContents* devtoolsContents = contents ? | 1729 TabContents* devtoolsContents = contents ? |
1745 DevToolsWindow::GetDevToolsContents(contents) : NULL; | 1730 DevToolsWindow::GetDevToolsContents(contents) : NULL; |
1746 [tabController showDevToolsContents:devtoolsContents]; | 1731 [tabController showDevToolsContents:devtoolsContents]; |
1747 } | 1732 } |
1748 | 1733 |
1749 @end | 1734 @end |
OLD | NEW |