| Index: ios/chrome/browser/ui/popup_menu/popup_menu_view.mm
|
| diff --git a/ios/chrome/browser/ui/popup_menu/popup_menu_view.mm b/ios/chrome/browser/ui/popup_menu/popup_menu_view.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4115e90cefc02db2aa522e836f5c95ec77ae706b
|
| --- /dev/null
|
| +++ b/ios/chrome/browser/ui/popup_menu/popup_menu_view.mm
|
| @@ -0,0 +1,63 @@
|
| +// Copyright 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#import "ios/chrome/browser/ui/popup_menu/popup_menu_view.h"
|
| +
|
| +#import <QuartzCore/QuartzCore.h>
|
| +
|
| +#include "base/mac/scoped_nsobject.h"
|
| +
|
| +namespace {
|
| +// The image edge insets for popup_background.png.
|
| +NS_INLINE UIEdgeInsets PopupBackgroundInsets() {
|
| + return UIEdgeInsetsMake(28, 28, 28, 28);
|
| +}
|
| +};
|
| +
|
| +@implementation PopupMenuView {
|
| + base::scoped_nsobject<UIImageView> imageView_;
|
| +}
|
| +
|
| +@synthesize delegate = delegate_;
|
| +
|
| +- (instancetype)initWithFrame:(CGRect)frame {
|
| + self = [super initWithFrame:frame];
|
| + if (self)
|
| + [self commonInitialization];
|
| +
|
| + return self;
|
| +}
|
| +
|
| +- (instancetype)initWithCoder:(NSCoder*)aDecoder {
|
| + self = [super initWithCoder:aDecoder];
|
| + if (self)
|
| + [self commonInitialization];
|
| +
|
| + return self;
|
| +}
|
| +
|
| +- (void)commonInitialization {
|
| + UIImage* image = [UIImage imageNamed:@"popup_background"];
|
| + image = [image resizableImageWithCapInsets:PopupBackgroundInsets()];
|
| +
|
| + imageView_.reset([[UIImageView alloc] initWithImage:image]);
|
| + [self addSubview:imageView_];
|
| +}
|
| +
|
| +- (void)layoutSubviews {
|
| + [super layoutSubviews];
|
| + [imageView_ setFrame:[self bounds]];
|
| +}
|
| +
|
| +- (BOOL)accessibilityPerformEscape {
|
| + if (delegate_) {
|
| + [delegate_ dismissPopupMenu];
|
| + UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification,
|
| + nil);
|
| + return YES;
|
| + }
|
| + return NO;
|
| +}
|
| +
|
| +@end
|
|
|