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

Side by Side Diff: chrome/browser/ui/cocoa/search_engine_dialog_controller.mm

Issue 7982018: Add more descriptive labels for views in Mac's first run dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial patch. Created 9 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 | 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) 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 #import "chrome/browser/ui/cocoa/search_engine_dialog_controller.h" 5 #import "chrome/browser/ui/cocoa/search_engine_dialog_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 atIndex:(size_t)index { 189 atIndex:(size_t)index {
190 bool useImages = false; 190 bool useImages = false;
191 #if defined(GOOGLE_CHROME_BUILD) 191 #if defined(GOOGLE_CHROME_BUILD)
192 useImages = true; 192 useImages = true;
193 #endif 193 #endif
194 194
195 // Make the engine identifier. 195 // Make the engine identifier.
196 NSView* engineIdentifier = nil; // either the logo or the text label 196 NSView* engineIdentifier = nil; // either the logo or the text label
197 197
198 int logoId = engine->logo_id(); 198 int logoId = engine->logo_id();
199 NSString* shortName = SysUTF16ToNSString(engine->short_name());
199 if (useImages && logoId > 0) { 200 if (useImages && logoId > 0) {
200 NSImage* logoImage = 201 NSImage* logoImage =
201 ResourceBundle::GetSharedInstance().GetNativeImageNamed(logoId); 202 ResourceBundle::GetSharedInstance().GetNativeImageNamed(logoId);
202 NSRect logoBounds = NSZeroRect; 203 NSRect logoBounds = NSZeroRect;
203 logoBounds.size = [logoImage size]; 204 logoBounds.size = [logoImage size];
204 NSImageView* logoView = 205 NSImageView* logoView =
205 [[[NSImageView alloc] initWithFrame:logoBounds] autorelease]; 206 [[[NSImageView alloc] initWithFrame:logoBounds] autorelease];
206 [logoView setImage:logoImage]; 207 [logoView setImage:logoImage];
207 [logoView setEditable:NO]; 208 [logoView setEditable:NO];
208 209
209 // Tooltip text provides accessibility. 210 // Tooltip text provides accessibility.
210 [logoView setToolTip:base::SysUTF16ToNSString(engine->short_name())]; 211 [logoView setToolTip:shortName];
212 [logoView accessibilitySetOverrideValue:shortName
213 forAttribute:NSAccessibilityDescriptionAttribute];
211 engineIdentifier = logoView; 214 engineIdentifier = logoView;
212 } else { 215 } else {
213 // No logo -- we must show a text label. 216 // No logo -- we must show a text label.
214 NSRect labelBounds = NSMakeRect(0, 0, kLogoLabelWidth, kLogoLabelHeight); 217 NSRect labelBounds = NSMakeRect(0, 0, kLogoLabelWidth, kLogoLabelHeight);
215 NSTextField* labelField = 218 NSTextField* labelField =
216 [[[NSTextField alloc] initWithFrame:labelBounds] autorelease]; 219 [[[NSTextField alloc] initWithFrame:labelBounds] autorelease];
217 [labelField setBezeled:NO]; 220 [labelField setBezeled:NO];
218 [labelField setEditable:NO]; 221 [labelField setEditable:NO];
219 [labelField setSelectable:NO]; 222 [labelField setSelectable:NO];
220 223
221 scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( 224 scoped_nsobject<NSMutableParagraphStyle> paragraphStyle(
222 [[NSMutableParagraphStyle alloc] init]); 225 [[NSMutableParagraphStyle alloc] init]);
223 [paragraphStyle setAlignment:NSCenterTextAlignment]; 226 [paragraphStyle setAlignment:NSCenterTextAlignment];
224 NSDictionary* attrs = [NSDictionary dictionaryWithObjectsAndKeys: 227 NSDictionary* attrs = [NSDictionary dictionaryWithObjectsAndKeys:
225 [NSFont boldSystemFontOfSize:13], NSFontAttributeName, 228 [NSFont boldSystemFontOfSize:13], NSFontAttributeName,
226 paragraphStyle.get(), NSParagraphStyleAttributeName, 229 paragraphStyle.get(), NSParagraphStyleAttributeName,
227 nil]; 230 nil];
228 231
229 NSString* value = base::SysUTF16ToNSString(engine->short_name());
230 scoped_nsobject<NSAttributedString> attrValue( 232 scoped_nsobject<NSAttributedString> attrValue(
231 [[NSAttributedString alloc] initWithString:value 233 [[NSAttributedString alloc] initWithString:shortName
232 attributes:attrs]); 234 attributes:attrs]);
233 235
234 [labelField setAttributedStringValue:attrValue.get()]; 236 [labelField setAttributedStringValue:attrValue.get()];
235 237
236 engineIdentifier = labelField; 238 engineIdentifier = labelField;
237 } 239 }
238 240
239 // Make the "Choose" button. 241 // Make the "Choose" button.
240 scoped_nsobject<NSButton> chooseButton( 242 scoped_nsobject<NSButton> chooseButton(
241 [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 100, 34)]); 243 [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 100, 34)]);
242 [chooseButton setBezelStyle:NSRoundedBezelStyle]; 244 [chooseButton setBezelStyle:NSRoundedBezelStyle];
243 [[chooseButton cell] setFont:[NSFont systemFontOfSize: 245 [[chooseButton cell] setFont:[NSFont systemFontOfSize:
244 [NSFont systemFontSizeForControlSize:NSRegularControlSize]]]; 246 [NSFont systemFontSizeForControlSize:NSRegularControlSize]]];
245 [chooseButton setTitle:l10n_util::GetNSStringWithFixup(IDS_FR_SEARCH_CHOOSE)]; 247 [chooseButton setTitle:l10n_util::GetNSStringWithFixup(IDS_FR_SEARCH_CHOOSE)];
246 [GTMUILocalizerAndLayoutTweaker sizeToFitView:chooseButton.get()]; 248 [GTMUILocalizerAndLayoutTweaker sizeToFitView:chooseButton.get()];
247 [chooseButton setTag:index]; 249 [chooseButton setTag:index];
248 [chooseButton setTarget:self]; 250 [chooseButton setTarget:self];
249 [chooseButton setAction:@selector(searchEngineSelected:)]; 251 [chooseButton setAction:@selector(searchEngineSelected:)];
250 252
253 // Provide a more descriptive accessibility description.
254 id accElement = NSAccessibilityUnignoredDescendant(engineIdentifier);
255 [[chooseButton cell] accessibilitySetOverrideValue:accElement
256 forAttribute:NSAccessibilityTitleUIElementAttribute];
257
251 // Put 'em together. 258 // Put 'em together.
252 NSRect engineIdentifierFrame = [engineIdentifier frame]; 259 NSRect engineIdentifierFrame = [engineIdentifier frame];
253 NSRect chooseButtonFrame = [chooseButton frame]; 260 NSRect chooseButtonFrame = [chooseButton frame];
254 261
255 NSRect containingViewFrame = NSZeroRect; 262 NSRect containingViewFrame = NSZeroRect;
256 containingViewFrame.size.width += engineIdentifierFrame.size.width; 263 containingViewFrame.size.width += engineIdentifierFrame.size.width;
257 containingViewFrame.size.height += engineIdentifierFrame.size.height; 264 containingViewFrame.size.height += engineIdentifierFrame.size.height;
258 containingViewFrame.size.height += kLogoButtonSpacing; 265 containingViewFrame.size.height += kLogoButtonSpacing;
259 containingViewFrame.size.height += chooseButtonFrame.size.height; 266 containingViewFrame.size.height += chooseButtonFrame.size.height;
260 267
(...skipping 16 matching lines...) Expand all
277 - (NSFont*)mainLabelFont { 284 - (NSFont*)mainLabelFont {
278 return [NSFont boldSystemFontOfSize:13]; 285 return [NSFont boldSystemFontOfSize:13];
279 } 286 }
280 287
281 - (IBAction)searchEngineSelected:(id)sender { 288 - (IBAction)searchEngineSelected:(id)sender {
282 [[self window] close]; 289 [[self window] close];
283 [NSApp stopModalWithCode:[sender tag]]; 290 [NSApp stopModalWithCode:[sender tag]];
284 } 291 }
285 292
286 @end 293 @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