OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/popup_menu/popup_menu_view.h" | 5 #import "ios/chrome/browser/ui/popup_menu/popup_menu_view.h" |
6 | 6 |
7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include "base/mac/scoped_nsobject.h" | 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 10 #error "This file requires ARC support." |
| 11 #endif |
10 | 12 |
11 namespace { | 13 namespace { |
12 // The image edge insets for popup_background.png. | 14 // The image edge insets for popup_background.png. |
13 NS_INLINE UIEdgeInsets PopupBackgroundInsets() { | 15 NS_INLINE UIEdgeInsets PopupBackgroundInsets() { |
14 return UIEdgeInsetsMake(28, 28, 28, 28); | 16 return UIEdgeInsetsMake(28, 28, 28, 28); |
15 } | 17 } |
16 }; | 18 }; |
17 | 19 |
18 @implementation PopupMenuView { | 20 @implementation PopupMenuView { |
19 base::scoped_nsobject<UIImageView> imageView_; | 21 UIImageView* imageView_; |
20 } | 22 } |
21 | 23 |
22 @synthesize delegate = delegate_; | 24 @synthesize delegate = delegate_; |
23 | 25 |
24 - (instancetype)initWithFrame:(CGRect)frame { | 26 - (instancetype)initWithFrame:(CGRect)frame { |
25 self = [super initWithFrame:frame]; | 27 self = [super initWithFrame:frame]; |
26 if (self) | 28 if (self) |
27 [self commonInitialization]; | 29 [self commonInitialization]; |
28 | 30 |
29 return self; | 31 return self; |
30 } | 32 } |
31 | 33 |
32 - (instancetype)initWithCoder:(NSCoder*)aDecoder { | 34 - (instancetype)initWithCoder:(NSCoder*)aDecoder { |
33 self = [super initWithCoder:aDecoder]; | 35 self = [super initWithCoder:aDecoder]; |
34 if (self) | 36 if (self) |
35 [self commonInitialization]; | 37 [self commonInitialization]; |
36 | 38 |
37 return self; | 39 return self; |
38 } | 40 } |
39 | 41 |
40 - (void)commonInitialization { | 42 - (void)commonInitialization { |
41 UIImage* image = [UIImage imageNamed:@"popup_background"]; | 43 UIImage* image = [UIImage imageNamed:@"popup_background"]; |
42 image = [image resizableImageWithCapInsets:PopupBackgroundInsets()]; | 44 image = [image resizableImageWithCapInsets:PopupBackgroundInsets()]; |
43 | 45 |
44 imageView_.reset([[UIImageView alloc] initWithImage:image]); | 46 imageView_ = [[UIImageView alloc] initWithImage:image]; |
45 [self addSubview:imageView_]; | 47 [self addSubview:imageView_]; |
46 } | 48 } |
47 | 49 |
48 - (void)layoutSubviews { | 50 - (void)layoutSubviews { |
49 [super layoutSubviews]; | 51 [super layoutSubviews]; |
50 [imageView_ setFrame:[self bounds]]; | 52 [imageView_ setFrame:[self bounds]]; |
51 } | 53 } |
52 | 54 |
53 - (BOOL)accessibilityPerformEscape { | 55 - (BOOL)accessibilityPerformEscape { |
54 if (delegate_) { | 56 if (delegate_) { |
55 [delegate_ dismissPopupMenu]; | 57 [delegate_ dismissPopupMenu]; |
56 UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, | 58 UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, |
57 nil); | 59 nil); |
58 return YES; | 60 return YES; |
59 } | 61 } |
60 return NO; | 62 return NO; |
61 } | 63 } |
62 | 64 |
63 @end | 65 @end |
OLD | NEW |