OLD | NEW |
1 // Copyright (c) 2010 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 "app/l10n_util_mac.h" | 9 #include "app/l10n_util_mac.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "base/mac/mac_util.h" | 11 #include "base/mac/mac_util.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 NSImage* logoImage = | 198 NSImage* logoImage = |
199 ResourceBundle::GetSharedInstance().GetNativeImageNamed(logoId); | 199 ResourceBundle::GetSharedInstance().GetNativeImageNamed(logoId); |
200 NSRect logoBounds = NSZeroRect; | 200 NSRect logoBounds = NSZeroRect; |
201 logoBounds.size = [logoImage size]; | 201 logoBounds.size = [logoImage size]; |
202 NSImageView* logoView = | 202 NSImageView* logoView = |
203 [[[NSImageView alloc] initWithFrame:logoBounds] autorelease]; | 203 [[[NSImageView alloc] initWithFrame:logoBounds] autorelease]; |
204 [logoView setImage:logoImage]; | 204 [logoView setImage:logoImage]; |
205 [logoView setEditable:NO]; | 205 [logoView setEditable:NO]; |
206 | 206 |
207 // Tooltip text provides accessibility. | 207 // Tooltip text provides accessibility. |
208 [logoView setToolTip:base::SysWideToNSString(engine->short_name())]; | 208 [logoView setToolTip:base::SysUTF16ToNSString(engine->short_name())]; |
209 engineIdentifier = logoView; | 209 engineIdentifier = logoView; |
210 } else { | 210 } else { |
211 // No logo -- we must show a text label. | 211 // No logo -- we must show a text label. |
212 NSRect labelBounds = NSMakeRect(0, 0, kLogoLabelWidth, kLogoLabelHeight); | 212 NSRect labelBounds = NSMakeRect(0, 0, kLogoLabelWidth, kLogoLabelHeight); |
213 NSTextField* labelField = | 213 NSTextField* labelField = |
214 [[[NSTextField alloc] initWithFrame:labelBounds] autorelease]; | 214 [[[NSTextField alloc] initWithFrame:labelBounds] autorelease]; |
215 [labelField setBezeled:NO]; | 215 [labelField setBezeled:NO]; |
216 [labelField setEditable:NO]; | 216 [labelField setEditable:NO]; |
217 [labelField setSelectable:NO]; | 217 [labelField setSelectable:NO]; |
218 | 218 |
219 scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( | 219 scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( |
220 [[NSMutableParagraphStyle alloc] init]); | 220 [[NSMutableParagraphStyle alloc] init]); |
221 [paragraphStyle setAlignment:NSCenterTextAlignment]; | 221 [paragraphStyle setAlignment:NSCenterTextAlignment]; |
222 NSDictionary* attrs = [NSDictionary dictionaryWithObjectsAndKeys: | 222 NSDictionary* attrs = [NSDictionary dictionaryWithObjectsAndKeys: |
223 [NSFont boldSystemFontOfSize:13], NSFontAttributeName, | 223 [NSFont boldSystemFontOfSize:13], NSFontAttributeName, |
224 paragraphStyle.get(), NSParagraphStyleAttributeName, | 224 paragraphStyle.get(), NSParagraphStyleAttributeName, |
225 nil]; | 225 nil]; |
226 | 226 |
227 NSString* value = base::SysWideToNSString(engine->short_name()); | 227 NSString* value = base::SysUTF16ToNSString(engine->short_name()); |
228 scoped_nsobject<NSAttributedString> attrValue( | 228 scoped_nsobject<NSAttributedString> attrValue( |
229 [[NSAttributedString alloc] initWithString:value | 229 [[NSAttributedString alloc] initWithString:value |
230 attributes:attrs]); | 230 attributes:attrs]); |
231 | 231 |
232 [labelField setAttributedStringValue:attrValue.get()]; | 232 [labelField setAttributedStringValue:attrValue.get()]; |
233 | 233 |
234 engineIdentifier = labelField; | 234 engineIdentifier = labelField; |
235 } | 235 } |
236 | 236 |
237 // Make the "Choose" button. | 237 // Make the "Choose" button. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 - (NSFont*)mainLabelFont { | 275 - (NSFont*)mainLabelFont { |
276 return [NSFont boldSystemFontOfSize:13]; | 276 return [NSFont boldSystemFontOfSize:13]; |
277 } | 277 } |
278 | 278 |
279 - (IBAction)searchEngineSelected:(id)sender { | 279 - (IBAction)searchEngineSelected:(id)sender { |
280 [[self window] close]; | 280 [[self window] close]; |
281 [NSApp stopModalWithCode:[sender tag]]; | 281 [NSApp stopModalWithCode:[sender tag]]; |
282 } | 282 } |
283 | 283 |
284 @end | 284 @end |
OLD | NEW |