OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 #import <Carbon/Carbon.h> // kVK_Return. | 6 #import <Carbon/Carbon.h> // kVK_Return. |
7 | 7 |
8 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" | 8 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" |
9 | 9 |
10 #include "base/mac/bundle_locations.h" | 10 #include "base/mac/bundle_locations.h" |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
694 [profileNameTextField_ setTarget:self]; | 694 [profileNameTextField_ setTarget:self]; |
695 [profileNameTextField_ setAction:@selector(saveProfileName:)]; | 695 [profileNameTextField_ setAction:@selector(saveProfileName:)]; |
696 | 696 |
697 // Hide the textfield until the user clicks on the button. | 697 // Hide the textfield until the user clicks on the button. |
698 [profileNameTextField_ setHidden:YES]; | 698 [profileNameTextField_ setHidden:YES]; |
699 | 699 |
700 [[self cell] accessibilitySetOverrideValue:l10n_util::GetNSStringF( | 700 [[self cell] accessibilitySetOverrideValue:l10n_util::GetNSStringF( |
701 IDS_PROFILES_NEW_AVATAR_MENU_EDIT_NAME_ACCESSIBLE_NAME, | 701 IDS_PROFILES_NEW_AVATAR_MENU_EDIT_NAME_ACCESSIBLE_NAME, |
702 base::SysNSStringToUTF16(profileName)) | 702 base::SysNSStringToUTF16(profileName)) |
703 forAttribute:NSAccessibilityTitleAttribute]; | 703 forAttribute:NSAccessibilityTitleAttribute]; |
704 | |
705 NSSize textSize = [profileName sizeWithAttributes: | |
706 @{NSFontAttributeName: [profileNameTextField_ font]}]; | |
707 | |
708 if (textSize.width > frameRect.size.width - [hoverImage size].width * 2) { | |
noms (inactive)
2015/02/23 22:16:34
nit: no {}, only 2 spaces indent on the second lin
wesleylancel
2015/02/23 22:45:47
Done.
| |
709 [self setToolTip:profileName]; | |
710 } | |
704 } | 711 } |
705 | 712 |
706 [[self cell] accessibilitySetOverrideValue:NSAccessibilityButtonRole | 713 [[self cell] accessibilitySetOverrideValue:NSAccessibilityButtonRole |
707 forAttribute:NSAccessibilityRoleAttribute]; | 714 forAttribute:NSAccessibilityRoleAttribute]; |
708 [[self cell] | 715 [[self cell] |
709 accessibilitySetOverrideValue:NSAccessibilityRoleDescription( | 716 accessibilitySetOverrideValue:NSAccessibilityRoleDescription( |
710 NSAccessibilityButtonRole, nil) | 717 NSAccessibilityButtonRole, nil) |
711 forAttribute:NSAccessibilityRoleDescriptionAttribute]; | 718 forAttribute:NSAccessibilityRoleDescriptionAttribute]; |
712 | 719 |
713 [self setBordered:NO]; | 720 [self setBordered:NO]; |
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1798 | 1805 |
1799 [profileButton setDefaultImage:CreateProfileImage( | 1806 [profileButton setDefaultImage:CreateProfileImage( |
1800 itemIcon, kSmallImageSide).ToNSImage()]; | 1807 itemIcon, kSmallImageSide).ToNSImage()]; |
1801 [profileButton setImagePosition:NSImageLeft]; | 1808 [profileButton setImagePosition:NSImageLeft]; |
1802 [profileButton setAlignment:NSLeftTextAlignment]; | 1809 [profileButton setAlignment:NSLeftTextAlignment]; |
1803 [profileButton setBordered:NO]; | 1810 [profileButton setBordered:NO]; |
1804 [profileButton setTag:itemIndex]; | 1811 [profileButton setTag:itemIndex]; |
1805 [profileButton setTarget:self]; | 1812 [profileButton setTarget:self]; |
1806 [profileButton setAction:@selector(switchToProfile:)]; | 1813 [profileButton setAction:@selector(switchToProfile:)]; |
1807 | 1814 |
1815 NSSize textSize = [[profileButton title] sizeWithAttributes: | |
1816 @{NSFontAttributeName: [profileButton font]}]; | |
1817 | |
1818 if (lroundf(textSize.width) > | |
1819 rect.size.width - kSmallImageSide - | |
noms (inactive)
2015/02/23 22:16:34
nit: move the thing on the right hand side of the
wesleylancel
2015/02/23 22:45:47
Done.
| |
1820 kImageTitleSpacing - kHorizontalSpacing) { | |
1821 [profileButton setToolTip:[profileButton title]]; | |
noms (inactive)
2015/02/23 22:16:34
nit: only indent 2 spaces
wesleylancel
2015/02/23 22:45:48
Done.
| |
1822 } | |
1823 | |
1808 return profileButton.autorelease(); | 1824 return profileButton.autorelease(); |
1809 } | 1825 } |
1810 | 1826 |
1811 - (NSView*)createOptionsViewWithRect:(NSRect)rect | 1827 - (NSView*)createOptionsViewWithRect:(NSRect)rect |
1812 displayLock:(BOOL)displayLock { | 1828 displayLock:(BOOL)displayLock { |
1813 NSRect viewRect = NSMakeRect(0, 0, | 1829 NSRect viewRect = NSMakeRect(0, 0, |
1814 rect.size.width, | 1830 rect.size.width, |
1815 kBlueButtonHeight + kSmallVerticalSpacing); | 1831 kBlueButtonHeight + kSmallVerticalSpacing); |
1816 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); | 1832 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); |
1817 | 1833 |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2284 } | 2300 } |
2285 | 2301 |
2286 - (bool)shouldShowGoIncognito { | 2302 - (bool)shouldShowGoIncognito { |
2287 bool incognitoAvailable = | 2303 bool incognitoAvailable = |
2288 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2304 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
2289 IncognitoModePrefs::DISABLED; | 2305 IncognitoModePrefs::DISABLED; |
2290 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 2306 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
2291 } | 2307 } |
2292 | 2308 |
2293 @end | 2309 @end |
OLD | NEW |