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

Side by Side Diff: ui/message_center/cocoa/status_item_view.mm

Issue 17408004: [Mac][MC] Initial accessibility pass. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Title -> Description Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/message_center/cocoa/status_item_view.h" 5 #import "ui/message_center/cocoa/status_item_view.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 // Draw the unread count. 144 // Draw the unread count.
145 NSAttributedString* countString = [self unreadCountString]; 145 NSAttributedString* countString = [self unreadCountString];
146 if (countString) { 146 if (countString) {
147 NSPoint countPoint = NSMakePoint( 147 NSPoint countPoint = NSMakePoint(
148 NSMaxX(drawRect) + kUnreadCountPadding, kUnreadCountMinY); 148 NSMaxX(drawRect) + kUnreadCountPadding, kUnreadCountMinY);
149 [countString drawAtPoint:countPoint]; 149 [countString drawAtPoint:countPoint];
150 } 150 }
151 } 151 }
152 152
153 - (NSArray*)accessibilityActionNames {
154 return @[ NSAccessibilityPressAction ];
155 }
156
157 - (void)accessibilityPerformAction:(NSString*)action {
158 if ([action isEqualToString:NSAccessibilityPressAction]) {
159 if (callback_)
160 callback_.get()();
161 return;
162 }
163 [super accessibilityPerformAction:action];
164 }
165
153 // Private ///////////////////////////////////////////////////////////////////// 166 // Private /////////////////////////////////////////////////////////////////////
154 167
155 - (BOOL)shouldHighlight { 168 - (BOOL)shouldHighlight {
156 return highlight_ || inMouseEventSequence_; 169 return highlight_ || inMouseEventSequence_;
157 } 170 }
158 171
159 - (NSAttributedString*)unreadCountString { 172 - (NSAttributedString*)unreadCountString {
160 if (unreadCount_ == 0) 173 if (unreadCount_ == 0)
161 return nil; 174 return nil;
162 175
163 NSString* count = nil; 176 NSString* count = nil;
164 if (unreadCount_ > 9) 177 if (unreadCount_ > 9)
165 count = @"9+"; 178 count = @"9+";
166 else 179 else
167 count = [NSString stringWithFormat:@"%"PRIuS, unreadCount_]; 180 count = [NSString stringWithFormat:@"%"PRIuS, unreadCount_];
168 181
169 NSColor* fontColor = [self shouldHighlight] ? [NSColor whiteColor] 182 NSColor* fontColor = [self shouldHighlight] ? [NSColor whiteColor]
170 : [NSColor blackColor]; 183 : [NSColor blackColor];
171 NSDictionary* attributes = @{ 184 NSDictionary* attributes = @{
172 NSFontAttributeName: [NSFont fontWithName:@"Helvetica-Bold" size:12], 185 NSFontAttributeName: [NSFont fontWithName:@"Helvetica-Bold" size:12],
173 NSForegroundColorAttributeName: fontColor, 186 NSForegroundColorAttributeName: fontColor,
174 }; 187 };
175 return [[[NSAttributedString alloc] initWithString:count 188 return [[[NSAttributedString alloc] initWithString:count
176 attributes:attributes] autorelease]; 189 attributes:attributes] autorelease];
177 } 190 }
178 191
179 @end 192 @end
OLDNEW
« no previous file with comments | « ui/message_center/cocoa/notification_controller.mm ('k') | ui/message_center/cocoa/tray_view_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698