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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm

Issue 2268353003: [Mac][MD User Menu] Fixed the accessibility string of profile button (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 months 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
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
6 6
7 #import <Carbon/Carbon.h> // kVK_Return. 7 #import <Carbon/Carbon.h> // kVK_Return.
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 maxAvailableTextWidth, kVerticalSpacing); 2042 maxAvailableTextWidth, kVerticalSpacing);
2043 } 2043 }
2044 if (!NSIsEmptyRect(profileLinksBound)) { 2044 if (!NSIsEmptyRect(profileLinksBound)) {
2045 NSView* linksContainer = 2045 NSView* linksContainer =
2046 [self createCurrentProfileLinksForItem:item rect:profileLinksBound]; 2046 [self createCurrentProfileLinksForItem:item rect:profileLinksBound];
2047 [container addSubview:linksContainer]; 2047 [container addSubview:linksContainer];
2048 yOffset = NSMaxY([linksContainer frame]); 2048 yOffset = NSMaxY([linksContainer frame]);
2049 } 2049 }
2050 2050
2051 // Profile card button that contains the profile icon, name, and username. 2051 // Profile card button that contains the profile icon, name, and username.
2052 const base::string16 profileNameString =
2053 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath());
2052 NSRect rect = NSMakeRect(0, yOffset, GetFixedMenuWidth(), 2054 NSRect rect = NSMakeRect(0, yOffset, GetFixedMenuWidth(),
2053 kMdImageSide + kVerticalSpacing); 2055 kMdImageSide + kVerticalSpacing);
2054 NSButton* profileCard = 2056 NSButton* profileCard =
2055 [self hoverButtonWithRect:rect 2057 [self hoverButtonWithRect:rect
2056 text:[[NSString alloc] init] 2058 text:[[NSString alloc] init]
2057 image:CreateProfileImage(item.icon, kMdImageSide, 2059 image:CreateProfileImage(item.icon, kMdImageSide,
2058 profiles::SHAPE_CIRCLE) 2060 profiles::SHAPE_CIRCLE)
2059 action:@selector(editProfile:)]; 2061 action:@selector(editProfile:)];
2060 [[profileCard cell] setImageDimsWhenDisabled:NO]; 2062 [[profileCard cell] setImageDimsWhenDisabled:NO];
2063 if (item.signed_in) {
2064 [[profileCard cell]
2065 accessibilitySetOverrideValue:
2066 l10n_util::GetNSStringF(
2067 IDS_PROFILES_EDIT_SIGNED_IN_PROFILE_ACCESSIBLE_NAME,
2068 profileNameString, item.username)
2069 forAttribute:NSAccessibilityTitleAttribute];
2070 } else {
2071 [[profileCard cell]
2072 accessibilitySetOverrideValue:
2073 l10n_util::GetNSStringF(IDS_PROFILES_EDIT_PROFILE_ACCESSIBLE_NAME,
2074 profileNameString)
2075 forAttribute:NSAccessibilityTitleAttribute];
2076 }
2061 [container addSubview:profileCard]; 2077 [container addSubview:profileCard];
2062 if (isGuestSession_) 2078 if (isGuestSession_)
2063 [profileCard setEnabled:NO]; 2079 [profileCard setEnabled:NO];
2064 2080
2065 // Profile badge for supervised account. 2081 // Profile badge for supervised account.
2066 if (browser_->profile()->IsSupervised()) { 2082 if (browser_->profile()->IsSupervised()) {
2067 base::scoped_nsobject<NSImageView> supervisedIcon( 2083 base::scoped_nsobject<NSImageView> supervisedIcon(
2068 [[NSImageView alloc] initWithFrame:NSZeroRect]); 2084 [[NSImageView alloc] initWithFrame:NSZeroRect]);
2069 // TODO(janeliulwq): Replace the following two profile badge icons with 2085 // TODO(janeliulwq): Replace the following two profile badge icons with
2070 // smaller versions of them (24 x 24) to adapt to smaller profile icons. 2086 // smaller versions of them (24 x 24) to adapt to smaller profile icons.
2071 int imageId = browser_->profile()->IsChild() 2087 int imageId = browser_->profile()->IsChild()
2072 ? IDR_ICON_PROFILES_MENU_CHILD 2088 ? IDR_ICON_PROFILES_MENU_CHILD
2073 : IDR_ICON_PROFILES_MENU_LEGACY_SUPERVISED; 2089 : IDR_ICON_PROFILES_MENU_LEGACY_SUPERVISED;
2074 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 2090 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
2075 [supervisedIcon setImage:rb.GetNativeImageNamed(imageId).ToNSImage()]; 2091 [supervisedIcon setImage:rb.GetNativeImageNamed(imageId).ToNSImage()];
2076 2092
2077 NSSize size = [[supervisedIcon image] size]; 2093 NSSize size = [[supervisedIcon image] size];
2078 [supervisedIcon setFrameSize:size]; 2094 [supervisedIcon setFrameSize:size];
2079 const int badgeSpacing = 4; 2095 const int badgeSpacing = 4;
2080 [supervisedIcon setFrameOrigin:NSMakePoint(xOffset + kMdImageSide - 2096 [supervisedIcon setFrameOrigin:NSMakePoint(xOffset + kMdImageSide -
2081 size.width + badgeSpacing, 2097 size.width + badgeSpacing,
2082 cardYOffset + kMdImageSide - 2098 cardYOffset + kMdImageSide -
2083 size.height + badgeSpacing)]; 2099 size.height + badgeSpacing)];
2084 [profileCard addSubview:supervisedIcon]; 2100 [profileCard addSubview:supervisedIcon];
2085 } 2101 }
2086 2102
2087 // Profile name, left-aligned to the right of profile icon. 2103 // Profile name, left-aligned to the right of profile icon.
2088 xOffset += kMdImageSide + kHorizontalSpacing; 2104 xOffset += kMdImageSide + kHorizontalSpacing;
2089 CGFloat fontSize = kTextFontSize + 1.0; 2105 CGFloat fontSize = kTextFontSize + 1.0;
2090 NSTextField* profileName = BuildLabel( 2106 NSTextField* profileName =
2091 base::SysUTF16ToNSString( 2107 BuildLabel(base::SysUTF16ToNSString(profileNameString), NSZeroPoint, nil);
2092 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath())),
2093 NSZeroPoint, nil);
2094 [[profileName cell] setLineBreakMode:NSLineBreakByTruncatingTail]; 2108 [[profileName cell] setLineBreakMode:NSLineBreakByTruncatingTail];
2095 [profileName setFont:[NSFont labelFontOfSize:fontSize]]; 2109 [profileName setFont:[NSFont labelFontOfSize:fontSize]];
2096 [profileName sizeToFit]; 2110 [profileName sizeToFit];
2097 const int profileNameYOffset = 2111 const int profileNameYOffset =
2098 cardYOffset + 2112 cardYOffset +
2099 std::floor((kMdImageSide - NSHeight([profileName frame])) / 2); 2113 std::floor((kMdImageSide - NSHeight([profileName frame])) / 2);
2100 [profileName 2114 [profileName
2101 setFrame:NSMakeRect(xOffset, profileNameYOffset, availableTextWidth, 2115 setFrame:NSMakeRect(xOffset, profileNameYOffset, availableTextWidth,
2102 NSHeight([profileName frame]))]; 2116 NSHeight([profileName frame]))];
2103 [profileCard addSubview:profileName]; 2117 [profileCard addSubview:profileName];
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
2890 } 2904 }
2891 2905
2892 - (bool)shouldShowGoIncognito { 2906 - (bool)shouldShowGoIncognito {
2893 bool incognitoAvailable = 2907 bool incognitoAvailable =
2894 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2908 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2895 IncognitoModePrefs::DISABLED; 2909 IncognitoModePrefs::DISABLED;
2896 return incognitoAvailable && !browser_->profile()->IsGuestSession(); 2910 return incognitoAvailable && !browser_->profile()->IsGuestSession();
2897 } 2911 }
2898 2912
2899 @end 2913 @end
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698