OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ios/chrome/browser/ui/icons/chrome_icon.h" | 5 #import "ios/chrome/browser/ui/icons/chrome_icon.h" |
6 | 6 |
7 #import <CoreGraphics/CoreGraphics.h> | 7 #import <CoreGraphics/CoreGraphics.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #import "base/mac/scoped_nsobject.h" | |
11 #include "ios/chrome/grit/ios_strings.h" | 10 #include "ios/chrome/grit/ios_strings.h" |
12 #include "ui/base/l10n/l10n_util_mac.h" | 11 #include "ui/base/l10n/l10n_util_mac.h" |
13 | 12 |
| 13 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 14 #error "This file requires ARC support." |
| 15 #endif |
| 16 |
14 namespace { | 17 namespace { |
15 | 18 |
16 NSString* AccessibilityLabelForIconNamed(NSString* name) { | 19 NSString* AccessibilityLabelForIconNamed(NSString* name) { |
17 if ([name isEqualToString:@"ic_arrow_back"]) | 20 if ([name isEqualToString:@"ic_arrow_back"]) |
18 return l10n_util::GetNSString(IDS_IOS_ICON_ARROW_BACK); | 21 return l10n_util::GetNSString(IDS_IOS_ICON_ARROW_BACK); |
19 if ([name isEqualToString:@"ic_close"]) | 22 if ([name isEqualToString:@"ic_close"]) |
20 return l10n_util::GetNSString(IDS_IOS_ICON_CLOSE); | 23 return l10n_util::GetNSString(IDS_IOS_ICON_CLOSE); |
21 if ([name isEqualToString:@"ic_info"]) | 24 if ([name isEqualToString:@"ic_info"]) |
22 return l10n_util::GetNSString(IDS_IOS_ICON_INFO); | 25 return l10n_util::GetNSString(IDS_IOS_ICON_INFO); |
23 if ([name isEqualToString:@"ic_search"]) | 26 if ([name isEqualToString:@"ic_search"]) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 + (UIImage*)chevronIcon { | 69 + (UIImage*)chevronIcon { |
67 return ImageFlippedForRightToLeftLayoutDirection( | 70 return ImageFlippedForRightToLeftLayoutDirection( |
68 IconNamed(@"ic_chevron_right")); | 71 IconNamed(@"ic_chevron_right")); |
69 } | 72 } |
70 | 73 |
71 + (UIBarButtonItem*)templateBarButtonItemWithImage:(UIImage*)image | 74 + (UIBarButtonItem*)templateBarButtonItemWithImage:(UIImage*)image |
72 target:(id)target | 75 target:(id)target |
73 action:(SEL)action { | 76 action:(SEL)action { |
74 UIImage* templateImage = | 77 UIImage* templateImage = |
75 [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; | 78 [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; |
76 base::scoped_nsobject<UIBarButtonItem> barButtonItem([[UIBarButtonItem alloc] | 79 UIBarButtonItem* barButtonItem = |
77 initWithImage:templateImage | 80 [[UIBarButtonItem alloc] initWithImage:templateImage |
78 style:UIBarButtonItemStylePlain | 81 style:UIBarButtonItemStylePlain |
79 target:target | 82 target:target |
80 action:action]); | 83 action:action]; |
81 [barButtonItem setAccessibilityIdentifier:image.accessibilityIdentifier]; | 84 [barButtonItem setAccessibilityIdentifier:image.accessibilityIdentifier]; |
82 [barButtonItem setAccessibilityLabel:image.accessibilityLabel]; | 85 [barButtonItem setAccessibilityLabel:image.accessibilityLabel]; |
83 return barButtonItem.autorelease(); | 86 return barButtonItem; |
84 } | 87 } |
85 | 88 |
86 @end | 89 @end |
OLD | NEW |