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

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

Issue 325203003: Turn off accessibility access to notification images. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« no previous file with comments | « no previous file | 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 (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/notification_controller.h" 5 #import "ui/message_center/cocoa/notification_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 196 }
197 [super accessibilityPerformAction:action]; 197 [super accessibilityPerformAction:action];
198 } 198 }
199 @end 199 @end
200 200
201 //////////////////////////////////////////////////////////////////////////////// 201 ////////////////////////////////////////////////////////////////////////////////
202 202
203 @interface AccessibilityIgnoredBox : NSBox 203 @interface AccessibilityIgnoredBox : NSBox
204 @end 204 @end
205 205
206 // Ignore this element, but expose its children to accessibility.
206 @implementation AccessibilityIgnoredBox 207 @implementation AccessibilityIgnoredBox
207 - (BOOL)accessibilityIsIgnored { 208 - (BOOL)accessibilityIsIgnored {
208 return YES; 209 return YES;
209 } 210 }
211
212 // Pretend this element has no children.
213 // TODO(petewil): Until we have alt text available, we will hide the children of
214 // the box also. Remove this override once alt text is set (by using
215 // NSAccessibilityDescriptionAttribute).
216 -(id) accessibilityAttributeValue:(NSString*) attribute {
Robert Sesek 2014/06/11 21:37:04 nit: space after - but not after )
Robert Sesek 2014/06/11 21:37:04 nit: no space after ) in arguments
Pete Williamson 2014/06/11 22:12:54 Done.
Pete Williamson 2014/06/11 22:12:54 Done.
217 // If we get a request for NSAccessibilityChildrenAttribute, return an empty
218 // array to pretend we have no children.
219 if ([attribute isEqualToString:NSAccessibilityChildrenAttribute])
220 return [[[NSMutableArray alloc] init] autorelease];
Robert Sesek 2014/06/11 21:37:04 nit: use [NSMutableArray array], or if it does not
Pete Williamson 2014/06/11 22:12:54 Done.
221 else
222 return [super accessibilityAttributeValue:attribute];
223 }
210 @end 224 @end
211 225
212 //////////////////////////////////////////////////////////////////////////////// 226 ////////////////////////////////////////////////////////////////////////////////
213 227
214 @interface MCNotificationController (Private) 228 @interface MCNotificationController (Private)
215 // Configures a NSBox to be borderless, titleless, and otherwise appearance- 229 // Configures a NSBox to be borderless, titleless, and otherwise appearance-
216 // free. 230 // free.
217 - (void)configureCustomBox:(NSBox*)box; 231 - (void)configureCustomBox:(NSBox*)box;
218 232
219 // Initializes the icon_ ivar and returns the view to insert into the hierarchy. 233 // Initializes the icon_ ivar and returns the view to insert into the hierarchy.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 message_center::kNotificationBackgroundColor)]; 304 message_center::kNotificationBackgroundColor)];
291 [self setView:rootView]; 305 [self setView:rootView];
292 306
293 [rootView addSubview:[self createIconView]]; 307 [rootView addSubview:[self createIconView]];
294 308
295 // Create the close button. 309 // Create the close button.
296 [self configureCloseButtonInFrame:rootFrame]; 310 [self configureCloseButtonInFrame:rootFrame];
297 [rootView addSubview:closeButton_]; 311 [rootView addSubview:closeButton_];
298 312
299 // Create the small image. 313 // Create the small image.
300 [self configureSmallImageInFrame:rootFrame]; 314 [rootView addSubview:[self createSmallImageInFrame:rootFrame]];
301 [[self view] addSubview:smallImage_];
302 315
303 NSRect contentFrame = [self currentContentRect]; 316 NSRect contentFrame = [self currentContentRect];
304 317
305 // Create the title. 318 // Create the title.
306 [self configureTitleInFrame:contentFrame]; 319 [self configureTitleInFrame:contentFrame];
307 [rootView addSubview:title_]; 320 [rootView addSubview:title_];
308 321
309 // Create the message body. 322 // Create the message body.
310 [self configureBodyInFrame:contentFrame]; 323 [self configureBodyInFrame:contentFrame];
311 [rootView addSubview:message_]; 324 [rootView addSubview:message_];
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 [closeButton_ setAction:@selector(close:)]; 738 [closeButton_ setAction:@selector(close:)];
726 [[closeButton_ cell] 739 [[closeButton_ cell]
727 accessibilitySetOverrideValue:NSAccessibilityCloseButtonSubrole 740 accessibilitySetOverrideValue:NSAccessibilityCloseButtonSubrole
728 forAttribute:NSAccessibilitySubroleAttribute]; 741 forAttribute:NSAccessibilitySubroleAttribute];
729 [[closeButton_ cell] 742 [[closeButton_ cell]
730 accessibilitySetOverrideValue: 743 accessibilitySetOverrideValue:
731 l10n_util::GetNSString(IDS_APP_ACCNAME_CLOSE) 744 l10n_util::GetNSString(IDS_APP_ACCNAME_CLOSE)
732 forAttribute:NSAccessibilityTitleAttribute]; 745 forAttribute:NSAccessibilityTitleAttribute];
733 } 746 }
734 747
735 - (void)configureSmallImageInFrame:(NSRect)rootFrame { 748 - (NSView*)createSmallImageInFrame:(NSRect)rootFrame {
736 int smallImageXOffset = 749 int smallImageXOffset =
737 message_center::kSmallImagePadding + message_center::kSmallImageSize; 750 message_center::kSmallImagePadding + message_center::kSmallImageSize;
738 NSRect smallImageFrame = 751 NSRect smallImageFrame =
739 NSMakeRect(NSMaxX(rootFrame) - smallImageXOffset, 752 NSMakeRect(NSMaxX(rootFrame) - smallImageXOffset,
740 NSMinY(rootFrame) + message_center::kSmallImagePadding, 753 NSMinY(rootFrame) + message_center::kSmallImagePadding,
741 message_center::kSmallImageSize, 754 message_center::kSmallImageSize,
742 message_center::kSmallImageSize); 755 message_center::kSmallImageSize);
756
757 // Put the smallImage inside another box which can hide it from accessibility
758 // until we have some alt text to go with it. Once we have alt text, remove
759 // the box, and set NSAccessibilityDescriptionAttribute with it.
760 base::scoped_nsobject<NSBox> imageBox(
761 [[AccessibilityIgnoredBox alloc] initWithFrame:smallImageFrame]);
762 [self configureCustomBox:imageBox];
763 [imageBox setAutoresizingMask:NSViewMinYMargin];
743 smallImage_.reset([[NSImageView alloc] initWithFrame:smallImageFrame]); 764 smallImage_.reset([[NSImageView alloc] initWithFrame:smallImageFrame]);
Robert Sesek 2014/06/11 21:37:04 Is this frame still correct? Since it's no longer
Pete Williamson 2014/06/11 22:12:54 The imageBox is supposed to be the same size and p
Robert Sesek 2014/06/12 13:31:10 Unless I'm misreading the code, it's not quite the
Pete Williamson 2014/06/12 17:29:04 Ah, I see. The code I cut and pasted worked since
744 [smallImage_ setImageScaling:NSImageScaleProportionallyUpOrDown]; 765 [smallImage_ setImageScaling:NSImageScaleProportionallyUpOrDown];
745 [smallImage_ setAutoresizingMask:NSViewMinYMargin]; 766 [imageBox setContentView:smallImage_];
767
768 return imageBox.autorelease();
746 } 769 }
747 770
748 - (void)configureTitleInFrame:(NSRect)contentFrame { 771 - (void)configureTitleInFrame:(NSRect)contentFrame {
749 contentFrame.size.height = 0; 772 contentFrame.size.height = 0;
750 title_.reset([self newLabelWithFrame:contentFrame]); 773 title_.reset([self newLabelWithFrame:contentFrame]);
751 [title_ setAutoresizingMask:NSViewMinYMargin]; 774 [title_ setAutoresizingMask:NSViewMinYMargin];
752 [title_ setTextColor:gfx::SkColorToCalibratedNSColor( 775 [title_ setTextColor:gfx::SkColorToCalibratedNSColor(
753 message_center::kRegularTextColor)]; 776 message_center::kRegularTextColor)];
754 [title_ setFont:[NSFont messageFontOfSize:message_center::kTitleFontSize]]; 777 [title_ setFont:[NSFont messageFontOfSize:message_center::kTitleFontSize]];
755 } 778 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 forFont:(NSFont*)nsfont 869 forFont:(NSFont*)nsfont
847 maxNumberOfLines:(size_t)lines { 870 maxNumberOfLines:(size_t)lines {
848 size_t unused; 871 size_t unused;
849 return [self wrapText:text 872 return [self wrapText:text
850 forFont:nsfont 873 forFont:nsfont
851 maxNumberOfLines:lines 874 maxNumberOfLines:lines
852 actualLines:&unused]; 875 actualLines:&unused];
853 } 876 }
854 877
855 @end 878 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698