| 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 #include "app/l10n_util_mac.h" | 5 #include "app/l10n_util_mac.h" |
| 6 #include "base/mac_util.h" | 6 #include "base/mac_util.h" |
| 7 #import "chrome/browser/browser_theme_provider.h" | 7 #import "chrome/browser/browser_theme_provider.h" |
| 8 #import "chrome/browser/cocoa/menu_controller.h" | 8 #import "chrome/browser/cocoa/menu_controller.h" |
| 9 #import "chrome/browser/cocoa/tab_controller.h" | 9 #import "chrome/browser/cocoa/tab_controller.h" |
| 10 #import "chrome/browser/cocoa/tab_controller_target.h" | 10 #import "chrome/browser/cocoa/tab_controller_target.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 return [contextMenuController_ menu]; | 137 return [contextMenuController_ menu]; |
| 138 } | 138 } |
| 139 | 139 |
| 140 - (IBAction)closeTab:(id)sender { | 140 - (IBAction)closeTab:(id)sender { |
| 141 if ([[self target] respondsToSelector:@selector(closeTab:)]) { | 141 if ([[self target] respondsToSelector:@selector(closeTab:)]) { |
| 142 [[self target] performSelector:@selector(closeTab:) | 142 [[self target] performSelector:@selector(closeTab:) |
| 143 withObject:[self view]]; | 143 withObject:[self view]]; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 - (BOOL)hovered { |
| 148 TabView* tabView = static_cast<TabView*>([self view]); |
| 149 return [tabView isMouseIn]; |
| 150 } |
| 151 |
| 147 - (void)setTitle:(NSString*)title { | 152 - (void)setTitle:(NSString*)title { |
| 148 [[self view] setToolTip:title]; | 153 [[self view] setToolTip:title]; |
| 149 if ([self mini] && ![self selected]) { | 154 if ([self mini] && ![self selected]) { |
| 150 TabView* tabView = static_cast<TabView*>([self view]); | 155 TabView* tabView = static_cast<TabView*>([self view]); |
| 151 DCHECK([tabView isKindOfClass:[TabView class]]); | 156 DCHECK([tabView isKindOfClass:[TabView class]]); |
| 152 [tabView startAlert]; | 157 [tabView startAlert]; |
| 153 } | 158 } |
| 154 [super setTitle:title]; | 159 [super setTitle:title]; |
| 155 } | 160 } |
| 156 | 161 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 220 |
| 216 int iconCapacity = [self iconCapacity]; | 221 int iconCapacity = [self iconCapacity]; |
| 217 if ([self selected]) | 222 if ([self selected]) |
| 218 return iconCapacity >= 2; | 223 return iconCapacity >= 2; |
| 219 return iconCapacity >= 1; | 224 return iconCapacity >= 1; |
| 220 } | 225 } |
| 221 | 226 |
| 222 // Returns YES if we should be showing the close button. The selected tab | 227 // Returns YES if we should be showing the close button. The selected tab |
| 223 // always shows the close button. | 228 // always shows the close button. |
| 224 - (BOOL)shouldShowCloseButton { | 229 - (BOOL)shouldShowCloseButton { |
| 225 if ([self mini]) | 230 if ([self mini] || (![self selected] && [self hovered])) |
| 226 return NO; | 231 return NO; |
| 227 return ([self selected] || [self iconCapacity] >= 3); | 232 return ([self selected] || [self iconCapacity] >= 3); |
| 228 } | 233 } |
| 229 | 234 |
| 230 - (void)updateVisibility { | 235 - (void)updateVisibility { |
| 231 // iconView_ may have been replaced or it may be nil, so [iconView_ isHidden] | 236 // iconView_ may have been replaced or it may be nil, so [iconView_ isHidden] |
| 232 // won't work. Instead, the state of the icon is tracked separately in | 237 // won't work. Instead, the state of the icon is tracked separately in |
| 233 // isIconShowing_. | 238 // isIconShowing_. |
| 234 BOOL oldShowIcon = isIconShowing_ ? YES : NO; | 239 BOOL oldShowIcon = isIconShowing_ ? YES : NO; |
| 235 BOOL newShowIcon = [self shouldShowIcon] ? YES : NO; | 240 BOOL newShowIcon = [self shouldShowIcon] ? YES : NO; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // Called by the tabs to determine whether we are in rapid (tab) closure mode. | 310 // Called by the tabs to determine whether we are in rapid (tab) closure mode. |
| 306 - (BOOL)inRapidClosureMode { | 311 - (BOOL)inRapidClosureMode { |
| 307 if ([[self target] respondsToSelector:@selector(inRapidClosureMode)]) { | 312 if ([[self target] respondsToSelector:@selector(inRapidClosureMode)]) { |
| 308 return [[self target] performSelector:@selector(inRapidClosureMode)] ? | 313 return [[self target] performSelector:@selector(inRapidClosureMode)] ? |
| 309 YES : NO; | 314 YES : NO; |
| 310 } | 315 } |
| 311 return NO; | 316 return NO; |
| 312 } | 317 } |
| 313 | 318 |
| 314 @end | 319 @end |
| OLD | NEW |