| OLD | NEW |
| 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 "base/mac/mac_util.h" | 5 #include "base/mac/mac_util.h" |
| 6 #import "chrome/browser/themes/theme_service.h" | 6 #import "chrome/browser/themes/theme_service.h" |
| 7 #import "chrome/browser/ui/cocoa/menu_controller.h" | 7 #import "chrome/browser/ui/cocoa/menu_controller.h" |
| 8 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" | 8 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" |
| 9 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" | 9 #import "chrome/browser/ui/cocoa/tabs/tab_controller_target.h" |
| 10 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" | 10 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
| 11 #import "chrome/browser/ui/cocoa/themed_window.h" | 11 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 12 #include "chrome/browser/ui/title_prefix_matcher.h" |
| 12 #import "chrome/common/extensions/extension.h" | 13 #import "chrome/common/extensions/extension.h" |
| 13 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 14 #import "third_party/GTM/AppKit/GTMFadeTruncatingTextFieldCell.h" | 15 #import "third_party/GTM/AppKit/GTMFadeTruncatingTextFieldCell.h" |
| 15 #include "ui/base/l10n/l10n_util_mac.h" | 16 #include "ui/base/l10n/l10n_util_mac.h" |
| 16 | 17 |
| 17 @implementation TabController | 18 @implementation TabController |
| 18 | 19 |
| 19 @synthesize action = action_; | 20 @synthesize action = action_; |
| 20 @synthesize app = app_; | 21 @synthesize app = app_; |
| 21 @synthesize loadingState = loadingState_; | 22 @synthesize loadingState = loadingState_; |
| 22 @synthesize mini = mini_; | 23 @synthesize mini = mini_; |
| 23 @synthesize pinned = pinned_; | 24 @synthesize pinned = pinned_; |
| 24 @synthesize target = target_; | 25 @synthesize target = target_; |
| 26 @synthesize url = url_; |
| 25 @synthesize iconView = iconView_; | 27 @synthesize iconView = iconView_; |
| 26 @synthesize titleView = titleView_; | 28 @synthesize titleView = titleView_; |
| 27 @synthesize closeButton = closeButton_; | 29 @synthesize closeButton = closeButton_; |
| 28 | 30 |
| 29 namespace TabControllerInternal { | 31 namespace TabControllerInternal { |
| 30 | 32 |
| 31 // A C++ delegate that handles enabling/disabling menu items and handling when | 33 // A C++ delegate that handles enabling/disabling menu items and handling when |
| 32 // a menu command is chosen. Also fixes up the menu item label for "pin/unpin | 34 // a menu command is chosen. Also fixes up the menu item label for "pin/unpin |
| 33 // tab". | 35 // tab". |
| 34 class MenuDelegate : public ui::SimpleMenuModel::Delegate { | 36 class MenuDelegate : public ui::SimpleMenuModel::Delegate { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 return [[self target] performSelector:@selector(inRapidClosureMode)] ? | 303 return [[self target] performSelector:@selector(inRapidClosureMode)] ? |
| 302 YES : NO; | 304 YES : NO; |
| 303 } | 305 } |
| 304 return NO; | 306 return NO; |
| 305 } | 307 } |
| 306 | 308 |
| 307 - (void)setTitleCommonPrefixLength:(NSUInteger)length { | 309 - (void)setTitleCommonPrefixLength:(NSUInteger)length { |
| 308 DCHECK([[titleView_ cell] isKindOfClass: | 310 DCHECK([[titleView_ cell] isKindOfClass: |
| 309 [GTMFadeTruncatingTextFieldCell class]]); | 311 [GTMFadeTruncatingTextFieldCell class]]); |
| 310 GTMFadeTruncatingTextFieldCell* cell = [titleView_ cell]; | 312 GTMFadeTruncatingTextFieldCell* cell = [titleView_ cell]; |
| 311 [cell setDesiredCharactersToTruncateFromHead:length]; | 313 [cell setDesiredCharactersToTruncateFromHead:length - |
| 312 [cell setTruncateMode:length > 0 ? GTMFadeTruncatingHeadAndTail : | 314 TitlePrefixMatcher::kCommonCharsToShow]; |
| 313 GTMFadeTruncatingTail]; | 315 [cell setTruncateMode:length > TitlePrefixMatcher::kMinElidingLength ? |
| 316 GTMFadeTruncatingHeadAndTail : GTMFadeTruncatingTail]; |
| 314 } | 317 } |
| 315 | 318 |
| 316 @end | 319 @end |
| OLD | NEW |