| Index: ios/chrome/browser/ui/context_menu/context_menu_controller.mm
|
| diff --git a/ui/base/ios/cru_context_menu_controller.mm b/ios/chrome/browser/ui/context_menu/context_menu_controller.mm
|
| similarity index 79%
|
| copy from ui/base/ios/cru_context_menu_controller.mm
|
| copy to ios/chrome/browser/ui/context_menu/context_menu_controller.mm
|
| index d052c99070ab2279a09499754d79e07bb9e327c6..1ba2a1ea3a6ee5d39d6045ef3fa94817b582b07a 100644
|
| --- a/ui/base/ios/cru_context_menu_controller.mm
|
| +++ b/ios/chrome/browser/ui/context_menu/context_menu_controller.mm
|
| @@ -2,26 +2,26 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#import "ui/base/ios/cru_context_menu_controller.h"
|
| +#import "ios/chrome/browser/ui/context_menu/context_menu_controller.h"
|
|
|
| #include <algorithm>
|
|
|
| #include "base/ios/weak_nsobject.h"
|
| #include "base/logging.h"
|
| #import "base/mac/scoped_nsobject.h"
|
| +#import "ios/chrome/browser/ui/context_menu/context_menu_holder.h"
|
| #include "ui/base/device_form_factor.h"
|
| -#import "ui/base/ios/cru_context_menu_holder.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/strings/grit/ui_strings.h"
|
|
|
| // Abstracts system implementation of popovers and action sheets.
|
| -@protocol CRUContextMenuControllerImpl<NSObject>
|
| +@protocol ContextMenuControllerImpl<NSObject>
|
|
|
| // Whether the context menu is visible.
|
| @property(nonatomic, readonly, getter=isVisible) BOOL visible;
|
|
|
| // Displays a context menu.
|
| -- (void)showWithHolder:(CRUContextMenuHolder*)menuHolder
|
| +- (void)showWithHolder:(ContextMenuHolder*)menuHolder
|
| atPoint:(CGPoint)localPoint
|
| inView:(UIView*)view;
|
|
|
| @@ -31,9 +31,8 @@
|
|
|
| @end
|
|
|
| -// Backs up CRUContextMenuController by using UIAlertController.
|
| -@interface CRUAlertController : NSObject<CRUContextMenuControllerImpl> {
|
| - // Weak underlying UIAlertController.
|
| +// Backs up ContextMenuController by using UIAlertController.
|
| +@interface AlertController : NSObject<ContextMenuControllerImpl> {
|
| base::WeakNSObject<UIAlertController> _alert;
|
| }
|
| // Redefined to readwrite.
|
| @@ -41,9 +40,8 @@
|
| @end
|
|
|
| // Displays a context menu. Implements Bridge pattern.
|
| -@implementation CRUContextMenuController {
|
| - // Implementation specific for iOS version.
|
| - base::scoped_nsprotocol<id<CRUContextMenuControllerImpl>> _impl;
|
| +@implementation ContextMenuController {
|
| + base::scoped_nsprotocol<id<ContextMenuControllerImpl>> _impl;
|
| }
|
|
|
| - (BOOL)isVisible {
|
| @@ -53,7 +51,7 @@
|
| - (instancetype)init {
|
| self = [super init];
|
| if (self) {
|
| - _impl.reset([[CRUAlertController alloc] init]);
|
| + _impl.reset([[AlertController alloc] init]);
|
| }
|
| return self;
|
| }
|
| @@ -63,7 +61,7 @@
|
| [super dealloc];
|
| }
|
|
|
| -- (void)showWithHolder:(CRUContextMenuHolder*)menuHolder
|
| +- (void)showWithHolder:(ContextMenuHolder*)menuHolder
|
| atPoint:(CGPoint)point
|
| inView:(UIView*)view {
|
| DCHECK(menuHolder.itemCount);
|
| @@ -81,10 +79,10 @@
|
|
|
| @end
|
|
|
| -@implementation CRUAlertController
|
| +@implementation AlertController
|
| @synthesize visible = _visible;
|
|
|
| -- (CGSize)sizeForTitleThatFitsMenuWithHolder:(CRUContextMenuHolder*)menuHolder
|
| +- (CGSize)sizeForTitleThatFitsMenuWithHolder:(ContextMenuHolder*)menuHolder
|
| atPoint:(CGPoint)point
|
| inView:(UIView*)view {
|
| // Presenting and dismissing a dummy UIAlertController flushes a screen.
|
| @@ -99,7 +97,7 @@
|
| return CGSizeMake(kAvailableWidth, kAvailableHeightPhone);
|
| }
|
|
|
| -- (void)showWithHolder:(CRUContextMenuHolder*)menuHolder
|
| +- (void)showWithHolder:(ContextMenuHolder*)menuHolder
|
| atPoint:(CGPoint)point
|
| inView:(UIView*)view {
|
| UIAlertController* alert = [UIAlertController
|
| @@ -111,10 +109,9 @@
|
| CGRectMake(point.x, point.y, 1.0, 1.0);
|
|
|
| // Add the actions.
|
| - base::WeakNSObject<CRUAlertController> weakSelf(self);
|
| - [menuHolder.itemTitles enumerateObjectsUsingBlock:^(NSString* itemTitle,
|
| - NSUInteger itemIndex,
|
| - BOOL*) {
|
| + base::WeakNSObject<AlertController> weakSelf(self);
|
| + [menuHolder.itemTitles enumerateObjectsUsingBlock:^(
|
| + NSString* itemTitle, NSUInteger itemIndex, BOOL*) {
|
| void (^actionHandler)(UIAlertAction*) = ^(UIAlertAction* action) {
|
| [menuHolder performActionAtIndex:itemIndex];
|
| [weakSelf setVisible:NO];
|
|
|